diff --git a/src/server/ServerWorld.cpp b/src/server/ServerWorld.cpp index a556d1d..5d8cebf 100644 --- a/src/server/ServerWorld.cpp +++ b/src/server/ServerWorld.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace blitz { @@ -41,6 +42,16 @@ void ServerWorld::HandlePacket(const protocol::packets::PlayerPositionAndRotatio if (data.m_Player != a_PlayerPos.m_Sender) return; + Player* player = GetPlayerById(data.m_Player); + if (!player) + return; + + if ((data.m_Position - player->get_position()).length() > 10) { + UtilityFunctions::print( + "Player ", data.m_Player, " moved too fast ! (from ", player->get_position(), " to ", data.m_Position, ")"); + return; + } + SetPlayerPositionAndRotation(data.m_Player, data.m_Position, data.m_Rotation, data.m_Velocity); }