diff --git a/BaseMenu.cpp b/BaseMenu.cpp index 249d91e4..3a63ce4b 100644 --- a/BaseMenu.cpp +++ b/BaseMenu.cpp @@ -902,7 +902,7 @@ void UI_ParseColor( char *&pfile, unsigned int *outColor ) for( int i = 0; i < 3; i++ ) { - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token )); if( !pfile ) break; color[i] = atoi( token ); } @@ -923,7 +923,7 @@ void UI_ApplyCustomColors( void ) return; } - while(( pfile = EngFuncs::COM_ParseFile( pfile, token )) != NULL ) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) != NULL ) { if( !stricmp( token, "HELP_COLOR" )) { @@ -984,7 +984,7 @@ static void UI_LoadBackgroundMapList( void ) return; } - while(( pfile = EngFuncs::COM_ParseFile( pfile, token )) != NULL ) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) != NULL ) { // skip the numbers (old format list) if( isdigit( token[0] )) continue; diff --git a/CFGScript.cpp b/CFGScript.cpp index 51bb386d..e80f8da5 100644 --- a/CFGScript.cpp +++ b/CFGScript.cpp @@ -41,7 +41,7 @@ Return true if next token is pExpext and skip it */ bool CSCR_ExpectString( parserstate_t *ps, const char *pExpect, bool skip, bool error ) { - char *tmp = EngFuncs::COM_ParseFile( ps->buf, ps->token ); + char *tmp = EngFuncs::COM_ParseFile( ps->buf, ps->token, sizeof( ps->token )); if( !stricmp( ps->token, pExpect ) ) { @@ -94,13 +94,13 @@ bool CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result ) result->list.pArray = NULL; // read the name - ps->buf = EngFuncs::COM_ParseFile( ps->buf, result->name ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, result->name, sizeof( result->name )); if( !CSCR_ExpectString( ps, "{", false, true ) ) goto error; // read description - ps->buf = EngFuncs::COM_ParseFile( ps->buf, result->desc ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, result->desc, sizeof( result->desc )); if( !CSCR_ExpectString( ps, "{", false, true ) ) goto error; @@ -116,11 +116,11 @@ bool CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result ) break; case T_NUMBER: // min - ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token, sizeof( ps->token )); result->number.fMin = atof( ps->token ); // max - ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token, sizeof( ps->token )); result->number.fMax = atof( ps->token ); if( !CSCR_ExpectString( ps, "}", false, true ) ) @@ -141,11 +141,11 @@ bool CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result ) // Read token for each item here // ExpectString already moves buffer pointer, so just read from ps->token - // ps->buf = EngFuncs::COM_ParseFile( ps->buf, szName ); + // ps->buf = EngFuncs::COM_ParseFile( ps->buf, szName, sizeof( szName )); if( !szName[0] ) goto error; - ps->buf = EngFuncs::COM_ParseFile( ps->buf, szValue ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, szValue, sizeof( szValue )); if( !szValue[0] ) goto error; @@ -172,7 +172,7 @@ bool CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result ) goto error; // default value - ps->buf = EngFuncs::COM_ParseFile( ps->buf, result->value ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, result->value, sizeof( result->value )); if( !CSCR_ExpectString( ps, "}", false, true ) ) goto error; @@ -231,7 +231,7 @@ bool CSCR_ParseHeader( parserstate_t *ps ) // Parse in the version # // Get the first token. - ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token, sizeof( ps->token )); if( atof( ps->token ) != 1 ) { @@ -242,7 +242,7 @@ bool CSCR_ParseHeader( parserstate_t *ps ) if( !CSCR_ExpectString( ps, "DESCRIPTION", false, true ) ) return false; - ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token ); + ps->buf = EngFuncs::COM_ParseFile( ps->buf, ps->token, sizeof( ps->token )); if( stricmp( ps->token, "INFO_OPTIONS") && stricmp( ps->token, "SERVER_OPTIONS" ) ) { @@ -322,7 +322,7 @@ scrvardef_t *CSCR_LoadDefaultCVars( const char *scriptfilename, int *count ) break; } - if( EngFuncs::COM_ParseFile( state.buf, state.token ) ) + if( EngFuncs::COM_ParseFile( state.buf, state.token, sizeof( state.token ))) Con_DPrintf( "Got extra tokens!\n" ); else success = true; diff --git a/MenuStrings.cpp b/MenuStrings.cpp index 0eec03d6..05964fa8 100644 --- a/MenuStrings.cpp +++ b/MenuStrings.cpp @@ -324,7 +324,7 @@ static void Localize_AddToDictionary( const char *name, const char *lang ) pfile = afile; - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token )); if( stricmp( token, "lang" )) { @@ -332,7 +332,7 @@ static void Localize_AddToDictionary( const char *name, const char *lang ) goto error; } - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( strcmp( token, "{" )) { @@ -340,7 +340,7 @@ static void Localize_AddToDictionary( const char *name, const char *lang ) goto error; } - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( stricmp( token, "Language" )) { @@ -349,9 +349,9 @@ static void Localize_AddToDictionary( const char *name, const char *lang ) } // skip language actual name - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( stricmp( token, "Tokens" )) { @@ -359,7 +359,7 @@ static void Localize_AddToDictionary( const char *name, const char *lang ) goto error; } - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( strcmp( token, "{" )) { @@ -367,13 +367,13 @@ static void Localize_AddToDictionary( const char *name, const char *lang ) goto error; } - while( (pfile = EngFuncs::COM_ParseFile( pfile, token ))) + while( (pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token )))) { if( !strcmp( token, "}" )) break; char szLocString[4096]; - pfile = EngFuncs::COM_ParseFile( pfile, szLocString ); + pfile = EngFuncs::COM_ParseFile( pfile, szLocString, sizeof( szLocString )); if( !strcmp( szLocString, "}" )) break; @@ -470,7 +470,7 @@ void UI_LoadCustomStrings( void ) if( !afile ) goto localize_init; - while(( pfile = EngFuncs::COM_ParseFile( pfile, token )) != NULL ) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) != NULL ) { if( isdigit( token[0] )) { @@ -484,7 +484,7 @@ void UI_LoadCustomStrings( void ) else continue; // invalid declaration ? // parse new string - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token )); MenuStrings[string_num] = StringCopy( token ); // replace default string with custom } diff --git a/controls/BackgroundBitmap.cpp b/controls/BackgroundBitmap.cpp index b072cacb..9535628a 100644 --- a/controls/BackgroundBitmap.cpp +++ b/controls/BackgroundBitmap.cpp @@ -224,22 +224,22 @@ bool CMenuBackgroundBitmap::LoadBackgroundImage( bool gamedirOnly ) pfile = afile; - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( !pfile || strcmp( token, "resolution" )) // resolution at first! goto freefile; - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( !pfile ) goto freefile; s_BackgroundImageSize.w = atoi( token ); - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( !pfile ) goto freefile; s_BackgroundImageSize.h = atoi( token ); // Now read all tiled background list - while(( pfile = EngFuncs::COM_ParseFile( pfile, token ))) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ))) { bimage_t img; @@ -251,14 +251,14 @@ bool CMenuBackgroundBitmap::LoadBackgroundImage( bool gamedirOnly ) if( !img.hImage ) goto freefile; // ignore "scaled" attribute. What does it mean? - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( !pfile ) goto freefile; - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( !pfile ) goto freefile; img.coord.x = atoi( token ); - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ) ); if( !pfile ) goto freefile; img.coord.y = atoi( token ); diff --git a/controls/ItemsHolder.cpp b/controls/ItemsHolder.cpp index 2701eb6c..9cbee091 100644 --- a/controls/ItemsHolder.cpp +++ b/controls/ItemsHolder.cpp @@ -534,7 +534,7 @@ bool RES_ExpectString( char **data, const char *expect, bool skip = true ) if( !data || !*data ) return true; - tmp = EngFuncs::COM_ParseFile( *data, token ); + tmp = EngFuncs::COM_ParseFile( *data, token, sizeof( token ) ); if( skip ) *data = tmp; @@ -566,7 +566,7 @@ bool CMenuItemsHolder::LoadRES(const char *filename) if( !pfile ) return false; - afile = EngFuncs::COM_ParseFile( afile, token ); + afile = EngFuncs::COM_ParseFile( afile, token, sizeof( token ) ); Con_DPrintf( "Loading res file from %s, name %s\n", filename, token ); @@ -583,7 +583,7 @@ bool CMenuItemsHolder::LoadRES(const char *filename) { CMenuBaseItem *item; - afile = EngFuncs::COM_ParseFile( afile, token ); + afile = EngFuncs::COM_ParseFile( afile, token, sizeof( token ) ); if( !afile ) return FreeFile( pfile, false ); @@ -603,11 +603,11 @@ bool CMenuItemsHolder::LoadRES(const char *filename) char key[1024]; char value[1024]; - afile = EngFuncs::COM_ParseFile( afile, key ); + afile = EngFuncs::COM_ParseFile( afile, key, sizeof( key )); if( !afile ) return FreeFile( pfile, false ); - afile = EngFuncs::COM_ParseFile( afile, value ); + afile = EngFuncs::COM_ParseFile( afile, value, sizeof( value )); if( !afile ) return FreeFile( pfile, false ); diff --git a/enginecallback_menu.h b/enginecallback_menu.h index 0d312fd7..841c9cdd 100644 --- a/enginecallback_menu.h +++ b/enginecallback_menu.h @@ -277,6 +277,12 @@ class EngFuncs { return textfuncs.pfnDoubleTime(); } + + static inline char* COM_ParseFile( char *data, char *token, const int size ) + { return textfuncs.pfnParseFile( data, token, size, 0, nullptr ); } + + static inline char* COM_ParseFile( char *data, char *token, const int size, int flags, int *len ) + { return textfuncs.pfnParseFile( data, token, size, flags, len ); } }; diff --git a/menus/Controls.cpp b/menus/Controls.cpp index ebf2d90e..816b23c7 100644 --- a/menus/Controls.cpp +++ b/menus/Controls.cpp @@ -185,7 +185,7 @@ void CMenuKeysModel::Update( void ) memset( firstKey, 0, sizeof( firstKey )); memset( secondKey, 0, sizeof( secondKey )); - while(( pfile = EngFuncs::COM_ParseFile( pfile, token )) != NULL ) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) != NULL ) { if( !stricmp( token, "blank" )) { @@ -209,7 +209,7 @@ void CMenuKeysModel::Update( void ) CMenuControls::GetKeyBindings( token, keys ); Q_strncpy( keysBind[i], token, sizeof( keysBind[i] )); - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token )); if( !pfile ) break; // technically an error if( token[0] == '#' ) @@ -275,13 +275,13 @@ void CMenuControls::ResetKeysList( void ) return; } - while(( pfile = EngFuncs::COM_ParseFile( pfile, token )) != NULL ) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) != NULL ) { char key[32]; Q_strncpy( key, token, sizeof( key )); - pfile = EngFuncs::COM_ParseFile( pfile, token ); + pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token )); if( !pfile ) break; // technically an error char cmd[4096]; diff --git a/menus/CreateGame.cpp b/menus/CreateGame.cpp index d07569d4..2fa84697 100644 --- a/menus/CreateGame.cpp +++ b/menus/CreateGame.cpp @@ -190,12 +190,12 @@ void CMenuMapListModel::Update( void ) strcpy( mapName[0], L( "GameUI_RandomMap" ) ); mapsDescription[0][0] = 0; - while(( pfile = EngFuncs::COM_ParseFile( pfile, token )) != NULL ) + while(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) != NULL ) { if( numMaps >= UI_MAXGAMES ) break; Q_strncpy( mapName[numMaps], token, 64 ); - if(( pfile = EngFuncs::COM_ParseFile( pfile, token )) == NULL ) + if(( pfile = EngFuncs::COM_ParseFile( pfile, token, sizeof( token ))) == NULL ) { Q_strncpy( mapsDescription[numMaps], mapName[numMaps], 64 ); break; // unexpected end of file