diff --git a/dll/dll/steam_masterserver_updater.h b/dll/dll/steam_masterserver_updater.h index c278ef29..9b52d523 100644 --- a/dll/dll/steam_masterserver_updater.h +++ b/dll/dll/steam_masterserver_updater.h @@ -18,7 +18,10 @@ #ifndef __INCLUDED_STEAM_MASTERSERVER_UPDATER_H__ #define __INCLUDED_STEAM_MASTERSERVER_UPDATER_H__ + #include "base.h" +#include "dll/steam_gameserver.h" + class Steam_Masterserver_Updater : public ISteamMasterServerUpdater @@ -28,6 +31,7 @@ public ISteamMasterServerUpdater class SteamCallResults *callback_results{}; class SteamCallBacks *callbacks{}; class RunEveryRunCB *run_every_runcb{}; + class Steam_GameServer *gameserver{}; static void steam_callback(void *object, Common_Message *msg); static void steam_run_every_runcb(void *object); @@ -36,7 +40,7 @@ public ISteamMasterServerUpdater void Callback(Common_Message *msg); public: - Steam_Masterserver_Updater(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb); + Steam_Masterserver_Updater(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb, class Steam_GameServer *gameserver); ~Steam_Masterserver_Updater(); // Call this as often as you like to tell the master server updater whether or not diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 8aadadd8..fc336d45 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -143,7 +143,7 @@ Steam_Client::Steam_Client() steam_gameserver_networking_sockets_serialized = new Steam_Networking_Sockets_Serialized(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); steam_gameserver_networking_messages = new Steam_Networking_Messages(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); steam_gameserver_game_coordinator = new Steam_Game_Coordinator(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); - steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); + steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb, steam_gameserver); steam_gameserver_gamestats = new Steam_GameStats(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); PRINT_DEBUG("init AppTicket"); diff --git a/dll/steam_gameserver.cpp b/dll/steam_gameserver.cpp index 78c8fe82..2b200554 100644 --- a/dll/steam_gameserver.cpp +++ b/dll/steam_gameserver.cpp @@ -789,6 +789,7 @@ void Steam_GameServer::ForceHeartbeat() void Steam_GameServer::ForceMasterServerHeartbeat_DEPRECATED() { PRINT_DEBUG_TODO(); + ForceHeartbeat(); } @@ -845,12 +846,14 @@ void Steam_GameServer::RunCallbacks() } if (temp_call_servers_disconnected) { - SteamServersDisconnected_t data; + PRINT_DEBUG("Gameserver is disconnected"); + SteamServersDisconnected_t data{}; data.m_eResult = k_EResultOK; callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); if (!logged_in) { - Common_Message msg; + PRINT_DEBUG("notifying all that Gameserver is not logged in"); + Common_Message msg{}; msg.set_source_id(settings->get_local_steam_id().ConvertToUint64()); msg.set_allocated_gameserver(new Gameserver(server_data)); msg.mutable_gameserver()->set_offline(true); diff --git a/dll/steam_masterserver_updater.cpp b/dll/steam_masterserver_updater.cpp index 965e99dc..b63e77d4 100644 --- a/dll/steam_masterserver_updater.cpp +++ b/dll/steam_masterserver_updater.cpp @@ -18,6 +18,11 @@ #include "dll/steam_masterserver_updater.h" +// old games like appid 50300 use this interface instead of ISteamGameServer +// we use it as a proxy for ISteamGameServer since it has an equivalent API +// and handles the actual game server logic + + void Steam_Masterserver_Updater::steam_callback(void *object, Common_Message *msg) { // PRINT_DEBUG_ENTRY(); @@ -35,13 +40,14 @@ void Steam_Masterserver_Updater::steam_run_every_runcb(void *object) } -Steam_Masterserver_Updater::Steam_Masterserver_Updater(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb) +Steam_Masterserver_Updater::Steam_Masterserver_Updater(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb, class Steam_GameServer *gameserver) { this->settings = settings; this->network = network; this->callback_results = callback_results; this->callbacks = callbacks; this->run_every_runcb = run_every_runcb; + this->gameserver = gameserver; this->network->setCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Masterserver_Updater::steam_callback, this); this->run_every_runcb->add(&Steam_Masterserver_Updater::steam_run_every_runcb, this); @@ -60,6 +66,8 @@ void Steam_Masterserver_Updater::SetActive( bool bActive ) { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + + gameserver->EnableHeartbeats(bActive); } @@ -70,6 +78,8 @@ void Steam_Masterserver_Updater::SetHeartbeatInterval( int iHeartbeatInterval ) { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + + gameserver->SetHeartbeatInterval(iHeartbeatInterval); } @@ -93,7 +103,8 @@ bool Steam_Masterserver_Updater::HandleIncomingPacket( const void *pData, int cb { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); - return true; + + return gameserver->HandleIncomingPacket(pData, cbData, srcIP, srcPort); } @@ -105,7 +116,8 @@ int Steam_Masterserver_Updater::GetNextOutgoingPacket( void *pOut, int cbMaxOut, { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); - return 0; + + return gameserver->GetNextOutgoingPacket(pOut, cbMaxOut, pNetAdr, pPort); } @@ -124,6 +136,13 @@ void Steam_Masterserver_Updater::SetBasicServerData( { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + + gameserver->SetDedicatedServer(bDedicatedServer); + gameserver->SetRegion(pRegionName); + gameserver->SetProduct(pProductName); + gameserver->SetMaxPlayerCount(nMaxReportedClients); + gameserver->SetPasswordProtected(bPasswordProtected); + gameserver->SetGameDescription(pGameDescription); } @@ -132,6 +151,8 @@ void Steam_Masterserver_Updater::ClearAllKeyValues() { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + + gameserver->ClearAllKeyValues(); } @@ -140,6 +161,8 @@ void Steam_Masterserver_Updater::SetKeyValue( const char *pKey, const char *pVal { PRINT_DEBUG("TODO '%s'='%s'", pKey, pValue); std::lock_guard lock(global_mutex); + + gameserver->SetKeyValue(pKey, pValue); } @@ -150,6 +173,8 @@ void Steam_Masterserver_Updater::NotifyShutdown() { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + + gameserver->LogOff(); } @@ -159,7 +184,8 @@ bool Steam_Masterserver_Updater::WasRestartRequested() { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); - return false; + + return gameserver->WasRestartRequested(); } @@ -168,6 +194,8 @@ void Steam_Masterserver_Updater::ForceHeartbeat() { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + + gameserver->ForceHeartbeat(); }