Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8718cc0
Added related functions
TracerDS Jun 3, 2024
58fe7db
Moved `CClientPed::Spawn` to `CClientPlayer` class
TracerDS Jun 4, 2024
fc5f800
Updated code according to reviews
TracerDS Jun 4, 2024
54c341f
Changes `IsSpawned` to `IsDead` in some places
TracerDS Jun 4, 2024
9e65c97
Merge github.com:TracerDS/mtasa-blue into 030624_NewFunction-isPlayer…
TracerDS Jun 22, 2024
30bebc7
Update according to reviews
TracerDS Jun 22, 2024
db6821e
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jun 22, 2024
20c02b3
Update according to reviews
TracerDS Jun 22, 2024
9cd7219
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jun 22, 2024
7939df5
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jun 24, 2024
04a644d
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jun 26, 2024
b9e98e6
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
Dutchman101 Jun 30, 2024
20f25b2
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 14, 2024
f2a6011
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 14, 2024
2e8adf5
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 15, 2024
346f9cc
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 15, 2024
4527f01
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 16, 2024
467048e
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 19, 2024
42536a9
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Jul 31, 2024
82c8767
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Aug 23, 2024
1c84853
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
TracerDS Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/ClientCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void DumpPlayer(CClientPlayer* pPlayer, FILE* pFile)
fprintf(pFile, "Armor: %f\n", pPlayer->GetArmor());
fprintf(pFile, "On screen: %u\n", pPlayer->IsOnScreen());
fprintf(pFile, "Frozen: %u\n", pPlayer->IsFrozen());
fprintf(pFile, "Respawn state: %i\n", pPlayer->GetRespawnState());
fprintf(pFile, "Respawn state: %u\n", pPlayer->IsSpawned());

fprintf(pFile, "Cur weapon slot: %i\n", static_cast<int>(pPlayer->GetCurrentWeaponSlot()));
fprintf(pFile, "Cur weapon type: %i\n", static_cast<int>(pPlayer->GetCurrentWeaponType()));
Expand Down
6 changes: 3 additions & 3 deletions Client/mods/deathmatch/logic/CClientPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
void StealthKill(CClientPed* pPed);
void BeHit(CClientPed* pClientPedAttacker, ePedPieceTypes hitBodyPart, int hitBodySide, int weaponId);

int GetRespawnState() const noexcept { return m_pRespawnState; };
void SetRespawnState(int iRespawnState) noexcept { m_pRespawnState = iRespawnState; };
int IsSpawned() const noexcept { return m_bIsSpawned; }
void SetSpawned(const bool bSpawned) noexcept { m_bIsSpawned = bSpawned; }

CWeapon* GiveWeapon(eWeaponType weaponType, unsigned int uiAmmo, bool bSetAsCurrent = false);
bool SetCurrentWeaponSlot(eWeaponSlot weaponSlot);
Expand Down Expand Up @@ -609,7 +609,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
CTaskManager* m_pTaskManager;
CPad* m_pPad;
bool m_bIsLocalPlayer;
int m_pRespawnState;
bool m_bIsSpawned;
unsigned long m_ulModel;
CMatrix m_matFrozen;
bool m_bRadioOn;
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ void CClientPlayer::Spawn(const CVector& vecPosition, float fRotation, unsigned
{
SetFrozenWaitingForGroundToLoad(true);
m_iLoadAllModelsCounter = 10;
SetPlayerSpawned(true);
}

// Remove any animation
Expand Down Expand Up @@ -246,6 +245,7 @@ void CClientPlayer::Spawn(const CVector& vecPosition, float fRotation, unsigned
}

// Set some states
SetSpawned(true);
SetFrozen(false);
Teleport(vecPosition);
SetCurrentRotationNew(fRotation);
Expand Down
5 changes: 0 additions & 5 deletions Client/mods/deathmatch/logic/CClientPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class CClientPlayer final : public CClientPed
// remove jetpack, etc...
void Spawn(const CVector& vecPosition, float fRotation, unsigned short usModel, unsigned char ucInterior);

bool IsPlayerSpawned() const noexcept { return m_bHasPlayerSpawned; }
void SetPlayerSpawned(const bool bSetSpawned) noexcept { m_bHasPlayerSpawned = bSetSpawned; }

unsigned long GetLastPuresyncTime() { return m_ulLastPuresyncTime; }
void SetLastPuresyncTime(unsigned long ulLastPuresyncTime) { m_ulLastPuresyncTime = ulLastPuresyncTime; }
const CVector& GetLastPuresyncPosition() { return m_vecLastPuresyncPosition; }
Expand Down Expand Up @@ -124,8 +121,6 @@ class CClientPlayer final : public CClientPed
uchar m_ucPrevBulletSyncOrderCounter;

private:
bool m_bHasPlayerSpawned{false};

bool m_bIsLocalPlayer;
SString m_strNick;

Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ int CLuaPlayerDefs::GetPlayerWantedLevel(lua_State* luaVM)

bool CLuaPlayerDefs::HasPlayerSpawned(CClientPlayer* player)
{
return player->IsPlayerSpawned();
return player->IsSpawned();
}


Expand Down
12 changes: 4 additions & 8 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,6 @@ void CGame::Packet_PlayerWasted(CPlayerWastedPacket& Packet)
CPlayer* pPlayer = Packet.GetSourcePlayer();
if (pPlayer && !pPlayer->IsDead())
{
pPlayer->SetSpawned(false);
pPlayer->SetIsDead(true);
pPlayer->SetHealth(0.0f);
pPlayer->SetArmor(0.0f);
Expand Down Expand Up @@ -2995,8 +2994,8 @@ void CGame::Packet_Vehicle_InOut(CVehicleInOutPacket& Packet)
FAIL_TRAILER,
} failReason = FAIL_INVALID;

// Is he spawned? (Fix for #2335)
if (!pPed->IsSpawned())
// Is he dead? (Fix for #2335)
if (pPed->IsDead())
{
CVehicleInOutPacket Reply(PedID, VehicleID, 0, VEHICLE_ATTEMPT_FAILED);
pPlayer->Send(Reply);
Expand Down Expand Up @@ -3735,8 +3734,8 @@ void CGame::Packet_VehicleTrailer(CVehicleTrailerPacket& Packet)
CPlayer* pPlayer = Packet.GetSourcePlayer();
if (pPlayer && pPlayer->IsJoined())
{
// Spawned?
if (pPlayer->IsSpawned())
// Alive?
if (!pPlayer->IsDead())
{
// Grab the vehicle with the chosen ID
ElementID ID = Packet.GetVehicle();
Expand Down Expand Up @@ -4296,9 +4295,6 @@ void CGame::PlayerCompleteConnect(CPlayer* pPlayer)

// Send him the join details
pPlayer->Send(CPlayerConnectCompletePacket());

// The player is spawned when he's connected, just the Camera is not faded in/not targetting
pPlayer->SetSpawned(true);
}

void CGame::Lock()
Expand Down
1 change: 0 additions & 1 deletion Server/mods/deathmatch/logic/CMapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ void CMapManager::SpawnPlayer(CPlayer& Player, const CVector& vecPosition, float
}

// Update the player data
Player.SetPlayerSpawned(true);
Player.SetSpawned(true);
Player.SetHealth(Player.GetMaxHealth());
Player.SetIsDead(false);
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CPickup.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class CPickup final : public CElement, private CColCallback
bool CanUse(class CPlayer& Player, bool bOnfootCheck = true);
void Use(class CPlayer& Player);

bool IsSpawned() { return m_bSpawned; }
void SetSpawned(bool bSpawned) { m_bSpawned = bSpawned; }
bool IsSpawned() const noexcept { return m_bSpawned; }
void SetSpawned(bool bSpawned) noexcept { m_bSpawned = bSpawned; }

CColShape* GetColShape() { return m_pCollision; }
void SetEnabled(bool bEnabled)
Expand Down
5 changes: 0 additions & 5 deletions Server/mods/deathmatch/logic/CPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class CPlayer final : public CPed, public CClient
bool IsJoined() { return m_bIsJoined; }
void SetJoined() { m_bIsJoined = true; }

bool IsPlayerSpawned() const noexcept { return m_bHasPlayerSpawned; }
void SetPlayerSpawned(const bool bSetSpawned) noexcept { m_bHasPlayerSpawned = bSetSpawned; }

bool SubscribeElementData(CElement* pElement, const std::string& strName);
bool UnsubscribeElementData(CElement* pElement, const std::string& strName);
bool UnsubscribeElementData(CElement* pElement);
Expand Down Expand Up @@ -468,6 +465,4 @@ class CPlayer final : public CPed, public CClient

ushort m_usPrevDimension;
SString m_strQuitReasonForLog;

bool m_bHasPlayerSpawned;
};
3 changes: 1 addition & 2 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,8 +2136,8 @@ CPed* CStaticFunctionDefinitions::CreatePed(CResource* pResource, unsigned short
}

pPed->SetPosition(vecPosition);
pPed->SetIsDead(false);
pPed->SetSpawned(true);
pPed->SetIsDead(false);
pPed->SetHealth(100.0f);
pPed->SetSyncable(bSynced);

Expand Down Expand Up @@ -3722,7 +3722,6 @@ bool CStaticFunctionDefinitions::KillPed(CElement* pElement, CElement* pKiller,
}

// Update the ped
pPed->SetSpawned(false);
pPed->SetIsDead(true);
pPed->SetHealth(0.0f);
pPed->SetArmor(0.0f);
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ unsigned int CLuaPlayerDefs::GetPlayerScriptDebugLevel(CPlayer* const player)

bool CLuaPlayerDefs::HasPlayerSpawned(CPlayer* player)
{
return player->IsPlayerSpawned();
return player->IsSpawned();
}

int CLuaPlayerDefs::BindKey(lua_State* luaVM)
Expand Down