Change zone timer resolutions based on zone having players or not

This commit is contained in:
KimLS 2017-04-14 16:59:37 -07:00
parent eec6687083
commit 984b50504c

View File

@ -442,7 +442,7 @@ int main(int argc, char** argv) {
std::unique_ptr<EQ::Net::EQStreamManager> eqsm;
std::chrono::time_point<std::chrono::system_clock> frame_prev = std::chrono::system_clock::now();
EQ::Timer process_timer(32, true, [&](EQ::Timer* t) {
auto loop_fn = [&](EQ::Timer* t) {
//Advance the timer to our current point in time
Timer::SetCurrentTime();
@ -529,15 +529,24 @@ int main(int argc, char** argv) {
database.ping();
entity_list.UpdateWho();
}
});
};
EQ::Timer process_timer(loop_fn);
process_timer.Start(1000, true);
while (RunLoops) {
bool previous_loaded = is_zone_loaded && numclients > 0;
EQ::EventLoop::Get().Process();
if (is_zone_loaded) {
Sleep(1);
Sleep(1);
bool current_loaded = is_zone_loaded && numclients > 0;
if (previous_loaded && !current_loaded) {
process_timer.Stop();
process_timer.Start(1000, true);
}
else {
Sleep(50);
else if (!previous_loaded && current_loaded) {
process_timer.Stop();
process_timer.Start(32, true);
}
}