[Bug Fix] Fix NPCs routing to 0.0, 0.0 on #summon (#3780)

# Notes
- Resolves #2474.
This commit is contained in:
Alex King 2023-12-17 20:24:24 -05:00 committed by GitHub
parent 286479198f
commit d3b46becd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 22 deletions

View File

@ -3,15 +3,12 @@
extern WorldServer worldserver; extern WorldServer worldserver;
#include "../corpse.h"
void command_summon(Client *c, const Seperator *sep) void command_summon(Client *c, const Seperator *sep)
{ {
int arguments = sep->argnum; const int arguments = sep->argnum;
if (!arguments && !c->GetTarget()) { 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 - 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, "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; return;
} }
@ -31,9 +28,9 @@ void command_summon(Client *c, const Seperator *sep)
return; return;
} }
auto search_client = entity_list.GetClientByName(character_name.c_str()); Client *s = entity_list.GetClientByName(character_name.c_str());
if (search_client) { if (s) {
t = search_client->CastToMob(); t = s->CastToMob();
} else { } else {
if (!worldserver.Connected()) { if (!worldserver.Connected()) {
c->Message(Chat::White, "World server is currently disconnected."); 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 pack = new ServerPacket(ServerOP_ZonePlayer, sizeof(ServerZonePlayer_Struct));
auto szp = (ServerZonePlayer_Struct *) pack->pBuffer; auto szp = (ServerZonePlayer_Struct *) pack->pBuffer;
strn0cpy(szp->adminname, c->GetName(), sizeof(szp->adminname)); 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->name, character_name.c_str(), sizeof(szp->name));
strn0cpy(szp->zone, zone->GetShortName(), sizeof(szp->zone)); strn0cpy(szp->zone, zone->GetShortName(), sizeof(szp->zone));
szp->adminrank = c->Admin();
szp->ignorerestrictions = 2;
szp->instance_id = zone->GetInstanceID();
szp->x_pos = c->GetX(); szp->x_pos = c->GetX();
szp->y_pos = c->GetY(); szp->y_pos = c->GetY();
szp->z_pos = c->GetZ(); szp->z_pos = c->GetZ();
szp->instance_id = zone->GetInstanceID();
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
return; return;
@ -97,9 +97,4 @@ void command_summon(Client *c, const Seperator *sep)
} }
t->GMMove(c->GetPosition()); t->GMMove(c->GetPosition());
if (t->IsNPC()) {
t->CastToNPC()->SaveGuardSpot(glm::vec4(0.0f));
} }
}

View File

@ -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.x = position.x;
m_Position.y = position.y; m_Position.y = position.y;
m_Position.z = position.z; m_Position.z = position.z;
SetHeading(position.w); SetHeading(position.w);
mMovementManager->SendCommandToClients(this, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeAny); mMovementManager->SendCommandToClients(this, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeAny);
if (IsNPC()) { if (IsNPC() && save_guard_spot) {
CastToNPC()->SaveGuardSpot(position); CastToNPC()->SaveGuardSpot(position);
} }
} }

View File

@ -714,7 +714,7 @@ public:
bool IsRunning() const { return m_is_running; } bool IsRunning() const { return m_is_running; }
void SetRunning(bool val) { m_is_running = val; } 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(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 SetDelta(const glm::vec4& delta);
void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu);
void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu);