From efae8368971909429a09711d2007b7eb09bb9362 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:54:20 +0800 Subject: [PATCH] [server] Update CNetGame constructor --- raknet/RakNetworkFactory.cpp | 10 +++ raknet/RakNetworkFactory.h | 19 ++++++ server/main.h | 8 +++ server/netgame.cpp | 126 +++++++++++++++++------------------ server/netgame.h | 2 - server/server.vcproj | 24 +++++++ 6 files changed, 124 insertions(+), 65 deletions(-) create mode 100644 raknet/RakNetworkFactory.cpp create mode 100644 raknet/RakNetworkFactory.h diff --git a/raknet/RakNetworkFactory.cpp b/raknet/RakNetworkFactory.cpp new file mode 100644 index 0000000..ec0a037 --- /dev/null +++ b/raknet/RakNetworkFactory.cpp @@ -0,0 +1,10 @@ +// TODO: Implement RakNetworkFactory.cpp + +#include "RakNetworkFactory.h" +#include "RakServerInterface.h" +#include "RakServer.h" + +RakServerInterface* RakNetworkFactory::GetRakServerInterface( void ) +{ + return new RakServer; +} \ No newline at end of file diff --git a/raknet/RakNetworkFactory.h b/raknet/RakNetworkFactory.h new file mode 100644 index 0000000..0d3980e --- /dev/null +++ b/raknet/RakNetworkFactory.h @@ -0,0 +1,19 @@ + +// TODO: Implement RakNetworkFactory.h + +#ifndef __RAK_NETWORK_FACTORY_H +#define __RAK_NETWORK_FACTORY_H + +#include "Export.h" + +class RakServerInterface; + +class RAK_DLL_EXPORT RakNetworkFactory +{ +public: + + static RakServerInterface* GetRakServerInterface( void ); + +}; + +#endif diff --git a/server/main.h b/server/main.h index 3b57cfe..5e2a42f 100644 --- a/server/main.h +++ b/server/main.h @@ -2,6 +2,12 @@ #ifndef SAMPSRV_MAIN_H #define SAMPSRV_MAIN_H +// ------- +// DEFINES +// ------- + +#define MAX_PLAYERS 1000 + #define DEFAULT_MAX_PLAYERS 50 #define DEFAULT_LISTEN_PORT 8192 @@ -45,6 +51,8 @@ #include // Raknet +#include "../raknet/RakServer.h" +#include "../raknet/RakNetworkFactory.h" #include "../raknet/GetTime.h" // amx diff --git a/server/netgame.cpp b/server/netgame.cpp index dea1303..9cea87b 100644 --- a/server/netgame.cpp +++ b/server/netgame.cpp @@ -3,71 +3,71 @@ CNetGame::CNetGame() { + m_bAllowWeapons = FALSE; + m_byteWorldTime = 12; + m_byteWeather = 1; + m_bStuntBonus = true; + m_fGravity = 0.008f; + m_iDeathDropMoney = 0; + field_6A = false; + m_bVehicleFriendlyFire = FALSE; + + // Init member variables + m_pPlayerPool = NULL; + m_pVehiclePool = NULL; + m_pGameMode = NULL; + m_pPickupPool = NULL; + m_pObjectPool = NULL; + m_pMenuPool = NULL; + m_pTextPool = NULL; + m_bNameTagLOS = true; + m_pGangZonePool = NULL; + m_pLabelPool = NULL; + m_pActorPool = NULL; + m_bLanMode = FALSE; + field_6B = 1; + + m_bLimitGlobalChatRadius = FALSE; + m_fGlobalChatRadius = 10000.0f; + m_bLimitPlayerMarkerRadius = FALSE; + m_fPlayerMarkerRadius = 10000.0f; + m_fNameTagDrawDistance = 70.0f; + m_bDisableEnterExits = false; + field_5C = 0; + + m_iCurrentGameModeIndex = 0; + m_iCurrentGameModeRepeat = 0; + m_bFirstGameModeLoaded = FALSE; + + m_pScriptTimers = new CScriptTimers; + m_pScriptHttps = new CScriptHttps; + +#ifndef WIN32 + m_dElapsedTime = 0.0; +#endif + + if(pConsole->GetIntVariable("maxplayers") > MAX_PLAYERS) { + pConsole->SetIntVariable("maxplayers", MAX_PLAYERS); + } + + CHAR *szBindAddress = pConsole->GetStringVariable("bind"); + if (szBindAddress && szBindAddress[0] == 0) + szBindAddress = NULL; + + DWORD dwPort = pConsole->GetIntVariable("port"); + DWORD dwMaxPlayers = pConsole->GetIntVariable("maxplayers"); + BOOL bLanMode = pConsole->GetBoolVariable("lanmode"); + + // Setup RakNet + m_pRak = RakNetworkFactory::GetRakServerInterface(); + + + + + // TODO: CNetGame::CNetGame W: 0048EEE0 L: 080AF360 -/*_this = this; - this->field_8 = 0; - this->field_C = 0; - this->field_0 = 0; - this->field_10 = 0; - this->field_14 = 0; - this->field_18 = 0; - this->field_1C = 0; - this->field_77 = 1; - this->field_24 = 0; - this->field_20 = 0; - this->field_28 = 0; - this->field_50 = 0; - this->field_6B = 1; - dword_515CF8 = 0; - this->field_5A = 0; - this->field_59 = 12; - this->field_5D = 1; - this->field_5B = 1; - LODWORD(this->field_62) = 1006834287; - this->field_66 = 0; - this->field_6A = 0; - this->field_7E = 0; - this->field_6C = 0; - LODWORD(this->field_6E) = 1176256512; - this->field_79 = 0; - LODWORD(this->field_7A) = 1176256512; - LODWORD(this->field_72) = 1116471296; - this->field_76 = 0; - this->field_5C = 0; - this->field_2C = 0; - this->field_30 = 0; - this->field_34 = 0; - v2 = operator new(0x10u); - v26 = 0; - if ( v2 ) - v3 = sub_482BF0(v2); - else - v3 = 0; - _this->field_3C = v3; - v4 = operator new(0x320u); - v26 = 1; - if ( v4 ) - v5 = sub_4809D0(v4); - else - v5 = 0; - _this->field_38 = v5; - v26 = -1; - if ( CConsole::GetIntVariable(pConsole, "maxplayers") > 1000 ) - CConsole::SetIntVariable(pConsole, "maxplayers", 1000); - v6 = CConsole::GetStringVariable(pConsole, "bind"); - v7 = v6; - v21 = v6; - if ( v6 && !*v6 ) - { - v21 = 0; - v7 = 0; - } - v8 = CConsole::GetIntVariable(pConsole, "port"); - v19 = CConsole::GetIntVariable(pConsole, "maxplayers"); - v20 = CConsole::GetBoolVariable(pConsole, "lanmode"); - v9 = RakNetworkFactory::GetRakServerInterface(); - _this->field_40 = v9; +/* sub_496D10(v9); dword_515CFC = sub_44E9D0(); _this->field_44 = sub_48DBD0(_this); diff --git a/server/netgame.h b/server/netgame.h index 10fe7f0..fdd571c 100644 --- a/server/netgame.h +++ b/server/netgame.h @@ -2,8 +2,6 @@ #ifndef SAMPSRV_NETGAME_H #define SAMPSRV_NETGAME_H -class RakServerInterface {}; // TODO: RakServerInterface placeholder, remove this later - class CNetGame // size: W: 14808 L: 14816 { private: diff --git a/server/server.vcproj b/server/server.vcproj index fa748f5..c4a12f3 100644 --- a/server/server.vcproj +++ b/server/server.vcproj @@ -129,6 +129,30 @@ + + + + + + + + + + + + + + + +