Merge pull request #246 from diamante0018/fix-lan
Fix lanonly for dedis
This commit is contained in:
commit
31f1dd2d55
@ -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()
|
||||||
{
|
{
|
||||||
@ -251,8 +253,14 @@ namespace Components
|
|||||||
|
|
||||||
void Dedicated::Heartbeat()
|
void Dedicated::Heartbeat()
|
||||||
{
|
{
|
||||||
int masterPort = Dvar::Var("masterPort").get<int>();
|
// Do not send a heartbeat if sv_lanOnly is set to true
|
||||||
const char* masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
if (Dedicated::SVLanOnly.get<bool>())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto masterPort = Dvar::Var("masterPort").get<int>();
|
||||||
|
const auto* masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
||||||
|
|
||||||
Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort));
|
Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort));
|
||||||
|
|
||||||
@ -290,7 +298,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();
|
||||||
|
|
||||||
|
@ -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