From 74fde3972b5888619cd56456373aa8085f94d42e Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Fri, 12 Feb 2021 22:31:02 -0500 Subject: [PATCH] [Quest API] Add Adventure methods to Perl and Lua. --- world/adventure.cpp | 3 +- world/adventure.h | 1 - world/adventure_manager.cpp | 10 +- zone/client.cpp | 12 +-- zone/client.h | 2 +- zone/client_packet.cpp | 11 +- zone/embparser_api.cpp | 196 ++++++++++++++++++++++++++++++++++++ zone/lua_general.cpp | 73 +++++++++++++- zone/questmgr.cpp | 112 +++++++++++++++++++++ zone/questmgr.h | 15 +++ zone/worldserver.cpp | 4 - 11 files changed, 408 insertions(+), 31 deletions(-) diff --git a/world/adventure.cpp b/world/adventure.cpp index 43b208e04..59d76ada0 100644 --- a/world/adventure.cpp +++ b/world/adventure.cpp @@ -434,5 +434,4 @@ int Adventure::GetAverageLevel() const void Adventure::SetAverageLevel(int average_level) { Adventure::average_level = average_level; -} - +} \ No newline at end of file diff --git a/world/adventure.h b/world/adventure.h index d5e8401d9..d77eb057e 100644 --- a/world/adventure.h +++ b/world/adventure.h @@ -99,7 +99,6 @@ protected: Timer *current_timer; int instance_id; int average_level; - }; #endif diff --git a/world/adventure_manager.cpp b/world/adventure_manager.cpp index c16e6f80d..217e1a885 100644 --- a/world/adventure_manager.cpp +++ b/world/adventure_manager.cpp @@ -334,13 +334,11 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) ServerAdventureRequestAccept_Struct *sra = (ServerAdventureRequestAccept_Struct*)pack->pBuffer; strcpy(sra->leader, sar->leader); strcpy(sra->text, (*ea_iter)->text); + uint32 iter_id = (*ea_iter)->id; sra->theme = sar->template_id; - sra->id = (*ea_iter)->id; + sra->id = iter_id; sra->member_count = sar->member_count; sra->average_level = avg_level; - - LogAdventure("[AdventureManager::CalculateAdventureRequestReply] Adventure average level [{}]", avg_level); - memcpy((pack->pBuffer + sizeof(ServerAdventureRequestAccept_Struct)), (data + sizeof(ServerAdventureRequest_Struct)), (sar->member_count * 64)); zoneserver_list.SendPacket(leader->zone(), leader->instance(), pack); delete pack; @@ -447,7 +445,6 @@ void AdventureManager::TryAdventureCreate(const char *data) } adv->SetAverageLevel(src->average_level); - adventure_list.push_back(adv); } @@ -943,9 +940,6 @@ void AdventureManager::GetZoneData(uint16 instance_id) zd->dest_z = temp->dest_z; zd->dest_h = temp->dest_h; zd->average_level = current->GetAverageLevel(); - - LogAdventure("[AdventureManager::GetZoneData] Adventure average level [{}]", zd->average_level); - zoneserver_list.SendPacket(0, instance_id, pack); delete pack; } diff --git a/zone/client.cpp b/zone/client.cpp index e1312f796..755784f37 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -325,7 +325,7 @@ Client::Client(EQStreamInterface* ieqs) adv_requested_theme = 0; adv_requested_id = 0; adv_requested_member_count = 0; - adv_requested_avg_lvl = 0; + adv_requested_average_lvl = 0; for(int i = 0; i < XTARGET_HARDCAP; ++i) { @@ -5993,17 +5993,14 @@ void Client::NewAdventure(int id, int theme, const char *text, int member_count, strn0cpy((char*)outapp->pBuffer, text, text_size); FastQueuePacket(&outapp); - adv_requested_id = id; + adv_requested_id = id; adv_requested_theme = theme; safe_delete_array(adv_requested_data); adv_requested_member_count = member_count; - adv_requested_avg_lvl = avg_level; - adv_requested_data = new char[64 * member_count]; - - LogAdventure("[Client::NewAdventure] Adventure average level [{}]", adv_requested_avg_lvl); - + adv_requested_average_lvl = avg_level; + adv_requested_data = new char[64 * member_count]; memcpy(adv_requested_data, members, (64 * member_count)); } @@ -6013,6 +6010,7 @@ void Client::ClearPendingAdventureData() adv_requested_theme = 0; safe_delete_array(adv_requested_data); adv_requested_member_count = 0; + adv_requested_average_lvl = 0; } bool Client::IsOnAdventure() diff --git a/zone/client.h b/zone/client.h index 4d65cd467..c967da77a 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1613,7 +1613,7 @@ protected: int adv_requested_theme; int adv_requested_id; char *adv_requested_data; - uint32 adv_requested_avg_lvl; + uint32 adv_requested_average_lvl; int adv_requested_member_count; char *adv_data; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index e281406f9..9f550a6ca 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9045,13 +9045,10 @@ void Client::Handle_OP_LDoNButton(const EQApplicationPacket *app) ServerAdventureRequestCreate_Struct *sac = (ServerAdventureRequestCreate_Struct *) pack->pBuffer; strcpy(sac->leader, GetName()); - sac->id = adv_requested_id; - sac->theme = adv_requested_theme; - sac->member_count = adv_requested_member_count; - sac->average_level = adv_requested_avg_lvl; - - LogAdventure("[Client::Handle_OP_LDoNButton] Adventure average level [{}]", sac->average_level); - + sac->id = adv_requested_id; + sac->theme = adv_requested_theme; + sac->member_count = adv_requested_member_count; + sac->average_level = adv_requested_average_lvl; memcpy((pack->pBuffer + sizeof(ServerAdventureRequestCreate_Struct)), adv_requested_data, (64 * adv_requested_member_count)); worldserver.SendPacket(pack); delete pack; diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 0fa68aa64..3e57e2d00 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -6404,6 +6404,188 @@ XS(XS__createitem) { XSRETURN(1); } +XS(XS__get_adventure_assassination_count); +XS(XS__get_adventure_assassination_count) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_assassination_count()"); + } + dXSTARG; + int assassination_count = quest_manager.GetAdventureAssassinationCount(); + XSprePUSH; + PUSHi((IV)assassination_count); + XSRETURN(1); +} + +XS(XS__get_adventure_assassination_x); +XS(XS__get_adventure_assassination_x) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_assassination_x()"); + } + dXSTARG; + int assassination_x = quest_manager.GetAdventureAssassinationX(); + XSprePUSH; + PUSHi((IV)assassination_x); + XSRETURN(1); +} + +XS(XS__get_adventure_assassination_y); +XS(XS__get_adventure_assassination_y) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_assassination_y()"); + } + dXSTARG; + int assassination_y = quest_manager.GetAdventureAssassinationY(); + XSprePUSH; + PUSHi((IV)assassination_y); + XSRETURN(1); +} + +XS(XS__get_adventure_assassination_z); +XS(XS__get_adventure_assassination_z) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_assassination_z()"); + } + dXSTARG; + int assassination_z = quest_manager.GetAdventureAssassinationZ(); + XSprePUSH; + PUSHi((IV)assassination_z); + XSRETURN(1); +} + +XS(XS__get_adventure_assassination_h); +XS(XS__get_adventure_assassination_h) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_assassination_h()"); + } + dXSTARG; + int assassination_h = quest_manager.GetAdventureAssassinationH(); + XSprePUSH; + PUSHi((IV)assassination_h); + XSRETURN(1); +} + +XS(XS__get_adventure_average_level); +XS(XS__get_adventure_average_level) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_average_level()"); + } + dXSTARG; + int average_level = quest_manager.GetAdventureAverageLevel(); + XSprePUSH; + PUSHi((IV)average_level); + XSRETURN(1); +} + +XS(XS__get_adventure_count); +XS(XS__get_adventure_count) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_count()"); + } + dXSTARG; + int count = quest_manager.GetAdventureCount(); + XSprePUSH; + PUSHi((IV)count); + XSRETURN(1); +} + +XS(XS__get_adventure_data_id); +XS(XS__get_adventure_data_id) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_data_id()"); + } + dXSTARG; + int data_id = quest_manager.GetAdventureDataID(); + XSprePUSH; + PUSHi((IV)data_id); + XSRETURN(1); +} + +XS(XS__get_adventure_destination_x); +XS(XS__get_adventure_destination_x) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_destination_x()"); + } + dXSTARG; + int destination_x = quest_manager.GetAdventureDestinationX(); + XSprePUSH; + PUSHi((IV)destination_x); + XSRETURN(1); +} + +XS(XS__get_adventure_destination_y); +XS(XS__get_adventure_destination_y) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_destination_y()"); + } + dXSTARG; + int destination_y = quest_manager.GetAdventureDestinationY(); + XSprePUSH; + PUSHi((IV)destination_y); + XSRETURN(1); +} + +XS(XS__get_adventure_destination_z); +XS(XS__get_adventure_destination_z) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_destination_z()"); + } + dXSTARG; + int destination_z = quest_manager.GetAdventureDestinationZ(); + XSprePUSH; + PUSHi((IV)destination_z); + XSRETURN(1); +} + +XS(XS__get_adventure_destination_h); +XS(XS__get_adventure_destination_h) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_destination_h()"); + } + dXSTARG; + int destination_h = quest_manager.GetAdventureDestinationH(); + XSprePUSH; + PUSHi((IV)destination_h); + XSRETURN(1); +} + +XS(XS__get_adventure_total); +XS(XS__get_adventure_total) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_total()"); + } + dXSTARG; + int total = quest_manager.GetAdventureTotal(); + XSprePUSH; + PUSHi((IV)total); + XSRETURN(1); +} + +XS(XS__get_adventure_type); +XS(XS__get_adventure_type) { + dXSARGS; + if (items >= 1) { + Perl_croak(aTHX_ "Usage: quest::get_adventure_type()"); + } + dXSTARG; + int type = quest_manager.GetAdventureType(); + XSprePUSH; + PUSHi((IV)type); + XSRETURN(1); +} + /* This is the callback perl will look for to setup the quest package's XSUBs @@ -6608,6 +6790,20 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "follow"), XS__follow, file); newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file); newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file); + newXS(strcpy(buf, "get_adventure_assassination_count"), XS__get_adventure_assassination_count, file); + newXS(strcpy(buf, "get_adventure_assassination_x"), XS__get_adventure_assassination_x, file); + newXS(strcpy(buf, "get_adventure_assassination_y"), XS__get_adventure_assassination_y, file); + newXS(strcpy(buf, "get_adventure_assassination_z"), XS__get_adventure_assassination_z, file); + newXS(strcpy(buf, "get_adventure_assassination_h"), XS__get_adventure_assassination_h, file); + newXS(strcpy(buf, "get_adventure_average_level"), XS__get_adventure_average_level, file); + newXS(strcpy(buf, "get_adventure_count"), XS__get_adventure_count, file); + newXS(strcpy(buf, "get_adventure_data_id"), XS__get_adventure_data_id, file); + newXS(strcpy(buf, "get_adventure_destination_x"), XS__get_adventure_destination_x, file); + newXS(strcpy(buf, "get_adventure_destination_y"), XS__get_adventure_destination_y, file); + newXS(strcpy(buf, "get_adventure_destination_z"), XS__get_adventure_destination_z, file); + newXS(strcpy(buf, "get_adventure_destination_h"), XS__get_adventure_destination_h, file); + newXS(strcpy(buf, "get_adventure_total"), XS__get_adventure_total, file); + newXS(strcpy(buf, "get_adventure_type"), XS__get_adventure_type, file); newXS(strcpy(buf, "getcharidbyname"), XS__getcharidbyname, file); newXS(strcpy(buf, "getclassname"), XS__getclassname, file); newXS(strcpy(buf, "getcurrencyid"), XS__getcurrencyid, file); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index b903ca774..190df5adf 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -2300,6 +2300,62 @@ void lua_remove_all_expedition_lockouts_by_char_id(uint32 char_id, std::string e Expedition::RemoveLockoutsByCharacterID(char_id, expedition_name); } +int lua_get_adventure_assassination_count() { + return quest_manager.GetAdventureAssassinationCount(); +} + +int lua_get_adventure_assassination_x() { + return quest_manager.GetAdventureAssassinationX(); +} + +int lua_get_adventure_assassination_y() { + return quest_manager.GetAdventureAssassinationY(); +} + +int lua_get_adventure_assassination_z() { + return quest_manager.GetAdventureAssassinationZ(); +} + +int lua_get_adventure_assassination_h() { + return quest_manager.GetAdventureAssassinationH(); +} + +int lua_get_adventure_average_level() { + return quest_manager.GetAdventureAverageLevel(); +} + +int lua_get_adventure_count() { + return quest_manager.GetAdventureCount(); +} + +int lua_get_adventure_data_id() { + return quest_manager.GetAdventureDataID(); +} + +int lua_get_adventure_destination_x() { + return quest_manager.GetAdventureDestinationX(); +} + +int lua_get_adventure_destination_y() { + return quest_manager.GetAdventureDestinationY(); +} + +int lua_get_adventure_destination_z() { + return quest_manager.GetAdventureDestinationZ(); +} + +int lua_get_adventure_destination_h() { + return quest_manager.GetAdventureDestinationH(); +} + +int lua_get_adventure_total() { + return quest_manager.GetAdventureTotal(); +} + +int lua_get_adventure_type() { + return quest_manager.GetAdventureType(); +} + #define LuaCreateNPCParse(name, c_type, default_value) do { \ cur = table[#name]; \ if(luabind::type(cur) != LUA_TNIL) { \ @@ -2914,7 +2970,22 @@ luabind::scope lua_register_general() { luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_by_char_id), luabind::def("remove_expedition_lockout_by_char_id", &lua_remove_expedition_lockout_by_char_id), luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32))&lua_remove_all_expedition_lockouts_by_char_id), - luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32, std::string))&lua_remove_all_expedition_lockouts_by_char_id) + luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32, std::string))&lua_remove_all_expedition_lockouts_by_char_id), + + luabind::def("get_adventure_assassination_count", &lua_get_adventure_assassination_count), + luabind::def("get_adventure_assassination_x", &lua_get_adventure_assassination_x), + luabind::def("get_adventure_assassination_y", &lua_get_adventure_assassination_y), + luabind::def("get_adventure_assassination_z", &lua_get_adventure_assassination_z), + luabind::def("get_adventure_assassination_h", &lua_get_adventure_assassination_h), + luabind::def("get_adventure_average_level", &lua_get_adventure_average_level), + luabind::def("get_adventure_count", &lua_get_adventure_count), + luabind::def("get_adventure_data_id", &lua_get_adventure_data_id), + luabind::def("get_adventure_destination_x", &lua_get_adventure_destination_x), + luabind::def("get_adventure_destination_y", &lua_get_adventure_destination_y), + luabind::def("get_adventure_destination_z", &lua_get_adventure_destination_z), + luabind::def("get_adventure_destination_h", &lua_get_adventure_destination_h), + luabind::def("get_adventure_total", &lua_get_adventure_total), + luabind::def("get_adventure_type", &lua_get_adventure_type) ]; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index a61a4e856..3003e3beb 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -4234,3 +4234,115 @@ EQ::ItemInstance *QuestManager::CreateItem(uint32 item_id, int16 charges, uint32 } return nullptr; } + +int QuestManager::GetAdventureAssassinationCount() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->assa_count; + } + return 0; +} + +int QuestManager::GetAdventureAssassinationX() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->assa_x; + } + return 0; +} + +int QuestManager::GetAdventureAssassinationY() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->assa_y; + } + return 0; +} + +int QuestManager::GetAdventureAssassinationZ() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->assa_z; + } + return 0; +} + +int QuestManager::GetAdventureAssassinationH() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->assa_h; + } + return 0; +} + +int QuestManager::GetAdventureAverageLevel() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->average_level; + } + return 0; +} + +int QuestManager::GetAdventureCount() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->count; + } + return 0; +} + +int QuestManager::GetAdventureDataID() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->data_id; + } + return 0; +} + +int QuestManager::GetAdventureDestinationX() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->dest_x; + } + return 0; +} + +int QuestManager::GetAdventureDestinationY() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->dest_y; + } + return 0; +} + +int QuestManager::GetAdventureDestinationZ() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->dest_z; + } + return 0; +} + +int QuestManager::GetAdventureDestinationH() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->dest_h; + } + return 0; +} + +int QuestManager::GetAdventureTotal() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->total; + } + return 0; +} + +int QuestManager::GetAdventureType() { + if (zone->adv_data) { + ServerZoneAdventureDataReply_Struct *adventure_data = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; + return adventure_data->type; + } + return 0; +} diff --git a/zone/questmgr.h b/zone/questmgr.h index 0ce21ccc4..3cfa5c60d 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -370,6 +370,21 @@ public: void ClearNPCTypeCache(int npctype_id); void ReloadZoneStaticData(); + int GetAdventureAssassinationCount(); + int GetAdventureAssassinationX(); + int GetAdventureAssassinationY(); + int GetAdventureAssassinationZ(); + int GetAdventureAssassinationH(); + int GetAdventureAverageLevel(); + int GetAdventureCount(); + int GetAdventureDataID(); + int GetAdventureDestinationX(); + int GetAdventureDestinationY(); + int GetAdventureDestinationZ(); + int GetAdventureDestinationH(); + int GetAdventureTotal(); + int GetAdventureType(); + Client *GetInitiator() const; NPC *GetNPC() const; Mob *GetOwner() const; diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index ef14e208b..18d45b773 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -1688,8 +1688,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Client *c = entity_list.GetClientByName(ars->leader); if (c) { - LogAdventure("[ServerOP_AdventureRequestAccept] Adventure average level [{}]", ars->average_level); - c->NewAdventure( ars->id, ars->theme, @@ -1820,8 +1818,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) zone->adv_data = new char[pack->size]; memcpy(zone->adv_data, pack->pBuffer, pack->size); ServerZoneAdventureDataReply_Struct* ds = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; - - LogAdventure("[ServerOP_AdventureZoneData] Adventure average level [{}]", ds->average_level); } break; }