[Fix] teleport to invalid map or invalid coordinates (x , y , z 200000, o ) given when teleporting player (g UI d full type player low , name , map , x , y , z , o ) (#1538)

* MoveSplineInitArgs::Validate: expression 'velocity > 0.01f' failed for GUID Full

* Update BotMovementUtils.h

* Playerbots: guard against invalid-Z teleports
This commit is contained in:
Alex Dcnh
2025-08-12 01:54:17 +02:00
committed by GitHub
parent 4e3ac609bd
commit ca2e2ef0db
11 changed files with 83 additions and 17 deletions

View File

@@ -49,4 +49,46 @@ int strcmpi(char const* s1, char const* s2);
#define GAI_VALUE(type, name) sSharedValueContext->getGlobalValue<type>(name)->Get()
#define GAI_VALUE2(type, name, param) sSharedValueContext->getGlobalValue<type>(name, param)->Get()
// ---- Safe teleport wrappers (module-only) ----
#include "Map.h"
#include <cmath>
#include "TravelMgr.h"
inline bool TeleportToSafe(Player* p, uint32 mapId, float x, float y, float z, float o)
{
if (!p) return false;
// If the height is invalid (-200000) or not finite, attempt ONE correction on the same map.
if (z <= -199000.0f || !std::isfinite(z))
{
if (p->GetMapId() == mapId && p->GetMap())
{
float hz = p->GetMap()->GetHeight(p->GetPhaseMask(), x, y, p->GetPositionZ(), true);
if (hz > -199000.0f && std::isfinite(hz))
z = hz;
else
return false; // still invalid -> cancel the TP
}
else
{
return false; // different map: do not "guess" the height here
}
}
return p->TeleportTo(mapId, x, y, z, o);
}
inline bool TeleportToSafe(Player* p, Position const& pos)
{
// Position doesn't have mapId: we keep actual bot map
return TeleportToSafe(p, p->GetMapId(),
pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(),
pos.GetOrientation());
}
inline bool TeleportToSafe(Player* p, WorldPosition pos)
{
return TeleportToSafe(p, pos.getMapId(), pos.getX(), pos.getY(), pos.getZ(), pos.getO());
}
// ---- /Safe teleport wrappers ----
#endif