From 5c7d90ff84ef61df3d93ce359b0f9ba41c89cce1 Mon Sep 17 00:00:00 2001 From: Reyli Date: Fri, 21 Jun 2024 09:51:53 -0500 Subject: [PATCH] Warning removals round 2 Chugged through the rest of the warnings by casting and builds without warnings. I was going through the intellisense stuff and initializing struct variables but like... it stopped working after I restarted Visual Studio. Guess you get what I got. --- src/api/server_http.hpp | 6 +++--- src/tools/nav_export/cache.h | 1 + src/tools/nav_export/lgb.h | 22 +++++++++++----------- src/tools/nav_export/main.cpp | 5 +++-- src/tools/nav_export/navmesh_exporter.h | 2 +- src/tools/nav_export/obj_exporter.h | 6 +++--- src/tools/pcb_reader/cache.h | 1 + src/tools/pcb_reader/lgb.h | 14 +++++++------- src/tools/pcb_reader/main.cpp | 7 ++++--- src/tools/pcb_reader/navmesh_exporter.h | 4 ++-- src/tools/pcb_reader/obj_exporter.h | 6 +++--- src/tools/pcb_reader/pcb.h | 2 +- 12 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/api/server_http.hpp b/src/api/server_http.hpp index b9166c57..596e2f6d 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, (long)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, (long)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, (long)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/tools/nav_export/cache.h b/src/tools/nav_export/cache.h index b9f79226..2953af82 100644 --- a/src/tools/nav_export/cache.h +++ b/src/tools/nav_export/cache.h @@ -119,6 +119,7 @@ private: } 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 ab4df7f3..7595fb9b 100644 --- a/src/tools/nav_export/lgb.h +++ b/src/tools/nav_export/lgb.h @@ -70,12 +70,12 @@ enum class LgbEntryType : struct InstanceObject { - LgbEntryType type; - uint32_t unknown; - uint32_t nameOffset; - vec3 translation; - vec3 rotation; - vec3 scale; + LgbEntryType type{}; + uint32_t unknown{}; + uint32_t nameOffset{}; + vec3 translation{}; + vec3 rotation{}; + vec3 scale{}; }; class LgbEntry @@ -221,10 +221,10 @@ public: struct MapRangeData : public InstanceObject { - uint32_t type; - uint16_t unknown2; - uint16_t unknown3; - uint8_t unknown4[0x10]; + uint32_t type{}; + uint16_t unknown2{}; + uint16_t unknown3{}; + uint8_t unknown4[0x10]{}; }; struct LGB_MAP_RANGE_ENTRY : @@ -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, (uint32_t)groupOffset ); groups.push_back( group ); } }; diff --git a/src/tools/nav_export/main.cpp b/src/tools/nav_export/main.cpp index 6a3369f0..d4e4bb70 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() ); + (unsigned long)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() ); + (unsigned long)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 642c404b..37744866 100644 --- a/src/tools/nav_export/navmesh_exporter.h +++ b/src/tools/nav_export/navmesh_exporter.h @@ -52,7 +52,7 @@ public: 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() ); + (unsigned long)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 fc7ddc99..8bed69b2 100644 --- a/src/tools/nav_export/obj_exporter.h +++ b/src/tools/nav_export/obj_exporter.h @@ -53,7 +53,7 @@ public: 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() ); + (unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); return fileName; } @@ -91,7 +91,7 @@ public: 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() ); + (unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); return fileName; } @@ -128,7 +128,7 @@ private: 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 += (int)mesh.verts.size() / 3; } } //of.flush(); diff --git a/src/tools/pcb_reader/cache.h b/src/tools/pcb_reader/cache.h index b9f79226..d393f5cb 100644 --- a/src/tools/pcb_reader/cache.h +++ b/src/tools/pcb_reader/cache.h @@ -119,6 +119,7 @@ private: } 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 bd3be81c..c4c36f64 100644 --- a/src/tools/pcb_reader/lgb.h +++ b/src/tools/pcb_reader/lgb.h @@ -70,12 +70,12 @@ enum class LgbEntryType : struct InstanceObject { - LgbEntryType type; - uint32_t unknown; - uint32_t nameOffset; - vec3 translation; - vec3 rotation; - vec3 scale; + LgbEntryType type{}; + uint32_t unknown{}; + uint32_t nameOffset{}; + vec3 translation{}; + vec3 rotation{}; + vec3 scale{}; }; class LgbEntry @@ -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, (uint32_t)groupOffset ); groups.push_back( group ); } }; diff --git a/src/tools/pcb_reader/main.cpp b/src/tools/pcb_reader/main.cpp index 29ce3eb3..3c1575df 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 += (uint32_t)(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() ); + (unsigned long)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() ); + (unsigned long)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 ba890727..630f1e65 100644 --- a/src/tools/pcb_reader/navmesh_exporter.h +++ b/src/tools/pcb_reader/navmesh_exporter.h @@ -53,7 +53,7 @@ public: 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() ); + (unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); } static void exportGroup( const std::string& zoneName, const ExportedGroup& group ) @@ -91,7 +91,7 @@ public: 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() ); + (unsigned long)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 fc7ddc99..8bed69b2 100644 --- a/src/tools/pcb_reader/obj_exporter.h +++ b/src/tools/pcb_reader/obj_exporter.h @@ -53,7 +53,7 @@ public: 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() ); + (unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); return fileName; } @@ -91,7 +91,7 @@ public: 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() ); + (unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ); return fileName; } @@ -128,7 +128,7 @@ private: 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 += (int)mesh.verts.size() / 3; } } //of.flush(); diff --git a/src/tools/pcb_reader/pcb.h b/src/tools/pcb_reader/pcb.h index afec2518..99a9e039 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 = (uint16_t)sizeof( block_entry.header ) + block_entry.header.num_vertices * 3 * 4 + block_entry.header.num_v16 * 6 + block_entry.header.num_indices * 6;