fix more VS2022 warnings

This commit is contained in:
otavepto 2024-06-04 14:58:16 +03:00
parent 5268683850
commit c28a1f1f52
15 changed files with 103 additions and 100 deletions

View File

@ -177,7 +177,7 @@ bool AppTicketV4::Deserialize(const uint8_t* pBuffer, size_t size)
return false;
uint16_t appid_count = *reinterpret_cast<const uint16_t*>(pBuffer);
if (size < (appid_count * 4 + 2) || appid_count >= 140)
if (size < static_cast<size_t>(appid_count * 4 + 2) || appid_count >= 140u)
return false;
AppIDs.resize(appid_count);

View File

@ -697,8 +697,9 @@ Auth_Data Auth_Manager::getTicketData( void *pTicket, int cbMaxTicket, uint32 *p
std::vector<uint8_t> ser = ticket_data.Serialize();
uint32_t ser_size = static_cast<uint32_t>(ser.size());
*pcbTicket = ser_size;
if (cbMaxTicket >= ser_size)
if (cbMaxTicket > 0 && static_cast<uint32_t>(cbMaxTicket) >= ser_size) {
memcpy(pTicket, ser.data(), ser_size);
}
}
else
{
@ -736,8 +737,9 @@ HAuthTicket Auth_Manager::getTicket( void *pTicket, int cbMaxTicket, uint32 *pcb
Auth_Data ticket_data = getTicketData(pTicket, cbMaxTicket, pcbTicket );
if (*pcbTicket > cbMaxTicket)
if (*pcbTicket > static_cast<uint32>(cbMaxTicket)) {
return k_HAuthTicketInvalid;
}
GetAuthSessionTicketResponse_t data{};
data.m_hAuthTicket = (HAuthTicket)ticket_data.number;

View File

@ -229,7 +229,7 @@ static BOOL DirectoryExists(LPCWSTR szPath)
static void createDirectoryRecursively(std::wstring path)
{
unsigned long long pos = 0;
size_t pos = 0;
do
{
pos = path.find_first_of(L"\\/", pos + 1);
@ -765,7 +765,7 @@ bool Local_Storage::iterate_file(std::string folder, int index, char *output_fil
}
std::vector<struct File_Data> files = get_filenames_recursive(save_directory + appid + folder);
if (index < 0 || index >= files.size()) return false;
if (index < 0 || static_cast<size_t>(index) >= files.size()) return false;
std::string name(desanitize_file_name(files[index].name));
if (output_size) *output_size = file_size(folder, name);
@ -807,7 +807,7 @@ bool Local_Storage::load_json(std::string full_path, nlohmann::json& json)
// If there is a file and we opened it
if (inventory_file) {
inventory_file.seekg(0, std::ios::end);
size_t size = inventory_file.tellg();
size_t size = static_cast<size_t>(inventory_file.tellg());
std::string buffer(size, '\0');
inventory_file.seekg(0);
// Read it entirely, if the .json file gets too big,

View File

@ -133,7 +133,7 @@ void get_challenge(std::vector<uint8_t> &challenge_buff)
std::vector<uint8_t> Source_Query::handle_source_query(const void* buffer, size_t len, Gameserver const& gs)
{
std::vector<uint8_t> output_buffer;
std::vector<uint8_t> output_buffer{};
if (len < source_query_header_size) // its not at least 5 bytes long (0xFF 0xFF 0xFF 0xFF 0x??)
return output_buffer;
@ -206,7 +206,7 @@ std::vector<uint8_t> Source_Query::handle_source_query(const void* buffer, size_
serialize_response(output_buffer, source_response_header::A2S_PLAYER);
serialize_response(output_buffer, static_cast<uint8_t>(players.size())); // num_players
for (int i = 0; i < players.size(); ++i) {
for (unsigned i = 0; i < players.size(); ++i) {
serialize_response(output_buffer, static_cast<uint8_t>(i)); // player index
serialize_response(output_buffer, players[i].second.name); // player name
serialize_response(output_buffer, players[i].second.score); // player score

View File

@ -243,11 +243,12 @@ bool Steam_Apps::GetCurrentBetaName( char *pchName, int cchNameBufferSize )
{
PRINT_DEBUG("%p [%i]", pchName, cchNameBufferSize);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (pchName && cchNameBufferSize > settings->current_branch_name.size()) {
if (pchName && cchNameBufferSize > 0 && static_cast<size_t>(cchNameBufferSize) > settings->current_branch_name.size()) {
memset(pchName, 0, cchNameBufferSize);
memcpy(pchName, settings->current_branch_name.c_str(), settings->current_branch_name.size());
}
PRINT_DEBUG("returned '%s'", pchName);
return settings->is_beta_branch;
}

View File

@ -272,7 +272,11 @@ CSteamID Steam_Friends::GetFriendByIndex( int iFriend, int iFriendFlags )
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
CSteamID id = k_steamIDNil;
if (ok_friend_flags(iFriendFlags)) if (iFriend < friends.size()) id = CSteamID((uint64)friends[iFriend].id());
if (ok_friend_flags(iFriendFlags)) {
if (iFriend >= 0 && static_cast<size_t>(iFriend) < friends.size()) {
id = CSteamID((uint64)friends[iFriend].id());
}
}
return id;
}
@ -933,7 +937,7 @@ const char* Steam_Friends::GetFriendRichPresenceKeyByIndex( CSteamID steamIDFrie
f = find_friend(steamIDFriend);
}
if (f && is_appid_compatible(f) && f->rich_presence().size() > iKey && iKey >= 0) {
if (iKey >= 0 && f && is_appid_compatible(f) && f->rich_presence().size() > static_cast<size_t>(iKey)) {
auto friend_data = f->rich_presence().begin();
for (int i = 0; i < iKey; ++i) ++friend_data;
key = friend_data->first.c_str();

View File

@ -726,10 +726,14 @@ int Steam_GameServer::GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *p
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (settings->disable_source_query) return 0;
if (outgoing_packets.size() == 0) return 0;
if (outgoing_packets.empty()) return 0;
if (outgoing_packets.back().data.size() < cbMaxOut) cbMaxOut = static_cast<int>(outgoing_packets.back().data.size());
if (pOut) memcpy(pOut, outgoing_packets.back().data.data(), cbMaxOut);
if (cbMaxOut > 0) {
if (outgoing_packets.back().data.size() < static_cast<size_t>(cbMaxOut)) {
cbMaxOut = static_cast<int>(outgoing_packets.back().data.size());
}
if (pOut) memcpy(pOut, outgoing_packets.back().data.data(), cbMaxOut);
}
if (pNetAdr) *pNetAdr = outgoing_packets.back().ip;
if (pPort) *pPort = outgoing_packets.back().port;
outgoing_packets.pop_back();

View File

@ -63,7 +63,7 @@ HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod,
request.response.resize(file_size);
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);
if (read != file_size) request.response.resize(static_cast<size_t>(read));
}
}
@ -318,7 +318,7 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
if (file_size) {
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);
request->response.resize(static_cast<size_t>(read));
}
send_callresult();

View File

@ -291,7 +291,7 @@ int Steam_Matchmaking::GetFavoriteGameCount()
{
PRINT_DEBUG_ENTRY();
std::string file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt";
unsigned long long file_size = file_size_(file_path);
unsigned int file_size = file_size_(file_path);
if (file_size) {
std::string list{};
list.resize(file_size);
@ -321,35 +321,32 @@ int Steam_Matchmaking::AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConn
{
PRINT_DEBUG("%u %u %hu %hu %u %u", nAppID, nIP, nConnPort, nQueryPort, unFlags, rTime32LastPlayedOnServer);
std::string file_path;
unsigned long long file_size;
std::string file_path{};
unsigned int file_size{};
if (unFlags == 1) {
file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt";
file_size = file_size_(file_path);
}
else if (unFlags == 2) {
} else if (unFlags == 2) {
file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_history.txt";
file_size = file_size_(file_path);
}
else {
} else {
return 0;
}
unsigned char ip[4];
unsigned char ip[4]{};
ip[0] = nIP & 0xFF;
ip[1] = (nIP >> 8) & 0xFF;
ip[2] = (nIP >> 16) & 0xFF;
ip[3] = (nIP >> 24) & 0xFF;
char newip[24];
char newip[24]{};
snprintf(newip, sizeof(newip), "%d.%d.%d.%d:%d\n", ip[3], ip[2], ip[1], ip[0], nConnPort);
std::string newip_string;
newip_string.append(newip);
std::string newip_string(newip);
if (file_size) {
std::string list{};
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)&list[0], 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');
@ -358,7 +355,7 @@ int Steam_Matchmaking::AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConn
list.append(newip_string);
list.append("\n");
std::size_t file_directory = file_path.rfind("/");
std::size_t file_directory = file_path.find_last_of("/\\");
std::string directory_path;
std::string file_name;
if (file_directory != std::string::npos) {
@ -371,11 +368,10 @@ int Steam_Matchmaking::AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConn
}
return list_lines;
}
else {
} else {
newip_string.append("\n");
std::size_t file_directory = file_path.rfind("/");
std::size_t file_directory = file_path.find_last_of("/\\");
std::string directory_path;
std::string file_name;
if (file_directory != std::string::npos) {
@ -394,43 +390,40 @@ bool Steam_Matchmaking::RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 n
{
PRINT_DEBUG_ENTRY();
std::string file_path;
unsigned long long file_size;
std::string file_path{};
unsigned int file_size{};
if (unFlags == 1) {
file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + "serverbrowser_favorites.txt";
file_size = file_size_(file_path);
}
else if (unFlags == 2) {
} else if (unFlags == 2) {
file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + "serverbrowser_history.txt";
file_size = file_size_(file_path);
}
else {
} else {
return false;
}
if (file_size) {
std::string list{};
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)&list[0], file_size, 0);
Local_Storage::get_file_data(file_path, (char*)&list[0], file_size, 0);
unsigned char ip[4];
unsigned char ip[4]{};
ip[0] = nIP & 0xFF;
ip[1] = (nIP >> 8) & 0xFF;
ip[2] = (nIP >> 16) & 0xFF;
ip[3] = (nIP >> 24) & 0xFF;
char newip[24];
char newip[24]{};
snprintf((char *)newip, sizeof(newip), "%d.%d.%d.%d:%d\n", ip[3], ip[2], ip[1], ip[0], nConnPort);
std::string newip_string;
newip_string.append(newip);
std::string newip_string(newip);
std::size_t list_ip = list.find(newip_string);
if (list_ip != std::string::npos) {
list.erase(list_ip, newip_string.length());
std::size_t file_directory = file_path.rfind("/");
std::string directory_path;
std::string file_name;
std::size_t file_directory = file_path.find_last_of("/\\");
std::string directory_path{};
std::string file_name{};
if (file_directory != std::string::npos) {
directory_path = file_path.substr(0, file_directory);
file_name = file_path.substr(file_directory);
@ -600,7 +593,9 @@ CSteamID Steam_Matchmaking::GetLobbyByIndex( int iLobby )
PRINT_DEBUG("%i", iLobby);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
CSteamID id = k_steamIDNil;
if (0 <= iLobby && iLobby < filtered_lobbies.size()) id = filtered_lobbies[iLobby];
if (iLobby >= 0 && static_cast<size_t>(iLobby) < filtered_lobbies.size()) {
id = filtered_lobbies[iLobby];
}
PRINT_DEBUG("found lobby %llu", id.ConvertToUint64());
return id;
}
@ -868,7 +863,7 @@ bool Steam_Matchmaking::GetLobbyDataByIndex( CSteamID steamIDLobby, int iLobbyDa
Lobby *lobby = get_lobby(steamIDLobby);
bool ret = false;
if (lobby && lobby->values().size() > iLobbyData && iLobbyData >= 0) {
if (iLobbyData >= 0 && lobby && lobby->values().size() > static_cast<size_t>(iLobbyData)) {
auto lobby_data = lobby->values().begin();
for (int i = 0; i < iLobbyData; ++i) ++lobby_data;
if (pchKey && cchKeyBufferSize > 0) {
@ -914,7 +909,7 @@ const char* Steam_Matchmaking::GetLobbyMemberData( CSteamID steamIDLobby, CSteam
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchKey) return "";
struct Lobby_Member *member = get_lobby_member(get_lobby(steamIDLobby), steamIDUser);
Lobby_Member *member = get_lobby_member(get_lobby(steamIDLobby), steamIDUser);
const char *ret = "";
if (member) {
if (steamIDUser == settings->get_local_steam_id()) {
@ -1009,12 +1004,12 @@ int Steam_Matchmaking::GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, ST
{
PRINT_DEBUG("%llu %i %p %p %i %p", steamIDLobby.ConvertToUint64(), iChatID, pSteamIDUser, pvData, cubData, peChatEntryType);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (iChatID >= chat_entries.size() || iChatID < 0 || cubData < 0) return 0;
if (iChatID < 0 || cubData < 0 || static_cast<size_t>(iChatID) >= chat_entries.size()) return 0;
if (chat_entries[iChatID].lobby_id != steamIDLobby) return 0;
if (pSteamIDUser) *pSteamIDUser = chat_entries[iChatID].user_id;
if (peChatEntryType) *peChatEntryType = chat_entries[iChatID].type;
if (pvData) {
if (chat_entries[iChatID].message.size() <= cubData) {
if (chat_entries[iChatID].message.size() <= static_cast<size_t>(cubData)) {
cubData = chat_entries[iChatID].message.size();
memcpy(pvData, chat_entries[iChatID].message.data(), cubData);
PRINT_DEBUG(" Returned chat of len: %i", cubData);
@ -1357,7 +1352,7 @@ void Steam_Matchmaking::RunCallbacks()
int compare_to = 0;
//TODO: check if this is how real steam behaves
if (value->second.size()) {
compare_to = std::stoll(value->second, 0, 0);
compare_to = static_cast<int>(std::stoll(value->second, 0, 0));
}
PRINT_DEBUG("Compare Values %i %i", compare_to, f.value_int);
if (f.eComparisonType == k_ELobbyComparisonEqual) {

View File

@ -104,8 +104,8 @@ HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, IS
return id;
}
std::string file_path;
unsigned long long file_size;
std::string file_path{};
unsigned int file_size{};
if (type == eInternetServer || type == eSpectatorServer) {
file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser.txt";
file_size = file_size_(file_path);
@ -117,29 +117,29 @@ HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, IS
file_size = file_size_(file_path);
}
PRINT_DEBUG("list file '%s' [%llu bytes]", file_path.c_str(), file_size);
PRINT_DEBUG("list file '%s' [%u bytes]", file_path.c_str(), file_size);
std::string list{};
if (file_size) {
list.resize(file_size);
Local_Storage::get_file_data(file_path, (char *)&list[0], static_cast<unsigned int>(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::string list_ip;
std::string list_ip{};
while (std::getline(list_ss, list_ip)) {
if (list_ip.length() <= 0) continue;
unsigned int byte4, byte3, byte2, byte1, byte0;
uint32 ip_int;
uint16 port_int;
char newip[24];
unsigned int byte4{}, byte3{}, byte2{}, byte1{}, byte0{};
uint32 ip_int{};
uint16 port_int{};
char newip[24]{};
if (sscanf(list_ip.c_str(), "%u.%u.%u.%u:%u", &byte3, &byte2, &byte1, &byte0, &byte4) == 5) {
ip_int = (byte3 << 24) + (byte2 << 16) + (byte1 << 8) + byte0;
port_int = byte4;
unsigned char ip_tmp[4];
unsigned char ip_tmp[4]{};
ip_tmp[0] = ip_int & 0xFF;
ip_tmp[1] = (ip_int >> 8) & 0xFF;
ip_tmp[2] = (ip_int >> 16) & 0xFF;
@ -390,7 +390,7 @@ gameserveritem_t *Steam_Matchmaking_Servers::GetServerDetails( HServerListReques
++g;
}
if (iServer >= gameservers_filtered.size() || iServer < 0) {
if (iServer < 0 || static_cast<size_t>(iServer) >= gameservers_filtered.size()) {
return NULL;
}
@ -593,14 +593,14 @@ void Steam_Matchmaking_Servers::server_details(Gameserver *g, gameserveritem_t *
if (settings->matchmaking_server_details_via_source_query && !(g->ip() < 0) && !(g->query_port() < 0)) {
unsigned char ip[4]{};
char newip[24];
char newip[24]{};
ip[0] = g->ip() & 0xFF;
ip[1] = (g->ip() >> 8) & 0xFF;
ip[2] = (g->ip() >> 16) & 0xFF;
ip[3] = (g->ip() >> 24) & 0xFF;
snprintf(newip, sizeof(newip), "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
PRINT_DEBUG(" connecting to ssq server on %s:%u", newip, g->query_port());
PRINT_DEBUG(" connecting to ssq server on %s:%u", newip, g->query_port());
SSQ_SERVER *ssq = ssq_server_new(newip, g->query_port());
if (ssq != NULL && ssq_server_eok(ssq)) {
PRINT_DEBUG(" ssq server connection ok");
@ -733,7 +733,8 @@ void Steam_Matchmaking_Servers::server_details_players(Gameserver *g, Steam_Matc
const auto &players = get_steam_client()->steam_gameserver->get_players();
auto player = players->cbegin();
for (uint32_t i = 0; i < number_players && player != players->end(); ++i, ++player) {
float playtime = static_cast<float>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - player->second.join_time).count());
auto duration = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - player->second.join_time);
float playtime = static_cast<float>(duration.count());
PRINT_DEBUG(" PLAYER [%u] '%s' %u %f", i, player->second.name.c_str(), player->second.score, playtime);
r->players_response->AddPlayerToList(player->second.name.c_str(), player->second.score, playtime);
}

View File

@ -514,7 +514,7 @@ bool Steam_Networking_Utils::SteamNetworkingIPAddr_ParseString( SteamNetworkingI
size_t sep_pos = 0;
std::string ip;
int sep_count = 0;
for (int i = 0; i < str.length(); ++i) {
for (unsigned i = 0; i < str.length(); ++i) {
if (str[i] == ':') {
sep_pos = i;
++sep_count;

View File

@ -147,15 +147,13 @@ bool Steam_Remote_Storage::FileReadAsyncComplete( SteamAPICall_t hReadCall, void
if (cubToRead < a_read->to_read)
return false;
char *temp = new char[a_read->size];
int read_data = local_storage->get_data(Local_Storage::remote_storage_folder, a_read->file_name, (char* )temp, a_read->size);
if (read_data < a_read->to_read + a_read->offset) {
delete[] temp;
std::vector<char> temp(a_read->size);
int read_data = local_storage->get_data(Local_Storage::remote_storage_folder, a_read->file_name, (char* )&temp[0], a_read->size);
if (read_data < 0 || (static_cast<uint32>(read_data) < (a_read->to_read + a_read->offset))) {
return false;
}
memcpy(pvBuffer, temp + a_read->offset, a_read->to_read);
delete[] temp;
memcpy(pvBuffer, &temp[0] + a_read->offset, a_read->to_read);
async_reads.erase(a_read);
return true;
}

View File

@ -426,18 +426,18 @@ SteamAPICall_t Steam_User::RequestEncryptedAppTicket( void *pDataToInclude, int
// retrieve a finished ticket
bool Steam_User::GetEncryptedAppTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket )
{
PRINT_DEBUG("%i", cbMaxTicket);
unsigned int ticket_size = static_cast<unsigned int>(encrypted_app_ticket.size());
if (!cbMaxTicket) {
PRINT_DEBUG("%i %p %p", cbMaxTicket, pTicket, pcbTicket);
uint32 ticket_size = static_cast<uint32>(encrypted_app_ticket.size());
if (pcbTicket) *pcbTicket = ticket_size;
if (cbMaxTicket <= 0) {
if (!pcbTicket) return false;
*pcbTicket = ticket_size;
return true;
}
if (!pTicket) return false;
if (ticket_size > cbMaxTicket) return false;
if (ticket_size > static_cast<uint32>(cbMaxTicket)) return false;
encrypted_app_ticket.copy((char *)pTicket, cbMaxTicket);
if (pcbTicket) *pcbTicket = ticket_size;
return true;
}

View File

@ -539,7 +539,7 @@ Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo
oldcount += flCountThisSession;
oldsessionlength += dSessionLength;
float average = oldcount / oldsessionlength;
float average = static_cast<float>(oldcount / oldsessionlength);
memcpy(data, &average, sizeof(average));
memcpy(data + sizeof(float), &oldcount, sizeof(oldcount));
memcpy(data + sizeof(float) * 2, &oldsessionlength, sizeof(oldsessionlength));
@ -1421,7 +1421,7 @@ const char * Steam_User_Stats::GetLeaderboardName( SteamLeaderboard_t hSteamLead
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return "";
return cached_leaderboards[hSteamLeaderboard - 1].name.c_str();
return cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].name.c_str();
}
@ -1432,7 +1432,7 @@ int Steam_User_Stats::GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderb
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return 0;
return (int)cached_leaderboards[hSteamLeaderboard - 1].entries.size();
return (int)cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].entries.size();
}
@ -1443,7 +1443,7 @@ ELeaderboardSortMethod Steam_User_Stats::GetLeaderboardSortMethod( SteamLeaderbo
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardSortMethodNone;
return cached_leaderboards[hSteamLeaderboard - 1].sort_method;
return cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].sort_method;
}
@ -1454,7 +1454,7 @@ ELeaderboardDisplayType Steam_User_Stats::GetLeaderboardDisplayType( SteamLeader
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardDisplayTypeNone;
return cached_leaderboards[hSteamLeaderboard - 1].display_type;
return cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].display_type;
}
@ -1473,7 +1473,7 @@ SteamAPICall_t Steam_User_Stats::DownloadLeaderboardEntries( SteamLeaderboard_t
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_uAPICallInvalid; //might return callresult even if hSteamLeaderboard is invalid
int entries_count = (int)cached_leaderboards[hSteamLeaderboard - 1].entries.size();
int entries_count = (int)cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)].entries.size();
// https://partner.steamgames.com/doc/api/ISteamUserStats#ELeaderboardDataRequest
if (eLeaderboardDataRequest != k_ELeaderboardDataRequestFriends) {
int required_count = nRangeEnd - nRangeStart + 1;
@ -1502,7 +1502,7 @@ SteamAPICall_t Steam_User_Stats::DownloadLeaderboardEntriesForUsers( SteamLeader
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_uAPICallInvalid; //might return callresult even if hSteamLeaderboard is invalid
auto &board = cached_leaderboards[hSteamLeaderboard - 1];
auto& board = cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)];
bool ok = true;
int total_count = 0;
if (prgUsers && cUsers > 0) {
@ -1553,8 +1553,8 @@ bool Steam_User_Stats::GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboardEntries > cached_leaderboards.size() || hSteamLeaderboardEntries <= 0) return false;
const auto &board = cached_leaderboards[hSteamLeaderboardEntries - 1];
if (index < 0 || index >= board.entries.size()) return false;
const auto &board = cached_leaderboards[static_cast<unsigned>(hSteamLeaderboardEntries - 1)];
if (index < 0 || static_cast<size_t>(index) >= board.entries.size()) return false;
const auto &target_entry = board.entries[index];
@ -1568,7 +1568,7 @@ bool Steam_User_Stats::GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t
}
if (pDetails && cDetailsMax > 0) {
for (int i = 0; i < target_entry.score_details.size() && i < cDetailsMax; ++i) {
for (unsigned i = 0; i < target_entry.score_details.size() && i < static_cast<unsigned>(cDetailsMax); ++i) {
pDetails[i] = target_entry.score_details[i];
}
}
@ -1588,7 +1588,7 @@ SteamAPICall_t Steam_User_Stats::UploadLeaderboardScore( SteamLeaderboard_t hSte
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return k_uAPICallInvalid; //TODO: might return callresult even if hSteamLeaderboard is invalid
auto &board = cached_leaderboards[hSteamLeaderboard - 1];
auto &board = cached_leaderboards[static_cast<unsigned>(hSteamLeaderboard - 1)];
auto my_entry = board.find_recent_entry(settings->get_local_steam_id());
int current_rank = my_entry
? 1 + (int)(my_entry - &board.entries[0])
@ -1756,7 +1756,7 @@ int Steam_User_Stats::GetNextMostAchievedAchievementInfo( int iIteratorPrevious,
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (iIteratorPrevious < 0) return -1;
int iIteratorCurrent = iIteratorPrevious + 1;
unsigned iIteratorCurrent = static_cast<unsigned>(iIteratorPrevious + 1);
if (iIteratorCurrent >= defined_achievements.size()) return -1;
std::string name(GetAchievementName(iIteratorCurrent));
@ -1776,7 +1776,7 @@ int Steam_User_Stats::GetNextMostAchievedAchievementInfo( int iIteratorPrevious,
*pbAchieved = achieved;
}
return iIteratorCurrent;
return static_cast<int>(iIteratorCurrent);
}

View File

@ -82,7 +82,7 @@ bool Steam_Utils::GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight )
if (!iImage || !pnWidth || !pnHeight) return false;
auto image = settings->images.find(iImage);
if (image == settings->images.end()) return false;
if (settings->images.end() == image) return false;
*pnWidth = image->second.width;
*pnHeight = image->second.height;
@ -94,16 +94,14 @@ bool Steam_Utils::GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight )
// the destination buffer size should be 4 * height * width * sizeof(char)
bool Steam_Utils::GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize )
{
PRINT_DEBUG("%i", iImage);
PRINT_DEBUG("%i %p %i", iImage, pubDest, nDestBufferSize);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!iImage || !pubDest || !nDestBufferSize) return false;
if (!iImage || !pubDest || nDestBufferSize <= 0) return false;
auto image = settings->images.find(iImage);
if (image == settings->images.end()) return false;
if (settings->images.end() == image) return false;
unsigned size = static_cast<unsigned>(image->second.data.size());
if (nDestBufferSize < size) size = nDestBufferSize;
image->second.data.copy((char *)pubDest, nDestBufferSize);
return true;
}
@ -111,7 +109,7 @@ bool Steam_Utils::GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize
// returns the IP of the reporting server for valve - currently only used in Source engine games
bool Steam_Utils::GetCSERIPPort( uint32 *unIP, uint16 *usPort )
{
PRINT_DEBUG_ENTRY();
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return false;
}
@ -122,7 +120,7 @@ uint8 Steam_Utils::GetCurrentBatteryPower()
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return 255;
return 255; // AC
}