From 8f7f311f60c1d80a9c3db35debd98dc49a755c06 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 17 Nov 2024 06:28:02 +0300 Subject: [PATCH] engine: mod_bmodel: simplify wadlist parser --- engine/common/mod_bmodel.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index fccc60be..f23bb6ba 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -878,8 +878,6 @@ Mod_FatPVS_RecursiveBSPNode */ static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *visbuffer, int visbytes, mnode_t *node, qboolean phs ) { - int i; - while( node->contents >= 0 ) { float d = PlaneDiff( org, node->plane ); @@ -1912,7 +1910,8 @@ static void Mod_LoadSubmodels( model_t *mod, dbspmodel_t *bmod ) static int Mod_LoadEntities_splitstr_handler( char *prev, char *next, void *userdata ) { - string token; + const char *wad; + wadlist_t *wadlist = userdata; *next = '\0'; @@ -1920,17 +1919,20 @@ static int Mod_LoadEntities_splitstr_handler( char *prev, char *next, void *user return 0; COM_FixSlashes( prev ); - COM_FileBase( prev, token, sizeof( token )); + wad = COM_FileWithoutPath( prev ); + + if( Q_stricmp( COM_FileExtension( wad ), "wad" )) + return 0; // make sure that wad is really exist - if( FS_FileExists( va( "%s.wad", token ), false )) + if( FS_FileExists( wad, false )) { - int num = world.wadlist.count++; - Q_strncpy( world.wadlist.wadnames[num], token, sizeof( world.wadlist.wadnames[0] )); - world.wadlist.wadusage[num] = 0; + int num = wadlist->count++; + Q_strncpy( wadlist->wadnames[num], wad, sizeof( wadlist->wadnames[0] )); + wadlist->wadusage[num] = 0; } - if( world.wadlist.count >= MAX_MAP_WADS ) + if( wadlist->count >= ARRAYSIZE( wadlist->wadnames )) return 1; return 0; @@ -2022,7 +2024,7 @@ static void Mod_LoadEntities( model_t *mod, dbspmodel_t *bmod ) Host_Error( "%s: closing brace without data\n", __func__ ); if( !Q_stricmp( keyname, "wad" )) - Q_splitstr( token, ';', NULL, Mod_LoadEntities_splitstr_handler ); + Q_splitstr( token, ';', &world.wadlist, Mod_LoadEntities_splitstr_handler ); else if( !Q_stricmp( keyname, "message" )) Q_strncpy( world.message, token, sizeof( world.message )); else if( !Q_stricmp( keyname, "compiler" ) || !Q_stricmp( keyname, "_compiler" ))