From ed813363a5f5e262383af746764d8bb6b00dab82 Mon Sep 17 00:00:00 2001 From: KimLS Date: Wed, 8 Feb 2017 19:27:51 -0800 Subject: [PATCH] Fix for locked server bug, bandaid to fix stupid missile code. --- common/features.h | 1 - world/net.cpp | 2 ++ world/zonelist.cpp | 1 - zone/net.cpp | 18 +++++++++++++++--- zone/special_attacks.cpp | 4 +++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/common/features.h b/common/features.h index 27390e745..cf6b6fb0f 100644 --- a/common/features.h +++ b/common/features.h @@ -163,7 +163,6 @@ enum { //timer settings, all in milliseconds ClientProximity_interval = 150, CombatEventTimer_expire = 12000, Tribute_duration = 600000, - ZoneTimerResolution = 3, //sleep time between zone main loop runs (milliseconds) FeignMemoryDuration = 120000, // Duration player must feign death to clear zonewide agro. EnragedTimer = 360000, EnragedDurationTimer = 10000 diff --git a/world/net.cpp b/world/net.cpp index 970109ecb..a3bb71adc 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -386,6 +386,7 @@ int main(int argc, char** argv) { Log.OutF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}", connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID()); + numzones++; zoneserver_list.Add(new ZoneServer(connection)); }); @@ -393,6 +394,7 @@ int main(int argc, char** argv) { Log.OutF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}", connection->GetUUID()); + numzones--; zoneserver_list.Remove(connection->GetUUID()); }); diff --git a/world/zonelist.cpp b/world/zonelist.cpp index ae8f26e6f..c0b2f6348 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -86,7 +86,6 @@ void ZSList::KillAll() { while(iterator != list.end()) { (*iterator)->Disconnect(); iterator = list.erase(iterator); - numzones--; } } diff --git a/zone/net.cpp b/zone/net.cpp index a663d6093..1980fe41f 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -76,6 +76,7 @@ #include #include #include +#include #ifdef _CRTDBG_MAP_ALLOC #undef new @@ -108,6 +109,7 @@ EQEmuLogSys Log; const SPDat_Spell_Struct* spells; int32 SPDAT_RECORDS = -1; const ZoneConfig *Config; +uint64_t frame_time = 0; void Shutdown(); extern void MapOpcodes(); @@ -431,11 +433,16 @@ int main(int argc, char** argv) { zoneupdate_timer.Start(); bool eqsf_open = false; std::unique_ptr eqsm; + std::chrono::time_point frame_prev = std::chrono::system_clock::now(); - EQ::Timer process_timer(50, true, [&eqsf_open, &eqsm, &stream_identifier, &eqsi, &worldwasconnected, - &zoneupdate_timer, &IDLEZONEUPDATE, &ZONEUPDATE, &quest_timers, &InterserverTimer](EQ::Timer* t) { + EQ::Timer process_timer(50, true, [&](EQ::Timer* t) { //Advance the timer to our current point in time Timer::SetCurrentTime(); + + //Calculate frame time + std::chrono::time_point frame_now = std::chrono::system_clock::now(); + frame_time = std::chrono::duration_cast(frame_now - frame_prev).count(); + frame_prev = frame_now; if (!eqsf_open && Config->ZonePort != 0) { Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort); @@ -525,7 +532,12 @@ int main(int argc, char** argv) { while(RunLoops) { EQ::EventLoop::Get().Process(); - Sleep(1); + if (is_zone_loaded) { + Sleep(1); + } + else { + Sleep(50); + } } entity_list.Clear(); diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 81c888915..3844a9d6d 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -26,6 +26,8 @@ #include +extern uint64_t frame_time; + int Mob::GetBaseSkillDamage(EQEmu::skills::SkillType skill, Mob *target) { int base = EQEmu::skills::GetBaseDamage(skill); @@ -1012,7 +1014,7 @@ void Mob::ProjectileAttack() ProjectileAtk[i].skill = 0; ProjectileAtk[i].speed_mod = 0.0f; } else { - ProjectileAtk[i].increment++; + ProjectileAtk[i].increment += frame_time; } }