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

@ -33,7 +33,7 @@ std::string Settings::sanitize(std::string 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->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->lobby_id = k_steamIDNil;
this->unlockAllDLCs = true;
this->offline = offline;
}
CSteamID Settings::get_local_steam_id()

View file

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

View file

@ -46,7 +46,7 @@ Steam_Client::Steam_Client()
char array[10] = {};
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;
try {
appid = std::stoi(array);
@ -61,7 +61,7 @@ Steam_Client::Steam_Client()
if (!appid) {
memset(array, 0, sizeof(array));
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 {
appid = std::stoi(array);
} catch (...) {}
@ -169,8 +169,21 @@ Steam_Client::Steam_Client()
local_storage->store_data_settings("user_steam_id.txt", temp_text, strlen(temp_text));
}
settings_client = new Settings(user_id, CGameID(appid), name, language);
settings_server = new Settings(generate_steam_id_server(), CGameID(appid), name, language);
bool steam_offline_mode = false;
{
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";

View file

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