Skip to content

Commit

Permalink
Merge remote-tracking branch 'remaster/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Sep 11, 2024
2 parents b6115e1 + 1aadd6e commit 9709fdd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/client/refresh/gl1/gl1_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
#define NUM_BEAM_SEGS 6

viddef_t vid;
model_t *r_worldmodel;
model_t *r_worldmodel = NULL;

float gldepthmin, gldepthmax;

glconfig_t gl_config;
glstate_t gl_state;
glconfig_t gl_config = {0};
glstate_t gl_state = {0};

image_t *r_notexture; /* use for bad textures */
image_t *r_particletexture; /* little dot for particles */
Expand Down Expand Up @@ -1781,6 +1781,11 @@ RI_Shutdown(void)
QGL_Shutdown();

R_FreeTemporaryLMBuffer();

if (gl_state.d_16to8table)
{
free(gl_state.d_16to8table);
}
}

static void
Expand Down
38 changes: 33 additions & 5 deletions src/common/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,23 +726,31 @@ int
FS_Read(void *buffer, int size, fileHandle_t f)
{
qboolean tried = false; /* Tried to read from a CD. */
byte *buf; /* Buffer. */
byte *buf, *compressed_buf; /* Buffer. */
int r; /* Number of bytes read. */
int remaining; /* Remaining bytes. */
fsHandle_t *handle; /* File handle. */

handle = FS_GetFileByHandle(f);

buf = (byte *)buffer;
compressed_buf = (byte *)buffer;

/* Read. */
if (handle->compressed_size)
{
remaining = handle->compressed_size;
if (size < handle->compressed_size)
{
/* compressed chunk bigger than provided buffer */
compressed_buf = malloc(handle->compressed_size);
buf = compressed_buf;
}
}
else
{
remaining = size;
}
buf = (byte *)buffer;

while (remaining)
{
Expand Down Expand Up @@ -784,7 +792,13 @@ FS_Read(void *buffer, int size, fileHandle_t f)
buf += r;
}

return FS_DecompressFile(buffer, size, handle);
remaining = FS_DecompressFile(compressed_buf, size, handle);
if (buffer != compressed_buf)
{
memcpy(buffer, compressed_buf, size);
free(compressed_buf);
}
return remaining;
}

/*
Expand All @@ -795,7 +809,7 @@ int
FS_FRead(void *buffer, int size, int count, fileHandle_t f)
{
qboolean tried = false; /* Tried to read from a CD. */
byte *buf; /* Buffer. */
byte *buf, *compressed_buf; /* Buffer. */
int loops; /* Loop indicator. */
int r; /* Number of bytes read. */
int remaining; /* Remaining bytes. */
Expand All @@ -806,6 +820,14 @@ FS_FRead(void *buffer, int size, int count, fileHandle_t f)
/* Read. */
loops = count;
buf = (byte *)buffer;
compressed_buf = (byte *)buffer;

if (handle->compressed_size && size < handle->compressed_size)
{
/* compressed chunk bigger than provided buffer */
compressed_buf = malloc(handle->compressed_size);
buf = compressed_buf;
}

while (loops)
{
Expand Down Expand Up @@ -861,7 +883,13 @@ FS_FRead(void *buffer, int size, int count, fileHandle_t f)
loops--;
}

return FS_DecompressFile(buffer, size, handle);
remaining = FS_DecompressFile(compressed_buf, size, handle);
if (buffer != compressed_buf)
{
memcpy(buffer, compressed_buf, size);
free(compressed_buf);
}
return remaining;
}

/*
Expand Down

0 comments on commit 9709fdd

Please sign in to comment.