Skip to content

Commit

Permalink
Merge tag 'quakespasm-0.96.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
codeflorist committed Oct 16, 2023
2 parents d5677c0 + 09e086b commit 72c82b5
Show file tree
Hide file tree
Showing 46 changed files with 227 additions and 562 deletions.
10 changes: 9 additions & 1 deletion Linux/sgml/Quakespasm.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title>QuakeSpasm
<toc>

<em>Page last edited: August 2023.</em>
<em>Page last edited: September 2023.</em>

<sect>About<p>

Expand Down Expand Up @@ -139,6 +139,14 @@ QuakeSpasm 0.94 has support for playing the 2021 re-release content: Copy the qu

<sect>Changes<p>

<sect1>Changes in 0.96.1<p>
<itemize>
<item> Fix demo recording as client-only after connection to server (was broken by signon changes in 0.96.0. Thanks to Jozsef Szalontai for issue report.)
<item> Fix potential buffer overflow in COM_Parse(), e.g. with maps with oversized 'wad' fields. (Thanks to Andrei Drexler.)
<item> Minor code cleanups.
</itemize>
</p>

<sect1>Changes in 0.96.0<p>
<itemize>
<item> <url url="https://github.com/sezero/quakespasm/pull/51" name="Adjustments"> to joystick defaults and behaviour. See the "Controller support / Cvars" section above.
Expand Down
Binary file modified MacOSX/English.lproj/InfoPlist.strings
Binary file not shown.
2 changes: 1 addition & 1 deletion MacOSX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.96.0</string>
<string>0.96.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>LSApplicationCategoryType</key>
Expand Down
Binary file modified MacOSX/codecs/lib/libmpg123.dylib
Binary file not shown.
2 changes: 1 addition & 1 deletion Quake/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const char *svc_strings[] =
"svc_backtolobby", // 55
"svc_localsound" // 56
};
#define NUM_SVC_STRINGS (sizeof(svc_strings) / sizeof(svc_strings[0]))
#define NUM_SVC_STRINGS Q_COUNTOF(svc_strings)

qboolean warn_about_nehahra_protocol; //johnfitz

Expand Down
4 changes: 2 additions & 2 deletions Quake/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Cmd_Exec_f
*/
void Cmd_Exec_f (void)
{
char *f;
const char *f;
int mark;

if (Cmd_Argc () != 2)
Expand All @@ -270,7 +270,7 @@ void Cmd_Exec_f (void)
}

mark = Hunk_LowMark ();
f = (char *)COM_LoadHunkFile (Cmd_Argv(1), NULL);
f = (const char *)COM_LoadHunkFile (Cmd_Argv(1), NULL);
if (!f && !strcmp(Cmd_Argv(1), "default.cfg")) {
f = default_cfg; /* see above.. */
}
Expand Down
84 changes: 42 additions & 42 deletions Quake/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,44 +256,19 @@ int q_strncasecmp(const char *s1, const char *s2, size_t n)
return (int)(c1 - c2);
}

//spike -- grabbed this from fte, because its useful to me
char *q_strcasestr(const char *haystack, const char *needle)
{
int c1, c2, c2f;
int i;
c2f = *needle;
if (c2f >= 'a' && c2f <= 'z')
c2f -= ('a' - 'A');
if (!c2f)
return (char*)haystack;
while (1)
const size_t len = strlen(needle);

while (*haystack)
{
c1 = *haystack;
if (!c1)
return NULL;
if (c1 >= 'a' && c1 <= 'z')
c1 -= ('a' - 'A');
if (c1 == c2f)
{
for (i = 1; ; i++)
{
c1 = haystack[i];
c2 = needle[i];
if (c1 >= 'a' && c1 <= 'z')
c1 -= ('a' - 'A');
if (c2 >= 'a' && c2 <= 'z')
c2 -= ('a' - 'A');
if (!c2)
return (char*)haystack; //end of needle means we found a complete match
if (!c1) //end of haystack means we can't possibly find needle in it any more
return NULL;
if (c1 != c2) //mismatch means no match starting at haystack[0]
break;
}
}
haystack++;
if (!q_strncasecmp(haystack, needle, len))
return (char *)haystack;

++haystack;
}
return NULL; //didn't find it

return NULL;
}

char *q_strlwr (char *str)
Expand Down Expand Up @@ -1227,12 +1202,16 @@ void COM_AddExtension (char *path, const char *extension, size_t len)

/*
==============
COM_Parse
COM_ParseEx
Parse a token out of a string
The mode argument controls how overflow is handled:
- CPE_NOTRUNC: return NULL (abort parsing)
- CPE_ALLOWTRUNC: truncate com_token (ignore the extra characters in this token)
==============
*/
const char *COM_Parse (const char *data)
const char *COM_ParseEx (const char *data, cpe_mode mode)
{
int c;
int len;
Expand Down Expand Up @@ -1284,26 +1263,32 @@ const char *COM_Parse (const char *data)
com_token[len] = 0;
return data;
}
com_token[len] = c;
len++;
if (len < Q_COUNTOF(com_token) - 1)
com_token[len++] = c;
else if (mode == CPE_NOTRUNC)
return NULL;
}
}

// parse single characters
if (c == '{' || c == '}'|| c == '('|| c == ')' || c == '\'' || c == ':')
{
com_token[len] = c;
len++;
if (len < Q_COUNTOF(com_token) - 1)
com_token[len++] = c;
else if (mode == CPE_NOTRUNC)
return NULL;
com_token[len] = 0;
return data+1;
}

// parse a regular word
do
{
com_token[len] = c;
if (len < Q_COUNTOF(com_token) - 1)
com_token[len++] = c;
else if (mode == CPE_NOTRUNC)
return NULL;
data++;
len++;
c = *data;
/* commented out the check for ':' so that ip:port works */
if (c == '{' || c == '}'|| c == '('|| c == ')' || c == '\''/* || c == ':' */)
Expand All @@ -1315,6 +1300,21 @@ const char *COM_Parse (const char *data)
}


/*
==============
COM_Parse
Parse a token out of a string
Return NULL in case of overflow
==============
*/
const char *COM_Parse (const char *data)
{
return COM_ParseEx (data, CPE_NOTRUNC);
}


/*
================
COM_CheckParm
Expand Down
7 changes: 7 additions & 0 deletions Quake/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,14 @@ extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
extern char com_token[1024];
extern qboolean com_eof;

typedef enum
{
CPE_NOTRUNC, // return parse error in case of overflow
CPE_ALLOWTRUNC // truncate com_token in case of overflow
} cpe_mode;

const char *COM_Parse (const char *data);
const char *COM_ParseEx (const char *data, cpe_mode mode);


extern int com_argc;
Expand Down
3 changes: 1 addition & 2 deletions Quake/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,7 @@ static const arg_completion_type_t arg_completion_types[] =
{ "timedemo ", &demolist }
};

static const int num_arg_completion_types =
sizeof(arg_completion_types)/sizeof(arg_completion_types[0]);
static const int num_arg_completion_types = Q_COUNTOF(arg_completion_types);

/*
============
Expand Down
2 changes: 1 addition & 1 deletion Quake/crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define CRC_INIT_VALUE 0xffff
#define CRC_XOR_VALUE 0x0000

static unsigned short crctable[256] =
static const unsigned short crctable[256] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
Expand Down
2 changes: 1 addition & 1 deletion Quake/default_cfg.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// keep in sync with Misc/qs_pak/default.cfg

static char default_cfg[] =
static const char default_cfg[] =
"unbindall\n"

"bind ALT +strafe\n"
Expand Down
2 changes: 1 addition & 1 deletion Quake/gl_fog.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void Fog_ParseWorldspawn (void)
q_strlcpy(key, com_token, sizeof(key));
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
data = COM_Parse(data);
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
if (!data)
return; // error
q_strlcpy(value, com_token, sizeof(value));
Expand Down
27 changes: 8 additions & 19 deletions Quake/gl_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ static int numcommands;
static int vertexorder[MAXALIASTRIS * 3];
static int numorder;

static int allverts, alltris;

static int stripverts[MAXALIASTRIS + 2];
static int striptris[MAXALIASTRIS];
static int stripcount;
Expand Down Expand Up @@ -279,9 +277,6 @@ static void BuildTris (void)
commands[numcommands++] = 0; // end of list marker

Con_DPrintf2 ("%3i tri %3i vert %3i cmd\n", pheader->numtris, numorder, numcommands);

allverts += numorder;
alltris += pheader->numtris;
}

static void GL_MakeAliasModelDisplayLists_VBO (qmodel_t *, aliashdr_t *);
Expand Down Expand Up @@ -348,9 +343,6 @@ void GL_MakeAliasModelDisplayLists (qmodel_t *m, aliashdr_t *hdr)
GL_MakeAliasModelDisplayLists_VBO (m, paliashdr);
}

unsigned int r_meshindexbuffer = 0;
unsigned int r_meshvertexbuffer = 0;

/*
================
GL_MakeAliasModelDisplayLists_VBO
Expand Down Expand Up @@ -442,9 +434,6 @@ static void GL_MakeAliasModelDisplayLists_VBO (qmodel_t *aliasmodel, aliashdr_t
GLMesh_LoadVertexBuffer (aliasmodel, pheader);
}

#define NUMVERTEXNORMALS 162
extern float r_avertexnormals[NUMVERTEXNORMALS][3];

/*
================
GLMesh_LoadVertexBuffer
Expand All @@ -465,23 +454,23 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)

if (!gl_glsl_alias_able)
return;

// count the sizes we need

// ericw -- RMQEngine stored these vbo*ofs values in aliashdr_t, but we must not
// mutate Mod_Extradata since it might be reloaded from disk, so I moved them to qmodel_t
// (test case: roman1.bsp from arwop, 64mb heap)
m->vboindexofs = 0;

m->vboxyzofs = 0;
totalvbosize += (hdr->numposes * hdr->numverts_vbo * sizeof (meshxyz_t)); // ericw -- what RMQEngine called nummeshframes is called numposes in QuakeSpasm

m->vbostofs = totalvbosize;
totalvbosize += (hdr->numverts_vbo * sizeof (meshst_t));

if (!hdr->numindexes) return;
if (!totalvbosize) return;

// grab the pointers to data in the extradata

desc = (aliasmesh_t *) ((byte *) hdr + hdr->meshdesc);
Expand Down Expand Up @@ -571,7 +560,7 @@ void GLMesh_LoadVertexBuffers (void)

if (!gl_glsl_alias_able)
return;

for (j = 1; j < MAX_MODELS; j++)
{
if (!(m = cl.model_precache[j])) break;
Expand All @@ -597,7 +586,7 @@ void GLMesh_DeleteVertexBuffers (void)

if (!gl_glsl_alias_able)
return;

for (j = 1; j < MAX_MODELS; j++)
{
if (!(m = cl.model_precache[j])) break;
Expand All @@ -609,6 +598,6 @@ void GLMesh_DeleteVertexBuffers (void)
GL_DeleteBuffersFunc (1, &m->meshindexesvbo);
m->meshindexesvbo = 0;
}

GL_ClearBufferBindings ();
}
4 changes: 2 additions & 2 deletions Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void R_ParseWorldspawn (void)
q_strlcpy(key, com_token, sizeof(key));
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
data = COM_Parse(data);
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
if (!data)
return; // error
q_strlcpy(value, com_token, sizeof(value));
Expand Down Expand Up @@ -559,7 +559,7 @@ GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int
}
else
{
if (gl_num_programs == (sizeof(gl_programs)/sizeof(GLuint)))
if (gl_num_programs == Q_COUNTOF(gl_programs))
Host_Error ("gl_programs overflow");

gl_programs[gl_num_programs] = program;
Expand Down
2 changes: 1 addition & 1 deletion Quake/gl_sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void Sky_NewMap (void)
q_strlcpy(key, com_token, sizeof(key));
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
data = COM_Parse(data);
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
if (!data)
return; // error
q_strlcpy(value, com_token, sizeof(value));
Expand Down
4 changes: 1 addition & 3 deletions Quake/gl_texmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static glmode_t glmodes[] = {
{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, "GL_LINEAR_MIPMAP_NEAREST"},
{GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, "GL_LINEAR_MIPMAP_LINEAR"},
};
#define NUM_GLMODES (int)(sizeof(glmodes)/sizeof(glmodes[0]))
#define NUM_GLMODES (int)Q_COUNTOF(glmodes)
static int glmode_idx = NUM_GLMODES - 1; /* trilinear */

/*
Expand All @@ -78,10 +78,8 @@ TexMgr_DescribeTextureModes_f -- report available texturemodes
static void TexMgr_DescribeTextureModes_f (void)
{
int i;

for (i = 0; i < NUM_GLMODES; i++)
Con_SafePrintf (" %2i: %s\n", i + 1, glmodes[i].name);

Con_Printf ("%i modes\n", i);
}

Expand Down
Loading

0 comments on commit 72c82b5

Please sign in to comment.