From 3936b2b88274d6c213975b03739c0e6ffd95b0b5 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sat, 2 Jul 2022 14:49:45 -0400 Subject: [PATCH] [Fix] Boats should never get FixZ'd (#2246) * Boats should never get FixZ'd * Use member variable to avoid repetitive checks * Resolve comments from review * Fix return type --- zone/mob.cpp | 4 +++- zone/mob.h | 5 ++++- zone/mob_movement_manager.cpp | 2 +- zone/npc.cpp | 2 +- zone/waypoints.cpp | 4 ++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 3f420d972..f0ccdd901 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -512,6 +512,8 @@ Mob::Mob( mob_close_scan_timer.Trigger(); SetCanOpenDoors(true); + + is_boat = IsBoat(); } Mob::~Mob() @@ -3741,7 +3743,7 @@ bool Mob::HateSummon() { void Mob::FaceTarget(Mob* mob_to_face /*= 0*/) { - if (IsBoat()) { + if (GetIsBoat()) { return; } diff --git a/zone/mob.h b/zone/mob.h index 5b0920f5a..6f9b51934 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -630,7 +630,9 @@ public: inline const float GetSize() const { return size; } inline const float GetBaseSize() const { return base_size; } inline const GravityBehavior GetFlyMode() const { return flymode; } - bool IsBoat() const; + bool IsBoat() const; // Checks races - used on mob instantiation + bool GetIsBoat() const { return is_boat; } // Set on instantiation for speed + void SetIsBoat(bool boat) { is_boat = boat; } bool IsControllableBoat() const; inline const bool AlwaysAggro() const { return always_aggro; } @@ -1664,6 +1666,7 @@ protected: bool endur_upkeep; bool degenerating_effects; // true if we have a buff that needs to be recalced every tick bool spawned_in_water; + bool is_boat; CombatRecord combat_record{}; diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index c323a13c2..001bee9db 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -1075,7 +1075,7 @@ void MobMovementManager::UpdatePath(Mob *who, float x, float y, float z, MobMove return; } - if (who->IsBoat()) { + if (who->GetIsBoat()) { UpdatePathBoat(who, x, y, z, mob_movement_mode); } else if (who->IsUnderwaterOnly()) { diff --git a/zone/npc.cpp b/zone/npc.cpp index e1230857f..d6019ab92 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -236,7 +236,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi if (npc_type_data->flymode >= 0) { flymode = static_cast(npc_type_data->flymode); } - else if (IsBoat()) { + else if (GetIsBoat()) { flymode = GravityBehavior::Floating; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 8a31cb06d..a84e5a88e 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -809,6 +809,10 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) { return; } + if (GetIsBoat()) { + return; + } + if (flymode == GravityBehavior::Flying) { return; }