[Dedicated] fix sv_lanOnly
This commit is contained in:
parent
46e7007c28
commit
d28dc6ecc4
@ -3,7 +3,9 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
SteamID Dedicated::PlayerGuids[18][2];
|
SteamID Dedicated::PlayerGuids[18][2];
|
||||||
|
|
||||||
Dvar::Var Dedicated::SVRandomMapRotation;
|
Dvar::Var Dedicated::SVRandomMapRotation;
|
||||||
|
Dvar::Var Dedicated::SVLanOnly;
|
||||||
|
|
||||||
bool Dedicated::IsEnabled()
|
bool Dedicated::IsEnabled()
|
||||||
{
|
{
|
||||||
@ -290,7 +292,11 @@ namespace Components
|
|||||||
// Make sure all callbacks are handled
|
// Make sure all callbacks are handled
|
||||||
Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks);
|
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();
|
Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
@ -380,6 +386,12 @@ namespace Components
|
|||||||
{
|
{
|
||||||
static Utils::Time::Interval interval;
|
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))
|
if (Dvar::Var("sv_maxclients").get<int>() > 0 && interval.elapsed(2min))
|
||||||
{
|
{
|
||||||
interval.update();
|
interval.update();
|
||||||
|
@ -8,6 +8,7 @@ namespace Components
|
|||||||
Dedicated();
|
Dedicated();
|
||||||
|
|
||||||
static SteamID PlayerGuids[18][2];
|
static SteamID PlayerGuids[18][2];
|
||||||
|
static Dvar::Var SVLanOnly;
|
||||||
|
|
||||||
static bool IsEnabled();
|
static bool IsEnabled();
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace Components
|
|||||||
|
|
||||||
void Node::StoreNodes(bool force)
|
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;
|
static Utils::Time::Interval interval;
|
||||||
if (!force && !interval.elapsed(1min)) return;
|
if (!force && !interval.elapsed(1min)) return;
|
||||||
@ -168,7 +168,7 @@ namespace Components
|
|||||||
void Node::RunFrame()
|
void Node::RunFrame()
|
||||||
{
|
{
|
||||||
if (ServerList::useMasterServer) return;
|
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)
|
if (!Dedicated::IsEnabled() && *Game::clcState > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user