diff --git a/.travis.yml b/.travis.yml index 5a08c891..6c5c62cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,17 +6,19 @@ before_install: - sudo apt-get update - sudo apt-get install -y software-properties-common - sudo apt-get update - - sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib cmake3 -y + - sudo apt-get install gcc-7 g++-7 gcc-7-multilib g++-7-multilib cmake3 -y - sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev -y - - sudo apt-get install libmysqlcppconn-dev -y + - sudo apt-get install libmysqlcppconn-dev -y + compiler: - - gcc + - g++ # Build steps script: + - g++ --version - mkdir build - cd build - - cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make -j 3 + - cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-7 && make -j 3 - cd .. - bash sql_import.sh diff --git a/src/tools/pcb_reader/CMakeLists.txt b/src/tools/pcb_reader/CMakeLists.txt index 85329b26..a73b4816 100644 --- a/src/tools/pcb_reader/CMakeLists.txt +++ b/src/tools/pcb_reader/CMakeLists.txt @@ -20,7 +20,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(pcb_reader2 ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(pcb_reader2 PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 14 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/pcb_reader/lgb.h b/src/tools/pcb_reader/lgb.h index 9de026ff..3ad58b89 100644 --- a/src/tools/pcb_reader/lgb.h +++ b/src/tools/pcb_reader/lgb.h @@ -1,14 +1,16 @@ #ifndef _LGB_H #define _LGB_H -#include "matrix4.h" -#include "vec3.h" +#include #include #include #include #include #include -#include +#include + +#include "matrix4.h" +#include "vec3.h" // all credit to // https://github.com/ufx/SaintCoinach/blob/master/SaintCoinach/Graphics/Lgb/ @@ -105,7 +107,7 @@ public: LGB_BGPARTS_ENTRY() {}; LGB_BGPARTS_ENTRY( char* buf, uint32_t offset ) { - header = *reinterpret_cast(buf + offset); + header = *reinterpret_cast( buf + offset ); name = std::string( buf + offset + header.nameOffset ); modelFileName = std::string( buf + offset + header.modelFileOffset ); collisionFileName = std::string( buf + offset + header.collisionFileOffset ); @@ -135,7 +137,7 @@ public: LGB_GIMMICK_ENTRY( char* buf, uint32_t offset ) { - header = *reinterpret_cast(buf + offset); + header = *reinterpret_cast( buf + offset ); name = std::string( buf + offset + header.nameOffset ); }; }; @@ -167,21 +169,21 @@ struct LGB_GROUP LGB_GROUP( char* buf, LGB_FILE* parentStruct, uint32_t offset ) { parent = parentStruct; - header = *reinterpret_cast(buf + offset); + header = *reinterpret_cast( buf + offset ); name = std::string( buf + offset + header.groupNameOffset ); //entries.resize( header.entryCount ); //std::cout << name << std::endl; - auto entriesOffset = offset + header.entriesOffset; + const auto entriesOffset = offset + header.entriesOffset; for( auto i = 0; i < header.entryCount; ++i ) { - auto entryOffset = entriesOffset + *reinterpret_cast(buf + (entriesOffset + i * 4)); + const auto entryOffset = entriesOffset + *reinterpret_cast( buf + ( entriesOffset + i * 4 ) ); try { - auto type = *reinterpret_cast(buf + entryOffset); + const auto type = *reinterpret_cast( buf + entryOffset ); if( type == LgbEntryType::BgParts ) { - entries.push_back(std::make_shared( buf, entryOffset )); + entries.push_back( std::make_shared( buf, entryOffset ) ); } /* else if( type == LgbEntryType::Gimmick ) @@ -222,22 +224,25 @@ struct LGB_FILE LGB_FILE( char* buf ) { - header = *reinterpret_cast(buf); + header = *reinterpret_cast( buf ); if( strncmp( &header.magic[0], "LGB1", 4 ) != 0 || strncmp( &header.magic2[0], "LGP1", 4 ) != 0 ) - throw std::exception( "Invalid LGB file!" ); + throw std::runtime_error( "Invalid LGB file!" ); //groups.resize(header.groupCount); - auto baseOffset = sizeof( header ); + constexpr auto baseOffset = sizeof( header ); for( auto i = 0; i < header.groupCount; ++i ) { - auto groupOffset = baseOffset + *reinterpret_cast(buf + (baseOffset + i * 4)); - auto group = LGB_GROUP( buf, this, groupOffset ); + const auto groupOffset = baseOffset + *reinterpret_cast( buf + ( baseOffset + i * 4 ) ); + const auto group = LGB_GROUP( buf, this, groupOffset ); groups.push_back( group ); } }; }; +/* +#if __cplusplus >= 201703L +#include std::map getLgbFiles( const std::string& dir ) { namespace fs = std::experimental::filesystem; @@ -246,10 +251,10 @@ std::map getLgbFiles( const std::string& dir ) { if( path.path().extension() == ".lgb" ) { - auto strPath = path.path().string(); + const auto& strPath = path.path().string(); auto f = fopen( strPath.c_str(), "rb" ); fseek( f, 0, SEEK_END ); - auto size = ftell( f ); + const auto size = ftell( f ); std::vector bytes( size ); rewind( f ); fread( bytes.data(), 1, size, f ); @@ -267,4 +272,6 @@ std::map getLgbFiles( const std::string& dir ) } return fileMap; } -#endif \ No newline at end of file +#endif +*/ +#endif diff --git a/src/tools/pcb_reader/main.cpp b/src/tools/pcb_reader/main.cpp index 81ac0ebd..e6dbffd5 100644 --- a/src/tools/pcb_reader/main.cpp +++ b/src/tools/pcb_reader/main.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "pcb.h" #include "lgb.h" @@ -18,7 +17,7 @@ #include using namespace std::chrono_literals; -namespace fs = std::experimental::filesystem; + struct face { int32_t f1, f2, f3; @@ -141,15 +140,15 @@ int main( int argc, char* argv[] ) const xiv::dat::Cat& test = data1.get_category( "bg" ); - auto &test_file = data1.get_file( "bg/ffxiv/" + zonePath + "/level/bg.lgb" ); - auto §ion = test_file->access_data_sections().at( 0 ); + auto test_file = data1.get_file( "bg/ffxiv/" + zonePath + "/level/bg.lgb" ); + auto section = test_file->access_data_sections().at( 0 ); int32_t list_offset = *(uint32_t*)§ion[0x18]; int32_t size = *(uint32_t*)§ion[4]; std::vector stringList; - auto &test_file1 = data1.get_file( "bg/ffxiv/" + zonePath + "/collision/list.pcb" ); - auto §ion1 = test_file1->access_data_sections().at( 0 ); + auto test_file1 = data1.get_file( "bg/ffxiv/" + zonePath + "/collision/list.pcb" ); + auto section1 = test_file1->access_data_sections().at( 0 ); std::string path = "bg/ffxiv/" + zonePath + "/collision/"; int offset1 = 0x20; for( ; ; ) @@ -180,7 +179,7 @@ int main( int argc, char* argv[] ) int counter = 0; // dont bother if we cant write to a file - auto fp_out = fopen( (zoneName + ".obj").c_str(), "w" ); + auto fp_out = fopen( ( zoneName + ".obj" ).c_str(), "w" ); if( fp_out ) { fprintf( fp_out, "\n" ); @@ -191,11 +190,11 @@ int main( int argc, char* argv[] ) std::string errorMessage( "Cannot create " + zoneName + ".obj\n" + " Check no programs have a handle to file and run as admin.\n" ); std::cout << errorMessage; - throw std::exception( errorMessage.c_str() ); + throw std::runtime_error( errorMessage.c_str() ); return 0; } - fp_out = fopen( (zoneName + ".obj").c_str(), "ab+" ); + fp_out = fopen( ( zoneName + ".obj" ).c_str(), "ab+" ); if( fp_out ) { std::map pcbFiles; @@ -212,7 +211,6 @@ int main( int argc, char* argv[] ) //std::cout << sections.size() << "\n"; uint32_t offset = 0; - uint32_t groupCount = 0; PCB_FILE pcb_file; memcpy( &pcb_file.header, &dataSection[0], sizeof( pcb_file.header ) ); offset += sizeof( pcb_file.header ); @@ -235,7 +233,6 @@ int main( int argc, char* argv[] ) { parseBlockEntry( &dataSection[0] + offset, pcb_file.entries, offset ); } - groupCount++; } pcbFiles.insert( std::make_pair( fileName, pcb_file ) ); } @@ -246,10 +243,10 @@ int main( int argc, char* argv[] ) }; auto pushVerts = [&]( const PCB_FILE& pcb_file, const std::string& name, const vec3* scale = nullptr, const vec3* rotation = nullptr, const vec3* translation = nullptr ) { - std::string name2 = (name + "_" + std::to_string( objCount[name]++ )); + std::string name2 = ( name + "_" + std::to_string( objCount[name]++ ) ); fprintf( fp_out, "o %s\n", name2.c_str() ); uint32_t groupCount = 0; - for( auto &entry : pcb_file.entries ) + for( const auto &entry : pcb_file.entries ) { float x_base = abs( float( entry.header.x1 - entry.header.x ) ); float y_base = abs( float( entry.header.y1 - entry.header.y ) ); @@ -303,7 +300,7 @@ int main( int argc, char* argv[] ) index.index[1] + max_index + 1, index.index[2] + max_index + 1 ); } -// std::cout << std::to_string( index.unknown[0] )<< " " << std::to_string( index.unknown[1] )<< " " << std::to_string( index.unknown[2]) << std::endl; + // 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(); } @@ -324,20 +321,17 @@ int main( int argc, char* argv[] ) totalGroups++; for( const auto pEntry : group.entries ) { - auto pBgParts = dynamic_cast(pEntry.get()); - + auto pBgParts = static_cast( pEntry.get() ); auto& fileName = pBgParts->collisionFileName; - if( pBgParts ) - { - if ( fileName.empty() ) - fileName = pBgParts->modelFileName; - boost::replace_all( fileName, "bgparts", "collision" ); - boost::replace_all( fileName, ".mdl", ".pcb" ); - } - if( !pBgParts || fileName.empty() ) + if( fileName.empty() ) continue; + { + //boost::replace_all( fileName, "bgparts", "collision" ); + //boost::replace_all( fileName, ".mdl", ".pcb" ); + } + { const auto& it = pcbFiles.find( fileName ); if( it == pcbFiles.end() ) @@ -351,8 +345,6 @@ int main( int argc, char* argv[] ) { totalGroupEntries++; - //std::cout << pBgParts->collisionFileName << "\n"; - const auto* scale = &pBgParts->header.scale; const auto* rotation = &pBgParts->header.rotation; const auto* translation = &pBgParts->header.translation; @@ -366,11 +358,11 @@ int main( int argc, char* argv[] ) std::cout << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n"; } std::cout << "Finished exporting " << zoneName << " in " << - std::chrono::duration_cast(std::chrono::system_clock::now() - startTime).count() << " seconds\n"; + std::chrono::duration_cast( std::chrono::system_clock::now() - startTime ).count() << " seconds\n"; } catch( std::exception& e ) { std::cout << e.what() << std::endl; } return 0; -} \ No newline at end of file +} diff --git a/src/tools/pcb_reader/matrix4.h b/src/tools/pcb_reader/matrix4.h index 981d5a98..d02d2c84 100644 --- a/src/tools/pcb_reader/matrix4.h +++ b/src/tools/pcb_reader/matrix4.h @@ -2,6 +2,7 @@ #define _MATRIX4_H #include +#include // https://github.com/jpd002/Play--Framework/tree/master/include/math struct matrix4 @@ -96,4 +97,4 @@ struct matrix4 return ret; } }; -#endif \ No newline at end of file +#endif diff --git a/src/tools/pcb_reader/pcb.h b/src/tools/pcb_reader/pcb.h index b8f451a9..4b775d84 100644 --- a/src/tools/pcb_reader/pcb.h +++ b/src/tools/pcb_reader/pcb.h @@ -74,19 +74,19 @@ struct PCB_FILE struct PCB_LIST_ENTRY { - uint32_t id; - float x, y, z, x2, y2, z2, rot; + uint32_t id; + float x, y, z, x2, y2, z2, rot; }; struct PCB_LIST_BASE_ENTRY { - float x, y, z, x2, y2, z2, rot; + float x, y, z, x2, y2, z2, rot; }; struct PCB_LIST_FILE { - uint32_t count; - PCB_LIST_BASE_ENTRY entry; - std::vector entries; + uint32_t count; + PCB_LIST_BASE_ENTRY entry; + std::vector entries; }; #endif \ No newline at end of file