allow setting the ip country reported to the game via a file

This commit is contained in:
otavepto 2024-02-07 04:22:33 +02:00
parent 0237152b82
commit e4af4f2b00
7 changed files with 43 additions and 1 deletions

View File

@ -1,6 +1,7 @@
## 2024/2/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 * 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`
--- ---

View File

@ -257,6 +257,7 @@ static inline void consume_bom(std::ifstream &input)
bom[1] = input.get(); bom[1] = input.get();
bom[2] = input.get(); bom[2] = input.get();
if (bom[0] != 0xEF || bom[1] != 0xBB || bom[2] != 0xBF) { if (bom[0] != 0xEF || bom[1] != 0xBB || bom[2] != 0xBF) {
input.clear();
input.seekg(pos, std::ios::beg); input.seekg(pos, std::ios::beg);
} }
} }

View File

@ -316,6 +316,8 @@ public:
bool hasOverlayAutoAcceptInviteFromFriend(uint64_t friend_id) const; bool hasOverlayAutoAcceptInviteFromFriend(uint64_t friend_id) const;
size_t overlayAutoAcceptInvitesCount() const; size_t overlayAutoAcceptInvitesCount() const;
// get the alpha-2 code from: https://www.iban.com/country-codes
std::string ip_country = "US";
}; };
#endif #endif

View File

@ -84,7 +84,7 @@ const char *GetIPCountry()
{ {
PRINT_DEBUG("Steam_Utils::GetIPCountry\n"); PRINT_DEBUG("Steam_Utils::GetIPCountry\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
return "US"; return settings->ip_country.c_str();
} }
// returns true if the image exists, and valid sizes were filled out // returns true if the image exists, and valid sizes were filled out

View File

@ -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) 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(); std::string program_path = Local_Storage::get_program_path();
@ -1333,6 +1359,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
parse_auto_accept_invite(settings_client, settings_server); parse_auto_accept_invite(settings_client, settings_server);
parse_ip_country(settings_client, settings_server);
*settings_client_out = settings_client; *settings_client_out = settings_client;
*settings_server_out = settings_server; *settings_server_out = settings_server;
*local_storage_out = local_storage; *local_storage_out = local_storage;

View File

@ -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: ## More configurations:
Due to the various changes and additions, it became tedious to document everything, 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. so it is recommended to check each example file in the `steam_settings` folder.

View File

@ -0,0 +1 @@
US