From d92c0e330d2d2314c3fccc5f46edad7d9b9bada1 Mon Sep 17 00:00:00 2001 From: hg <4683435+hgtw@users.noreply.github.com> Date: Fri, 15 May 2020 17:58:07 -0400 Subject: [PATCH] Validate expedition invite response server side Stores expedition invite data on client --- zone/client.h | 9 ++++----- zone/client_packet.cpp | 7 ++++--- zone/expedition.cpp | 11 +++++------ zone/expedition.h | 9 ++++++++- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/zone/client.h b/zone/client.h index 353466687..58b0e8643 100644 --- a/zone/client.h +++ b/zone/client.h @@ -21,8 +21,6 @@ class Client; class EQApplicationPacket; class EQStream; -class Expedition; -class ExpeditionLockoutTimer; class Group; class NPC; class Object; @@ -54,6 +52,7 @@ namespace EQ #include "aggromanager.h" #include "common.h" +#include "expedition.h" #include "dynamiczone.h" #include "merc.h" #include "mob.h" @@ -1126,14 +1125,14 @@ public: const std::string& expedition_name, const std::string& event_name, bool include_expired = false) const; const std::vector& GetExpeditionLockouts() const { return m_expedition_lockouts; }; std::vector GetExpeditionLockouts(const std::string& expedition_name); - uint32 GetPendingExpeditionInviteID() const { return m_pending_expedition_invite_id; } + uint32 GetPendingExpeditionInviteID() const { return m_pending_expedition_invite.expedition_id; } bool HasExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool include_expired = false); bool IsInExpedition() const { return m_expedition_id != 0; } void RemoveAllExpeditionLockouts(std::string expedition_name = {}); void RemoveExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool update_db = false); - void SetPendingExpeditionInvite(uint32 id) { m_pending_expedition_invite_id = id; } void SendExpeditionLockoutTimers(); void SetExpeditionID(uint32 expedition_id) { m_expedition_id = expedition_id; }; + void SetPendingExpeditionInvite(ExpeditionInvite&& invite) { m_pending_expedition_invite = invite; } void LoadAllExpeditionLockouts(); void UpdateExpeditionInfoAndLockouts(); void DzListTimers(); @@ -1699,7 +1698,7 @@ private: int client_max_level; uint32 m_expedition_id = 0; - uint32 m_pending_expedition_invite_id = 0; + ExpeditionInvite m_pending_expedition_invite { 0 }; std::vector m_expedition_lockouts; DynamicZoneLocation m_quest_compass; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 704e3dc4b..824928c71 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -5665,13 +5665,14 @@ void Client::Handle_OP_DzChooseZoneReply(const EQApplicationPacket *app) void Client::Handle_OP_DzExpeditionInviteResponse(const EQApplicationPacket *app) { - auto expedition = Expedition::FindCachedExpeditionByID(m_pending_expedition_invite_id); - m_pending_expedition_invite_id = 0; + auto expedition = Expedition::FindCachedExpeditionByID(m_pending_expedition_invite.expedition_id); + std::string swap_remove_name = m_pending_expedition_invite.swap_remove_name; + m_pending_expedition_invite = { 0 }; // clear before re-validating if (expedition) { auto dzmsg = reinterpret_cast(app->pBuffer); - expedition->DzInviteResponse(this, dzmsg->accepted, dzmsg->swapping, dzmsg->swap_name); + expedition->DzInviteResponse(this, dzmsg->accepted, swap_remove_name); } } diff --git a/zone/expedition.cpp b/zone/expedition.cpp index e70612b91..7a9ce5b00 100644 --- a/zone/expedition.cpp +++ b/zone/expedition.cpp @@ -612,7 +612,7 @@ void Expedition::SendClientExpeditionInvite( m_id, client->GetName(), inviter_name, swap_remove_name ); - client->SetPendingExpeditionInvite(m_id); + client->SetPendingExpeditionInvite(ExpeditionInvite{m_id, inviter_name, swap_remove_name}); client->MessageString( Chat::System, EXPEDITION_ASKED_TO_JOIN, m_leader.name.c_str(), m_expedition_name.c_str() @@ -731,8 +731,7 @@ bool Expedition::ProcessAddConflicts(Client* leader_client, Client* add_client, return has_conflict; } -void Expedition::DzInviteResponse( - Client* add_client, bool accepted, bool has_swap_name, std::string swap_remove_name) +void Expedition::DzInviteResponse(Client* add_client, bool accepted, const std::string& swap_remove_name) { if (!add_client) { @@ -740,8 +739,8 @@ void Expedition::DzInviteResponse( } LogExpeditionsModerate( - "Invite response by [{}] accepted [{}] swapping [{}] swap_name [{}]", - add_client->GetName(), accepted, has_swap_name, swap_remove_name + "Invite response by [{}] accepted [{}] swap_name [{}]", + add_client->GetName(), accepted, swap_remove_name ); // a null leader_client is handled by SendLeaderMessage fallbacks @@ -754,7 +753,7 @@ void Expedition::DzInviteResponse( return; } - bool was_swap_invite = (has_swap_name && !swap_remove_name.empty()); + bool was_swap_invite = !swap_remove_name.empty(); bool has_conflicts = ProcessAddConflicts(leader_client, add_client, was_swap_invite); // error if swapping and character was already removed before the accept diff --git a/zone/expedition.h b/zone/expedition.h index 61b71829b..cf6c9306d 100644 --- a/zone/expedition.h +++ b/zone/expedition.h @@ -60,6 +60,13 @@ struct ExpeditionMember : char_id(char_id_), name(name_), status(status_) {} }; +struct ExpeditionInvite +{ + uint32_t expedition_id; + std::string inviter_name; + std::string swap_remove_name; +}; + class Expedition { public: @@ -111,7 +118,7 @@ public: void DzAddPlayer(Client* requester, std::string add_char_name, std::string swap_remove_name = {}); void DzAddPlayerContinue(std::string leader_name, std::string add_char_name, std::string swap_remove_name = {}); - void DzInviteResponse(Client* add_client, bool accepted, bool has_swap_name, std::string swap_remove_name); + void DzInviteResponse(Client* add_client, bool accepted, const std::string& swap_remove_name); void DzMakeLeader(Client* requester, std::string new_leader_name); void DzPlayerList(Client* requester); void DzRemovePlayer(Client* requester, std::string remove_char_name);