From 89aa344e9cf361bb60822627bd93a23b850e6b45 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Nov 2022 18:44:40 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 27 +++++++++++++++++++++++++++ server/gameserver/mapinstance.cc | 6 +++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 1d944bdb..601dfcb6 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -39,6 +39,7 @@ #include "skillhelper.h" #include "shot.h" #include "battledatacontext.h" +#include "mapinstance.h" const int kReviveTimeAdd = 12; const int kSkinNum = 4; @@ -3531,6 +3532,31 @@ void Human::OnLand() if (IsPlayer()) { StartRefreshViewTimer(); } +#ifdef MAP3D + { + a8::Vec3 center; + center.x = GetPos().x / 10; + center.z = GetPos().y / 10; + a8::Vec3 point; + bool ok = room->map_instance->FindNearestPoint(center, 2, point); + if (!ok) { + abort(); + } + a8::Vec2 new_pos; + new_pos.x = point.x * 10; + new_pos.y = point.z * 10; + SetPos(new_pos); +#ifdef DEBUG + a8::XPrintf("OnLoad ok:%d pos:%f,%f,%f\n", + { + ok ? 1 : 0, + point.x, + point.y, + point.z + }); +#endif + } +#else if (CheckCollision()) { a8::Vec2 old_pos = GetPos(); std::vector dirs; @@ -3551,6 +3577,7 @@ void Human::OnLand() } SetPos(old_pos); } +#endif if (IsAndroid()) { int buff_uniid = MustBeAddBuff(this, kPeaceModeBuffId diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 645c4594..6fd2e0b6 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -730,7 +730,7 @@ bool MapInstance::FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec filter.setIncludeFlags(0xffff); filter.setExcludeFlags(0); - const float extents[3] = {2.f, 4.f, 2.f}; + const float extents[3] = {radius, radius, radius}; float nearestPt[3]; float pos[3]; @@ -740,7 +740,11 @@ bool MapInstance::FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec navmesh_query_->findNearestPoly(pos, extents, &filter, &startRef, nearestPt); if (!startRef) { + return false; } + nearest_pt.x = nearestPt[0]; + nearest_pt.y = nearestPt[1]; + nearest_pt.z = nearestPt[2]; return true; }