fix that stupid mistake in overlay when loading audio buffers

This commit is contained in:
otavepto 2024-04-10 12:27:37 +02:00
parent 837a0c30d5
commit 3c2b849601
4 changed files with 15 additions and 15 deletions

View File

@ -348,9 +348,9 @@ int GetFavoriteGameCount()
std::string file_path = Local_Storage::get_user_appdata_path() + "/7/" + Local_Storage::remote_storage_folder + "/serverbrowser_favorites.txt";
unsigned long long file_size = file_size_(file_path);
if (file_size) {
std::string list;
std::string list{};
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)list.data(), file_size, 0);
Local_Storage::get_file_data(file_path, (char *)&list[0], file_size, 0);
auto list_lines = std::count(list.begin(), list.end(), '\n');
list_lines += (!list.empty() && list.back() != '\n');
return list_lines;
@ -402,9 +402,9 @@ int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQuery
newip_string.append(newip);
if (file_size) {
std::string list;
std::string list{};
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)list.data(), file_size, 0);
Local_Storage::get_file_data(file_path, (char *)&list[0], file_size, 0);
auto list_lines = std::count(list.begin(), list.end(), '\n');
list_lines += (!list.empty() && list.back() != '\n');
@ -465,9 +465,9 @@ bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQ
}
if (file_size) {
std::string list;
std::string list{};
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)list.data(), file_size, 0);
Local_Storage::get_file_data(file_path, (char *)&list[0], file_size, 0);
unsigned char ip[4];
ip[0] = nIP & 0xFF;

View File

@ -61,7 +61,7 @@ HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod,
unsigned long long file_size = file_size_(file_path);
if (file_size) {
request.response.resize(file_size);
long long read = Local_Storage::get_file_data(file_path, (char *)request.response.data(), file_size, 0);
long long read = Local_Storage::get_file_data(file_path, (char *)&request.response[0], file_size, 0);
if (read < 0) read = 0;
if (read != file_size) request.response.resize(read);
}
@ -315,7 +315,7 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
unsigned int file_size = file_size_(request->target_filepath);
if (file_size) {
long long read = Local_Storage::get_file_data(request->target_filepath, (char *)request->response.data(), file_size, 0);
long long read = Local_Storage::get_file_data(request->target_filepath, (char *)&request->response[0], file_size, 0);
if (read < 0) read = 0;
request->response.resize(read);
}

View File

@ -99,15 +99,15 @@ HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, IS
}
PRINT_DEBUG("list file '%s' [%llu bytes]", file_path.c_str(), file_size);
std::string list;
std::string list{};
if (file_size) {
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)list.data(), file_size, 0);
Local_Storage::get_file_data(file_path, (char *)&list[0], file_size, 0);
} else {
return id;
}
std::istringstream list_ss (list);
std::istringstream list_ss(list);
std::string list_ip;
while (std::getline(list_ss, list_ip)) {
if (list_ip.length() <= 0) continue;

View File

@ -330,11 +330,11 @@ void Steam_Overlay::load_audio()
if (file_size) break;
}
kv.second.clear();
if (file_size) {
kv.second.assign(file_size, 0);
Local_Storage::get_file_data(file_path, (char *)&kv.second[0], file_size);
} else {
kv.second.clear();
kv.second.assign(file_size + 1, 0); // +1 because this will be treated as a null-terminated string later
int read = Local_Storage::get_file_data(file_path, (char *)&kv.second[0], file_size);
if (read <= 0) kv.second.clear();
}
}
}