generated from Persson-dev/Godot-Xmake
add server side speed check
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <blitz/godot/NetworkInterface.h>
|
#include <blitz/godot/NetworkInterface.h>
|
||||||
#include <client/Player.h>
|
#include <client/Player.h>
|
||||||
#include <godot_cpp/classes/engine.hpp>
|
#include <godot_cpp/classes/engine.hpp>
|
||||||
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
|
||||||
namespace blitz {
|
namespace blitz {
|
||||||
|
|
||||||
@@ -41,6 +42,16 @@ void ServerWorld::HandlePacket(const protocol::packets::PlayerPositionAndRotatio
|
|||||||
if (data.m_Player != a_PlayerPos.m_Sender)
|
if (data.m_Player != a_PlayerPos.m_Sender)
|
||||||
return;
|
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);
|
SetPlayerPositionAndRotation(data.m_Player, data.m_Position, data.m_Rotation, data.m_Velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user