From c09ab507dd7fdb8c10ecd3296b80b1f07dcb9e3c Mon Sep 17 00:00:00 2001 From: Xackery Date: Wed, 14 Mar 2018 13:54:08 -0700 Subject: [PATCH] Added opcode support for aaaction, aaexpupdate, zonecompleted. --- common/message.proto | 30 ++++++++++--- zone/aa.cpp | 7 ++++ zone/client_packet.cpp | 3 ++ zone/nats_manager.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++ zone/nats_manager.h | 23 +++++----- 5 files changed, 143 insertions(+), 15 deletions(-) diff --git a/common/message.proto b/common/message.proto index 02fc9b726..efc5807fd 100644 --- a/common/message.proto +++ b/common/message.proto @@ -386,6 +386,26 @@ message SpawnEvent { bool show_name= 100; } +message AlternateAdvancementStatsEvent { + uint32 experience = 1; + uint32 unspent = 2; + uint32 unknown006 = 3; + uint32 percentage = 4; + uint32 unknown009 = 5; +} + +message ZoneCompleteEvent { + +} + +message UseAAEvent { + uint32 begin = 1; + uint32 ability = 2; + uint32 end = 3; + uint32 action = 4; + uint32 target_id = 5; + uint32 exp_value = 6; +} //EntityType will attempt to identify an entity to it's upper-most type by default enum EntityType { @@ -606,11 +626,11 @@ enum GenderType { enum OpCode { //option allow_alias = true; OP_Unknown = 0; - OP_ExploreUnknown = 1; - OP_0x0193 = 2; - OP_0x0347 = 3; - OP_AAAction = 4; - OP_AAExpUpdate = 5; + OP_ExploreUnknown = 1; //Not used + OP_0x0193 = 2; //Not used + OP_ZoneCompleted = 3; //supported, internally OP_0x0347 + OP_AAAction = 4; //supported + OP_AAExpUpdate = 5; //supported OP_AcceptNewTask = 6; OP_AckPacket = 7; OP_Action = 8; diff --git a/zone/aa.cpp b/zone/aa.cpp index 38d477fb8..43113ae15 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -27,6 +27,7 @@ Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) #include "client.h" #include "corpse.h" #include "groups.h" +#include "nats_manager.h" #include "mob.h" #include "queryserv.h" #include "raids.h" @@ -35,6 +36,7 @@ Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) #include "zonedb.h" extern QueryServ* QServ; +extern NatsManager nats; void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, uint32 duration_override, bool followme, bool sticktarg) { @@ -922,6 +924,7 @@ void Client::SendAlternateAdvancementStats() { aps->percentage = m_epp.perAA; QueuePacket(outapp); safe_delete(outapp); + nats.OnAlternateAdvancementStats(GetID(), aps); } void Client::SendAlternateAdvancementPoints() { @@ -957,6 +960,7 @@ void Client::SendAlternateAdvancementTimer(int ability, int begin, int end) { uaaout->end = end; QueuePacket(outapp); safe_delete(outapp); + nats.OnAlternateAdvancementAction(GetID(), uaaout); } //sends all AA timers. @@ -976,6 +980,7 @@ void Client::SendAlternateAdvancementTimers() { uaaout->begin = cur->GetStartTime(); uaaout->end = static_cast(time(nullptr)); uaaout->ability = cur->GetType() - pTimerAAStart; // uuaaout->ability is really a shared timer number + nats.OnAlternateAdvancementAction(GetID(), uaaout); QueuePacket(outapp); } @@ -1008,6 +1013,8 @@ void Client::ResetAlternateAdvancementTimers() { uaaout->ability = cur->GetType() - pTimerAAStart; r_timers.push_back(cur->GetType()); QueuePacket(outapp); + + nats.OnAlternateAdvancementAction(GetID(), uaaout); } for(auto &i : r_timers) { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 466b49b1b..b205deb52 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1226,6 +1226,7 @@ void Client::Handle_Connect_OP_ZoneComplete(const EQApplicationPacket *app) auto outapp = new EQApplicationPacket(OP_0x0347, 0); QueuePacket(outapp); safe_delete(outapp); + nats.OnZoneComplete(GetID()); return; } @@ -1799,6 +1800,8 @@ void Client::Handle_OP_AAAction(const EQApplicationPacket *app) } AA_Action* action = (AA_Action*)app->pBuffer; + nats.OnAlternateAdvancementActionRequest(GetID(), action); + if (action->action == aaActionActivate) {//AA Hotkey Log(Logs::Detail, Logs::AA, "Activating AA %d", action->ability); ActivateAlternateAdvancementAbility(action->ability, action->target_id); diff --git a/zone/nats_manager.cpp b/zone/nats_manager.cpp index 4302531cf..9b6a135f8 100644 --- a/zone/nats_manager.cpp +++ b/zone/nats_manager.cpp @@ -1275,4 +1275,99 @@ void NatsManager::OnAnimationEvent(uint32 entity_id, Animation_Struct *anim) { return; } SendEvent(op, entity_id, event_buffer, event_size); +} + + +void NatsManager::OnAlternateAdvancementStats(uint32 entity_id, AltAdvStats_Struct * aas) { + if (!connect()) + return; + if (entity_id == 0) + return; + if (!isEntityEventAllEnabled && !isEntitySubscribed(entity_id)) + return; + + auto op = eqproto::OP_AAExpUpdate; + + eqproto::AlternateAdvancementStatsEvent* event = google::protobuf::Arena::CreateMessage(&the_arena); + event->set_experience(aas->experience); + event->set_unspent(aas->unspent); + event->set_unknown006(aas->unknown006); + //event->set_unknown009(aas->unknown009); + + size_t event_size = event->ByteSizeLong(); + void *event_buffer = malloc(event_size); + if (!event->SerializeToArray(event_buffer, event_size)) { + Log(Logs::General, Logs::NATS, "zone.%s.%d.entity.%d.event.out: (OP: %d) failed to serialize message", subscribedZoneName.c_str(), subscribedZoneInstance, entity_id, op); + return; + } + SendEvent(op, entity_id, event_buffer, event_size); +} + + +void NatsManager::OnZoneComplete(uint32 entity_id) { + if (!connect()) + return; + if (entity_id == 0) + return; + if (!isEntityEventAllEnabled && !isEntitySubscribed(entity_id)) + return; + + auto op = eqproto::OP_ZoneCompleted; + + eqproto::ZoneCompleteEvent* event = google::protobuf::Arena::CreateMessage(&the_arena); + + size_t event_size = event->ByteSizeLong(); + void *event_buffer = malloc(event_size); + if (!event->SerializeToArray(event_buffer, event_size)) { + Log(Logs::General, Logs::NATS, "zone.%s.%d.entity.%d.event.out: (OP: %d) failed to serialize message", subscribedZoneName.c_str(), subscribedZoneInstance, entity_id, op); + return; + } + SendEvent(op, entity_id, event_buffer, event_size); +} + +void NatsManager::OnAlternateAdvancementAction(uint32 entity_id, UseAA_Struct * uaas) { + if (!connect()) + return; + if (entity_id == 0) + return; + if (!isEntityEventAllEnabled && !isEntitySubscribed(entity_id)) + return; + + auto op = eqproto::OP_AAAction; + + eqproto::UseAAEvent* event = google::protobuf::Arena::CreateMessage(&the_arena); + event->set_begin(uaas->begin); + event->set_ability(uaas->ability); + event->set_end(uaas->end); + size_t event_size = event->ByteSizeLong(); + void *event_buffer = malloc(event_size); + if (!event->SerializeToArray(event_buffer, event_size)) { + Log(Logs::General, Logs::NATS, "zone.%s.%d.entity.%d.event.out: (OP: %d) failed to serialize message", subscribedZoneName.c_str(), subscribedZoneInstance, entity_id, op); + return; + } + SendEvent(op, entity_id, event_buffer, event_size); +} + +void NatsManager::OnAlternateAdvancementActionRequest(uint32 entity_id, AA_Action* action) { + if (!connect()) + return; + if (entity_id == 0) + return; + if (!isEntityEventAllEnabled && !isEntitySubscribed(entity_id)) + return; + + auto op = eqproto::OP_AAAction; + + eqproto::UseAAEvent* event = google::protobuf::Arena::CreateMessage(&the_arena); + event->set_ability(action->ability); + event->set_target_id(action->target_id); + event->set_exp_value(action->exp_value); + event->set_action(action->action); + size_t event_size = event->ByteSizeLong(); + void *event_buffer = malloc(event_size); + if (!event->SerializeToArray(event_buffer, event_size)) { + Log(Logs::General, Logs::NATS, "zone.%s.%d.entity.%d.event.out: (OP: %d) failed to serialize message", subscribedZoneName.c_str(), subscribedZoneInstance, entity_id, op); + return; + } + SendEvent(op, entity_id, event_buffer, event_size); } \ No newline at end of file diff --git a/zone/nats_manager.h b/zone/nats_manager.h index 0f5ce1e21..ae7dd15d9 100644 --- a/zone/nats_manager.h +++ b/zone/nats_manager.h @@ -31,18 +31,21 @@ public: void SendAdminMessage(std::string adminMessage); void SendEvent(eqproto::OpCode op, uint32 entity_id, void * buffer, size_t size); - void OnChannelMessageEvent(uint32 entity_id, ChannelMessage_Struct * cm); - void OnSpecialMessageEvent(uint32 entity_id, SpecialMesg_Struct *sm); - void OnEntityEvent(const EmuOpcode op, uint32 entity_id, uint32 target_id); - void OnSpawnEvent(const EmuOpcode op, uint32 entity_id, Spawn_Struct * spawn); - void OnWearChangeEvent(uint32 entity_id, WearChange_Struct * wc); - void OnDeleteSpawnEvent(uint32 entity_id, DeleteSpawn_Struct * ds); - void OnHPEvent(const EmuOpcode op, uint32 entity_id, uint32 cur_hp, uint32 max_hp); - void OnDamageEvent(uint32 entity_id, CombatDamage_Struct * cd); - void OnClientUpdateEvent(uint32 entity_id, PlayerPositionUpdateServer_Struct * spu); + void OnAlternateAdvancementStats(uint32 entity_id, AltAdvStats_Struct * aas); + void OnAlternateAdvancementAction(uint32 entity_id, UseAA_Struct * uaas); + void OnAlternateAdvancementActionRequest(uint32 entity_id, AA_Action* action); void OnAnimationEvent(uint32 entity_id, Animation_Struct * anim); + void OnChannelMessageEvent(uint32 entity_id, ChannelMessage_Struct * cm); + void OnClientUpdateEvent(uint32 entity_id, PlayerPositionUpdateServer_Struct * spu); + void OnDamageEvent(uint32 entity_id, CombatDamage_Struct * cd); void OnDeathEvent(Death_Struct * d); - + void OnDeleteSpawnEvent(uint32 entity_id, DeleteSpawn_Struct * ds); + void OnEntityEvent(const EmuOpcode op, uint32 entity_id, uint32 target_id); + void OnHPEvent(const EmuOpcode op, uint32 entity_id, uint32 cur_hp, uint32 max_hp); + void OnSpawnEvent(const EmuOpcode op, uint32 entity_id, Spawn_Struct * spawn); + void OnSpecialMessageEvent(uint32 entity_id, SpecialMesg_Struct *sm); + void OnWearChangeEvent(uint32 entity_id, WearChange_Struct * wc); + void OnZoneComplete(uint32 entity_id); protected: bool connect();