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
This commit is contained in:
Ozkan Sezer 2014-09-08 18:20:47 +00:00
parent 9d2193f1d4
commit 1c4c5ba254
2 changed files with 23 additions and 55 deletions

View File

@ -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)

View File

@ -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));