[Bug Fix] Using %T in channel messages on fresh corpse yields mob, not corpse name. (#4168)

* [Bug Fix] Using %T in channel messages on fresh corpse yields mob/player name, not corpse name.

* Undo changes to PC corpse.

* Use rename to fix %T usage on client for those in zone

* Fix indentation spacing

* Update to consolidate Rename as suggested.

* Fix for mobs with ` in name

* Fix to use GetName() instead of GetCleanName()
This commit is contained in:
Paul Coene 2024-04-05 09:29:48 -04:00 committed by GitHub
parent 043eeced6f
commit b1d873d1fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 10 deletions

View File

@ -2500,8 +2500,9 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
d->spell_id = UINT32_MAX;
d->attack_skill = SkillDamageTypes[attack_skill];
d->damage = damage;
d->corpseid = GetID();
app->priority = 6;
app->priority = 1;
entity_list.QueueClients(killer_mob, app, false);
@ -2833,8 +2834,15 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
}
entity_list.LimitRemoveNPC(this);
entity_list.AddCorpse(corpse, GetID());
// The client sees NPC corpses as name's_corpse. The server uses
// name`s_corpse so that %T works on corpses (client workaround)
// Rename the new corpse on client side.
std::string old_name = Strings::Replace(corpse->GetName(), "`s_corpse", "'s_corpse");
SendRename(killer_mob, old_name.c_str(), corpse->GetName());
entity_list.UnMarkNPC(GetID());
entity_list.RemoveNPC(GetID());

View File

@ -1647,6 +1647,22 @@ void Mob::SendHPUpdate(bool force_update_all)
}
}
void Mob::SendRename(Mob *sender, const char* old_name, const char* new_name)
{
auto out2 = new EQApplicationPacket(OP_MobRename, sizeof(MobRename_Struct));
auto data = (MobRename_Struct *)out2->pBuffer;
out2->priority = 6;
strn0cpy(data->old_name, old_name, sizeof(data->old_name));
strn0cpy(data->old_name_again, old_name, sizeof(data->old_name_again));
strn0cpy(data->new_name, new_name, sizeof(data->new_name));
data->unknown192 = 0;
data->unknown196 = 1;
entity_list.QueueClients(sender, out2);
safe_delete(out2);
}
void Mob::StopMoving()
{
StopNavigation();
@ -4374,15 +4390,7 @@ void Mob::TempName(const char *newname)
entity_list.MakeNameUnique(temp_name);
// Send the new name to all clients
auto outapp = new EQApplicationPacket(OP_MobRename, sizeof(MobRename_Struct));
MobRename_Struct* mr = (MobRename_Struct*) outapp->pBuffer;
strn0cpy(mr->old_name, old_name, 64);
strn0cpy(mr->old_name_again, old_name, 64);
strn0cpy(mr->new_name, temp_name, 64);
mr->unknown192 = 0;
mr->unknown196 = 1;
entity_list.QueueClients(this, outapp);
safe_delete(outapp);
SendRename(this, old_name, temp_name);
SetName(temp_name);
}

View File

@ -829,6 +829,7 @@ public:
void SendHPUpdate(bool force_update_all = false);
virtual void ResetHPUpdateTimer() {}; // does nothing
static void SetSpawnLastNameByClass(NewSpawn_Struct* ns);
void SendRename(Mob* sender, const char* old_name, const char* new_name);
//Util
static uint32 RandomTimer(int min, int max);