Skip to content

Commit 1e7893c

Browse files
authored
Fix false positive in onPlayerTeleport event when using spawnPlayer (PR #3990)
1 parent 5dceaf3 commit 1e7893c

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Server/mods/deathmatch/logic/CMapManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ void CMapManager::SpawnPlayer(CPlayer& Player, const CVector& vecPosition, float
593593

594594
// Update the player data
595595
Player.SetSpawned(true);
596+
Player.SetTeleported(true);
596597
Player.SetHealth(Player.GetMaxHealth());
597598
Player.SetIsDead(false);
598599
Player.SetWearingGoggles(false);

Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,20 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream)
132132
position.data.vecPosition += vecTempPos;
133133
}
134134

135-
CVector playerPosition = pSourcePlayer->GetPosition();
136-
float playerDistancePosition = DistanceBetweenPoints3D(playerPosition, position.data.vecPosition);
137-
if (playerDistancePosition >= g_TickRateSettings.playerTeleportAlert) {
138-
if (!pSourcePlayer->GetTeleported()) {
139-
CLuaArguments arguments;
140-
pSourcePlayer->CallEvent("onPlayerTeleport", arguments, nullptr);
141-
}
135+
if (position.data.vecPosition.fX != 0.0f && position.data.vecPosition.fY != 0.0f && position.data.vecPosition.fZ != 0.0f)
136+
{
137+
CVector playerPosition = pSourcePlayer->GetPosition();
138+
float playerDistancePosition = DistanceBetweenPoints3D(playerPosition, position.data.vecPosition);
139+
if (playerDistancePosition >= g_TickRateSettings.playerTeleportAlert)
140+
{
141+
if (!pSourcePlayer->GetTeleported())
142+
{
143+
CLuaArguments arguments;
144+
pSourcePlayer->CallEvent("onPlayerTeleport", arguments, nullptr);
145+
}
142146

143-
pSourcePlayer->SetTeleported(false);
147+
pSourcePlayer->SetTeleported(false);
148+
}
144149
}
145150

146151
pSourcePlayer->SetPosition(position.data.vecPosition);

0 commit comments

Comments
 (0)