mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-05 11:44:53 +01:00
Added a way to configure stats and moved parser logic to other file.
This commit is contained in:
parent
1d920c538a
commit
bca4bd6dc1
8 changed files with 486 additions and 298 deletions
|
|
@ -83,11 +83,21 @@ bool GetStat( const char *pchName, int32 *pData )
|
|||
PRINT_DEBUG("GetStat int32 %s\n", pchName);
|
||||
if (!pchName || !pData) return false;
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
auto stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(pchName);
|
||||
if (stats_data != stats_config.end()) {
|
||||
if (stats_data->second.type != Stat_Type::STAT_TYPE_INT) return false;
|
||||
}
|
||||
|
||||
int read_data = local_storage->get_data(STATS_STORAGE_FOLDER, pchName, (char* )pData, sizeof(*pData));
|
||||
if (read_data == sizeof(int32))
|
||||
return true;
|
||||
|
||||
if (stats_data != stats_config.end()) {
|
||||
*pData = stats_data->second.default_value_int;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -96,11 +106,21 @@ bool GetStat( const char *pchName, float *pData )
|
|||
PRINT_DEBUG("GetStat float %s\n", pchName);
|
||||
if (!pchName || !pData) return false;
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
auto stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(pchName);
|
||||
if (stats_data != stats_config.end()) {
|
||||
if (stats_data->second.type == Stat_Type::STAT_TYPE_INT) return false;
|
||||
}
|
||||
|
||||
int read_data = local_storage->get_data(STATS_STORAGE_FOLDER, pchName, (char* )pData, sizeof(*pData));
|
||||
if (read_data == sizeof(int32))
|
||||
if (read_data == sizeof(float))
|
||||
return true;
|
||||
|
||||
if (stats_data != stats_config.end()) {
|
||||
*pData = stats_data->second.default_value_float;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue