[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
3 changed files with 17 additions and 22 deletions
+14 -19
View File
@@ -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));
}
}