From cbccd720502cf3a87d6dfeacd7a146a54b3f1be1 Mon Sep 17 00:00:00 2001 From: hg <4683435+hgtw@users.noreply.github.com> Date: Tue, 22 Sep 2020 18:18:24 -0400 Subject: [PATCH] Truncate members after conflict checks This more accurately matches live for the new behavior introduced in the September 16, 2020 patch. All members of a raid/group are still checked for conflicts and the truncation is only allowed if there are none. It might make sense to add a rule for this since ignoring members that would exceed the expedition max from the start makes it more convenient to create expeditions. Members that wouldn't be added anyway don't really need their conflicts checked. --- zone/expedition_database.cpp | 4 ++-- zone/expedition_request.cpp | 18 +++++++++++------- zone/expedition_request.h | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/zone/expedition_database.cpp b/zone/expedition_database.cpp index d818200f6..1f7bbdeb7 100644 --- a/zone/expedition_database.cpp +++ b/zone/expedition_database.cpp @@ -261,8 +261,8 @@ MySQLRequestResult ExpeditionDatabase::LoadMembersForCreateRequest( AND lockout.expedition_name = '{}' LEFT JOIN expedition_members member ON character_data.id = member.character_id WHERE character_data.name IN ({}) - ORDER BY character_data.id; - ), EscapeString(expedition_name), in_character_names_query); + ORDER BY FIELD(character_data.name, {}) + ), EscapeString(expedition_name), in_character_names_query, in_character_names_query); results = database.QueryDatabase(query); } diff --git a/zone/expedition_request.cpp b/zone/expedition_request.cpp index 5013d49a4..1b8f5170b 100644 --- a/zone/expedition_request.cpp +++ b/zone/expedition_request.cpp @@ -113,8 +113,9 @@ bool ExpeditionRequest::CanRaidRequest(Raid* raid) SystemName, m_max_players, "raid", raid_members.size()); } + // live still performs conflict checks for all members even those beyond max std::vector member_names; - for (int i = 0; i < raid_members.size() && member_names.size() < m_max_players; ++i) + for (int i = 0; i < raid_members.size(); ++i) { member_names.emplace_back(raid_members[i].membername); } @@ -149,8 +150,6 @@ bool ExpeditionRequest::CanGroupRequest(Group* group) { m_not_all_added_msg = fmt::format(CREATE_NOT_ALL_ADDED, "group", SystemName, SystemName, m_max_players, "group", member_names.size()); - - member_names.resize(m_max_players); } return CanMembersJoin(member_names); @@ -181,7 +180,7 @@ bool ExpeditionRequest::CanMembersJoin(const std::vector& member_na // maybe it's done intentionally as a way to preview lockout conflicts if (requirements_met) { - requirements_met = IsPlayerCountValidated(static_cast(member_names.size())); + requirements_met = IsPlayerCountValidated(); } return requirements_met; @@ -373,7 +372,7 @@ void ExpeditionRequest::SendLeaderMemberEventLockout( }); } -bool ExpeditionRequest::IsPlayerCountValidated(uint32_t member_count) +bool ExpeditionRequest::IsPlayerCountValidated() { // note: offline group members count towards requirement but not added to expedition bool requirements_met = true; @@ -381,12 +380,17 @@ bool ExpeditionRequest::IsPlayerCountValidated(uint32_t member_count) auto bypass_status = RuleI(Expedition, MinStatusToBypassPlayerCountRequirements); auto gm_bypass = (m_requester && m_requester->GetGM() && m_requester->Admin() >= bypass_status); - if (!gm_bypass && (member_count < m_min_players || member_count > m_max_players)) + if (m_members.size() > m_max_players) + { + // members were sorted at start, truncate after conflict checks to act like live + m_members.resize(m_max_players); + } + else if (!gm_bypass && m_members.size() < m_min_players) { requirements_met = false; SendLeaderMessage(Chat::System, REQUIRED_PLAYER_COUNT, { - fmt::format_int(member_count).str(), + fmt::format_int(m_members.size()).str(), fmt::format_int(m_min_players).str(), fmt::format_int(m_max_players).str() }); diff --git a/zone/expedition_request.h b/zone/expedition_request.h index cf1151771..edfdd6122 100644 --- a/zone/expedition_request.h +++ b/zone/expedition_request.h @@ -59,7 +59,7 @@ private: bool CanGroupRequest(Group* group); bool CheckMembersForConflicts(const std::vector& member_names); std::string GetGroupLeaderName(uint32_t group_id); - bool IsPlayerCountValidated(uint32_t member_count); + bool IsPlayerCountValidated(); bool LoadLeaderLockouts(); void SendLeaderMemberInExpedition(const std::string& member_name, bool is_solo); void SendLeaderMemberReplayLockout(const std::string& member_name, const ExpeditionLockoutTimer& lockout, bool is_solo);