mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
const all the things for readability
- removed .mdl collision loading since game doesnt use it fixed style issues in pcb_reader
This commit is contained in:
parent
06271dd669
commit
a90fd345dc
6 changed files with 60 additions and 58 deletions
|
@ -6,17 +6,19 @@ before_install:
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
- sudo apt-get install -y software-properties-common
|
- sudo apt-get install -y software-properties-common
|
||||||
- sudo apt-get update
|
- 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 libboost-dev libboost-all-dev libmysqlclient-dev -y
|
||||||
- sudo apt-get install libmysqlcppconn-dev -y
|
- sudo apt-get install libmysqlcppconn-dev -y
|
||||||
|
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- g++
|
||||||
|
|
||||||
|
|
||||||
# Build steps
|
# Build steps
|
||||||
script:
|
script:
|
||||||
|
- g++ --version
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd 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 ..
|
- cd ..
|
||||||
- bash sql_import.sh
|
- bash sql_import.sh
|
||||||
|
|
|
@ -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})
|
add_executable(pcb_reader2 ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES})
|
||||||
|
|
||||||
set_target_properties(pcb_reader2 PROPERTIES
|
set_target_properties(pcb_reader2 PROPERTIES
|
||||||
CXX_STANDARD 17
|
CXX_STANDARD 14
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS ON
|
CXX_EXTENSIONS ON
|
||||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/"
|
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/"
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
#ifndef _LGB_H
|
#ifndef _LGB_H
|
||||||
#define _LGB_H
|
#define _LGB_H
|
||||||
|
|
||||||
#include "matrix4.h"
|
#include <cstring>
|
||||||
#include "vec3.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <experimental/filesystem>
|
#include <string>
|
||||||
|
|
||||||
|
#include "matrix4.h"
|
||||||
|
#include "vec3.h"
|
||||||
|
|
||||||
// all credit to
|
// all credit to
|
||||||
// https://github.com/ufx/SaintCoinach/blob/master/SaintCoinach/Graphics/Lgb/
|
// https://github.com/ufx/SaintCoinach/blob/master/SaintCoinach/Graphics/Lgb/
|
||||||
|
@ -171,14 +173,14 @@ struct LGB_GROUP
|
||||||
name = std::string( buf + offset + header.groupNameOffset );
|
name = std::string( buf + offset + header.groupNameOffset );
|
||||||
//entries.resize( header.entryCount );
|
//entries.resize( header.entryCount );
|
||||||
//std::cout << name << std::endl;
|
//std::cout << name << std::endl;
|
||||||
auto entriesOffset = offset + header.entriesOffset;
|
const auto entriesOffset = offset + header.entriesOffset;
|
||||||
for( auto i = 0; i < header.entryCount; ++i )
|
for( auto i = 0; i < header.entryCount; ++i )
|
||||||
{
|
{
|
||||||
auto entryOffset = entriesOffset + *reinterpret_cast<int32_t*>(buf + (entriesOffset + i * 4));
|
const auto entryOffset = entriesOffset + *reinterpret_cast<int32_t*>( buf + ( entriesOffset + i * 4 ) );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto type = *reinterpret_cast<LgbEntryType*>(buf + entryOffset);
|
const auto type = *reinterpret_cast<LgbEntryType*>( buf + entryOffset );
|
||||||
if( type == LgbEntryType::BgParts )
|
if( type == LgbEntryType::BgParts )
|
||||||
{
|
{
|
||||||
entries.push_back( std::make_shared<LGB_BGPARTS_ENTRY>( buf, entryOffset ) );
|
entries.push_back( std::make_shared<LGB_BGPARTS_ENTRY>( buf, entryOffset ) );
|
||||||
|
@ -224,20 +226,23 @@ struct LGB_FILE
|
||||||
{
|
{
|
||||||
header = *reinterpret_cast<LGB_FILE_HEADER*>( buf );
|
header = *reinterpret_cast<LGB_FILE_HEADER*>( buf );
|
||||||
if( strncmp( &header.magic[0], "LGB1", 4 ) != 0 || strncmp( &header.magic2[0], "LGP1", 4 ) != 0 )
|
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);
|
//groups.resize(header.groupCount);
|
||||||
|
|
||||||
auto baseOffset = sizeof( header );
|
constexpr auto baseOffset = sizeof( header );
|
||||||
for( auto i = 0; i < header.groupCount; ++i )
|
for( auto i = 0; i < header.groupCount; ++i )
|
||||||
{
|
{
|
||||||
auto groupOffset = baseOffset + *reinterpret_cast<int32_t*>(buf + (baseOffset + i * 4));
|
const auto groupOffset = baseOffset + *reinterpret_cast<int32_t*>( buf + ( baseOffset + i * 4 ) );
|
||||||
auto group = LGB_GROUP( buf, this, groupOffset );
|
const auto group = LGB_GROUP( buf, this, groupOffset );
|
||||||
groups.push_back( group );
|
groups.push_back( group );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
#include <experimental/filesystem>
|
||||||
std::map<std::string, LGB_FILE> getLgbFiles( const std::string& dir )
|
std::map<std::string, LGB_FILE> getLgbFiles( const std::string& dir )
|
||||||
{
|
{
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
|
@ -246,10 +251,10 @@ std::map<std::string, LGB_FILE> getLgbFiles( const std::string& dir )
|
||||||
{
|
{
|
||||||
if( path.path().extension() == ".lgb" )
|
if( path.path().extension() == ".lgb" )
|
||||||
{
|
{
|
||||||
auto strPath = path.path().string();
|
const auto& strPath = path.path().string();
|
||||||
auto f = fopen( strPath.c_str(), "rb" );
|
auto f = fopen( strPath.c_str(), "rb" );
|
||||||
fseek( f, 0, SEEK_END );
|
fseek( f, 0, SEEK_END );
|
||||||
auto size = ftell( f );
|
const auto size = ftell( f );
|
||||||
std::vector<char> bytes( size );
|
std::vector<char> bytes( size );
|
||||||
rewind( f );
|
rewind( f );
|
||||||
fread( bytes.data(), 1, size, f );
|
fread( bytes.data(), 1, size, f );
|
||||||
|
@ -268,3 +273,5 @@ std::map<std::string, LGB_FILE> getLgbFiles( const std::string& dir )
|
||||||
return fileMap;
|
return fileMap;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <experimental/filesystem>
|
|
||||||
|
|
||||||
#include "pcb.h"
|
#include "pcb.h"
|
||||||
#include "lgb.h"
|
#include "lgb.h"
|
||||||
|
@ -18,7 +17,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
namespace fs = std::experimental::filesystem;
|
|
||||||
struct face
|
struct face
|
||||||
{
|
{
|
||||||
int32_t f1, f2, f3;
|
int32_t f1, f2, f3;
|
||||||
|
@ -141,15 +140,15 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
const xiv::dat::Cat& test = data1.get_category( "bg" );
|
const xiv::dat::Cat& test = data1.get_category( "bg" );
|
||||||
|
|
||||||
auto &test_file = data1.get_file( "bg/ffxiv/" + zonePath + "/level/bg.lgb" );
|
auto test_file = data1.get_file( "bg/ffxiv/" + zonePath + "/level/bg.lgb" );
|
||||||
auto §ion = test_file->access_data_sections().at( 0 );
|
auto section = test_file->access_data_sections().at( 0 );
|
||||||
int32_t list_offset = *(uint32_t*)§ion[0x18];
|
int32_t list_offset = *(uint32_t*)§ion[0x18];
|
||||||
int32_t size = *(uint32_t*)§ion[4];
|
int32_t size = *(uint32_t*)§ion[4];
|
||||||
|
|
||||||
std::vector<std::string> stringList;
|
std::vector<std::string> stringList;
|
||||||
|
|
||||||
auto &test_file1 = data1.get_file( "bg/ffxiv/" + zonePath + "/collision/list.pcb" );
|
auto test_file1 = data1.get_file( "bg/ffxiv/" + zonePath + "/collision/list.pcb" );
|
||||||
auto §ion1 = test_file1->access_data_sections().at( 0 );
|
auto section1 = test_file1->access_data_sections().at( 0 );
|
||||||
std::string path = "bg/ffxiv/" + zonePath + "/collision/";
|
std::string path = "bg/ffxiv/" + zonePath + "/collision/";
|
||||||
int offset1 = 0x20;
|
int offset1 = 0x20;
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
|
@ -191,7 +190,7 @@ int main( int argc, char* argv[] )
|
||||||
std::string errorMessage( "Cannot create " + zoneName + ".obj\n" +
|
std::string errorMessage( "Cannot create " + zoneName + ".obj\n" +
|
||||||
" Check no programs have a handle to file and run as admin.\n" );
|
" Check no programs have a handle to file and run as admin.\n" );
|
||||||
std::cout << errorMessage;
|
std::cout << errorMessage;
|
||||||
throw std::exception( errorMessage.c_str() );
|
throw std::runtime_error( errorMessage.c_str() );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +211,6 @@ int main( int argc, char* argv[] )
|
||||||
//std::cout << sections.size() << "\n";
|
//std::cout << sections.size() << "\n";
|
||||||
|
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
uint32_t groupCount = 0;
|
|
||||||
PCB_FILE pcb_file;
|
PCB_FILE pcb_file;
|
||||||
memcpy( &pcb_file.header, &dataSection[0], sizeof( pcb_file.header ) );
|
memcpy( &pcb_file.header, &dataSection[0], sizeof( pcb_file.header ) );
|
||||||
offset += 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 );
|
parseBlockEntry( &dataSection[0] + offset, pcb_file.entries, offset );
|
||||||
}
|
}
|
||||||
groupCount++;
|
|
||||||
}
|
}
|
||||||
pcbFiles.insert( std::make_pair( fileName, pcb_file ) );
|
pcbFiles.insert( std::make_pair( fileName, pcb_file ) );
|
||||||
}
|
}
|
||||||
|
@ -249,7 +246,7 @@ int main( int argc, char* argv[] )
|
||||||
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() );
|
fprintf( fp_out, "o %s\n", name2.c_str() );
|
||||||
uint32_t groupCount = 0;
|
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 x_base = abs( float( entry.header.x1 - entry.header.x ) );
|
||||||
float y_base = abs( float( entry.header.y1 - entry.header.y ) );
|
float y_base = abs( float( entry.header.y1 - entry.header.y ) );
|
||||||
|
@ -324,20 +321,17 @@ int main( int argc, char* argv[] )
|
||||||
totalGroups++;
|
totalGroups++;
|
||||||
for( const auto pEntry : group.entries )
|
for( const auto pEntry : group.entries )
|
||||||
{
|
{
|
||||||
auto pBgParts = dynamic_cast<LGB_BGPARTS_ENTRY*>(pEntry.get());
|
auto pBgParts = static_cast<LGB_BGPARTS_ENTRY*>( pEntry.get() );
|
||||||
|
|
||||||
auto& fileName = pBgParts->collisionFileName;
|
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;
|
continue;
|
||||||
|
|
||||||
|
{
|
||||||
|
//boost::replace_all( fileName, "bgparts", "collision" );
|
||||||
|
//boost::replace_all( fileName, ".mdl", ".pcb" );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto& it = pcbFiles.find( fileName );
|
const auto& it = pcbFiles.find( fileName );
|
||||||
if( it == pcbFiles.end() )
|
if( it == pcbFiles.end() )
|
||||||
|
@ -351,8 +345,6 @@ int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
totalGroupEntries++;
|
totalGroupEntries++;
|
||||||
|
|
||||||
//std::cout << pBgParts->collisionFileName << "\n";
|
|
||||||
|
|
||||||
const auto* scale = &pBgParts->header.scale;
|
const auto* scale = &pBgParts->header.scale;
|
||||||
const auto* rotation = &pBgParts->header.rotation;
|
const auto* rotation = &pBgParts->header.rotation;
|
||||||
const auto* translation = &pBgParts->header.translation;
|
const auto* translation = &pBgParts->header.translation;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _MATRIX4_H
|
#define _MATRIX4_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
// https://github.com/jpd002/Play--Framework/tree/master/include/math
|
// https://github.com/jpd002/Play--Framework/tree/master/include/math
|
||||||
struct matrix4
|
struct matrix4
|
||||||
|
|
Loading…
Add table
Reference in a new issue