diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 006c1201..98026a0c 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -351,6 +351,7 @@ class Creature : public MoveableEntity const mt::Equip* bullet_meta); bool CanShot(bool try_reload); void AdjustPos(); + void OnLand(); protected: virtual void OnBuffRemove(Buff& buff); @@ -372,7 +373,6 @@ private: void CheckAbilityUsed(); void AutoSwitchWeapon(); void CheckLoadingBullet(); - void OnLand(); protected: bool need_sync_active_player_ = false; diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index a12faaa8..932f1fb9 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -1295,3 +1295,20 @@ bool MapInstance::IsConnectablePoly(dtPolyRef poly_ref) { return connectable_polys_.find(poly_ref) != connectable_polys_.end(); } + +bool MapInstance::IsValidPos(const glm::vec3& point) +{ + if (point.x >= GetMapMeta()->map_width()) { + return false; + } + if (point.x <= 0) { + return false; + } + if (point.z >= GetMapMeta()->map_height()) { + return false; + } + if (point.z <= 0) { + return false; + } + return true; +} diff --git a/server/gameserver/mapinstance.h b/server/gameserver/mapinstance.h index 02ec160f..1cc63223 100644 --- a/server/gameserver/mapinstance.h +++ b/server/gameserver/mapinstance.h @@ -62,6 +62,7 @@ class MapInstance : public std::enable_shared_from_this bool GetNearestGrass(const glm::vec3& center, glm::vec3& out_pt); void AdjustOnLandPoint(glm::vec3& point); bool IsConnectablePoly(dtPolyRef poly_ref); + bool IsValidPos(const glm::vec3& point); private: void LoadHouse(); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 5a77d3a5..407c5f0f 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -30,6 +30,7 @@ #include "buff.h" #include "stats.h" #include "guide.h" +#include "mapinstance.h" #include "mt/Param.h" #include "mt/Equip.h" @@ -1039,10 +1040,17 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg) sand_table_target_pos = std::make_shared(); } TypeConvert::FromPb(*sand_table_target_pos, &msg.sand_table_target_pos()); - if (GlmHelper::IsEqual2D(*sand_table_target_pos, GetPos().ToGlmVec3())) { + if (GlmHelper::IsEqual2D(*sand_table_target_pos, GetPos().ToGlmVec3()) || + !room->map_instance->IsValidPos(*sand_table_target_pos)) { sand_table_target_pos = nullptr; } else { - glm::vec3 dir = *sand_table_target_pos - GetPos().ToGlmVec3(); + glm::vec3 target_dir = *sand_table_target_pos - GetPos().ToGlmVec3(); + target_dir = glm::vec3(target_dir.x, 0.0f, target_dir.z); + float distance = GlmHelper::Norm(target_dir); + GlmHelper::Normalize(target_dir); + SetMoveDir(target_dir); + SetAttackDir(target_dir); + GetMovement()->CalcTargetPos(distance); } } else { sand_table_target_pos = nullptr; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 0a186489..c2ebd0bd 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1294,6 +1294,17 @@ void Room::UpdateGasInactivePvp() ForwardGasRing(map_meta_->init_gas_ring()); } } + TraverseHumanList + ( + [] (Human* hum) -> bool + { + hum->RemoveBuffByEffectId(kBET_ThroughWall); + hum->OnLand(); + if (hum->GetEntitySubType() == EST_Player) { + GameLog::Instance()->GameStart((Player*)hum); + } + return true; + }); NotifyUiUpdate(); NotifyGameStart(); } else {