[Dedicated] fix sv_lanOnly

This commit is contained in:
FutureRave 2022-05-04 00:03:11 +01:00
parent 46e7007c28
commit d28dc6ecc4
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
3 changed files with 16 additions and 3 deletions

View File

@ -3,7 +3,9 @@
namespace Components
{
SteamID Dedicated::PlayerGuids[18][2];
Dvar::Var Dedicated::SVRandomMapRotation;
Dvar::Var Dedicated::SVLanOnly;
bool Dedicated::IsEnabled()
{
@ -290,7 +292,11 @@ namespace Components
// Make sure all callbacks are handled
Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks);
Dvar::Register<bool>("sv_lanOnly", false, Game::dvar_flag::DVAR_NONE, "Don't act as node");
Dvar::OnInit([]
{
Dedicated::SVLanOnly = Dvar::Register<bool>("sv_lanOnly", false,
Game::dvar_flag::DVAR_NONE, "Don't act as node");
});
Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick();
@ -380,6 +386,12 @@ namespace Components
{
static Utils::Time::Interval interval;
// Do not send an heartbeat if sv_lanOnly is set to true
if (Dedicated::SVLanOnly.get<bool>())
{
return;
}
if (Dvar::Var("sv_maxclients").get<int>() > 0 && interval.elapsed(2min))
{
interval.update();

View File

@ -8,6 +8,7 @@ namespace Components
Dedicated();
static SteamID PlayerGuids[18][2];
static Dvar::Var SVLanOnly;
static bool IsEnabled();

View File

@ -114,7 +114,7 @@ namespace Components
void Node::StoreNodes(bool force)
{
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
if (Dedicated::IsEnabled() && Dedicated::SVLanOnly.get<bool>()) return;
static Utils::Time::Interval interval;
if (!force && !interval.elapsed(1min)) return;
@ -168,7 +168,7 @@ namespace Components
void Node::RunFrame()
{
if (ServerList::useMasterServer) return;
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
if (Dedicated::IsEnabled() && Dedicated::SVLanOnly.get<bool>()) return;
if (!Dedicated::IsEnabled() && *Game::clcState > 0)
{