Add steam offline mode and change steam_appid.txt priority.

This commit is contained in:
Mr_Goldberg 2019-04-21 16:47:45 -04:00
parent 5cf841c603
commit 5af7508e2f
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
5 changed files with 28 additions and 8 deletions

View File

@ -44,9 +44,12 @@ Mod folders must be a number corresponding to the file id of the mod.
See the steam_settings.EXAMPLE folder for an example. See the steam_settings.EXAMPLE folder for an example.
Steam appid: Steam appid:
The steam_appid.txt can be put in the steam_settings folder if for some reason you can't put it beside the steam api dll. The best place to put your steam_appid.txt is in the steam_settings folder because this is where the emulator checks first.
If there is no steam_appid.txt in the steam_settings folder it will try opening it from the run path of the game. If one isn't there it will try to load it from beside my steam api dll.
The steam appid can also be set using the SteamAppId or SteamGameId env variables (this is how real steam tells games what their appid is). The steam appid can also be set using the SteamAppId or SteamGameId env variables (this is how real steam tells games what their appid is).
Offline mode:
Some games that connect to online servers might only work if the steam emu behaves like steam is in offline mode. If you need this create a offline.txt file in the steam_settings folder.
Support for CPY steam_api(64).dll cracks: See the build in the experimental folder. Support for CPY steam_api(64).dll cracks: See the build in the experimental folder.

View File

@ -33,7 +33,7 @@ std::string Settings::sanitize(std::string name)
return name; return name;
} }
Settings::Settings(CSteamID steam_id, CGameID game_id, std::string name, std::string language) Settings::Settings(CSteamID steam_id, CGameID game_id, std::string name, std::string language, bool offline)
{ {
this->steam_id = steam_id; this->steam_id = steam_id;
this->game_id = game_id; this->game_id = game_id;
@ -52,6 +52,8 @@ Settings::Settings(CSteamID steam_id, CGameID game_id, std::string name, std::st
this->language = lang; this->language = lang;
this->lobby_id = k_steamIDNil; this->lobby_id = k_steamIDNil;
this->unlockAllDLCs = true; this->unlockAllDLCs = true;
this->offline = offline;
} }
CSteamID Settings::get_local_steam_id() CSteamID Settings::get_local_steam_id()

View File

@ -40,6 +40,7 @@ class Settings {
CSteamID lobby_id; CSteamID lobby_id;
bool unlockAllDLCs; bool unlockAllDLCs;
bool offline;
std::vector<struct DLC_entry> DLCs; std::vector<struct DLC_entry> DLCs;
std::vector<struct Mod_entry> mods; std::vector<struct Mod_entry> mods;
public: public:
@ -49,7 +50,7 @@ public:
static const bool is_lobby_connect = false; static const bool is_lobby_connect = false;
#endif #endif
static std::string sanitize(std::string name); static std::string sanitize(std::string name);
Settings(CSteamID steam_id, CGameID game_id, std::string name, std::string language); Settings(CSteamID steam_id, CGameID game_id, std::string name, std::string language, bool offline);
CSteamID get_local_steam_id(); CSteamID get_local_steam_id();
CGameID get_local_game_id(); CGameID get_local_game_id();
const char *get_local_name(); const char *get_local_name();
@ -57,6 +58,7 @@ public:
void set_game_id(CGameID game_id); void set_game_id(CGameID game_id);
void set_lobby(CSteamID lobby_id); void set_lobby(CSteamID lobby_id);
CSteamID get_lobby(); CSteamID get_lobby();
bool is_offline() {return offline; }
//DLC stuff //DLC stuff
void unlockAllDLC(bool value); void unlockAllDLC(bool value);

View File

@ -46,7 +46,7 @@ Steam_Client::Steam_Client()
char array[10] = {}; char array[10] = {};
array[0] = '0'; array[0] = '0';
Local_Storage::get_file_data(program_path + "steam_appid.txt", array, sizeof(array) - 1); Local_Storage::get_file_data(Local_Storage::get_game_settings_path() + "steam_appid.txt", array, sizeof(array) - 1);
uint32 appid = 0; uint32 appid = 0;
try { try {
appid = std::stoi(array); appid = std::stoi(array);
@ -61,7 +61,7 @@ Steam_Client::Steam_Client()
if (!appid) { if (!appid) {
memset(array, 0, sizeof(array)); memset(array, 0, sizeof(array));
array[0] = '0'; array[0] = '0';
Local_Storage::get_file_data(Local_Storage::get_game_settings_path() + "steam_appid.txt", array, sizeof(array) - 1); Local_Storage::get_file_data(program_path + "steam_appid.txt", array, sizeof(array) - 1);
try { try {
appid = std::stoi(array); appid = std::stoi(array);
} catch (...) {} } catch (...) {}
@ -169,8 +169,21 @@ Steam_Client::Steam_Client()
local_storage->store_data_settings("user_steam_id.txt", temp_text, strlen(temp_text)); local_storage->store_data_settings("user_steam_id.txt", temp_text, strlen(temp_text));
} }
settings_client = new Settings(user_id, CGameID(appid), name, language); bool steam_offline_mode = false;
settings_server = new Settings(generate_steam_id_server(), CGameID(appid), name, language); {
std::string steam_settings_path = Local_Storage::get_game_settings_path();
std::vector<std::string> paths = Local_Storage::get_filenames_path(steam_settings_path);
for (auto & p: paths) {
PRINT_DEBUG("steam settings path %s\n", p.c_str());
if (p == "offline.txt") {
steam_offline_mode = true;
}
}
}
settings_client = new Settings(user_id, CGameID(appid), name, language, steam_offline_mode);
settings_server = new Settings(generate_steam_id_server(), CGameID(appid), name, language, steam_offline_mode);
{ {
std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt"; std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt";

View File

@ -74,7 +74,7 @@ HSteamUser GetHSteamUser()
bool BLoggedOn() bool BLoggedOn()
{ {
PRINT_DEBUG("BLoggedOn\n"); PRINT_DEBUG("BLoggedOn\n");
return true; return !settings->is_offline();
} }
// returns the CSteamID of the account currently logged into the Steam client // returns the CSteamID of the account currently logged into the Steam client