diff --git a/CHANGELOG.md b/CHANGELOG.md index 30e7cf91..91363cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2024/2/7 * new persistent modes for cold client loader, mode 2 is a more accurate simulation and allows launching apps from their .exe +* allow setting the IP country via the file `ip_country.txt` --- diff --git a/dll/dll/common_includes.h b/dll/dll/common_includes.h index a1903900..187410d3 100644 --- a/dll/dll/common_includes.h +++ b/dll/dll/common_includes.h @@ -257,6 +257,7 @@ static inline void consume_bom(std::ifstream &input) bom[1] = input.get(); bom[2] = input.get(); if (bom[0] != 0xEF || bom[1] != 0xBB || bom[2] != 0xBF) { + input.clear(); input.seekg(pos, std::ios::beg); } } diff --git a/dll/dll/settings.h b/dll/dll/settings.h index c3d56e34..0c7b737c 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -316,6 +316,8 @@ public: bool hasOverlayAutoAcceptInviteFromFriend(uint64_t friend_id) const; size_t overlayAutoAcceptInvitesCount() const; + // get the alpha-2 code from: https://www.iban.com/country-codes + std::string ip_country = "US"; }; #endif diff --git a/dll/dll/steam_utils.h b/dll/dll/steam_utils.h index 2ca30114..295b1550 100644 --- a/dll/dll/steam_utils.h +++ b/dll/dll/steam_utils.h @@ -84,7 +84,7 @@ const char *GetIPCountry() { PRINT_DEBUG("Steam_Utils::GetIPCountry\n"); std::lock_guard lock(global_mutex); - return "US"; + return settings->ip_country.c_str(); } // returns true if the image exists, and valid sizes were filled out diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 23d301ba..d5ff0afc 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -1129,6 +1129,32 @@ static void parse_auto_accept_invite(class Settings *settings_client, Settings * } } +// ip_country.txt +static void parse_ip_country(class Settings *settings_client, Settings *settings_server) +{ + std::string setting_file = Local_Storage::get_game_settings_path() + "ip_country.txt"; + std::ifstream input( utf8_decode(setting_file) ); + if (input.is_open()) { + consume_bom(input); + std::string line{}; + std::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); + + // ISO 3166-1-alpha-2 format is 2 chars only + if (line.size() == 2) { + std::transform(line.begin(), line.end(), line.begin(), [](char c) { return std::toupper(c); }); + settings_client->ip_country = line; + settings_server->ip_country = line; + PRINT_DEBUG("Setting IP country to: '%s'\n", line.c_str()); + } + } +} + 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(); @@ -1332,6 +1358,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s load_gamecontroller_settings(settings_client); parse_auto_accept_invite(settings_client, settings_server); + + parse_ip_country(settings_client, settings_server); *settings_client_out = settings_client; *settings_server_out = settings_server; diff --git a/post_build/README.release.md b/post_build/README.release.md index b2cf3aab..5c8d6777 100644 --- a/post_build/README.release.md +++ b/post_build/README.release.md @@ -465,6 +465,15 @@ Check the exaxmple file in the `steam_settings` folder --- +## IP country: + +You can report a country IP if the game queries it, by setting the 2 characters code in the file `ip_country.txt`. +Use this link to get the `Alpha-2` country code: https://www.iban.com/country-codes + +Check the exaxmple file in the `steam_settings` folder + +--- + ## More configurations: Due to the various changes and additions, it became tedious to document everything, so it is recommended to check each example file in the `steam_settings` folder. diff --git a/post_build/steam_settings.EXAMPLE/ip_country.EXAMPLE.txt b/post_build/steam_settings.EXAMPLE/ip_country.EXAMPLE.txt new file mode 100644 index 00000000..4547d977 --- /dev/null +++ b/post_build/steam_settings.EXAMPLE/ip_country.EXAMPLE.txt @@ -0,0 +1 @@ +US \ No newline at end of file