diff --git a/crash_printer/win.cpp b/crash_printer/win.cpp index e9139f9f..d10bc509 100644 --- a/crash_printer/win.cpp +++ b/crash_printer/win.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #define WIN32_LEAN_AND_MEAN #include @@ -108,7 +109,8 @@ static void log_exception(LPEXCEPTION_POINTERS ex_pointers) auto now = std::chrono::system_clock::now(); auto t_now = std::chrono::system_clock::to_time_t(now); auto gm_time = std::gmtime(&t_now); - auto time = std::string(std::asctime(gm_time)); + auto asc_time = std::asctime(gm_time); + auto time = std::string(asc_time); time.pop_back(); // remove the trailing '\n' added by asctime common_helpers::write(file, "[" + time + "]"); { diff --git a/dll/appticket.cpp b/dll/appticket.cpp index 7f0a45af..db708c1b 100644 --- a/dll/appticket.cpp +++ b/dll/appticket.cpp @@ -35,7 +35,7 @@ std::vector AppTicketV1::Serialize() const pBuffer = buffer.data(); *reinterpret_cast(pBuffer) = TicketSize; pBuffer += 4; *reinterpret_cast(pBuffer) = TicketVersion; pBuffer += 4; - *reinterpret_cast(pBuffer) = UserData.size(); pBuffer += 4; + *reinterpret_cast(pBuffer) = static_cast(UserData.size()); pBuffer += 4; *reinterpret_cast(pBuffer) = Unk2; pBuffer += 4; memcpy(pBuffer, UserData.data(), UserData.size()); @@ -132,7 +132,7 @@ std::vector AppTicketV4::Serialize() appids.emplace_back(0); } - uint16_t appid_count = static_cast(appids.size() > 140 ? 140 : appids.size()); + uint16_t appid_count = static_cast(static_cast(appids.size()) > 140 ? 140 : static_cast(appids.size())); size_t buffer_size = static_cast(appid_count) * 4ul + 2ul; std::vector buffer{}; uint8_t* pBuffer{}; @@ -235,8 +235,8 @@ std::vector DecryptedAppTicket::SerializeTicket() { std::vector buffer{}; - TicketV1.TicketSize = TicketV1.UserData.size() + 40 + 2 + ((TicketV4.AppIDs.size() == 0 ? 1 : TicketV4.AppIDs.size()) * 4) + (TicketV4.HasVACStatus ? 4 : 0) + (TicketV4.HasAppValue ? 4 : 0); - TicketV2.TicketSize = TicketV1.TicketSize - TicketV1.UserData.size(); + TicketV1.TicketSize = static_cast(TicketV1.UserData.size()) + 40 + 2 + ((static_cast(TicketV4.AppIDs.size()) == 0 ? 1 : static_cast(TicketV4.AppIDs.size())) * 4) + (TicketV4.HasVACStatus ? 4 : 0) + (TicketV4.HasAppValue ? 4 : 0); + TicketV2.TicketSize = TicketV1.TicketSize - static_cast(TicketV1.UserData.size()); buffer = TicketV1.Serialize(); diff --git a/dll/auth.cpp b/dll/auth.cpp index 03550373..8fd297ee 100644 --- a/dll/auth.cpp +++ b/dll/auth.cpp @@ -671,7 +671,7 @@ Auth_Data Auth_Manager::getTicketData( void *pTicket, int cbMaxTicket, uint32 *p ticket_data.Ticket.Licenses.push_back(0); //TODO unsigned int dlcCount = settings->DLCCount(); ticket_data.Ticket.DLCs.resize(0); //currently set to 0 - for (int i = 0; i < dlcCount; ++i) + for (unsigned i = 0; i < dlcCount; ++i) { DLC dlc; AppId_t appid; @@ -695,9 +695,10 @@ Auth_Data Auth_Manager::getTicketData( void *pTicket, int cbMaxTicket, uint32 *p ticket_data.GC.TicketGeneratedCount = get_ticket_count(); } std::vector ser = ticket_data.Serialize(); - *pcbTicket = ser.size(); - if (cbMaxTicket >= ser.size()) - memcpy(pTicket, ser.data(), ser.size()); + uint32_t ser_size = static_cast(ser.size()); + *pcbTicket = ser_size; + if (cbMaxTicket >= ser_size) + memcpy(pTicket, ser.data(), ser_size); } else { @@ -846,7 +847,7 @@ EBeginAuthSessionResult Auth_Manager::beginAuth(const void *pAuthTicket, int cbA uint32 Auth_Manager::countInboundAuth() { - return inbound.size(); + return static_cast(inbound.size()); } bool Auth_Manager::endAuth(CSteamID id) diff --git a/dll/callsystem.cpp b/dll/callsystem.cpp index 1ae24cc7..83352509 100644 --- a/dll/callsystem.cpp +++ b/dll/callsystem.cpp @@ -204,7 +204,7 @@ void SteamCallResults::setCbAll(void (*cb_all)(std::vector result, int cal void SteamCallResults::runCallResults() { - unsigned long current_size = callresults.size(); + unsigned long current_size = static_cast(callresults.size()); for (unsigned i = 0; i < current_size; ++i) { unsigned index = i; @@ -315,7 +315,7 @@ void SteamCallBacks::addCallBack(int iCallback, class CCallbackBase *cb) CCallbackMgr::SetRegister(cb, iCallback); for (auto & res: callbacks[iCallback].results) { //TODO: timeout? - SteamAPICall_t api_id = results->addCallResult(iCallback, &(res[0]), res.size(), 0.0, false); + SteamAPICall_t api_id = results->addCallResult(iCallback, &(res[0]), static_cast(res.size()), 0.0, false); results->addCallBack(api_id, cb); } } diff --git a/dll/dll.cpp b/dll/dll.cpp index f1a52074..3469ac69 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -1105,7 +1105,7 @@ STEAMAPI_API steam_bool S_CALLTYPE SteamAPI_ManualDispatch_GetNextCallback( HSte pCallbackMsg->m_hSteamUser = m_hSteamUser; pCallbackMsg->m_iCallback = q->front().cb_id; pCallbackMsg->m_pubParam = (uint8 *)&(q->front().result[0]); - pCallbackMsg->m_cubParam = q->front().result.size(); + pCallbackMsg->m_cubParam = static_cast(q->front().result.size()); PRINT_DEBUG("cb number %i", q->front().cb_id); return true; } diff --git a/dll/settings.cpp b/dll/settings.cpp index f2ed6330..90ab622e 100644 --- a/dll/settings.cpp +++ b/dll/settings.cpp @@ -352,7 +352,7 @@ void Settings::setStatDefiniton(const std::string &name, const struct Stat_confi int Settings::add_image(const std::string &data, uint32 width, uint32 height) { - int last = images.size() + 1; + int last = static_cast(images.size()) + 1; struct Image_Data dt; dt.width = width; dt.height = height; diff --git a/dll/steam_gameserver.cpp b/dll/steam_gameserver.cpp index 4bf31137..7b7a3c28 100644 --- a/dll/steam_gameserver.cpp +++ b/dll/steam_gameserver.cpp @@ -728,7 +728,7 @@ int Steam_GameServer::GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *p if (settings->disable_source_query) return 0; if (outgoing_packets.size() == 0) return 0; - if (outgoing_packets.back().data.size() < cbMaxOut) cbMaxOut = outgoing_packets.back().data.size(); + if (outgoing_packets.back().data.size() < cbMaxOut) cbMaxOut = static_cast(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; diff --git a/sdk/steam/matchmakingtypes.h b/sdk/steam/matchmakingtypes.h index 3e171677..5f26507a 100644 --- a/sdk/steam/matchmakingtypes.h +++ b/sdk/steam/matchmakingtypes.h @@ -42,9 +42,9 @@ struct MatchMakingKeyValuePair_t MatchMakingKeyValuePair_t() { m_szKey[0] = m_szValue[0] = 0; } MatchMakingKeyValuePair_t( const char *pchKey, const char *pchValue ) { - strncpy( m_szKey, pchKey, sizeof(m_szKey) ); // this is a public header, use basic c library string funcs only! + strncpy_s( m_szKey, pchKey, sizeof(m_szKey) ); // this is a public header, use basic c library string funcs only! m_szKey[ sizeof( m_szKey ) - 1 ] = '\0'; - strncpy( m_szValue, pchValue, sizeof(m_szValue) ); + strncpy_s( m_szValue, pchValue, sizeof(m_szValue) ); m_szValue[ sizeof( m_szValue ) - 1 ] = '\0'; } char m_szKey[ 256 ]; @@ -156,9 +156,9 @@ inline const char *servernetadr_t::ToString( uint32 unIP, uint16 usPort ) const static int nBuf = 0; unsigned char *ipByte = (unsigned char *)&unIP; #ifdef VALVE_BIG_ENDIAN - _snprintf (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[0]), (int)(ipByte[1]), (int)(ipByte[2]), (int)(ipByte[3]), usPort ); + _snprintf_s (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[0]), (int)(ipByte[1]), (int)(ipByte[2]), (int)(ipByte[3]), usPort ); #else - _snprintf (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[3]), (int)(ipByte[2]), (int)(ipByte[1]), (int)(ipByte[0]), usPort ); + _snprintf_s (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[3]), (int)(ipByte[2]), (int)(ipByte[1]), (int)(ipByte[0]), usPort ); #endif const char *pchRet = s[nBuf]; ++nBuf; @@ -243,7 +243,7 @@ inline const char* gameserveritem_t::GetName() const inline void gameserveritem_t::SetName( const char *pName ) { - strncpy( m_szServerName, pName, sizeof( m_szServerName ) ); + strncpy_s( m_szServerName, pName, sizeof( m_szServerName ) ); m_szServerName[ sizeof( m_szServerName ) - 1 ] = '\0'; }