diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 003ff0d..eb95471 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -3,12 +3,12 @@ char unnamed_2[63]; char unnamed_5[1000][24]; -int unnamed_6[1000]; +BOOL unnamed_6[MAX_PLAYERS]; char unnamed_9; char unnamed_1[68]; char unnamed_3[1000][68]; char unnamed_8[1000]; -int unnamed_7[2000]; +BOOL unnamed_7[MAX_VEHICLES]; char unnamed_4[1000][63]; //---------------------------------------------------- @@ -27,39 +27,9 @@ CNetGame::~CNetGame() UnRegisterScriptRPCs(m_pRakClient); // Unregister server-side scripting RPCs. RakNetworkFactory::DestroyRakClientInterface(m_pRakClient); SAFE_DELETE(m_pGameMode); - - // TODO: ~CNetGame (W: 00416D50 L: 080ACFDE) - /* - if ( this->field_38A ) - { - v4 = (void *)this->field_38A; - if ( v4 ) - { - sub_80B8160(v4); - operator delete(v4); - } - this->field_38A = 0; - } - if ( this->field_4 ) - { - v3 = (void *)this->field_4; - if ( v3 ) - { - sub_80B1FF8(v3); - operator delete(v3); - } - this->field_4 = 0; - } - if ( this->field_8 ) - { - v2 = (void *)this->field_8; - if ( v2 ) - { - sub_80B9470(v2); - operator delete(v2); - } - this->field_8 = 0; - }*/ + SAFE_DELETE(m_pScriptTimers); + SAFE_DELETE(m_pPlayerPool); + SAFE_DELETE(m_pVehiclePool); } //---------------------------------------------------- @@ -171,3 +141,20 @@ void CNetGame::Process() } //---------------------------------------------------- + +void CNetGame::sub_415EA0(PLAYERID playerId, BOOL a2) +{ + if(playerId < MAX_PLAYERS) + { + unnamed_6[playerId] = a2; + } +} + +void CNetGame::sub_415EC0(VEHICLEID VehicleID, BOOL a2) +{ + if(VehicleID < MAX_VEHICLES) + { + unnamed_7[VehicleID] = a2; + } +} + diff --git a/bot/net/netgame.h b/bot/net/netgame.h index 05a43a7..499aef0 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -60,6 +60,8 @@ public: void Init(PCHAR szHostOrIp,int iPort,PCHAR szPlayerName,PCHAR szPass,PCHAR szNpcMode); void Process(); + void sub_415EA0(PLAYERID playerId, BOOL a2); + void sub_415EC0(VEHICLEID VehicleID, BOOL a2); }; //---------------------------------------------------- diff --git a/bot/net/playerpool.cpp b/bot/net/playerpool.cpp index dee72bb..2d8f339 100644 --- a/bot/net/playerpool.cpp +++ b/bot/net/playerpool.cpp @@ -1,6 +1,8 @@ #include "../main.h" +extern CNetGame *pNetGame; + //---------------------------------------------------- CPlayerPool::CPlayerPool() @@ -10,10 +12,28 @@ CPlayerPool::CPlayerPool() // loop through and initialize all net players to null and slot states to false for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) { - field_0[playerId] = 0; + m_bPlayerSlotState[playerId] = FALSE; field_7167[playerId] = 0; field_810B[playerId] = 0; } } //---------------------------------------------------- + +CPlayerPool::~CPlayerPool() +{ + for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) { + Delete(playerId,0); + } +} + +//---------------------------------------------------- + +BOOL CPlayerPool::Delete(PLAYERID playerId, BYTE byteReason) +{ + m_bPlayerSlotState[playerId] = FALSE; + pNetGame->sub_415EA0(playerId, FALSE); + return TRUE; +} + +//---------------------------------------------------- diff --git a/bot/net/playerpool.h b/bot/net/playerpool.h index 952cc8b..dd91917 100644 --- a/bot/net/playerpool.h +++ b/bot/net/playerpool.h @@ -4,7 +4,7 @@ class CPlayerPool // size: 41035 { private: - int field_0[1000]; + BOOL m_bPlayerSlotState[MAX_PLAYERS]; char _gapFA0[2]; CHAR m_szLocalPlayerName[MAX_PLAYER_NAME+1]; char gapFBB[25000]; @@ -19,4 +19,8 @@ public: void SetLocalPlayerName(PCHAR szName) { strcpy(m_szLocalPlayerName,szName); }; CPlayerPool(); + ~CPlayerPool(); + + BOOL Delete(PLAYERID playerId, BYTE byteReason); + }; \ No newline at end of file diff --git a/bot/net/vehiclepool.cpp b/bot/net/vehiclepool.cpp index ce0411a..2ba40ff 100644 --- a/bot/net/vehiclepool.cpp +++ b/bot/net/vehiclepool.cpp @@ -1,5 +1,6 @@ #include "../main.h" +extern CNetGame *pNetGame; //---------------------------------------------------- @@ -12,3 +13,20 @@ CVehiclePool::CVehiclePool() } //---------------------------------------------------- + +CVehiclePool::~CVehiclePool() +{ + for(VEHICLEID VehicleID = 0; VehicleID < MAX_VEHICLES; VehicleID++) { + Delete(VehicleID); + } +} + +//---------------------------------------------------- + +BOOL CVehiclePool::Delete(VEHICLEID VehicleID) +{ + pNetGame->sub_415EC0(VehicleID, FALSE); + return TRUE; +} + +//---------------------------------------------------- diff --git a/bot/net/vehiclepool.h b/bot/net/vehiclepool.h index c4db422..a3e5858 100644 --- a/bot/net/vehiclepool.h +++ b/bot/net/vehiclepool.h @@ -8,4 +8,7 @@ private: public: CVehiclePool(); + ~CVehiclePool(); + + BOOL Delete(VEHICLEID VehicleID); }; diff --git a/bot/scrtimers.cpp b/bot/scrtimers.cpp index 952a8cc..3c47ce4 100644 --- a/bot/scrtimers.cpp +++ b/bot/scrtimers.cpp @@ -1,7 +1,36 @@ #include "main.h" +//---------------------------------------------------------------------------------- + CScriptTimers::CScriptTimers() { m_dwTimerCount = 0; } + +//---------------------------------------------------------------------------------- + +CScriptTimers::~CScriptTimers() +{ + DwordTimerMap::iterator itor; + for (itor = m_Timers.begin(); itor != m_Timers.end(); itor++) + { + FreeMem(itor->second); + SAFE_DELETE(itor->second); + } + m_Timers.clear(); +} + +//---------------------------------------------------------------------------------- + +void CScriptTimers::FreeMem(ScriptTimer_s* Timer) +{ + if (Timer->cellParams != NULL) + { + free(Timer->cellParams); + Timer->cellParams = NULL; + } +} + +//---------------------------------------------------------------------------------- + diff --git a/bot/scrtimers.h b/bot/scrtimers.h index e333c16..a020f87 100644 --- a/bot/scrtimers.h +++ b/bot/scrtimers.h @@ -4,7 +4,8 @@ struct ScriptTimer_s { - char _gap0[283]; + char _gap0[279]; + void* cellParams; }; typedef std::map DwordTimerMap; @@ -18,7 +19,9 @@ private: DWORD m_dwTimerCount; public: CScriptTimers(); + ~CScriptTimers(); + void FreeMem(ScriptTimer_s* Timer); }; #endif