[bot] Implement InitGame(...)

This commit is contained in:
RD42 2024-06-03 22:51:04 +08:00
parent aca41ed816
commit 843b2406bf
5 changed files with 93 additions and 14 deletions

View File

@ -36,22 +36,29 @@ private:
void Packet_ConnectAttemptFailed(Packet* packet);
void Packet_TrailerSync(Packet *p);
public:
int m_iSpawnsAvailable;
char _gap18[6];
bool m_bShowPlayerMarkers;
int m_iPlayerMarkersMode;
bool m_bTirePopping;
BYTE m_byteWorldTime;
BYTE m_byteWorldMinute;
BYTE m_byteWeather;
char _gap21[16];
BYTE m_byteFriendlyFire;
char _gap32[2];
bool m_bAllowWeapons;
bool m_bNameTagLOS;
float m_fGravity;
int m_iDeathDropMoney;
BYTE m_byteHoldTime;
bool m_bInstagib;
bool m_bZoneNames;
char _gap3F;
bool m_bLimitGlobalChatRadius;
bool m_bUseCJWalk;
char _gap41[9];
float m_fGlobalChatRadius;
float m_fNameTagDrawDistance;
bool m_bDisableEnterExits;
DWORD m_dwMapIcon[100];
int field_1DA;
int field_1DE;
@ -75,6 +82,8 @@ public:
~CNetGame();
int GetGameState() { return m_iGameState; };
void SetGameState(int iGameState) { m_iGameState = iGameState; };
void SetLanMode(BOOL bMode) { m_bLanMode = bMode; };
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
RakClientInterface * GetRakClient() { return m_pRakClient; };

View File

@ -101,9 +101,75 @@ void ServerQuit(RPCParameters *rpcParams)
pPlayerPool->Delete(playerId,byteReason);
}
void Unk8B(RPCParameters *rpcParams)
int iNetModeNormalOnfootSendRate;
int iNetModeNormalIncarSendRate;
int iNetModeFiringSendRate;
int iNetModeSendMultiplier;
int iNetModeLagCompensation;
void InitGame(RPCParameters *rpcParams)
{
// TODO: Unk8B
PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
int iBitLength = rpcParams->numberOfBitsOfData;
PlayerID sender = rpcParams->sender;
RakNet::BitStream bsInitGame(Data,(iBitLength/8)+1,false);
CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool();
PLAYERID MyPlayerID;
bool bLanMode, bStuntBonus;
bool bManualVehicleEngineAndLights;
bsInitGame.Read(pNetGame->m_bZoneNames);
bsInitGame.Read(pNetGame->m_bUseCJWalk);
bsInitGame.Read(pNetGame->m_bAllowWeapons);
bsInitGame.Read(pNetGame->m_bLimitGlobalChatRadius);
bsInitGame.Read(pNetGame->m_fGlobalChatRadius);
bsInitGame.Read(bStuntBonus);
bsInitGame.Read(pNetGame->m_fNameTagDrawDistance);
bsInitGame.Read(pNetGame->m_bDisableEnterExits);
bsInitGame.Read(pNetGame->m_bNameTagLOS);
pNetGame->m_bNameTagLOS = true;
bsInitGame.Read(bManualVehicleEngineAndLights);
bsInitGame.Read(pNetGame->m_iSpawnsAvailable);
bsInitGame.Read(MyPlayerID);
bsInitGame.Read(pNetGame->m_iPlayerMarkersMode);
bsInitGame.Read(pNetGame->m_bShowPlayerMarkers);
bsInitGame.Read(pNetGame->m_bTirePopping);
bsInitGame.Read(pNetGame->m_byteWorldTime);
bsInitGame.Read(pNetGame->m_byteWeather);
bsInitGame.Read(pNetGame->m_fGravity);
bsInitGame.Read(bLanMode);
bsInitGame.Read(pNetGame->m_iDeathDropMoney);
bsInitGame.Read(pNetGame->m_bInstagib);
// Server's send rate restrictions
bsInitGame.Read(iNetModeNormalOnfootSendRate);
bsInitGame.Read(iNetModeNormalIncarSendRate);
bsInitGame.Read(iNetModeFiringSendRate);
bsInitGame.Read(iNetModeSendMultiplier);
bsInitGame.Read(iNetModeLagCompensation);
BYTE byteStrLen;
bsInitGame.Read(byteStrLen);
if(byteStrLen) {
memset(pNetGame->m_szHostName,0,sizeof(pNetGame->m_szHostName));
bsInitGame.Read(pNetGame->m_szHostName, byteStrLen);
}
pNetGame->m_szHostName[byteStrLen] = '\0';
pPlayerPool->SetLocalPlayerID(MyPlayerID);
if(bLanMode) pNetGame->SetLanMode(TRUE);
pNetGame->SetGameState(GAMESTATE_CONNECTED);
//logprintf("NPC: Got InitGame. Sending class request.");
if(pNetGame->GetBotMode()) {
pNetGame->GetBotMode()->OnNPCConnect(MyPlayerID);
}
RakNet::BitStream bsSpawnRequest;
bsSpawnRequest.Write((int)0);
pNetGame->GetRakClient()->RPC(RPC_RequestClass,&bsSpawnRequest,HIGH_PRIORITY,RELIABLE,0,false);
}
void Chat(RPCParameters *rpcParams)
@ -187,7 +253,7 @@ void RegisterRPCs(RakClientInterface * pRakClient)
REGISTER_STATIC_RPC(pRakClient,Unk1E);
REGISTER_STATIC_RPC(pRakClient,Unk89);
REGISTER_STATIC_RPC(pRakClient,ServerQuit);
REGISTER_STATIC_RPC(pRakClient,Unk8B);
REGISTER_STATIC_RPC(pRakClient,InitGame);
REGISTER_STATIC_RPC(pRakClient,Chat);
REGISTER_STATIC_RPC(pRakClient,RequestClass);
REGISTER_STATIC_RPC(pRakClient,RequestSpawn);
@ -228,7 +294,7 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
UNREGISTER_STATIC_RPC(pRakClient,UnkA5);
UNREGISTER_STATIC_RPC(pRakClient,Unk89);
UNREGISTER_STATIC_RPC(pRakClient,ServerQuit);
UNREGISTER_STATIC_RPC(pRakClient,Unk8B);
UNREGISTER_STATIC_RPC(pRakClient,InitGame);
UNREGISTER_STATIC_RPC(pRakClient,Chat);
UNREGISTER_STATIC_RPC(pRakClient,RequestClass);
UNREGISTER_STATIC_RPC(pRakClient,RequestSpawn);

View File

@ -5,9 +5,9 @@ class CPlayerPool // size: 41035
{
private:
BOOL m_bPlayerSlotState[MAX_PLAYERS];
char _gapFA0[2];
PLAYERID m_LocalPlayerID;
CHAR m_szLocalPlayerName[MAX_PLAYER_NAME+1];
char gapFBB[25000];
CHAR m_szPlayerNames[MAX_PLAYERS][MAX_PLAYER_NAME+1];
int field_7163;
int field_7167[1000];
int field_8107;
@ -31,4 +31,8 @@ public:
return m_bPlayerSlotState[playerId];
};
void SetLocalPlayerID(PLAYERID MyPlayerID) {
strcpy(m_szPlayerNames[MyPlayerID],m_szLocalPlayerName);
m_LocalPlayerID = MyPlayerID;
};
};

View File

@ -46,8 +46,8 @@
#define RPC_EnterVehicle "\x1A"
#define RPC_ExitVehicle "\x9A"
#define RPC_Unk89 "\x89"
#define RPC_Unk8B "\x8B"
#define RPC_ServerQuit "\x8A"
#define RPC_InitGame "\x8B"
#define RPC_Chat "\x65"
#define RPC_RequestClass "\x80"
#define RPC_RequestSpawn "\x81"

View File

@ -35,8 +35,8 @@ void Unk18(RPCParameters *rpcParams) {}
void EnterVehicle(RPCParameters *rpcParams) {}
void ExitVehicle(RPCParameters *rpcParams) {}
void Unk89(RPCParameters *rpcParams) {}
void Unk8B(RPCParameters *rpcParams) {}
void ServerQuit(RPCParameters *rpcParams) {}
void InitGame(RPCParameters *rpcParams) {}
void Chat(RPCParameters *rpcParams) {}
void RequestClass(RPCParameters *rpcParams) {}
void RequestSpawn(RPCParameters *rpcParams) {}
@ -86,8 +86,8 @@ void RegisterRPCs(RakClientInterface * pRakClient)
REGISTER_STATIC_RPC(pRakClient,EnterVehicle);
REGISTER_STATIC_RPC(pRakClient,ExitVehicle);
REGISTER_STATIC_RPC(pRakClient,Unk89);
REGISTER_STATIC_RPC(pRakClient,Unk8B);
REGISTER_STATIC_RPC(pRakClient,ServerQuit);
REGISTER_STATIC_RPC(pRakClient,InitGame);
REGISTER_STATIC_RPC(pRakClient,Chat);
REGISTER_STATIC_RPC(pRakClient,RequestClass);
REGISTER_STATIC_RPC(pRakClient,RequestSpawn);
@ -123,8 +123,8 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
UNREGISTER_STATIC_RPC(pRakClient,Unk3B);
UNREGISTER_STATIC_RPC(pRakClient,Unk3D);
UNREGISTER_STATIC_RPC(pRakClient,Unk89);
UNREGISTER_STATIC_RPC(pRakClient,Unk8B);
UNREGISTER_STATIC_RPC(pRakClient,ServerQuit);
UNREGISTER_STATIC_RPC(pRakClient,InitGame);
UNREGISTER_STATIC_RPC(pRakClient,Chat);
UNREGISTER_STATIC_RPC(pRakClient,Unk6B);
UNREGISTER_STATIC_RPC(pRakClient,Unk25);