Add Rule Zone:KillProcessOnDynamicShutdown and functionality for killing a dynamic after it has been allocated a zone and has shutdown - this is done for memory reasons because we do not clean up after ourselves at all and zone processes bloat heavily in memory. This is a workaround until we manage this better

This commit is contained in:
Akkadius
2019-09-06 12:26:30 -05:00
parent 45278f80ca
commit 534bed1483
4 changed files with 25 additions and 16 deletions
+1
View File
@@ -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)
+2 -1
View File
@@ -543,8 +543,9 @@ int main(int argc, char** argv) {
}
}
if (quest_timers.Check())
if (quest_timers.Check()) {
quest_manager.Process();
}
}
}
+13 -6
View File
@@ -683,10 +683,11 @@ 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();
@@ -706,8 +707,7 @@ void Zone::Shutdown(bool quite)
zone->adventure_entry_list_flavor.clear();
std::map<uint32, LDoNTrapTemplate *>::iterator itr4;
while(!zone->ldon_trap_list.empty())
{
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)
+1 -1
View File
@@ -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();