diff --git a/common/emu_constants.h b/common/emu_constants.h index 178fcbcf4..6494f61dc 100644 --- a/common/emu_constants.h +++ b/common/emu_constants.h @@ -416,6 +416,15 @@ enum ConsiderLevel : uint8 { Scowls }; +enum TargetDescriptionType : uint8 { + LCSelf, + UCSelf, + LCYou, + UCYou, + LCYour, + UCYour +}; + enum ReloadWorld : uint8 { NoRepop = 0, Repop, diff --git a/common/servertalk.h b/common/servertalk.h index 7ae8efd40..af5af4541 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -232,6 +232,7 @@ #define ServerOP_ReloadMerchants 0x4016 #define ServerOP_ReloadAAData 0x4017 #define ServerOP_ReloadTraps 0x4018 +#define ServerOP_ReloadZonePoints 0x4019 #define ServerOP_ReloadStaticZoneData 0x4020 #define ServerOP_CZDialogueWindow 0x4500 diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 5a1641f81..d3967130f 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -88,48 +88,51 @@ ZoneServer::ZoneServer(std::shared_ptr conn } ZoneServer::~ZoneServer() { - if (RunLoops) + if (RunLoops) { client_list.CLERemoveZSRef(this); + } } -bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { +bool ZoneServer::SetZone(uint32 zone_id, uint32 instance_id, bool is_static_zone) { is_booting_up = false; - const char* zn = MakeLowerString(ZoneName(iZoneID)); - char* longname; + std::string zone_short_name = ZoneName(zone_id, true); + std::string zone_long_name = ZoneLongName(zone_id, true); - if (iZoneID) - Log(Logs::Detail, Logs::WorldServer, "Setting to '%s' (%d:%d)%s", (zn) ? zn : "", iZoneID, iInstanceID, - iStaticZone ? " (Static)" : ""); + if (zone_id) { + LogInfo( + "Setting zone process to Zone: {} ({}) ID: {}{}{}", + zone_long_name, + zone_short_name, + zone_id, + ( + instance_id ? + fmt::format( + " (Instance ID {})", + instance_id + ) : + "" + ), + is_static_zone ? " (Static)" : "" + ); + } - zone_server_zone_id = iZoneID; - instance_id = iInstanceID; - if (iZoneID != 0) - zone_server_previous_zone_id = iZoneID; - if (zone_server_zone_id == 0) { + zone_server_zone_id = zone_id; + instance_id = instance_id; + if (zone_id) { + zone_server_previous_zone_id = zone_id; + } + + if (!zone_server_zone_id) { client_list.CLERemoveZSRef(this); zone_player_count = 0; LSSleepUpdate(GetPrevZoneID()); } - is_static_zone = iStaticZone; + is_static_zone = is_static_zone; - if (zn) - { - strn0cpy(zone_name, zn, sizeof(zone_name)); - if (content_db.GetZoneLongName((char*)zone_name, &longname, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)) - { - strn0cpy(long_name, longname, sizeof(long_name)); - safe_delete_array(longname); - } - else - strcpy(long_name, ""); - } - else - { - strcpy(zone_name, ""); - strcpy(long_name, ""); - } + strn0cpy(zone_name, zone_short_name.c_str(), sizeof(zone_name)); + strn0cpy(long_name, zone_long_name.c_str(), sizeof(long_name)); client_list.ZoneBootup(this); zone_boot_timer.Start(); @@ -137,37 +140,34 @@ bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { return true; } -void ZoneServer::LSShutDownUpdate(uint32 zoneid) { +void ZoneServer::LSShutDownUpdate(uint32 zone_id) { if (WorldConfig::get()->UpdateStats) { auto pack = new ServerPacket; pack->opcode = ServerOP_LSZoneShutdown; pack->size = sizeof(ZoneShutdown_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ZoneShutdown_Struct* zsd = (ZoneShutdown_Struct*)pack->pBuffer; - if (zoneid == 0) - zsd->zone = GetPrevZoneID(); - else - zsd->zone = zoneid; + auto zsd = (ZoneShutdown_Struct*) pack->pBuffer; + zsd->zone = zone_id ? zone_id : GetPrevZoneID(); zsd->zone_wid = GetID(); loginserverlist.SendPacket(pack); safe_delete(pack); } } -void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup) { +void ZoneServer::LSBootUpdate(uint32 zone_id, uint32 instanceid, bool startup) { if (WorldConfig::get()->UpdateStats) { auto pack = new ServerPacket; - if (startup) - pack->opcode = ServerOP_LSZoneStart; - else - pack->opcode = ServerOP_LSZoneBoot; + pack->opcode = startup ? ServerOP_LSZoneStart : ServerOP_LSZoneBoot; pack->size = sizeof(ZoneBoot_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ZoneBoot_Struct* bootup = (ZoneBoot_Struct*)pack->pBuffer; - if (startup) + auto bootup = (ZoneBoot_Struct*) pack->pBuffer; + + if (startup) { strcpy(bootup->compile_time, GetCompileTime()); - bootup->zone = zoneid; + } + + bootup->zone = zone_id; bootup->zone_wid = GetID(); bootup->instance = instanceid; loginserverlist.SendPacket(pack); @@ -175,15 +175,15 @@ void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup) { } } -void ZoneServer::LSSleepUpdate(uint32 zoneid) { +void ZoneServer::LSSleepUpdate(uint32 zone_id) { if (WorldConfig::get()->UpdateStats) { auto pack = new ServerPacket; pack->opcode = ServerOP_LSZoneSleep; pack->size = sizeof(ServerLSZoneSleep_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerLSZoneSleep_Struct* sleep = (ServerLSZoneSleep_Struct*)pack->pBuffer; - sleep->zone = zoneid; + auto sleep = (ServerLSZoneSleep_Struct*) pack->pBuffer; + sleep->zone = zone_id; sleep->zone_wid = GetID(); loginserverlist.SendPacket(pack); safe_delete(pack); @@ -192,1322 +192,1250 @@ void ZoneServer::LSSleepUpdate(uint32 zoneid) { void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerPacket tpack(opcode, p); - ServerPacket *pack = &tpack; + auto pack = &tpack; switch (opcode) { - case 0: - break; - case ServerOP_KeepAlive: { - // ignore this - break; - } - case ServerOP_ZAAuth: { - break; - } - case ServerOP_LSZoneBoot: { - if (pack->size == sizeof(ZoneBoot_Struct)) { - ZoneBoot_Struct* zbs = (ZoneBoot_Struct*)pack->pBuffer; - SetCompile(zbs->compile_time); - } - break; - } - case ServerOP_GroupInvite: { - if (pack->size != sizeof(GroupInvite_Struct)) - break; - - GroupInvite_Struct* gis = (GroupInvite_Struct*)pack->pBuffer; - - client_list.SendPacket(gis->invitee_name, pack); - break; - } - case ServerOP_GroupFollow: { - if (pack->size != sizeof(ServerGroupFollow_Struct)) - break; - - ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *)pack->pBuffer; - - client_list.SendPacket(sgfs->gf.name1, pack); - break; - } - case ServerOP_GroupFollowAck: { - if (pack->size != sizeof(ServerGroupFollowAck_Struct)) - break; - - ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *)pack->pBuffer; - - client_list.SendPacket(sgfas->Name, pack); - break; - } - case ServerOP_GroupCancelInvite: { - if (pack->size != sizeof(GroupCancel_Struct)) - break; - - GroupCancel_Struct *gcs = (GroupCancel_Struct *)pack->pBuffer; - - client_list.SendPacket(gcs->name1, pack); - break; - } - case ServerOP_GroupIDReq: { - SendGroupIDs(); - break; - } - case ServerOP_GroupLeave: { - if (pack->size != sizeof(ServerGroupLeave_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_GroupJoin: { - if (pack->size != sizeof(ServerGroupJoin_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_ForceGroupUpdate: { - if (pack->size != sizeof(ServerForceGroupUpdate_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_OOZGroupMessage: { - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_DisbandGroup: { - if (pack->size != sizeof(ServerDisbandGroup_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_RaidAdd: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidRemove: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidDisband: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidLockFlag: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidChangeGroup: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_UpdateGroup: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupDisband: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupAdd: { - if (pack->size != sizeof(ServerRaidGroupAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupRemove: { - if (pack->size != sizeof(ServerRaidGroupAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupSay: { - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidSay: { - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupLeader: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidLeader: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_DetailsChange: { - if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidMOTD: { - if (pack->size < sizeof(ServerRaidMOTD_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_SpawnCondition: { - if (pack->size != sizeof(ServerSpawnCondition_Struct)) - break; - //bounce the packet to the correct zone server, if its up - ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer; - zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack); - break; - } - case ServerOP_SpawnEvent: { - if (pack->size != sizeof(ServerSpawnEvent_Struct)) - break; - //bounce the packet to the correct zone server, if its up - ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer; - zoneserver_list.SendPacket(sse->zoneID, 0, pack); - break; - } - case ServerOP_ChannelMessage: { - if (pack->size < sizeof(ServerChannelMessage_Struct)) - break; - ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer; - if (scm->chan_num == ChatChannel_UCSRelay) - { - UCSLink.SendMessage(scm->from, scm->message); + case 0: + case ServerOP_KeepAlive: + case ServerOP_ZAAuth: { break; } - if (scm->chan_num == ChatChannel_Tell || scm->chan_num == ChatChannel_TellEcho) { - if (scm->deliverto[0] == '*') { + case ServerOP_LSZoneBoot: { + if (pack->size == sizeof(ZoneBoot_Struct)) { + auto zbs = (ZoneBoot_Struct*) pack->pBuffer; + SetCompile(zbs->compile_time); + } - if (console) { - auto con = console->FindByAccountName(&scm->deliverto[1]); - if (((!con) || (!con->SendChannelMessage(scm, [&scm]() { - auto pack = new ServerPacket(ServerOP_ChannelMessage, - sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1); - memcpy(pack->pBuffer, scm, pack->size); - ServerChannelMessage_Struct* scm2 = (ServerChannelMessage_Struct*)pack->pBuffer; - strcpy(scm2->deliverto, scm2->from); - scm2->noreply = true; - client_list.SendPacket(scm->from, pack); - safe_delete(pack); - }))) && (!scm->noreply)) - { + break; + } + case ServerOP_GroupInvite: { + if (pack->size != sizeof(GroupInvite_Struct)) { + break; + } + + auto gis = (GroupInvite_Struct*) pack->pBuffer; + client_list.SendPacket(gis->invitee_name, pack); + break; + } + case ServerOP_GroupFollow: { + if (pack->size != sizeof(ServerGroupFollow_Struct)) { + break; + } + + auto sgfs = (ServerGroupFollow_Struct*) pack->pBuffer; + client_list.SendPacket(sgfs->gf.name1, pack); + break; + } + case ServerOP_GroupFollowAck: { + if (pack->size != sizeof(ServerGroupFollowAck_Struct)) { + break; + } + + auto sgfas = (ServerGroupFollowAck_Struct*) pack->pBuffer; + client_list.SendPacket(sgfas->Name, pack); + break; + } + case ServerOP_GroupCancelInvite: { + if (pack->size != sizeof(GroupCancel_Struct)) { + break; + } + + auto gcs = (GroupCancel_Struct*) pack->pBuffer; + client_list.SendPacket(gcs->name1, pack); + break; + } + case ServerOP_GroupIDReq: { + SendGroupIDs(); + break; + } + case ServerOP_GroupLeave: { + if (pack->size != sizeof(ServerGroupLeave_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_GroupJoin: { + if (pack->size != sizeof(ServerGroupJoin_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_ForceGroupUpdate: { + if (pack->size != sizeof(ServerForceGroupUpdate_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_DisbandGroup: { + if (pack->size != sizeof(ServerDisbandGroup_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidAdd: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidRemove: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidDisband: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidLockFlag: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidChangeGroup: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_UpdateGroup: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidGroupDisband: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidGroupAdd: { + if (pack->size != sizeof(ServerRaidGroupAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidGroupRemove: { + if (pack->size != sizeof(ServerRaidGroupAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidGroupLeader: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidLeader: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_DetailsChange: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RaidMOTD: { + if (pack->size < sizeof(ServerRaidMOTD_Struct)) { + break; + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_SpawnCondition: { + if (pack->size != sizeof(ServerSpawnCondition_Struct)) { + break; + } + + auto ssc = (ServerSpawnCondition_Struct*) pack->pBuffer; + zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack); + break; + } + case ServerOP_SpawnEvent: { + if (pack->size != sizeof(ServerSpawnEvent_Struct)) { + break; + } + + auto sse = (ServerSpawnEvent_Struct*) pack->pBuffer; + zoneserver_list.SendPacket(sse->zoneID, 0, pack); + break; + } + case ServerOP_ChannelMessage: { + if (pack->size < sizeof(ServerChannelMessage_Struct)) { + break; + } + + auto scm = (ServerChannelMessage_Struct*) pack->pBuffer; + if (scm->chan_num == ChatChannel_UCSRelay) { + UCSLink.SendMessage(scm->from, scm->message); + break; + } + + if (scm->chan_num == ChatChannel_Tell || scm->chan_num == ChatChannel_TellEcho) { + if (scm->deliverto[0] == '*') { + if (console) { + auto con = console->FindByAccountName(&scm->deliverto[1]); + if ( + !con || + ( + !con->SendChannelMessage( + scm, + [&scm]() { + auto pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1); + memcpy(pack->pBuffer, scm, pack->size); + auto scm2 = (ServerChannelMessage_Struct*) pack->pBuffer; + strcpy(scm2->deliverto, scm2->from); + scm2->noreply = true; + client_list.SendPacket(scm->from, pack); + safe_delete(pack); + } + ) + ) && + !scm->noreply + ) { + zoneserver_list.SendEmoteMessage( + scm->from, + 0, + AccountStatus::Player, + Chat::White, + fmt::format( + "{} is not online at this time.", + scm->to + ).c_str() + ); + } + } + break; + } + + auto cle = client_list.FindCharacter(scm->deliverto); + if ( + !cle || + cle->Online() < CLE_Status::Zoning || + ( + cle->TellsOff() && + ( + ( + cle->Anon() == 1 && + scm->fromadmin < cle->Admin() + ) || + scm->fromadmin < AccountStatus::QuestTroupe + ) + ) + ) { + if (!scm->noreply) { + auto sender = client_list.FindCharacter(scm->from); + if (!sender || !sender->Server()) { + break; + } + + scm->noreply = true; + scm->queued = 3; // offline + scm->chan_num = ChatChannel_TellEcho; + strcpy(scm->deliverto, scm->from); + sender->Server()->SendPacket(pack); + } + } else if (cle->Online() == CLE_Status::Zoning) { + if (!scm->noreply) { + auto sender = client_list.FindCharacter(scm->from); + if (cle->TellQueueFull()) { + if (!sender || !sender->Server()) { + break; + } + + scm->noreply = true; + scm->queued = 2; // queue full + scm->chan_num = ChatChannel_TellEcho; + strcpy(scm->deliverto, scm->from); + sender->Server()->SendPacket(pack); + } else { + size_t struct_size = sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1; + auto temp = (ServerChannelMessage_Struct *) new uchar[struct_size]; + memset(temp, 0, struct_size); // just in case, was seeing some corrupt messages, but it shouldn't happen + memcpy(temp, scm, struct_size); + temp->noreply = true; + cle->PushToTellQueue(temp); // deallocation is handled in processing or deconstructor + + if (!sender || !sender->Server()) { + break; + } + + scm->noreply = true; + scm->queued = 1; // queued + scm->chan_num = ChatChannel_TellEcho; + strcpy(scm->deliverto, scm->from); + sender->Server()->SendPacket(pack); + } + } + } else if (!cle->Server()) { + if (!scm->noreply) zoneserver_list.SendEmoteMessage( scm->from, 0, AccountStatus::Player, Chat::White, fmt::format( - "{} is not online at this time.", + "You told {}, '{} is not contactable at this time'", + scm->to, scm->to ).c_str() ); + } else { + cle->Server()->SendPacket(pack); + } + } else { + if ( + scm->chan_num == ChatChannel_OOC || + scm->chan_num == ChatChannel_Broadcast || + scm->chan_num == ChatChannel_GMSAY + ) { + if (console) { + console->SendChannelMessage( + scm, + [&scm]() { + auto pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1); + memcpy(pack->pBuffer, scm, pack->size); + auto scm2 = (ServerChannelMessage_Struct*) pack->pBuffer; + strcpy(scm2->deliverto, scm2->from); + scm2->noreply = true; + client_list.SendPacket(scm->from, pack); + safe_delete(pack); + } + ); } } - break; + zoneserver_list.SendPacket(pack); } - ClientListEntry* cle = client_list.FindCharacter(scm->deliverto); - if (cle == 0 || cle->Online() < CLE_Status::Zoning || - (cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < AccountStatus::QuestTroupe))) { - if (!scm->noreply) { - ClientListEntry* sender = client_list.FindCharacter(scm->from); - if (!sender || !sender->Server()) - break; - scm->noreply = true; - scm->queued = 3; // offline - scm->chan_num = ChatChannel_TellEcho; - strcpy(scm->deliverto, scm->from); - // ideally this would be trimming off the message too, oh well - sender->Server()->SendPacket(pack); - } - } - else if (cle->Online() == CLE_Status::Zoning) { - if (!scm->noreply) { - ClientListEntry* sender = client_list.FindCharacter(scm->from); - if (cle->TellQueueFull()) { - if (!sender || !sender->Server()) - break; - scm->noreply = true; - scm->queued = 2; // queue full - scm->chan_num = ChatChannel_TellEcho; - strcpy(scm->deliverto, scm->from); - sender->Server()->SendPacket(pack); - } - else { - size_t struct_size = sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1; - ServerChannelMessage_Struct *temp = (ServerChannelMessage_Struct *) new uchar[struct_size]; - memset(temp, 0, struct_size); // just in case, was seeing some corrupt messages, but it shouldn't happen - memcpy(temp, scm, struct_size); - temp->noreply = true; - cle->PushToTellQueue(temp); // deallocation is handled in processing or deconstructor - - if (!sender || !sender->Server()) - break; - scm->noreply = true; - scm->queued = 1; // queued - scm->chan_num = ChatChannel_TellEcho; - strcpy(scm->deliverto, scm->from); - sender->Server()->SendPacket(pack); - } - } - } - else if (cle->Server() == 0) { - if (!scm->noreply) + break; + } + case ServerOP_EmoteMessage: { + auto sem = (ServerEmoteMessage_Struct*) pack->pBuffer; + zoneserver_list.SendEmoteMessageRaw( + sem->to, + sem->guilddbid, + sem->minstatus, + sem->type, + sem->message + ); + break; + } + case ServerOP_VoiceMacro: { + auto svm = (ServerVoiceMacro_Struct*) pack->pBuffer; + if (svm->Type == VoiceMacroTell) { + auto cle = client_list.FindCharacter(svm->To); + if ( + !cle || + cle->Online() < CLE_Status::Zoning || + !cle->Server() + ) { zoneserver_list.SendEmoteMessage( - scm->from, + svm->From, 0, AccountStatus::Player, Chat::White, fmt::format( - "You told {}, '{} is not contactable at this time'", - scm->to, - scm->to + "'{} is not online at this time'", + svm->To ).c_str() ); - } - else - cle->Server()->SendPacket(pack); - } - else { - if (scm->chan_num == ChatChannel_OOC || scm->chan_num == ChatChannel_Broadcast - || scm->chan_num == ChatChannel_GMSAY) { - if (console) { - console->SendChannelMessage(scm, [&scm]() { - auto pack = new ServerPacket(ServerOP_ChannelMessage, - sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1); - memcpy(pack->pBuffer, scm, pack->size); - ServerChannelMessage_Struct* scm2 = (ServerChannelMessage_Struct*)pack->pBuffer; - strcpy(scm2->deliverto, scm2->from); - scm2->noreply = true; - client_list.SendPacket(scm->from, pack); - safe_delete(pack); - }); + break; } + cle->Server()->SendPacket(pack); + } else { + zoneserver_list.SendPacket(pack); } - zoneserver_list.SendPacket(pack); + + break; } - break; - } - case ServerOP_EmoteMessage: { - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; - zoneserver_list.SendEmoteMessageRaw( - sem->to, - sem->guilddbid, - sem->minstatus, - sem->type, - sem->message - ); - break; - } - case ServerOP_VoiceMacro: { - ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer; - if (svm->Type == VoiceMacroTell) { - ClientListEntry* cle = client_list.FindCharacter(svm->To); - if (!cle || (cle->Online() < CLE_Status::Zoning) || !cle->Server()) { - zoneserver_list.SendEmoteMessage( - svm->From, - 0, - AccountStatus::Player, - Chat::White, - fmt::format( - "'{} is not online at this time'", - svm->To - ).c_str() - ); + case ServerOP_RezzPlayer: { + auto rps = (RezzPlayer_Struct*) pack->pBuffer; + if (zoneserver_list.SendPacket(pack)) { + LogInfo("Sent Rez packet for [{}]", rps->rez.your_name); + } else { + LogInfo("Could not send Rez packet for [{}]", rps->rez.your_name); + } + + break; + } + case ServerOP_RezzPlayerReject: { + auto recipient = (char*) pack->pBuffer; + client_list.SendPacket(recipient, pack); + break; + } + case ServerOP_MultiLineMsg: { + auto mlm = (ServerMultiLineMsg_Struct*) pack->pBuffer; + client_list.SendPacket(mlm->to, pack); + break; + } + case ServerOP_SetZone: { + if (pack->size != sizeof(SetZone_Struct)) { break; } - cle->Server()->SendPacket(pack); - } else { - zoneserver_list.SendPacket(pack); - } - break; - } - case ServerOP_RezzPlayerAccept: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_RezzPlayer: { - - RezzPlayer_Struct* sRezz = (RezzPlayer_Struct*)pack->pBuffer; - if (zoneserver_list.SendPacket(pack)) { - LogInfo("Sent Rez packet for [{}]", sRezz->rez.your_name); - } - else { - LogInfo("Could not send Rez packet for [{}]", sRezz->rez.your_name); - } - break; - } - case ServerOP_RezzPlayerReject: - { - char *Recipient = (char *)pack->pBuffer; - client_list.SendPacket(Recipient, pack); - break; - } - - case ServerOP_MultiLineMsg: { - ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*)pack->pBuffer; - client_list.SendPacket(mlm->to, pack); - break; - } - case ServerOP_SetZone: { - if (pack->size != sizeof(SetZone_Struct)) - break; - - SetZone_Struct* szs = (SetZone_Struct*)pack->pBuffer; - if (szs->zoneid != 0) { - if (ZoneName(szs->zoneid)) - SetZone(szs->zoneid, szs->instanceid, szs->staticzone); - else + auto szs = (SetZone_Struct*) pack->pBuffer; + if (szs->zoneid) { + if (ZoneName(szs->zoneid)) { + SetZone(szs->zoneid, szs->instanceid, szs->staticzone); + } else { + SetZone(0); + } + } else { SetZone(0); - } - else - SetZone(0); - - break; - } - case ServerOP_SetConnectInfo: { - if (pack->size != sizeof(ServerConnectInfo)) - break; - ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer; - - if (!sci->port) { - client_port = zoneserver_list.GetAvailableZonePort(); - - ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo)); - memset(p.pBuffer, 0, sizeof(ServerConnectInfo)); - ServerConnectInfo* sci = (ServerConnectInfo*)p.pBuffer; - sci->port = client_port; - SendPacket(&p); - LogInfo("Auto zone port configuration. Telling zone to use port [{}]", client_port); - } - else { - client_port = sci->port; - LogInfo("Zone specified port [{}]", client_port); - } - - if (sci->address[0]) { - strn0cpy(client_address, sci->address, 250); - LogInfo("Zone specified address [{}]", sci->address); - } - - if (sci->local_address[0]) { - strn0cpy(client_local_address, sci->local_address, 250); - LogInfo("Zone specified local address [{}]", sci->local_address); - } - - if (sci->process_id) { - zone_os_process_id = sci->process_id; - } - - } - case ServerOP_SetLaunchName: { - if (pack->size != sizeof(LaunchName_Struct)) - break; - const LaunchName_Struct* ln = (const LaunchName_Struct*)pack->pBuffer; - launcher_name = ln->launcher_name; - launched_name = ln->zone_name; - LogInfo("Zone started with name [{}] by launcher [{}]", launched_name.c_str(), launcher_name.c_str()); - break; - } - case ServerOP_ShutdownAll: { - if (pack->size == 0) { - zoneserver_list.SendPacket(pack); - zoneserver_list.Process(); - CatchSignal(2); - } - else { - WorldShutDown_Struct* wsd = (WorldShutDown_Struct*)pack->pBuffer; - if (wsd->time == 0 && wsd->interval == 0 && zoneserver_list.shutdowntimer->Enabled()) { - zoneserver_list.shutdowntimer->Disable(); - zoneserver_list.reminder->Disable(); } - else { - zoneserver_list.shutdowntimer->SetTimer(wsd->time); - zoneserver_list.reminder->SetTimer(wsd->interval - 1000); - zoneserver_list.reminder->SetAtTrigger(wsd->interval); - zoneserver_list.shutdowntimer->Start(); - zoneserver_list.reminder->Start(); - } - } - break; - } - case ServerOP_ZoneShutdown: { - ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer; - ZoneServer* zs = 0; - if (s->ZoneServerID != 0) { - zs = zoneserver_list.FindByID(s->ZoneServerID); - } else if (s->zoneid != 0) { - zs = zoneserver_list.FindByName(ZoneName(s->zoneid)); - } else { - zoneserver_list.SendEmoteMessage( - s->adminname, - 0, - AccountStatus::Player, - Chat::White, - "Error: SOP_ZoneShutdown: neither ID nor name specified" - ); - } - if (!zs) { - zoneserver_list.SendEmoteMessage( - s->adminname, - 0, - AccountStatus::Player, - Chat::White, - "Error: SOP_ZoneShutdown: zoneserver not found" - ); - } else { - zs->SendPacket(pack); - } - break; - } - case ServerOP_ZoneBootup: { - ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer; - zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, ZoneName(s->zoneid), s->makestatic); - break; - } - case ServerOP_ZoneStatus: { - if (pack->size >= 1) - zoneserver_list.SendZoneStatus((char *)&pack->pBuffer[1], (uint8)pack->pBuffer[0], this); - break; - - } - case ServerOP_AcceptWorldEntrance: { - if (pack->size != sizeof(WorldToZone_Struct)) break; - - WorldToZone_Struct* wtz = (WorldToZone_Struct*)pack->pBuffer; - Client* client = 0; - client = client_list.FindByAccountID(wtz->account_id); - if (client != 0) - client->Clearance(wtz->response); - } - case ServerOP_ZoneToZoneRequest: { - // - // ZoneChange is received by the zone the player is in, then the - // zone sends a ZTZ which ends up here. This code then find the target - // (ingress point) and boots it if needed, then sends the ZTZ to it. - // The ingress server will decide wether the player can enter, then will - // send back the ZTZ to here. This packet is passed back to the egress - // server, which will send a ZoneChange response back to the client - // which can be an error, or a success, in which case the client will - // disconnect, and their zone location will be saved when ~Client is - // called, so it will be available when they ask to zone. - // - - - if (pack->size != sizeof(ZoneToZone_Struct)) - break; - ZoneToZone_Struct* ztz = (ZoneToZone_Struct*)pack->pBuffer; - ClientListEntry* client = nullptr; - if (WorldConfig::get()->UpdateStats) - client = client_list.FindCharacter(ztz->name); - - LogInfo("ZoneToZone request for [{}] current zone [{}] req zone [{}]", ztz->name, ztz->current_zone_id, ztz->requested_zone_id); - - /* This is a request from the egress zone */ - if (GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id) { - LogInfo("Processing ZTZ for egress from zone for client [{}]", ztz->name); - - if (ztz->admin < AccountStatus::QuestTroupe && ztz->ignorerestrictions < 2 && zoneserver_list.IsZoneLocked(ztz->requested_zone_id)) { - ztz->response = 0; - SendPacket(pack); + } + case ServerOP_SetConnectInfo: { + if (pack->size != sizeof(ServerConnectInfo)) { break; } - ZoneServer *ingress_server = nullptr; - if (ztz->requested_instance_id > 0) { - ingress_server = zoneserver_list.FindByInstanceID(ztz->requested_instance_id); - } - else { - ingress_server = zoneserver_list.FindByZoneID(ztz->requested_zone_id); + auto sci = (ServerConnectInfo*) pack->pBuffer; + + if (!sci->port) { + client_port = zoneserver_list.GetAvailableZonePort(); + + ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo)); + memset(p.pBuffer, 0, sizeof(ServerConnectInfo)); + sci = (ServerConnectInfo*)p.pBuffer; + sci->port = client_port; + SendPacket(&p); + LogInfo("Auto zone port configuration. Telling zone to use port [{}]", client_port); + } else { + client_port = sci->port; + LogInfo("Zone specified port [{}]", client_port); } - /* Zone was already running*/ - if (ingress_server) { - LogInfo("Found a zone already booted for [{}]", ztz->name); - ztz->response = 1; + if (sci->address[0]) { + strn0cpy(client_address, sci->address, 250); + LogInfo("Zone specified address [{}]", sci->address); } - /* Boot the Zone*/ - else { - int server_id; - if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))) { - LogInfo("Successfully booted a zone for [{}]", ztz->name); - // bootup successful, ready to rock - ztz->response = 1; - ingress_server = zoneserver_list.FindByID(server_id); + + if (sci->local_address[0]) { + strn0cpy(client_local_address, sci->local_address, 250); + LogInfo("Zone specified local address [{}]", sci->local_address); + } + + if (sci->process_id) { + zone_os_process_id = sci->process_id; + } + + break; + } + case ServerOP_SetLaunchName: { + if (pack->size != sizeof(LaunchName_Struct)) { + break; + } + + auto ln = (const LaunchName_Struct*) pack->pBuffer; + launcher_name = ln->launcher_name; + launched_name = ln->zone_name; + LogInfo("Zone started with name [{}] by launcher [{}]", launched_name.c_str(), launcher_name.c_str()); + break; + } + case ServerOP_ShutdownAll: { + if (!pack->size) { + zoneserver_list.SendPacket(pack); + zoneserver_list.Process(); + CatchSignal(2); + } else { + auto wsd = (WorldShutDown_Struct*) pack->pBuffer; + if (!wsd->time && !wsd->interval && zoneserver_list.shutdowntimer->Enabled()) { + zoneserver_list.shutdowntimer->Disable(); + zoneserver_list.reminder->Disable(); + } else { + zoneserver_list.shutdowntimer->SetTimer(wsd->time); + zoneserver_list.reminder->SetTimer(wsd->interval - 1000); + zoneserver_list.reminder->SetAtTrigger(wsd->interval); + zoneserver_list.shutdowntimer->Start(); + zoneserver_list.reminder->Start(); } - else { - LogError("failed to boot a zone for [{}]", ztz->name); - // bootup failed, send back error code 0 + } + + break; + } + case ServerOP_ZoneShutdown: { + auto s = (ServerZoneStateChange_struct*) pack->pBuffer; + ZoneServer* zs = 0; + if (s->ZoneServerID) { + zs = zoneserver_list.FindByID(s->ZoneServerID); + } else if (s->zoneid) { + zs = zoneserver_list.FindByName(ZoneName(s->zoneid)); + } else { + zoneserver_list.SendEmoteMessage( + s->adminname, + 0, + AccountStatus::Player, + Chat::White, + "Error: SOP_ZoneShutdown: neither ID nor name specified" + ); + } + + if (!zs) { + zoneserver_list.SendEmoteMessage( + s->adminname, + 0, + AccountStatus::Player, + Chat::White, + "Error: SOP_ZoneShutdown: zoneserver not found" + ); + } else { + zs->SendPacket(pack); + } + + break; + } + case ServerOP_ZoneBootup: { + auto s = (ServerZoneStateChange_struct*) pack->pBuffer; + zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, ZoneName(s->zoneid), s->makestatic); + break; + } + case ServerOP_ZoneStatus: { + if (pack->size >= 1) { + zoneserver_list.SendZoneStatus((char *)&pack->pBuffer[1], (uint8)pack->pBuffer[0], this); + } + + break; + } + case ServerOP_AcceptWorldEntrance: { + if (pack->size != sizeof(WorldToZone_Struct)) { + break; + } + + auto wtz = (WorldToZone_Struct*) pack->pBuffer; + auto client = client_list.FindByAccountID(wtz->account_id); + if (client) { + client->Clearance(wtz->response); + } + } + case ServerOP_ZoneToZoneRequest: { + // ZoneChange is received by the zone the player is in, then the + // zone sends a ZTZ which ends up here. This code then find the target + // (ingress point) and boots it if needed, then sends the ZTZ to it. + // The ingress server will decide wether the player can enter, then will + // send back the ZTZ to here. This packet is passed back to the egress + // server, which will send a ZoneChange response back to the client + // which can be an error, or a success, in which case the client will + // disconnect, and their zone location will be saved when ~Client is + // called, so it will be available when they ask to zone. + + if (pack->size != sizeof(ZoneToZone_Struct)) { + break; + } + + auto ztz = (ZoneToZone_Struct*) pack->pBuffer; + ClientListEntry* client = nullptr; + if (WorldConfig::get()->UpdateStats) { + client = client_list.FindCharacter(ztz->name); + } + + LogInfo("ZoneToZone request for [{}] current zone [{}] req zone [{}]", ztz->name, ztz->current_zone_id, ztz->requested_zone_id); + + /* This is a request from the egress zone */ + if (GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id) { + LogInfo("Processing ZTZ for egress from zone for client [{}]", ztz->name); + + if ( + ztz->admin < AccountStatus::QuestTroupe && + ztz->ignorerestrictions < 2 && + zoneserver_list.IsZoneLocked(ztz->requested_zone_id) + ) { ztz->response = 0; + SendPacket(pack); + break; + } + + auto ingress_server = ( + ztz->requested_instance_id ? + zoneserver_list.FindByInstanceID(ztz->requested_instance_id) : + zoneserver_list.FindByZoneID(ztz->requested_zone_id) + ); + + if (ingress_server) { + LogInfo("Found a zone already booted for [{}]", ztz->name); + ztz->response = 1; + } else { + int server_id; + if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))) { + LogInfo("Successfully booted a zone for [{}]", ztz->name); + ztz->response = 1; + ingress_server = zoneserver_list.FindByID(server_id); + } else { + LogError("failed to boot a zone for [{}]", ztz->name); + ztz->response = 0; + } + } + + if (ztz->response && client) { + client->LSZoneChange(ztz); + } + + SendPacket(pack); // send back to egress server + if (ingress_server) { + ingress_server->SendPacket(pack); // inform target server + } + } else { + LogInfo("Processing ZTZ for ingress to zone for client [{}]", ztz->name); + auto egress_server = ( + ztz->current_instance_id ? + zoneserver_list.FindByInstanceID(ztz->current_instance_id) : + zoneserver_list.FindByZoneID(ztz->current_zone_id) + ); + + if (egress_server) { + egress_server->SendPacket(pack); } } - if (ztz->response != 0 && client) - client->LSZoneChange(ztz); - SendPacket(pack); // send back to egress server - if (ingress_server) { - ingress_server->SendPacket(pack); // inform target server - } - } - /* Response from Ingress server, route back to egress */ - else { - LogInfo("Processing ZTZ for ingress to zone for client [{}]", ztz->name); - ZoneServer *egress_server = nullptr; - if (ztz->current_instance_id > 0) { - egress_server = zoneserver_list.FindByInstanceID(ztz->current_instance_id); - } - else { - egress_server = zoneserver_list.FindByZoneID(ztz->current_zone_id); - } - - if (egress_server) { - egress_server->SendPacket(pack); - } - } - - break; - } - case ServerOP_ClientList: { - if (pack->size != sizeof(ServerClientList_Struct)) { - LogInfo("Wrong size on ServerOP_ClientList. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerClientList_Struct)); break; } - client_list.ClientUpdate(this, (ServerClientList_Struct*)pack->pBuffer); - break; - } - case ServerOP_ClientListKA: { - ServerClientListKeepAlive_Struct* sclka = (ServerClientListKeepAlive_Struct*)pack->pBuffer; - if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) { - LogInfo("Wrong size on ServerOP_ClientListKA. Got: [{}], Expected: [{}]", pack->size, (4 + (4 * sclka->numupdates))); + case ServerOP_ClientList: { + if (pack->size != sizeof(ServerClientList_Struct)) { + LogInfo("Wrong size on ServerOP_ClientList. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerClientList_Struct)); + break; + } + + auto scl = (ServerClientList_Struct*) pack->pBuffer; + client_list.ClientUpdate(this, scl); break; } - client_list.CLEKeepAlive(sclka->numupdates, sclka->wid); - break; - } - case ServerOP_Who: { - ServerWhoAll_Struct* whoall = (ServerWhoAll_Struct*)pack->pBuffer; - auto whom = new Who_All_Struct; - memset(whom, 0, sizeof(Who_All_Struct)); - whom->gmlookup = whoall->gmlookup; - whom->lvllow = whoall->lvllow; - whom->lvlhigh = whoall->lvlhigh; - whom->wclass = whoall->wclass; - whom->wrace = whoall->wrace; - strcpy(whom->whom, whoall->whom); - client_list.SendWhoAll(whoall->fromid, whoall->from, whoall->admin, whom, this); - safe_delete(whom); - break; - } - case ServerOP_RequestOnlineGuildMembers: { - ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*)pack->pBuffer; - client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID); - break; - } - case ServerOP_ClientVersionSummary: { - ServerRequestClientVersionSummary_Struct *srcvss = (ServerRequestClientVersionSummary_Struct*)pack->pBuffer; - client_list.SendClientVersionSummary(srcvss->Name); - break; - } - case ServerOP_ReloadLogs: { - zoneserver_list.SendPacket(pack); - LogSys.LoadLogDatabaseSettings(); - break; - } - case ServerOP_ReloadRules: { - zoneserver_list.SendPacket(pack); - RuleManager::Instance()->LoadRules(&database, "default", true); - break; - } - case ServerOP_ReloadContentFlags: { - zoneserver_list.SendPacket(pack); - content_service.SetExpansionContext()->ReloadContentFlags(); - break; - } - case ServerOP_ReloadRulesWorld: - { - RuleManager::Instance()->LoadRules(&database, "default", true); - break; - } - case ServerOP_ReloadVariablesWorld: - { - database.LoadVariables(); - break; - } - case ServerOP_ReloadPerlExportSettings: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ReloadLevelEXPMods: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ReloadAAData: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ReloadMerchants: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ReloadStaticZoneData: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_CameraShake: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_FriendsWho: { - ServerFriendsWho_Struct* FriendsWho = (ServerFriendsWho_Struct*)pack->pBuffer; - client_list.SendFriendsWho(FriendsWho, this); - break; - } - case ServerOP_LFGMatches: { - ServerLFGMatchesRequest_Struct* smrs = (ServerLFGMatchesRequest_Struct*)pack->pBuffer; - client_list.SendLFGMatches(smrs); - break; - } - case ServerOP_LFPMatches: { - ServerLFPMatchesRequest_Struct* smrs = (ServerLFPMatchesRequest_Struct*)pack->pBuffer; - LFPGroupList.SendLFPMatches(smrs); - break; - } - case ServerOP_LFPUpdate: { - ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*)pack->pBuffer; - if (sus->Action) - LFPGroupList.UpdateGroup(sus); - else - LFPGroupList.RemoveGroup(sus); - break; - } - case ServerOP_ZonePlayer: { - //ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer; - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_KickPlayer: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_KillPlayer: { - zoneserver_list.SendPacket(pack); - break; - } + case ServerOP_ClientListKA: { + auto sclka = (ServerClientListKeepAlive_Struct*) pack->pBuffer; + if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) { + LogInfo("Wrong size on ServerOP_ClientListKA. Got: [{}], Expected: [{}]", pack->size, (4 + (4 * sclka->numupdates))); + break; + } - case ServerOP_GuildRankUpdate: - { - zoneserver_list.SendPacket(pack); - break; - } - //these opcodes get processed by the guild manager. - case ServerOP_RefreshGuild: - case ServerOP_DeleteGuild: - case ServerOP_GuildCharRefresh: - case ServerOP_GuildMemberUpdate: { - guild_mgr.ProcessZonePacket(pack); - break; - } - - case ServerOP_FlagUpdate: { - ClientListEntry* cle = client_list.FindCLEByAccountID(*((uint32*)pack->pBuffer)); - if (cle) - cle->SetAdmin(*((int16*)&pack->pBuffer[4])); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_GMGoto: { - if (pack->size != sizeof(ServerGMGoto_Struct)) { - LogInfo("Wrong size on ServerOP_GMGoto. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerGMGoto_Struct)); + client_list.CLEKeepAlive(sclka->numupdates, sclka->wid); break; } - ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*)pack->pBuffer; - ClientListEntry* cle = client_list.FindCharacter(gmg->gotoname); - if (cle != 0) { - if (!cle->Server()) { + case ServerOP_Who: { + auto whoall = (ServerWhoAll_Struct*) pack->pBuffer; + auto whom = new Who_All_Struct; + memset(whom, 0, sizeof(Who_All_Struct)); + whom->gmlookup = whoall->gmlookup; + whom->lvllow = whoall->lvllow; + whom->lvlhigh = whoall->lvlhigh; + whom->wclass = whoall->wclass; + whom->wrace = whoall->wrace; + strn0cpy(whom->whom, whoall->whom, sizeof(whom->whom)); + client_list.SendWhoAll(whoall->fromid, whoall->from, whoall->admin, whom, this); + safe_delete(whom); + break; + } + case ServerOP_RequestOnlineGuildMembers: { + auto srogms = (ServerRequestOnlineGuildMembers_Struct*) pack->pBuffer; + client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID); + break; + } + case ServerOP_ClientVersionSummary: { + auto srcvss = (ServerRequestClientVersionSummary_Struct*) pack->pBuffer; + client_list.SendClientVersionSummary(srcvss->Name); + break; + } + case ServerOP_ReloadLogs: { + zoneserver_list.SendPacket(pack); + LogSys.LoadLogDatabaseSettings(); + break; + } + case ServerOP_ReloadRules: { + zoneserver_list.SendPacket(pack); + RuleManager::Instance()->LoadRules(&database, "default", true); + break; + } + case ServerOP_ReloadContentFlags: { + zoneserver_list.SendPacket(pack); + content_service.SetExpansionContext()->ReloadContentFlags(); + break; + } + case ServerOP_ReloadRulesWorld: { + RuleManager::Instance()->LoadRules(&database, "default", true); + break; + } + case ServerOP_ReloadVariablesWorld: { + database.LoadVariables(); + break; + } + case ServerOP_FriendsWho: { + auto sfw = (ServerFriendsWho_Struct*) pack->pBuffer; + client_list.SendFriendsWho(sfw, this); + break; + } + case ServerOP_LFGMatches: { + auto smrs = (ServerLFGMatchesRequest_Struct*) pack->pBuffer; + client_list.SendLFGMatches(smrs); + break; + } + case ServerOP_LFPMatches: { + auto smrs = (ServerLFPMatchesRequest_Struct*) pack->pBuffer; + LFPGroupList.SendLFPMatches(smrs); + break; + } + case ServerOP_LFPUpdate: { + auto sus = (ServerLFPUpdate_Struct*) pack->pBuffer; + if (sus->Action) { + LFPGroupList.UpdateGroup(sus); + } else { + LFPGroupList.RemoveGroup(sus); + } + + break; + } + case ServerOP_DeleteGuild: + case ServerOP_GuildCharRefresh: + case ServerOP_GuildMemberUpdate: + case ServerOP_RefreshGuild: { + guild_mgr.ProcessZonePacket(pack); + break; + } + case ServerOP_FlagUpdate: { + auto cle = client_list.FindCLEByAccountID(*((uint32*) pack->pBuffer)); + if (cle) { + cle->SetAdmin(*((int16*)&pack->pBuffer[4])); + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_GMGoto: { + if (pack->size != sizeof(ServerGMGoto_Struct)) { + LogInfo("Wrong size on ServerOP_GMGoto. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerGMGoto_Struct)); + break; + } + + auto gmg = (ServerGMGoto_Struct*) pack->pBuffer; + auto cle = client_list.FindCharacter(gmg->gotoname); + if (cle) { + if (!cle->Server()) { + SendEmoteMessage( + gmg->myname, + 0, + AccountStatus::Player, + Chat::Red, + fmt::format( + "Error: Cannot identify {}'s zoneserver.", + gmg->gotoname + ).c_str() + ); + } else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) { // no snooping for anon GMs + SendEmoteMessage( + gmg->myname, + 0, + AccountStatus::Player, + Chat::Red, + fmt::format( + "Error: {} not found.", + gmg->gotoname + ).c_str() + ); + } else { + cle->Server()->SendPacket(pack); + } + } else { SendEmoteMessage( gmg->myname, 0, AccountStatus::Player, Chat::Red, fmt::format( - "Error: Cannot identify {}'s zoneserver.", + "Error: {} not found", gmg->gotoname ).c_str() ); - } else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) { // no snooping for anon GMs + } + + break; + } + case ServerOP_Lock: { + if (pack->size != sizeof(ServerLock_Struct)) { + LogInfo("Wrong size on ServerOP_Lock. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLock_Struct)); + break; + } + + auto slock = (ServerLock_Struct*) pack->pBuffer; + if (slock->mode >= 1) { + WorldConfig::LockWorld(); + } else { + WorldConfig::UnlockWorld(); + } + + if (loginserverlist.Connected()) { + loginserverlist.SendStatus(); SendEmoteMessage( - gmg->myname, + slock->myname, 0, AccountStatus::Player, Chat::Red, fmt::format( - "Error: {} not found.", - gmg->gotoname + "World {}.", + slock->mode ? "locked" : "unlocked" ).c_str() ); } else { + SendEmoteMessage( + slock->myname, + 0, + AccountStatus::Player, + Chat::Red, + fmt::format( + "World {}, but login server not connected.", + slock->mode ? "locked" : "unlocked" + ).c_str() + ); + } + + break; + } + case ServerOP_Motd: { + if (pack->size != sizeof(ServerMotd_Struct)) { + LogInfo("Wrong size on ServerOP_Motd. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerMotd_Struct)); + break; + } + + auto smotd = (ServerMotd_Struct*) pack->pBuffer; + database.SetVariable("MOTD", smotd->motd); + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_Uptime: { + if (pack->size != sizeof(ServerUptime_Struct)) { + LogInfo("Wrong size on ServerOP_Uptime. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerUptime_Struct)); + break; + } + + auto sus = (ServerUptime_Struct*) pack->pBuffer; + if (!sus->zoneserverid) { + ZSList::ShowUpTime(this, sus->adminname); + } else { + auto zs = zoneserver_list.FindByID(sus->zoneserverid); + if (zs) { + zs->SendPacket(pack); + } + } + + break; + } + case ServerOP_GetWorldTime: { + LogInfo("Broadcasting a world time update"); + auto pack = new ServerPacket; + + pack->opcode = ServerOP_SyncWorldTime; + pack->size = sizeof(eqTimeOfDay); + pack->pBuffer = new uchar[pack->size]; + memset(pack->pBuffer, 0, pack->size); + auto tod = (eqTimeOfDay*) pack->pBuffer; + tod->start_eqtime = zoneserver_list.worldclock.getStartEQTime(); + tod->start_realtime = zoneserver_list.worldclock.getStartRealTime(); + SendPacket(pack); + safe_delete(pack); + break; + } + case ServerOP_SetWorldTime: { + LogNetcode("Received SetWorldTime"); + auto newtime = (eqTimeOfDay*) pack->pBuffer; + zoneserver_list.worldclock.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime); + LogInfo("New time = [{}]-[{}]-[{}] [{}]:[{}] ([{}])\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime); + database.SaveTime((int)newtime->start_eqtime.minute, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.day, newtime->start_eqtime.month, newtime->start_eqtime.year); + zoneserver_list.SendTimeSync(); + break; + } + case ServerOP_IPLookup: { + if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) { + LogInfo("Wrong size on ServerOP_IPLookup. Got: [{}], Expected (at least): [{}]", pack->size, sizeof(ServerGenericWorldQuery_Struct)); + break; + } + + auto sgwq = (ServerGenericWorldQuery_Struct*) pack->pBuffer; + if (pack->size == sizeof(ServerGenericWorldQuery_Struct)) { + client_list.SendCLEList(sgwq->admin, sgwq->from, this); + } else { + client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query); + } + + break; + } + case ServerOP_LockZone: { + if (pack->size < sizeof(ServerLockZone_Struct)) { + LogInfo("Wrong size on ServerOP_LockZone. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLockZone_Struct)); + break; + } + + auto lock_zone = (ServerLockZone_Struct*) pack->pBuffer; + if (lock_zone->op == ServerLockType::List) { + zoneserver_list.ListLockedZones(lock_zone->adminname, this); + break; + } else if ( + lock_zone->op == ServerLockType::Lock || + lock_zone->op == ServerLockType::Unlock + ) { + if (zoneserver_list.SetLockedZone(lock_zone->zoneID, lock_zone->op == ServerLockType::Lock)) { + zoneserver_list.SendEmoteMessage( + 0, + 0, + AccountStatus::QuestTroupe, + Chat::White, + fmt::format( + "Zone {} | Name: {} ({}) ID: {}", + lock_zone->op == ServerLockType::Lock ? "Locked" : "Unlocked", + ZoneLongName(lock_zone->zoneID), + ZoneName(lock_zone->zoneID), + lock_zone->zoneID + ).c_str() + ); + } else { + SendEmoteMessageRaw( + lock_zone->adminname, + 0, + AccountStatus::Player, + Chat::White, + fmt::format( + "Zone Failed to {} | Name: {} ({}) ID: {}", + lock_zone->op == ServerLockType::Lock ? "Lock" : "Unlock", + ZoneLongName(lock_zone->zoneID), + ZoneName(lock_zone->zoneID), + lock_zone->zoneID + ).c_str() + ); + } + break; + } + + break; + } + case ServerOP_Revoke: { + auto rev = (RevokeStruct*) pack->pBuffer; + auto cle = client_list.FindCharacter(rev->name); + if (cle && cle->Server()) { cle->Server()->SendPacket(pack); } - } - else { - SendEmoteMessage( - gmg->myname, - 0, - AccountStatus::Player, - Chat::Red, - fmt::format( - "Error: {} not found", - gmg->gotoname - ).c_str() - ); - } - break; - } - case ServerOP_Lock: { - if (pack->size != sizeof(ServerLock_Struct)) { - LogInfo("Wrong size on ServerOP_Lock. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLock_Struct)); + break; } - ServerLock_Struct* slock = (ServerLock_Struct*)pack->pBuffer; - if (slock->mode >= 1) - WorldConfig::LockWorld(); - else - WorldConfig::UnlockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); - SendEmoteMessage( - slock->myname, - 0, - AccountStatus::Player, - Chat::Red, - fmt::format( - "World {}.", - slock->mode ? "locked" : "unlocked" - ).c_str() - ); - } - else { - SendEmoteMessage( - slock->myname, - 0, - AccountStatus::Player, - Chat::Red, - fmt::format( - "World {}, but login server not connected.", - slock->mode ? "locked" : "unlocked" - ).c_str() - ); - } - break; - } - case ServerOP_Motd: { - if (pack->size != sizeof(ServerMotd_Struct)) { - LogInfo("Wrong size on ServerOP_Motd. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerMotd_Struct)); - break; - } - ServerMotd_Struct* smotd = (ServerMotd_Struct*)pack->pBuffer; - database.SetVariable("MOTD", smotd->motd); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_Uptime: { - if (pack->size != sizeof(ServerUptime_Struct)) { - LogInfo("Wrong size on ServerOP_Uptime. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerUptime_Struct)); - break; - } - ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer; - if (sus->zoneserverid == 0) { - ZSList::ShowUpTime(this, sus->adminname); - } - else { - ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid); - if (zs) + case ServerOP_SpawnPlayerCorpse: { + auto s = (SpawnPlayerCorpse_Struct*) pack->pBuffer; + auto zs = zoneserver_list.FindByZoneID(s->zone_id); + if (zs) { zs->SendPacket(pack); - } - break; - } - case ServerOP_Petition: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_GetWorldTime: { - LogInfo("Broadcasting a world time update"); - auto pack = new ServerPacket; + } - pack->opcode = ServerOP_SyncWorldTime; - pack->size = sizeof(eqTimeOfDay); - pack->pBuffer = new uchar[pack->size]; - memset(pack->pBuffer, 0, pack->size); - eqTimeOfDay* tod = (eqTimeOfDay*)pack->pBuffer; - tod->start_eqtime = zoneserver_list.worldclock.getStartEQTime(); - tod->start_realtime = zoneserver_list.worldclock.getStartRealTime(); - SendPacket(pack); - safe_delete(pack); - break; - } - case ServerOP_RefreshCensorship: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_SetWorldTime: { - LogNetcode("Received SetWorldTime"); - eqTimeOfDay* newtime = (eqTimeOfDay*)pack->pBuffer; - zoneserver_list.worldclock.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime); - LogInfo("New time = [{}]-[{}]-[{}] [{}]:[{}] ([{}])\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime); - database.SaveTime((int)newtime->start_eqtime.minute, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.day, newtime->start_eqtime.month, newtime->start_eqtime.year); - zoneserver_list.SendTimeSync(); - break; - } - case ServerOP_IPLookup: { - if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) { - LogInfo("Wrong size on ServerOP_IPLookup. Got: [{}], Expected (at least): [{}]", pack->size, sizeof(ServerGenericWorldQuery_Struct)); - break; - } - ServerGenericWorldQuery_Struct* sgwq = (ServerGenericWorldQuery_Struct*)pack->pBuffer; - if (pack->size == sizeof(ServerGenericWorldQuery_Struct)) - client_list.SendCLEList(sgwq->admin, sgwq->from, this); - else - client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query); - break; - } - case ServerOP_LockZone: { - if (pack->size < sizeof(ServerLockZone_Struct)) { - LogInfo("Wrong size on ServerOP_LockZone. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLockZone_Struct)); break; } + case ServerOP_Consent_Response: { + auto s = (ServerOP_Consent_Struct*) pack->pBuffer; - ServerLockZone_Struct* lock_zone = (ServerLockZone_Struct*) pack->pBuffer; - if (lock_zone->op == ServerLockType::List) { - zoneserver_list.ListLockedZones(lock_zone->adminname, this); - break; - } else if ( - lock_zone->op == ServerLockType::Lock || - lock_zone->op == ServerLockType::Unlock - ) { - if (zoneserver_list.SetLockedZone(lock_zone->zoneID, lock_zone->op == ServerLockType::Lock)) { - zoneserver_list.SendEmoteMessage( - 0, - 0, - AccountStatus::QuestTroupe, - Chat::White, - fmt::format( - "Zone {} | Name: {} ({}) ID: {}", - lock_zone->op == ServerLockType::Lock ? "Locked" : "Unlocked", - ZoneLongName(lock_zone->zoneID), - ZoneName(lock_zone->zoneID), - lock_zone->zoneID - ).c_str() - ); + auto owner_zs = ( + s->instance_id ? + zoneserver_list.FindByInstanceID(s->instance_id) : + zoneserver_list.FindByZoneID(s->zone_id) + ); + + if (owner_zs) { + owner_zs->SendPacket(pack); } else { - SendEmoteMessageRaw( - lock_zone->adminname, - 0, - AccountStatus::Player, - Chat::White, - fmt::format( - "Zone Failed to {} | Name: {} ({}) ID: {}", - lock_zone->op == ServerLockType::Lock ? "Lock" : "Unlock", - ZoneLongName(lock_zone->zoneID), - ZoneName(lock_zone->zoneID), - lock_zone->zoneID - ).c_str() - ); + LogInfo("Unable to locate zone record for zone id [{}] or instance id [{}] in zoneserver list for ServerOP_Consent_Response operation", s->zone_id, s->instance_id); } - break; - } - break; - } - case ServerOP_ItemStatus: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_OOCMute: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_Revoke: { - RevokeStruct* rev = (RevokeStruct*)pack->pBuffer; - ClientListEntry* cle = client_list.FindCharacter(rev->name); - if (cle != 0 && cle->Server() != 0) - { - cle->Server()->SendPacket(pack); - } - break; - } - case ServerOP_SpawnPlayerCorpse: { - SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer; - ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id); - if (zs) { - zs->SendPacket(pack); - } - break; - } - case ServerOP_Consent: { - zoneserver_list.SendPacket(pack); // update corpses in all zones - break; - } - case ServerOP_Consent_Response: { - ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; - ZoneServer* owner_zs = nullptr; - if (s->instance_id == 0) { - owner_zs = zoneserver_list.FindByZoneID(s->zone_id); - } - else { - owner_zs = zoneserver_list.FindByInstanceID(s->instance_id); - } + if (s->consent_type == EQ::consent::Normal) { + auto cle = client_list.FindCharacter(s->grantname); + if (cle) { + auto granted_zs = ( + cle->instance() ? + zoneserver_list.FindByInstanceID(cle->instance()) : + zoneserver_list.FindByZoneID(cle->zone()) + ); - if (owner_zs) { - owner_zs->SendPacket(pack); - } - else { - LogInfo("Unable to locate zone record for zone id [{}] or instance id [{}] in zoneserver list for ServerOP_Consent_Response operation", s->zone_id, s->instance_id); - } - - if (s->consent_type == EQ::consent::Normal) { - // send the message to the client being granted or denied permission - ClientListEntry* cle = client_list.FindCharacter(s->grantname); - if (cle) { - ZoneServer* granted_zs = nullptr; - if (cle->instance() == 0) { - granted_zs = zoneserver_list.FindByZoneID(cle->zone()); - } - else { - granted_zs = zoneserver_list.FindByInstanceID(cle->instance()); - } - // avoid sending twice if owner and granted are in same zone - if (granted_zs && granted_zs != owner_zs) { - granted_zs->SendPacket(pack); + if (granted_zs && granted_zs != owner_zs) { + granted_zs->SendPacket(pack); + } } } - } - break; - } - case ServerOP_InstanceUpdateTime: - { - ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer; - ZoneServer *zm = zoneserver_list.FindByInstanceID(iut->instance_id); - if (zm) - { - zm->SendPacket(pack); - } - break; - } - case ServerOP_QGlobalUpdate: - { - if (pack->size != sizeof(ServerQGlobalUpdate_Struct)) - { break; } + case ServerOP_InstanceUpdateTime: { + auto iut = (ServerInstanceUpdateTime_Struct*) pack->pBuffer; + auto zm = zoneserver_list.FindByInstanceID(iut->instance_id); + if (zm) { + zm->SendPacket(pack); + } - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_QGlobalDelete: - { - if (pack->size != sizeof(ServerQGlobalDelete_Struct)) - { break; } + case ServerOP_QGlobalUpdate: { + if (pack->size != sizeof(ServerQGlobalUpdate_Struct)) { + break; + } - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_AdventureRequest: - { - adventure_manager.CalculateAdventureRequestReply((const char*)pack->pBuffer); - break; - } - - case ServerOP_AdventureRequestCreate: - { - adventure_manager.TryAdventureCreate((const char*)pack->pBuffer); - break; - } - - case ServerOP_AdventureDataRequest: - { - AdventureFinishEvent fe; - while (adventure_manager.PopFinishedEvent((const char*)pack->pBuffer, fe)) - { - adventure_manager.SendAdventureFinish(fe); - } - adventure_manager.GetAdventureData((const char*)pack->pBuffer); - break; - } - - case ServerOP_AdventureClickDoor: - { - ServerPlayerClickedAdventureDoor_Struct *pcad = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer; - adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id); - break; - } - - case ServerOP_AdventureLeave: - { - adventure_manager.LeaveAdventure((const char*)pack->pBuffer); - break; - } - - case ServerOP_AdventureCountUpdate: - { - ServerAdventureCount_Struct *sc = (ServerAdventureCount_Struct*)pack->pBuffer; - adventure_manager.IncrementCount(sc->instance_id); - break; - } - - case ServerOP_AdventureAssaCountUpdate: - { - adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer)); - break; - } - case ServerOP_AdventureZoneData: - { - adventure_manager.GetZoneData(*((uint16*)pack->pBuffer)); - break; - } - - case ServerOP_AdventureLeaderboard: - { - ServerLeaderboardRequest_Struct *lr = (ServerLeaderboardRequest_Struct*)pack->pBuffer; - adventure_manager.DoLeaderboardRequest(lr->player, lr->type); - break; - } - - case ServerOP_LSAccountUpdate: - { - LogNetcode("Received ServerOP_LSAccountUpdate packet from zone"); - loginserverlist.SendAccountUpdate(pack); - break; - } - - case ServerOP_UCSMailMessage: - { - UCSLink.SendPacket(pack); - break; - } - - case ServerOP_UCSServerStatusRequest: - { - auto ucsss = (UCSServerStatus_Struct*)pack->pBuffer; - auto zs = zoneserver_list.FindByPort(ucsss->port); - if (!zs) + zoneserver_list.SendPacket(pack); break; - - auto outapp = new ServerPacket(ServerOP_UCSServerStatusReply, sizeof(UCSServerStatus_Struct)); - ucsss = (UCSServerStatus_Struct*)outapp->pBuffer; - ucsss->available = (UCSServerAvailable_ ? 1 : 0); - ucsss->timestamp = Timer::GetCurrentTime(); - zs->SendPacket(outapp); - safe_delete(outapp); - - break; - } - - case ServerOP_QSSendQuery: - case ServerOP_QueryServGeneric: - case ServerOP_Speech: - case ServerOP_QSPlayerLogTrades: - case ServerOP_QSPlayerLogHandins: - case ServerOP_QSPlayerLogNPCKills: - case ServerOP_QSPlayerLogDeletes: - case ServerOP_QSPlayerLogMoves: - case ServerOP_QSPlayerLogMerchantTransactions: - case ServerOP_QSPlayerDropItem: - { - QSLink.SendPacket(pack); - break; - } - case ServerOP_CZDialogueWindow: - case ServerOP_CZLDoNUpdate: - case ServerOP_CZMarquee: - case ServerOP_CZMessage: - case ServerOP_CZMove: - case ServerOP_CZSetEntityVariable: - case ServerOP_CZSignal: - case ServerOP_CZSpell: - case ServerOP_CZTaskUpdate: - case ServerOP_WWDialogueWindow: - case ServerOP_WWLDoNUpdate: - case ServerOP_WWMarquee: - case ServerOP_WWMessage: - case ServerOP_WWMove: - case ServerOP_WWSetEntityVariable: - case ServerOP_WWSignal: - case ServerOP_WWSpell: - case ServerOP_WWTaskUpdate: - case ServerOP_DepopAllPlayersCorpses: - case ServerOP_DepopPlayerCorpse: - case ServerOP_ReloadTitles: - case ServerOP_SpawnStatusChange: - case ServerOP_ReloadWorld: - case ServerOP_UpdateSpawn: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ReloadTasks: - { - // world needs to update its copy of task data as well - shared_task_manager.LoadTaskData(); - - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ChangeSharedMem: { - std::string hotfix_name = std::string((char*)pack->pBuffer); - - LogInfo("Loading items"); - if (!database.LoadItems(hotfix_name)) { - LogInfo("Error: Could not load item data. But ignoring"); } + case ServerOP_QGlobalDelete: { + if (pack->size != sizeof(ServerQGlobalDelete_Struct)) { + break; + } - LogInfo("Loading skill caps"); - if (!content_db.LoadSkillCaps(hotfix_name)) { - LogInfo("Error: Could not load skill cap data. But ignoring"); - } - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RequestTellQueue: - { - ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*)pack->pBuffer; - ClientListEntry *cle = client_list.FindCharacter(rtq->name); - if (!cle || cle->TellQueueEmpty()) + zoneserver_list.SendPacket(pack); break; + } + case ServerOP_AdventureRequest: { + adventure_manager.CalculateAdventureRequestReply((const char*) pack->pBuffer); + break; + } + case ServerOP_AdventureRequestCreate: { + adventure_manager.TryAdventureCreate((const char*) pack->pBuffer); + break; + } + case ServerOP_AdventureDataRequest: { + AdventureFinishEvent fe; + while (adventure_manager.PopFinishedEvent((const char*) pack->pBuffer, fe)) { + adventure_manager.SendAdventureFinish(fe); + } + adventure_manager.GetAdventureData((const char*) pack->pBuffer); + break; + } + case ServerOP_AdventureClickDoor: { + auto pcad = (ServerPlayerClickedAdventureDoor_Struct*) pack->pBuffer; + adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id); + break; + } + case ServerOP_AdventureLeave: { + adventure_manager.LeaveAdventure((const char*) pack->pBuffer); + break; + } + case ServerOP_AdventureCountUpdate: { + auto sc = (ServerAdventureCount_Struct*) pack->pBuffer; + adventure_manager.IncrementCount(sc->instance_id); + break; + } + case ServerOP_AdventureAssaCountUpdate: { + adventure_manager.IncrementAssassinationCount(*((uint16*) pack->pBuffer)); + break; + } + case ServerOP_AdventureZoneData: { + adventure_manager.GetZoneData(*((uint16*) pack->pBuffer)); + break; + } + case ServerOP_AdventureLeaderboard: { + auto lr = (ServerLeaderboardRequest_Struct*) pack->pBuffer; + adventure_manager.DoLeaderboardRequest(lr->player, lr->type); + break; + } + case ServerOP_LSAccountUpdate: { + LogNetcode("Received ServerOP_LSAccountUpdate packet from zone"); + loginserverlist.SendAccountUpdate(pack); + break; + } + case ServerOP_UCSMailMessage: { + UCSLink.SendPacket(pack); + break; + } + case ServerOP_UCSServerStatusRequest: { + auto ucsss = (UCSServerStatus_Struct*) pack->pBuffer; + auto zs = zoneserver_list.FindByPort(ucsss->port); + if (!zs) { + break; + } - cle->ProcessTellQueue(); - break; - } - case ServerOP_CZClientMessageString: - { - auto buf = reinterpret_cast(pack->pBuffer); - client_list.SendPacket(buf->client_name, pack); - break; - } - case ServerOP_ExpeditionLockout: - case ServerOP_ExpeditionLockoutDuration: - case ServerOP_ExpeditionLockState: - case ServerOP_ExpeditionReplayOnJoin: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_SharedTaskRequest: - case ServerOP_SharedTaskAddPlayer: - case ServerOP_SharedTaskAttemptRemove: - case ServerOP_SharedTaskUpdate: - case ServerOP_SharedTaskRequestMemberlist: - case ServerOP_SharedTaskRemovePlayer: - case ServerOP_SharedTaskInviteAcceptedPlayer: - case ServerOP_SharedTaskMakeLeader: - case ServerOP_SharedTaskCreateDynamicZone: - case ServerOP_SharedTaskPurgeAllCommand: - case ServerOP_SharedTaskPlayerList: - case ServerOP_SharedTaskKickPlayers: - { - SharedTaskWorldMessaging::HandleZoneMessage(pack); - break; - } + auto outapp = new ServerPacket(ServerOP_UCSServerStatusReply, sizeof(UCSServerStatus_Struct)); + ucsss = (UCSServerStatus_Struct*)outapp->pBuffer; + ucsss->available = (UCSServerAvailable_ ? 1 : 0); + ucsss->timestamp = Timer::GetCurrentTime(); + zs->SendPacket(outapp); + safe_delete(outapp); + break; + } + case ServerOP_Speech: + case ServerOP_QSSendQuery: + case ServerOP_QSPlayerLogDeletes: + case ServerOP_QSPlayerDropItem: + case ServerOP_QSPlayerLogHandins: + case ServerOP_QSPlayerLogMerchantTransactions: + case ServerOP_QSPlayerLogMoves: + case ServerOP_QSPlayerLogNPCKills: + case ServerOP_QSPlayerLogTrades: + case ServerOP_QueryServGeneric: { + QSLink.SendPacket(pack); + break; + } + case ServerOP_CZDialogueWindow: + case ServerOP_CZLDoNUpdate: + case ServerOP_CZMarquee: + case ServerOP_CZMessage: + case ServerOP_CZMove: + case ServerOP_CZSetEntityVariable: + case ServerOP_CZSignal: + case ServerOP_CZSpell: + case ServerOP_CZTaskUpdate: + case ServerOP_CameraShake: + case ServerOP_Consent: + case ServerOP_DepopAllPlayersCorpses: + case ServerOP_DepopPlayerCorpse: + case ServerOP_ExpeditionLockState: + case ServerOP_ExpeditionLockout: + case ServerOP_ExpeditionLockoutDuration: + case ServerOP_ExpeditionReplayOnJoin: + case ServerOP_GuildRankUpdate: + case ServerOP_ItemStatus: + case ServerOP_KickPlayer: + case ServerOP_KillPlayer: + case ServerOP_OOZGroupMessage: + case ServerOP_Petition: + case ServerOP_RaidGroupSay: + case ServerOP_RaidSay: + case ServerOP_RefreshCensorship: + case ServerOP_ReloadAAData: + case ServerOP_ReloadLevelEXPMods: + case ServerOP_ReloadMerchants: + case ServerOP_ReloadPerlExportSettings: + case ServerOP_ReloadStaticZoneData: + case ServerOP_ReloadTitles: + case ServerOP_ReloadWorld: + case ServerOP_ReloadZonePoints: + case ServerOP_RezzPlayerAccept: + case ServerOP_SpawnStatusChange: + case ServerOP_UpdateSpawn: + case ServerOP_WWDialogueWindow: + case ServerOP_WWLDoNUpdate: + case ServerOP_WWMarquee: + case ServerOP_WWMessage: + case ServerOP_WWMove: + case ServerOP_WWSetEntityVariable: + case ServerOP_WWSignal: + case ServerOP_WWSpell: + case ServerOP_WWTaskUpdate: + case ServerOP_ZonePlayer: { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_ReloadTasks: { + shared_task_manager.LoadTaskData(); + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_ChangeSharedMem: { + auto hotfix_name = std::string((char*) pack->pBuffer); - case ServerOP_ExpeditionCreate: - case ServerOP_ExpeditionDzAddPlayer: - case ServerOP_ExpeditionDzMakeLeader: - case ServerOP_ExpeditionCharacterLockout: - case ServerOP_ExpeditionSaveInvite: - case ServerOP_ExpeditionRequestInvite: - { - ExpeditionMessage::HandleZoneMessage(pack); - break; - } - case ServerOP_DzCreated: - case ServerOP_DzAddRemoveMember: - case ServerOP_DzSwapMembers: - case ServerOP_DzRemoveAllMembers: - case ServerOP_DzGetMemberStatuses: - case ServerOP_DzSetSecondsRemaining: - case ServerOP_DzSetCompass: - case ServerOP_DzSetSafeReturn: - case ServerOP_DzSetZoneIn: - case ServerOP_DzUpdateMemberStatus: - { - DynamicZone::HandleZoneMessage(pack); - break; - } - default: - { - LogInfo("Unknown ServerOPcode from zone {:#04x}, size [{}]", pack->opcode, pack->size); - DumpPacket(pack->pBuffer, pack->size); - break; - } + LogInfo("Loading items"); + if (!database.LoadItems(hotfix_name)) { + LogInfo("Error: Could not load item data. But ignoring"); + } + + LogInfo("Loading skill caps"); + if (!content_db.LoadSkillCaps(hotfix_name)) { + LogInfo("Error: Could not load skill cap data. But ignoring"); + } + + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RequestTellQueue: { + auto rtq = (ServerRequestTellQueue_Struct*) pack->pBuffer; + auto cle = client_list.FindCharacter(rtq->name); + if (!cle || cle->TellQueueEmpty()) { + break; + } + + cle->ProcessTellQueue(); + break; + } + case ServerOP_CZClientMessageString: { + auto buf = reinterpret_cast(pack->pBuffer); + client_list.SendPacket(buf->client_name, pack); + break; + } + case ServerOP_SharedTaskRequest: + case ServerOP_SharedTaskAddPlayer: + case ServerOP_SharedTaskAttemptRemove: + case ServerOP_SharedTaskUpdate: + case ServerOP_SharedTaskRequestMemberlist: + case ServerOP_SharedTaskRemovePlayer: + case ServerOP_SharedTaskInviteAcceptedPlayer: + case ServerOP_SharedTaskMakeLeader: + case ServerOP_SharedTaskCreateDynamicZone: + case ServerOP_SharedTaskPurgeAllCommand: + case ServerOP_SharedTaskPlayerList: + case ServerOP_SharedTaskKickPlayers: { + SharedTaskWorldMessaging::HandleZoneMessage(pack); + break; + } + case ServerOP_ExpeditionCreate: + case ServerOP_ExpeditionDzAddPlayer: + case ServerOP_ExpeditionDzMakeLeader: + case ServerOP_ExpeditionCharacterLockout: + case ServerOP_ExpeditionSaveInvite: + case ServerOP_ExpeditionRequestInvite: { + ExpeditionMessage::HandleZoneMessage(pack); + break; + } + case ServerOP_DzCreated: + case ServerOP_DzAddRemoveMember: + case ServerOP_DzSwapMembers: + case ServerOP_DzRemoveAllMembers: + case ServerOP_DzGetMemberStatuses: + case ServerOP_DzSetSecondsRemaining: + case ServerOP_DzSetCompass: + case ServerOP_DzSetSafeReturn: + case ServerOP_DzSetZoneIn: + case ServerOP_DzUpdateMemberStatus: { + DynamicZone::HandleZoneMessage(pack); + break; + } + default: { + LogInfo("Unknown ServerOPcode from zone {:#04x}, size [{}]", pack->opcode, pack->size); + DumpPacket(pack->pBuffer, pack->size); + break; + } } } void ZoneServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...) { - if (!message) + if (!message) { return; + } + va_list argptr; char buffer[1024]; @@ -1524,20 +1452,21 @@ void ZoneServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_ } void ZoneServer::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message) { - if (!message) + if (!message) { return; + } + auto pack = new ServerPacket; pack->opcode = ServerOP_EmoteMessage; pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1; pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; + auto sem = (ServerEmoteMessage_Struct*) pack->pBuffer; if (to != 0) { strcpy((char *)sem->to, to); - } - else { + } else { sem->to[0] = 0; } @@ -1552,7 +1481,7 @@ void ZoneServer::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 void ZoneServer::SendGroupIDs() { auto pack = new ServerPacket(ServerOP_GroupIDReply, sizeof(ServerGroupIDReply_Struct)); - ServerGroupIDReply_Struct* sgi = (ServerGroupIDReply_Struct*)pack->pBuffer; + auto sgi = (ServerGroupIDReply_Struct*) pack->pBuffer; zoneserver_list.NextGroupIDs(sgi->start, sgi->end); SendPacket(pack); delete pack; @@ -1567,7 +1496,7 @@ void ZoneServer::SendKeepAlive() void ZoneServer::ChangeWID(uint32 iCharID, uint32 iWID) { auto pack = new ServerPacket(ServerOP_ChangeWID, sizeof(ServerChangeWID_Struct)); - ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*)pack->pBuffer; + auto scw = (ServerChangeWID_Struct*) pack->pBuffer; scw->charid = iCharID; scw->newwid = iWID; zoneserver_list.SendPacket(pack); @@ -1575,33 +1504,30 @@ void ZoneServer::ChangeWID(uint32 iCharID, uint32 iWID) { } -void ZoneServer::TriggerBootup(uint32 iZoneID, uint32 iInstanceID, const char* adminname, bool iMakeStatic) { +void ZoneServer::TriggerBootup(uint32 zone_id, uint32 instance_id, const char* admin_name, bool is_static_zone) { is_booting_up = true; - zone_server_zone_id = iZoneID; - instance_id = iInstanceID; + zone_server_zone_id = zone_id; + instance_id = instance_id; auto pack = new ServerPacket(ServerOP_ZoneBootup, sizeof(ServerZoneStateChange_struct)); - ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer; + auto s = (ServerZoneStateChange_struct*) pack->pBuffer; s->ZoneServerID = zone_server_id; - if (adminname != 0) - strcpy(s->adminname, adminname); + if (admin_name) { + strn0cpy(s->adminname, admin_name, sizeof(s->adminname)); + } - if (iZoneID == 0) - s->zoneid = GetZoneID(); - else - s->zoneid = iZoneID; - - s->instanceid = iInstanceID; - s->makestatic = iMakeStatic; + s->zoneid = zone_id ? zone_id : GetZoneID(); + s->instanceid = instance_id; + s->makestatic = is_static_zone; SendPacket(pack); delete pack; - LSBootUpdate(iZoneID, iInstanceID); + LSBootUpdate(zone_id, instance_id); } void ZoneServer::IncomingClient(Client* client) { is_booting_up = true; auto pack = new ServerPacket(ServerOP_ZoneIncClient, sizeof(ServerZoneIncomingClient_Struct)); - ServerZoneIncomingClient_Struct* s = (ServerZoneIncomingClient_Struct*)pack->pBuffer; + auto s = (ServerZoneIncomingClient_Struct*) pack->pBuffer; s->zoneid = GetZoneID(); s->instanceid = GetInstanceID(); s->wid = client->GetWID(); @@ -1610,8 +1536,11 @@ void ZoneServer::IncomingClient(Client* client) { s->admin = client->GetAdmin(); s->charid = client->GetCharID(); s->lsid = client->GetLSID(); - if (client->GetCLE()) + + if (client->GetCLE()) { s->tellsoff = client->GetCLE()->TellsOff(); + } + strn0cpy(s->charname, client->GetCharName(), sizeof(s->charname)); strn0cpy(s->lskey, client->GetLSKey(), sizeof(s->lskey)); SendPacket(pack); diff --git a/world/zoneserver.h b/world/zoneserver.h index 98f60dcdb..3298892ae 100644 --- a/world/zoneserver.h +++ b/world/zoneserver.h @@ -40,13 +40,13 @@ public: void SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...); void SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message); void SendKeepAlive(); - bool SetZone(uint32 iZoneID, uint32 iInstanceID = 0, bool iStaticZone = false); - void TriggerBootup(uint32 iZoneID = 0, uint32 iInstanceID = 0, const char* iAdminName = 0, bool iMakeStatic = false); + bool SetZone(uint32 zone_id, uint32 instance_id = 0, bool is_static_zone = false); + void TriggerBootup(uint32 zone_id = 0, uint32 instance_id = 0, const char* admin_name = 0, bool is_static_zone = false); void Disconnect() { auto handle = tcpc->Handle(); if (handle) { handle->Disconnect(); } } void IncomingClient(Client* client); - void LSBootUpdate(uint32 zoneid, uint32 iInstanceID = 0, bool startup = false); - void LSSleepUpdate(uint32 zoneid); - void LSShutDownUpdate(uint32 zoneid); + void LSBootUpdate(uint32 zone_id, uint32 instance_id = 0, bool startup = false); + void LSSleepUpdate(uint32 zone_id); + void LSShutDownUpdate(uint32 zone_id); uint32 GetPrevZoneID() { return zone_server_previous_zone_id; } void ChangeWID(uint32 iCharID, uint32 iWID); void SendGroupIDs(); diff --git a/zone/aggro.cpp b/zone/aggro.cpp index bd1f91426..8eead60d9 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -37,15 +37,14 @@ extern Zone* zone; //#define LOSDEBUG 6 -void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbose) { +void EntityList::DescribeAggro(Client *to_who, NPC *from_who, float d, bool verbose) { float distance_squared = (d * d); - towho->Message( + to_who->Message( Chat::White, fmt::format( "Describing aggro for {} ({}).", - from_who->GetCleanName(), - from_who->GetID() + to_who->GetTargetDescription(from_who) ).c_str() ); @@ -53,18 +52,14 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo bool will_aggro_npcs = from_who->WillAggroNPCs(); if (is_engaged) { Mob *top = from_who->GetHateTop(); - towho->Message( + to_who->Message( Chat::White, fmt::format( "I am currently engaged with {}.", ( !top ? "nothing" : - fmt::format( - "{} ({})", - top->GetCleanName(), - top->GetID() - ) + from_who->GetTargetDescription(top) ) ).c_str() ); @@ -90,12 +85,11 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo ) ); - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is on Faction {} ({}).", - from_who->GetCleanName(), - from_who->GetID(), + "{} is on Faction {} ({}).", + to_who->GetTargetDescription(from_who), faction_name, faction_id ).c_str() @@ -115,12 +109,11 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo if (is_engaged) { uint32 hate_amount = from_who->GetHateAmount(npc); - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is {}on my hate list{}.", - npc->GetCleanName(), - npc->GetID(), + "{} is {}on my hate list{}.", + to_who->GetTargetDescription(npc), !hate_amount ? "not " : "", ( !hate_amount ? @@ -133,21 +126,20 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo ).c_str() ); } else if (!will_aggro_npcs) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is an NPC and I cannot aggro NPCs.", - npc->GetCleanName(), - npc->GetID() + "{} is an NPC and I cannot aggro NPCs.", + to_who->GetTargetDescription(npc) ).c_str() ); } else { - from_who->DescribeAggro(towho, npc, verbose); + from_who->DescribeAggro(to_who, npc, verbose); } } } -void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { +void NPC::DescribeAggro(Client *to_who, Mob *mob, bool verbose) { //this logic is duplicated from below, try to keep it up to date. float aggro_range = GetAggroRange(); float x_range = std::abs(mob->GetX() - GetX()); @@ -158,12 +150,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { y_range > aggro_range || z_range > aggro_range ) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is out of range. X Range: {} Y Range: {} Z Range: {} Aggro Range: {}", - mob->GetCleanName(), - mob->GetID(), + "{} is out of range. X Range: {} Y Range: {} Z Range: {} Aggro Range: {}", + to_who->GetTargetDescription(mob), x_range, y_range, z_range, @@ -174,12 +165,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { } if (mob->IsInvisible(this)) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is invisible to me. ", - mob->GetCleanName(), - mob->GetID() + "{} is invisible to me.", + to_who->GetTargetDescription(mob) ).c_str() ); return; @@ -194,12 +184,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { mob->CastToClient()->GetGM() ) ) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is a GM or is not connected. ", - mob->GetCleanName(), - mob->GetID() + "{} is a GM or is not connected.", + to_who->GetTargetDescription(mob) ).c_str() ); return; @@ -207,12 +196,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { if (mob == GetOwner()) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is my owner. ", - mob->GetCleanName(), - mob->GetID() + "{} is my owner.", + to_who->GetTargetDescription(mob) ).c_str() ); return; @@ -221,12 +209,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { float distance_squared = DistanceSquared(mob->GetPosition(), m_Position); float aggro_range_squared = (aggro_range * aggro_range); if (distance_squared > aggro_range_squared) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is out of range. Distance: {:.2f} Aggro Range: {:.2f}", - mob->GetCleanName(), - mob->GetID(), + "{} is out of range. Distance: {:.2f} Aggro Range: {:.2f}", + to_who->GetTargetDescription(mob), distance_squared, aggro_range_squared ).c_str() @@ -241,12 +228,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { GetBodyType() != BT_Undead && !AlwaysAggro() ) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) considers Red to me.", - mob->GetCleanName(), - mob->GetID() + "{} considers Red to me.", + to_who->GetTargetDescription(mob) ).c_str() ); return; @@ -257,12 +243,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { mob->GetLevelCon(GetLevel()) == CON_GRAY && !AlwaysAggro() ) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) considers Red to me.", - mob->GetCleanName(), - mob->GetID() + "{} considers Red to me.", + to_who->GetTargetDescription(mob) ).c_str() ); return; @@ -283,21 +268,19 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { } if (!mob_faction_id) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) has no primary Faction.", - mob->GetCleanName(), - mob->GetID() + "{} has no primary Faction.", + to_who->GetTargetDescription(mob) ).c_str() ); } else if (mob_faction_id < 0) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is on special Faction {}.", - mob->GetCleanName(), - mob->GetID(), + "{} is on special Faction {}.", + to_who->GetTargetDescription(mob), mob_faction_id ).c_str() ); @@ -306,12 +289,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { bool has_entry = false; for (auto faction : faction_list) { if (static_cast(faction->factionID) == mob_faction_id) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) has {} standing with Faction {} ({}) with their Faction Level of {}", - mob->GetCleanName(), - mob->GetID(), + "{} has {} standing with Faction {} ({}) with their Faction Level of {}", + to_who->GetTargetDescription(mob), ( faction->npc_value != 0 ? ( @@ -332,12 +314,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { } if (!has_entry) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) is on Faction {} ({}), for which I do not have an entry.", - mob->GetCleanName(), - mob->GetID(), + "{} is on Faction {} ({}), for which I do not have an entry.", + to_who->GetTargetDescription(mob), faction_name, mob_faction_id ).c_str() @@ -348,7 +329,7 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { auto faction_value = mob->GetReverseFactionCon(this); - if( + if ( !( faction_value == FACTION_THREATENINGLY || faction_value == FACTION_SCOWLS || @@ -359,12 +340,11 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { ) ) ) { - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) does not have low enough faction, their Faction Level is {} ({}).", - mob->GetCleanName(), - mob->GetID(), + "{} does not have low enough faction, their Faction Level is {} ({}).", + to_who->GetTargetDescription(mob), FactionValueToString(faction_value), faction_value ).c_str() @@ -372,23 +352,21 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { return; } - if(!CheckLosFN(mob)) { - towho->Message( + if (!CheckLosFN(mob)) { + to_who->Message( Chat::White, fmt::format( - "{} ({}) is out of sight.", - mob->GetCleanName(), - mob->GetID() + "{} is out of sight.", + to_who->GetTargetDescription(mob) ).c_str() ); } - towho->Message( + to_who->Message( Chat::White, fmt::format( - "{} ({}) meets all conditions, I should be attacking them.", - mob->GetCleanName(), - mob->GetID() + "{} meets all conditions, I should be attacking them.", + to_who->GetTargetDescription(mob) ).c_str() ); } diff --git a/zone/client.h b/zone/client.h index 1afa32fa3..2622efcc4 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1267,7 +1267,7 @@ public: return (task_state ? task_state->EnabledTaskCount(task_set_id) : -1); } inline int IsTaskCompleted(int task_id) { return (task_state ? task_state->IsTaskCompleted(task_id) : -1); } - inline void ShowClientTasks(Client *client) { if (task_state) { task_state->ShowClientTasks(client); }} + inline void ShowClientTasks(Client *client) { if (task_state) { task_state->ShowClientTasks(this, client); }} inline void CancelAllTasks() { if (task_state) { task_state->CancelAllTasks(this); }} inline int GetActiveTaskCount() { return (task_state ? task_state->GetActiveTaskCount() : 0); } inline int GetActiveTaskID(int index) { return (task_state ? task_state->GetActiveTaskID(index) : -1); } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 63f59f73b..eeae9a4f9 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -799,9 +799,8 @@ void Client::CompleteConnect() Message( Chat::Yellow, fmt::format( - "{} ({}) will expire in {}.", - zone->GetLongName(), - zone->GetInstanceID(), + "{} will expire in {}.", + zone->GetZoneDescription(), time_string ).c_str() ); diff --git a/zone/command.cpp b/zone/command.cpp index fd9e7cff1..3062f825b 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -296,7 +296,7 @@ int command_init(void) command_add("reloadtraps", "[0|1] - Reloads and repops traps, globally if specified (1 = global)", AccountStatus::QuestTroupe, command_reloadtraps) || command_add("reloadtitles", "- Reload player titles from the database", AccountStatus::GMLeadAdmin, command_reloadtitles) || command_add("reloadworld", "[0|1|2] - Reload quests global and repop NPCs if specified (0 = No Repop, 1 = Repop, 2 = Force Repop)", AccountStatus::Max, command_reloadworld) || - command_add("reloadzps", "- Reload zone points from database", AccountStatus::GMLeadAdmin, command_reloadzps) || + command_add("reloadzps", "- Reload zone points from database globally", AccountStatus::GMLeadAdmin, command_reloadzps) || command_add("removeitem", "[Item ID] [Amount] - Removes the specified Item ID by Amount from you or your player target's inventory (Amount defaults to 1 if not used)", AccountStatus::GMAdmin, command_removeitem) || command_add("repop", "[Force] - Repop the zone with optional force repop", AccountStatus::GMAdmin, command_repop) || command_add("resetaa", "- Resets a Player's AA in their profile and refunds spent AA's to unspent, may disconnect player.", AccountStatus::GMMgmt, command_resetaa) || @@ -1104,15 +1104,7 @@ void command_emptyinventory(Client *c, const Seperator *sep) Chat::White, fmt::format( "Inventory cleared for {}, {} items deleted.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), removed_count ).c_str() ); @@ -1120,16 +1112,9 @@ void command_emptyinventory(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} no items to delete.", - ( - c == target ? - "You have" : - fmt::format( - "{} ({}) has", - target->GetCleanName(), - target->GetID() - ) - ) + "{} {} no items to delete.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "have" : "has" ).c_str() ); } diff --git a/zone/entity.h b/zone/entity.h index b8fe43a22..982fe2bd2 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -331,7 +331,7 @@ public: void StopMobAI(); - void DescribeAggro(Client *towho, NPC *from_who, float dist, bool verbose); + void DescribeAggro(Client *to_who, NPC *from_who, float dist, bool verbose); void Message(uint32 to_guilddbid, uint32 type, const char* message, ...); void MessageStatus(uint32 to_guilddbid, int to_minstatus, uint32 type, const char* message, ...); diff --git a/zone/gm_commands/advnpcspawn.cpp b/zone/gm_commands/advnpcspawn.cpp index 7545ded35..7daa174d4 100755 --- a/zone/gm_commands/advnpcspawn.cpp +++ b/zone/gm_commands/advnpcspawn.cpp @@ -206,10 +206,8 @@ void command_advnpcspawn(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Spawn2 {} Deleted | Name: {} ({})", - spawn2_id, - target->GetCleanName(), - target->GetID() + "Spawn2 {} Deleted | Name: {}", + spawn2_id,c->GetTargetDescription(target) ).c_str() ); target->Depop(false); @@ -324,10 +322,9 @@ void command_advnpcspawn(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Spawn2 {} Respawn Modified | Name: {} ({}) Respawn Timer: {} Variance: {}", + "Spawn2 {} Respawn Modified | Name: {} Respawn Timer: {} Variance: {}", spawn2_id, - target->GetCleanName(), - target->GetID(), + c->GetTargetDescription(target), respawn_timer, variance ).c_str() @@ -468,10 +465,9 @@ void command_advnpcspawn(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Spawn2 {} Moved | Name: {} ({})", + "Spawn2 {} Moved | Name: {}", spawn2_id, - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); c->Message( @@ -520,10 +516,9 @@ void command_advnpcspawn(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Spawngroup {} Version Modified | Name: {} ({}) Version: {}", + "Spawngroup {} Version Modified | Name: {} Version: {}", target->GetSpawnGroupId(), - target->GetCleanName(), - target->GetID(), + c->GetTargetDescription(target), version ).c_str() ); diff --git a/zone/gm_commands/aggrozone.cpp b/zone/gm_commands/aggrozone.cpp index 797ed2128..606900435 100755 --- a/zone/gm_commands/aggrozone.cpp +++ b/zone/gm_commands/aggrozone.cpp @@ -17,15 +17,7 @@ void command_aggrozone(Client *c, const Seperator *sep) Chat::White, fmt::format( "Aggroing zone on {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/ai.cpp b/zone/gm_commands/ai.cpp index e7f686307..88c3e2a02 100755 --- a/zone/gm_commands/ai.cpp +++ b/zone/gm_commands/ai.cpp @@ -51,11 +51,9 @@ void command_ai(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) considers {} ({}) as {} ({}).", - target->GetCleanName(), - target->GetID(), - mob_to_consider->GetCleanName(), - mob_to_consider->GetID(), + "{} considers {} as {} ({}).", + c->GetTargetDescription(target), + c->GetTargetDescription(mob_to_consider), EQ::constants::GetConsiderLevelName(consider_level), consider_level ).c_str() @@ -72,9 +70,8 @@ void command_ai(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) is now on Faction {}.", - target->GetCleanName(), - target->GetID(), + "{} is now on Faction {}.", + c->GetTargetDescription(target), ( faction_name.empty() ? std::to_string(faction_id) : @@ -97,9 +94,8 @@ void command_ai(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) now has a guard spot of {:.2f}, {:.2f}, {:.2f} with a heading of {:.2f}.", - target->GetCleanName(), - target->GetID(), + "{} now has a guard spot of {:.2f}, {:.2f}, {:.2f} with a heading of {:.2f}.", + c->GetTargetDescription(target), target_position.x, target_position.y, target_position.z, @@ -147,9 +143,8 @@ void command_ai(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) now has a roambox from {}, {} to {}, {} with {} and {} and a distance of {}.", - target->GetCleanName(), - target->GetID(), + "{} now has a roambox from {}, {} to {}, {} with {} and {} and a distance of {}.", + c->GetTargetDescription(target), min_x, min_y, max_x, @@ -205,9 +200,8 @@ void command_ai(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) now has a roambox with a max distance of {} and a roam distance variance of {} with {} and {}.", - target->GetCleanName(), - target->GetID(), + "{} now has a roambox with a max distance of {} and a roam distance variance of {} with {} and {}.", + c->GetTargetDescription(target), max_distance, roam_distance_variance, ( @@ -246,9 +240,8 @@ void command_ai(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) is now using Spell List {}.", - target->GetCleanName(), - target->GetID(), + "{} is now using Spell List {}.", + c->GetTargetDescription(target), spell_list_id ).c_str() ); diff --git a/zone/gm_commands/attack.cpp b/zone/gm_commands/attack.cpp index dc6f3e29e..4623a85ca 100755 --- a/zone/gm_commands/attack.cpp +++ b/zone/gm_commands/attack.cpp @@ -19,10 +19,9 @@ void command_attack(Client *c, const Seperator *sep) c->Message( Chat::EchoChat1, fmt::format( - "{} whispers, 'Attacking {} ({}).'", + "{} whispers, 'Attacking {}.'", c->GetTarget()->GetCleanName(), - entity->GetCleanName(), - entity->GetID() + c->GetTargetDescription(entity) ).c_str() ); } else { diff --git a/zone/gm_commands/bind.cpp b/zone/gm_commands/bind.cpp index f9a68502e..4c1b56644 100755 --- a/zone/gm_commands/bind.cpp +++ b/zone/gm_commands/bind.cpp @@ -7,39 +7,27 @@ void command_bind(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - target->SetBindPoint(); - - bool in_persistent_instance = ( - zone->GetInstanceID() != 0 && - zone->IsInstancePersistent() - ); - - auto target_string = ( - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() + bool bind_allowed = ( + !zone->GetInstanceID() || + ( + zone->GetInstanceID() != 0 && + zone->IsInstancePersistent() ) ); + if (!bind_allowed) { + c->Message(Chat::White, "Yu cannot bind here."); + return; + } + + target->SetBindPoint(); + c->Message( Chat::White, fmt::format( - "Set Bind Point for {} | Zone: {} ({}) ID: {} {}", - target_string, - zone->GetLongName(), - zone->GetShortName(), - zone->GetZoneID(), - ( - in_persistent_instance ? - fmt::format( - " Instance ID: {}", - zone->GetInstanceID() - ) : - "" - ) + "Set Bind Point for {} | Zone: {}", + c->GetTargetDescription(target), + zone->GetZoneDescription() ).c_str() ); @@ -47,7 +35,7 @@ void command_bind(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set Bind Point for {} | XYZ: {:.2f}, {:.2f}, {:.2f}", - target_string, + c->GetTargetDescription(target), target->GetX(), target->GetY(), target->GetZ() diff --git a/zone/gm_commands/castspell.cpp b/zone/gm_commands/castspell.cpp index 68e2e1801..ef0be063d 100755 --- a/zone/gm_commands/castspell.cpp +++ b/zone/gm_commands/castspell.cpp @@ -54,15 +54,7 @@ void command_castspell(Client *c, const Seperator *sep) "Cast {} ({}) on {}{}.", GetSpellName(spell_id), spell_id, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), instant_cast ? " instantly" : "" ).c_str() ); diff --git a/zone/gm_commands/checklos.cpp b/zone/gm_commands/checklos.cpp index fa54a56ef..150e74649 100755 --- a/zone/gm_commands/checklos.cpp +++ b/zone/gm_commands/checklos.cpp @@ -4,16 +4,19 @@ void command_checklos(Client *c, const Seperator *sep) { if (!c->GetTarget()) { c->Message(Chat::White, "You must have a target to use this command."); + return; } - bool has_los = c->CheckLosFN(c->GetTarget()); + auto target = c->GetTarget(); + + bool has_los = c->CheckLosFN(target); + c->Message( Chat::White, fmt::format( - "You {}have line of sight to {} ({}).", + "You {}have line of sight to {}.", has_los ? "" : "do not ", - c->GetTarget()->GetCleanName(), - c->GetTarget()->GetID() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/corpse.cpp b/zone/gm_commands/corpse.cpp index 43c760fc4..d1176b599 100755 --- a/zone/gm_commands/corpse.cpp +++ b/zone/gm_commands/corpse.cpp @@ -110,10 +110,9 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Deleting {} corpse {} ({}).", + "Deleting {} corpse {}.", target->IsNPCCorpse() ? "NPC" : "player", - target->GetName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); target->CastToCorpse()->Delete(); @@ -155,11 +154,10 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Setting the owner to {} ({}) for the player corpse {} ({}).", + "Setting the owner to {} ({}) for the player corpse {}.", database.GetCharNameByID(character_id), target->CastToCorpse()->SetCharID(character_id), - target->GetName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } else { @@ -181,10 +179,9 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Reset looter for {} corpse {} ({}).", + "Reset looter for {} corpse {}.", target->IsNPCCorpse() ? "NPC" : "player", - target->GetName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } else if (is_remove_cash) { @@ -206,10 +203,9 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Removed cash from {} corpse {} ({}).", + "Removed cash from {} corpse {}.", target->IsNPCCorpse() ? "NPC" : "player", - target->GetName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } @@ -240,10 +236,9 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Locking {} corpse {} ({}).", + "Locking {} corpse {}.", target->IsNPCCorpse() ? "NPC" : "player", - target->GetName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } else if (is_unlock) { @@ -261,10 +256,9 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Unlocking {} corpse {} ({}).", + "Unlocking {} corpse {}.", target->IsNPCCorpse() ? "NPC" : "player", - target->GetName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } else if (is_depop) { @@ -286,9 +280,8 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Depopping player corpse {} ({}).", - target->GetName(), - target->GetID() + "Depopping player corpse {}.", + c->GetTargetDescription(target) ).c_str() ); target->CastToCorpse()->DepopPlayerCorpse(); @@ -318,9 +311,8 @@ void command_corpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Depopping all player corpses for {} ({}).", - target->GetName(), - target->GetID() + "Depopping all player corpses for {}.", + c->GetTargetDescription(target) ).c_str() ); target->CastToClient()->DepopAllCorpses(); diff --git a/zone/gm_commands/countitem.cpp b/zone/gm_commands/countitem.cpp index 01e507081..c65e9c46f 100644 --- a/zone/gm_commands/countitem.cpp +++ b/zone/gm_commands/countitem.cpp @@ -42,15 +42,7 @@ void command_countitem(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} {} {} {}.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", ( item_count ? diff --git a/zone/gm_commands/distance.cpp b/zone/gm_commands/distance.cpp index 578f94bb5..f69446129 100755 --- a/zone/gm_commands/distance.cpp +++ b/zone/gm_commands/distance.cpp @@ -8,9 +8,8 @@ void command_distance(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) is {:.2f} units from you.", - target->GetCleanName(), - target->GetID(), + "{} is {:.2f} units from you.", + c->GetTargetDescription(target), Distance( c->GetPosition(), target->GetPosition() diff --git a/zone/gm_commands/endurance.cpp b/zone/gm_commands/endurance.cpp index 9ae34a477..7f113a949 100755 --- a/zone/gm_commands/endurance.cpp +++ b/zone/gm_commands/endurance.cpp @@ -20,15 +20,7 @@ void command_endurance(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} to full Endurance ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), endurance ).c_str() ); diff --git a/zone/gm_commands/faction.cpp b/zone/gm_commands/faction.cpp index 3a704c81a..43aec7904 100755 --- a/zone/gm_commands/faction.cpp +++ b/zone/gm_commands/faction.cpp @@ -154,16 +154,13 @@ void command_faction(Client *c, const Seperator *sep) } else if (!strcasecmp(sep->arg[1], "view")) { if (c->GetTarget() && c->GetTarget()->IsNPC()) { - Mob *target = c->GetTarget(); - uint32 npc_id = target->GetNPCTypeID(); - uint32 npc_faction_id = target->CastToNPC()->GetPrimaryFaction(); - std::string npc_name = target->GetCleanName(); + auto target = c->GetTarget(); + auto npc_faction_id = target->CastToNPC()->GetPrimaryFaction(); c->Message( Chat::White, fmt::format( - "{} ({}) has a Primary Faction of {} ({}).", - npc_name, - npc_id, + "{} has a Primary Faction of {} ({}).", + c->GetTargetDescription(target), content_db.GetFactionName(npc_faction_id), npc_faction_id ).c_str() diff --git a/zone/gm_commands/feature.cpp b/zone/gm_commands/feature.cpp index bacd6c7c0..60ab3a4a4 100644 --- a/zone/gm_commands/feature.cpp +++ b/zone/gm_commands/feature.cpp @@ -210,15 +210,7 @@ void command_feature(Client *c, const Seperator *sep) fmt::format( "{} set for {} to {}.", feature_changed, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ( is_size ? fmt::format( diff --git a/zone/gm_commands/flagedit.cpp b/zone/gm_commands/flagedit.cpp index 2b3cf746b..af87b7df6 100755 --- a/zone/gm_commands/flagedit.cpp +++ b/zone/gm_commands/flagedit.cpp @@ -99,13 +99,7 @@ void command_flagedit(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} now {} the flag for {} ({}).", - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", zone_long_name, zone_id @@ -229,13 +223,7 @@ void command_flagedit(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} no longer {} the flag for {} ({}).", - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", zone_long_name, zone_id diff --git a/zone/gm_commands/flymode.cpp b/zone/gm_commands/flymode.cpp index c9c76fd98..58dcf0c7b 100755 --- a/zone/gm_commands/flymode.cpp +++ b/zone/gm_commands/flymode.cpp @@ -28,15 +28,7 @@ void command_flymode(Client *c, const Seperator *sep) Chat::White, fmt::format( "Fly Mode for {} is now {} ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), EQ::constants::GetFlyModeName(flymode_id), flymode_id ).c_str() diff --git a/zone/gm_commands/fov.cpp b/zone/gm_commands/fov.cpp index 50447a326..bfb8397c3 100755 --- a/zone/gm_commands/fov.cpp +++ b/zone/gm_commands/fov.cpp @@ -2,41 +2,42 @@ void command_fov(Client *c, const Seperator *sep) { - if (c->GetTarget()) { - auto target = c->GetTarget(); - std::string behind_message = ( - c->BehindMob( - target, - c->GetX(), - c->GetY() - ) ? - "behind" : - "not behind" - ); - std::string gender_message = ( - target->GetGender() == MALE ? - "he" : - ( - target->GetGender() == FEMALE ? - "she" : - "it" - ) - ); - - c->Message( - Chat::White, - fmt::format( - "You are {} {} ({}), {} has a heading of {}.", - behind_message, - target->GetCleanName(), - target->GetID(), - gender_message, - target->GetHeading() - ).c_str() - ); - } - else { + if (!c->GetTarget()) { c->Message(Chat::White, "You must have a target to use this command."); + return; } + + auto target = c->GetTarget(); + + std::string behind_message = ( + c->BehindMob( + target, + c->GetX(), + c->GetY() + ) ? + "behind" : + "not behind" + ); + + std::string gender_message = ( + target->GetGender() == MALE ? + "he" : + ( + target->GetGender() == FEMALE ? + "she" : + "it" + ) + ); + + c->Message( + Chat::White, + fmt::format( + "You are {} {}, {} has a heading of {}.", + behind_message, + c->GetTargetDescription(target), + gender_message, + target->GetHeading() + ).c_str() + ); } diff --git a/zone/gm_commands/freeze.cpp b/zone/gm_commands/freeze.cpp index d817af169..0b002b124 100755 --- a/zone/gm_commands/freeze.cpp +++ b/zone/gm_commands/freeze.cpp @@ -2,15 +2,25 @@ void command_freeze(Client *c, const Seperator *sep) { - if (c->GetTarget()) { - auto target = c->GetTarget(); - if (target != c) { - target->SendAppearancePacket(AT_Anim, ANIM_FREEZE); - } else { - c->Message(Chat::White, "You cannot freeze yourself."); - } - } else { + if (!c->GetTarget()) { c->Message(Chat::White, "You must have a target to use this command."); + return; } + + auto target = c->GetTarget(); + if (c == target) { + c->Message(Chat::White, "You cannot freeze yourself."); + return; + } + + target->SendAppearancePacket(AT_Anim, ANIM_FREEZE); + + c->Message( + Chat::White, + fmt::format( + "You have frozen {}.", + c->GetTargetDescription(target) + ).c_str() + ); } diff --git a/zone/gm_commands/gender.cpp b/zone/gm_commands/gender.cpp index 000d65f23..6e611e04a 100755 --- a/zone/gm_commands/gender.cpp +++ b/zone/gm_commands/gender.cpp @@ -30,15 +30,7 @@ void command_gender(Client *c, const Seperator *sep) Chat::White, fmt::format( "Gender changed for {} to {} ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), GetGenderName(gender_id), gender_id ).c_str() diff --git a/zone/gm_commands/getplayerburiedcorpsecount.cpp b/zone/gm_commands/getplayerburiedcorpsecount.cpp index 20e82bac4..8692c7d3e 100755 --- a/zone/gm_commands/getplayerburiedcorpsecount.cpp +++ b/zone/gm_commands/getplayerburiedcorpsecount.cpp @@ -12,16 +12,9 @@ void command_getplayerburiedcorpsecount(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} {} buried corpse{}.", - ( - c == target ? - "You have" : - fmt::format( - "{} ({}) has", - target->GetCleanName(), - target->GetID() - ) - ), + "{} {} {} buried corpse{}.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "have" : "has", ( corpse_count ? std::to_string(corpse_count) : diff --git a/zone/gm_commands/ginfo.cpp b/zone/gm_commands/ginfo.cpp index 65874bfd0..a8ab9cff1 100755 --- a/zone/gm_commands/ginfo.cpp +++ b/zone/gm_commands/ginfo.cpp @@ -13,16 +13,9 @@ void command_ginfo(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} not in a group.", - ( - c == target ? - "You are" : - fmt::format( - "{} ({}) is", - target->GetCleanName(), - target->GetID() - ) - ) + "{} {} not in a group.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "are" : "is" ).c_str() ); return; @@ -30,13 +23,7 @@ void command_ginfo(Client *c, const Seperator *sep) std::string popup_title = fmt::format( "Group Info for {}", - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target, TargetDescriptionType::UCSelf) ); std::string popup_text = ""; popup_text += fmt::format( diff --git a/zone/gm_commands/givemoney.cpp b/zone/gm_commands/givemoney.cpp index 705ab7461..701bd2412 100755 --- a/zone/gm_commands/givemoney.cpp +++ b/zone/gm_commands/givemoney.cpp @@ -36,15 +36,7 @@ void command_givemoney(Client *c, const Seperator *sep) fmt::format( "Added {} to {}.", ConvertMoneyToString(platinum, gold, silver, copper), - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/gm.cpp b/zone/gm_commands/gm.cpp index d781bb93a..fb5560b74 100755 --- a/zone/gm_commands/gm.cpp +++ b/zone/gm_commands/gm.cpp @@ -19,9 +19,8 @@ void command_gm(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) is {} flagged as a GM.", - target->GetCleanName(), - target->GetID(), + "{} is {} flagged as a GM.", + c->GetTargetDescription(target), gm_flag ? "now" : "no longer" ).c_str() ); diff --git a/zone/gm_commands/gmspeed.cpp b/zone/gm_commands/gmspeed.cpp index 30b5eccfa..627082c74 100755 --- a/zone/gm_commands/gmspeed.cpp +++ b/zone/gm_commands/gmspeed.cpp @@ -24,15 +24,7 @@ void command_gmspeed(Client *c, const Seperator *sep) fmt::format( "Turning GM Speed {} for {}.", gm_speed_flag ? "on" : "off", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); @@ -40,15 +32,7 @@ void command_gmspeed(Client *c, const Seperator *sep) Chat::White, fmt::format( "Note: {} must zone for it to take effect.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target, TargetDescriptionType::UCYou) ).c_str() ); } diff --git a/zone/gm_commands/guild.cpp b/zone/gm_commands/guild.cpp index aea407f7a..c1afc7259 100755 --- a/zone/gm_commands/guild.cpp +++ b/zone/gm_commands/guild.cpp @@ -519,16 +519,18 @@ void command_guild(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} is not in a guild.", - client->GetCleanName() + "{} {} not in a guild.", + c->GetTargetDescription(client, TargetDescriptionType::UCYou), + c == target ? "are" : "is" ).c_str() ); } else if (guild_mgr.IsGuildLeader(client->GuildID(), client->CharacterID())) { c->Message( Chat::White, fmt::format( - "{} is the leader of {}.", - client->GetName(), + "{} {} the leader of {}.", + c->GetTargetDescription(client, TargetDescriptionType::UCYou), + c == target ? "are" : "is", guild_mgr.GetGuildNameByID(client->GuildID()) ).c_str() ); @@ -536,8 +538,9 @@ void command_guild(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} is a(n) {} of {}.", - client->GetName(), + "{} {} a(n) {} of {}.", + c->GetTargetDescription(client, TargetDescriptionType::UCYou), + c == target ? "are" : "is", guild_mgr.GetRankName(client->GuildID(), client->GuildRank()), guild_mgr.GetGuildNameByID(client->GuildID()) ).c_str() diff --git a/zone/gm_commands/heal.cpp b/zone/gm_commands/heal.cpp index 5a68a7c55..904cf4baf 100755 --- a/zone/gm_commands/heal.cpp +++ b/zone/gm_commands/heal.cpp @@ -13,15 +13,7 @@ void command_heal(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} to full Health ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), target->GetMaxHP() ).c_str() ); diff --git a/zone/gm_commands/instance.cpp b/zone/gm_commands/instance.cpp index f9bd357e3..1777ef652 100755 --- a/zone/gm_commands/instance.cpp +++ b/zone/gm_commands/instance.cpp @@ -100,29 +100,19 @@ void command_instance(Client *c, const Seperator *sep) uint32 zone_id = database.ZoneIDFromInstanceID(instance_id); uint32 version = database.VersionFromInstanceID(instance_id); uint32 current_id = database.GetInstanceID(zone_id, character_id, version); - if (!current_id) { - std::string target_string = ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - character_name, - character_id - ) - ); - + if (!current_id) { c->Message( Chat::White, ( database.AddClientToInstance(instance_id, character_id) ? fmt::format( "Added {} to Instance ID {}.", - target_string, + c->GetTargetDescription(target), instance_id ) : fmt::format( "Failed to add {} to Instance ID {}.", - target_string, + c->GetTargetDescription(target), instance_id ) ).c_str() @@ -297,28 +287,18 @@ void command_instance(Client *c, const Seperator *sep) return; } - std::string target_string = ( - c->CharacterID() == character_id ? - "yourself" : - fmt::format( - "{} ({})", - character_name, - character_id - ) - ); - c->Message( Chat::White, ( database.RemoveClientFromInstance(instance_id, character_id) ? fmt::format( "Removed {} from Instance ID {}.", - target_string, + c->GetTargetDescription(target), instance_id ) : fmt::format( "Failed to remove {} from Instance ID {}.", - target_string, + c->GetTargetDescription(target), instance_id ) ).c_str() diff --git a/zone/gm_commands/invul.cpp b/zone/gm_commands/invul.cpp index a6db1f3c1..18fa2aa6a 100755 --- a/zone/gm_commands/invul.cpp +++ b/zone/gm_commands/invul.cpp @@ -19,7 +19,7 @@ void command_invul(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} {} now {}.", - c == target ? "You" : target->GetCleanName(), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "are" : "is", invul_flag ? "invulnerable" : "vulnerable" ).c_str() diff --git a/zone/gm_commands/lastname.cpp b/zone/gm_commands/lastname.cpp index a990785d9..8dd3c7dd0 100755 --- a/zone/gm_commands/lastname.cpp +++ b/zone/gm_commands/lastname.cpp @@ -20,15 +20,7 @@ void command_lastname(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} now {} a last name of '{}'.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", last_name ).c_str() diff --git a/zone/gm_commands/loc.cpp b/zone/gm_commands/loc.cpp index c45513dc9..48b232498 100755 --- a/zone/gm_commands/loc.cpp +++ b/zone/gm_commands/loc.cpp @@ -13,15 +13,7 @@ void command_loc(Client *c, const Seperator *sep) Chat::White, fmt::format( "Location for {} | XYZ: {:.2f}, {:.2f}, {:.2f} Heading: {:.2f}", - ( - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), target_position.x, target_position.y, target_position.z, diff --git a/zone/gm_commands/mana.cpp b/zone/gm_commands/mana.cpp index dc75a0aa3..8808a568e 100755 --- a/zone/gm_commands/mana.cpp +++ b/zone/gm_commands/mana.cpp @@ -17,15 +17,7 @@ void command_mana(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} to full Mana ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), mana ).c_str() ); diff --git a/zone/gm_commands/memspell.cpp b/zone/gm_commands/memspell.cpp index 673d2efd0..e0fc422a4 100755 --- a/zone/gm_commands/memspell.cpp +++ b/zone/gm_commands/memspell.cpp @@ -33,16 +33,9 @@ void command_memspell(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} not have a place to memorize {} ({}).", - ( - c == target ? - "You do" : - fmt::format( - "{} ({}) does", - target->GetCleanName(), - target->GetID() - ) - ), + "{} {} not have a place to memorize {} ({}).", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "do" : "does", GetSpellName(spell_id), spell_id ).c_str() @@ -68,12 +61,11 @@ void command_memspell(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) memorized to spell gem {} for {} ({}).", + "{} ({}) memorized to spell gem {} for {}.", GetSpellName(spell_id), spell_id, spell_gem, - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/npccast.cpp b/zone/gm_commands/npccast.cpp index 4abef226f..408e5e576 100755 --- a/zone/gm_commands/npccast.cpp +++ b/zone/gm_commands/npccast.cpp @@ -2,93 +2,84 @@ void command_npccast(Client *c, const Seperator *sep) { - if (c->GetTarget() && c->GetTarget()->IsNPC()) { - NPC *target = c->GetTarget()->CastToNPC(); - if (!sep->IsNumber(1) && sep->arg[1] && sep->IsNumber(2)) { - const char *entity_name = sep->arg[1] ? sep->arg[1] : 0; - auto spell_id = sep->arg[2] ? std::stoul(sep->arg[2]) : 0; - Mob *spell_target = entity_list.GetMob(entity_name); - if (spell_target && IsValidSpell(spell_id) && spell_id < SPDAT_RECORDS) { - c->Message( - Chat::White, - fmt::format( - "{} ({}) casting {} ({}) on {} ({}).", - target->GetCleanName(), - target->GetID(), - GetSpellName(static_cast(spell_id)), - spell_id, - spell_target->GetCleanName(), - spell_target->GetID() - ).c_str() - ); - - target->CastSpell(spell_id, spell_target->GetID()); - } - else { - if (!spell_target) { - c->Message( - Chat::White, - fmt::format( - "Entity {} was not found", - entity_name - ).c_str() - ); - } - else if (!spell_id || !IsValidSpell(spell_id)) { - c->Message( - Chat::White, - fmt::format( - "Spell ID {} was not found", - spell_id - ).c_str() - ); - } - } - } - else if (sep->IsNumber(1) && sep->IsNumber(2)) { - uint16 entity_id = sep->arg[1] ? std::stoul(sep->arg[1]) : 0; - auto spell_id = sep->arg[2] ? std::stoul(sep->arg[2]) : 0; - Mob *spell_target = entity_list.GetMob(entity_id); - if (spell_target && IsValidSpell(spell_id) && spell_id < SPDAT_RECORDS) { - c->Message( - Chat::White, - fmt::format( - "{} ({}) casting {} ({}) on {} ({}).", - target->GetCleanName(), - target->GetID(), - GetSpellName(static_cast(spell_id)), - spell_id, - spell_target->GetCleanName(), - spell_target->GetID() - ).c_str() - ); - - target->CastSpell(spell_id, spell_target->GetID()); - } - else { - if (!spell_target) { - c->Message( - Chat::White, - fmt::format( - "Entity ID {} was not found", - entity_id - ).c_str() - ); - } - else if (!spell_id || !IsValidSpell(spell_id)) { - c->Message( - Chat::White, - fmt::format( - "Spell ID {} was not found", - spell_id - ).c_str() - ); - } - } - } - } - else { + if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { c->Message(Chat::White, "You must target an NPC to use this command."); + return; + } + + auto target = c->GetTarget()->CastToNPC(); + if (!sep->IsNumber(1) && sep->arg[1] && sep->IsNumber(2)) { + std::string entity_name = sep->arg[1] ? sep->arg[1] : 0; + auto spell_id = sep->arg[2] ? std::stoul(sep->arg[2]) : 0; + auto spell_target = entity_list.GetMob(entity_name.c_str()); + if (spell_target && IsValidSpell(spell_id) && spell_id < SPDAT_RECORDS) { + c->Message( + Chat::White, + fmt::format( + "{} casting {} ({}) on {}.", + c->GetTargetDescription(target), + GetSpellName(static_cast(spell_id)), + spell_id, + c->GetTargetDescription(spell_target) + ).c_str() + ); + + target->CastSpell(spell_id, spell_target->GetID()); + } else { + if (!spell_target) { + c->Message( + Chat::White, + fmt::format( + "Entity {} was not found", + entity_name + ).c_str() + ); + } else if (!spell_id || !IsValidSpell(spell_id)) { + c->Message( + Chat::White, + fmt::format( + "Spell ID {} was not found", + spell_id + ).c_str() + ); + } + } + } else if (sep->IsNumber(1) && sep->IsNumber(2)) { + uint16 entity_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = std::stoul(sep->arg[2]); + auto spell_target = entity_list.GetMob(entity_id); + if (spell_target && IsValidSpell(spell_id) && spell_id < SPDAT_RECORDS) { + c->Message( + Chat::White, + fmt::format( + "{} casting {} ({}) on {}.", + c->GetTargetDescription(target), + GetSpellName(static_cast(spell_id)), + spell_id, + c->GetTargetDescription(spell_target) + ).c_str() + ); + + target->CastSpell(spell_id, spell_target->GetID()); + } else { + if (!spell_target) { + c->Message( + Chat::White, + fmt::format( + "Entity ID {} was not found", + entity_id + ).c_str() + ); + } else if (!spell_id || !IsValidSpell(spell_id)) { + c->Message( + Chat::White, + fmt::format( + "Spell ID {} was not found", + spell_id + ).c_str() + ); + } + } } } diff --git a/zone/gm_commands/npcloot.cpp b/zone/gm_commands/npcloot.cpp index 9f95f56ff..30ff7da4a 100755 --- a/zone/gm_commands/npcloot.cpp +++ b/zone/gm_commands/npcloot.cpp @@ -65,7 +65,9 @@ void command_npcloot(Client *c, const Seperator *sep) return; } - c->GetTarget()->CastToNPC()->AddItem( + auto target = c->GetTarget(); + + target->CastToNPC()->AddItem( item_id, item_charges, equip_item, @@ -97,11 +99,10 @@ void command_npcloot(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Added {} ({}) to {} ({}).", + "Added {} ({}) to {}.", item_link, item_id, - c->GetTarget()->GetCleanName(), - c->GetTarget()->GetID() + c->GetTargetDescription(target) ).c_str() ); } else if (is_money) { @@ -143,9 +144,8 @@ void command_npcloot(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) now has {}.", - target->GetCleanName(), - target->GetID(), + "{} now has {}.", + c->GetTargetDescription(target), money_string ).c_str() ); @@ -172,12 +172,11 @@ void command_npcloot(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Removed {} {} ({}) from {} ({}).", + "Removed {} {} ({}) from {}.", item_count, database.CreateItemLink(item_id), item_id, - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); @@ -188,20 +187,18 @@ void command_npcloot(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) has no items to remove.", - target->GetCleanName(), - target->GetID() + "{} has no items to remove.", + c->GetTargetDescription(target) ).c_str() ); } else { c->Message( Chat::White, fmt::format( - "{} Item{} removed from {} ({}).", + "{} Item{} removed from {}.", total_item_count, total_item_count != 1 ? "s" : "", - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } @@ -214,21 +211,19 @@ void command_npcloot(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Removed {} {} ({}) from {} ({}).", + "Removed {} {} ({}) from {}.", item_count, database.CreateItemLink(item_id), item_id, - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } else { c->Message( Chat::White, fmt::format( - "{} ({}) does not have any {} ({}).", - target->GetCleanName(), - target->GetID(), + "{} does not have any {} ({}).", + c->GetTargetDescription(target), database.CreateItemLink(item_id), item_id ).c_str() diff --git a/zone/gm_commands/npcspawn.cpp b/zone/gm_commands/npcspawn.cpp index dd88bbece..a6ea88899 100755 --- a/zone/gm_commands/npcspawn.cpp +++ b/zone/gm_commands/npcspawn.cpp @@ -2,26 +2,31 @@ void command_npcspawn(Client *c, const Seperator *sep) { + if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { + c->Message(Chat::White, "You must target an NPC to use this command."); + return; + } + int arguments = sep->argnum; if (!arguments) { c->Message(Chat::White, "Command Syntax: #npcspawn [Add|Create|Delete|Remove|Update]"); return; } - if (!(c->GetTarget() && c->GetTarget()->IsNPC())) { - c->Message(Chat::White, "You must target an NPC to use this command."); - return; - } - - NPC *target = c->GetTarget()->CastToNPC(); - std::string spawn_type = str_tolower(sep->arg[1]); - uint32 extra = 0; - bool is_add = spawn_type.find("add") != std::string::npos; - bool is_create = spawn_type.find("create") != std::string::npos; - bool is_delete = spawn_type.find("delete") != std::string::npos; - bool is_remove = spawn_type.find("remove") != std::string::npos; - bool is_update = spawn_type.find("update") != std::string::npos; - if (!is_add && !is_create && !is_delete && !is_remove && !is_update) { + auto target = c->GetTarget()->CastToNPC(); + uint32 extra = 0; + bool is_add = !strcasecmp(sep->arg[1], "add"); + bool is_create = !strcasecmp(sep->arg[1], "create"); + bool is_delete = !strcasecmp(sep->arg[1], "delete"); + bool is_remove = !strcasecmp(sep->arg[1], "remove"); + bool is_update = !strcasecmp(sep->arg[1], "update"); + if ( + !is_add && + !is_create && + !is_delete && + !is_remove && + !is_update + ) { c->Message(Chat::White, "Command Syntax: #npcspawn [Add|Create|Delete|Remove|Update]"); return; } @@ -29,16 +34,17 @@ void command_npcspawn(Client *c, const Seperator *sep) if (is_add || is_create) { extra = ( sep->IsNumber(2) ? - ( - is_add ? - std::stoi(sep->arg[2]) : - 1 - ) : ( + ( is_add ? - 1200 : - 0 + std::stoi(sep->arg[2]) : + 1 + ) : ( + is_add ? + 1200 : + 0 ) ); // Default to 1200 for Add, 0 for Create if not set + content_db.NPCSpawnDB( is_add ? NPCSpawnTypes::AddNewSpawngroup : NPCSpawnTypes::CreateNewSpawn, zone->GetShortName(), @@ -47,35 +53,37 @@ void command_npcspawn(Client *c, const Seperator *sep) target, extra ); + c->Message( Chat::White, fmt::format( - "Spawn {} | Name: {} ({})", + "Spawn {} | Name: {}", is_add ? "Added" : "Created", - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } else if (is_delete || is_remove || is_update) { - uint8 spawn_update_type = ( + uint8 spawn_update_type = ( is_delete ? - NPCSpawnTypes::DeleteSpawn : - ( - is_remove ? - NPCSpawnTypes::RemoveSpawn : - NPCSpawnTypes::UpdateAppearance - ) + NPCSpawnTypes::DeleteSpawn : + ( + is_remove ? + NPCSpawnTypes::RemoveSpawn : + NPCSpawnTypes::UpdateAppearance + ) ); - std::string spawn_message = ( + + std::string spawn_message = ( is_delete ? - "Deleted" : - ( - is_remove ? - "Removed" : - "Updated" - ) + "Deleted" : + ( + is_remove ? + "Removed" : + "Updated" + ) ); + content_db.NPCSpawnDB( spawn_update_type, zone->GetShortName(), @@ -83,13 +91,13 @@ void command_npcspawn(Client *c, const Seperator *sep) c, target ); + c->Message( Chat::White, fmt::format( - "Spawn {} | Name: {} ({})", + "Spawn {} | Name: {}", spawn_message, - target->GetCleanName(), - target->GetID() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/nukebuffs.cpp b/zone/gm_commands/nukebuffs.cpp index bb6542ea0..c28504755 100755 --- a/zone/gm_commands/nukebuffs.cpp +++ b/zone/gm_commands/nukebuffs.cpp @@ -32,15 +32,7 @@ void command_nukebuffs(Client *c, const Seperator *sep) fmt::format( "Faded all{} buffs for {}.", buff_type, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/nukeitem.cpp b/zone/gm_commands/nukeitem.cpp index 1856b9b1f..d31cba7aa 100755 --- a/zone/gm_commands/nukeitem.cpp +++ b/zone/gm_commands/nukeitem.cpp @@ -23,15 +23,7 @@ void command_nukeitem(Client *c, const Seperator *sep) deleted_count, database.CreateItemLink(item_id), item_id, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } else { @@ -41,15 +33,7 @@ void command_nukeitem(Client *c, const Seperator *sep) "Could not find any {} ({}) to delete from {}.", database.CreateItemLink(item_id), item_id, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/peqzone.cpp b/zone/gm_commands/peqzone.cpp index 1632087fc..9dfb31651 100755 --- a/zone/gm_commands/peqzone.cpp +++ b/zone/gm_commands/peqzone.cpp @@ -95,9 +95,8 @@ void command_peqzone(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "You are already in {} ({}).", - zone->GetLongName(), - zone->GetShortName() + "You are already in {}.", + zone->GetZoneDescription() ).c_str() ); return; diff --git a/zone/gm_commands/permaclass.cpp b/zone/gm_commands/permaclass.cpp index 3aa72c97a..648c61169 100755 --- a/zone/gm_commands/permaclass.cpp +++ b/zone/gm_commands/permaclass.cpp @@ -17,7 +17,7 @@ void command_permaclass(Client *c, const Seperator *sep) LogInfo("Class changed by {} for {} to {} ({})", c->GetCleanName(), - target->GetCleanName(), + c->GetTargetDescription(target), GetClassIDName(class_id), class_id ); @@ -31,7 +31,7 @@ void command_permaclass(Client *c, const Seperator *sep) Chat::White, fmt::format( "Class changed for {} to {} ({}).", - target->GetCleanName(), + c->GetTargetDescription(target), GetClassIDName(class_id), class_id ).c_str() diff --git a/zone/gm_commands/permagender.cpp b/zone/gm_commands/permagender.cpp index bdfd33013..f4f2f16f3 100755 --- a/zone/gm_commands/permagender.cpp +++ b/zone/gm_commands/permagender.cpp @@ -23,7 +23,7 @@ void command_permagender(Client *c, const Seperator *sep) LogInfo("Gender changed by {} for {} to {} ({})", c->GetCleanName(), - target->GetCleanName(), + c->GetTargetDescription(target), GetGenderName(gender_id), gender_id ); @@ -36,15 +36,7 @@ void command_permagender(Client *c, const Seperator *sep) Chat::White, fmt::format( "Gender changed for {} to {} ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), GetGenderName(gender_id), gender_id ).c_str() diff --git a/zone/gm_commands/permarace.cpp b/zone/gm_commands/permarace.cpp index bee8e6dc2..b84157f3b 100755 --- a/zone/gm_commands/permarace.cpp +++ b/zone/gm_commands/permarace.cpp @@ -22,7 +22,7 @@ void command_permarace(Client *c, const Seperator *sep) LogInfo("Race changed by {} for {} to {} ({})", c->GetCleanName(), - target->GetCleanName(), + c->GetTargetDescription(target), GetRaceIDName(race_id), race_id ); @@ -36,15 +36,7 @@ void command_permarace(Client *c, const Seperator *sep) Chat::White, fmt::format( "Race changed for {} to {} ({}).", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), GetRaceIDName(race_id), race_id ).c_str() diff --git a/zone/gm_commands/push.cpp b/zone/gm_commands/push.cpp index a964c6bcf..7d693cff1 100755 --- a/zone/gm_commands/push.cpp +++ b/zone/gm_commands/push.cpp @@ -27,9 +27,8 @@ void command_push(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Pushing {} ({}) with a push back of {:.2f} and a push up of {:.2f}.", - target->GetCleanName(), - target->GetID(), + "Pushing {} with a push back of {:.2f} and a push up of {:.2f}.", + c->GetTargetDescription(target), back, up ).c_str() diff --git a/zone/gm_commands/pvp.cpp b/zone/gm_commands/pvp.cpp index 5ba3d092a..ed9992b10 100755 --- a/zone/gm_commands/pvp.cpp +++ b/zone/gm_commands/pvp.cpp @@ -19,8 +19,9 @@ void command_pvp(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} now follows the ways of {}.", - target->GetCleanName(), + "{} now follow{} the ways of {}.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c != target ? "s" : "", pvp_state ? "Discord" : "Order" ).c_str() ); diff --git a/zone/gm_commands/qglobal.cpp b/zone/gm_commands/qglobal.cpp index 2771ebf7a..301ef4a84 100755 --- a/zone/gm_commands/qglobal.cpp +++ b/zone/gm_commands/qglobal.cpp @@ -43,9 +43,8 @@ void command_qglobal(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Failed to disable quest global flag for {} ({}).", - target->GetCleanName(), - target->GetID() + "Failed to disable quest global flag for {}.", + c->GetTargetDescription(target) ).c_str() ); return; @@ -60,9 +59,8 @@ void command_qglobal(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) will no longer be able to view quest globals, {} them to apply this change.", - target->GetCleanName(), - target->GetID(), + "{} will no longer be able to view quest globals, {} them to apply this change.", + c->GetTargetDescription(target), repop_link ).c_str() ); @@ -78,9 +76,8 @@ void command_qglobal(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Failed to enable quest global flag for {} ({}).", - target->GetCleanName(), - target->GetID() + "Failed to enable quest global flag for {}.", + c->GetTargetDescription(target) ).c_str() ); return; @@ -95,9 +92,8 @@ void command_qglobal(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) will now be able to view quest globals, {} them to apply this change.", - target->GetCleanName(), - target->GetID(), + "{} will now be able to view quest globals, {} them to apply this change.", + c->GetTargetDescription(target), repop_link ).c_str() ); @@ -118,9 +114,8 @@ void command_qglobal(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) {} view quest globals.", - target->GetCleanName(), - target->GetID(), + "{} {} view quest globals.", + c->GetTargetDescription(target), npc_type->qglobal ? "can" : "cannot" ).c_str() ); diff --git a/zone/gm_commands/randomfeatures.cpp b/zone/gm_commands/randomfeatures.cpp index 87c9b41fb..64a8bcda3 100755 --- a/zone/gm_commands/randomfeatures.cpp +++ b/zone/gm_commands/randomfeatures.cpp @@ -13,18 +13,20 @@ void command_randomfeatures(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) has had their features randomized.", - target->GetCleanName(), - target->GetID() + "{} {} had {} features randomized.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "have" : "had", + c == target ? "your" : "their" ).c_str() ); } else { c->Message( Chat::White, fmt::format( - "{} ({}) is not a player race, their race is {} ({}).", - target->GetCleanName(), - target->GetID(), + "{} {} not a player race, {} race is {} ({}).", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "are" : "is", + c == target ? "your" : "their", GetRaceIDName(target->GetRace()), target->GetRace() ).c_str() diff --git a/zone/gm_commands/refreshgroup.cpp b/zone/gm_commands/refreshgroup.cpp index d4ed1dedb..e78a2d2cd 100755 --- a/zone/gm_commands/refreshgroup.cpp +++ b/zone/gm_commands/refreshgroup.cpp @@ -14,16 +14,9 @@ void command_refreshgroup(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} not in a group.", - ( - c == target ? - "You are" : - fmt::format( - "{} ({}} is", - target->GetCleanName(), - target->GetID() - ) - ) + "{} {} not in a group.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "are" : "is" ).c_str() ); return; @@ -35,15 +28,7 @@ void command_refreshgroup(Client *c, const Seperator *sep) Chat::White, fmt::format( "Group has been refreshed for {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); diff --git a/zone/gm_commands/reloadzps.cpp b/zone/gm_commands/reloadzps.cpp index 353499d88..b7929e26c 100755 --- a/zone/gm_commands/reloadzps.cpp +++ b/zone/gm_commands/reloadzps.cpp @@ -2,7 +2,9 @@ void command_reloadzps(Client *c, const Seperator *sep) { - content_db.LoadStaticZonePoints(&zone->zone_point_list, zone->GetShortName(), zone->GetInstanceVersion()); - c->Message(Chat::White, "Reloading server zone_points."); + c->Message(Chat::White, "Attempting to reloading server zone points globally."); + auto pack = new ServerPacket(ServerOP_ReloadZonePoints, 0); + worldserver.SendPacket(pack); + safe_delete(pack); } diff --git a/zone/gm_commands/removeitem.cpp b/zone/gm_commands/removeitem.cpp index 6285e65d4..44ad46d84 100644 --- a/zone/gm_commands/removeitem.cpp +++ b/zone/gm_commands/removeitem.cpp @@ -12,16 +12,6 @@ void command_removeitem(Client *c, const Seperator *sep) if (c->GetTarget() && c->GetTarget()->IsClient()) { target = c->GetTarget()->CastToClient(); } - - auto target_string = ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ); auto item_id = std::stoi(sep->arg[1]); if (!database.GetItem(item_id)) { @@ -49,7 +39,7 @@ void command_removeitem(Client *c, const Seperator *sep) amount, item_link, item_id, - target_string + c->GetTargetDescription(target) ).c_str() ); } else { @@ -62,7 +52,7 @@ void command_removeitem(Client *c, const Seperator *sep) item_count, item_link, item_id, - target_string, + c->GetTargetDescription(target), c == target ? "you" : "they", amount, item_link, @@ -77,7 +67,7 @@ void command_removeitem(Client *c, const Seperator *sep) "Could not find any {} ({}) to delete from {}.", database.CreateItemLink(item_id), item_id, - target_string + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/resetaa.cpp b/zone/gm_commands/resetaa.cpp index f645ec713..c0a9a075d 100755 --- a/zone/gm_commands/resetaa.cpp +++ b/zone/gm_commands/resetaa.cpp @@ -14,15 +14,7 @@ void command_resetaa(Client *c, const Seperator *sep) Chat::White, fmt::format( "Successfully reset all Alternate Advancements for {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/resetaa_timer.cpp b/zone/gm_commands/resetaa_timer.cpp index 5809436bf..bb108c6c4 100755 --- a/zone/gm_commands/resetaa_timer.cpp +++ b/zone/gm_commands/resetaa_timer.cpp @@ -21,15 +21,7 @@ void command_resetaa_timer(Client *c, const Seperator *sep) Chat::White, fmt::format( "Reset all Alternate Advancement timers for {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); target->ResetAlternateAdvancementTimers(); @@ -43,15 +35,7 @@ void command_resetaa_timer(Client *c, const Seperator *sep) fmt::format( "Reset Alternate Advancement timer {} for {}.", timer_id, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); target->ResetAlternateAdvancementTimer(timer_id); diff --git a/zone/gm_commands/resetdisc_timer.cpp b/zone/gm_commands/resetdisc_timer.cpp index cf1fb0f57..305ae5c3a 100755 --- a/zone/gm_commands/resetdisc_timer.cpp +++ b/zone/gm_commands/resetdisc_timer.cpp @@ -21,15 +21,7 @@ void command_resetdisc_timer(Client *c, const Seperator *sep) Chat::White, fmt::format( "Reset all Discipline timers for {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); target->ResetAllDisciplineTimers(); @@ -43,15 +35,7 @@ void command_resetdisc_timer(Client *c, const Seperator *sep) fmt::format( "Reset Discipline timer {} for {}.", timer_id, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); target->ResetDisciplineTimer(timer_id); diff --git a/zone/gm_commands/revoke.cpp b/zone/gm_commands/revoke.cpp index 5ef959f06..50eba21a2 100755 --- a/zone/gm_commands/revoke.cpp +++ b/zone/gm_commands/revoke.cpp @@ -49,9 +49,8 @@ void command_revoke(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Found {} ({}) in this zone.", - revoke_client->GetName(), - revoke_client->GetID() + "Found {} in this zone.", + c->GetTargetDescription(revoke_client) ).c_str() ); revoke_client->SetRevoked(revoked); diff --git a/zone/gm_commands/roambox.cpp b/zone/gm_commands/roambox.cpp index 8daa0067d..e3056c223 100755 --- a/zone/gm_commands/roambox.cpp +++ b/zone/gm_commands/roambox.cpp @@ -77,9 +77,8 @@ void command_roambox(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Failed to set roambox for {} ({}).", - target->GetCleanName(), - target->GetID() + "Failed to set roambox for {}.", + c->GetTargetDescription(target) ).c_str() ); return; @@ -88,10 +87,9 @@ void command_roambox(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Roambox set to box size of {} for {} ({}) on spawn group ID {} with a delay of {} ({}).", + "Roambox set to box size of {} for {} on spawn group ID {} with a delay of {} ({}).", box_size, - target->GetCleanName(), - target->GetID(), + c->GetTargetDescription(target), spawn_group_id, ConvertMillisecondsToTime(delay), delay diff --git a/zone/gm_commands/save.cpp b/zone/gm_commands/save.cpp index ed2c1fd3b..54d248dfc 100755 --- a/zone/gm_commands/save.cpp +++ b/zone/gm_commands/save.cpp @@ -15,24 +15,25 @@ void command_save(Client *c, const Seperator *sep) return; } - if (c->GetTarget()->IsClient()) { + auto target = c->GetTarget(); + + if (target->IsClient()) { c->Message( Chat::White, fmt::format( - "{} ({}) {} saved.", - c->GetTarget()->GetCleanName(), - c->GetTarget()->GetID(), - c->GetTarget()->CastToClient()->Save(2) ? "successfully" : "failed to be" + "{} {} been {} saved.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "have" : "has", + target->CastToClient()->Save(2) ? "successfully" : "failed to be" ).c_str() ); - } else if (c->GetTarget()->IsPlayerCorpse()) { + } else if (target->IsPlayerCorpse()) { c->Message( Chat::White, fmt::format( - "{} ({}) {} saved.", - c->GetTarget()->GetCleanName(), - c->GetTarget()->CastToCorpse()->GetCorpseDBID(), - c->GetTarget()->CastToMob()->Save() ? "successfully" : "failed to be" + "{} has been {} saved.", + c->GetTargetDescription(target), + target->CastToMob()->Save() ? "successfully" : "failed to be" ).c_str() ); } diff --git a/zone/gm_commands/scribespells.cpp b/zone/gm_commands/scribespells.cpp index 2d084d9df..89ba25f93 100755 --- a/zone/gm_commands/scribespells.cpp +++ b/zone/gm_commands/scribespells.cpp @@ -8,7 +8,7 @@ void command_scribespells(Client *c, const Seperator *sep) } if (sep->argnum < 1 || !sep->IsNumber(1)) { - c->Message(Chat::White, "FORMAT: #scribespells "); + c->Message(Chat::White, "Usage: #scribespells [Max Level] [Min Level]"); return; } @@ -31,12 +31,12 @@ void command_scribespells(Client *c, const Seperator *sep) } if (max_level < 1 || min_level < 1) { - c->Message(Chat::White, "ERROR: Level must be greater than or equal to 1."); + c->Message(Chat::White, "Level must be greater than or equal to 1."); return; } if (min_level > max_level) { - c->Message(Chat::White, "ERROR: Minimum Level must be less than or equal to Maximum Level."); + c->Message(Chat::White, "Minimum Level must be less than or equal to Maximum Level."); return; } @@ -59,7 +59,7 @@ void command_scribespells(Client *c, const Seperator *sep) fmt::format( "{} scribed for {}.", spell_message, - target->GetCleanName() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/sensetrap.cpp b/zone/gm_commands/sensetrap.cpp index 03363c06f..0bfaa441f 100755 --- a/zone/gm_commands/sensetrap.cpp +++ b/zone/gm_commands/sensetrap.cpp @@ -18,9 +18,8 @@ void command_sensetrap(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) is too far away.", - target->GetCleanName(), - target->GetID() + "{} is too far away.", + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/set_adventure_points.cpp b/zone/gm_commands/set_adventure_points.cpp index fff6eec9a..8518f2aa8 100755 --- a/zone/gm_commands/set_adventure_points.cpp +++ b/zone/gm_commands/set_adventure_points.cpp @@ -68,15 +68,7 @@ void command_set_adventure_points(Client *c, const Seperator *sep) EQ::constants::GetLDoNThemeName(theme_id) ) ), - ( - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); diff --git a/zone/gm_commands/setaapts.cpp b/zone/gm_commands/setaapts.cpp index cb5e9f3f0..f47745a4a 100755 --- a/zone/gm_commands/setaapts.cpp +++ b/zone/gm_commands/setaapts.cpp @@ -48,15 +48,7 @@ void command_setaapts(Client *c, const Seperator *sep) std::string aa_message = fmt::format( "{} now {} {} {}AA Point{}.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", aa_points, group_raid_string, diff --git a/zone/gm_commands/setaaxp.cpp b/zone/gm_commands/setaaxp.cpp index 081a7d1d6..57b57cf76 100755 --- a/zone/gm_commands/setaaxp.cpp +++ b/zone/gm_commands/setaaxp.cpp @@ -54,15 +54,7 @@ void command_setaaxp(Client *c, const Seperator *sep) std::string aa_exp_message = fmt::format( "{} now {} {} {}AA Experience.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", aa_experience, group_raid_string diff --git a/zone/gm_commands/setaltcurrency.cpp b/zone/gm_commands/setaltcurrency.cpp index 339542d6e..d484ee3b1 100644 --- a/zone/gm_commands/setaltcurrency.cpp +++ b/zone/gm_commands/setaltcurrency.cpp @@ -37,15 +37,7 @@ void command_setaltcurrency(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} now {} {} {}.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", ( amount ? diff --git a/zone/gm_commands/setanim.cpp b/zone/gm_commands/setanim.cpp index 63b925166..b6deeec01 100755 --- a/zone/gm_commands/setanim.cpp +++ b/zone/gm_commands/setanim.cpp @@ -43,15 +43,7 @@ void command_setanim(Client *c, const Seperator *sep) "Set animation to {} ({}) for {}.", animation_name, animation_id, - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ).c_str() - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/setcrystals.cpp b/zone/gm_commands/setcrystals.cpp index 4f7f1f14f..fd3306acd 100755 --- a/zone/gm_commands/setcrystals.cpp +++ b/zone/gm_commands/setcrystals.cpp @@ -42,15 +42,7 @@ void command_setcrystals(Client *c, const Seperator *sep) Chat::White, fmt::format( "{} now {} {} {}.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", crystal_amount, crystal_link diff --git a/zone/gm_commands/setendurance.cpp b/zone/gm_commands/setendurance.cpp index a6c42f8ea..920b30829 100644 --- a/zone/gm_commands/setendurance.cpp +++ b/zone/gm_commands/setendurance.cpp @@ -35,15 +35,7 @@ void command_setendurance(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} to {} Endurance{}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ( set_to_max ? "full" : diff --git a/zone/gm_commands/sethp.cpp b/zone/gm_commands/sethp.cpp index c9c73c96f..e3efbc955 100644 --- a/zone/gm_commands/sethp.cpp +++ b/zone/gm_commands/sethp.cpp @@ -27,15 +27,7 @@ void command_sethp(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} to {} Health{}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ( set_to_max ? "full" : diff --git a/zone/gm_commands/setlanguage.cpp b/zone/gm_commands/setlanguage.cpp index 50353f150..f3242c1e9 100755 --- a/zone/gm_commands/setlanguage.cpp +++ b/zone/gm_commands/setlanguage.cpp @@ -37,7 +37,7 @@ void command_setlanguage(Client *c, const Seperator *sep) LogInfo( "Set language request from [{}], Target: [{}] Language ID: [{}] Language Value: [{}]", c->GetCleanName(), - target->GetCleanName(), + c->GetTargetDescription(target), language_id, language_value ); @@ -52,7 +52,7 @@ void command_setlanguage(Client *c, const Seperator *sep) EQ::constants::GetLanguageName(language_id), language_id, language_value, - target->GetCleanName() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/setmana.cpp b/zone/gm_commands/setmana.cpp index 505e85afe..3b1c1132b 100644 --- a/zone/gm_commands/setmana.cpp +++ b/zone/gm_commands/setmana.cpp @@ -35,15 +35,7 @@ void command_setmana(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} to {} Mana{}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ( set_to_max ? "full" : diff --git a/zone/gm_commands/setpvppoints.cpp b/zone/gm_commands/setpvppoints.cpp index d124cb6eb..b6d3a0598 100755 --- a/zone/gm_commands/setpvppoints.cpp +++ b/zone/gm_commands/setpvppoints.cpp @@ -19,15 +19,7 @@ void command_setpvppoints(Client *c, const Seperator *sep) target->SendPVPStats(); std::string pvp_message = fmt::format( "{} now {} {} PVP Point{}.", - ( - c == target ? - "You" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCYou), c == target ? "have" : "has", pvp_points, pvp_points != 1 ? "s" : "" diff --git a/zone/gm_commands/setskill.cpp b/zone/gm_commands/setskill.cpp index 625d54e0e..fd6cacaa5 100755 --- a/zone/gm_commands/setskill.cpp +++ b/zone/gm_commands/setskill.cpp @@ -23,7 +23,7 @@ void command_setskill(Client *c, const Seperator *sep) LogInfo( "Set skill request from [{}], Target: [{}] Skill ID: [{}] Skill Value: [{}]", c->GetCleanName(), - target->GetCleanName(), + c->GetTargetDescription(target), skill_id, skill_value ); @@ -45,7 +45,7 @@ void command_setskill(Client *c, const Seperator *sep) EQ::skills::GetSkillName((EQ::skills::SkillType) skill_id), skill_id, skill_value, - target->GetCleanName() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/setskillall.cpp b/zone/gm_commands/setskillall.cpp index 8cc853814..f9ec1e3e4 100755 --- a/zone/gm_commands/setskillall.cpp +++ b/zone/gm_commands/setskillall.cpp @@ -21,7 +21,7 @@ void command_setskillall(Client *c, const Seperator *sep) LogInfo( "Set ALL skill request from [{}], target:[{}]", c->GetCleanName(), - target->GetCleanName() + c->GetTargetDescription(target) ); auto skill_level = static_cast(std::stoul(sep->arg[1])); @@ -31,13 +31,7 @@ void command_setskillall(Client *c, const Seperator *sep) fmt::format( "Setting all skills to {} for {}.", skill_level, - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target) ).c_str() ); diff --git a/zone/gm_commands/setstartzone.cpp b/zone/gm_commands/setstartzone.cpp index cf946041d..16e66bb6e 100755 --- a/zone/gm_commands/setstartzone.cpp +++ b/zone/gm_commands/setstartzone.cpp @@ -35,15 +35,7 @@ void command_setstartzone(Client *c, const Seperator *sep) fmt::format( "Start Zone {} for {} |{}", is_reset ? "Reset" : "Changed", - ( - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), ( zone_id ? fmt::format( diff --git a/zone/gm_commands/showskills.cpp b/zone/gm_commands/showskills.cpp index 8dc4dc47a..68c1c92e3 100755 --- a/zone/gm_commands/showskills.cpp +++ b/zone/gm_commands/showskills.cpp @@ -46,13 +46,7 @@ void command_showskills(Client *c, const Seperator *sep) std::string popup_title = fmt::format( "Skills for {} [{} to {}]", - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ), + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), start_skill_id, max_skill_id ); @@ -71,13 +65,7 @@ void command_showskills(Client *c, const Seperator *sep) start_skill_id, EQ::skills::GetSkillName((EQ::skills::SkillType) max_skill_id), max_skill_id, - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target) ).c_str() ); diff --git a/zone/gm_commands/stun.cpp b/zone/gm_commands/stun.cpp index 53bfad8cc..cf8cd8a97 100755 --- a/zone/gm_commands/stun.cpp +++ b/zone/gm_commands/stun.cpp @@ -30,28 +30,12 @@ void command_stun(Client *c, const Seperator *sep) duration ? fmt::format( "You stunned {} for {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ConvertMillisecondsToTime(duration) ) : fmt::format( "You unstunned {}.", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ) + c->GetTargetDescription(target) ) ); c->Message( diff --git a/zone/gm_commands/summon.cpp b/zone/gm_commands/summon.cpp index eb496c2ab..6a4c568d8 100755 --- a/zone/gm_commands/summon.cpp +++ b/zone/gm_commands/summon.cpp @@ -67,9 +67,8 @@ void command_summon(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Summoning {} ({}) to {:.2f}, {:.2f}, {:.2f} in {} ({}).", - target->GetCleanName(), - target->GetID(), + "Summoning {} to {:.2f}, {:.2f}, {:.2f} in {} ({}).", + c->GetTargetDescription(target), c->GetX(), c->GetY(), c->GetZ(), diff --git a/zone/gm_commands/summonburiedplayercorpse.cpp b/zone/gm_commands/summonburiedplayercorpse.cpp index f82717740..6ed7b4a25 100755 --- a/zone/gm_commands/summonburiedplayercorpse.cpp +++ b/zone/gm_commands/summonburiedplayercorpse.cpp @@ -19,16 +19,9 @@ void command_summonburiedplayercorpse(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} not have any buried corpses.", - ( - c == target ? - "You do" : - fmt::format( - "{} ({}) does", - target->GetCleanName(), - target->GetID() - ) - ) + "{} {} not have any buried corpses.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "do" : "does" ).c_str() ); } diff --git a/zone/gm_commands/task.cpp b/zone/gm_commands/task.cpp index ce6e15579..9f6077fca 100755 --- a/zone/gm_commands/task.cpp +++ b/zone/gm_commands/task.cpp @@ -80,9 +80,9 @@ void command_task(Client *c, const Seperator *sep) return; } - Client *client_target = c; + Client *target = c; if (c->GetTarget() && c->GetTarget()->IsClient()) { - client_target = c->GetTarget()->CastToClient(); + target = c->GetTarget()->CastToClient(); } bool is_assign = !strcasecmp(sep->arg[1], "assign"); @@ -177,21 +177,13 @@ void command_task(Client *c, const Seperator *sep) if (is_assign) { auto task_id = std::stoul(sep->arg[2]); if (task_id && task_id < MAXTASKS) { - client_target->AssignTask(task_id, 0, false); + target->AssignTask(task_id, 0, false); c->Message( Chat::Yellow, fmt::format( "Assigned task ID {} to {}.", task_id, - ( - client_target == c ? - "yourself" : - fmt::format( - "{} ({})", - client_target->GetCleanName(), - client_target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); } @@ -201,23 +193,15 @@ void command_task(Client *c, const Seperator *sep) Chat::Yellow, fmt::format( "Task timers have been purged for {}.", - ( - client_target == c ? - "yourself" : - fmt::format( - "{} ({})", - client_target->GetCleanName(), - client_target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); - if (client_target != c) { - client_target->Message(Chat::Yellow, "Your task timers have been purged by a GM."); + if (c != target) { + target->Message(Chat::Yellow, "Your task timers have been purged by a GM."); } - client_target->PurgeTaskTimers(); + target->PurgeTaskTimers(); return; } else if (is_reload) { if (arguments >= 2) { @@ -282,62 +266,45 @@ void command_task(Client *c, const Seperator *sep) return; } else if (is_show) { - c->ShowClientTasks(client_target); + target->ShowClientTasks(c); return; } else if (is_uncomplete) { if (sep->IsNumber(2)) { auto task_id = std::stoul(sep->arg[2]); - if (task_id && task_id < MAXTASKS) { - if ( - CompletedTasksRepository::DeleteWhere( - database, - fmt::format( - "charid = {} AND taskid = {}", - client_target->CharacterID(), - task_id - ) - ) - ) { - c->Message( - Chat::Yellow, - fmt::format( - "Successfully uncompleted task ID {} for {}.", - task_id, - ( - client_target == c ? - "yourself" : - fmt::format( - "{} ({})", - client_target->GetCleanName(), - client_target->GetID() - ) - ) - ).c_str() - ); - return; - } else { - c->Message( - Chat::Yellow, - fmt::format( - "{} not completed task ID {}.", - ( - client_target == c ? - "You have" : - fmt::format( - "{} ({}) has", - client_target->GetCleanName(), - client_target->GetID() - ) - ), - task_id - ).c_str() - ); - return; - } - } else { + if (!task_id || task_id > MAXTASKS) { c->Message(Chat::White, "Invalid task ID specified."); return; } + + if ( + CompletedTasksRepository::DeleteWhere( + database, + fmt::format( + "charid = {} AND taskid = {}", + target->CharacterID(), + task_id + ) + ) + ) { + c->Message( + Chat::Yellow, + fmt::format( + "Successfully uncompleted task ID {} for {}.", + task_id, + c->GetTargetDescription(target) + ).c_str() + ); + } else { + c->Message( + Chat::Yellow, + fmt::format( + "{} {} not completed task ID {}.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "have" : "has", + task_id + ).c_str() + ); + } } } else if (is_update) { if (arguments >= 3) { @@ -359,21 +326,12 @@ void command_task(Client *c, const Seperator *sep) task_id, activity_id, count, - ( - client_target == c ? - "yourself" : - fmt::format( - "{} ({})", - client_target->GetCleanName(), - client_target->GetID() - ) - ) + c->GetTargetDescription(target) ).c_str() ); - client_target->UpdateTaskActivity(task_id, activity_id, count); - c->ShowClientTasks(client_target); + target->UpdateTaskActivity(task_id, activity_id, count); + target->ShowClientTasks(c); } - return; } } diff --git a/zone/gm_commands/texture.cpp b/zone/gm_commands/texture.cpp index 09f00df4b..1a5c94a16 100755 --- a/zone/gm_commands/texture.cpp +++ b/zone/gm_commands/texture.cpp @@ -41,15 +41,7 @@ void command_texture(Client *c, const Seperator *sep) Chat::White, fmt::format( "Texture Changed for {} | Texture: {}{}", - ( - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), texture, ( Mob::IsPlayerRace(target->GetModel()) ? diff --git a/zone/gm_commands/timers.cpp b/zone/gm_commands/timers.cpp index 4e36661e4..6f66feeae 100755 --- a/zone/gm_commands/timers.cpp +++ b/zone/gm_commands/timers.cpp @@ -12,13 +12,7 @@ void command_timers(Client *c, const Seperator *sep) std::string popup_title = fmt::format( "Recast Timers for {}", - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target, TargetDescriptionType::UCSelf) ); std::string popup_text = "
"; diff --git a/zone/gm_commands/title.cpp b/zone/gm_commands/title.cpp index 48b935b3c..bd0503008 100755 --- a/zone/gm_commands/title.cpp +++ b/zone/gm_commands/title.cpp @@ -44,15 +44,7 @@ void command_title(Client *c, const Seperator *sep) "Title has been {}{} for {}{}", is_remove ? "removed" : "changed", !is_remove && save_title ? " and saved" : "", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ( is_remove ? "." : diff --git a/zone/gm_commands/titlesuffix.cpp b/zone/gm_commands/titlesuffix.cpp index 7dbad5e2b..b2e6cb4bf 100755 --- a/zone/gm_commands/titlesuffix.cpp +++ b/zone/gm_commands/titlesuffix.cpp @@ -44,15 +44,7 @@ void command_titlesuffix(Client *c, const Seperator *sep) "Title suffix has been {}{} for {}{}", is_remove ? "removed" : "changed", !is_remove && save_suffix ? " and saved" : "", - ( - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ), + c->GetTargetDescription(target), ( is_remove ? "." : diff --git a/zone/gm_commands/traindisc.cpp b/zone/gm_commands/traindisc.cpp index 7e5fff255..4392aa126 100755 --- a/zone/gm_commands/traindisc.cpp +++ b/zone/gm_commands/traindisc.cpp @@ -8,7 +8,7 @@ void command_traindisc(Client *c, const Seperator *sep) } if (sep->argnum < 1 || !sep->IsNumber(1)) { - c->Message(Chat::White, "FORMAT: #traindisc "); + c->Message(Chat::White, "Usage: #traindisc [Max Level] [Min Level]"); return; } @@ -32,12 +32,12 @@ void command_traindisc(Client *c, const Seperator *sep) } if (max_level < 1 || min_level < 1) { - c->Message(Chat::White, "ERROR: Level must be greater than or equal to 1."); + c->Message(Chat::White, "Level must be greater than or equal to 1."); return; } if (min_level > max_level) { - c->Message(Chat::White, "ERROR: Minimum Level must be less than or equal to Maximum Level."); + c->Message(Chat::White, "Minimum Level must be less than or equal to Maximum Level."); return; } @@ -60,7 +60,7 @@ void command_traindisc(Client *c, const Seperator *sep) fmt::format( "{} learned for {}.", discipline_message, - target->GetCleanName() + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/undye.cpp b/zone/gm_commands/undye.cpp index e5430a02b..414ac9ab4 100755 --- a/zone/gm_commands/undye.cpp +++ b/zone/gm_commands/undye.cpp @@ -12,13 +12,7 @@ void command_undye(Client *c, const Seperator *sep) Chat::White, fmt::format( "Undyed armor for {}.", - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target) ).c_str() ); } diff --git a/zone/gm_commands/unfreeze.cpp b/zone/gm_commands/unfreeze.cpp index 0785ca7c7..c9658fb7b 100755 --- a/zone/gm_commands/unfreeze.cpp +++ b/zone/gm_commands/unfreeze.cpp @@ -7,6 +7,15 @@ void command_unfreeze(Client *c, const Seperator *sep) return; } - c->GetTarget()->SendAppearancePacket(AT_Anim, ANIM_STAND); + auto target = c->GetTarget(); + target->SendAppearancePacket(AT_Anim, ANIM_STAND); + + c->Message( + Chat::White, + fmt::format( + "You have unfrozen {}.", + c->GetTargetDescription(target) + ).c_str() + ); } diff --git a/zone/gm_commands/unmemspell.cpp b/zone/gm_commands/unmemspell.cpp index 67ffc5664..56589f9ec 100644 --- a/zone/gm_commands/unmemspell.cpp +++ b/zone/gm_commands/unmemspell.cpp @@ -33,16 +33,9 @@ void command_unmemspell(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} not have {} ({}) memorized.", - ( - c == target ? - "You do" : - fmt::format( - "{} ({}) does", - target->GetCleanName(), - target->GetID() - ) - ), + "{} {} not have {} ({}) memorized.", + c->GetTargetDescription(target), + c == target ? "do" : "does", GetSpellName(spell_id), spell_id ).c_str() @@ -56,11 +49,10 @@ void command_unmemspell(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) unmemorized for {} ({}) from spell gem {}.", + "{} ({}) unmemorized for {} from spell gem {}.", GetSpellName(spell_id), spell_id, - target->GetCleanName(), - target->GetID(), + c->GetTargetDescription(target), spell_gem ).c_str() ); diff --git a/zone/gm_commands/unmemspells.cpp b/zone/gm_commands/unmemspells.cpp index f5f6f0987..a39d329c8 100644 --- a/zone/gm_commands/unmemspells.cpp +++ b/zone/gm_commands/unmemspells.cpp @@ -12,16 +12,9 @@ void command_unmemspells(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} no spells to unmemorize.", - ( - c == target ? - "You have" : - fmt::format( - "{} ({}) has", - target->GetCleanName(), - target->GetID() - ) - ) + "{} {} no spells to unmemorize.", + c->GetTargetDescription(target, TargetDescriptionType::UCYou), + c == target ? "have" : "has" ).c_str() ); return; @@ -33,9 +26,8 @@ void command_unmemspells(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) has had {} spells unmemorized.", - target->GetCleanName(), - target->GetID(), + "{} has had {} spells unmemorized.", + c->GetTargetDescription(target), memmed_count ).c_str() ); diff --git a/zone/gm_commands/unscribespell.cpp b/zone/gm_commands/unscribespell.cpp index 447c31202..bbb59af07 100755 --- a/zone/gm_commands/unscribespell.cpp +++ b/zone/gm_commands/unscribespell.cpp @@ -38,27 +38,16 @@ void command_unscribespell(Client *c, const Seperator *sep) "Unscribing {} ({}) for {}.", spell_name, spell_id, - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target) ).c_str() ); } else { c->Message( Chat::White, fmt::format( - "{} not have {} ({}) scribed.", - c == target ? - "You do" : - fmt::format( - "{} ({}) does", - target->GetCleanName(), - target->GetID() - ), + "{} {} not have {} ({}) scribed.", + c->GetTargetDescription(target), + c == target ? "do" : "does", spell_name, spell_id ).c_str() diff --git a/zone/gm_commands/untraindisc.cpp b/zone/gm_commands/untraindisc.cpp index 694af047c..31620d78a 100755 --- a/zone/gm_commands/untraindisc.cpp +++ b/zone/gm_commands/untraindisc.cpp @@ -38,27 +38,16 @@ void command_untraindisc(Client *c, const Seperator *sep) "Untraining {} ({}) for {}.", spell_name, spell_id, - c == target ? - "yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) + c->GetTargetDescription(target) ).c_str() ); } else { c->Message( Chat::White, fmt::format( - "{} not have {} ({}) trained.", - c == target ? - "You do" : - fmt::format( - "{} ({}) does", - target->GetCleanName(), - target->GetID() - ), + "{} {} not have {} ({}) trained.", + c->GetTargetDescription(target), + c == target ? "do" : "does", spell_name, spell_id ).c_str() diff --git a/zone/gm_commands/viewcurrencies.cpp b/zone/gm_commands/viewcurrencies.cpp index c66393c6f..b665a5d14 100644 --- a/zone/gm_commands/viewcurrencies.cpp +++ b/zone/gm_commands/viewcurrencies.cpp @@ -6,16 +6,6 @@ void command_viewcurrencies(Client *c, const Seperator *sep) if (c->GetTarget() && c->GetTarget()->IsClient()) { target = c->GetTarget()->CastToClient(); } - - auto target_string = ( - c == target ? - "Yourself" : - fmt::format( - "{} ({})", - target->GetCleanName(), - target->GetID() - ) - ); auto platinum = ( target->GetMoney(3, 0) + @@ -52,7 +42,7 @@ void command_viewcurrencies(Client *c, const Seperator *sep) Chat::White, fmt::format( "Money for {} | {}", - target_string, + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), ConvertMoneyToString( platinum, gold, @@ -70,7 +60,7 @@ void command_viewcurrencies(Client *c, const Seperator *sep) fmt::format( "{} for {} | {}", database.CreateItemLink(RuleI(Zone, EbonCrystalItemID)), - target_string, + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), ebon_crystals ).c_str() ); @@ -83,21 +73,21 @@ void command_viewcurrencies(Client *c, const Seperator *sep) fmt::format( "{} for {} | {}", database.CreateItemLink(RuleI(Zone, RadiantCrystalItemID)), - target_string, + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), radiant_crystals ).c_str() ); } - for (const auto& alternate_currency : zone->AlternateCurrencies) { - auto currency_value = target->GetAlternateCurrencyValue(alternate_currency.id); + for (const auto& ac : zone->AlternateCurrencies) { + auto currency_value = target->GetAlternateCurrencyValue(ac.id); if (currency_value) { c->Message( Chat::White, fmt::format( "{} for {} | {}", - database.CreateItemLink(alternate_currency.item_id), - target_string, + database.CreateItemLink(ac.item_id), + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), currency_value ).c_str() ); @@ -116,7 +106,7 @@ void command_viewcurrencies(Client *c, const Seperator *sep) fmt::format( "{} for {} | {}", EQ::constants::GetLDoNThemeName(ldon_currency_id), - target_string, + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), ldon_currency_value ).c_str() ); @@ -129,7 +119,7 @@ void command_viewcurrencies(Client *c, const Seperator *sep) Chat::White, fmt::format( "PVP Points for {} | {}", - target_string, + c->GetTargetDescription(target, TargetDescriptionType::UCSelf), pvp_points ).c_str() ); diff --git a/zone/gm_commands/wpinfo.cpp b/zone/gm_commands/wpinfo.cpp index 55b775581..4c1774c08 100755 --- a/zone/gm_commands/wpinfo.cpp +++ b/zone/gm_commands/wpinfo.cpp @@ -13,9 +13,8 @@ void command_wpinfo(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "{} ({}) is not a part of any grid.", - target->GetCleanName(), - target->GetID() + "{} is not a part of any grid.", + c->GetTargetDescription(target) ).c_str() ); return; diff --git a/zone/gm_commands/zclip.cpp b/zone/gm_commands/zclip.cpp index 3e465e1f4..957464c72 100755 --- a/zone/gm_commands/zclip.cpp +++ b/zone/gm_commands/zclip.cpp @@ -80,9 +80,8 @@ void command_zclip(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Clipping Changed | Zone: {} ({}) Permanent: {}", - zone->GetLongName(), - zone->GetZoneID(), + "Clipping Changed | Zone: {} Permanent: {}", + zone->GetZoneDescription(), permanent ? "Yes" : "No" ).c_str() ); diff --git a/zone/gm_commands/zcolor.cpp b/zone/gm_commands/zcolor.cpp index bfe8cbd44..77f7379ca 100755 --- a/zone/gm_commands/zcolor.cpp +++ b/zone/gm_commands/zcolor.cpp @@ -56,9 +56,8 @@ void command_zcolor(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Fog Color Changed | Zone: {} ({}) Red: {} Green: {} Blue: {} Permanent: {}", - zone->GetLongName(), - zone->GetZoneID(), + "Fog Color Changed | Zone: {} Red: {} Green: {} Blue: {} Permanent: {}", + zone->GetZoneDescription(), red, green, blue, diff --git a/zone/gm_commands/zsafecoords.cpp b/zone/gm_commands/zsafecoords.cpp index bce0ea743..25be80391 100755 --- a/zone/gm_commands/zsafecoords.cpp +++ b/zone/gm_commands/zsafecoords.cpp @@ -44,17 +44,8 @@ void command_zsafecoords(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Safe Coordinates Changed | Zone: {} ({}){} XYZ: {:.2f}, {:.2f}, {:.2f} Heading: {:.2f} Permanent: {} ", - zone->GetLongName(), - zone->GetZoneID(), - ( - zone->GetInstanceVersion() ? - fmt::format( - " Version: {}", - zone->GetInstanceVersion() - ) : - "" - ), + "Safe Coordinates Changed | Zone: {} XYZ: {:.2f}, {:.2f}, {:.2f} Heading: {:.2f} Permanent: {} ", + zone->GetZoneDescription(), x, y, z, diff --git a/zone/gm_commands/zsky.cpp b/zone/gm_commands/zsky.cpp index d43b2f152..ed3ef2dc8 100755 --- a/zone/gm_commands/zsky.cpp +++ b/zone/gm_commands/zsky.cpp @@ -34,9 +34,8 @@ void command_zsky(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Sky Changed | Zone: {} ({}) Sky Type: {} Permanent: {}", - zone->GetLongName(), - zone->GetZoneID(), + "Sky Changed | Zone: {} Sky Type: {} Permanent: {}", + zone->GetZoneDescription(), sky_type, permanent ? "Yes" : "No" ).c_str() diff --git a/zone/gm_commands/zstats.cpp b/zone/gm_commands/zstats.cpp index 9c4330ae5..7468cf1b2 100755 --- a/zone/gm_commands/zstats.cpp +++ b/zone/gm_commands/zstats.cpp @@ -6,11 +6,8 @@ void command_zstats(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Zone | ID: {} Instance ID: {} Name: {} ({})", - zone->GetZoneID(), - zone->GetInstanceID(), - zone->GetLongName(), - zone->GetShortName() + "Zone | {}", + zone->GetZoneDescription() ).c_str() ); diff --git a/zone/gm_commands/zunderworld.cpp b/zone/gm_commands/zunderworld.cpp index 88499dc2e..be55236ef 100755 --- a/zone/gm_commands/zunderworld.cpp +++ b/zone/gm_commands/zunderworld.cpp @@ -29,9 +29,8 @@ void command_zunderworld(Client *c, const Seperator *sep) c->Message( Chat::White, fmt::format( - "Underworld Z Changed | Zone: {} ({}) Z: {:.2f} Permanent: {}", - zone->GetLongName(), - zone->GetZoneID(), + "Underworld Z Changed | Zone: {} Z: {:.2f} Permanent: {}", + zone->GetZoneDescription(), z, permanent ? "Yes" : "No" ).c_str() diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 75923c99e..775862f4f 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -649,9 +649,8 @@ void HateList::PrintHateListToClient(Client *c) c->Message( Chat::White, fmt::format( - "Displaying hate list for {} ({}).", - hate_owner->GetCleanName(), - hate_owner->GetID() + "Displaying hate list for {}.", + c->GetTargetDescription(hate_owner) ).c_str() ); @@ -687,9 +686,8 @@ void HateList::PrintHateListToClient(Client *c) c->Message( Chat::White, fmt::format( - "{} ({}) has nothing on its hatelist.", - hate_owner->GetCleanName(), - hate_owner->GetID() + "{} has nothing on its hatelist.", + c->GetTargetDescription(hate_owner) ).c_str() ); } diff --git a/zone/mob.cpp b/zone/mob.cpp index 0d89af6fe..3fb889c6c 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3973,6 +3973,65 @@ const char *Mob::GetCleanName() return clean_name; } +std::string Mob::GetTargetDescription(Mob* target, uint8 description_type) +{ + std::string self_return = "yourself"; + + switch (description_type) + { + case TargetDescriptionType::LCSelf: + { + self_return = "yourself"; + break; + } + case TargetDescriptionType::UCSelf: + { + self_return = "Yourself"; + break; + } + case TargetDescriptionType::LCYou: + { + self_return = "you"; + break; + } + case TargetDescriptionType::UCYou: + { + self_return = "You"; + break; + } + case TargetDescriptionType::LCYour: + { + self_return = "your"; + break; + } + case TargetDescriptionType::UCYour: + { + self_return = "Your"; + break; + } + default: + { + break; + } + } + + + auto d = fmt::format( + "{}", + ( + this == target ? + self_return : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ) + ); + + return d; +} + // hp event void Mob::SetNextHPEvent( int hpevent ) { diff --git a/zone/mob.h b/zone/mob.h index 0e44c29bb..feedcd32a 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -546,6 +546,7 @@ public: virtual void SetName(const char *new_name = nullptr) { new_name ? strn0cpy(name, new_name, 64) : strn0cpy(name, GetName(), 64); return; }; inline Mob* GetTarget() const { return target; } + std::string GetTargetDescription(Mob* target, uint8 description_type = TargetDescriptionType::LCSelf); virtual void SetTarget(Mob* mob); inline bool HasTargetReflection() const { return (target && target != this && target->target == this); } virtual inline float GetHPRatio() const { return max_hp == 0 ? 0 : ((float) current_hp / max_hp * 100); } diff --git a/zone/npc.h b/zone/npc.h index d6c52915e..65e5fe9e9 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -194,7 +194,7 @@ public: void AddLootTable(); void AddLootTable(uint32 ldid); void CheckGlobalLootTables(); - void DescribeAggro(Client *towho, Mob *mob, bool verbose); + void DescribeAggro(Client *to_who, Mob *mob, bool verbose); void RemoveItem(uint32 item_id, uint16 quantity = 0, uint16 slot = 0); void CheckTrivialMinMaxLevelDrop(Mob *killer); void ClearItemList(); diff --git a/zone/task_client_state.cpp b/zone/task_client_state.cpp index 6064b322b..4ef2ea5cc 100644 --- a/zone/task_client_state.cpp +++ b/zone/task_client_state.cpp @@ -1733,24 +1733,24 @@ void ClientTaskState::ShowClientTaskInfoMessage(ClientTaskInformation *task, Cli } } -void ClientTaskState::ShowClientTasks(Client *client) +void ClientTaskState::ShowClientTasks(Client* who, Client *to) { - client->Message(Chat::White, "------------------------------------------------"); - client->Message( + to->SendChatLineBreak(); + + to->Message( Chat::White, fmt::format( - "Task Information for {} ({})", - client->GetCleanName(), - client->GetID() + "Task Information for {}", + to->GetTargetDescription(who, TargetDescriptionType::UCSelf) ).c_str() ); if (m_active_task.task_id != TASKSLOTEMPTY) { - ShowClientTaskInfoMessage(&m_active_task, client); + ShowClientTaskInfoMessage(&m_active_task, to); } if (m_active_shared_task.task_id != TASKSLOTEMPTY) { - ShowClientTaskInfoMessage(&m_active_shared_task, client); + ShowClientTaskInfoMessage(&m_active_shared_task, to); } for (auto &active_quest : m_active_quests) { @@ -1758,10 +1758,10 @@ void ClientTaskState::ShowClientTasks(Client *client) continue; } - ShowClientTaskInfoMessage(&active_quest, client); + ShowClientTaskInfoMessage(&active_quest, to); } - client->Message(Chat::White, "------------------------------------------------"); + to->SendChatLineBreak(); } // TODO: Shared Task diff --git a/zone/task_client_state.h b/zone/task_client_state.h index ab3ad1044..b8aa03667 100644 --- a/zone/task_client_state.h +++ b/zone/task_client_state.h @@ -13,7 +13,7 @@ class ClientTaskState { public: ClientTaskState(); ~ClientTaskState(); - void ShowClientTasks(Client *client); + void ShowClientTasks(Client* who, Client *to); inline int GetActiveTaskCount() { return m_active_task_count; } int GetActiveTaskID(int index); bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id); diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index daf031708..58b25cbfc 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -168,9 +168,8 @@ void WorldServer::OnConnected() { 0, Chat::Yellow, fmt::format( - "Zone Connected | {} ({})", - zone->GetLongName(), - zone->GetZoneID() + "Zone Connected | {}", + zone->GetZoneDescription() ).c_str() ); zone->GetTimeSync(); @@ -193,14 +192,10 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) ServerPacket *pack = &tpack; switch (opcode) { - case 0: { - break; - } + case 0: case ServerOP_KeepAlive: { - // ignore this break; } - // World is tellins us what port to use. case ServerOP_SetConnectInfo: { if (pack->size != sizeof(ServerConnectInfo)) break; @@ -255,7 +250,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_VoiceMacro: { - if (!is_zone_loaded) break; @@ -270,46 +264,45 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) vmo->MacroNumber = svm->MacroNumber; switch (svm->Type) { - case VoiceMacroTell: { - Client* c = entity_list.GetClientByName(svm->To); - if (!c) + case VoiceMacroTell: { + Client* c = entity_list.GetClientByName(svm->To); + if (!c) + break; + + c->QueuePacket(outapp); break; - - c->QueuePacket(outapp); - break; - } - - case VoiceMacroGroup: { - Group* g = entity_list.GetGroupByID(svm->GroupID); - - if (!g) - break; - - for (unsigned int i = 0; i < MAX_GROUP_MEMBERS; i++) { - if (g->members[i] && g->members[i]->IsClient()) - g->members[i]->CastToClient()->QueuePacket(outapp); - } - break; - } - case VoiceMacroRaid: { - Raid *r = entity_list.GetRaidByID(svm->RaidID); + case VoiceMacroGroup: { + Group* g = entity_list.GetGroupByID(svm->GroupID); - if (!r) + if (!g) + break; + + for (unsigned int i = 0; i < MAX_GROUP_MEMBERS; i++) { + if (g->members[i] && g->members[i]->IsClient()) + g->members[i]->CastToClient()->QueuePacket(outapp); + + } break; + } - for (int i = 0; i < MAX_RAID_MEMBERS; i++) - if (r->members[i].member) - r->members[i].member->QueuePacket(outapp); + case VoiceMacroRaid: { + Raid *r = entity_list.GetRaidByID(svm->RaidID); - break; - } + if (!r) + break; + + for (int i = 0; i < MAX_RAID_MEMBERS; i++) + if (r->members[i].member) + r->members[i].member->QueuePacket(outapp); + + break; + } } safe_delete(outapp); break; } - case ServerOP_SpawnCondition: { if (pack->size != sizeof(ServerSpawnCondition_Struct)) break; @@ -532,9 +525,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) 0, Chat::Yellow, fmt::format( - "Zone Shutdown | {} ({})", - zone->GetLongName(), - zone->GetZoneID() + "Zone Shutdown | {}", + zone->GetZoneDescription() ).c_str() ); @@ -562,9 +554,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) 0, Chat::White, fmt::format( - "Zone Bootup Failed | {} ({}) Already running", - zone->GetLongName(), - zone->GetZoneID() + "Zone Bootup Failed | {} Already running", + zone->GetZoneDescription() ).c_str() ); } @@ -690,9 +681,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) skp->name, is_zone_loaded ? fmt::format( - "in {} ({})", - zone->GetLongName(), - zone->GetZoneID() + "in {}", + zone->GetZoneDescription() ) : "" ).c_str() @@ -726,9 +716,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) skp->target, is_zone_loaded ? fmt::format( - "in {} ({})", - zone->GetLongName(), - zone->GetZoneID() + "in {}", + zone->GetZoneDescription() ) : "" ).c_str() @@ -747,22 +736,17 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - - //hand all the guild related packets to the guild manager for processing. case ServerOP_OnlineGuildMembersResponse: case ServerOP_RefreshGuild: - // case ServerOP_GuildInvite: case ServerOP_DeleteGuild: case ServerOP_GuildCharRefresh: case ServerOP_GuildMemberUpdate: case ServerOP_GuildRankUpdate: case ServerOP_LFGuildUpdate: - // case ServerOP_GuildGMSet: - // case ServerOP_GuildGMSetRank: - // case ServerOP_GuildJoin: + { guild_mgr.ProcessWorldPacket(pack); break; - + } case ServerOP_FlagUpdate: { Client* client = entity_list.GetClientByAccID(*((uint32*)pack->pBuffer)); if (client) { @@ -785,10 +769,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) 0, Chat::Red, fmt::format( - "Summoning you to {} ({}) in {} at {:.2f}, {:.2f}, {:.2f}", + "Summoning you to {} in {} at {:.2f}, {:.2f}, {:.2f}", client->GetCleanName(), - zone->GetLongName(), - zone->GetZoneID(), + zone->GetZoneDescription(), client->GetX(), client->GetY(), client->GetZ() @@ -987,9 +970,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) 0, Chat::White, fmt::format( - "Zone {} ({}) | {} {}.", - zone->GetLongName(), - zone->GetZoneID(), + "Zone {} | {} {}.", + zone->GetZoneDescription(), rev->toggle ? "Revoking" : "Unrevoking", client->GetCleanName() ).c_str() @@ -1235,7 +1217,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_ForceGroupUpdate: { ServerForceGroupUpdate_Struct* fgu = (ServerForceGroupUpdate_Struct*)pack->pBuffer; if (zone) { @@ -1246,7 +1227,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_OOZGroupMessage: { ServerGroupChannelMessage_Struct* gcm = (ServerGroupChannelMessage_Struct*)pack->pBuffer; if (zone) { @@ -1284,7 +1264,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidRemove: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1305,7 +1284,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidDisband: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1321,7 +1299,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidLockFlag: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1339,7 +1316,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidChangeGroup: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1368,7 +1344,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_UpdateGroup: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1382,7 +1357,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidGroupLeader: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1391,7 +1365,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidLeader: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1412,7 +1385,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_DetailsChange: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1428,7 +1400,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidGroupDisband: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; if (zone) { @@ -1449,7 +1420,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidGroupAdd: { ServerRaidGroupAction_Struct* rga = (ServerRaidGroupAction_Struct*)pack->pBuffer; if (zone) { @@ -1480,7 +1450,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidGroupRemove: { ServerRaidGroupAction_Struct* rga = (ServerRaidGroupAction_Struct*)pack->pBuffer; if (zone) { @@ -1511,7 +1480,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidGroupSay: { ServerRaidMessage_Struct* rmsg = (ServerRaidMessage_Struct*)pack->pBuffer; if (zone) { @@ -1536,7 +1504,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidSay: { ServerRaidMessage_Struct* rmsg = (ServerRaidMessage_Struct*)pack->pBuffer; if (zone) @@ -1560,7 +1527,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_RaidMOTD: { ServerRaidMOTD_Struct *rmotd = (ServerRaidMOTD_Struct *)pack->pBuffer; if (!zone) @@ -1572,7 +1538,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) r->SendRaidMOTD(); break; } - case ServerOP_SpawnPlayerCorpse: { SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer; Corpse* NewCorpse = database.LoadCharacterCorpse(s->player_corpse_id); @@ -1647,12 +1612,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_ReloadTasks: { - if (RuleB(Tasks, EnableTaskSystem)) { - HandleReloadTasks(pack); - } - break; - } case ServerOP_LFGMatches: { HandleLFGMatches(pack); break; @@ -1661,7 +1620,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) HandleLFPMatches(pack); break; } - case ServerOP_UpdateSpawn: { if (zone) { @@ -1683,7 +1641,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_InstanceUpdateTime: { ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer; @@ -1696,7 +1653,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_DepopAllPlayersCorpses: { ServerDepopAllPlayersCorpses_Struct *sdapcs = (ServerDepopAllPlayersCorpses_Struct *)pack->pBuffer; @@ -1707,7 +1663,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_DepopPlayerCorpse: { ServerDepopPlayerCorpse_Struct *sdpcs = (ServerDepopPlayerCorpse_Struct *)pack->pBuffer; @@ -1718,38 +1673,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - - case ServerOP_ReloadTitles: - { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Titles reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - } - - title_manager.LoadTitles(); - break; - } - case ServerOP_SpawnStatusChange: { if (zone) @@ -1783,7 +1706,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_QGlobalUpdate: { if (pack->size != sizeof(ServerQGlobalUpdate_Struct)) @@ -1809,7 +1731,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_QGlobalDelete: { if (pack->size != sizeof(ServerQGlobalDelete_Struct)) @@ -1828,7 +1749,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureRequestAccept: { ServerAdventureRequestAccept_Struct *ars = (ServerAdventureRequestAccept_Struct*)pack->pBuffer; @@ -1840,7 +1760,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureRequestDeny: { ServerAdventureRequestDeny_Struct *ars = (ServerAdventureRequestDeny_Struct*)pack->pBuffer; @@ -1852,7 +1771,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureCreateDeny: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1863,7 +1781,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureData: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1879,7 +1796,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureDataClear: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1893,7 +1809,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureClickDoorReply: { ServerPlayerClickedAdventureDoorReply_Struct *adr = (ServerPlayerClickedAdventureDoorReply_Struct*)pack->pBuffer; @@ -1905,7 +1820,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureClickDoorError: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1916,7 +1830,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureLeaveReply: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1927,7 +1840,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureLeaveDeny: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1938,7 +1850,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureCountUpdate: { ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer; @@ -1949,7 +1860,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureZoneData: { if (zone) @@ -1961,7 +1871,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureFinish: { ServerAdventureFinish_Struct *af = (ServerAdventureFinish_Struct*)pack->pBuffer; @@ -1972,7 +1881,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_AdventureLeaderboard: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); @@ -1985,239 +1893,85 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_ReloadRules: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Rules reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - } - RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset(), true); + case ServerOP_ReloadAAData: + { + zone->SendReloadMessage("Alternate Advancement Data"); + zone->LoadAlternateAdvancement(); break; } - case ServerOP_ReloadContentFlags: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Content flags (and expansion) reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - } - content_service.SetExpansionContext()->ReloadContentFlags(); - break; - } - case ServerOP_ReloadLogs: { - LogSys.LoadLogDatabaseSettings(); - break; - } - case ServerOP_ReloadPerlExportSettings: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Perl event export settings reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - } - parse->LoadPerlEventExportSettings(parse->perl_event_export_settings); - break; - } -case ServerOP_ReloadTraps: + case ServerOP_ReloadContentFlags: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Traps reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - - entity_list.UpdateAllTraps(true, true); - } + zone->SendReloadMessage("Content Flags"); + content_service.SetExpansionContext()->ReloadContentFlags(); break; } case ServerOP_ReloadLevelEXPMods: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Level based experience modifiers reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - - zone->LoadLevelEXPMods(); - } + zone->SendReloadMessage("Level Based Experience Modifiers"); + zone->LoadLevelEXPMods(); break; } - case ServerOP_ReloadAAData: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Alternate Advancement data reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - - zone->LoadAlternateAdvancement(); - } + case ServerOP_ReloadLogs: + { + zone->SendReloadMessage("Log Settings"); + LogSys.LoadLogDatabaseSettings(); break; } - case ServerOP_ReloadMerchants: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Merchants reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - - entity_list.ReloadMerchants(); - } + case ServerOP_ReloadMerchants: { + zone->SendReloadMessage("Merchants"); + entity_list.ReloadMerchants(); + break; + } + case ServerOP_ReloadPerlExportSettings: + { + zone->SendReloadMessage("Perl Event Export Settings"); + parse->LoadPerlEventExportSettings(parse->perl_event_export_settings); + break; + } + case ServerOP_ReloadRules: + { + zone->SendReloadMessage("Rules"); + RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset(), true); break; } case ServerOP_ReloadStaticZoneData: { - if (zone) { - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::GMAdmin, - Chat::Yellow, - fmt::format( - "Static zone data reloaded for {}{}.", - fmt::format( - "{} ({})", - zone->GetLongName(), - zone->GetZoneID() - ), - ( - zone->GetInstanceID() ? - fmt::format( - " (Instance ID {})", - zone->GetInstanceID() - ) : - "" - ) - ).c_str() - ); - - zone->ReloadStaticData(); + zone->SendReloadMessage("Static Zone Data"); + zone->ReloadStaticData(); + break; + } + case ServerOP_ReloadTasks: + { + if (RuleB(Tasks, EnableTaskSystem)) { + zone->SendReloadMessage("Tasks"); + HandleReloadTasks(pack); } + + break; + } + case ServerOP_ReloadTitles: + { + zone->SendReloadMessage("Titles"); + title_manager.LoadTitles(); + break; + } + case ServerOP_ReloadTraps: + { + zone->SendReloadMessage("Traps"); + entity_list.UpdateAllTraps(true, true); + break; + } + case ServerOP_ReloadWorld: + { + auto* reload_world = (ReloadWorld_Struct*)pack->pBuffer; + if (zone) { + zone->ReloadWorld(reload_world->global_repop); + } + break; + } + case ServerOP_ReloadZonePoints: + { + zone->SendReloadMessage("Zone Points"); + content_db.LoadStaticZonePoints(&zone->zone_point_list, zone->GetShortName(), zone->GetInstanceVersion()); break; } case ServerOP_CameraShake: @@ -3296,16 +3050,6 @@ case ServerOP_ReloadTraps: } break; } - - case ServerOP_ReloadWorld: - { - auto* reload_world = (ReloadWorld_Struct*)pack->pBuffer; - if (zone) { - zone->ReloadWorld(reload_world->global_repop); - } - break; - } - case ServerOP_UpdateSchedulerEvents: { LogScheduler("Received signal from world to update"); if (m_zone_scheduler) { @@ -3314,7 +3058,6 @@ case ServerOP_ReloadTraps: break; } - case ServerOP_HotReloadQuests: { if (!zone) { @@ -3445,9 +3188,6 @@ case ServerOP_ReloadTraps: } default: { LogInfo("[HandleMessage] Unknown ZS Opcode [{}] size [{}]", (int)pack->opcode, pack->size); - -// std::cout << " Unknown ZSopcode:" << (int)pack->opcode; -// std::cout << " size:" << pack->size << std::endl; break; } } diff --git a/zone/zone.cpp b/zone/zone.cpp index b0a027dd1..5833f89f0 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2727,3 +2727,45 @@ uint32 Zone::GetCurrencyItemID(uint32 currency_id) return 0; } + +std::string Zone::GetZoneDescription() +{ + auto d = fmt::format( + "{} ({}){}{}", + GetLongName(), + GetZoneID(), + ( + GetInstanceID() ? + fmt::format( + " (Instance ID {})", + GetInstanceID() + ) : + "" + ), + ( + GetInstanceVersion() ? + fmt::format( + " (Version {})", + GetInstanceVersion() + ) : + "" + ) + ); + + return d; +} + +void Zone::SendReloadMessage(std::string reload_type) +{ + worldserver.SendEmoteMessage( + 0, + 0, + AccountStatus::GMAdmin, + Chat::Yellow, + fmt::format( + "{} reloaded for {}.", + reload_type, + GetZoneDescription() + ).c_str() + ); +} diff --git a/zone/zone.h b/zone/zone.h index 3437eb6a6..253514e02 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -244,6 +244,9 @@ public: uint32 GetCurrencyID(uint32 item_id); uint32 GetCurrencyItemID(uint32 currency_id); + std::string GetZoneDescription(); + void SendReloadMessage(std::string reload_type); + void AddAggroMob() { aggroedmobs++; } void AddAuth(ServerZoneIncomingClient_Struct *szic); void ChangeWeather();