mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-26 22:02:26 +00:00
Change zone timer resolutions based on zone having players or not
This commit is contained in:
parent
eec6687083
commit
984b50504c
21
zone/net.cpp
21
zone/net.cpp
@ -442,7 +442,7 @@ int main(int argc, char** argv) {
|
|||||||
std::unique_ptr<EQ::Net::EQStreamManager> eqsm;
|
std::unique_ptr<EQ::Net::EQStreamManager> eqsm;
|
||||||
std::chrono::time_point<std::chrono::system_clock> frame_prev = std::chrono::system_clock::now();
|
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
|
//Advance the timer to our current point in time
|
||||||
Timer::SetCurrentTime();
|
Timer::SetCurrentTime();
|
||||||
|
|
||||||
@ -529,15 +529,24 @@ int main(int argc, char** argv) {
|
|||||||
database.ping();
|
database.ping();
|
||||||
entity_list.UpdateWho();
|
entity_list.UpdateWho();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
EQ::Timer process_timer(loop_fn);
|
||||||
|
process_timer.Start(1000, true);
|
||||||
|
|
||||||
while (RunLoops) {
|
while (RunLoops) {
|
||||||
|
bool previous_loaded = is_zone_loaded && numclients > 0;
|
||||||
EQ::EventLoop::Get().Process();
|
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 {
|
else if (!previous_loaded && current_loaded) {
|
||||||
Sleep(50);
|
process_timer.Stop();
|
||||||
|
process_timer.Start(32, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user