From f041b95c8613e49b338f6ac35653725d681105cf Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Sat, 7 Aug 2021 01:46:10 -0400 Subject: [PATCH] Add a way to config the build id in the emu. Fix crash due to empty lines in some files Add a way to disable lobby creation in the emu (lobby creation will return an error when enabled) --- Readme_release.txt | 5 +++ dll/settings.h | 6 +++ dll/settings_parser.cpp | 33 +++++++++++---- dll/steam_apps.cpp | 2 +- dll/steam_matchmaking.h | 40 ++++++++++++------- .../build_id.EXAMPLE.txt | 1 + 6 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 files_example/steam_settings.EXAMPLE/build_id.EXAMPLE.txt diff --git a/Readme_release.txt b/Readme_release.txt index 440121ac..e555d0dd 100644 --- a/Readme_release.txt +++ b/Readme_release.txt @@ -105,6 +105,11 @@ The format is: STAT_NAME=type=default value The type can be: int, float or avgrate The default value is simply a number that represents the default value for the stat. +Build id: +Add a steam_settings\build_id.txt with the build id if the game doesn't show the correct build id and you want the emu to give it the correct one. +An example can be found in steam_settings.EXAMPLE + + Support for CPY steam_api(64).dll cracks: See the build in the experimental folder. Notes: diff --git a/dll/settings.h b/dll/settings.h index de4b66ba..b54815ea 100644 --- a/dll/settings.h +++ b/dll/settings.h @@ -149,6 +149,12 @@ public: //overlay bool disable_overlay = false; + + //app build id + int build_id = 10; + + //make lobby creation fail in the matchmaking interface + bool disable_lobby_creation = false; }; #endif diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 3168cf5d..fb4a6a8b 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -260,6 +260,9 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s bool steam_offline_mode = false; bool disable_networking = false; bool disable_overlay = false; + bool disable_lobby_creation = false; + int build_id = 10; + { std::string steam_settings_path = Local_Storage::get_game_settings_path(); @@ -272,6 +275,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s disable_networking = true; } else if (p == "disable_overlay.txt") { disable_overlay = true; + } else if (p == "disable_lobby_creation.txt") { + disable_lobby_creation = true; } else if (p == "force_language.txt") { int len = Local_Storage::get_file_data(steam_settings_path + "force_language.txt", language, sizeof(language) - 1); if (len > 0) language[len] = 0; @@ -290,6 +295,10 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s char array_port[10] = {}; int len = Local_Storage::get_file_data(steam_settings_path + "force_listen_port.txt", array_port, sizeof(array_port) - 1); if (len > 0) port = std::stoi(array_port); + } else if (p == "build_id.txt") { + char array_id[10] = {}; + int len = Local_Storage::get_file_data(steam_settings_path + "build_id.txt", array_id, sizeof(array_id) - 1); + if (len > 0) build_id = std::stoi(array_id); } } } @@ -304,6 +313,10 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s settings_server->disable_networking = disable_networking; settings_client->disable_overlay = disable_overlay; settings_server->disable_overlay = disable_overlay; + settings_client->disable_lobby_creation = disable_lobby_creation; + settings_server->disable_lobby_creation = disable_lobby_creation; + settings_client->build_id = build_id; + settings_server->build_id = build_id; { std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt"; @@ -503,10 +516,12 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s line.pop_back(); } - DepotId_t depot_id = stoul(line); - settings_client->depots.push_back(depot_id); - settings_server->depots.push_back(depot_id); - PRINT_DEBUG("Added depot %u\n", depot_id); + try { + DepotId_t depot_id = std::stoul(line); + settings_client->depots.push_back(depot_id); + settings_server->depots.push_back(depot_id); + PRINT_DEBUG("Added depot %u\n", depot_id); + } catch (...) {} } } } @@ -525,10 +540,12 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s line.pop_back(); } - uint64 source_id = stoull(line); - settings_client->subscribed_groups.insert(source_id); - settings_server->subscribed_groups.insert(source_id); - PRINT_DEBUG("Added source %llu\n", source_id); + try { + uint64 source_id = std::stoull(line); + settings_client->subscribed_groups.insert(source_id); + settings_server->subscribed_groups.insert(source_id); + PRINT_DEBUG("Added source %llu\n", source_id); + } catch (...) {} } } } diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index b8016851..2973e616 100644 --- a/dll/steam_apps.cpp +++ b/dll/steam_apps.cpp @@ -262,7 +262,7 @@ bool Steam_Apps::GetDlcDownloadProgress( AppId_t nAppID, uint64 *punBytesDownloa int Steam_Apps::GetAppBuildId() { PRINT_DEBUG("GetAppBuildId\n"); - return 10; + return this->settings->build_id; } diff --git a/dll/steam_matchmaking.h b/dll/steam_matchmaking.h index 5ebbf3ef..e846e825 100644 --- a/dll/steam_matchmaking.h +++ b/dll/steam_matchmaking.h @@ -559,23 +559,35 @@ void Create_pending_lobbies() enter_lobby(&lobby, settings->get_local_steam_id()); lobbies.push_back(lobby); - LobbyCreated_t data; - data.m_eResult = k_EResultOK; - data.m_ulSteamIDLobby = lobby.room_id(); - callback_results->addCallResult(p_c->api_id, data.k_iCallback, &data, sizeof(data)); - callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); - - { - LobbyEnter_t data; - data.m_ulSteamIDLobby = lobby.room_id(); - data.m_rgfChatPermissions = 0; //Unused - Always 0 - data.m_bLocked = false; - data.m_EChatRoomEnterResponse = k_EChatRoomEnterResponseSuccess; + if (settings->disable_lobby_creation) { + LobbyCreated_t data; + data.m_eResult = k_EResultFail; + data.m_ulSteamIDLobby = 0; + callback_results->addCallResult(p_c->api_id, data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); + } else { + LobbyCreated_t data; + data.m_eResult = k_EResultOK; + data.m_ulSteamIDLobby = lobby.room_id(); + callback_results->addCallResult(p_c->api_id, data.k_iCallback, &data, sizeof(data)); + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); + + { + LobbyEnter_t data; + data.m_ulSteamIDLobby = lobby.room_id(); + data.m_rgfChatPermissions = 0; //Unused - Always 0 + if (p_c->eLobbyType == k_ELobbyTypePrivate) + data.m_bLocked = true; + else + data.m_bLocked = false; + data.m_EChatRoomEnterResponse = k_EChatRoomEnterResponseSuccess; + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); + } + + on_self_enter_leave_lobby(lobby_id, p_c->eLobbyType, false); + trigger_lobby_dataupdate(lobby_id, lobby_id, true); } - on_self_enter_leave_lobby(lobby_id, p_c->eLobbyType, false); - trigger_lobby_dataupdate(lobby_id, lobby_id, true); p_c = pending_creates.erase(p_c); } else { ++p_c; diff --git a/files_example/steam_settings.EXAMPLE/build_id.EXAMPLE.txt b/files_example/steam_settings.EXAMPLE/build_id.EXAMPLE.txt new file mode 100644 index 00000000..bd41cba7 --- /dev/null +++ b/files_example/steam_settings.EXAMPLE/build_id.EXAMPLE.txt @@ -0,0 +1 @@ +12345 \ No newline at end of file