diff --git a/common/timer.cpp b/common/timer.cpp index d5a90a0f2..3b5d8f15e 100644 --- a/common/timer.cpp +++ b/common/timer.cpp @@ -131,12 +131,11 @@ void Timer::SetTimer(uint32 set_timer_time) { uint32 Timer::GetRemainingTime() { if (enabled) { - if (current_time-start_time > timer_time) + if (current_time - start_time > timer_time) return 0; else return (start_time + timer_time) - current_time; - } - else { + } else { return 0xFFFFFFFF; } } diff --git a/zone/net.cpp b/zone/net.cpp index 80411af7b..f51d50bb4 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -541,11 +541,6 @@ int main(int argc, char** argv) { if (previous_loaded && !current_loaded) { process_timer.Stop(); process_timer.Start(1000, true); - - if (zone && zone->GetZoneID() && zone->GetInstanceVersion()) { - uint32 shutdown_timer = database.getZoneShutDownDelay(zone->GetZoneID(), zone->GetInstanceVersion()); - zone->StartShutdownTimer(shutdown_timer); - } } else if (!previous_loaded && current_loaded) { process_timer.Stop(); diff --git a/zone/zone.cpp b/zone/zone.cpp index f4a1e86e8..d43527c4f 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -150,8 +150,15 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { zone->RequestUCSServerStatus(); - /* Set Logging */ + /** + * Set Shutdown timer + */ + uint32 shutdown_timer = static_cast(database.getZoneShutDownDelay(zone->GetZoneID(), zone->GetInstanceVersion())); + zone->StartShutdownTimer(shutdown_timer); + /* + * Set Logging + */ LogSys.StartFileLogs(StringFormat("%s_version_%u_inst_id_%u_port_%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort)); return true; @@ -1427,11 +1434,18 @@ bool Zone::HasWeather() void Zone::StartShutdownTimer(uint32 set_time) { if (set_time > autoshutdown_timer.GetRemainingTime()) { if (set_time == (RuleI(Zone, AutoShutdownDelay))) { - set_time = database.getZoneShutDownDelay(GetZoneID(), GetInstanceVersion()); + set_time = static_cast(database.getZoneShutDownDelay(GetZoneID(), GetInstanceVersion())); } autoshutdown_timer.SetTimer(set_time); Log(Logs::General, Logs::Zone_Server, "Zone::StartShutdownTimer set to %u", set_time); } + + Log(Logs::Detail, Logs::Zone_Server, + "Zone::StartShutdownTimer trigger - set_time: %u remaining_time: %u diff: %i", + set_time, + autoshutdown_timer.GetRemainingTime(), + (set_time - autoshutdown_timer.GetRemainingTime()) + ); } bool Zone::Depop(bool StartSpawnTimer) {