Validate expedition invite response server side

Stores expedition invite data on client
This commit is contained in:
hg 2020-05-15 17:58:07 -04:00
parent 43963783db
commit d92c0e330d
4 changed files with 21 additions and 15 deletions

View File

@ -21,8 +21,6 @@
class Client; class Client;
class EQApplicationPacket; class EQApplicationPacket;
class EQStream; class EQStream;
class Expedition;
class ExpeditionLockoutTimer;
class Group; class Group;
class NPC; class NPC;
class Object; class Object;
@ -54,6 +52,7 @@ namespace EQ
#include "aggromanager.h" #include "aggromanager.h"
#include "common.h" #include "common.h"
#include "expedition.h"
#include "dynamiczone.h" #include "dynamiczone.h"
#include "merc.h" #include "merc.h"
#include "mob.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::string& expedition_name, const std::string& event_name, bool include_expired = false) const;
const std::vector<ExpeditionLockoutTimer>& GetExpeditionLockouts() const { return m_expedition_lockouts; }; const std::vector<ExpeditionLockoutTimer>& GetExpeditionLockouts() const { return m_expedition_lockouts; };
std::vector<ExpeditionLockoutTimer> GetExpeditionLockouts(const std::string& expedition_name); std::vector<ExpeditionLockoutTimer> 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 HasExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool include_expired = false);
bool IsInExpedition() const { return m_expedition_id != 0; } bool IsInExpedition() const { return m_expedition_id != 0; }
void RemoveAllExpeditionLockouts(std::string expedition_name = {}); void RemoveAllExpeditionLockouts(std::string expedition_name = {});
void RemoveExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool update_db = false); 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 SendExpeditionLockoutTimers();
void SetExpeditionID(uint32 expedition_id) { m_expedition_id = expedition_id; }; void SetExpeditionID(uint32 expedition_id) { m_expedition_id = expedition_id; };
void SetPendingExpeditionInvite(ExpeditionInvite&& invite) { m_pending_expedition_invite = invite; }
void LoadAllExpeditionLockouts(); void LoadAllExpeditionLockouts();
void UpdateExpeditionInfoAndLockouts(); void UpdateExpeditionInfoAndLockouts();
void DzListTimers(); void DzListTimers();
@ -1699,7 +1698,7 @@ private:
int client_max_level; int client_max_level;
uint32 m_expedition_id = 0; uint32 m_expedition_id = 0;
uint32 m_pending_expedition_invite_id = 0; ExpeditionInvite m_pending_expedition_invite { 0 };
std::vector<ExpeditionLockoutTimer> m_expedition_lockouts; std::vector<ExpeditionLockoutTimer> m_expedition_lockouts;
DynamicZoneLocation m_quest_compass; DynamicZoneLocation m_quest_compass;

View File

@ -5665,13 +5665,14 @@ void Client::Handle_OP_DzChooseZoneReply(const EQApplicationPacket *app)
void Client::Handle_OP_DzExpeditionInviteResponse(const EQApplicationPacket *app) void Client::Handle_OP_DzExpeditionInviteResponse(const EQApplicationPacket *app)
{ {
auto expedition = Expedition::FindCachedExpeditionByID(m_pending_expedition_invite_id); auto expedition = Expedition::FindCachedExpeditionByID(m_pending_expedition_invite.expedition_id);
m_pending_expedition_invite_id = 0; std::string swap_remove_name = m_pending_expedition_invite.swap_remove_name;
m_pending_expedition_invite = { 0 }; // clear before re-validating
if (expedition) if (expedition)
{ {
auto dzmsg = reinterpret_cast<ExpeditionInviteResponse_Struct*>(app->pBuffer); auto dzmsg = reinterpret_cast<ExpeditionInviteResponse_Struct*>(app->pBuffer);
expedition->DzInviteResponse(this, dzmsg->accepted, dzmsg->swapping, dzmsg->swap_name); expedition->DzInviteResponse(this, dzmsg->accepted, swap_remove_name);
} }
} }

View File

@ -612,7 +612,7 @@ void Expedition::SendClientExpeditionInvite(
m_id, client->GetName(), inviter_name, swap_remove_name 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( client->MessageString(
Chat::System, EXPEDITION_ASKED_TO_JOIN, m_leader.name.c_str(), m_expedition_name.c_str() 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; return has_conflict;
} }
void Expedition::DzInviteResponse( void Expedition::DzInviteResponse(Client* add_client, bool accepted, const std::string& swap_remove_name)
Client* add_client, bool accepted, bool has_swap_name, std::string swap_remove_name)
{ {
if (!add_client) if (!add_client)
{ {
@ -740,8 +739,8 @@ void Expedition::DzInviteResponse(
} }
LogExpeditionsModerate( LogExpeditionsModerate(
"Invite response by [{}] accepted [{}] swapping [{}] swap_name [{}]", "Invite response by [{}] accepted [{}] swap_name [{}]",
add_client->GetName(), accepted, has_swap_name, swap_remove_name add_client->GetName(), accepted, swap_remove_name
); );
// a null leader_client is handled by SendLeaderMessage fallbacks // a null leader_client is handled by SendLeaderMessage fallbacks
@ -754,7 +753,7 @@ void Expedition::DzInviteResponse(
return; 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); bool has_conflicts = ProcessAddConflicts(leader_client, add_client, was_swap_invite);
// error if swapping and character was already removed before the accept // error if swapping and character was already removed before the accept

View File

@ -60,6 +60,13 @@ struct ExpeditionMember
: char_id(char_id_), name(name_), status(status_) {} : 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 class Expedition
{ {
public: public:
@ -111,7 +118,7 @@ public:
void DzAddPlayer(Client* requester, std::string add_char_name, std::string swap_remove_name = {}); 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 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 DzMakeLeader(Client* requester, std::string new_leader_name);
void DzPlayerList(Client* requester); void DzPlayerList(Client* requester);
void DzRemovePlayer(Client* requester, std::string remove_char_name); void DzRemovePlayer(Client* requester, std::string remove_char_name);