Changeset View
Changeset View
Standalone View
Standalone View
source/ps/UserReport.cpp
Show All 22 Lines | |||||
#include "lib/utf8.h" | #include "lib/utf8.h" | ||||
#include "lib/external_libraries/curl.h" | #include "lib/external_libraries/curl.h" | ||||
#include "lib/external_libraries/zlib.h" | #include "lib/external_libraries/zlib.h" | ||||
#include "lib/file/archive/stream.h" | #include "lib/file/archive/stream.h" | ||||
#include "lib/os_path.h" | #include "lib/os_path.h" | ||||
#include "lib/sysdep/sysdep.h" | #include "lib/sysdep/sysdep.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/GUID.h" | |||||
#include "ps/Profiler2.h" | #include "ps/Profiler2.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
#include "ps/Threading.h" | #include "ps/Threading.h" | ||||
#include <condition_variable> | #include <condition_variable> | ||||
#include <deque> | #include <deque> | ||||
#include <fstream> | #include <fstream> | ||||
#include <mutex> | #include <mutex> | ||||
▲ Show 20 Lines • Show All 479 Lines • ▼ Show 20 Lines | |||||
std::string CUserReporter::LoadUserID() | std::string CUserReporter::LoadUserID() | ||||
{ | { | ||||
std::string userID; | std::string userID; | ||||
// Read the user ID from user.cfg (if there is one) | // Read the user ID from user.cfg (if there is one) | ||||
CFG_GET_VAL("userreport.id", userID); | CFG_GET_VAL("userreport.id", userID); | ||||
// If we don't have a validly-formatted user ID, generate a new one | if (userID.length() == 16) | ||||
if (userID.length() != 16) | return userID; | ||||
{ | |||||
u8 bytes[8] = {0}; | |||||
sys_generate_random_bytes(bytes, ARRAY_SIZE(bytes)); | |||||
// ignore failures - there's not much we can do about it | |||||
userID = ""; | // We don't have a validly-formatted user ID, generate a new one | ||||
for (size_t i = 0; i < ARRAY_SIZE(bytes); ++i) | const std::string newUserID = ps_generate_guid(); | ||||
{ | |||||
char hex[3]; | |||||
sprintf_s(hex, ARRAY_SIZE(hex), "%02x", (unsigned int)bytes[i]); | |||||
userID += hex; | |||||
} | |||||
g_ConfigDB.SetValueString(CFG_USER, "userreport.id", userID); | g_ConfigDB.SetValueString(CFG_USER, "userreport.id", newUserID); | ||||
g_ConfigDB.WriteValueToFile(CFG_USER, "userreport.id", userID); | g_ConfigDB.WriteValueToFile(CFG_USER, "userreport.id", newUserID); | ||||
} | |||||
return userID; | return newUserID; | ||||
Stan: implicit cast. | |||||
Done Inline Actionsps_generate_guid implicitly converts the other way. phosit: `ps_generate_guid` implicitly converts the other way.
I'll make `ps_generate_guid` to return a… | |||||
Not Done Inline ActionsOk Stan: Ok | |||||
} | } | ||||
bool CUserReporter::IsReportingEnabled() | bool CUserReporter::IsReportingEnabled() | ||||
{ | { | ||||
int version = -1; | int version = -1; | ||||
CFG_GET_VAL("userreport.enabledversion", version); | CFG_GET_VAL("userreport.enabledversion", version); | ||||
return (version >= REPORTER_VERSION); | return (version >= REPORTER_VERSION); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
implicit cast.