diff --git a/doomsday/plugins/common/include/p_mapsetup.h b/doomsday/plugins/common/include/p_mapsetup.h index 81d04463c3..ac2f32b8d2 100644 --- a/doomsday/plugins/common/include/p_mapsetup.h +++ b/doomsday/plugins/common/include/p_mapsetup.h @@ -46,6 +46,12 @@ void P_FinalizeMapChange(Uri const *uri); */ void P_SetupMap(Uri const *uri); +/** + * To be called to reset the local world state (e.g., when leaving a networked game). + * Note that @ref P_SetupMap() calls this automatically when the current map changes. + */ +void P_ResetWorldState(); + /** * @param mapUri Identifier of the map to lookup the author of. Can be @c 0 in which * case the author for the @em current map will be returned (if set). diff --git a/doomsday/plugins/common/src/d_net.cpp b/doomsday/plugins/common/src/d_net.cpp index 15f5ffe3c1..f0596806e0 100644 --- a/doomsday/plugins/common/src/d_net.cpp +++ b/doomsday/plugins/common/src/d_net.cpp @@ -25,6 +25,7 @@ #include "gamesession.h" #include "player.h" #include "hu_menu.h" +#include "p_mapsetup.h" #include "p_start.h" #include "fi_lib.h" @@ -182,21 +183,25 @@ int D_NetConnect(int before) int D_NetDisconnect(int before) { - if(before) return true; + if(before) + { + // Free PU_MAP, Zone-allocated storage for the local world state. + P_ResetWorldState(); + return true; + } D_NetClearBuffer(); // Start demo. COMMON_GAMESESSION->endAndBeginTitle(); - // Restore normal game state. - GameRuleset newRules(COMMON_GAMESESSION->rules()); + /*GameRuleset newRules(COMMON_GAMESESSION->rules()); newRules.deathmatch = false; newRules.noMonsters = false; #if __JHEXEN__ newRules.randomClasses = false; #endif - COMMON_GAMESESSION->applyNewRules(newRules); + COMMON_GAMESESSION->applyNewRules(newRules);*/ return true; } diff --git a/doomsday/plugins/common/src/p_mapsetup.cpp b/doomsday/plugins/common/src/p_mapsetup.cpp index 87750e0e5c..b4a3ea3d9f 100644 --- a/doomsday/plugins/common/src/p_mapsetup.cpp +++ b/doomsday/plugins/common/src/p_mapsetup.cpp @@ -46,8 +46,6 @@ # define TOLIGHTIDX(c) (!((c) >> 8)? 0 : ((c) - 0x100) + 1) #endif -static void P_ResetWorldState(void); - // Our private map data structures xsector_t *xsectors; xline_t *xlines; @@ -706,9 +704,19 @@ void P_SetupMap(Uri const *mapUri) // It begins... mapSetup = true; + ::timerGame = 0; + if(COMMON_GAMESESSION->rules().deathmatch) + { + int parm = CommandLine_Check("-timer"); + if(parm && parm < CommandLine_Count() - 1) + { + ::timerGame = atoi(CommandLine_At(parm + 1)) * 35 * 60; + } + } + P_ResetWorldState(); - // Initialize The Logical Sound Manager. + // Initialize the logical sound manager. S_MapChange(); AutoStr *mapUriStr = Uri_Compose(mapUri); @@ -1013,10 +1021,7 @@ void P_FinalizeMapChange(Uri const *uri) #endif } -/** - * Called during map setup when beginning to load a new map. - */ -static void P_ResetWorldState() +void P_ResetWorldState() { #if __JHEXEN__ static int firstFragReset = 1; @@ -1054,16 +1059,6 @@ static void P_ResetWorldState() #endif } - timerGame = 0; - if(COMMON_GAMESESSION->rules().deathmatch) - { - int parm = CommandLine_Check("-timer"); - if(parm && parm < CommandLine_Count() - 1) - { - timerGame = atoi(CommandLine_At(parm + 1)) * 35 * 60; - } - } - for(int i = 0; i < MAXPLAYERS; ++i) { player_t *plr = &players[i];