From b14fda976f0c609fa07391e1277c77033d82098d Mon Sep 17 00:00:00 2001 From: staphen Date: Sun, 6 Mar 2022 23:52:10 -0500 Subject: [PATCH] Fix IsGameHost() function for ZeroTier --- Source/dvlnet/base.h | 2 +- Source/dvlnet/base_protocol.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/dvlnet/base.h b/Source/dvlnet/base.h index 82e96819e..45bd90242 100644 --- a/Source/dvlnet/base.h +++ b/Source/dvlnet/base.h @@ -69,7 +69,7 @@ protected: int32_t lastTurnValue = {}; }; - seq_t next_turn; + seq_t next_turn = 0; message_t message_last; std::deque message_queue; diff --git a/Source/dvlnet/base_protocol.h b/Source/dvlnet/base_protocol.h index 24ca8e242..09b4b8e79 100644 --- a/Source/dvlnet/base_protocol.h +++ b/Source/dvlnet/base_protocol.h @@ -42,6 +42,7 @@ private: std::string gamename; std::map, endpoint>> game_list; std::array peers; + bool isGameHost_; plr_t get_master(); void recv(); @@ -129,6 +130,7 @@ template int base_protocol

::create(std::string addrstr) { gamename = addrstr; + isGameHost_ = true; if (wait_network()) { plr_self = 0; @@ -141,17 +143,19 @@ template int base_protocol

::join(std::string addrstr) { gamename = addrstr; - if (wait_network()) + isGameHost_ = false; + + if (wait_network()) { if (wait_firstpeer()) wait_join(); - + } return (plr_self == PLR_BROADCAST ? -1 : plr_self); } template bool base_protocol

::IsGameHost() { - return firstpeer == endpoint(); + return isGameHost_; } template