}
SendUpdates();
- input->Update(dt);
CheckPlayerFix();
CheckChunkQueue();
}
return;
}
glm::vec3 movement(0.0f);
- float pitch = 0.0f;
- float yaw = 0.0f;
uint8_t new_actions;
uint8_t slot;
player_update_pack = pack.Seq();
pack.ReadPredictedState(player_update_state);
pack.ReadMovement(movement);
- pack.ReadPitch(pitch);
- pack.ReadYaw(yaw);
pack.ReadActions(new_actions);
pack.ReadSlot(slot);
input->SetMovement(movement);
- input->TurnHead(pitch - input->GetPitch(), yaw - input->GetYaw());
+ input->TurnHead(player_update_state.pitch - input->GetPitch(), player_update_state.yaw - input->GetYaw());
input->SelectInventory(slot);
if ((new_actions & 0x01) && !(old_actions & 0x01)) {
pack.ReadMessage(msg);
if (type == 1 && HasPlayer()) {
- server.DistributeMessage(1, PlayerEntity().ID(), msg);
+ server.DispatchMessage(input->GetPlayer(), msg);
}
}
, world(world)
, spawn_index(world.Chunks().MakeIndex(wc.spawn, 3))
, save(save)
-, player_model(nullptr) {
+, player_model(nullptr)
+, cli(world) {
serv_sock = SDLNet_UDP_Open(conf.port);
if (!serv_sock) {
throw NetError("SDLNet_UDP_Open");
}
}
+void Server::DispatchMessage(Player &player, const string &msg) {
+ if (msg.empty()) {
+ return;
+ }
+ if (msg[0] == '/' && msg.size() > 1 && msg[1] != '/') {
+ cli.Execute(player, msg.substr(1));
+ } else {
+ DistributeMessage(1, player.GetEntity().ID(), msg);
+ }
+}
+
void Server::DistributeMessage(uint8_t type, uint32_t ref, const string &msg) {
auto pack = Packet::Make<Packet::Message>(serv_pack);
pack.WriteType(type);