From 6864aafc12822430343f30ab4144370d783265c1 Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Fri, 29 Dec 2023 08:41:34 +0200 Subject: [PATCH] restored missing files! why! --- CHANGELOG.md | 3 +- dll/dll/settings.h | 3 ++ dll/dll/steam_friends.h | 4 +-- dll/settings_parser.cpp | 29 +++++++++++++++++++ overlay_experimental/steam_overlay.cpp | 2 +- .../auto_accept_invite.EXAMPLE.txt | 3 ++ 6 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 post_build/steam_settings.EXAMPLE/auto_accept_invite.EXAMPLE.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index e46ec1c1..6cb1600a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ +* addded new `auto_accept_invite.txt` setting to automatically accept game/lobby invites from this list, each SteamID64 on a separate line * fixed the condition of `warn_forced_setting`, previously it may be reset back to `false` accidentally * deprecated `disable_overlay_warning.txt` in `steam_settings` folder in favor of new options/files -* new `disable_overlay_warning_*.txt` settings to disable certain or all warnings in the overlay +* added new `disable_overlay_warning_*.txt` settings to disable certain or all warnings in the overlay * `disable_overlay_warning_forced_setting.txt`: - disable the warning for the usage of any file `force_*.txt` in the overlay - unlocks the settigs menu, this may result in an undesirable output diff --git a/dll/dll/settings.h b/dll/dll/settings.h index c8a22593..67b26086 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -278,6 +278,9 @@ public: bool enable_new_app_ticket = false; // can use GC token for generation bool use_gc_token = false; + + // list of user steam IDs to auto-accept invites from + std::unordered_set auto_accept_invites{}; }; #endif diff --git a/dll/dll/steam_friends.h b/dll/dll/steam_friends.h index 4940acfe..70ce0a77 100644 --- a/dll/dll/steam_friends.h +++ b/dll/dll/steam_friends.h @@ -1241,7 +1241,7 @@ void Callback(Common_Message *msg) data.m_ulGameID = f->appid(); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); - if (overlay->Ready()) + if (overlay->Ready() && !settings->auto_accept_invites.count(msg->source_id())) { //TODO: the user should accept the invite first but we auto accept it because there's no gui yet // Then we will handle it ! @@ -1260,7 +1260,7 @@ void Callback(Common_Message *msg) if (msg->friend_messages().type() == Friend_Messages::GAME_INVITE) { PRINT_DEBUG("Steam_Friends Got Game Invite\n"); //TODO: I'm pretty sure that the user should accept the invite before this is posted but we do like above - if (overlay->Ready()) + if (overlay->Ready() && !settings->auto_accept_invites.count(msg->source_id())) { // Then we will handle it ! overlay->SetRichInvite(*find_friend(static_cast(msg->source_id())), msg->friend_messages().connect_str().c_str()); diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index ec88e7be..2b317427 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -1066,6 +1066,33 @@ static void parse_crash_printer_location() } } +// auto_accept_invite.txt +static void parse_auto_accept_invite(class Settings *settings_client, Settings *settings_server) +{ + std::string auto_accept_list_path = Local_Storage::get_game_settings_path() + "auto_accept_invite.txt"; + std::ifstream input( utf8_decode(auto_accept_list_path) ); + if (input.is_open()) { + consume_bom(input); + for( std::string line; getline( input, line ); ) { + + size_t start = line.find_first_not_of(whitespaces); + size_t end = line.find_last_not_of(whitespaces); + line = start == end + ? std::string() + : line.substr(start, end - start + 1); + + if (!line.empty()) { + try { + auto friend_id = std::stoull(line); + settings_client->auto_accept_invites.insert((uint64_t)friend_id); + settings_server->auto_accept_invites.insert((uint64_t)friend_id); + PRINT_DEBUG("Auto accepting invitations from user with ID (SteamID64) = " "%" PRIu64 "\n", friend_id); + } catch (...) {} + } + } + } +} + uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out) { std::string program_path = Local_Storage::get_program_path(); @@ -1268,6 +1295,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s load_gamecontroller_settings(settings_client); + parse_auto_accept_invite(settings_client, settings_server); + *settings_client_out = settings_client; *settings_server_out = settings_server; *local_storage_out = local_storage; diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 7e484ec4..0c8e0190 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -242,7 +242,7 @@ void Steam_Overlay::OpenOverlayInvite(CSteamID lobbyId) void Steam_Overlay::OpenOverlay(const char* pchDialog) { // TODO: Show pages depending on pchDialog - if ((strcmp(pchDialog, "Friends") == 0) && (settings->auto_accept_invites.size() > 0)) { + if ((strncmp(pchDialog, "Friends", sizeof("Friends") - 1) == 0) && (settings->auto_accept_invites.size() > 0)) { PRINT_DEBUG("Not opening overlay's friends list because some friends are defined in the auto accept list\n"); AddAutoAcceptInviteNotification(); } else { diff --git a/post_build/steam_settings.EXAMPLE/auto_accept_invite.EXAMPLE.txt b/post_build/steam_settings.EXAMPLE/auto_accept_invite.EXAMPLE.txt new file mode 100644 index 00000000..8ebfdf5c --- /dev/null +++ b/post_build/steam_settings.EXAMPLE/auto_accept_invite.EXAMPLE.txt @@ -0,0 +1,3 @@ +76561197960287930 +76561197960271227 +76561197960276863