Skip to content

Commit

Permalink
Merge branch 'andrei-drexler:master' into aspect-ratio-desktop-fullsc…
Browse files Browse the repository at this point in the history
…reen
  • Loading branch information
KurtLoeffler authored Sep 24, 2023
2 parents dbab1a4 + 64a8b65 commit 89ad320
Show file tree
Hide file tree
Showing 34 changed files with 964 additions and 504 deletions.
7 changes: 5 additions & 2 deletions Quake/cl_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,12 @@ void CL_Record_f (void)

// open the demo file
COM_AddExtension (relname, ".dem", sizeof(relname));
Con_Printf ("recording to %s.\n", relname);

q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, relname);

Con_SafePrintf ("Recording to ");
Con_LinkPrintf (name, "%s", relname);
Con_SafePrintf (".\n");

cls.demofile = Sys_fopen (name, "wb");
if (!cls.demofile)
{
Expand Down
64 changes: 48 additions & 16 deletions Quake/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,12 +1253,16 @@ char *COM_TintString (const char *in, char *out, size_t outsize)

/*
==============
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 @@ -1310,26 +1314,32 @@ const char *COM_Parse (const char *data)
com_token[len] = 0;
return data;
}
com_token[len] = c;
len++;
if (len < 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 < 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 < 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 @@ -1341,6 +1351,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 Expand Up @@ -2082,7 +2107,7 @@ const char *COM_ParseFloatNewline(const char *buffer, float *value)
const char *COM_ParseStringNewline(const char *buffer)
{
int i;
for (i = 0; i < 1023; i++)
for (i = 0; i < countof (com_token) - 1; i++)
if (!buffer[i] || q_isspace (buffer[i]))
break;
memcpy (com_token, buffer, i);
Expand Down Expand Up @@ -2111,7 +2136,6 @@ static pack_t *COM_LoadPackFile (const char *packfile)
pack_t *pack;
int packhandle;
dpackfile_t info[MAX_FILES_IN_PACK];
unsigned short crc;

if (Sys_FileOpenRead (packfile, &packhandle) == -1)
return NULL;
Expand Down Expand Up @@ -2148,11 +2172,12 @@ static pack_t *COM_LoadPackFile (const char *packfile)
Sys_FileRead (packhandle, (void *)info, header.dirlen);

// crc the directory to check for modifications
CRC_Init (&crc);
for (i = 0; i < header.dirlen; i++)
CRC_ProcessByte (&crc, ((byte *)info)[i]);
if (crc != PAK0_CRC_V106 && crc != PAK0_CRC_V101 && crc != PAK0_CRC_V100)
com_modified = true;
if (!com_modified)
{
unsigned short crc = CRC_Block (info, header.dirlen);
if (crc != PAK0_CRC_V106 && crc != PAK0_CRC_V101 && crc != PAK0_CRC_V100)
com_modified = true;
}

// parse the directory
for (i = 0; i < numpackfiles; i++)
Expand Down Expand Up @@ -2755,7 +2780,14 @@ static void COM_InitBaseDir (void)
{
quakeflavor_t flavor;
if (original[0] && remastered[0])
flavor = ChooseQuakeFlavor ();
{
if (COM_CheckParm ("-prefremaster") || COM_CheckParm ("-remaster") || COM_CheckParm ("-remastered"))
flavor = QUAKE_FLAVOR_REMASTERED;
else if (COM_CheckParm ("-preforiginal") || COM_CheckParm ("-original"))
flavor = QUAKE_FLAVOR_ORIGINAL;
else
flavor = ChooseQuakeFlavor ();
}
else
flavor = remastered[0] ? QUAKE_FLAVOR_REMASTERED : QUAKE_FLAVOR_ORIGINAL;
q_strlcpy (path, flavor == QUAKE_FLAVOR_REMASTERED ? remastered : original, sizeof (path));
Expand Down
7 changes: 7 additions & 0 deletions Quake/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,14 @@ extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
extern THREAD_LOCAL 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
Loading

0 comments on commit 89ad320

Please sign in to comment.