diff --git a/deps/datReader/Dat.cpp b/deps/datReader/Dat.cpp index 943e12fd0b..f3e9a3a7cf 100644 --- a/deps/datReader/Dat.cpp +++ b/deps/datReader/Dat.cpp @@ -292,7 +292,7 @@ namespace xiv::dat DatBlockHeader block_header = extract< DatBlockHeader >( m_handle ); // Resizing the vector to write directly into it - const uint32_t data_size = o_data.size(); + const uint32_t data_size = static_cast(o_data.size()); o_data.resize( data_size + block_header.uncompressed_size ); // 32000 in compressed_size means it is not compressed so take uncompressed_size @@ -308,7 +308,7 @@ namespace xiv::dat m_handle.read( temp_buffer.data(), block_header.compressed_size ); utils::zlib::no_header_decompress( reinterpret_cast(temp_buffer.data()), - temp_buffer.size(), + static_cast(temp_buffer.size()), reinterpret_cast(o_data.data() + data_size), block_header.uncompressed_size ); } diff --git a/deps/datReader/DatCategories/bg/sgb.h b/deps/datReader/DatCategories/bg/sgb.h index fbf23f5ab9..d9616d8ab1 100644 --- a/deps/datReader/DatCategories/bg/sgb.h +++ b/deps/datReader/DatCategories/bg/sgb.h @@ -258,7 +258,7 @@ struct SGB_FILE if( stateCount > 0 ) { stateCount = stateCount; - for( int i = 0; i < stateCount; ++i ) + for( uint32_t i = 0; i < stateCount; ++i ) { auto state = SGB_STATE_ENTRY( buf + baseOffset + header.statesOffset + 8 + i * sizeof( SGB_STATE_HEADER ) ); stateEntries.push_back( state ); diff --git a/deps/datReader/Exd.cpp b/deps/datReader/Exd.cpp index 6c4769b5f0..0e4b68c637 100644 --- a/deps/datReader/Exd.cpp +++ b/deps/datReader/Exd.cpp @@ -238,7 +238,7 @@ namespace xiv::exd std::map< ExdRow, std::vector< Field >, exdRowSort > data; // Iterates over all the cached ids - const uint32_t memberCount = _exh->get_members().size(); + const uint32_t memberCount = static_cast(_exh->get_members().size()); for( auto& cacheEntry : _idCache ) { std::vector< char > dataCpy = cacheEntry.second.file->get_data_sections().front(); @@ -249,7 +249,7 @@ namespace xiv::exd for( int32_t i = 0; i < cacheEntry.second.subRows; i++ ) { // Get the vector fields for the given record and preallocate it - ExdRow row = { cacheEntry.first, i }; + ExdRow row = { cacheEntry.first, static_cast(i) }; auto& fields = data[ row ]; fields.reserve( memberCount ); diff --git a/deps/datReader/GameData.cpp b/deps/datReader/GameData.cpp index f3e5653755..16ed810b3d 100644 --- a/deps/datReader/GameData.cpp +++ b/deps/datReader/GameData.cpp @@ -273,8 +273,8 @@ namespace xiv::dat std::string filenamePart = pathLower.substr( lastSlashPos + 1 ); // Get the crc32 values from zlib, to compensate the final XOR 0xFFFFFFFF that isnot done in the exe we just reXOR - dirHash = crc32( 0, reinterpret_cast( dirPart.data() ), dirPart.size() ) ^ 0xFFFFFFFF; - filenameHash = crc32( 0, reinterpret_cast( filenamePart.data() ), filenamePart.size() ) ^ 0xFFFFFFFF; + dirHash = crc32( 0, reinterpret_cast( dirPart.data() ), static_cast(dirPart.size()) ) ^ 0xFFFFFFFF; + filenameHash = crc32( 0, reinterpret_cast( filenamePart.data() ), static_cast(filenamePart.size()) ) ^ 0xFFFFFFFF; } void GameData::createCategory( uint32_t catNum ) diff --git a/deps/datReader/crc32.cpp b/deps/datReader/crc32.cpp index c861cebc76..49c48e6def 100644 --- a/deps/datReader/crc32.cpp +++ b/deps/datReader/crc32.cpp @@ -101,7 +101,7 @@ namespace xiv::utils::crc32 void generate_hashes_1( std::string& i_format, const uint32_t i_first_index, std::vector< uint32_t >& o_hashes ) { char* str = const_cast(i_format.data()); - const uint32_t str_size = i_format.size(); + const uint32_t str_size = static_cast(i_format.size()); o_hashes.resize( 10000 ); @@ -130,7 +130,7 @@ namespace xiv::utils::crc32 std::vector< uint32_t >& o_hashes ) { char* str = const_cast(i_format.data()); - const uint32_t str_size = i_format.size(); + const uint32_t str_size = static_cast(i_format.size()); o_hashes.resize( 100000000 ); diff --git a/deps/datReader/zlib.cpp b/deps/datReader/zlib.cpp index 29396b993d..d294060ea0 100644 --- a/deps/datReader/zlib.cpp +++ b/deps/datReader/zlib.cpp @@ -10,11 +10,11 @@ namespace xiv::utils::zlib void compress( const std::vector< char >& in, std::vector< char >& out ) { // Fetching upper bound for out size - auto out_size = compressBound( in.size() ); + auto out_size = compressBound( static_cast(in.size()) ); out.resize( out_size ); auto ret = compress2( reinterpret_cast(out.data()), &out_size, - reinterpret_cast(in.data()), in.size(), Z_BEST_COMPRESSION ); + reinterpret_cast(in.data()), static_cast(in.size()), Z_BEST_COMPRESSION ); if( ret != Z_OK ) { diff --git a/deps/mysqlConnector/Connection.cpp b/deps/mysqlConnector/Connection.cpp index 20d1f00687..1d667939f1 100644 --- a/deps/mysqlConnector/Connection.cpp +++ b/deps/mysqlConnector/Connection.cpp @@ -29,7 +29,8 @@ Mysql::Connection::Connection( std::shared_ptr< MySqlBase > pBase, const std::string& password, const optionMap& options, uint16_t port ) : - m_pBase( pBase ) + m_pBase( pBase ), + m_bConnected( false ) { m_pRawCon = mysql_init( nullptr ); // Different mysql versions support different options, for now whatever was unsupporter here was commented out @@ -165,7 +166,7 @@ bool Mysql::Connection::getAutoCommit() { // TODO: should be replaced with wrapped sql query function once available std::string query("SELECT @@autocommit"); - auto res = mysql_real_query( m_pRawCon, query.c_str(), query.length() ); + auto res = mysql_real_query( m_pRawCon, query.c_str(), static_cast(query.length()) ); if( res != 0 ) throw std::runtime_error( "Query failed!" ); @@ -237,7 +238,7 @@ std::shared_ptr< Mysql::PreparedStatement > Mysql::Connection::prepareStatement( if( !stmt ) throw std::runtime_error( "Could not init prepared statement: " + getError() ); - if( mysql_stmt_prepare( stmt, sql.c_str(), sql.size() ) ) + if( mysql_stmt_prepare( stmt, sql.c_str(), static_cast(sql.size()) ) ) throw std::runtime_error( "Could not prepare statement: " + getError() ); return std::make_shared< PreparedStatement >( stmt, shared_from_this() ); diff --git a/deps/mysqlConnector/PreparedStatement.cpp b/deps/mysqlConnector/PreparedStatement.cpp index 5354fc024a..7089bd5328 100644 --- a/deps/mysqlConnector/PreparedStatement.cpp +++ b/deps/mysqlConnector/PreparedStatement.cpp @@ -18,7 +18,7 @@ struct LongDataSender { unsigned position; MYSQL_STMT* m_pStmt; - LongDataSender() + LongDataSender() : position( 0 ), m_pStmt(nullptr) {} @@ -77,9 +77,9 @@ struct LongDataSender while( sent < str->length() ) { - chunkSize = ( sent + MAX_SEND_LONGDATA_CHUNK > str->length() + chunkSize = static_cast(( sent + MAX_SEND_LONGDATA_CHUNK > str->length() ? str->length() - sent - : MAX_SEND_LONGDATA_CHUNK ); + : MAX_SEND_LONGDATA_CHUNK )); if( mysql_stmt_send_long_data( m_pStmt, position, str->c_str() + sent, chunkSize ) ) { @@ -307,7 +307,7 @@ class ParamBind } Mysql::PreparedStatement::PreparedStatement( MYSQL_STMT* pStmt, std::shared_ptr< Mysql::Connection > pConn ) - : Statement( pConn ) + : Statement( pConn ), m_paramCount( 0 ), resultSetConcurrency ( 0 ), resultSetType( 0 ), warningsCount( 0 ) { m_pStmt = pStmt; m_pConnection = pConn; diff --git a/deps/mysqlConnector/Statement.cpp b/deps/mysqlConnector/Statement.cpp index 14d810206d..f873d147ca 100644 --- a/deps/mysqlConnector/Statement.cpp +++ b/deps/mysqlConnector/Statement.cpp @@ -10,14 +10,14 @@ std::shared_ptr< Mysql::Connection > Mysql::Statement::getConnection() } Mysql::Statement::Statement( std::shared_ptr< Mysql::Connection > conn ) : - m_pConnection( conn ) + m_pConnection( conn ), m_lastUpdateCount( 0 ), m_warningsCount( 0 ) { } void Mysql::Statement::doQuery( const std::string &q ) { - mysql_real_query( m_pConnection->getRawCon(), q.c_str(), q.length() ); + mysql_real_query( m_pConnection->getRawCon(), q.c_str(), static_cast(q.length()) ); if( errNo() ) throw std::runtime_error( m_pConnection->getError() ); diff --git a/src/api/SapphireApi.cpp b/src/api/SapphireApi.cpp index e31e37c1e5..7995eead97 100644 --- a/src/api/SapphireApi.cpp +++ b/src/api/SapphireApi.cpp @@ -114,7 +114,7 @@ int SapphireApi::createCharacter( const uint32_t accountId, const std::string& n const char* ptr = infoJson.c_str() + 50; std::string lookPart( ptr ); - int32_t pos = lookPart.find_first_of( "]" ); + int32_t pos = static_cast(lookPart.find_first_of( "]" )); if( pos != std::string::npos ) { lookPart = lookPart.substr( 0, pos + 1 ); diff --git a/src/api/server_http.hpp b/src/api/server_http.hpp index b9166c5795..a2a0b98fdf 100644 --- a/src/api/server_http.hpp +++ b/src/api/server_http.hpp @@ -242,7 +242,7 @@ namespace SimpleWeb { std::shared_ptr request(new Request(*socket)); //Set timeout on the following asio::async-read or write function - auto timer=this->get_timeout_timer(socket, config.timeout_request); + auto timer=this->get_timeout_timer(socket, static_cast(config.timeout_request)); asio::async_read_until(*socket, request->streambuf, "\r\n\r\n", [this, socket, request, timer](const std::error_code& ec, size_t bytes_transferred) { @@ -272,7 +272,7 @@ namespace SimpleWeb { } if(content_length>num_additional_bytes) { //Set timeout on the following asio::async-read or write function - auto timer=this->get_timeout_timer(socket, config.timeout_content); + auto timer=this->get_timeout_timer(socket, static_cast(config.timeout_content)); asio::async_read(*socket, request->streambuf, asio::transfer_exactly(static_cast< size_t >(content_length-num_additional_bytes)), [this, socket, request, timer] @@ -368,7 +368,7 @@ namespace SimpleWeb { std::function::Response>, std::shared_ptr::Request>)>& resource_function) { //Set timeout on the following asio::async-read or write function - auto timer=this->get_timeout_timer(socket, config.timeout_content); + auto timer=this->get_timeout_timer(socket, static_cast(config.timeout_content)); auto response=std::shared_ptr(new Response(socket), [this, request, timer](Response *response_ptr) { auto response=std::shared_ptr(response_ptr); diff --git a/src/common/Config/ConfigMgr.h b/src/common/Config/ConfigMgr.h index b78da899ec..3705e91afd 100644 --- a/src/common/Config/ConfigMgr.h +++ b/src/common/Config/ConfigMgr.h @@ -24,6 +24,8 @@ namespace Sapphire::Common template< class T > T getValue( const std::string& section, const std::string& name, T defaultValue = T() ) { + #pragma warning( push ) + #pragma warning( disable : 4244 ) if constexpr ( std::is_same_v< T, uint32_t > ) return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr ( std::is_same_v< T, int32_t > ) @@ -48,6 +50,7 @@ namespace Sapphire::Common return m_pInih->GetBoolean( section, name, defaultValue ); else static_assert( always_false< T >::value, "non-exhaustive getter!" ); + #pragma warning( pop ) } template< class T > diff --git a/src/common/Crypt/base64.cpp b/src/common/Crypt/base64.cpp index 7d513c4765..b095f2128f 100644 --- a/src/common/Crypt/base64.cpp +++ b/src/common/Crypt/base64.cpp @@ -89,7 +89,7 @@ std::string Sapphire::Common::Util::base64Encode( uint8_t const* bytes_to_encode std::string Sapphire::Common::Util::base64Decode( std::string const& encoded_string ) { - int32_t in_len = encoded_string.size(); + int32_t in_len = static_cast(encoded_string.size()); int32_t i = 0; int32_t j = 0; int32_t in_ = 0; diff --git a/src/common/Database/DbWorkerPool.cpp b/src/common/Database/DbWorkerPool.cpp index 09a24bfb56..3be538fbca 100644 --- a/src/common/Database/DbWorkerPool.cpp +++ b/src/common/Database/DbWorkerPool.cpp @@ -131,7 +131,7 @@ void Sapphire::Db::DbWorkerPool< T >::escapeString( std::string& str ) return; char* buf = new char[str.size() * 2 + 1]; - escapeString( buf, str.c_str(), str.size() ); + escapeString( buf, str.c_str(), static_cast(str.size()) ); str = buf; delete[] buf; } diff --git a/src/common/Network/GamePacketParser.cpp b/src/common/Network/GamePacketParser.cpp index f784f10280..768cff1dbe 100644 --- a/src/common/Network/GamePacketParser.cpp +++ b/src/common/Network/GamePacketParser.cpp @@ -73,7 +73,7 @@ PacketParseResult Network::Packets::getPackets( const std::vector< uint8_t >& bu std::vector< uint8_t > outBuf; outBuf.resize( packetHeader.oodleDecompressedSize ); - bool oodleSuccess = oodle->oodleDecode( inBuf, bytesExpected, outBuf, packetHeader.oodleDecompressedSize ); + bool oodleSuccess = oodle->oodleDecode( inBuf, static_cast(bytesExpected), outBuf, packetHeader.oodleDecompressedSize ); if( !oodleSuccess ) { diff --git a/src/common/Network/PacketContainer.cpp b/src/common/Network/PacketContainer.cpp index f06f1c8fdf..491ec2e4ba 100644 --- a/src/common/Network/PacketContainer.cpp +++ b/src/common/Network/PacketContainer.cpp @@ -65,14 +65,14 @@ void Network::Packets::PacketContainer::fillSendBuffer( std::vector< uint8_t >& std::vector< uint8_t > outBuf; outBuf.resize( m_ipcHdr.size ); - auto compLen = oodle->oodleEncode(inBuf, inBuf.size(), outBuf); + auto compLen = oodle->oodleEncode(inBuf, static_cast(inBuf.size()), outBuf); // Check if we compressed at all if (compLen != m_ipcHdr.size) { tempBuffer.resize(compLen); memcpy(&inBuf[0], &outBuf[0], compLen); m_ipcHdr.oodleDecompressedSize = m_ipcHdr.size; - m_ipcHdr.size = compLen; + m_ipcHdr.size = static_cast(compLen); m_ipcHdr.compressionType = static_cast< uint8_t >(Packets::CompressionType::Oodle); } } diff --git a/src/common/Util/Util.cpp b/src/common/Util/Util.cpp index 5aa64bf6f8..ead5ce0272 100644 --- a/src/common/Util/Util.cpp +++ b/src/common/Util/Util.cpp @@ -124,7 +124,7 @@ uint64_t Util::getTimeMs() uint32_t Util::getTimeSeconds() { auto currClock = std::chrono::system_clock::now(); - return std::chrono::time_point_cast< std::chrono::seconds >( currClock ).time_since_epoch().count(); + return static_cast(std::chrono::time_point_cast< std::chrono::seconds >( currClock ).time_since_epoch().count()); } uint64_t Util::getEorzeanTimeStamp() diff --git a/src/lobby/GameConnection.cpp b/src/lobby/GameConnection.cpp index 158e3a5b6b..ff0c46c0e7 100644 --- a/src/lobby/GameConnection.cpp +++ b/src/lobby/GameConnection.cpp @@ -470,7 +470,7 @@ void Lobby::GameConnection::handlePackets( const Network::Packets::FFXIVARR_PACK BlowFish blowfish; blowfish.initialize( m_encKey, 0x10 ); blowfish.Decode( ( uint8_t* ) ( &inPacket.data[ 0 ] ), ( uint8_t* ) ( &inPacket.data[ 0 ] ), - ( inPacket.data.size() ) - 0x10 ); + ( static_cast(inPacket.data.size() ) - 0x10 )); } switch( inPacket.segHdr.type ) diff --git a/src/lobby/LobbyPacketContainer.cpp b/src/lobby/LobbyPacketContainer.cpp index fcd4e4596d..2aa8d57141 100644 --- a/src/lobby/LobbyPacketContainer.cpp +++ b/src/lobby/LobbyPacketContainer.cpp @@ -32,10 +32,10 @@ void LobbyPacketContainer::addPacket( FFXIVPacketBasePtr pEntry ) { BlowFish blowfish; blowfish.initialize( m_encKey, 0x10 ); - blowfish.Encode( m_dataBuf + m_header.size + 0x10, m_dataBuf + m_header.size + 0x10, pEntry->getSize() - 0x10 ); + blowfish.Encode( m_dataBuf + m_header.size + 0x10, m_dataBuf + m_header.size + 0x10, (uint32_t)pEntry->getSize() - 0x10 ); } - m_header.size += pEntry->getSize(); + m_header.size += static_cast(pEntry->getSize()); m_header.count++; } diff --git a/src/lobby/RestConnector.cpp b/src/lobby/RestConnector.cpp index a8ee459ff5..3dcac39aa1 100644 --- a/src/lobby/RestConnector.cpp +++ b/src/lobby/RestConnector.cpp @@ -289,7 +289,7 @@ int Lobby::RestConnector::createCharacter( char* sId, std::string name, std::str { std::string json_string = "{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name + - "\",\"infoJson\": \"" + Common::Util::base64Encode( ( uint8_t* ) infoJson.c_str(), infoJson.length() ) + "\"}"; + "\",\"infoJson\": \"" + Common::Util::base64Encode( ( uint8_t* ) infoJson.c_str(), static_cast(infoJson.length()) ) + "\"}"; HttpResponse r = requestApi( "createCharacter", json_string ); diff --git a/src/scripts/quest/subquest/gridania/SubFst008.cpp b/src/scripts/quest/subquest/gridania/SubFst008.cpp index fb55691450..3f146d3b0b 100644 --- a/src/scripts/quest/subquest/gridania/SubFst008.cpp +++ b/src/scripts/quest/subquest/gridania/SubFst008.cpp @@ -125,7 +125,7 @@ class SubFst008 : { if( player.giveQuestRewards( getId(), result.param3 ) ) { - player.setQuestUI8BH( getId(), result.param3 ); + player.setQuestUI8BH( getId(), static_cast(result.param3) ); player.finishQuest( getId() ); } } diff --git a/src/tools/discovery_parser/main.cpp b/src/tools/discovery_parser/main.cpp index cfc427d9d7..c7ff4abb9c 100644 --- a/src/tools/discovery_parser/main.cpp +++ b/src/tools/discovery_parser/main.cpp @@ -77,11 +77,11 @@ struct DiscoveryMap : std::enable_shared_from_this< DiscoveryMap > { auto ogX = x, ogY = y; int col = ( mapIndex % ( int ) ( ( float ) img.width / ( float ) tileWidth ) ); - int row = ( mapIndex / ( ( float ) img.width / ( float ) tileWidth ) ); + int row = static_cast(( mapIndex / ( ( float ) img.width / ( float ) tileWidth ) )); x = ( x / 2048.f ) * ( float ) tileWidth; y = ( y / 2048.f ) * ( float ) tileWidth; - int tileX = ( col * ( float ) tileWidth ) + x; - int tileY = ( row * ( float ) tileWidth ) + y; + int tileX = static_cast((col * (float)tileWidth) + x); + int tileY = static_cast(( row * ( float ) tileWidth ) + y); if( tileX < 0 || tileY < 0 || tileY > img.data.size() - 1 || tileX > img.data[ 0 ].size() - 1 ) { diff --git a/src/tools/discovery_parser/tex_decode.h b/src/tools/discovery_parser/tex_decode.h index 2cc14f56ff..43ab5e61ef 100644 --- a/src/tools/discovery_parser/tex_decode.h +++ b/src/tools/discovery_parser/tex_decode.h @@ -63,7 +63,7 @@ struct Image data[ y ].resize( entries ); offset += 8; - for( auto x = 0; x < entries; ++x ) + for( uint32_t x = 0; x < entries; ++x ) data[ y ][ x ] = *reinterpret_cast< uint32_t* >( buf + offset + ( x * 4 ) ); offset += entries * 4; } @@ -254,9 +254,9 @@ Image DecodeTexDXT1( const TEX_FILE& tex, uint32_t offset, uint32_t targetHeight Image img( targetHeight, targetWidth ); - for( int y = 0; y < compressedHeight; y++ ) + for( uint32_t y = 0; y < compressedHeight; y++ ) { - for( int x = 0; x < compressedWidth; x++ ) + for( uint32_t x = 0; x < compressedWidth; x++ ) { const int t0 = *reinterpret_cast< const uint16_t* >( data + pos + 0 ) & 0xffff; const int t1 = *reinterpret_cast< const uint16_t* >( data + pos + 2 ) & 0xffff; diff --git a/src/tools/event_object_parser/main.cpp b/src/tools/event_object_parser/main.cpp index f1529fcb7f..484e369adf 100644 --- a/src/tools/event_object_parser/main.cpp +++ b/src/tools/event_object_parser/main.cpp @@ -156,7 +156,7 @@ void loadAllInstanceContentEntries() if( name.empty() ) continue; - auto i = 0; + size_t i = 0; while( ( i = name.find( ' ' ) ) != std::string::npos ) name = name.replace( name.begin() + i, name.begin() + i + 1, { '_' } ); diff --git a/src/tools/exd_struct_gen/main.cpp b/src/tools/exd_struct_gen/main.cpp index 7526a231d6..b388d4bb75 100644 --- a/src/tools/exd_struct_gen/main.cpp +++ b/src/tools/exd_struct_gen/main.cpp @@ -313,7 +313,7 @@ std::string generateConstructorsDecl( const std::string& exd ) { uint32_t amount = indexCountMap[ count ]; - for( int i = 0; i < amount; i++ ) + for( uint32_t i = 0; i < amount; i++ ) { result += indent + indexToNameMap[ count ] + ".push_back( exdData->getField< " + indexToTypeMap[ count ] + diff --git a/src/tools/nav_export/cache.h b/src/tools/nav_export/cache.h index b9f792262e..2953af82c6 100644 --- a/src/tools/nav_export/cache.h +++ b/src/tools/nav_export/cache.h @@ -119,6 +119,7 @@ class Cache : public std::enable_shared_from_this< Cache > } catch( std::exception& e ) { + (void)e; // suppress unused var warning std::vector< char > empty; return empty; } diff --git a/src/tools/nav_export/lgb.h b/src/tools/nav_export/lgb.h index ab4df7f36f..ef534d87bf 100644 --- a/src/tools/nav_export/lgb.h +++ b/src/tools/nav_export/lgb.h @@ -380,7 +380,7 @@ struct LGB_FILE for( auto i = 0; i < header.groupCount; ++i ) { const auto groupOffset = baseOffset + *reinterpret_cast< int32_t* >( buf + ( baseOffset + i * 4 ) ); - const auto group = LGB_GROUP( buf, this, groupOffset ); + const auto group = LGB_GROUP( buf, this, static_cast(groupOffset) ); groups.push_back( group ); } }; diff --git a/src/tools/nav_export/main.cpp b/src/tools/nav_export/main.cpp index 6a3369f0fb..09845462cf 100644 --- a/src/tools/nav_export/main.cpp +++ b/src/tools/nav_export/main.cpp @@ -332,6 +332,7 @@ int main( int argc, char* argv[] ) } catch( std::exception& e ) { + printf("An exception has occurred: %s", e.what()); printf( "Unable to initialise EXD!\n" ); return -1; } @@ -492,7 +493,7 @@ int main( int argc, char* argv[] ) printf( "Built export struct for %s in %lu seconds \n", zoneName.c_str(), - std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() )); } catch( std::exception& e ) { @@ -506,7 +507,7 @@ int main( int argc, char* argv[] ) std::cout << "\n\n\n"; printf( "Finished all tasks in %lu seconds\n", - std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() )); delete eData; delete gameData; diff --git a/src/tools/nav_export/navmesh_exporter.h b/src/tools/nav_export/navmesh_exporter.h index 642c404b1f..6c7488fa2b 100644 --- a/src/tools/nav_export/navmesh_exporter.h +++ b/src/tools/nav_export/navmesh_exporter.h @@ -52,7 +52,7 @@ class NavmeshExporter auto end = std::chrono::high_resolution_clock::now(); printf( "[Navmesh] Finished exporting %s in %lu ms\n", zone.name.c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); } }; diff --git a/src/tools/nav_export/obj_exporter.h b/src/tools/nav_export/obj_exporter.h index fc7ddc9993..e4969cfe17 100644 --- a/src/tools/nav_export/obj_exporter.h +++ b/src/tools/nav_export/obj_exporter.h @@ -53,7 +53,7 @@ class ObjExporter printf( "[Obj] Finished exporting %s in %lu ms\n", fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); return fileName; } @@ -91,7 +91,7 @@ class ObjExporter auto end = std::chrono::high_resolution_clock::now(); printf( "[Obj] Finished exporting %s in %lu ms\n", fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); return fileName; } @@ -128,7 +128,7 @@ class ObjExporter std::to_string( mesh.indices[ i + 1 ] + indicesOffset + 1 ) << ' ' + std::to_string( mesh.indices[ i + 2 ] + indicesOffset + 1 ) << '\n'; } - indicesOffset += mesh.verts.size() / 3; + indicesOffset += static_cast(mesh.verts.size()) / 3; } } //of.flush(); diff --git a/src/tools/nav_export/threadpool.h b/src/tools/nav_export/threadpool.h index 9da3f63e52..5ec9d2413c 100644 --- a/src/tools/nav_export/threadpool.h +++ b/src/tools/nav_export/threadpool.h @@ -34,7 +34,7 @@ class ThreadPool if( num == 0 ) num = std::thread::hardware_concurrency() - 1; - for( auto i = 0; i < num; ++i ) + for( unsigned int i = 0; i < num; ++i ) { m_workers.push_back( std::async( std::launch::async, [this]{ run(); } ) ); } diff --git a/src/tools/pcb_reader/cache.h b/src/tools/pcb_reader/cache.h index b9f792262e..d393f5cba2 100644 --- a/src/tools/pcb_reader/cache.h +++ b/src/tools/pcb_reader/cache.h @@ -119,6 +119,7 @@ class Cache : public std::enable_shared_from_this< Cache > } catch( std::exception& e ) { + (void)e; // suppress unused warning std::vector< char > empty; return empty; } diff --git a/src/tools/pcb_reader/lgb.h b/src/tools/pcb_reader/lgb.h index bd3be81ce5..198cbb481f 100644 --- a/src/tools/pcb_reader/lgb.h +++ b/src/tools/pcb_reader/lgb.h @@ -379,7 +379,7 @@ struct LGB_FILE for( auto i = 0; i < header.groupCount; ++i ) { const auto groupOffset = baseOffset + *reinterpret_cast< int32_t* >( buf + ( baseOffset + i * 4 ) ); - const auto group = LGB_GROUP( buf, this, groupOffset ); + const auto group = LGB_GROUP( buf, this, static_cast(groupOffset) ); groups.push_back( group ); } }; diff --git a/src/tools/pcb_reader/main.cpp b/src/tools/pcb_reader/main.cpp index 29ce3eb364..6dd7a8fafa 100644 --- a/src/tools/pcb_reader/main.cpp +++ b/src/tools/pcb_reader/main.cpp @@ -212,6 +212,7 @@ int main( int argc, char* argv[] ) } catch( std::exception& e ) { + printf("An exception has occurred: %s", e.what()); printf( "Unable to initialise EXD!\n Usage: pcb_reader \"path/to/FINAL FANTASY XIV - A REALM REBORN/game/sqpack\" [--no-obj, --dump-all, --navmesh, --jobs #]\n" ); return -1; } @@ -390,7 +391,7 @@ int main( int argc, char* argv[] ) mesh.indices[ indices++ ] = index.index[ 2 ]; // std::cout << std::to_string( index.unknown[0] )<< " " << std::to_string( index.unknown[1] )<< " " << std::to_string( index.unknown[2]) << std::endl; } - max_index += entry.data.vertices.size() + entry.data.vertices_i16.size(); + max_index += static_cast((entry.data.vertices.size() + entry.data.vertices_i16.size())); model.meshes[ meshCount++ ] = mesh; } exportedGroup.models[model.name] = model; @@ -521,7 +522,7 @@ int main( int argc, char* argv[] ) printf( "Built export struct for %s in %lu seconds \n", zoneName.c_str(), - std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() )); if( zoneCount++ % nJobs == 0 ) { exportMgr.restart(); @@ -540,7 +541,7 @@ int main( int argc, char* argv[] ) std::cout << "\n\n\n"; printf( "Finished all tasks in %lu seconds\n", - std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() )); delete eData; delete gameData; diff --git a/src/tools/pcb_reader/navmesh_exporter.h b/src/tools/pcb_reader/navmesh_exporter.h index ba890727af..b241ec8c6a 100644 --- a/src/tools/pcb_reader/navmesh_exporter.h +++ b/src/tools/pcb_reader/navmesh_exporter.h @@ -53,7 +53,7 @@ class NavmeshExporter auto end = std::chrono::high_resolution_clock::now(); printf( "[Navmesh] Finished exporting %s in %lu ms\n", zone.name.c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); } static void exportGroup( const std::string& zoneName, const ExportedGroup& group ) @@ -91,7 +91,7 @@ class NavmeshExporter auto end = std::chrono::high_resolution_clock::now(); printf( "[Navmesh] Finished exporting %s in %lu ms\n", fileName.c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); } }; #endif // !OBJ_EXPORTER_H diff --git a/src/tools/pcb_reader/obj_exporter.h b/src/tools/pcb_reader/obj_exporter.h index fc7ddc9993..e4969cfe17 100644 --- a/src/tools/pcb_reader/obj_exporter.h +++ b/src/tools/pcb_reader/obj_exporter.h @@ -53,7 +53,7 @@ class ObjExporter printf( "[Obj] Finished exporting %s in %lu ms\n", fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); return fileName; } @@ -91,7 +91,7 @@ class ObjExporter auto end = std::chrono::high_resolution_clock::now(); printf( "[Obj] Finished exporting %s in %lu ms\n", fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(), - std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); + static_cast(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() )); return fileName; } @@ -128,7 +128,7 @@ class ObjExporter std::to_string( mesh.indices[ i + 1 ] + indicesOffset + 1 ) << ' ' + std::to_string( mesh.indices[ i + 2 ] + indicesOffset + 1 ) << '\n'; } - indicesOffset += mesh.verts.size() / 3; + indicesOffset += static_cast(mesh.verts.size()) / 3; } } //of.flush(); diff --git a/src/tools/pcb_reader/pcb.h b/src/tools/pcb_reader/pcb.h index afec251801..31b7abbd37 100644 --- a/src/tools/pcb_reader/pcb.h +++ b/src/tools/pcb_reader/pcb.h @@ -121,7 +121,7 @@ struct PCB_FILE /* printf( "\tnum_v16: %i, num_indices: %i, num_vertices: %i\n\n", block_entry.header.num_v16, block_entry.header.num_indices, block_entry.header.num_vertices );*/ int doffset = sizeof( block_entry.header ) + offset; - uint16_t block_size = sizeof( block_entry.header ) + + uint16_t block_size = static_cast(sizeof( block_entry.header )) + block_entry.header.num_vertices * 3 * 4 + block_entry.header.num_v16 * 6 + block_entry.header.num_indices * 6; diff --git a/src/tools/pcb_reader/threadpool.h b/src/tools/pcb_reader/threadpool.h index 78657bd310..000d971ad6 100644 --- a/src/tools/pcb_reader/threadpool.h +++ b/src/tools/pcb_reader/threadpool.h @@ -34,7 +34,7 @@ class ThreadPool if( num == 0 ) num = std::thread::hardware_concurrency() - 1; - for( auto i = 0; i < num; ++i ) + for( unsigned int i = 0; i < num; ++i ) { m_workers.push_back( std::async( std::launch::async, [this]{ run(); } ) ); } diff --git a/src/tools/quest_parser/main.cpp b/src/tools/quest_parser/main.cpp index 44d60f056c..7b09ff4c7c 100644 --- a/src/tools/quest_parser/main.cpp +++ b/src/tools/quest_parser/main.cpp @@ -329,7 +329,7 @@ int main( int argc, char** argv ) Logger::info( "Export in progress" ); - uint32_t updateInterval = rows.size() / 20; + uint32_t updateInterval = static_cast(rows.size()) / 20; uint32_t i = 0; for( const auto& row : rows ) { @@ -386,7 +386,7 @@ int main( int argc, char** argv ) { std::string entry( §ion[ offset ] ); - offset += entry.size() + 1; + offset += static_cast(entry.size()) + 1; if( entry.size() > 3 && entry.find_first_not_of( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-" ) == diff --git a/src/tools/questbattle_bruteforce/main.cpp b/src/tools/questbattle_bruteforce/main.cpp index d8c1c6d4d0..f463b253af 100644 --- a/src/tools/questbattle_bruteforce/main.cpp +++ b/src/tools/questbattle_bruteforce/main.cpp @@ -122,7 +122,7 @@ int main( int argc, char* argv[] ) } catch( const std::exception& ex ) { - + (void)ex; // suppress unused variable warning } } diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 73ec81bfce..2fb8e0a7fb 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1572,9 +1572,9 @@ bool Sapphire::Entity::Player::hateListHasEntry( BNpcPtr pBNpc ) void Sapphire::Entity::Player::sendHateList() { auto hateListPacket = makeZonePacket< FFXIVIpcHateList >( getId() ); - hateListPacket->data().numEntries = m_actorIdTohateSlotMap.size(); + hateListPacket->data().numEntries = static_cast(m_actorIdTohateSlotMap.size()); auto hateRankPacket = makeZonePacket< FFXIVIpcHateRank >( getId() ); - hateRankPacket->data().numEntries = m_actorIdTohateSlotMap.size(); + hateRankPacket->data().numEntries = static_cast(m_actorIdTohateSlotMap.size()); auto it = m_actorIdTohateSlotMap.begin(); for( int32_t i = 0; it != m_actorIdTohateSlotMap.end(); ++it, i++ ) { @@ -1759,7 +1759,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget ) effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) ); Common::EffectEntry entry{}; - entry.value = damage.first; + entry.value = static_cast(damage.first); entry.effectType = Common::ActionEffectType::Damage; entry.param0 = static_cast< uint8_t >( damage.second ); entry.param2 = 0x72; @@ -1774,7 +1774,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget ) effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) ); Common::EffectEntry entry{}; - entry.value = damage.first; + entry.value = static_cast(damage.first); entry.effectType = Common::ActionEffectType::Damage; entry.param0 = static_cast< uint8_t >( damage.second ); entry.param2 = 0x73; @@ -1785,7 +1785,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget ) } - pTarget->takeDamage( damage.first ); + pTarget->takeDamage(static_cast(damage.first) ); } diff --git a/src/world/Actor/PlayerEvent.cpp b/src/world/Actor/PlayerEvent.cpp index eb9659e04d..cf19beb211 100644 --- a/src/world/Actor/PlayerEvent.cpp +++ b/src/world/Actor/PlayerEvent.cpp @@ -338,7 +338,7 @@ void Sapphire::Entity::Player::playScene16( uint32_t eventId, uint32_t scene, ui eventPlay16->data().scene = scene; eventPlay16->data().flags = flags; eventPlay16->data().param3 = param3; - eventPlay16->data().paramSize = paramList.size(); + eventPlay16->data().paramSize = static_cast(paramList.size()); int i = 0; for( auto p : paramList ) { diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index c818244a1e..38fb0eaa3e 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -1032,13 +1032,13 @@ Sapphire::ItemPtr Sapphire::Entity::Player::dropInventoryItem( Sapphire::Common: { auto& container = m_storageMap[ type ]; - auto item = container->getItem( slotId ); + auto item = container->getItem( static_cast(slotId) ); if( !item ) return nullptr; // unlink item - container->removeItem( slotId, false ); - updateContainer( type, slotId, nullptr ); + container->removeItem(static_cast(slotId), false ); + updateContainer( type, static_cast(slotId), nullptr ); if( !silent ) { @@ -1079,7 +1079,7 @@ bool Sapphire::Entity::Player::getFreeInventoryContainerSlot( Inventory::Invento for( uint16_t idx = 0; idx < container->getMaxSize(); idx++ ) { - auto item = container->getItem( idx ); + auto item = container->getItem(static_cast(idx) ); if( !item ) { containerPair = std::make_pair( bagId, idx ); @@ -1094,7 +1094,7 @@ bool Sapphire::Entity::Player::getFreeInventoryContainerSlot( Inventory::Invento void Sapphire::Entity::Player::insertInventoryItem( Sapphire::Common::InventoryType type, uint16_t slot, const Sapphire::ItemPtr item ) { - updateContainer( type, slot, item ); + updateContainer( type, static_cast(slot), item ); auto slotUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), slot, type, *item ); queuePacket( slotUpdate ); diff --git a/src/world/Actor/PlayerSql.cpp b/src/world/Actor/PlayerSql.cpp index 4b0bb68bdb..14d9250019 100644 --- a/src/world/Actor/PlayerSql.cpp +++ b/src/world/Actor/PlayerSql.cpp @@ -527,7 +527,7 @@ void Sapphire::Entity::Player::updateDbMonsterNote() auto stmt = db.getPreparedStatement( Db::CHARA_MONSTERNOTE_UP ); //std::array< std::vector< uint8_t >, 12 > vectors; std::vector< uint8_t > vector( 41 ); - for( std::size_t i = 0; i < m_huntingLogEntries.size(); ++i ) + for( uint8_t i = 0; i < m_huntingLogEntries.size(); ++i ) { vector[ 0 ] = m_huntingLogEntries[ i ].rank; diff --git a/src/world/Inventory/ItemContainer.cpp b/src/world/Inventory/ItemContainer.cpp index ddbece5bab..93b66ffef7 100644 --- a/src/world/Inventory/ItemContainer.cpp +++ b/src/world/Inventory/ItemContainer.cpp @@ -67,12 +67,12 @@ const Sapphire::ItemMap& Sapphire::ItemContainer::getItemMap() const int8_t Sapphire::ItemContainer::getFreeSlot() { - for( uint16_t slotId = 0; slotId < m_size; slotId++ ) + for( uint8_t slotId = 0; slotId < m_size; slotId++ ) { ItemMap::iterator it = m_itemMap.find( slotId ); if( it == m_itemMap.end() || it->second == nullptr ) - return slotId; + return static_cast(slotId); } return -1; } diff --git a/src/world/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index 044bc7f247..c804522425 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -446,7 +446,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& { uint8_t values[15]; std::memset( values, 0, sizeof( values ) ); - sscanf( params.c_str(), "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", + sscanf( params.c_str(), "%hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu", &values[ 0 ], &values[ 1 ], &values[ 2 ], &values[ 3 ], &values[ 4 ], &values[ 5 ], &values[ 6 ], &values[ 7 ], &values[ 8 ], &values[ 9 ], &values[ 10 ], &values[ 11 ], &values[ 12 ], &values[ 13 ], &values[ 14 ] ); @@ -686,7 +686,7 @@ void Sapphire::World::Manager::DebugCommandMgr::get( char* data, Entity::Player& } else if( ( subCommand == "poprange" ) ) { - uint32_t id, param; + uint32_t id; sscanf( params.c_str(), "%u", &id ); auto& instanceObjectCache = Common::Service< InstanceObjectCache >::ref(); diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index cd6b19934e..8df3964799 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -89,7 +89,7 @@ bool Sapphire::World::Manager::HousingMgr::init() { auto count = landSet.second.size(); - houseCount += count; + houseCount += static_cast(count); if( landSet.second.size() != 60 ) { @@ -810,7 +810,7 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity: if( !hZone ) return; - auto land = hZone->getLand( ident.landId ); + auto land = hZone->getLand(static_cast(ident.landId) ); if( !land ) return; @@ -1295,6 +1295,7 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla } catch( const std::out_of_range& ex ) { + (void)ex; // suppress unused var warning return false; } @@ -1702,7 +1703,7 @@ void Sapphire::World::Manager::HousingMgr::editAppearance( bool isInterior, Sapp updateHouseModels( land->getHouse() ); if( !isInterior ) { - terri->sendLandUpdate( landIdent.landId ); + terri->sendLandUpdate(static_cast(landIdent.landId) ); } } @@ -1758,11 +1759,11 @@ void Sapphire::World::Manager::HousingMgr::removeHouse( Entity::Player& player, land->setStatus( HouseStatus::Sold ); land->updateLandDb(); - terri->sendLandUpdate( plot ); + terri->sendLandUpdate(static_cast(plot) ); player.setLandFlags( LandFlagsSlot::Private, 0, land->getLandIdent() ); - terri->removeEstateEntranceEObj( plot ); + terri->removeEstateEntranceEObj(static_cast(plot) ); // missing reply for ClientTrigger RequestEstateHallRemoval } \ No newline at end of file diff --git a/src/world/Manager/MapMgr.cpp b/src/world/Manager/MapMgr.cpp index 34c3fd58fe..dee5b40d0e 100644 --- a/src/world/Manager/MapMgr.cpp +++ b/src/world/Manager/MapMgr.cpp @@ -620,7 +620,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even if( mapData.size() <= 2 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); @@ -629,7 +629,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even else if( mapData.size() <= 4 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate4 >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); @@ -638,7 +638,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even else if( mapData.size() <= 8 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate8 >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); @@ -647,7 +647,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even else if( mapData.size() <= 16 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate16 >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); @@ -656,7 +656,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even else if( mapData.size() <= 32 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate32 >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); @@ -665,7 +665,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even else if( mapData.size() <= 64 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate64 >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); @@ -674,7 +674,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even else if( mapData.size() <= 128 ) { auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate128 >( player.getId() ); - mapUpdatePacket->data().entryCount = mapData.size(); + mapUpdatePacket->data().entryCount = static_cast(mapData.size()); fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds ); diff --git a/src/world/Manager/PlayerMgr.cpp b/src/world/Manager/PlayerMgr.cpp index 79062f2e0b..6a47fb6e20 100644 --- a/src/world/Manager/PlayerMgr.cpp +++ b/src/world/Manager/PlayerMgr.cpp @@ -27,7 +27,7 @@ void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Sapphire: if( terriMgr.isHousingTerritory( terriPos->getTargetZoneId() ) ) { auto& housingMgr = Common::Service< HousingMgr >::ref(); - auto landSetId = housingMgr.toLandSetId( terriPos->getTargetZoneId(), param ); + auto landSetId = housingMgr.toLandSetId( terriPos->getTargetZoneId(), static_cast(param) ); auto housingZone = housingMgr.getHousingZoneByLandSetId( landSetId ); diff --git a/src/world/Manager/ShopMgr.cpp b/src/world/Manager/ShopMgr.cpp index 8ad8d2d53d..b55b1cfe50 100644 --- a/src/world/Manager/ShopMgr.cpp +++ b/src/world/Manager/ShopMgr.cpp @@ -52,7 +52,7 @@ bool Sapphire::World::Manager::ShopMgr::purchaseGilShopItem( Entity::Player& pla bool Sapphire::World::Manager::ShopMgr::shopSellItem( Sapphire::Entity::Player& player, uint32_t shopId, uint16_t containerId, uint16_t slotId ) { - auto item = player.getItemAt( containerId, slotId ); + auto item = player.getItemAt( containerId, static_cast(slotId) ); if( item ) { auto& exdData = Common::Service< Data::ExdDataGenerated >::ref(); diff --git a/src/world/Manager/TerritoryMgr.cpp b/src/world/Manager/TerritoryMgr.cpp index bf20bcae6d..2259eeeada 100644 --- a/src/world/Manager/TerritoryMgr.cpp +++ b/src/world/Manager/TerritoryMgr.cpp @@ -475,7 +475,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousi if( !parentZone ) return nullptr; - auto land = parentZone->getLand( landIdent.landId ); + auto land = parentZone->getLand(static_cast(landIdent.landId) ); if( !land ) return nullptr; diff --git a/src/world/Math/CalcStats.cpp b/src/world/Math/CalcStats.cpp index 6d0d8f583f..0efd48c50c 100644 --- a/src/world/Math/CalcStats.cpp +++ b/src/world/Math/CalcStats.cpp @@ -205,7 +205,7 @@ float CalcStats::directHitProbability( const Chara& chara ) const auto& baseStats = chara.getStats(); auto level = chara.getLevel(); - float dhRate = chara.getStatValue( Common::BaseParam::DirectHitRate ); + float dhRate = static_cast(chara.getStatValue( Common::BaseParam::DirectHitRate )); auto divVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::DIV ] ); auto subVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::SUB ] ); @@ -218,7 +218,7 @@ float CalcStats::criticalHitProbability( const Chara& chara ) const auto& baseStats = chara.getStats(); auto level = chara.getLevel(); - float chRate = chara.getStatValue( Common::BaseParam::CriticalHit ); + float chRate = (float)chara.getStatValue( Common::BaseParam::CriticalHit ); auto divVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::DIV ] ); auto subVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::SUB ] ); diff --git a/src/world/Navi/NaviProvider.cpp b/src/world/Navi/NaviProvider.cpp index e118734b0f..d14ea610ba 100644 --- a/src/world/Navi/NaviProvider.cpp +++ b/src/world/Navi/NaviProvider.cpp @@ -573,7 +573,7 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara ) std::memset( ¶ms, 0, sizeof( params ) ); params.height = 3.f; params.maxAcceleration = 25.f; - params.maxSpeed = std::pow( 2, chara.getRadius() * 0.35f ) + 1.f; + params.maxSpeed = static_cast(std::pow( 2, chara.getRadius() * 0.35f )) + 1.f; params.radius = ( chara.getRadius() ) * 0.75f; params.collisionQueryRange = params.radius * 12.0f; params.pathOptimizationRange = params.radius * 20.0f; @@ -589,7 +589,7 @@ void Sapphire::World::Navi::NaviProvider::updateAgentParameters( Entity::BNpc& b std::memset( ¶ms, 0, sizeof( params ) ); params.height = 3.f; params.maxAcceleration = 25.f; - params.maxSpeed = std::pow( 2, bnpc.getRadius() * 0.35f ) + 1.f; + params.maxSpeed = (float)std::pow( 2, bnpc.getRadius() * 0.35f ) + 1.f; if( bnpc.getState() == Entity::BNpcState::Combat || bnpc.getState() == Entity::BNpcState::Retreat ) params.maxSpeed *= 2; params.radius = ( bnpc.getRadius() ) * 0.75f; diff --git a/src/world/Network/GameConnection.cpp b/src/world/Network/GameConnection.cpp index c2afcd0e2d..c6f10f22bc 100644 --- a/src/world/Network/GameConnection.cpp +++ b/src/world/Network/GameConnection.cpp @@ -328,7 +328,7 @@ void Sapphire::Network::GameConnection::processOutQueue() } pRP.addPacket( pPacket ); - totalSize += pPacket->getSize(); + totalSize += static_cast(pPacket->getSize()); // todo: figure out a good max set size and make it configurable if( totalSize > 10000 ) diff --git a/src/world/Network/Handlers/ClientTriggerHandler.cpp b/src/world/Network/Handlers/ClientTriggerHandler.cpp index 8c60c23388..427fb18dc0 100644 --- a/src/world/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/world/Network/Handlers/ClientTriggerHandler.cpp @@ -154,7 +154,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX } case ClientTriggerType::Examine: { - uint32_t targetId = p1u64; + uint32_t targetId = static_cast(p1u64); examineHandler( player, targetId ); break; } diff --git a/src/world/Network/Handlers/PacketHandlers.cpp b/src/world/Network/Handlers/PacketHandlers.cpp index f0a5c5fcaa..91d8237d9b 100644 --- a/src/world/Network/Handlers/PacketHandlers.cpp +++ b/src/world/Network/Handlers/PacketHandlers.cpp @@ -658,13 +658,13 @@ void Sapphire::Network::GameConnection::landRenameHandler( const Packets::FFXIVA auto& housingMgr = Common::Service< HousingMgr >::ref(); - auto landSetId = housingMgr.toLandSetId( packet.data().ident.territoryTypeId, packet.data().ident.wardNum ); + auto landSetId = housingMgr.toLandSetId( packet.data().ident.territoryTypeId, (uint8_t)packet.data().ident.wardNum ); auto pZone = housingMgr.getHousingZoneByLandSetId( landSetId ); if( !pZone ) return; - auto pLand = pZone->getLand( packet.data().ident.landId ); + auto pLand = pZone->getLand(static_cast(packet.data().ident.landId) ); if( !pLand ) return; @@ -712,11 +712,11 @@ void Sapphire::Network::GameConnection::reqPlaceHousingItem( const Packets::FFXI if( data.shouldPlaceItem == 1 ) { - housingMgr.reqPlaceHousingItem( player, data.landId, data.sourceInvContainerId, data.sourceInvSlotId, + housingMgr.reqPlaceHousingItem( player, data.landId, data.sourceInvContainerId, static_cast(data.sourceInvSlotId), data.position, data.rotation ); } else - housingMgr.reqPlaceItemInStore( player, data.landId, data.sourceInvContainerId, data.sourceInvSlotId ); + housingMgr.reqPlaceItemInStore( player, data.landId, data.sourceInvContainerId, static_cast(data.sourceInvSlotId) ); } @@ -728,7 +728,7 @@ void Sapphire::Network::GameConnection::reqMoveHousingItem( const Packets::FFXIV const auto packet = ZoneChannelPacket< Client::FFXIVIpcHousingUpdateObjectPosition >( inPacket ); const auto& data = packet.data(); - housingMgr.reqMoveHousingItem( player, data.ident, data.slot, data.pos, data.rotation ); + housingMgr.reqMoveHousingItem( player, data.ident, static_cast(data.slot), data.pos, data.rotation ); } void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) @@ -748,7 +748,7 @@ void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXI slotList.push_back( container != 0x270F ? static_cast< uint8_t >( packet.data().slot[i] ) : 0xFF ); } - housingMgr.editAppearance( false, player, terri->getLand( packet.data().landId )->getLandIdent(), containerList, slotList, packet.data().removeFlag ); + housingMgr.editAppearance( false, player, terri->getLand( static_cast(packet.data().landId) )->getLandIdent(), containerList, slotList, packet.data().removeFlag ); } void Sapphire::Network::GameConnection::housingEditInterior( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) @@ -847,18 +847,18 @@ void Sapphire::Network::GameConnection::inventoryEquipRecommendedItemsHandler( c if ( fromContainer == Common::GearSet0 ) continue; - const auto fromItem = fromSlot == -1 ? nullptr : player.getItemAt( fromContainer, fromSlot ); + const auto fromItem = fromSlot == -1 ? nullptr : player.getItemAt( fromContainer, static_cast(fromSlot) ); const auto equippedItem = player.getItemAt( Common::GearSet0, slot ); if ( fromItem && equippedItem ) { - player.swapItem( fromContainer, fromSlot, Common::GearSet0, slot, slot == 0 || slot == 13 ); + player.swapItem( fromContainer, static_cast(fromSlot), Common::GearSet0, slot, slot == 0 || slot == 13 ); player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), fromSlot, fromContainer, *equippedItem, 0 ) ); player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), slot, Common::GearSet0, *fromItem, 0 ) ); } else if ( fromItem && !equippedItem ) { - player.moveItem( fromContainer, fromSlot, Common::GearSet0, slot, slot == 0 || slot == 13 ); + player.moveItem( fromContainer, static_cast(fromSlot), Common::GearSet0, slot, slot == 0 || slot == 13 ); player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), fromSlot, fromContainer, 0 ) ); player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), slot, Common::GearSet0, *fromItem, 0 ) ); } diff --git a/src/world/Network/PacketWrappers/InviteHandlers.cpp b/src/world/Network/PacketWrappers/InviteHandlers.cpp index 97f3d41f2a..79df30d3b6 100644 --- a/src/world/Network/PacketWrappers/InviteHandlers.cpp +++ b/src/world/Network/PacketWrappers/InviteHandlers.cpp @@ -115,7 +115,7 @@ void Sapphire::Network::GameConnection::socialReplyHandler( const FFXIVARR_PACKE strcpy( inviteUpPacket->data().name, player.getName().c_str() ); pPlayer->queuePacket( inviteUpPacket ); - inviteReplyData.contentId == pPlayer->getContentId(); + inviteReplyData.contentId = pPlayer->getContentId(); inviteReplyData.socialType = data.socialType; inviteReplyData.gender = pPlayer->getGender(); strcpy( inviteReplyData.name, pPlayer->getName().c_str() ); diff --git a/src/world/Network/PacketWrappers/MoveActorPacket.h b/src/world/Network/PacketWrappers/MoveActorPacket.h index 9cf724fc77..8c65b43c94 100644 --- a/src/world/Network/PacketWrappers/MoveActorPacket.h +++ b/src/world/Network/PacketWrappers/MoveActorPacket.h @@ -32,7 +32,7 @@ namespace Sapphire::Network::Packets::Server m_data.headRotation = headRotation; m_data.animationType = animationType; m_data.animationState = state; - m_data.animationSpeed = animationSpeed; + m_data.animationSpeed = static_cast(animationSpeed); m_data.unknownRotation = unknownRotation; m_data.posX = Common::Util::floatToUInt16( actor.getPos().x ); m_data.posY = Common::Util::floatToUInt16( actor.getPos().y ); diff --git a/src/world/Script/ScriptMgr.cpp b/src/world/Script/ScriptMgr.cpp index efb0c0cf8e..fcd730ba93 100644 --- a/src/world/Script/ScriptMgr.cpp +++ b/src/world/Script/ScriptMgr.cpp @@ -164,7 +164,7 @@ bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t ac { // check if the actor is an eobj and call its script if we have one auto zone = player.getCurrentTerritory(); - if( auto eobj = zone->getEObj( actorId ) ) + if( auto eobj = zone->getEObj( static_cast(actorId) ) ) { auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventObjectScript >( eobj->getObjectId() ); if( script ) diff --git a/src/world/Territory/HousingZone.cpp b/src/world/Territory/HousingZone.cpp index 246e048546..fcd95b96f3 100644 --- a/src/world/Territory/HousingZone.cpp +++ b/src/world/Territory/HousingZone.cpp @@ -140,12 +140,12 @@ bool Sapphire::HousingZone::init() land->setHouse( house ); } - land->init( entry.m_type, entry.m_size, entry.m_status, entry.m_currentPrice, entry.m_ownerId, entry.m_houseId ); + land->init( entry.m_type, entry.m_size, entry.m_status, static_cast(entry.m_currentPrice), entry.m_ownerId, entry.m_houseId ); - m_landPtrMap[ entry.m_landId ] = land; + m_landPtrMap[ static_cast(entry.m_landId) ] = land; if( entry.m_houseId > 0 ) - registerEstateEntranceEObj( entry.m_landId ); + registerEstateEntranceEObj( static_cast(entry.m_landId) ); updateYardObjects( land->getLandIdent() ); } @@ -169,7 +169,7 @@ void Sapphire::HousingZone::onPlayerZoneIn( Entity::Player& player ) { auto housingObjectInit = makeZonePacket< FFXIVIpcHousingObjectInitialize >( player.getId() ); memset( &housingObjectInit->data().landIdent, 0xFF, sizeof( Common::LandIdent ) ); - housingObjectInit->data().u1 = 0xFF; + housingObjectInit->data().u1 |= 0xFF; housingObjectInit->data().packetNum = yardPacketNum; housingObjectInit->data().packetTotal = yardPacketTotal; @@ -232,7 +232,7 @@ void Sapphire::HousingZone::sendLandSet( Entity::Player& player ) for( auto i = 0; i != parts.size(); i++ ) { landData.housePart[ i ] = parts[ i ].first; - landData.houseColour[ i ] = parts[ i ].second; + landData.houseColour[ i ] = static_cast(parts[ i ].second); } } } @@ -269,7 +269,7 @@ void Sapphire::HousingZone::sendLandUpdate( uint8_t landId ) for( auto i = 0; i != parts.size(); i++ ) { landData.housePart[ i ] = parts[ i ].first; - landData.houseColour[ i ] = parts[ i ].second; + landData.houseColour[ i ] = static_cast(parts[ i ].second); } } @@ -409,11 +409,11 @@ void Sapphire::HousingZone::updateYardObjectPos( Entity::Player& sourcePlayer, u auto packet = makeZonePacket< Server::FFXIVIpcHousingObjectMove >( player.second->getId() ); - packet->data().itemRotation = item.getRot(); + packet->data().itemRotation = static_cast(item.getRot()); packet->data().pos = item.getPos(); - packet->data().landId = landId; - packet->data().objectArray = slot; + packet->data().landId = static_cast(landId); + packet->data().objectArray = static_cast(slot); player.second->queuePacket( packet ); } diff --git a/src/world/Territory/Land.cpp b/src/world/Territory/Land.cpp index bb16550cb6..1cfd7c0981 100644 --- a/src/world/Territory/Land.cpp +++ b/src/world/Territory/Land.cpp @@ -242,18 +242,16 @@ Sapphire::Land::InvMaxItemsPair Sapphire::Land::getInventoryItemMax() const { switch( m_size ) { + default: case HouseSize::Cottage: - { return std::make_pair( 20, 200 ); - } + break; case HouseSize::House: - { return std::make_pair( 30, 300 ); - } + break; case HouseSize::Mansion: - { return std::make_pair( 40, 400 ); - } + break; } assert( false ); } diff --git a/src/world/Territory/Territory.cpp b/src/world/Territory/Territory.cpp index c7fdb72411..272c1f4d47 100644 --- a/src/world/Territory/Territory.cpp +++ b/src/world/Territory/Territory.cpp @@ -474,7 +474,7 @@ bool Sapphire::Territory::update( uint64_t tickCount ) auto dt = std::difftime( tickCount, m_lastUpdate ) / 1000.f; if( m_pNaviProvider ) - m_pNaviProvider->updateCrowd( dt ); + m_pNaviProvider->updateCrowd( static_cast(dt) ); updateSessions( tickCount, changedWeather ); onUpdate( tickCount );