diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index da207d22..582bebb0 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -252,9 +252,15 @@ namespace Components } void Dedicated::Heartbeat() - { - int masterPort = Dvar::Var("masterPort").get(); - const char* masterServerName = Dvar::Var("masterServerName").get(); + { + // Do not send a heartbeat if sv_lanOnly is set to true + if (Dedicated::SVLanOnly.get()) + { + return; + } + + auto masterPort = Dvar::Var("masterPort").get(); + const auto* masterServerName = Dvar::Var("masterServerName").get(); Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort)); @@ -386,12 +392,6 @@ namespace Components { static Utils::Time::Interval interval; - // Do not send an heartbeat if sv_lanOnly is set to true - if (Dedicated::SVLanOnly.get()) - { - return; - } - if (Dvar::Var("sv_maxclients").get() > 0 && interval.elapsed(2min)) { interval.update();