Tweaks to zone shutdown code

This commit is contained in:
Akkadius 2018-05-12 03:31:47 -05:00
parent d43273fd1b
commit eb463eef97
3 changed files with 18 additions and 10 deletions

View File

@ -131,12 +131,11 @@ void Timer::SetTimer(uint32 set_timer_time) {
uint32 Timer::GetRemainingTime() { uint32 Timer::GetRemainingTime() {
if (enabled) { if (enabled) {
if (current_time-start_time > timer_time) if (current_time - start_time > timer_time)
return 0; return 0;
else else
return (start_time + timer_time) - current_time; return (start_time + timer_time) - current_time;
} } else {
else {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
} }

View File

@ -541,11 +541,6 @@ int main(int argc, char** argv) {
if (previous_loaded && !current_loaded) { if (previous_loaded && !current_loaded) {
process_timer.Stop(); process_timer.Stop();
process_timer.Start(1000, true); 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) { else if (!previous_loaded && current_loaded) {
process_timer.Stop(); process_timer.Stop();

View File

@ -150,8 +150,15 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
zone->RequestUCSServerStatus(); zone->RequestUCSServerStatus();
/* Set Logging */ /**
* Set Shutdown timer
*/
uint32 shutdown_timer = static_cast<uint32>(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)); LogSys.StartFileLogs(StringFormat("%s_version_%u_inst_id_%u_port_%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
return true; return true;
@ -1427,11 +1434,18 @@ bool Zone::HasWeather()
void Zone::StartShutdownTimer(uint32 set_time) { void Zone::StartShutdownTimer(uint32 set_time) {
if (set_time > autoshutdown_timer.GetRemainingTime()) { if (set_time > autoshutdown_timer.GetRemainingTime()) {
if (set_time == (RuleI(Zone, AutoShutdownDelay))) { if (set_time == (RuleI(Zone, AutoShutdownDelay))) {
set_time = database.getZoneShutDownDelay(GetZoneID(), GetInstanceVersion()); set_time = static_cast<uint32>(database.getZoneShutDownDelay(GetZoneID(), GetInstanceVersion()));
} }
autoshutdown_timer.SetTimer(set_time); autoshutdown_timer.SetTimer(set_time);
Log(Logs::General, Logs::Zone_Server, "Zone::StartShutdownTimer set to %u", 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) { bool Zone::Depop(bool StartSpawnTimer) {