network #2

Merged
Persson-dev merged 23 commits from network into main 2024-08-22 08:30:03 +00:00
Showing only changes of commit d7e80e05de - Show all commits

View File

@@ -3,6 +3,7 @@
#include <blitz/godot/NetworkInterface.h>
#include <client/Player.h>
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
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);
}