diff --git a/common/ruletypes.h b/common/ruletypes.h index e7c3ea2b5..be947bf47 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -274,6 +274,7 @@ RULE_INT(Zone, MinOfflineTimeToReplenishments, 21600) // 21600 seconds is 6 Hour RULE_BOOL(Zone, UseZoneController, true) // Enables the ability to use persistent quest based zone controllers (zone_controller.pl/lua) RULE_BOOL(Zone, EnableZoneControllerGlobals, false) // Enables the ability to use quest globals with the zone controller NPC RULE_INT(Zone, GlobalLootMultiplier, 1) // Sets Global Loot drop multiplier for database based drops, useful for double, triple loot etc. +RULE_BOOL(Zone, KillProcessOnDynamicShutdown, true) // When process has booted a zone and has hit its zone shut down timer, it will hard kill the process to free memory back to the OS RULE_CATEGORY_END() RULE_CATEGORY(Map) diff --git a/zone/net.cpp b/zone/net.cpp index f23e432e9..0ce901359 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -435,8 +435,8 @@ int main(int argc, char** argv) { LogDebug("Main thread running with thread id [{}]", pthread_self()); #endif - bool worldwasconnected = worldserver.Connected(); - bool eqsf_open = false; + bool worldwasconnected = worldserver.Connected(); + bool eqsf_open = false; bool websocker_server_opened = false; Timer quest_timers(100); @@ -543,8 +543,9 @@ int main(int argc, char** argv) { } } - if (quest_timers.Check()) + if (quest_timers.Check()) { quest_manager.Process(); + } } } diff --git a/zone/zone.cpp b/zone/zone.cpp index 8e51bae72..f4aade55c 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -683,31 +683,31 @@ bool Zone::IsLoaded() { return is_zone_loaded; } -void Zone::Shutdown(bool quite) +void Zone::Shutdown(bool quiet) { - if (!is_zone_loaded) + if (!is_zone_loaded) { return; + } entity_list.StopMobAI(); - std::map::iterator itr; - while(!zone->npctable.empty()) { - itr=zone->npctable.begin(); + std::map::iterator itr; + while (!zone->npctable.empty()) { + itr = zone->npctable.begin(); delete itr->second; zone->npctable.erase(itr); } - while(!zone->merctable.empty()) { - itr=zone->merctable.begin(); + while (!zone->merctable.empty()) { + itr = zone->merctable.begin(); delete itr->second; zone->merctable.erase(itr); } zone->adventure_entry_list_flavor.clear(); - std::map::iterator itr4; - while(!zone->ldon_trap_list.empty()) - { + std::map::iterator itr4; + while (!zone->ldon_trap_list.empty()) { itr4 = zone->ldon_trap_list.begin(); delete itr4->second; zone->ldon_trap_list.erase(itr4); @@ -717,8 +717,10 @@ void Zone::Shutdown(bool quite) LogInfo("Zone Shutdown: [{}] ([{}])", zone->GetShortName(), zone->GetZoneID()); petition_list.ClearPetitions(); zone->SetZoneHasCurrentTime(false); - if (!quite) - LogInfo("Zone shutdown: going to sleep"); + if (!quiet) { + LogInfo("Zone Shutdown: Going to sleep"); + } + is_zone_loaded = false; zone->ResetAuth(); @@ -728,6 +730,11 @@ void Zone::Shutdown(bool quite) UpdateWindowTitle(); LogSys.CloseFileLogs(); + + if (RuleB(Zone, KillProcessOnDynamicShutdown)) { + LogInfo("[KillProcessOnDynamicShutdown] Shutting down"); + std::exit(EXIT_SUCCESS); + } } void Zone::LoadZoneDoors(const char* zone, int16 version) diff --git a/zone/zone.h b/zone/zone.h index c6da2642e..4ed017627 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -84,7 +84,7 @@ class MobMovementManager; class Zone { public: static bool Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone = false); - static void Shutdown(bool quite = false); + static void Shutdown(bool quiet = false); Zone(uint32 in_zoneid, uint32 in_instanceid, const char *in_short_name); ~Zone();