mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-25 01:44:15 +08:00
refactor steam_apps
This commit is contained in:
parent
8c012f7101
commit
a09bc24437
@ -61,12 +61,14 @@ bool Steam_Apps::BIsVACBanned()
|
|||||||
const char *Steam_Apps::GetCurrentGameLanguage()
|
const char *Steam_Apps::GetCurrentGameLanguage()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Apps::GetCurrentGameLanguage\n");
|
PRINT_DEBUG("Steam_Apps::GetCurrentGameLanguage\n");
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
return settings->get_language();
|
return settings->get_language();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Steam_Apps::GetAvailableGameLanguages()
|
const char *Steam_Apps::GetAvailableGameLanguages()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Apps::GetAvailableGameLanguages\n");
|
PRINT_DEBUG("Steam_Apps::GetAvailableGameLanguages\n");
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
//TODO?
|
//TODO?
|
||||||
return settings->get_language();
|
return settings->get_language();
|
||||||
}
|
}
|
||||||
@ -141,21 +143,16 @@ bool Steam_Apps::BGetDLCDataByIndex( int iDLC, AppId_t *pAppID, bool *pbAvailabl
|
|||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Apps::BGetDLCDataByIndex\n");
|
PRINT_DEBUG("Steam_Apps::BGetDLCDataByIndex\n");
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
AppId_t appid;
|
AppId_t appid = k_uAppIdInvalid;
|
||||||
bool available;
|
bool available = false;
|
||||||
std::string name;
|
std::string name{};
|
||||||
if (!settings->getDLC(iDLC, appid, available, name)) return false;
|
if (!settings->getDLC(iDLC, appid, available, name)) return false;
|
||||||
|
|
||||||
if (pAppID) *pAppID = appid;
|
if (pAppID) *pAppID = appid;
|
||||||
if (pbAvailable) *pbAvailable = available;
|
if (pbAvailable) *pbAvailable = available;
|
||||||
if (pchName && cchNameBufferSize > 0) {
|
if (pchName && cchNameBufferSize > 0) {
|
||||||
if (cchNameBufferSize > name.size()) {
|
memset(pchName, 0, cchNameBufferSize);
|
||||||
cchNameBufferSize = name.size();
|
name.copy(pchName, cchNameBufferSize - 1);
|
||||||
pchName[cchNameBufferSize] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: should pchName be null terminated if the size is smaller or equal to the name size?
|
|
||||||
memcpy(pchName, name.data(), cchNameBufferSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -255,8 +252,9 @@ uint32 Steam_Apps::GetInstalledDepots( AppId_t appID, DepotId_t *pvecDepots, uin
|
|||||||
PRINT_DEBUG("Steam_Apps::GetInstalledDepots %u, %u\n", appID, cMaxDepots);
|
PRINT_DEBUG("Steam_Apps::GetInstalledDepots %u, %u\n", appID, cMaxDepots);
|
||||||
//TODO not sure about the behavior of this function, I didn't actually test this.
|
//TODO not sure about the behavior of this function, I didn't actually test this.
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
if (!pvecDepots) return 0;
|
unsigned int count = (unsigned int)settings->depots.size();
|
||||||
unsigned int count = settings->depots.size();
|
if (!pvecDepots || !cMaxDepots || !count) return 0;
|
||||||
|
|
||||||
if (cMaxDepots < count) count = cMaxDepots;
|
if (cMaxDepots < count) count = cMaxDepots;
|
||||||
std::copy(settings->depots.begin(), settings->depots.begin() + count, pvecDepots);
|
std::copy(settings->depots.begin(), settings->depots.begin() + count, pvecDepots);
|
||||||
return count;
|
return count;
|
||||||
@ -276,10 +274,10 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
|
|||||||
//TODO return real path instead of dll path
|
//TODO return real path instead of dll path
|
||||||
std::string installed_path = settings->getAppInstallPath(appID);
|
std::string installed_path = settings->getAppInstallPath(appID);
|
||||||
|
|
||||||
if (installed_path.size() == 0) {
|
if (installed_path.empty()) {
|
||||||
std::string dll_path = get_full_program_path();
|
std::string dll_path = get_full_program_path();
|
||||||
std::string current_path = get_current_path();
|
std::string current_path = get_current_path();
|
||||||
PRINT_DEBUG("Steam_Apps::paths %s %s\n", dll_path.c_str(), current_path.c_str());
|
PRINT_DEBUG(" Steam_Apps::GetAppInstallDircurrent dll: '%s', current: '%s'\n", dll_path.c_str(), current_path.c_str());
|
||||||
|
|
||||||
//Just pick the smallest path, it has the most chances of being the good one
|
//Just pick the smallest path, it has the most chances of being the good one
|
||||||
if (dll_path.size() > current_path.size() && current_path.size()) {
|
if (dll_path.size() > current_path.size() && current_path.size()) {
|
||||||
@ -289,9 +287,10 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_DEBUG("Steam_Apps::path %s\n", installed_path.c_str());
|
PRINT_DEBUG(" Steam_Apps::GetAppInstallDir final path '%s'\n", installed_path.c_str());
|
||||||
if (cchFolderBufferSize && pchFolder) {
|
if (pchFolder && cchFolderBufferSize) {
|
||||||
snprintf(pchFolder, cchFolderBufferSize, "%s", installed_path.c_str());
|
memset(pchFolder, 0, cchFolderBufferSize);
|
||||||
|
installed_path.copy(pchFolder, cchFolderBufferSize - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return installed_path.length(); //Real steam always returns the actual path length, not the copied one.
|
return installed_path.length(); //Real steam always returns the actual path length, not the copied one.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user