diff --git a/src/acs/interface.cpp b/src/acs/interface.cpp index 8b56b6ebe..43cd4a2f2 100644 --- a/src/acs/interface.cpp +++ b/src/acs/interface.cpp @@ -70,6 +70,28 @@ void ACS_Shutdown(void) #endif } +/*-------------------------------------------------- + void ACS_InvalidateMapScope(size_t mapID) + + See header file for description. +--------------------------------------------------*/ +void ACS_InvalidateMapScope(void) +{ + Environment *env = &ACSEnv; + + ACSVM::GlobalScope *const global = env->getGlobalScope(0); + ACSVM::HubScope *hub = NULL; + ACSVM::MapScope *map = NULL; + + // Conclude hub scope, even if we are not using it. + hub = global->getHubScope(0); + hub->reset(); + + // Conclude current map scope. + map = hub->getMapScope(0); // This is where you'd put in mapID if you add hub support. + map->reset(); +} + /*-------------------------------------------------- void ACS_LoadLevelScripts(size_t mapID) @@ -103,14 +125,20 @@ void ACS_LoadLevelScripts(size_t mapID) // hubs are to be implemented, this logic would need // to be far more sophisticated. - // Reset hub scope, even if we are not using it. + // Extra note regarding the commented out ->reset()'s: + // This is too late! That needs to be done before + // PU_LEVEL is purged. Call ACS_InvalidateMapScope + // to take care of that. Those lines are left in + // only as a warning to future code spelunkers. + + // Restart hub scope, even if we are not using it. hub = global->getHubScope(0); - hub->reset(); + //hub->reset(); hub->active = true; // Start up new map scope. map = hub->getMapScope(0); // This is where you'd put in mapID if you add hub support. - map->reset(); + //map->reset(); map->active = true; // Insert BEHAVIOR lump into the list. diff --git a/src/acs/interface.h b/src/acs/interface.h index 32ba78b90..0b9881950 100644 --- a/src/acs/interface.h +++ b/src/acs/interface.h @@ -44,6 +44,23 @@ void ACS_Init(void); void ACS_Shutdown(void); +/*-------------------------------------------------- + void ACS_InvalidateMapScope(size_t mapID); + + Resets the ACS hub and map scopes to remove + existing running scripts, without starting + any new scripts. + + Input Arguments:- + None + + Return:- + None +--------------------------------------------------*/ + +void ACS_InvalidateMapScope(void); + + /*-------------------------------------------------- void ACS_LoadLevelScripts(size_t mapID); diff --git a/src/p_setup.c b/src/p_setup.c index c9cf7ec5c..e3406a3d3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8340,6 +8340,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) K_UnsetDialogue(); + ACS_InvalidateMapScope(); + LUA_InvalidateLevel(); for (ss = sectors; sectors+numsectors != ss; ss++)