From 1c4c5ba2543ca59aec865dc7b86f30ad488f1d4c Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 8 Sep 2014 18:20:47 +0000 Subject: [PATCH] add the com_base_searchpaths thing of qw and use it in Host_Game_f(), kill the no longer needed com_nummissionpacks, KillGameDir() and NumGames(). git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@998 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/common.c | 24 ++++++++------------- Quake/host_cmd.c | 54 +++++++++++++----------------------------------- 2 files changed, 23 insertions(+), 55 deletions(-) diff --git a/Quake/common.c b/Quake/common.c index d42495ea..3c36a19a 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -34,8 +34,6 @@ cvar_t cmdline = {"cmdline","",CVAR_ROM/*|CVAR_SERVERINFO*/}; /* sending cmdline qboolean com_modified; // set true if using non-id files -int com_nummissionpacks; //johnfitz - qboolean fitzmode; static void COM_Path_f (void); @@ -1466,6 +1464,7 @@ typedef struct searchpath_s } searchpath_t; searchpath_t *com_searchpaths; +searchpath_t *com_base_searchpaths; /* ============ @@ -1994,25 +1993,20 @@ void COM_InitFilesystem (void) //johnfitz -- modified based on topaz's tutorial // start up with GAMENAME by default (id1) COM_AddGameDirectory (com_basedir, GAMENAME); - //johnfitz -- track number of mission packs added - //since we don't want to allow the "game" command to strip them away - com_nummissionpacks = 0; if (COM_CheckParm ("-rogue")) - { COM_AddGameDirectory (com_basedir, "rogue"); - com_nummissionpacks++; - } if (COM_CheckParm ("-hipnotic")) - { COM_AddGameDirectory (com_basedir, "hipnotic"); - com_nummissionpacks++; - } if (COM_CheckParm ("-quoth")) - { COM_AddGameDirectory (com_basedir, "quoth"); - com_nummissionpacks++; - } - //johnfitz + +/* this is the end of our base searchpath: + * any set gamedirs, such as those from -game command line + * arguments or by the 'game' console command will be freed + * up to here upon a new game command. + * Set here instead of just after 'id1', because we don't want + * to allow the 'game' command to strip away the mission packs */ + com_base_searchpaths = com_searchpaths; i = COM_CheckParm ("-game"); if (i && i < com_argc-1) diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index 40956219..b3d414ed 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -27,8 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern cvar_t pausable; -extern int com_nummissionpacks; //johnfitz - int current_skill; void Mod_Print (void); @@ -84,43 +82,9 @@ typedef struct searchpath_s extern qboolean com_modified; extern searchpath_t *com_searchpaths; +extern searchpath_t *com_base_searchpaths; pack_t *COM_LoadPackFile (const char *packfile); -// Kill all the search packs until the game path is found. Kill it, then return -// the next path to it. -void KillGameDir(searchpath_t *search) -{ - searchpath_t *search_killer; - while (search) - { - if (*search->filename) - { - com_searchpaths = search->next; - Z_Free(search); - return; //once you hit the dir, youve already freed the paks - } - Sys_FileClose (search->pack->handle); //johnfitz - search_killer = search->next; - Z_Free(search->pack->files); - Z_Free(search->pack); - Z_Free(search); - search = search_killer; - } -} - -// Return the number of games in memory -int NumGames(searchpath_t *search) -{ - int found = 0; - while (search) - { - if (*search->filename) - found++; - search = search->next; - } - return found; -} - void ExtraMaps_NewGame (void); /* @@ -132,7 +96,7 @@ void Host_Game_f (void) { int i; unsigned int path_id; - searchpath_t *search = com_searchpaths; + searchpath_t *search; pack_t *pak; char pakfile[MAX_OSPATH]; @@ -168,8 +132,18 @@ void Host_Game_f (void) Host_WriteConfiguration (); //Kill the extra game if it is loaded - if (NumGames(com_searchpaths) > 1 + com_nummissionpacks) - KillGameDir(com_searchpaths); + while (com_searchpaths != com_base_searchpaths) + { + if (com_searchpaths->pack) + { + Sys_FileClose (com_searchpaths->pack->handle); + Z_Free (com_searchpaths->pack->files); + Z_Free (com_searchpaths->pack); + } + search = com_searchpaths->next; + Z_Free (com_searchpaths); + com_searchpaths = search; + } q_strlcpy (com_gamedir, va("%s/%s", com_basedir, p), sizeof(com_gamedir));