diff --git a/Quake/common.c b/Quake/common.c index 5e32afa..2b7ce2d 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -2155,6 +2155,70 @@ _add_path: } //============================================================================== +// hard-reset gamedir to id1 base. +//============================================================================== +static void COM_GameReset_f (void) +{ + searchpath_t *search; + + if (Cmd_Argc() != 1) + { + Con_Printf("gamereset: hard-reset game to %s\n", GAMENAME); + return; + } + + //Kill the server + CL_Disconnect (); + Host_ShutdownServer(true); + + //Write config file + Host_WriteConfiguration (); + + //Kill the extra game if it is loaded + 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; + } + hipnotic = false; + rogue = false; + standard_quake = true; + + //update com_gamedir + q_snprintf (com_gamedir, sizeof(com_gamedir), "%s/%s", + (host_parms->userdir != host_parms->basedir)? + host_parms->userdir : com_basedir, + GAMENAME); + + //clear out and reload appropriate data + Cache_Flush (); + Mod_ResetAll(); + Sky_ClearAll(); + if (!isDedicated) + { + TexMgr_NewGame (); + Draw_NewGame (); + R_NewGame (); + } + ExtraMaps_NewGame (); + Host_Resetdemos (); + DemoList_Rebuild (); + + Con_Printf("\"game\" changed to \"%s\"\n", COM_SkipPath(com_gamedir)); + + VID_Lock (); + Cbuf_AddText ("exec quake.rc\n"); + Cbuf_AddText ("vid_unlock\n"); +} + +//============================================================================== //johnfitz -- dynamic gamedir stuff -- modified by QuakeSpasm team. //============================================================================== static void COM_Game_f (void) @@ -2305,6 +2369,7 @@ void COM_InitFilesystem (void) //johnfitz -- modified based on topaz's tutorial Cvar_RegisterVariable (&cmdline); Cmd_AddCommand ("path", COM_Path_f); Cmd_AddCommand ("game", COM_Game_f); //johnfitz + Cmd_AddCommand ("gamereset", COM_GameReset_f); i = COM_CheckParm ("-basedir"); if (i && i < com_argc-1)