mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 14:37:29 +08:00
[bot] Implement ServerJoin(...)
* Implement `CPlayerPool::New(...)`
This commit is contained in:
parent
2aa2b1e628
commit
a88d88bb26
@ -11,10 +11,35 @@ extern ONFOOT_SYNC_DATA ofSync;
|
||||
extern bool bSpawned;
|
||||
|
||||
//----------------------------------------------------
|
||||
// Sent when a client joins the server we're
|
||||
// currently connected to.
|
||||
|
||||
void Unk89(RPCParameters *rpcParams)
|
||||
void ServerJoin(RPCParameters *rpcParams)
|
||||
{
|
||||
// TODO: Unk89
|
||||
PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
|
||||
int iBitLength = rpcParams->numberOfBitsOfData;
|
||||
PlayerID sender = rpcParams->sender;
|
||||
|
||||
RakNet::BitStream bsData(Data,(iBitLength/8)+1,false);
|
||||
CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool();
|
||||
CHAR szPlayerName[MAX_PLAYER_NAME+1];
|
||||
PLAYERID playerId;
|
||||
DWORD dwColor;
|
||||
BYTE byteNameLen=0;
|
||||
BYTE byteNPC;
|
||||
|
||||
bsData.Read(playerId);
|
||||
bsData.Read(dwColor);
|
||||
bsData.Read(byteNPC);
|
||||
bsData.Read(byteNameLen);
|
||||
|
||||
if(byteNameLen > MAX_PLAYER_NAME) return;
|
||||
|
||||
bsData.Read(szPlayerName,byteNameLen);
|
||||
szPlayerName[byteNameLen] = '\0';
|
||||
|
||||
// Add this client to the player pool.
|
||||
pPlayerPool->New(playerId, szPlayerName);
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -434,7 +459,7 @@ void RegisterRPCs(RakClientInterface * pRakClient)
|
||||
REGISTER_STATIC_RPC(pRakClient,Weather);
|
||||
REGISTER_STATIC_RPC(pRakClient,Unk1D);
|
||||
REGISTER_STATIC_RPC(pRakClient,Unk1E);
|
||||
REGISTER_STATIC_RPC(pRakClient,Unk89);
|
||||
REGISTER_STATIC_RPC(pRakClient,ServerJoin);
|
||||
REGISTER_STATIC_RPC(pRakClient,ServerQuit);
|
||||
REGISTER_STATIC_RPC(pRakClient,InitGame);
|
||||
REGISTER_STATIC_RPC(pRakClient,Chat);
|
||||
@ -475,7 +500,7 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
|
||||
UNREGISTER_STATIC_RPC(pRakClient,UnkA3);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,UnkA4);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,UnkA5);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Unk89);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,ServerJoin);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,ServerQuit);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,InitGame);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Chat);
|
||||
|
@ -29,6 +29,16 @@ CPlayerPool::~CPlayerPool()
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
BOOL CPlayerPool::New(PLAYERID playerId, PCHAR szPlayerName)
|
||||
{
|
||||
m_bPlayerSlotState[playerId] = TRUE;
|
||||
strcpy(m_szPlayerNames[playerId], szPlayerName);
|
||||
pNetGame->SetPlayerAdded(playerId, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
BOOL CPlayerPool::Delete(PLAYERID playerId, BYTE byteReason)
|
||||
{
|
||||
m_bPlayerSlotState[playerId] = FALSE;
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
CPlayerPool();
|
||||
~CPlayerPool();
|
||||
|
||||
BOOL New(PLAYERID playerId, PCHAR szPlayerName);
|
||||
BOOL Delete(PLAYERID playerId, BYTE byteReason);
|
||||
|
||||
// Find out if the slot is inuse.
|
||||
|
@ -45,7 +45,7 @@
|
||||
#define RPC_Unk18 "\x18"
|
||||
#define RPC_EnterVehicle "\x1A"
|
||||
#define RPC_ExitVehicle "\x9A"
|
||||
#define RPC_Unk89 "\x89"
|
||||
#define RPC_ServerJoin "\x89"
|
||||
#define RPC_ServerQuit "\x8A"
|
||||
#define RPC_InitGame "\x8B"
|
||||
#define RPC_Chat "\x65"
|
||||
|
@ -34,7 +34,7 @@ void DamageVehicle(RPCParameters *rpcParams) {}
|
||||
void Unk18(RPCParameters *rpcParams) {}
|
||||
void EnterVehicle(RPCParameters *rpcParams) {}
|
||||
void ExitVehicle(RPCParameters *rpcParams) {}
|
||||
void Unk89(RPCParameters *rpcParams) {}
|
||||
void ServerJoin(RPCParameters *rpcParams) {}
|
||||
void ServerQuit(RPCParameters *rpcParams) {}
|
||||
void InitGame(RPCParameters *rpcParams) {}
|
||||
void Chat(RPCParameters *rpcParams) {}
|
||||
@ -85,7 +85,7 @@ void RegisterRPCs(RakClientInterface * pRakClient)
|
||||
REGISTER_STATIC_RPC(pRakClient,Unk18);
|
||||
REGISTER_STATIC_RPC(pRakClient,EnterVehicle);
|
||||
REGISTER_STATIC_RPC(pRakClient,ExitVehicle);
|
||||
REGISTER_STATIC_RPC(pRakClient,Unk89);
|
||||
REGISTER_STATIC_RPC(pRakClient,ServerJoin);
|
||||
REGISTER_STATIC_RPC(pRakClient,ServerQuit);
|
||||
REGISTER_STATIC_RPC(pRakClient,InitGame);
|
||||
REGISTER_STATIC_RPC(pRakClient,Chat);
|
||||
@ -122,7 +122,7 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Unk3A);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Unk3B);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Unk3D);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Unk89);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,ServerJoin);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,ServerQuit);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,InitGame);
|
||||
UNREGISTER_STATIC_RPC(pRakClient,Chat);
|
||||
|
Loading…
Reference in New Issue
Block a user