From 9c94cab39f94240acdbf47185ee57caa4b2cba74 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:10:37 +0800 Subject: [PATCH] [bot] Implement `CNetGame::Init(...)` --- bot/net/netgame.cpp | 64 +++++++++++++++++++++------------------------ bot/net/netgame.h | 32 +++++++++++------------ 2 files changed, 46 insertions(+), 50 deletions(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 785c1a9..2661b67 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -2,6 +2,8 @@ #include "../main.h" #include "../../raknet/SocketDataEncryptor.h" +char szGameModeFile[256]; + char unnamed_2[63]; char unnamed_5[1000][24]; BOOL unnamed_6[MAX_PLAYERS]; @@ -73,45 +75,39 @@ void CNetGame::Init(PCHAR szHostOrIp, int iPort, SocketDataEncryptor::SetKey(iPort); RegisterRPCs(m_pRakClient); - RegisterScriptRPCs(m_pRakClient); - - + RegisterScriptRPCs(m_pRakClient); // Register server-side scripting RPCs. + sprintf(szGameModeFile, "npcmodes/%s.amx", szNpcMode); + if (!m_pGameMode->Load(szGameModeFile)) + exit(1); + m_pRakClient->SetPassword(szPass); + m_pRakClient->Connect(szHostOrIp,iPort,0,0,10); - // TODO: CNetGame::Init (W: 00416490 L: 080AD126) + m_iGameState = GAMESTATE_CONNECTING; /* - this->field_0 = sub_8070E80(); - sub_8094DD0((unsigned __int16)a3); - sub_80B1714(this->field_0); - sub_80B7032(this->field_0); - sprintf(byte_810A720, "npcmodes/%s.amx", a6); - if ( !(unsigned __int8)sub_80A9448((void *)this->field_386, byte_810A720) ) - exit(1); - (*(void (__cdecl **)(int, char *))(*(_DWORD *)this->field_0 + 20))(this->field_0, a5); - (*(void (__cdecl **)(int, char *, _DWORD, _DWORD, _DWORD, signed int))(*(_DWORD *)this->field_0 + 8))( - this->field_0, - src, - (unsigned __int16)a3, - 0, - 0, - 10);*/ - m_iGameState = 1; - field_14 = 0; - field_1E = 12; - field_1F = 0; - field_20 = 10; - field_34 = 1006834287; - field_38 = 0; - field_10 = 0; - field_3C = 1; - field_40 = 0; - for (int i = 0; i < 100; ++i ) - field_4A[i] = 0; - field_31 = 1; - field_3E = 0; - field_3D = 0; + char s[256]; + sprintf(s,"Bot(%s): connecting to %s:%d...",szPlayerName,szHostOrIp,iPort); + OutputDebugString(s);*/ + + m_iSpawnsAvailable = 0; + m_byteWorldTime = 12; + m_byteWorldMinute = 0; + m_byteWeather = 10; + m_fGravity = (float)0.008000000; + m_iDeathDropMoney = 0; + m_bLanMode = FALSE; + m_byteHoldTime = 1; + m_bUseCJWalk = FALSE; + + int i; + for (i = 0; i < 100; i++) m_dwMapIcon[i] = NULL; + + m_byteFriendlyFire = 1; + m_bZoneNames = FALSE; + m_bInstagib = FALSE; + memset(unnamed_1,0,sizeof(unnamed_1)); memset(unnamed_2,0,sizeof(unnamed_2)); memset(unnamed_3,0,sizeof(unnamed_3)); diff --git a/bot/net/netgame.h b/bot/net/netgame.h index 499aef0..af231fc 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -1,6 +1,7 @@ #pragma once +#define GAMESTATE_CONNECTING 1 #define GAMESTATE_CONNECTED 2 //---------------------------------------------------- @@ -10,28 +11,27 @@ class CNetGame // size: 910 bytes private: RakClientInterface *m_pRakClient; CPlayerPool *m_pPlayerPool; + CVehiclePool *m_pVehiclePool; + int m_iGameState; + BOOL m_bLanMode; - - CVehiclePool* m_pVehiclePool; - int m_iGameState; - int field_10; - int field_14; + int m_iSpawnsAvailable; char _gap18[6]; - char field_1E; // m_byteWorldTime ? - char field_1F; - char field_20; + BYTE m_byteWorldTime; + BYTE m_byteWorldMinute; + BYTE m_byteWeather; char _gap21[16]; - char field_31; + BYTE m_byteFriendlyFire; char _gap32[2]; - int field_34; - int field_38; - char field_3C; - char field_3D; - char field_3E; + float m_fGravity; + int m_iDeathDropMoney; + BYTE m_byteHoldTime; + bool m_bInstagib; + bool m_bZoneNames; char _gap3F; - char field_40; + bool m_bUseCJWalk; char _gap41[9]; - int field_4A[100]; + DWORD m_dwMapIcon[100]; char _gap1DA[4]; int field_1DE; int field_1E2;