diff options
Diffstat (limited to 'src/network/clientpackethandler.cpp')
-rw-r--r-- | src/network/clientpackethandler.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 78ace6a81..1f17470af 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <iostream> #include "client/client.h" #include "util/base64.h" @@ -33,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "server.h" #include "util/strfnd.h" #include "client/clientevent.h" +#include "client/content_cao.h" #include "client/sound.h" #include "network/clientopcodes.h" #include "network/connection.h" @@ -458,6 +460,9 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt) } */ + LocalPlayer *player = m_env.getLocalPlayer(); + bool try_reattach = player && player->isWaitingForReattach(); + try { u8 type; u16 removed_count, added_count, id; @@ -476,6 +481,8 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt) for (u16 i = 0; i < added_count; i++) { *pkt >> id >> type; m_env.addActiveObject(id, type, pkt->readLongString()); + if (try_reattach) + player->tryReattach(id); } } catch (PacketError &e) { infostream << "handleCommand_ActiveObjectRemoveAdd: " << e.what() @@ -602,12 +609,15 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt) LocalPlayer *player = m_env.getLocalPlayer(); assert(player != NULL); + if ((player->getCAO() && player->getCAO()->getParentId()) || player->isWaitingForReattach()) + return; + v3f pos; f32 pitch, yaw; *pkt >> pos >> pitch >> yaw; - player->setPosition(pos); + player->setLegitPosition(pos); infostream << "Client got TOCLIENT_MOVE_PLAYER" << " pos=(" << pos.X << "," << pos.Y << "," << pos.Z << ")" @@ -621,6 +631,10 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt) it would just force the pitch and yaw values to whatever the camera points to. */ + + if (g_settings->getBool("no_force_rotate")) + return; + ClientEvent *event = new ClientEvent(); event->type = CE_PLAYER_FORCE_MOVE; event->player_force_move.pitch = pitch; @@ -832,6 +846,11 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt) *pkt >> ephemeral; } catch (PacketError &e) {}; + SimpleSoundSpec sound_spec(name, gain, fade, pitch); + + if (m_mods_loaded && m_script->on_play_sound(sound_spec)) + return; + // Start playing int client_id = -1; switch(type) { @@ -981,6 +1000,9 @@ void Client::handleCommand_SpawnParticle(NetworkPacket* pkt) event->type = CE_SPAWN_PARTICLE; event->spawn_particle = new ParticleParameters(p); + if (m_mods_loaded && m_script->on_spawn_particle(*event->spawn_particle)) + return; + m_client_event_queue.push(event); } @@ -1178,6 +1200,12 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt) player->hud_flags &= ~mask; player->hud_flags |= flags; + if (g_settings->getBool("hud_flags_bypass")) + player->hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE | + HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE | + HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE | + HUD_FLAG_MINIMAP_RADAR_VISIBLE; + m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE); bool m_minimap_radar_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE); @@ -1492,6 +1520,8 @@ void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt) void Client::handleCommand_PlayerSpeed(NetworkPacket *pkt) { + if (g_settings->getBool("antiknockback")) + return; v3f added_vel; *pkt >> added_vel; |