From d3b46becd09919994665cbfd875e6a1fa048ef6b Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 17 Dec 2023 20:24:24 -0500 Subject: [PATCH] [Bug Fix] Fix NPCs routing to 0.0, 0.0 on #summon (#3780) # Notes - Resolves #2474. --- zone/gm_commands/summon.cpp | 33 ++++++++++++++------------------- zone/mob.cpp | 4 ++-- zone/mob.h | 2 +- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/zone/gm_commands/summon.cpp b/zone/gm_commands/summon.cpp index 659349546..ead556744 100755 --- a/zone/gm_commands/summon.cpp +++ b/zone/gm_commands/summon.cpp @@ -3,19 +3,16 @@ extern WorldServer worldserver; -#include "../corpse.h" - void command_summon(Client *c, const Seperator *sep) { - int arguments = sep->argnum; + const int arguments = sep->argnum; if (!arguments && !c->GetTarget()) { c->Message(Chat::White, "Usage: #summon - Summon your target, if you have one, to your position"); c->Message(Chat::White, "Usage: #summon [Character Name] - Summon a character by name to your position"); - c->Message(Chat::White, "Note: You may also summon your target if you have one."); return; } - Mob* t = c; + Mob *t = c; if (arguments == 1) { std::string character_name = sep->arg[1]; @@ -31,9 +28,9 @@ void command_summon(Client *c, const Seperator *sep) return; } - auto search_client = entity_list.GetClientByName(character_name.c_str()); - if (search_client) { - t = search_client->CastToMob(); + Client *s = entity_list.GetClientByName(character_name.c_str()); + if (s) { + t = s->CastToMob(); } else { if (!worldserver.Connected()) { c->Message(Chat::White, "World server is currently disconnected."); @@ -42,15 +39,18 @@ void command_summon(Client *c, const Seperator *sep) auto pack = new ServerPacket(ServerOP_ZonePlayer, sizeof(ServerZonePlayer_Struct)); auto szp = (ServerZonePlayer_Struct *) pack->pBuffer; + strn0cpy(szp->adminname, c->GetName(), sizeof(szp->adminname)); - szp->adminrank = c->Admin(); - szp->ignorerestrictions = 2; strn0cpy(szp->name, character_name.c_str(), sizeof(szp->name)); strn0cpy(szp->zone, zone->GetShortName(), sizeof(szp->zone)); - szp->x_pos = c->GetX(); - szp->y_pos = c->GetY(); - szp->z_pos = c->GetZ(); - szp->instance_id = zone->GetInstanceID(); + + szp->adminrank = c->Admin(); + szp->ignorerestrictions = 2; + szp->instance_id = zone->GetInstanceID(); + szp->x_pos = c->GetX(); + szp->y_pos = c->GetY(); + szp->z_pos = c->GetZ(); + worldserver.SendPacket(pack); safe_delete(pack); return; @@ -97,9 +97,4 @@ void command_summon(Client *c, const Seperator *sep) } t->GMMove(c->GetPosition()); - - if (t->IsNPC()) { - t->CastToNPC()->SaveGuardSpot(glm::vec4(0.0f)); - } } - diff --git a/zone/mob.cpp b/zone/mob.cpp index 5e2a4430f..ca0f8ff83 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3511,14 +3511,14 @@ void Mob::GMMove(float x, float y, float z, float heading, bool save_guard_spot) } } -void Mob::GMMove(const glm::vec4 &position) { +void Mob::GMMove(const glm::vec4 &position, bool save_guard_spot) { m_Position.x = position.x; m_Position.y = position.y; m_Position.z = position.z; SetHeading(position.w); mMovementManager->SendCommandToClients(this, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeAny); - if (IsNPC()) { + if (IsNPC() && save_guard_spot) { CastToNPC()->SaveGuardSpot(position); } } diff --git a/zone/mob.h b/zone/mob.h index bcd4a6a3f..d61fe9a1f 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -714,7 +714,7 @@ public: bool IsRunning() const { return m_is_running; } void SetRunning(bool val) { m_is_running = val; } virtual void GMMove(float x, float y, float z, float heading = 0.01, bool save_guard_spot = true); - virtual void GMMove(const glm::vec4 &position); + virtual void GMMove(const glm::vec4 &position, bool save_guard_spot = true); void SetDelta(const glm::vec4& delta); void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu);