(only left like the >or < comparision with unsigned/signed)
steam_matchmaking.cpp(241,40) has C4244 issue, look into it!
This commit is contained in:
Detanup01 2024-05-25 14:59:13 +02:00 committed by otavepto
parent 3a6a7cef73
commit 7c5b4e5325
15 changed files with 91 additions and 91 deletions

View File

@ -61,7 +61,7 @@ static void save_global_ini_value(class Local_Storage *local_storage, const char
auto sz = local_storage->data_settings_size(filename);
if (sz > 0) {
std::vector<char> ini_file_data(sz);
auto read = local_storage->get_data_settings(filename, &ini_file_data[0], ini_file_data.size());
auto read = local_storage->get_data_settings(filename, &ini_file_data[0], static_cast<unsigned int>(ini_file_data.size()));
if (read == sz) {
new_ini.LoadData(&ini_file_data[0], ini_file_data.size());
}
@ -96,7 +96,7 @@ static void save_global_ini_value(class Local_Storage *local_storage, const char
std::string ini_buff{};
if (new_ini.Save(ini_buff, false) == SI_OK) {
local_storage->store_data_settings(filename, &ini_buff[0], ini_buff.size());
local_storage->store_data_settings(filename, &ini_buff[0], static_cast<unsigned int>(ini_buff.size()));
}
}
@ -545,7 +545,7 @@ static bool parse_local_save(std::string &save_path)
// main::connectivity::listen_port
static uint16 parse_listen_port(class Local_Storage *local_storage)
{
uint16 port = ini.GetLongValue("main::connectivity", "listen_port");
uint16 port = static_cast<uint16>(ini.GetLongValue("main::connectivity", "listen_port"));
if (port == 0) {
port = DEFAULT_PORT;
save_global_ini_value(

View File

@ -199,7 +199,7 @@ static void FillProofOfPurchaseKey( AppProofOfPurchaseKeyResponse_t& data, AppId
? key.size() < k_cubAppProofOfPurchaseKeyMax
: k_cubAppProofOfPurchaseKeyMax - 1; // -1 because we need space for null
data.m_eResult = EResult::k_EResultOK;
data.m_cchKeyLength = min_len;
data.m_cchKeyLength = static_cast<uint32>(min_len);
memcpy(data.m_rgchKey, key.c_str(), min_len);
data.m_rgchKey[min_len] = 0;
} else {
@ -307,7 +307,7 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
installed_path.copy(pchFolder, cchFolderBufferSize - 1);
}
return installed_path.length(); //Real steam always returns the actual path length, not the copied one.
return static_cast<uint32>(installed_path.length()); //Real steam always returns the actual path length, not the copied one.
}
// returns true if that app is installed (not necessarily owned)
@ -387,7 +387,7 @@ void Steam_Apps::RequestAllProofOfPurchaseKeys()
// DLCs
const auto count = settings->DLCCount();
for (size_t i = 0; i < settings->DLCCount(); i++) {
for (unsigned int i = 0; i < settings->DLCCount(); i++) {
AppId_t app_id;
bool available;
std::string name;

View File

@ -201,7 +201,7 @@ void Steam_Controller::background_rumble(Rumble_Thread_Data *data)
}
}
GamepadSetRumble((GAMEPAD_DEVICE)gamepad, ((double)left) / 65535.0, ((double)right) / 65535.0, rumble_length_ms);
GamepadSetRumble((GAMEPAD_DEVICE)gamepad, ((float)left) / 65535.0f, ((float)right) / 65535.0f, rumble_length_ms);
}
}
@ -734,9 +734,9 @@ ControllerAnalogActionData_t Steam_Controller::GetAnalogActionData( ControllerHa
int mov_y = (int)GamepadButtonDown(device, BUTTON_DPAD_UP) - (int)GamepadButtonDown(device, BUTTON_DPAD_DOWN);
int mov_x = (int)GamepadButtonDown(device, BUTTON_DPAD_RIGHT) - (int)GamepadButtonDown(device, BUTTON_DPAD_LEFT);
if (mov_y || mov_x) {
data.x = mov_x;
data.y = mov_y;
double length = 1.0 / std::sqrt(data.x * data.x + data.y * data.y);
data.x = static_cast<float>(mov_x);
data.y = static_cast<float>(mov_y);
float length = 1.0f / std::sqrt(data.x * data.x + data.y * data.y);
data.x = data.x * length;
data.y = data.y * length;
}
@ -877,7 +877,7 @@ void Steam_Controller::TriggerVibration( ControllerHandle_t controllerHandle, un
rumble_length_ms = 100;
#endif
unsigned gamepad_device = (controllerHandle - 1);
unsigned gamepad_device = (static_cast<unsigned int>(controllerHandle) - 1);
if (gamepad_device > GAMEPAD_COUNT) return;
rumble_thread_data->rumble_mutex.lock();
rumble_thread_data->data[gamepad_device].new_data = true;
@ -910,7 +910,7 @@ int Steam_Controller::GetGamepadIndexForController( ControllerHandle_t ulControl
auto controller = controllers.find(ulControllerHandle);
if (controller == controllers.end()) return -1;
return ulControllerHandle - 1;
return static_cast<int>(ulControllerHandle) - 1;
}

View File

@ -251,7 +251,7 @@ int Steam_Friends::GetFriendCount( int iFriendFlags )
PRINT_DEBUG("%i", iFriendFlags);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
int count = 0;
if (ok_friend_flags(iFriendFlags)) count = friends.size();
if (ok_friend_flags(iFriendFlags)) count = static_cast<int>(friends.size());
PRINT_DEBUG("count %i", count);
return count;
}
@ -871,7 +871,7 @@ int Steam_Friends::GetFriendRichPresenceKeyCount( CSteamID steamIDFriend )
f = find_friend(steamIDFriend);
}
if (f && is_appid_compatible(f)) num = f->rich_presence().size();
if (f && is_appid_compatible(f)) num = static_cast<int>(f->rich_presence().size());
return num;
}
@ -1199,7 +1199,7 @@ void Steam_Friends::RunCallbacks()
void Steam_Friends::Callback(Common_Message *msg)
{
if (msg->has_low_level()) {
if (msg->low_level().type() == Low_Level::DISCONNECT) {
if (msg->low_level().type() & Low_Level::DISCONNECT) {
PRINT_DEBUG("Disconnect");
uint64 id = msg->source_id();
auto f = std::find_if(friends.begin(), friends.end(), [&id](Friend const& item) { return item.id() == id; });
@ -1210,7 +1210,7 @@ void Steam_Friends::Callback(Common_Message *msg)
}
}
if (msg->low_level().type() == Low_Level::CONNECT) {
if (msg->low_level().type() & Low_Level::CONNECT) {
PRINT_DEBUG("Connect %llu", (uint64)msg->source_id());
Common_Message msg_;
msg_.set_source_id(settings->get_local_steam_id().ConvertToUint64());
@ -1254,7 +1254,7 @@ void Steam_Friends::Callback(Common_Message *msg)
}
if (msg->has_friend_messages()) {
if (msg->friend_messages().type() == Friend_Messages::LOBBY_INVITE) {
if (msg->friend_messages().type() & Friend_Messages::LOBBY_INVITE) {
PRINT_DEBUG("Got Lobby Invite");
Friend *f = find_friend((uint64)msg->source_id());
if (f) {
@ -1280,7 +1280,7 @@ void Steam_Friends::Callback(Common_Message *msg)
}
}
if (msg->friend_messages().type() == Friend_Messages::GAME_INVITE) {
if (msg->friend_messages().type() & Friend_Messages::GAME_INVITE) {
PRINT_DEBUG("Got Game Invite");
//TODO: I'm pretty sure that the user should accept the invite before this is posted but we do like above
if (overlay->Ready() && !settings->hasOverlayAutoAcceptInviteFromFriend(msg->source_id()))

View File

@ -58,7 +58,7 @@ HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod,
if (url.back() == '/') url += "index.html";
std::string file_path = Local_Storage::get_game_settings_path() + "http" + PATH_SEPARATOR + Local_Storage::sanitize_string(url.substr(url_index));
request.target_filepath = file_path;
unsigned long long file_size = file_size_(file_path);
unsigned int 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[0], file_size, 0);
@ -170,7 +170,7 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
struct HTTPRequestCompleted_t data{};
data.m_hRequest = request->handle;
data.m_ulContextValue = request->context_value;
data.m_unBodySize = request->response.size();
data.m_unBodySize = static_cast<uint32>(request->response.size());
if (request->response.empty() && !settings->force_steamhttp_success) {
data.m_bRequestSuccessful = false;
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
@ -346,7 +346,7 @@ bool Steam_HTTP::SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pC
struct HTTPRequestCompleted_t data{};
data.m_hRequest = request->handle;
data.m_ulContextValue = request->context_value;
data.m_unBodySize = request->response.size();
data.m_unBodySize = static_cast<uint32>(request->response.size());
if (request->response.empty() && !settings->force_steamhttp_success) {
data.m_bRequestSuccessful = false;
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;

View File

@ -178,7 +178,7 @@ bool Steam_Inventory::GetResultItems( SteamInventoryResult_t resultHandle,
if (!max_items) break;
auto it = user_items.find(std::to_string(itemid));
if (it != user_items.end()) {
pOutItemsArray->m_iDefinition = itemid;
pOutItemsArray->m_iDefinition = static_cast<int32>(itemid);
pOutItemsArray->m_itemId = itemid;
try
@ -196,14 +196,14 @@ bool Steam_Inventory::GetResultItems( SteamInventoryResult_t resultHandle,
}
}
*punOutItemsArraySize = pOutItemsArray - items_array_base;
*punOutItemsArraySize = static_cast<uint32>(pOutItemsArray - items_array_base);
}
else if (punOutItemsArraySize != nullptr)
{
if (request->full_query) {
*punOutItemsArraySize = user_items.size();
*punOutItemsArraySize = static_cast<uint32>(user_items.size());
} else {
*punOutItemsArraySize = std::count_if(request->instance_ids.begin(), request->instance_ids.end(), [this](SteamItemInstanceID_t item_id){ return user_items.find(std::to_string(item_id)) != user_items.end();});
*punOutItemsArraySize = static_cast<uint32>(std::count_if(request->instance_ids.begin(), request->instance_ids.end(), [this](SteamItemInstanceID_t item_id){ return user_items.find(std::to_string(item_id)) != user_items.end();}));
}
}
@ -634,11 +634,11 @@ bool Steam_Inventory::GetItemDefinitionIDs(
if (pItemDefIDs == nullptr || *punItemDefIDsArraySize == 0)
{
*punItemDefIDsArraySize = defined_items.size();
*punItemDefIDsArraySize = static_cast<uint32>(defined_items.size());
return true;
}
if (*punItemDefIDsArraySize < defined_items.size())
if (*punItemDefIDsArraySize < static_cast<uint32>(defined_items.size()))
return false;
for (auto i = defined_items.begin(); i != defined_items.end(); ++i)
@ -694,7 +694,7 @@ bool Steam_Inventory::GetItemDefinitionProperty( SteamItemDef_t iDefinition, con
else
{
// Set punValueBufferSizeOut to the property size
*punValueBufferSizeOut = val.length() + 1;
*punValueBufferSizeOut = static_cast<uint32>(val.length()) + 1;
}
if (pchValueBuffer != nullptr)
@ -719,7 +719,7 @@ bool Steam_Inventory::GetItemDefinitionProperty( SteamItemDef_t iDefinition, con
// Should I check for punValueBufferSizeOut == nullptr ?
*punValueBufferSizeOut = 0;
for (auto i = item.value().begin(); i != item.value().end(); ++i)
*punValueBufferSizeOut += i.key().length() + 1; // Size of key + comma, and the last is not a comma but null char
*punValueBufferSizeOut += static_cast<uint32>(i.key().length()) + 1; // Size of key + comma, and the last is not a comma but null char
}
else
{

View File

@ -121,7 +121,7 @@ HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, IS
std::string list{};
if (file_size) {
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], static_cast<unsigned int>(file_size), 0);
} else {
return id;
}
@ -451,7 +451,7 @@ int Steam_Matchmaking_Servers::GetServerCount( HServerListRequest hRequest )
auto g = std::begin(requests);
while (g != std::end(requests)) {
if (g->id == hRequest) {
size = g->gameservers_filtered.size();
size = static_cast<int>(g->gameservers_filtered.size());
break;
}
@ -639,9 +639,9 @@ void Steam_Matchmaking_Servers::server_details(Gameserver *g, gameserveritem_t *
if (ssq_a2s_info->vac) g->set_secure(true);
else g->set_secure(false);
g->set_num_players(ssq_a2s_info->players);
g->set_version(std::stoull(ssq_a2s_info->version, NULL, 0));
g->set_version(static_cast<uint32_t>(std::stoull(ssq_a2s_info->version, NULL, 0)));
if (ssq_info_has_port(ssq_a2s_info)) g->set_port(ssq_a2s_info->port);
if (ssq_info_has_gameid(ssq_a2s_info)) g->set_appid(ssq_a2s_info->gameid);
if (ssq_info_has_gameid(ssq_a2s_info)) g->set_appid(static_cast<uint32_t>(ssq_a2s_info->gameid));
else g->set_appid(ssq_a2s_info->id);
g->set_offline(false);
} else {
@ -732,7 +732,7 @@ void Steam_Matchmaking_Servers::server_details_players(Gameserver *g, Steam_Matc
PRINT_DEBUG(" players: %u", number_players);
const auto &players = get_steam_client()->steam_gameserver->get_players();
auto player = players->cbegin();
for (int i = 0; i < number_players && player != players->end(); ++i, ++player) {
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());
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

@ -263,7 +263,7 @@ bool Steam_Networking::IsP2PPacketAvailable( uint32 *pcubMsgSize, int nChannel)
PRINT_DEBUG("Messages %zu %p", messages.size(), &messages);
for (auto &msg : messages) {
if (connection_exists((uint64)msg.source_id()) && msg.mutable_network()->channel() == nChannel && msg.network().processed()) {
uint32 size = msg.mutable_network()->data().size();
uint32 size = static_cast<uint32>(msg.mutable_network()->data().size());
if (pcubMsgSize) *pcubMsgSize = size;
PRINT_DEBUG("available with size: %u", size);
return true;
@ -299,7 +299,7 @@ bool Steam_Networking::ReadP2PPacket( void *pubDest, uint32 cubDest, uint32 *pcu
auto msg = std::begin(messages);
while (msg != std::end(messages)) {
if (connection_exists((uint64)msg->source_id()) && msg->network().channel() == nChannel && msg->network().processed()) {
uint32 msg_size = msg->network().data().size();
uint32 msg_size = static_cast<uint32>(msg->network().data().size());
if (msg_size > cubDest) msg_size = cubDest;
if (pcubMsgSize) *pcubMsgSize = msg_size;
memcpy(pubDest, msg->network().data().data(), msg_size);
@ -593,7 +593,7 @@ bool Steam_Networking::IsDataAvailableOnSocket( SNetSocket_t hSocket, uint32 *pc
}
if (socket->data_packets.size() == 0) return false;
if (pcubMsgSize) *pcubMsgSize = socket->data_packets[0].data().size();
if (pcubMsgSize) *pcubMsgSize = static_cast<uint32>(socket->data_packets[0].data().size());
return true;
}
@ -611,7 +611,7 @@ bool Steam_Networking::RetrieveDataFromSocket( SNetSocket_t hSocket, void *pubDe
auto msg = std::begin(socket->data_packets);
if (msg != std::end(socket->data_packets)) {
uint32 msg_size = msg->data().size();
uint32 msg_size = static_cast<uint32>(msg->data().size());
if (msg_size > cubDest) msg_size = cubDest;
if (pcubMsgSize) *pcubMsgSize = msg_size;
memcpy(pubDest, msg->data().data(), msg_size);
@ -635,7 +635,7 @@ bool Steam_Networking::IsDataAvailable( SNetListenSocket_t hListenSocket, uint32
for (auto & socket : connection_sockets) {
if (socket.listen_id == hListenSocket && socket.data_packets.size()) {
if (pcubMsgSize) *pcubMsgSize = socket.data_packets[0].data().size();
if (pcubMsgSize) *pcubMsgSize = static_cast<uint32>(socket.data_packets[0].data().size());
if (phSocket) *phSocket = socket.id;
return true;
}
@ -661,7 +661,7 @@ bool Steam_Networking::RetrieveData( SNetListenSocket_t hListenSocket, void *pub
if (socket.listen_id == hListenSocket && socket.data_packets.size()) {
auto msg = std::begin(socket.data_packets);
if (msg != std::end(socket.data_packets)) {
uint32 msg_size = msg->data().size();
uint32 msg_size = static_cast<uint32>(msg->data().size());
if (msg_size > cubDest) msg_size = cubDest;
if (pcubMsgSize) *pcubMsgSize = msg_size;
if (phSocket) *phSocket = socket.id;
@ -858,11 +858,11 @@ void Steam_Networking::Callback(Common_Message *msg)
PRINT_DEBUG("msg data: '%s'",
common_helpers::uint8_vector_to_hex_string(std::vector<uint8_t>(msg->network().data().begin(), msg->network().data().end())).c_str());
if (msg->network().type() == Network_pb::DATA) {
if (msg->network().type() & Network_pb::DATA) {
unprocessed_messages.push_back(Common_Message(*msg));
}
if (msg->network().type() == Network_pb::NEW_CONNECTION) {
if (msg->network().type() & Network_pb::NEW_CONNECTION) {
std::lock_guard<std::recursive_mutex> lock(messages_mutex);
auto msg_temp = std::begin(messages);
while (msg_temp != std::end(messages)) {
@ -878,10 +878,10 @@ void Steam_Networking::Callback(Common_Message *msg)
if (msg->has_network_old()) {
PRINT_DEBUG("got network socket msg %u", msg->network_old().type());
if (msg->network_old().type() == Network_Old::CONNECTION_REQUEST_IP) {
if (msg->network_old().type() & Network_Old::CONNECTION_REQUEST_IP) {
for (auto & listen : listen_sockets) {
if (listen.nPort == msg->network_old().port()) {
SNetSocket_t new_sock = create_connection_socket((uint64)msg->source_id(), 0, 0, msg->network_old().port(), listen.id, SOCKET_CONNECTED, msg->network_old().connection_id_from());
SNetSocket_t new_sock = create_connection_socket((uint64)msg->source_id(), 0, 0, msg->network_old().port(), listen.id, SOCKET_CONNECTED, static_cast<SNetSocket_t>(msg->network_old().connection_id_from()));
if (new_sock) {
struct SocketStatusCallback_t data;
data.m_hSocket = new_sock;
@ -892,10 +892,10 @@ void Steam_Networking::Callback(Common_Message *msg)
}
}
}
} else if (msg->network_old().type() == Network_Old::CONNECTION_REQUEST_STEAMID) {
} else if (msg->network_old().type() & Network_Old::CONNECTION_REQUEST_STEAMID) {
for (auto & listen : listen_sockets) {
if (listen.nVirtualP2PPort == msg->network_old().port()) {
SNetSocket_t new_sock = create_connection_socket((uint64)msg->source_id(), msg->network_old().port(), 0, 0, listen.id, SOCKET_CONNECTED, msg->network_old().connection_id_from());
SNetSocket_t new_sock = create_connection_socket((uint64)msg->source_id(), msg->network_old().port(), 0, 0, listen.id, SOCKET_CONNECTED, static_cast<SNetSocket_t>(msg->network_old().connection_id_from()));
if (new_sock) {
struct SocketStatusCallback_t data;
data.m_hSocket = new_sock;
@ -907,15 +907,15 @@ void Steam_Networking::Callback(Common_Message *msg)
}
}
} else if (msg->network_old().type() == Network_Old::CONNECTION_ACCEPTED) {
struct steam_connection_socket *socket = get_connection_socket(msg->network_old().connection_id());
} else if (msg->network_old().type() & Network_Old::CONNECTION_ACCEPTED) {
struct steam_connection_socket *socket = get_connection_socket(static_cast<SNetSocket_t>(msg->network_old().connection_id()));
if (socket && socket->nPort && socket->status == SOCKET_CONNECTING && !socket->target.IsValid()) {
socket->target = (uint64)msg->source_id();
}
if (socket && socket->status == SOCKET_CONNECTING && msg->source_id() == socket->target.ConvertToUint64()) {
socket->status = SOCKET_CONNECTED;
socket->other_id = msg->network_old().connection_id_from();
socket->other_id = static_cast<SNetSocket_t>(msg->network_old().connection_id_from());
struct SocketStatusCallback_t data;
data.m_hSocket = socket->id;
data.m_hListenSocket = socket->listen_id;
@ -923,8 +923,8 @@ void Steam_Networking::Callback(Common_Message *msg)
data.m_eSNetSocketState = k_ESNetSocketStateConnected; //TODO is this the right state?
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
} else if (msg->network_old().type() == Network_Old::CONNECTION_END) {
struct steam_connection_socket *socket = get_connection_socket(msg->network_old().connection_id());
} else if (msg->network_old().type() & Network_Old::CONNECTION_END) {
struct steam_connection_socket *socket = get_connection_socket(static_cast<SNetSocket_t>(msg->network_old().connection_id()));
if (socket && socket->status == SOCKET_CONNECTED && msg->source_id() == socket->target.ConvertToUint64()) {
struct SocketStatusCallback_t data;
socket->status = SOCKET_DISCONNECTED;
@ -935,7 +935,7 @@ void Steam_Networking::Callback(Common_Message *msg)
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
}
} else if (msg->network_old().type() == Network_Old::DATA) {
struct steam_connection_socket *socket = get_connection_socket(msg->network_old().connection_id());
struct steam_connection_socket *socket = get_connection_socket(static_cast<SNetSocket_t>(msg->network_old().connection_id()));
if (socket && socket->status == SOCKET_CONNECTED && msg->source_id() == socket->target.ConvertToUint64()) {
socket->data_packets.push_back(msg->network_old());
}
@ -943,7 +943,7 @@ void Steam_Networking::Callback(Common_Message *msg)
}
if (msg->has_low_level()) {
if (msg->low_level().type() == Low_Level::DISCONNECT) {
if (msg->low_level().type() & Low_Level::DISCONNECT) {
CSteamID source_id((uint64)msg->source_id());
if (connection_exists(source_id)) {
P2PSessionConnectFail_t data;
@ -965,7 +965,7 @@ void Steam_Networking::Callback(Common_Message *msg)
}
} else
if (msg->low_level().type() == Low_Level::CONNECT) {
if (msg->low_level().type() & Low_Level::CONNECT) {
}
}

View File

@ -221,7 +221,7 @@ int Steam_Networking_Messages::ReceiveMessagesOnChannel( int nLocalChannel, Stea
if (chan != conn.second.data.end()) {
while (!chan->second.empty() && message_counter < nMaxMessages) {
SteamNetworkingMessage_t *pMsg = new SteamNetworkingMessage_t(); //TODO size is wrong
unsigned long size = chan->second.front().size();
unsigned long size = static_cast<unsigned long>(chan->second.front().size());
pMsg->m_pData = malloc(size);
pMsg->m_cbSize = size;
memcpy(pMsg->m_pData, chan->second.front().data(), size);
@ -382,18 +382,18 @@ void Steam_Networking_Messages::RunCallbacks()
void Steam_Networking_Messages::Callback(Common_Message *msg)
{
if (msg->has_low_level()) {
if (msg->low_level().type() == Low_Level::CONNECT) {
if (msg->low_level().type() & Low_Level::CONNECT) {
}
if (msg->low_level().type() == Low_Level::DISCONNECT) {
if (msg->low_level().type() & Low_Level::DISCONNECT) {
end_connection((uint64)msg->source_id());
}
}
if (msg->has_networking_messages()) {
PRINT_DEBUG("got network socket msg %u", msg->networking_messages().type());
if (msg->networking_messages().type() == Networking_Messages::CONNECTION_NEW) {
if (msg->networking_messages().type() & Networking_Messages::CONNECTION_NEW) {
SteamNetworkingIdentity identity;
identity.SetSteamID64(msg->source_id());
auto conn = find_or_create_message_connection(identity, true, false);
@ -401,18 +401,18 @@ void Steam_Networking_Messages::Callback(Common_Message *msg)
conn->second.dead = false;
}
if (msg->networking_messages().type() == Networking_Messages::CONNECTION_ACCEPT) {
if (msg->networking_messages().type() & Networking_Messages::CONNECTION_ACCEPT) {
auto conn = connections.find((uint64)msg->source_id());
if (conn != connections.end()) {
conn->second.remote_id = msg->networking_messages().id_from();
}
}
if (msg->networking_messages().type() == Networking_Messages::CONNECTION_END) {
if (msg->networking_messages().type() & Networking_Messages::CONNECTION_END) {
end_connection((uint64)msg->source_id());
}
if (msg->networking_messages().type() == Networking_Messages::DATA) {
if (msg->networking_messages().type() & Networking_Messages::DATA) {
incoming_data.push_back(Common_Message(*msg));
}
}

View File

@ -40,7 +40,7 @@ SteamNetworkingMessage_t* Steam_Networking_Sockets::get_steam_message_connection
if (connect_socket == sbcs->connect_sockets.end()) return NULL;
if (connect_socket->second.data.empty()) return NULL;
SteamNetworkingMessage_t *pMsg = new SteamNetworkingMessage_t();
unsigned long size = connect_socket->second.data.top().data().size();
unsigned long size = static_cast<unsigned long>(connect_socket->second.data.top().data().size());
pMsg->m_pData = malloc(size);
pMsg->m_cbSize = size;
memcpy(pMsg->m_pData, connect_socket->second.data.top().data().data(), size);
@ -938,8 +938,8 @@ EResult Steam_Networking_Sockets::GetConnectionRealTimeStatus( HSteamNetConnecti
pStatus->m_flOutBytesPerSec = 0.0;
pStatus->m_flInPacketsPerSec = 0.0;
pStatus->m_flInBytesPerSec = 0.0;
pStatus->m_cbSentUnackedReliable = 0.0;
pStatus->m_usecQueueTime = 0.0;
pStatus->m_cbSentUnackedReliable = 0;
pStatus->m_usecQueueTime = static_cast<SteamNetworkingMicroseconds>(0.0f);
//Note some games (volcanoids) might not allocate a struct the whole size of SteamNetworkingQuickConnectionStatus
//keep this in mind in future interface updates
@ -2052,26 +2052,26 @@ void Steam_Networking_Sockets::Callback(Common_Message *msg)
if (connect_socket == sbcs->connect_sockets.end()) {
SteamNetworkingIdentity identity;
identity.SetSteamID64(msg->source_id());
HSteamNetConnection new_connection = new_connect_socket(identity, virtual_port, real_port, CONNECT_SOCKET_NOT_ACCEPTED, conn->socket_id, msg->networking_sockets().connection_id_from());
HSteamNetConnection new_connection = new_connect_socket(identity, virtual_port, real_port, CONNECT_SOCKET_NOT_ACCEPTED, conn->socket_id, static_cast<HSteamNetConnection>(msg->networking_sockets().connection_id_from()));
launch_callback(new_connection, CONNECT_SOCKET_NO_CONNECTION);
}
}
} else if (msg->networking_sockets().type() == Networking_Sockets::CONNECTION_ACCEPTED) {
auto connect_socket = sbcs->connect_sockets.find(msg->networking_sockets().connection_id());
auto connect_socket = sbcs->connect_sockets.find(static_cast<HSteamNetConnection>(msg->networking_sockets().connection_id()));
if (connect_socket != sbcs->connect_sockets.end()) {
if (connect_socket->second.remote_identity.GetSteamID64() == 0) {
connect_socket->second.remote_identity.SetSteamID64(msg->source_id());
}
if (connect_socket->second.remote_identity.GetSteamID64() == msg->source_id() && connect_socket->second.status == CONNECT_SOCKET_CONNECTING) {
connect_socket->second.remote_id = msg->networking_sockets().connection_id_from();
connect_socket->second.remote_id = static_cast<HSteamNetConnection>(msg->networking_sockets().connection_id_from());
connect_socket->second.status = CONNECT_SOCKET_CONNECTED;
launch_callback(connect_socket->first, CONNECT_SOCKET_CONNECTING);
}
}
} else if (msg->networking_sockets().type() == Networking_Sockets::DATA) {
auto connect_socket = sbcs->connect_sockets.find(msg->networking_sockets().connection_id());
auto connect_socket = sbcs->connect_sockets.find(static_cast<HSteamNetConnection>(msg->networking_sockets().connection_id()));
if (connect_socket != sbcs->connect_sockets.end()) {
if (connect_socket->second.remote_identity.GetSteamID64() == msg->source_id() && (connect_socket->second.status == CONNECT_SOCKET_CONNECTED)) {
PRINT_DEBUG("got data len %zu, num " "%" PRIu64 " on connection %u", msg->networking_sockets().data().size(), msg->networking_sockets().message_number(), connect_socket->first);
@ -2085,7 +2085,7 @@ void Steam_Networking_Sockets::Callback(Common_Message *msg)
}
}
} else if (msg->networking_sockets().type() == Networking_Sockets::CONNECTION_END) {
auto connect_socket = sbcs->connect_sockets.find(msg->networking_sockets().connection_id());
auto connect_socket = sbcs->connect_sockets.find(static_cast<HSteamNetConnection>(msg->networking_sockets().connection_id()));
if (connect_socket != sbcs->connect_sockets.end()) {
if (connect_socket->second.remote_identity.GetSteamID64() == msg->source_id() && connect_socket->second.status == CONNECT_SOCKET_CONNECTED) {
enum connect_socket_status old_status = connect_socket->second.status;

View File

@ -264,7 +264,7 @@ SteamNetworkingMicroseconds Steam_Networking_Utils::GetLocalTimestamp()
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - initialized_time).count() + (SteamNetworkingMicroseconds)24*3600*30*1e6;
return static_cast<SteamNetworkingMicroseconds>(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - initialized_time).count() + (SteamNetworkingMicroseconds)24*3600*30*1e6);
}
@ -493,7 +493,7 @@ bool Steam_Networking_Utils::SteamNetworkingIPAddr_ParseString( SteamNetworkingI
if (inet_pton(AF_INET, ip, &ipv4_addr) == 1)
{
valid = true;
pAddr->SetIPv4(ntohl(ipv4_addr.s_addr), strtoul(port, nullptr, 10));
pAddr->SetIPv4(ntohl(ipv4_addr.s_addr), static_cast<uint16>(strtoul(port, nullptr, 10)));
}
} else {// Try ipv4 without port
in_addr ipv4_addr;
@ -657,7 +657,7 @@ bool Steam_Networking_Utils::SteamNetworkingIdentity_ParseString( SteamNetworkin
valid = true;
length /= 2;
pIdentity->m_eType = k_ESteamNetworkingIdentityType_GenericBytes;
pIdentity->m_cbSize = length;
pIdentity->m_cbSize = static_cast<int>(length);
uint8* pBytes = pIdentity->m_genericBytes;
char hex[3] = { 0,0,0 };
@ -666,7 +666,7 @@ bool Steam_Networking_Utils::SteamNetworkingIdentity_ParseString( SteamNetworkin
hex[0] = end[0];
hex[1] = end[1];
// Steam doesn't check if wasn't a hex char
*pBytes = strtol(hex, nullptr, 16);
*pBytes = static_cast<uint8>(strtol(hex, nullptr, 16));
++pBytes;
end += 2;
@ -715,11 +715,11 @@ void Steam_Networking_Utils::RunCallbacks()
void Steam_Networking_Utils::Callback(Common_Message *msg)
{
if (msg->has_low_level()) {
if (msg->low_level().type() == Low_Level::CONNECT) {
if (msg->low_level().type() & Low_Level::CONNECT) {
}
if (msg->low_level().type() == Low_Level::DISCONNECT) {
if (msg->low_level().type() & Low_Level::DISCONNECT) {
}
}

View File

@ -247,7 +247,7 @@ bool Steam_Remote_Storage::FileWriteStreamClose( UGCFileWriteStreamHandle_t writ
if (stream_writes.end() == request)
return false;
local_storage->store_data(Local_Storage::remote_storage_folder, request->file_name, request->file_data.data(), request->file_data.size());
local_storage->store_data(Local_Storage::remote_storage_folder, request->file_name, request->file_data.data(), static_cast<unsigned int>(request->file_data.size()));
stream_writes.erase(request);
return true;
}
@ -353,7 +353,7 @@ bool Steam_Remote_Storage::GetQuota( int32 *pnTotalBytes, int32 *puAvailableByte
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
uint64 quota = 2 << 26;
int32 quota = 2 << 26;
if (pnTotalBytes) *pnTotalBytes = quota;
if (puAvailableBytes) *puAvailableBytes = (quota);
return true;

View File

@ -144,7 +144,7 @@ bool Steam_UGC::write_ugc_favorites()
ss.flush();
}
auto file_data = ss.str();
int stored = local_storage->store_data("", ugc_favorits_file, &file_data[0], file_data.size());
int stored = local_storage->store_data("", ugc_favorits_file, &file_data[0], static_cast<unsigned int>(file_data.size()));
return (size_t)stored == file_data.size();
}
@ -261,8 +261,8 @@ SteamAPICall_t Steam_UGC::SendQueryUGCRequest( UGCQueryHandle_t handle )
SteamUGCQueryCompleted_t data = {};
data.m_handle = handle;
data.m_eResult = k_EResultOK;
data.m_unNumResultsReturned = request->results.size();
data.m_unTotalMatchingResults = request->results.size();
data.m_unNumResultsReturned = static_cast<uint32>(request->results.size());
data.m_unTotalMatchingResults = static_cast<uint32>(request->results.size());
data.m_bCachedData = false;
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
@ -315,7 +315,7 @@ uint32 Steam_UGC::GetQueryUGCNumTags( UGCQueryHandle_t handle, uint32 index )
if (handle == k_UGCQueryHandleInvalid) return 0;
auto res = get_query_ugc_tags(handle, index);
return res.has_value() ? res.value().size() : 0;
return res.has_value() ? static_cast<uint32>(res.value().size()) : 0;
}
bool Steam_UGC::GetQueryUGCTag( UGCQueryHandle_t handle, uint32 index, uint32 indexTag, STEAM_OUT_STRING_COUNT( cchValueSize ) char* pchValue, uint32 cchValueSize )

View File

@ -164,8 +164,8 @@ EVoiceResult Steam_User::GetAvailableVoice( uint32 *pcbCompressed, uint32 *pcbUn
if (pcbUncompressed_Deprecated) *pcbUncompressed_Deprecated = 0;
if (!recording) return k_EVoiceResultNotRecording;
double seconds = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - last_get_voice).count();
if (pcbCompressed) *pcbCompressed = seconds * 1024.0 * 64.0 / 8.0;
if (pcbUncompressed_Deprecated) *pcbUncompressed_Deprecated = seconds * (double)nUncompressedVoiceDesiredSampleRate_Deprecated * 2.0;
if (pcbCompressed) *pcbCompressed = static_cast<uint32>(seconds * 1024.0 * 64.0 / 8.0);
if (pcbUncompressed_Deprecated) *pcbUncompressed_Deprecated = static_cast<uint32>(seconds * (double)nUncompressedVoiceDesiredSampleRate_Deprecated * 2.0);
return k_EVoiceResultOK;
}
@ -203,7 +203,7 @@ EVoiceResult Steam_User::GetVoice( bool bWantCompressed, void *pDestBuffer, uint
if (!recording) return k_EVoiceResultNotRecording;
double seconds = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - last_get_voice).count();
if (bWantCompressed) {
uint32 towrite = seconds * 1024.0 * 64.0 / 8.0;
uint32 towrite = static_cast<uint32>(seconds * 1024.0 * 64.0 / 8.0);
if (cbDestBufferSize < towrite) towrite = cbDestBufferSize;
if (pDestBuffer) memset(pDestBuffer, 0, towrite);
if (nBytesWritten) *nBytesWritten = towrite;
@ -239,7 +239,7 @@ EVoiceResult Steam_User::DecompressVoice( const void *pCompressed, uint32 cbComp
{
PRINT_DEBUG_ENTRY();
if (!recording) return k_EVoiceResultNotRecording;
uint32 uncompressed = (double)cbCompressed * ((double)nDesiredSampleRate / 8192.0);
uint32 uncompressed = static_cast<uint32>((double)cbCompressed * ((double)nDesiredSampleRate / 8192.0));
if(nBytesWritten) *nBytesWritten = uncompressed;
if (uncompressed > cbDestBufferSize) uncompressed = cbDestBufferSize;
if (pDestBuffer) memset(pDestBuffer, 0, uncompressed);
@ -358,7 +358,7 @@ void Steam_User::AdvertiseGame( CSteamID steamIDGameServer, uint32 unIPServer, u
server->set_ip(unIPServer);
server->set_port(usPortServer);
server->set_query_port(usPortServer);
server->set_appid(settings->get_local_game_id().ToUint64());
server->set_appid(settings->get_local_game_id().AppID());
if (settings->matchmaking_server_list_always_lan_type)
server->set_type(eLANServer);
@ -394,7 +394,7 @@ SteamAPICall_t Steam_User::RequestEncryptedAppTicket( void *pDataToInclude, int
ticket.TicketV2.TicketVersion = 4;
ticket.TicketV2.SteamID = settings->get_local_steam_id().ConvertToUint64();
ticket.TicketV2.TicketIssueTime = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
ticket.TicketV2.TicketIssueTime = static_cast<uint32>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count());
ticket.TicketV2.TicketValidityEnd = ticket.TicketV2.TicketIssueTime + (21 * 24 * 60 * 60);
for (int i = 0; i < 140; ++i)
@ -415,7 +415,7 @@ SteamAPICall_t Steam_User::RequestEncryptedAppTicket( void *pDataToInclude, int
pb.set_ticket_version_no(1);
pb.set_crc_encryptedticket(0); // TODO: Find out how to compute the CRC
pb.set_cb_encrypteduserdata(cbDataToInclude);
pb.set_cb_encrypted_appownershipticket(serialized.size() - 16);
pb.set_cb_encrypted_appownershipticket(static_cast<uint32>(serialized.size()) - 16);
pb.mutable_encrypted_ticket()->assign(serialized.begin(), serialized.end()); // TODO: Find how to encrypt datas
encrypted_app_ticket = pb.SerializeAsString();
@ -427,7 +427,7 @@ SteamAPICall_t Steam_User::RequestEncryptedAppTicket( void *pDataToInclude, int
bool Steam_User::GetEncryptedAppTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket )
{
PRINT_DEBUG("%i", cbMaxTicket);
unsigned int ticket_size = encrypted_app_ticket.size();
unsigned int ticket_size = static_cast<unsigned int>(encrypted_app_ticket.size());
if (!cbMaxTicket) {
if (!pcbTicket) return false;
*pcbTicket = ticket_size;

View File

@ -102,7 +102,7 @@ bool Steam_Utils::GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize
auto image = settings->images.find(iImage);
if (image == settings->images.end()) return false;
unsigned size = image->second.data.size();
unsigned size = static_cast<unsigned>(image->second.data.size());
if (nDestBufferSize < size) size = nDestBufferSize;
image->second.data.copy((char *)pubDest, nDestBufferSize);
return true;
@ -415,7 +415,7 @@ int Steam_Utils::FilterText( ETextFilteringContext eContext, CSteamID sourceStea
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!nByteSizeOutFilteredText) return 0;
unsigned len = strlen(pchInputMessage);
unsigned len = static_cast<unsigned>(strlen(pchInputMessage));
if (!len) return 0;
len += 1;
if (len > nByteSizeOutFilteredText) len = nByteSizeOutFilteredText;