From fe626fdce51ebeecca87924a728fa3f9a2df70dd Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 20 Sep 2024 23:35:31 +0800 Subject: [PATCH] [server] Implement/match `CPlayer::SetPlayerColor(...)` --- bot/net/scriptrpc.cpp | 6 +++--- raknet/SAMPRPC.h | 2 +- saco/net/scriptrpc.cpp | 6 +++--- server/player.cpp | 12 ++++++++++++ server/player.h | 4 +++- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bot/net/scriptrpc.cpp b/bot/net/scriptrpc.cpp index 84aa4e1..196cd3f 100644 --- a/bot/net/scriptrpc.cpp +++ b/bot/net/scriptrpc.cpp @@ -104,7 +104,7 @@ void ScrRemovePlayerFromVehicle(RPCParameters *rpcParams) //---------------------------------------------------- -void ScrUnk48(RPCParameters *rpcParams) +void ScrSetPlayerColor(RPCParameters *rpcParams) { } @@ -497,7 +497,7 @@ void RegisterScriptRPCs(RakClientInterface* pRakClient) REGISTER_STATIC_RPC(pRakClient, ScrUnk0E); REGISTER_STATIC_RPC(pRakClient, ScrPutPlayerInVehicle); REGISTER_STATIC_RPC(pRakClient, ScrRemovePlayerFromVehicle); - REGISTER_STATIC_RPC(pRakClient, ScrUnk48); + REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerColor); REGISTER_STATIC_RPC(pRakClient, ScrDisplayGameText); REGISTER_STATIC_RPC(pRakClient, ScrUnk9C); REGISTER_STATIC_RPC(pRakClient, ScrUnk9D); @@ -571,7 +571,7 @@ void UnRegisterScriptRPCs(RakClientInterface* pRakClient) UNREGISTER_STATIC_RPC(pRakClient, ScrUnk0E); UNREGISTER_STATIC_RPC(pRakClient, ScrPutPlayerInVehicle); UNREGISTER_STATIC_RPC(pRakClient, ScrRemovePlayerFromVehicle); - UNREGISTER_STATIC_RPC(pRakClient, ScrUnk48); + UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerColor); UNREGISTER_STATIC_RPC(pRakClient, ScrDisplayGameText); UNREGISTER_STATIC_RPC(pRakClient, ScrUnk9C); UNREGISTER_STATIC_RPC(pRakClient, ScrUnk9D); diff --git a/raknet/SAMPRPC.h b/raknet/SAMPRPC.h index d9e743b..4923590 100644 --- a/raknet/SAMPRPC.h +++ b/raknet/SAMPRPC.h @@ -132,7 +132,7 @@ #define RPC_ScrUnk0E "\x0E" #define RPC_ScrPutPlayerInVehicle "\x46" #define RPC_ScrRemovePlayerFromVehicle "\x47" -#define RPC_ScrUnk48 "\x48" +#define RPC_ScrSetPlayerColor "\x48" #define RPC_ScrDisplayGameText "\x49" #define RPC_ScrUnk9C "\x9C" #define RPC_ScrSetCameraPos "\x9D" diff --git a/saco/net/scriptrpc.cpp b/saco/net/scriptrpc.cpp index 58c4f32..ca09d9d 100644 --- a/saco/net/scriptrpc.cpp +++ b/saco/net/scriptrpc.cpp @@ -59,7 +59,7 @@ void ScrUnk0D(RPCParameters *rpcParams) {} void ScrUnk0E(RPCParameters *rpcParams) {} void ScrPutPlayerInVehicle(RPCParameters *rpcParams) {} void ScrRemovePlayerFromVehicle(RPCParameters *rpcParams) {} -void ScrUnk48(RPCParameters *rpcParams) {} +void ScrSetPlayerColor(RPCParameters *rpcParams) {} void ScrDisplayGameText(RPCParameters *rpcParams) {} void ScrUnk9C(RPCParameters *rpcParams) {} void ScrUnk9D(RPCParameters *rpcParams) {} @@ -159,7 +159,7 @@ void RegisterScriptRPCs(RakClientInterface* pRakClient) REGISTER_STATIC_RPC(pRakClient, ScrUnk0E); REGISTER_STATIC_RPC(pRakClient, ScrPutPlayerInVehicle); REGISTER_STATIC_RPC(pRakClient, ScrRemovePlayerFromVehicle); - REGISTER_STATIC_RPC(pRakClient, ScrUnk48); + REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerColor); REGISTER_STATIC_RPC(pRakClient, ScrDisplayGameText); REGISTER_STATIC_RPC(pRakClient, ScrUnk9C); REGISTER_STATIC_RPC(pRakClient, ScrUnk9D); @@ -267,7 +267,7 @@ void UnRegisterScriptRPCs(RakClientInterface* pRakClient) UNREGISTER_STATIC_RPC(pRakClient, ScrUnk0E); UNREGISTER_STATIC_RPC(pRakClient, ScrPutPlayerInVehicle); UNREGISTER_STATIC_RPC(pRakClient, ScrRemovePlayerFromVehicle); - UNREGISTER_STATIC_RPC(pRakClient, ScrUnk48); + UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerColor); UNREGISTER_STATIC_RPC(pRakClient, ScrDisplayGameText); UNREGISTER_STATIC_RPC(pRakClient, ScrUnk9C); UNREGISTER_STATIC_RPC(pRakClient, ScrUnk9D); diff --git a/server/player.cpp b/server/player.cpp index 469d65e..4f9f72d 100644 --- a/server/player.cpp +++ b/server/player.cpp @@ -23,7 +23,19 @@ void CPlayer::SetSpawnInfo(PLAYER_SPAWN_INFO *pSpawn) +//---------------------------------------------------- +void CPlayer::SetPlayerColor(DWORD dwColor) +{ + RakNet::BitStream bsColor; + + m_dwColor = dwColor; + + bsColor.Write(m_PlayerID); + bsColor.Write(dwColor); + + pNetGame->BroadcastData(RPC_ScrSetPlayerColor, &bsColor, INVALID_PLAYER_ID, 2); +} //---------------------------------------------------- diff --git a/server/player.h b/server/player.h index 007e8d7..a46e784 100644 --- a/server/player.h +++ b/server/player.h @@ -184,7 +184,7 @@ public: char field_2C30; char field_2C31; VEHICLEID m_VehicleID; - int field_2C34; + DWORD m_dwColor; BOOL m_bCheckpointEnabled; BOOL m_bRaceCheckpointEnabled; int m_iInteriorId; @@ -223,6 +223,8 @@ public: void SetSpawnInfo(PLAYER_SPAWN_INFO *pSpawn); + void SetPlayerColor(DWORD dwColor); + void SetCheckpoint(float fX, float fY, float fZ, float fSize); void ToggleCheckpoint(BOOL bEnabled); void SetRaceCheckpoint(int iType, float fX, float fY, float fZ, float fNX, float fNY, float fNZ, float fSize);