fix more VS warnings

This commit is contained in:
otavepto 2024-06-06 21:08:42 +03:00
parent 05b6ccdcf8
commit 57846cb133
4 changed files with 31 additions and 27 deletions

View File

@ -291,9 +291,9 @@ static int send_packet_to(sock_t sock, IP_PORT ip_port, char *data, unsigned lon
struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
#if defined(STEAM_WIN32)
size_t addrsize = sizeof(struct sockaddr_in);
int addrsize = (int)sizeof(struct sockaddr_in);
#else
socklen_t addrsize = sizeof(struct sockaddr_in);
socklen_t addrsize = (socklen_t)sizeof(struct sockaddr_in);
#endif
addr4->sin_family = AF_INET;
addr4->sin_addr.s_addr = ip_port.ip;
@ -378,9 +378,9 @@ static bool bind_socket(sock_t sock, uint16 port)
struct sockaddr_storage addr = {};
struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
#if defined(STEAM_WIN32)
size_t addrsize = sizeof(struct sockaddr_in);
int addrsize = (int)sizeof(struct sockaddr_in);
#else
socklen_t addrsize = sizeof(struct sockaddr_in);
socklen_t addrsize = (socklen_t)sizeof(struct sockaddr_in);
#endif
addr4->sin_family = AF_INET;
addr4->sin_port = htons(port);
@ -400,9 +400,9 @@ static void connect_socket(sock_t sock, IP_PORT ip_port)
struct sockaddr_storage addr;
struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
#if defined(STEAM_WIN32)
size_t addrsize = sizeof(struct sockaddr_in);
int addrsize = (int)sizeof(struct sockaddr_in);
#else
socklen_t addrsize = sizeof(struct sockaddr_in);
socklen_t addrsize = (socklen_t)sizeof(struct sockaddr_in);
#endif
addr4->sin_family = AF_INET;
addr4->sin_addr.s_addr = ip_port.ip;

View File

@ -21,8 +21,8 @@ void Steam_Game_Coordinator::push_incoming(std::string message)
{
outgoing_messages.push(message);
struct GCMessageAvailable_t data;
data.m_nMessageSize = message.size();
struct GCMessageAvailable_t data{};
data.m_nMessageSize = static_cast<uint32>(message.size());
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
@ -88,7 +88,7 @@ bool Steam_Game_Coordinator::IsMessageAvailable( uint32 *pcubMsgSize )
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (outgoing_messages.size()) {
if (pcubMsgSize) *pcubMsgSize = outgoing_messages.front().size();
if (pcubMsgSize) *pcubMsgSize = static_cast<uint32>(outgoing_messages.front().size());
return true;
} else {
return false;
@ -109,7 +109,7 @@ EGCResults Steam_Game_Coordinator::RetrieveMessage( uint32 *punMsgType, void *pu
}
outgoing_messages.front().copy((char *)pubDest, cubDest);
if (pcubMsgSize) *pcubMsgSize = outgoing_messages.front().size();
if (pcubMsgSize) *pcubMsgSize = static_cast<uint32>(outgoing_messages.front().size());
if (punMsgType && outgoing_messages.front().size() >= sizeof(uint32)) {
outgoing_messages.front().copy((char *)punMsgType, sizeof(uint32));
*punMsgType = ntohl(*punMsgType);

View File

@ -298,7 +298,7 @@ int Steam_Matchmaking::GetFavoriteGameCount()
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;
return static_cast<int>(list_lines);
}
return 0;
}
@ -364,10 +364,11 @@ int Steam_Matchmaking::AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConn
}
Local_Storage::store_file_data(directory_path, file_name, (char *)list.data(), list.size());
return ++list_lines;
++list_lines;
return static_cast<int>(list_lines);
}
return list_lines;
return static_cast<int>(list_lines);
} else {
newip_string.append("\n");
@ -847,7 +848,7 @@ int Steam_Matchmaking::GetLobbyDataCount( CSteamID steamIDLobby )
Lobby *lobby = get_lobby(steamIDLobby);
int size = 0;
if (lobby) size = lobby->values().size();
if (lobby) size = static_cast<int>(lobby->values().size());
return size;
@ -1010,7 +1011,7 @@ int Steam_Matchmaking::GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, ST
if (peChatEntryType) *peChatEntryType = chat_entries[iChatID].type;
if (pvData) {
if (chat_entries[iChatID].message.size() <= static_cast<size_t>(cubData)) {
cubData = chat_entries[iChatID].message.size();
cubData = static_cast<int>(chat_entries[iChatID].message.size());
memcpy(pvData, chat_entries[iChatID].message.data(), cubData);
PRINT_DEBUG(" Returned chat of len: %i", cubData);
return cubData;
@ -1387,7 +1388,7 @@ void Steam_Matchmaking::RunCallbacks()
PRINT_DEBUG("returning lobby search results, count=%zu", filtered_lobbies.size());
searching = false;
LobbyMatchList_t data{};
data.m_nLobbiesMatching = filtered_lobbies.size();
data.m_nLobbiesMatching = static_cast<uint32>(filtered_lobbies.size());
callback_results->addCallResult(search_call_api_id, data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
search_call_api_id = 0;
@ -1398,7 +1399,7 @@ void Steam_Matchmaking::RunCallbacks()
if (searching && check_timedout(lobby_last_search, LOBBY_SEARCH_TIMEOUT)) {
PRINT_DEBUG("LOBBY_SEARCH_TIMEOUT %zu", filtered_lobbies.size());
LobbyMatchList_t data{};
data.m_nLobbiesMatching = filtered_lobbies.size();
data.m_nLobbiesMatching = static_cast<uint32>(filtered_lobbies.size());
callback_results->addCallResult(search_call_api_id, data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
searching = false;
@ -1617,7 +1618,7 @@ void Steam_Matchmaking::Callback(Common_Message *msg)
data.m_ulSteamIDLobby = msg->lobby_messages().id();
data.m_ulSteamIDUser = msg->source_id();
data.m_eChatEntryType = entry.type;
data.m_iChatID = chat_entries.size();
data.m_iChatID = static_cast<uint32>(chat_entries.size());
chat_entries.push_back(entry);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}

View File

@ -227,7 +227,8 @@ void Steam_User_Stats::save_my_leaderboard_entry(const Steam_Leaderboard &leader
}
std::string leaderboard_name(common_helpers::ascii_to_lowercase(leaderboard.name));
local_storage->store_data(Local_Storage::leaderboard_storage_folder, leaderboard_name, (char* )&output[0], output.size() * sizeof(output[0]));
unsigned int buffer_size = static_cast<unsigned int>(output.size() * sizeof(output[0])); // in bytes
local_storage->store_data(Local_Storage::leaderboard_storage_folder, leaderboard_name, (char* )&output[0], buffer_size);
}
Steam_Leaderboard_Entry* Steam_User_Stats::update_leaderboard_entry(Steam_Leaderboard &leaderboard, const Steam_Leaderboard_Entry &entry, bool overwrite)
@ -283,7 +284,7 @@ unsigned int Steam_User_Stats::cache_leaderboard_ifneeded(const std::string &nam
// save it in memory for later
cached_leaderboards.push_back(new_board);
board_handle = cached_leaderboards.size();
board_handle = static_cast<unsigned int>(cached_leaderboards.size());
PRINT_DEBUG("cached a new leaderboard '%s' %i %i",
new_board.name.c_str(), (int)eLeaderboardSortMethod, (int)eLeaderboardDisplayType
@ -1164,14 +1165,16 @@ bool Steam_User_Stats::IndicateAchievementProgress( const char *pchName, uint32
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
UserAchievementStored_t data{};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_bGroupAchievement = false;
data.m_nCurProgress = nCurProgress;
data.m_nMaxProgress = nMaxProgress;
ach_name.copy(data.m_rgchAchievementName, sizeof(data.m_rgchAchievementName) - 1);
{
UserAchievementStored_t data{};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_bGroupAchievement = false;
data.m_nCurProgress = nCurProgress;
data.m_nMaxProgress = nMaxProgress;
ach_name.copy(data.m_rgchAchievementName, sizeof(data.m_rgchAchievementName) - 1);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
// callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); // TODO was this correct?
return true;
}