From 91adf9c0ebd4c94fc94f84ab08f83b1c4dd14903 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 11 Oct 2021 16:33:18 -0400 Subject: [PATCH] [Quest API] Add cross zone and world wide dialogue windows to Perl/Lua. (#1599) * [Quest API] Add cross zone and world wide dialogue windows to Perl/Lua. - Add quest::crosszonedialoguewindowbycharid(character_id, message) to Perl. - Add quest::crosszonedialoguewindowbygroupid(group_id, message) to Perl. - Add quest::crosszonedialoguewindowbyraidid(raid_id, message) to Perl. - Add quest::crosszonedialoguewindowbyguildid(guild_id, message) to Perl. - Add quest::crosszonedialoguewindowbyexpeditionid(expedition_id, message) to Perl. - Add quest::crosszonedialoguewindowbyclientname(client_name, message) to Perl. - Add quest::worldwidedialoguewindow(message, min_status, max_status) to Perl. - Add eq.cross_zone_dialogue_window_by_char_id(character_id, message) to Lua. - Add eq.cross_zone_dialogue_window_by_group_id(group_id, message) to Lua. - Add eq.cross_zone_dialogue_window_by_raid_id(raid_id, message) to Lua. - Add eq.cross_zone_dialogue_window_by_guild_id(guild_id, message) to Lua. - Add eq.cross_zone_dialogue_window_by_expedition_id(expedition_id, message) to Lua. - Add eq.cross_zone_dialogue_window_by_client_name(client_name, message) to Lua. - Add eq.world_wide_dialogue_window(message, min_status, max_status) to Lua. * Use string instead. --- common/servertalk.h | 49 ++-- world/zoneserver.cpp | 4 +- zone/embparser_api.cpp | 112 +++++++++ zone/lua_general.cpp | 52 ++++ zone/questmgr.cpp | 21 ++ zone/questmgr.h | 4 +- zone/worldserver.cpp | 556 +++++++++++++++++++++++------------------ 7 files changed, 534 insertions(+), 264 deletions(-) diff --git a/common/servertalk.h b/common/servertalk.h index 00510d60b..fd91f591e 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -227,24 +227,26 @@ #define ServerOP_HotReloadQuests 0x4011 #define ServerOP_UpdateSchedulerEvents 0x4012 -#define ServerOP_CZLDoNUpdate 0x4500 -#define ServerOP_CZMarquee 0x4501 -#define ServerOP_CZMessage 0x4502 -#define ServerOP_CZMove 0x4503 -#define ServerOP_CZSetEntityVariable 0x4504 -#define ServerOP_CZSignal 0x4505 -#define ServerOP_CZSpell 0x4506 -#define ServerOP_CZTaskUpdate 0x4507 -#define ServerOP_CZClientMessageString 0x4508 +#define ServerOP_CZDialogueWindow 0x4500 +#define ServerOP_CZLDoNUpdate 0x4501 +#define ServerOP_CZMarquee 0x4502 +#define ServerOP_CZMessage 0x4503 +#define ServerOP_CZMove 0x4504 +#define ServerOP_CZSetEntityVariable 0x4505 +#define ServerOP_CZSignal 0x4506 +#define ServerOP_CZSpell 0x4507 +#define ServerOP_CZTaskUpdate 0x4508 +#define ServerOP_CZClientMessageString 0x4509 -#define ServerOP_WWLDoNUpdate 0x4750 -#define ServerOP_WWMarquee 0x4751 -#define ServerOP_WWMessage 0x4752 -#define ServerOP_WWMove 0x4753 -#define ServerOP_WWSetEntityVariable 0x4754 -#define ServerOP_WWSignal 0x4755 -#define ServerOP_WWSpell 0x4756 -#define ServerOP_WWTaskUpdate 0x4757 +#define ServerOP_WWDialogueWindow 0x4750 +#define ServerOP_WWLDoNUpdate 0x4751 +#define ServerOP_WWMarquee 0x4752 +#define ServerOP_WWMessage 0x4753 +#define ServerOP_WWMove 0x4754 +#define ServerOP_WWSetEntityVariable 0x4755 +#define ServerOP_WWSignal 0x4756 +#define ServerOP_WWSpell 0x4757 +#define ServerOP_WWTaskUpdate 0x4758 /** * QueryServer @@ -1440,6 +1442,13 @@ struct CZClientMessageString_Struct { char args[1]; // null delimited }; +struct CZDialogueWindow_Struct { + uint8 update_type; // 0 - Character, 1 - Group, 2 - Raid, 3 - Guild, 4 - Expedition, 5 - Character Name + int update_identifier; // Character ID, Group ID, Raid ID, Guild ID, or Expedition ID based on update type, 0 for Character Name + char message[4096]; + char client_name[64]; // Only used by Character Name Type, else empty +}; + struct CZLDoNUpdate_Struct { uint8 update_type; // 0 - Character, 1 - Group, 2 - Raid, 3 - Guild, 4 - Expedition, 5 - Character Name uint8 update_subtype; // 0 - Loss, 1 - Points, 2 - Win @@ -1512,6 +1521,12 @@ struct CZTaskUpdate_Struct { char client_name[64]; // Only used by Character Name Type, else empty }; +struct WWDialogueWindow_Struct { + char message[4096]; + uint8 min_status; + uint8 max_status; +}; + struct WWLDoNUpdate_Struct { uint8 update_type; // 0 - Loss, 1 - Points, 2 - Win uint32 theme_id; diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index ee0c9e8da..03b5e8dd2 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -1239,7 +1239,8 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { { QSLink.SendPacket(pack); break; - } + } + case ServerOP_CZDialogueWindow: case ServerOP_CZLDoNUpdate: case ServerOP_CZMarquee: case ServerOP_CZMessage: @@ -1248,6 +1249,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { case ServerOP_CZSignal: case ServerOP_CZSpell: case ServerOP_CZTaskUpdate: + case ServerOP_WWDialogueWindow: case ServerOP_WWLDoNUpdate: case ServerOP_WWMarquee: case ServerOP_WWMessage: diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 164021bf6..98e061c8c 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -5806,6 +5806,91 @@ XS(XS__crosszonecastspellbyclientname) { XSRETURN_EMPTY; } +XS(XS__crosszonedialoguewindowbycharid); +XS(XS__crosszonedialoguewindowbycharid) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: quest::crosszonedialoguewindowbycharid(int character_id, string message)"); + { + uint8 update_type = CZUpdateType_Character; + int character_id = (int) SvIV(ST(0)); + const char* message = (const char*) SvPV_nolen(ST(1)); + quest_manager.CrossZoneDialogueWindow(update_type, character_id, message); + } + XSRETURN_EMPTY; +} + +XS(XS__crosszonedialoguewindowbygroupid); +XS(XS__crosszonedialoguewindowbygroupid) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: quest::crosszonedialoguewindowbygroupid(int group_id, string message)"); + { + uint8 update_type = CZUpdateType_Group; + int group_id = (int) SvIV(ST(0)); + const char* message = (const char*) SvPV_nolen(ST(1)); + quest_manager.CrossZoneDialogueWindow(update_type, group_id, message); + } + XSRETURN_EMPTY; +} + +XS(XS__crosszonedialoguewindowbyraidid); +XS(XS__crosszonedialoguewindowbyraidid) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: quest::crosszonedialoguewindowbyraidid(int raid_id, string message)"); + { + uint8 update_type = CZUpdateType_Raid; + int raid_id = (int) SvIV(ST(0)); + const char* message = (const char*) SvPV_nolen(ST(1)); + quest_manager.CrossZoneDialogueWindow(update_type, raid_id, message); + } + XSRETURN_EMPTY; +} + +XS(XS__crosszonedialoguewindowbyguildid); +XS(XS__crosszonedialoguewindowbyguildid) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: quest::crosszonedialoguewindowbyguildid(int guild_id, string message)"); + { + uint8 update_type = CZUpdateType_Guild; + int guild_id = (int) SvIV(ST(0)); + const char* message = (const char*) SvPV_nolen(ST(1)); + quest_manager.CrossZoneDialogueWindow(update_type, guild_id, message); + } + XSRETURN_EMPTY; +} + +XS(XS__crosszonedialoguewindowbyexpeditionid); +XS(XS__crosszonedialoguewindowbyexpeditionid) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: quest::crosszonedialoguewindowbyexpeditionid(uint32 expedition_id, string message)"); + { + uint8 update_type = CZUpdateType_Expedition; + uint32 expedition_id = (uint32) SvUV(ST(0)); + const char* message = (const char*) SvPV_nolen(ST(1)); + quest_manager.CrossZoneDialogueWindow(update_type, expedition_id, message); + } + XSRETURN_EMPTY; +} + +XS(XS__crosszonedialoguewindowbyclientname); +XS(XS__crosszonedialoguewindowbyclientname) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: quest::crosszonedialoguewindowbyclientname(const char* client_name, string message)"); + { + uint8 update_type = CZUpdateType_ClientName; + int update_identifier = 0; + const char* client_name = (const char*) SvPV_nolen(ST(0)); + const char* message = (const char*) SvPV_nolen(ST(1)); + quest_manager.CrossZoneDialogueWindow(update_type, update_identifier, message, client_name); + } + XSRETURN_EMPTY; +} + XS(XS__crosszonedisabletaskbycharid); XS(XS__crosszonedisabletaskbycharid) { dXSARGS; @@ -7225,6 +7310,26 @@ XS(XS__worldwidecastspell) { XSRETURN_EMPTY; } +XS(XS__worldwidedialoguewindow); +XS(XS__worldwidedialoguewindow) { + dXSARGS; + if (items < 1 || items > 3) + Perl_croak(aTHX_ "Usage: quest::worldwidedialoguewindow(string message, [uint8 min_status = 0, uint8 max_status = 0])"); + { + const char* message = (const char*) SvPV_nolen(ST(0)); + uint8 min_status = 0; + uint8 max_status = 0; + if (items == 2) + min_status = (uint8)SvUV(ST(1)); + + if (items == 3) + max_status = (uint8)SvUV(ST(2)); + + quest_manager.WorldWideDialogueWindow(message, min_status, max_status); + } + XSRETURN_EMPTY; +} + XS(XS__worldwidedisabletask); XS(XS__worldwidedisabletask) { dXSARGS; @@ -7791,6 +7896,12 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "crosszonecastspellbyguildid"), XS__crosszonecastspellbyguildid, file); newXS(strcpy(buf, "crosszonecastspellbyexpeditionid"), XS__crosszonecastspellbyexpeditionid, file); newXS(strcpy(buf, "crosszonecastspellbyclientname"), XS__crosszonecastspellbyclientname, file); + newXS(strcpy(buf, "crosszonedialoguewindowbycharid"), XS__crosszonedialoguewindowbycharid, file); + newXS(strcpy(buf, "crosszonedialoguewindowbygroupid"), XS__crosszonedialoguewindowbygroupid, file); + newXS(strcpy(buf, "crosszonedialoguewindowbyraidid"), XS__crosszonedialoguewindowbyraidid, file); + newXS(strcpy(buf, "crosszonedialoguewindowbyguildid"), XS__crosszonedialoguewindowbyguildid, file); + newXS(strcpy(buf, "crosszonedialoguewindowbyexpeditionid"), XS__crosszonedialoguewindowbyexpeditionid, file); + newXS(strcpy(buf, "crosszonedialoguewindowbyclientname"), XS__crosszonedialoguewindowbyclientname, file); newXS(strcpy(buf, "crosszonedisabletaskbycharid"), XS__crosszonedisabletaskbycharid, file); newXS(strcpy(buf, "crosszonedisabletaskbygroupid"), XS__crosszonedisabletaskbygroupid, file); newXS(strcpy(buf, "crosszonedisabletaskbyraidid"), XS__crosszonedisabletaskbyraidid, file); @@ -7875,6 +7986,7 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "worldwideaddldonpoints"), XS__worldwideaddldonpoints, file); newXS(strcpy(buf, "worldwideaddldonwin"), XS__worldwideaddldonwin, file); newXS(strcpy(buf, "worldwidecastspell"), XS__worldwidecastspell, file); + newXS(strcpy(buf, "worldwidedialoguewindow"), XS__worldwidedialoguewindow, file); newXS(strcpy(buf, "worldwidedisabletask"), XS__worldwidedisabletask, file); newXS(strcpy(buf, "worldwideenabletask"), XS__worldwideenabletask, file); newXS(strcpy(buf, "worldwidefailtask"), XS__worldwidefailtask, file); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 404a074ef..a9d724138 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -2179,6 +2179,37 @@ void lua_cross_zone_cast_spell_by_client_name(const char* client_name, uint32 sp quest_manager.CrossZoneSpell(update_type, update_subtype, update_identifier, spell_id, client_name); } +void lua_cross_zone_dialogue_window_by_char_id(int character_id, const char* message) { + uint8 update_type = CZUpdateType_Character; + quest_manager.CrossZoneDialogueWindow(update_type, character_id, message); +} + +void lua_cross_zone_dialogue_window_by_group_id(int group_id, const char* message) { + uint8 update_type = CZUpdateType_Group; + quest_manager.CrossZoneDialogueWindow(update_type, group_id, message); +} + +void lua_cross_zone_dialogue_window_by_raid_id(int raid_id, const char* message) { + uint8 update_type = CZUpdateType_Raid; + quest_manager.CrossZoneDialogueWindow(update_type, raid_id, message); +} + +void lua_cross_zone_dialogue_window_by_guild_id(int guild_id, const char* message) { + uint8 update_type = CZUpdateType_Guild; + quest_manager.CrossZoneDialogueWindow(update_type, guild_id, message); +} + +void lua_cross_zone_dialogue_window_by_expedition_id(uint32 expedition_id, const char* message) { + uint8 update_type = CZUpdateType_Expedition; + quest_manager.CrossZoneDialogueWindow(update_type, expedition_id, message); +} + +void lua_cross_zone_dialogue_window_by_client_name(const char* client_name, const char* message) { + uint8 update_type = CZUpdateType_ClientName; + int update_identifier = 0; + quest_manager.CrossZoneDialogueWindow(update_type, update_identifier, message, client_name); +} + void lua_cross_zone_disable_task_by_char_id(int character_id, uint32 task_id) { uint8 update_type = CZUpdateType_Character; uint8 update_subtype = CZTaskUpdateSubtype_DisableTask; @@ -2882,6 +2913,18 @@ void lua_world_wide_cast_spell(uint32 spell_id, uint8 min_status, uint8 max_stat quest_manager.WorldWideSpell(update_type, spell_id, min_status, max_status); } +void lua_world_wide_dialogue_window(const char* message) { + quest_manager.WorldWideDialogueWindow(message); +} + +void lua_world_wide_dialogue_window(const char* message, uint8 min_status) { + quest_manager.WorldWideDialogueWindow(message, min_status); +} + +void lua_world_wide_dialogue_window(const char* message, uint8 min_status, uint8 max_status) { + quest_manager.WorldWideDialogueWindow(message, min_status, max_status); +} + void lua_world_wide_disable_task(uint32 task_id) { uint8 update_type = WWTaskUpdateType_DisableTask; quest_manager.WorldWideTaskUpdate(update_type, task_id); @@ -3662,6 +3705,12 @@ luabind::scope lua_register_general() { luabind::def("cross_zone_cast_spell_by_guild_id", &lua_cross_zone_cast_spell_by_guild_id), luabind::def("cross_zone_cast_spell_by_expedition_id", &lua_cross_zone_cast_spell_by_expedition_id), luabind::def("cross_zone_cast_spell_by_client_name", &lua_cross_zone_cast_spell_by_client_name), + luabind::def("cross_zone_dialogue_window_by_char_id", &lua_cross_zone_dialogue_window_by_char_id), + luabind::def("cross_zone_dialogue_window_by_group_id", &lua_cross_zone_dialogue_window_by_group_id), + luabind::def("cross_zone_dialogue_window_by_raid_id", &lua_cross_zone_dialogue_window_by_raid_id), + luabind::def("cross_zone_dialogue_window_by_guild_id", &lua_cross_zone_dialogue_window_by_guild_id), + luabind::def("cross_zone_dialogue_window_by_expedition_id", &lua_cross_zone_dialogue_window_by_expedition_id), + luabind::def("cross_zone_dialogue_window_by_client_name", &lua_cross_zone_dialogue_window_by_client_name), luabind::def("cross_zone_disable_task_by_char_id", &lua_cross_zone_disable_task_by_char_id), luabind::def("cross_zone_disable_task_by_group_id", &lua_cross_zone_disable_task_by_group_id), luabind::def("cross_zone_disable_task_by_raid_id", &lua_cross_zone_disable_task_by_raid_id), @@ -3767,6 +3816,9 @@ luabind::scope lua_register_general() { luabind::def("world_wide_cast_spell", (void(*)(uint32))&lua_world_wide_cast_spell), luabind::def("world_wide_cast_spell", (void(*)(uint32,uint8))&lua_world_wide_cast_spell), luabind::def("world_wide_cast_spell", (void(*)(uint32,uint8,uint8))&lua_world_wide_cast_spell), + luabind::def("world_wide_dialogue_window", (void(*)(const char*))&lua_world_wide_dialogue_window), + luabind::def("world_wide_dialogue_window", (void(*)(const char*,uint8))&lua_world_wide_dialogue_window), + luabind::def("world_wide_dialogue_window", (void(*)(const char*,uint8,uint8))&lua_world_wide_dialogue_window), luabind::def("world_wide_disable_task", (void(*)(uint32))&lua_world_wide_disable_task), luabind::def("world_wide_disable_task", (void(*)(uint32,uint8))&lua_world_wide_disable_task), luabind::def("world_wide_disable_task", (void(*)(uint32,uint8,uint8))&lua_world_wide_disable_task), diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 350a8a6ef..e2fa0617b 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -3464,6 +3464,17 @@ int QuestManager::getspellstat(uint32 spell_id, std::string stat_identifier, uin return GetSpellStatValue(spell_id, stat_identifier.c_str(), slot); } +void QuestManager::CrossZoneDialogueWindow(uint8 update_type, int update_identifier, const char* message, const char* client_name) { + auto pack = new ServerPacket(ServerOP_CZDialogueWindow, sizeof(CZDialogueWindow_Struct)); + CZDialogueWindow_Struct* CZDW = (CZDialogueWindow_Struct*)pack->pBuffer; + CZDW->update_type = update_type; + CZDW->update_identifier = update_identifier; + strn0cpy(CZDW->message, message, 4096); + strn0cpy(CZDW->client_name, client_name, 64); + worldserver.SendPacket(pack); + safe_delete(pack); +} + void QuestManager::CrossZoneLDoNUpdate(uint8 update_type, uint8 update_subtype, int update_identifier, uint32 theme_id, int points, const char* client_name) { auto pack = new ServerPacket(ServerOP_CZLDoNUpdate, sizeof(CZLDoNUpdate_Struct)); CZLDoNUpdate_Struct* CZLU = (CZLDoNUpdate_Struct*)pack->pBuffer; @@ -3568,6 +3579,16 @@ void QuestManager::CrossZoneTaskUpdate(uint8 update_type, uint8 update_subtype, safe_delete(pack); } +void QuestManager::WorldWideDialogueWindow(const char* message, uint8 min_status, uint8 max_status) { + auto pack = new ServerPacket(ServerOP_WWDialogueWindow, sizeof(WWDialogueWindow_Struct)); + WWDialogueWindow_Struct* WWDW = (WWDialogueWindow_Struct*)pack->pBuffer; + strn0cpy(WWDW->message, message, 4096); + WWDW->min_status = min_status; + WWDW->max_status = max_status; + worldserver.SendPacket(pack); + safe_delete(pack); +} + void QuestManager::WorldWideLDoNUpdate(uint8 update_type, uint32 theme_id, int points, uint8 min_status, uint8 max_status) { auto pack = new ServerPacket(ServerOP_WWLDoNUpdate, sizeof(WWLDoNUpdate_Struct)); WWLDoNUpdate_Struct* WWLU = (WWLDoNUpdate_Struct*)pack->pBuffer; diff --git a/zone/questmgr.h b/zone/questmgr.h index fa56f8dc2..00221c965 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -290,6 +290,7 @@ public: static std::string GetZoneLongName(std::string zone_short_name); static std::string GetZoneLongNameByID(uint32 zone_id); static std::string GetZoneShortName(uint32 zone_id); + void CrossZoneDialogueWindow(uint8 update_type, int update_identifier, const char* message, const char* client_name = ""); void CrossZoneLDoNUpdate(uint8 update_type, uint8 update_subtype, int update_identifier, uint32 theme_id, int points = 1, const char* client_name = ""); void CrossZoneMarquee(uint8 update_type, int update_identifier, uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, const char* message, const char* client_name = ""); void CrossZoneMessage(uint8 update_type, int update_identifier, uint32 type, const char* message, const char* client_name = ""); @@ -298,7 +299,8 @@ public: void CrossZoneSignal(uint8 update_type, int update_identifier, uint32 signal, const char* client_name = ""); void CrossZoneSpell(uint8 update_type, uint8 update_subtype, int update_identifier, uint32 spell_id, const char* client_name = ""); void CrossZoneTaskUpdate(uint8 update_type, uint8 update_subtype, int update_identifier, uint32 task_identifier, int task_subidentifier = -1, int update_count = 1, bool enforce_level_requirement = false, const char* client_name = ""); - void WorldWideLDoNUpdate(uint8 update_type, uint32 theme_id, int points = 1, uint8 min_status = 0, uint8 max_status = 0); + void WorldWideDialogueWindow(const char* message, uint8 min_status = 0, uint8 max_status = 0); + void WorldWideLDoNUpdate(uint8 update_type, uint32 theme_id, int points = 1, uint8 min_status = 0, uint8 max_status = 0); void WorldWideMarquee(uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, const char* message, uint8 min_status = 0, uint8 max_status = 0); void WorldWideMessage(uint32 type, const char* message, uint8 min_status = 0, uint8 max_status = 0); void WorldWideMove(uint8 update_type, const char* zone_short_name, uint16 instance_id = 0, uint8 min_status = 0, uint8 max_status = 0); diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 98fe2a0f3..36d1b7c22 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -56,6 +56,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "zone_reload.h" #include "../common/shared_tasks.h" #include "shared_task_zone_messaging.h" +#include "dialogue_window.h" extern EntityList entity_list; extern Zone* zone; @@ -1887,25 +1888,17 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_CZSpell: + case ServerOP_CZDialogueWindow: { - CZSpell_Struct* CZS = (CZSpell_Struct*) pack->pBuffer; - uint8 update_type = CZS->update_type; - uint8 update_subtype = CZS->update_subtype; - int update_identifier = CZS->update_identifier; - uint32 spell_id = CZS->spell_id; - const char* client_name = CZS->client_name; + CZDialogueWindow_Struct* CZDW = (CZDialogueWindow_Struct*) pack->pBuffer; + uint8 update_type = CZDW->update_type; + int update_identifier = CZDW->update_identifier; + std::string message = CZDW->message; + const char* client_name = CZDW->client_name; if (update_type == CZUpdateType_Character) { auto client = entity_list.GetClientByCharID(update_identifier); if (client) { - switch (update_subtype) { - case CZSpellUpdateSubtype_Cast: - client->SpellFinished(spell_id, client); - break; - case CZSpellUpdateSubtype_Remove: - client->BuffFadeBySpellID(spell_id); - break; - } + DialogueWindow::Render(client, message); } } else if (update_type == CZUpdateType_Group) { auto client_group = entity_list.GetGroupByID(update_identifier); @@ -1913,143 +1906,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) { if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) { auto group_member = client_group->members[member_index]->CastToClient(); - switch (update_subtype) { - case CZSpellUpdateSubtype_Cast: - group_member->SpellFinished(spell_id, group_member); - break; - case CZSpellUpdateSubtype_Remove: - group_member->BuffFadeBySpellID(spell_id); - break; - } - } - } - } - } else if (update_type == CZUpdateType_Raid) { - auto client_raid = entity_list.GetRaidByID(update_identifier); - if (client_raid) { - for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) { - if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) { - auto raid_member = client_raid->members[member_index].member->CastToClient(); - switch (update_subtype) { - case CZSpellUpdateSubtype_Cast: - raid_member->SpellFinished(spell_id, raid_member); - break; - case CZSpellUpdateSubtype_Remove: - raid_member->BuffFadeBySpellID(spell_id); - break; - } - } - } - } - } else if (update_type == CZUpdateType_Guild) { - for (auto &client: entity_list.GetClientList()) { - if (client.second->GuildID() > 0 && client.second->GuildID() == update_identifier) { - switch (update_subtype) { - case CZSpellUpdateSubtype_Cast: - client.second->SpellFinished(spell_id, client.second); - break; - case CZSpellUpdateSubtype_Remove: - client.second->BuffFadeBySpellID(spell_id); - break; - } - } - } - } else if (update_type == CZUpdateType_Expedition) { - for (auto &client: entity_list.GetClientList()) { - if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) { - switch (update_subtype) { - case CZSpellUpdateSubtype_Cast: - client.second->SpellFinished(spell_id, client.second); - break; - case CZSpellUpdateSubtype_Remove: - client.second->BuffFadeBySpellID(spell_id); - break; - } - } - } - } else if (update_type == CZUpdateType_ClientName) { - auto client = entity_list.GetClientByName(client_name); - if (client) { - switch (update_subtype) { - case CZSpellUpdateSubtype_Cast: - client->SpellFinished(spell_id, client); - break; - case CZSpellUpdateSubtype_Remove: - client->BuffFadeBySpellID(spell_id); - break; - } - } - } - break; - } - case ServerOP_CZTaskUpdate: - { - CZTaskUpdate_Struct* CZTU = (CZTaskUpdate_Struct*) pack->pBuffer; - uint8 update_type = CZTU->update_type; - uint8 update_subtype = CZTU->update_subtype; - int update_identifier = CZTU->update_identifier; - uint32 task_identifier = CZTU->task_identifier; - int task_subidentifier = CZTU->task_subidentifier; - int update_count = CZTU->update_count; - bool enforce_level_requirement = CZTU->enforce_level_requirement; - const char* client_name = CZTU->client_name; - if (update_type == CZUpdateType_Character) { - auto client = entity_list.GetClientByCharID(update_identifier); - if (client) { - switch (update_subtype) { - case CZTaskUpdateSubtype_ActivityReset: - client->ResetTaskActivity(task_identifier, task_subidentifier); - break; - case CZTaskUpdateSubtype_ActivityUpdate: - client->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); - break; - case CZTaskUpdateSubtype_AssignTask: - client->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); - break; - case CZTaskUpdateSubtype_DisableTask: - client->DisableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_EnableTask: - client->EnableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_FailTask: - client->FailTask(task_identifier); - break; - case CZTaskUpdateSubtype_RemoveTask: - client->RemoveTaskByTaskID(task_identifier); - break; - } - } - break; - } else if (update_type == CZUpdateType_Group) { - auto client_group = entity_list.GetGroupByID(update_identifier); - if (client_group) { - for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) { - if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) { - auto group_member = client_group->members[member_index]->CastToClient(); - switch (update_subtype) { - case CZTaskUpdateSubtype_ActivityReset: - group_member->ResetTaskActivity(task_identifier, task_subidentifier); - break; - case CZTaskUpdateSubtype_ActivityUpdate: - group_member->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); - break; - case CZTaskUpdateSubtype_AssignTask: - group_member->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); - break; - case CZTaskUpdateSubtype_DisableTask: - group_member->DisableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_EnableTask: - group_member->EnableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_FailTask: - group_member->FailTask(task_identifier); - break; - case CZTaskUpdateSubtype_RemoveTask: - group_member->RemoveTaskByTaskID(task_identifier); - break; - } + DialogueWindow::Render(group_member, message); } } } @@ -2059,114 +1916,26 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) { if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) { auto raid_member = client_raid->members[member_index].member->CastToClient(); - switch (update_subtype) { - case CZTaskUpdateSubtype_ActivityReset: - raid_member->ResetTaskActivity(task_identifier, task_subidentifier); - break; - case CZTaskUpdateSubtype_ActivityUpdate: - raid_member->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); - break; - case CZTaskUpdateSubtype_AssignTask: - raid_member->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); - break; - case CZTaskUpdateSubtype_DisableTask: - raid_member->DisableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_EnableTask: - raid_member->EnableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_FailTask: - raid_member->FailTask(task_identifier); - break; - case CZTaskUpdateSubtype_RemoveTask: - raid_member->RemoveTaskByTaskID(task_identifier); - break; - } + DialogueWindow::Render(raid_member, message); } } } } else if (update_type == CZUpdateType_Guild) { for (auto &client: entity_list.GetClientList()) { if (client.second->GuildID() > 0 && client.second->GuildID() == update_identifier) { - switch (update_subtype) { - case CZTaskUpdateSubtype_ActivityReset: - client.second->ResetTaskActivity(task_identifier, task_subidentifier); - break; - case CZTaskUpdateSubtype_ActivityUpdate: - client.second->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); - break; - case CZTaskUpdateSubtype_AssignTask: - client.second->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); - break; - case CZTaskUpdateSubtype_DisableTask: - client.second->DisableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_EnableTask: - client.second->EnableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_FailTask: - client.second->FailTask(task_identifier); - break; - case CZTaskUpdateSubtype_RemoveTask: - client.second->RemoveTaskByTaskID(task_identifier); - break; - } + DialogueWindow::Render(client.second, message); } - } + } } else if (update_type == CZUpdateType_Expedition) { for (auto &client: entity_list.GetClientList()) { if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) { - switch (update_subtype) { - case CZTaskUpdateSubtype_ActivityReset: - client.second->ResetTaskActivity(task_identifier, task_subidentifier); - break; - case CZTaskUpdateSubtype_ActivityUpdate: - client.second->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); - break; - case CZTaskUpdateSubtype_AssignTask: - client.second->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); - break; - case CZTaskUpdateSubtype_DisableTask: - client.second->DisableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_EnableTask: - client.second->EnableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_FailTask: - client.second->FailTask(task_identifier); - break; - case CZTaskUpdateSubtype_RemoveTask: - client.second->RemoveTaskByTaskID(task_identifier); - break; - } + DialogueWindow::Render(client.second, message); } } } else if (update_type == CZUpdateType_ClientName) { auto client = entity_list.GetClientByName(client_name); if (client) { - switch (update_subtype) { - case CZTaskUpdateSubtype_ActivityReset: - client->ResetTaskActivity(task_identifier, task_subidentifier); - break; - case CZTaskUpdateSubtype_ActivityUpdate: - client->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); - break; - case CZTaskUpdateSubtype_AssignTask: - client->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); - break; - case CZTaskUpdateSubtype_DisableTask: - client->DisableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_EnableTask: - client->EnableTask(1, reinterpret_cast(task_identifier)); - break; - case CZTaskUpdateSubtype_FailTask: - client->FailTask(task_identifier); - break; - case CZTaskUpdateSubtype_RemoveTask: - client->RemoveTaskByTaskID(task_identifier); - break; - } + DialogueWindow::Render(client, message); } } break; @@ -2620,6 +2389,303 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } + case ServerOP_CZSpell: + { + CZSpell_Struct* CZS = (CZSpell_Struct*) pack->pBuffer; + uint8 update_type = CZS->update_type; + uint8 update_subtype = CZS->update_subtype; + int update_identifier = CZS->update_identifier; + uint32 spell_id = CZS->spell_id; + const char* client_name = CZS->client_name; + if (update_type == CZUpdateType_Character) { + auto client = entity_list.GetClientByCharID(update_identifier); + if (client) { + switch (update_subtype) { + case CZSpellUpdateSubtype_Cast: + client->SpellFinished(spell_id, client); + break; + case CZSpellUpdateSubtype_Remove: + client->BuffFadeBySpellID(spell_id); + break; + } + } + } else if (update_type == CZUpdateType_Group) { + auto client_group = entity_list.GetGroupByID(update_identifier); + if (client_group) { + for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) { + if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) { + auto group_member = client_group->members[member_index]->CastToClient(); + switch (update_subtype) { + case CZSpellUpdateSubtype_Cast: + group_member->SpellFinished(spell_id, group_member); + break; + case CZSpellUpdateSubtype_Remove: + group_member->BuffFadeBySpellID(spell_id); + break; + } + } + } + } + } else if (update_type == CZUpdateType_Raid) { + auto client_raid = entity_list.GetRaidByID(update_identifier); + if (client_raid) { + for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) { + if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) { + auto raid_member = client_raid->members[member_index].member->CastToClient(); + switch (update_subtype) { + case CZSpellUpdateSubtype_Cast: + raid_member->SpellFinished(spell_id, raid_member); + break; + case CZSpellUpdateSubtype_Remove: + raid_member->BuffFadeBySpellID(spell_id); + break; + } + } + } + } + } else if (update_type == CZUpdateType_Guild) { + for (auto &client: entity_list.GetClientList()) { + if (client.second->GuildID() > 0 && client.second->GuildID() == update_identifier) { + switch (update_subtype) { + case CZSpellUpdateSubtype_Cast: + client.second->SpellFinished(spell_id, client.second); + break; + case CZSpellUpdateSubtype_Remove: + client.second->BuffFadeBySpellID(spell_id); + break; + } + } + } + } else if (update_type == CZUpdateType_Expedition) { + for (auto &client: entity_list.GetClientList()) { + if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) { + switch (update_subtype) { + case CZSpellUpdateSubtype_Cast: + client.second->SpellFinished(spell_id, client.second); + break; + case CZSpellUpdateSubtype_Remove: + client.second->BuffFadeBySpellID(spell_id); + break; + } + } + } + } else if (update_type == CZUpdateType_ClientName) { + auto client = entity_list.GetClientByName(client_name); + if (client) { + switch (update_subtype) { + case CZSpellUpdateSubtype_Cast: + client->SpellFinished(spell_id, client); + break; + case CZSpellUpdateSubtype_Remove: + client->BuffFadeBySpellID(spell_id); + break; + } + } + } + break; + } + case ServerOP_CZTaskUpdate: + { + CZTaskUpdate_Struct* CZTU = (CZTaskUpdate_Struct*) pack->pBuffer; + uint8 update_type = CZTU->update_type; + uint8 update_subtype = CZTU->update_subtype; + int update_identifier = CZTU->update_identifier; + uint32 task_identifier = CZTU->task_identifier; + int task_subidentifier = CZTU->task_subidentifier; + int update_count = CZTU->update_count; + bool enforce_level_requirement = CZTU->enforce_level_requirement; + const char* client_name = CZTU->client_name; + if (update_type == CZUpdateType_Character) { + auto client = entity_list.GetClientByCharID(update_identifier); + if (client) { + switch (update_subtype) { + case CZTaskUpdateSubtype_ActivityReset: + client->ResetTaskActivity(task_identifier, task_subidentifier); + break; + case CZTaskUpdateSubtype_ActivityUpdate: + client->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); + break; + case CZTaskUpdateSubtype_AssignTask: + client->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); + break; + case CZTaskUpdateSubtype_DisableTask: + client->DisableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_EnableTask: + client->EnableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_FailTask: + client->FailTask(task_identifier); + break; + case CZTaskUpdateSubtype_RemoveTask: + client->RemoveTaskByTaskID(task_identifier); + break; + } + } + break; + } else if (update_type == CZUpdateType_Group) { + auto client_group = entity_list.GetGroupByID(update_identifier); + if (client_group) { + for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) { + if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) { + auto group_member = client_group->members[member_index]->CastToClient(); + switch (update_subtype) { + case CZTaskUpdateSubtype_ActivityReset: + group_member->ResetTaskActivity(task_identifier, task_subidentifier); + break; + case CZTaskUpdateSubtype_ActivityUpdate: + group_member->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); + break; + case CZTaskUpdateSubtype_AssignTask: + group_member->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); + break; + case CZTaskUpdateSubtype_DisableTask: + group_member->DisableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_EnableTask: + group_member->EnableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_FailTask: + group_member->FailTask(task_identifier); + break; + case CZTaskUpdateSubtype_RemoveTask: + group_member->RemoveTaskByTaskID(task_identifier); + break; + } + } + } + } + } else if (update_type == CZUpdateType_Raid) { + auto client_raid = entity_list.GetRaidByID(update_identifier); + if (client_raid) { + for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) { + if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) { + auto raid_member = client_raid->members[member_index].member->CastToClient(); + switch (update_subtype) { + case CZTaskUpdateSubtype_ActivityReset: + raid_member->ResetTaskActivity(task_identifier, task_subidentifier); + break; + case CZTaskUpdateSubtype_ActivityUpdate: + raid_member->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); + break; + case CZTaskUpdateSubtype_AssignTask: + raid_member->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); + break; + case CZTaskUpdateSubtype_DisableTask: + raid_member->DisableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_EnableTask: + raid_member->EnableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_FailTask: + raid_member->FailTask(task_identifier); + break; + case CZTaskUpdateSubtype_RemoveTask: + raid_member->RemoveTaskByTaskID(task_identifier); + break; + } + } + } + } + } else if (update_type == CZUpdateType_Guild) { + for (auto &client: entity_list.GetClientList()) { + if (client.second->GuildID() > 0 && client.second->GuildID() == update_identifier) { + switch (update_subtype) { + case CZTaskUpdateSubtype_ActivityReset: + client.second->ResetTaskActivity(task_identifier, task_subidentifier); + break; + case CZTaskUpdateSubtype_ActivityUpdate: + client.second->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); + break; + case CZTaskUpdateSubtype_AssignTask: + client.second->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); + break; + case CZTaskUpdateSubtype_DisableTask: + client.second->DisableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_EnableTask: + client.second->EnableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_FailTask: + client.second->FailTask(task_identifier); + break; + case CZTaskUpdateSubtype_RemoveTask: + client.second->RemoveTaskByTaskID(task_identifier); + break; + } + } + } + } else if (update_type == CZUpdateType_Expedition) { + for (auto &client: entity_list.GetClientList()) { + if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) { + switch (update_subtype) { + case CZTaskUpdateSubtype_ActivityReset: + client.second->ResetTaskActivity(task_identifier, task_subidentifier); + break; + case CZTaskUpdateSubtype_ActivityUpdate: + client.second->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); + break; + case CZTaskUpdateSubtype_AssignTask: + client.second->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); + break; + case CZTaskUpdateSubtype_DisableTask: + client.second->DisableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_EnableTask: + client.second->EnableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_FailTask: + client.second->FailTask(task_identifier); + break; + case CZTaskUpdateSubtype_RemoveTask: + client.second->RemoveTaskByTaskID(task_identifier); + break; + } + } + } + } else if (update_type == CZUpdateType_ClientName) { + auto client = entity_list.GetClientByName(client_name); + if (client) { + switch (update_subtype) { + case CZTaskUpdateSubtype_ActivityReset: + client->ResetTaskActivity(task_identifier, task_subidentifier); + break; + case CZTaskUpdateSubtype_ActivityUpdate: + client->UpdateTaskActivity(task_identifier, task_subidentifier, update_count); + break; + case CZTaskUpdateSubtype_AssignTask: + client->AssignTask(task_identifier, task_subidentifier, enforce_level_requirement); + break; + case CZTaskUpdateSubtype_DisableTask: + client->DisableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_EnableTask: + client->EnableTask(1, reinterpret_cast(task_identifier)); + break; + case CZTaskUpdateSubtype_FailTask: + client->FailTask(task_identifier); + break; + case CZTaskUpdateSubtype_RemoveTask: + client->RemoveTaskByTaskID(task_identifier); + break; + } + } + } + break; + } + case ServerOP_WWDialogueWindow: + { + WWDialogueWindow_Struct* WWDW = (WWDialogueWindow_Struct*) pack->pBuffer; + std::string message = WWDW->message; + uint8 min_status = WWDW->min_status; + uint8 max_status = WWDW->max_status; + for (auto &client : entity_list.GetClientList()) { + if (client.second->Admin() >= min_status && (client.second->Admin() <= max_status || max_status == 0)) { + DialogueWindow::Render(client.second, message); + } + } + break; + } case ServerOP_WWLDoNUpdate: { WWLDoNUpdate_Struct* WWLU = (WWLDoNUpdate_Struct*) pack->pBuffer;