block_join_reasons cleanup (#3290)

This commit is contained in:
Quentin 2024-06-27 22:11:08 +02:00 committed by GitHub
parent 4589b87553
commit 10d0e72285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 180 additions and 45 deletions

View File

@ -2,28 +2,132 @@
namespace big namespace big
{ {
inline std::unordered_map<int, const char*> block_join_reasons = { enum block_join_reason_t : int32_t
{1, "None"}, {
{5, "Been Voted Out"}, // You have already been voted out of this game session. UNK_0 = 0,
{7, "Incompatible Assets"}, // Failed to join session due to incompatible assets.
{8, "Session Full"}, // The session you're trying to join is currently full. None = 1,
{9, "Slot Full"}, // The session you're trying to join is currently full of players.
{10, "No Title Update"}, // Please make sure all players have the latest Title Update. UNK_2 = 2,
{12, "Invites Disabled"}, // Invites are currently disabled in the session. UNK_3 = 3,
{13, "Different Targeting Mode"},// The session you are trying to join is using a different targeting preference. You can change your preference in the Settings tab of the Pause Menu in Grand Theft Auto V. Joining a new GTA Online Session. UNK_4 = 4,
{14, "Cheater"},// You are classed as a cheat and can only play with other cheats until you are forgiven.
{16, "Incompatible DLC"},// Incompatible downloadable content. All players must have the latest compatibility pack. // You have already been voted out of this game session.
{17, "Crew Only"}, // You are trying to enter a Crew Members only session. BeenVotedOut = 5,
{21, "Session No Longer Exists"},// The session you are trying to join no longer exists.
{22, "Invite Only"},// The session you are trying to join is private. You will need to be invited to join this session. UNK_6 = 6,
{26, "Friends Only"}, // The session you are trying to join is friends only.
{23, "Different Build Type"},// The session you are trying to join is a different build type. // Failed to join session due to incompatible assets.
{25, "Different Content"}, // The session you are trying to join is not using the same content. IncompatibleAssets = 7,
{18, "Bad Sport"},// The session you are trying to join is for people who are not Bad Sports or cheaters - you are a Bad Sport.
{19, "Bad Sports Only"},// The session you are trying to join is for Bad Sports only. // The session you're trying to join is currently full.
{20, "Cheaters Only"}, // The session you are trying to join is for cheaters only. SessionFull = 8,
{27, "Bad Reputation"}, // Unable to join this session, your account has a bad reputation.
{28, "May Not Exist"}, // Unable to connect to session. The session may no longer exist. // The session you're trying to join is currently full of players.
{29, "Premium Race"},// Unable to Join. The session you are trying to join is a Premium Race. Joining and accepting invites is disabled for this mode. SlotFull = 9,
// Please make sure all players have the latest Title Update.
NoTitleUpdate = 10,
UNK_11 = 11,
// Invites are currently disabled in the session.
InvitesDisabled = 12,
// The session you are trying to join is using a different targeting preference. You can change your preference in the Settings tab of the Pause Menu in Grand Theft Auto V. Joining a new GTA Online Session.
DifferentTargetingMode = 13,
// You are classed as a cheat and can only play with other cheats until you are forgiven.
Cheater = 14,
UNK_15 = 15,
// Incompatible downloadable content. All players must have the latest compatibility pack.
IncompatibleDLC = 16,
// You are trying to enter a Crew Members only session.
CrewOnly = 17,
// The session you are trying to join is for people who are not Bad Sports or cheaters - you are a Bad Sport.
BadSport = 18,
// The session you are trying to join is for Bad Sports only.
BadSportOnly = 19,
// The session you are trying to join is for cheaters only.
CheatersOnly = 20,
// The session you are trying to join no longer exists.
SessionNoLongerExists = 21,
// The session you are trying to join is private. You will need to be invited to join this session.
InviteOnly = 22,
// The session you are trying to join is a different build type.
DifferentBuildType = 23,
UNK_24 = 24,
// The session you are trying to join is not using the same content.
DifferentContent = 25,
// The session you are trying to join is friends only.
FriendsOnly = 26,
// Unable to join this session, your account has a bad reputation.
BadReputation = 27,
// Unable to connect to session. The session may no longer exist.
MayNotExist = 28,
// Unable to Join. The session you are trying to join is a Premium Race. Joining and accepting invites is disabled for this mode.
PremiumRace = 29
}; };
inline block_join_reason_t& operator++(block_join_reason_t& reason)
{
reason = static_cast<block_join_reason_t>(static_cast<int32_t>(reason) + 1);
return reason;
}
inline block_join_reason_t operator++(block_join_reason_t& reason, int32_t)
{
block_join_reason_t a = reason;
++reason;
return a;
}
inline constexpr auto block_join_reasons = std::to_array({
"", // 0
"None", // 1
"", // 2
"", // 3
"", // 4
"Been Voted Out", // 5
"", // 6
"Incompatible Assets", // 7
"Session Full", // 8
"Slot Full", // 9
"No Title Update", // 10
"", // 11
"Invites Disabled", // 12
"Different Targeting Mode", // 13
"Cheater", // 14
"", // 15
"Incompatible DLC", // 16
"Crew Only", // 17
"Bad Sport", // 18
"Bad Sports Only", // 19
"Cheaters Only", // 20
"Session No Longer Exists", // 21
"Invite Only", // 22
"Different Build Type", // 23
"", // 24
"Different Content", // 25
"Friends Only", // 26
"Bad Reputation", // 27
"May Not Exist", // 28
"Premium Race" // 29
});
} }

View File

@ -1,5 +1,6 @@
#include "translation_service.hpp" #include "translation_service.hpp"
#include "core/data/block_join_reasons.hpp"
#include "fiber_pool.hpp" #include "fiber_pool.hpp"
#include "file_manager.hpp" #include "file_manager.hpp"
#include "http_client/http_client.hpp" #include "http_client/http_client.hpp"
@ -313,7 +314,7 @@ namespace big
// Tweaks to make it easier for people playing in the China region // Tweaks to make it easier for people playing in the China region
g.session_browser.filter_multiplexed_sessions = true; g.session_browser.filter_multiplexed_sessions = true;
g.reactions.chat_spam.block_joins = true; g.reactions.chat_spam.block_joins = true;
g.reactions.chat_spam.block_join_reason = 27; g.reactions.chat_spam.block_join_reason = block_join_reason_t::BadReputation;
} }
if (does_language_exist(preferred_lang)) if (does_language_exist(preferred_lang))

View File

@ -153,18 +153,26 @@ namespace big
if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[current_player->block_join_reason])) if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[current_player->block_join_reason]))
{ {
for (const auto& reason : block_join_reasons) block_join_reason_t i = block_join_reason_t::None;
for (const auto& reason_str : block_join_reasons)
{ {
if (ImGui::Selectable(reason.second, reason.first == current_player->block_join_reason)) if (reason_str != "")
{ {
current_player->block_join_reason = reason.first; const bool is_selected = current_player->block_join_reason == i;
g_player_database_service->save();
if (ImGui::Selectable(reason_str, is_selected))
{
current_player->block_join_reason = i;
g_player_database_service->save();
}
if (is_selected)
{
ImGui::SetItemDefaultFocus();
}
} }
if (reason.first == current_player->block_join_reason) i++;
{
ImGui::SetItemDefaultFocus();
}
} }
ImGui::EndCombo(); ImGui::EndCombo();

View File

@ -1,5 +1,5 @@
#include "views/view.hpp"
#include "core/data/block_join_reasons.hpp" #include "core/data/block_join_reasons.hpp"
#include "views/view.hpp"
namespace big namespace big
{ {
@ -28,14 +28,25 @@ namespace big
if (reaction.block_joins) if (reaction.block_joins)
if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[reaction.block_join_reason])) if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[reaction.block_join_reason]))
{ {
for (const auto& [key, value] : block_join_reasons) block_join_reason_t i = block_join_reason_t::None;
for (const auto& reason_str : block_join_reasons)
{ {
bool is_selected = (reaction.block_join_reason == key); if (reason_str != "")
{
const bool is_selected = reaction.block_join_reason == i;
if (ImGui::Selectable(value, is_selected)) if (ImGui::Selectable(reason_str, is_selected))
reaction.block_join_reason = key; {
if (is_selected) reaction.block_join_reason = i;
ImGui::SetItemDefaultFocus(); }
if (is_selected)
{
ImGui::SetItemDefaultFocus();
}
}
i++;
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
@ -62,14 +73,25 @@ namespace big
if (reaction.block_joins) if (reaction.block_joins)
if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[reaction.block_join_reason])) if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[reaction.block_join_reason]))
{ {
for (const auto& [key, value] : block_join_reasons) block_join_reason_t i = block_join_reason_t::None;
for (const auto& reason_str : block_join_reasons)
{ {
bool is_selected = (reaction.block_join_reason == key); if (reason_str != "")
{
const bool is_selected = reaction.block_join_reason == i;
if (ImGui::Selectable(value, is_selected)) if (ImGui::Selectable(reason_str, is_selected))
reaction.block_join_reason = key; {
if (is_selected) reaction.block_join_reason = i;
ImGui::SetItemDefaultFocus(); }
if (is_selected)
{
ImGui::SetItemDefaultFocus();
}
}
i++;
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }