Skip to content

Commit

Permalink
Fix false positive in onPlayerTeleport event when using `spawnPlaye…
Browse files Browse the repository at this point in the history
…r` (PR #3990)
  • Loading branch information
imfelipedev authored Jan 30, 2025
1 parent 5dceaf3 commit 1e7893c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CMapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ void CMapManager::SpawnPlayer(CPlayer& Player, const CVector& vecPosition, float

// Update the player data
Player.SetSpawned(true);
Player.SetTeleported(true);
Player.SetHealth(Player.GetMaxHealth());
Player.SetIsDead(false);
Player.SetWearingGoggles(false);
Expand Down
21 changes: 13 additions & 8 deletions Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,20 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream)
position.data.vecPosition += vecTempPos;
}

CVector playerPosition = pSourcePlayer->GetPosition();
float playerDistancePosition = DistanceBetweenPoints3D(playerPosition, position.data.vecPosition);
if (playerDistancePosition >= g_TickRateSettings.playerTeleportAlert) {
if (!pSourcePlayer->GetTeleported()) {
CLuaArguments arguments;
pSourcePlayer->CallEvent("onPlayerTeleport", arguments, nullptr);
}
if (position.data.vecPosition.fX != 0.0f && position.data.vecPosition.fY != 0.0f && position.data.vecPosition.fZ != 0.0f)
{
CVector playerPosition = pSourcePlayer->GetPosition();
float playerDistancePosition = DistanceBetweenPoints3D(playerPosition, position.data.vecPosition);
if (playerDistancePosition >= g_TickRateSettings.playerTeleportAlert)
{
if (!pSourcePlayer->GetTeleported())
{
CLuaArguments arguments;
pSourcePlayer->CallEvent("onPlayerTeleport", arguments, nullptr);
}

pSourcePlayer->SetTeleported(false);
pSourcePlayer->SetTeleported(false);
}
}

pSourcePlayer->SetPosition(position.data.vecPosition);
Expand Down

0 comments on commit 1e7893c

Please sign in to comment.