[saco] Implement/match ScrSetPlayerColor(...)

This commit is contained in:
RD42 2024-10-17 17:34:21 +08:00
parent 1ff45278eb
commit 5e46ec5702
7 changed files with 56 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#include "../main.h"
#include "../game/util.h"
extern CGame *pGame;
@ -84,3 +85,10 @@ void CLocalPlayer::Say(PCHAR szText)
//----------------------------------------------------------
void CLocalPlayer::SetPlayerColor(DWORD dwColor)
{
SetRadarColor(pNetGame->GetPlayerPool()->GetLocalPlayerID(),dwColor);
}
//----------------------------------------------------

View File

@ -96,6 +96,7 @@ public:
void Say(PCHAR szText);
void SetPlayerColor(DWORD dwColor);
BOOL IsSpectating() { return m_bIsSpectating; };
void ReturnToClassSelection() { m_bWantsAnotherClass = TRUE; };

View File

@ -13,7 +13,7 @@ CPlayerPool::CPlayerPool()
m_pLocalPlayer = new CLocalPlayer();
field_0 = 0;
field_22 = 0;
field_4 = 0;
m_LocalPlayerID = 0;
field_2F3A = 0;
}

View File

@ -8,8 +8,9 @@
class CPlayerPool
{
private:
int field_0;
short field_4;
PLAYERID m_LocalPlayerID;
std::string field_6;
int field_22;
CLocalPlayer *m_pLocalPlayer;
@ -33,6 +34,15 @@ public:
CLocalPlayer * GetLocalPlayer() { return m_pLocalPlayer; };
CRemotePlayer* GetAt(PLAYERID playerId) {
if(playerId > MAX_PLAYERS) { return NULL; }
CNetPlayer *pNetPlayer = m_pPlayers[playerId];
if(pNetPlayer) return pNetPlayer->m_pRemotePlayer;
return NULL;
};
PLAYERID GetLocalPlayerID() { return m_LocalPlayerID; };
CPlayerPool();
};

View File

@ -1,5 +1,6 @@
#include "../main.h"
#include "../game/util.h"
extern CGame *pGame;
@ -61,3 +62,11 @@ void CRemotePlayer::ResetAllSyncAttributes()
}
//----------------------------------------------------
void CRemotePlayer::SetPlayerColor(DWORD dwColor)
{
SetRadarColor(m_PlayerID,dwColor);
}
//----------------------------------------------------

View File

@ -57,6 +57,7 @@ public:
void ResetAllSyncAttributes();
void SetPlayerColor(DWORD dwColor);
};
//----------------------------------------------------

View File

@ -60,7 +60,6 @@ void ScrSetPlayerPos(RPCParameters *rpcParams) {}
void ScrUnk0D(RPCParameters *rpcParams) {}
void ScrPutPlayerInVehicle(RPCParameters *rpcParams) {}
void ScrRemovePlayerFromVehicle(RPCParameters *rpcParams) {}
void ScrSetPlayerColor(RPCParameters *rpcParams) {}
void ScrDisplayGameText(RPCParameters *rpcParams) {}
void ScrSetInterior(RPCParameters *rpcParams) {}
void ScrUnk9F(RPCParameters *rpcParams) {}
@ -149,6 +148,31 @@ void ScrSetPlayerHealth(RPCParameters *rpcParams)
pLocalPlayer->GetPlayerPed()->SetHealth(fHealth);
}
//----------------------------------------------------
void ScrSetPlayerColor(RPCParameters *rpcParams)
{
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();
PLAYERID playerId;
DWORD dwColor;
bsData.Read(playerId);
bsData.Read(dwColor);
if(playerId == pPlayerPool->GetLocalPlayerID()) {
pPlayerPool->GetLocalPlayer()->SetPlayerColor(dwColor);
} else {
CRemotePlayer *pPlayer = pPlayerPool->GetAt(playerId);
if(pPlayer) pPlayer->SetPlayerColor(dwColor);
}
}
//----------------------------------------------------
void ScrSetCameraPos(RPCParameters *rpcParams)