Some bug fixes

This commit is contained in:
KimLS 2018-09-20 22:08:35 -07:00
parent 7278c6294d
commit 4815cabb63
6 changed files with 59 additions and 40 deletions

View File

@ -7260,6 +7260,7 @@ void command_pf(Client *c, const Seperator *sep)
c->Message(0, "POS: (%.2f, %.2f, %.2f)", who->GetX(), who->GetY(), who->GetZ());
c->Message(0, "WP: %s (%d/%d)", to_string(who->GetCurrentWayPoint()).c_str(), who->IsNPC()?who->CastToNPC()->GetMaxWp():-1);
c->Message(0, "pause=%d RAspeed=%d", who->GetCWPP(), who->GetRunAnimSpeed());
who->DumpMovement(c);
} else {
c->Message(0, "ERROR: target required");
}

View File

@ -969,7 +969,7 @@ public:
inline bool CheckAggro(Mob* other) {return hate_list.IsEntOnHateList(other);}
float CalculateHeadingToTarget(float in_x, float in_y) { return HeadingAngleToMob(in_x, in_y); }
virtual void CalculateNewPosition(float x, float y, float z, float speed, bool check_z = true, bool calculate_heading = true);
void CalculateNewPosition(float x, float y, float z, float speed, bool check_z = true, bool calculate_heading = true);
float CalculateDistance(float x, float y, float z);
float GetGroundZ(float new_x, float new_y, float z_offset=0.0);
void SendTo(float new_x, float new_y, float new_z);
@ -978,7 +978,8 @@ public:
float GetDefaultRaceSize() const;
void TryFixZ(int32 z_find_offset = 5, bool fix_client_z = false);
void FixZ(int32 z_find_offset = 5, bool fix_client_z = false);
float GetFixedZ(glm::vec3 destination, int32 z_find_offset = 5);
float GetFixedZ(const glm::vec3 &destination, int32 z_find_offset = 5);
void DumpMovement(Client *to);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false);
inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; }

View File

@ -185,6 +185,35 @@ void MobMovementManager::StopNavigation(Mob *who) {
auto iter = _impl->MoveEntries.find(who);
auto &ent = iter->second;
ent.active = false;
SendPosition(who);
}
void MobMovementManager::Dump(Mob *m, Client *to)
{
{
auto iter = _impl->Entries.find(m);
auto &ent = iter->second;
to->Message(0, "Packet: anim=%d, heading=%.2f, dirty=%s, last_sent_time=%.2f, last_sent_time_long_dist=%.2f",
ent.animation,
ent.heading,
ent.dirty ? "true" : "false",
ent.last_sent_time,
ent.last_sent_time_long_distance);
}
{
auto iter = _impl->MoveEntries.find(m);
auto &ent = iter->second;
to->Message(0, "Movement: speed=%.2f, x=%.2f, y=%.2f, z=%.2f, active=%s",
ent.speed,
ent.x,
ent.y,
ent.z,
ent.active ? "true" : "false");
}
}
bool MobMovementManager::HeadingEqual(float a, float b)

View File

@ -18,6 +18,7 @@ public:
void SendPositionUpdate(Mob *who, bool send_to_self);
void NavigateTo(Mob *who, float x, float y, float z, float speed);
void StopNavigation(Mob *who);
void Dump(Mob *m, Client *to);
static MobMovementManager &Get() {
static MobMovementManager inst;

View File

@ -7,21 +7,6 @@
extern Zone *zone;
void AdjustRoute(std::list<IPathfinder::IPathNode> &nodes, int flymode, float offset) {
if (!zone->HasMap() || !zone->HasWaterMap()) {
return;
}
for (auto &node : nodes) {
if (flymode == GravityBehavior::Ground || !zone->watermap->InLiquid(node.pos)) {
auto best_z = zone->zonemap->FindBestZ(node.pos, nullptr);
if (best_z != BEST_Z_INVALID) {
node.pos.z = best_z + offset;
}
}
}
}
glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChanged, bool &NodeReached)
{
glm::vec3 To(ToX, ToY, ToZ);
@ -42,7 +27,6 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
bool partial = false;
bool stuck = false;
Route = zone->pathing->FindRoute(From, To, partial, stuck);
AdjustRoute(Route, flymode, GetZOffset());
PathingDestination = To;
WaypointChanged = true;
@ -66,7 +50,6 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
bool partial = false;
bool stuck = false;
Route = zone->pathing->FindRoute(From, To, partial, stuck);
AdjustRoute(Route, flymode, GetZOffset());
PathingDestination = To;
WaypointChanged = true;
@ -86,27 +69,27 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
}
if (!IsRooted()) {
//bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f;
//if (AtPrevNode) {
// PathingLoopCount++;
// auto front = (*Route.begin()).pos;
//
// if (PathingLoopCount > 5) {
// Teleport(front);
// SendPosition();
// Route.pop_front();
//
// WaypointChanged = true;
// NodeReached = true;
// PathingLoopCount = 0;
// }
//
// return front;
//}
//else {
bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f;
if (AtPrevNode) {
PathingLoopCount++;
auto front = (*Route.begin()).pos;
if (PathingLoopCount > 5) {
Teleport(front);
SendPosition();
Route.pop_front();
WaypointChanged = true;
NodeReached = true;
PathingLoopCount = 0;
}
return front;
}
else {
PathingLastPosition = From;
PathingLoopCount = 0;
//}
}
}
else {
PathingLastPosition = From;
@ -133,7 +116,6 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
bool partial = false;
bool stuck = false;
Route = zone->pathing->FindRoute(From, To, partial, stuck);
AdjustRoute(Route, flymode, GetZOffset());
PathingDestination = To;
WaypointChanged = true;

View File

@ -573,7 +573,7 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
}
}
float Mob::GetFixedZ(glm::vec3 destination, int32 z_find_offset) {
float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
BenchTimer timer;
timer.reset();
@ -615,6 +615,11 @@ float Mob::GetFixedZ(glm::vec3 destination, int32 z_find_offset) {
return new_z;
}
void Mob::DumpMovement(Client *to)
{
mMovementManager->Dump(this, to);
}
void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
glm::vec3 current_loc(m_Position);