mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Fixed datreader
This commit is contained in:
parent
dc46fea1b0
commit
ec0322ce36
10 changed files with 80 additions and 87 deletions
78
deps/datReader/Exd.cpp
vendored
78
deps/datReader/Exd.cpp
vendored
|
@ -52,18 +52,18 @@ namespace xiv
|
|||
_exh = i_exh;
|
||||
_files = i_files;
|
||||
|
||||
|
||||
// Iterates over all the files
|
||||
const uint32_t member_count = _exh->get_members().size();
|
||||
for ( auto &file_ptr : _files )
|
||||
{
|
||||
// Get a stream
|
||||
std::vector< char > dataCpy = file_ptr->get_data_sections().front();
|
||||
xiv::utils::stream::vectorwrapbuf<char> databuf(dataCpy);
|
||||
std::istream stream(&databuf);
|
||||
std::istringstream iss( std::string( dataCpy.begin(), dataCpy.end() ) );
|
||||
|
||||
// Extract the header and skip to the record indices
|
||||
auto exd_header = extract< ExdHeader >( stream );
|
||||
stream.seekg( 0x20 );
|
||||
auto exd_header = extract< ExdHeader >( iss );
|
||||
iss.seekg( 0x20 );
|
||||
|
||||
// Preallocate and extract the record_indices
|
||||
const uint32_t record_count = exd_header.index_size / sizeof( ExdRecordIndex );
|
||||
|
@ -71,7 +71,7 @@ namespace xiv
|
|||
record_indices.reserve( record_count );
|
||||
for ( uint32_t i = 0; i < record_count; ++i )
|
||||
{
|
||||
auto recordIndex = extract< ExdRecordIndex >( stream );
|
||||
auto recordIndex = extract< ExdRecordIndex >( iss );
|
||||
_idCache[recordIndex.id] = ExdCacheEntry{file_ptr, recordIndex.offset};
|
||||
}
|
||||
}
|
||||
|
@ -93,8 +93,7 @@ namespace xiv
|
|||
auto& file_ptr = cacheEntryIt->second.file;
|
||||
|
||||
std::vector< char > dataCpy = file_ptr->get_data_sections().front();
|
||||
xiv::utils::stream::vectorwrapbuf<char> databuf(dataCpy);
|
||||
std::istream stream(&databuf);
|
||||
std::istringstream iss( std::string( dataCpy.begin(), dataCpy.end() ) );
|
||||
|
||||
// Get the vector fields for the given record and preallocate it
|
||||
auto fields = _data[id];
|
||||
|
@ -104,7 +103,7 @@ namespace xiv
|
|||
{
|
||||
// Seek to the position of the member to extract.
|
||||
// 6 is because we have uint32_t/uint16_t at the start of each record
|
||||
stream.seekg( cacheEntryIt->second.offset + 6 + member_entry.offset );
|
||||
iss.seekg( cacheEntryIt->second.offset + 6 + member_entry.offset );
|
||||
|
||||
// Switch depending on the type to extract
|
||||
switch( member_entry.type )
|
||||
|
@ -113,53 +112,53 @@ namespace xiv
|
|||
// Extract the offset to the actual string
|
||||
// Seek to it then extract the actual string
|
||||
{
|
||||
auto string_offset = extract<uint32_t>( stream, "string_offset", false );
|
||||
stream.seekg( cacheEntryIt->second.offset + 6 + _exh->get_header().data_offset + string_offset );
|
||||
fields.emplace_back( utils::bparse::extract_cstring( stream, "string" ) );
|
||||
auto string_offset = extract<uint32_t>( iss, "string_offset", false );
|
||||
iss.seekg( cacheEntryIt->second.offset + 6 + _exh->get_header().data_offset + string_offset );
|
||||
fields.emplace_back( utils::bparse::extract_cstring( iss, "string" ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case DataType::boolean:
|
||||
fields.emplace_back( extract<bool>( stream, "bool" ) );
|
||||
fields.emplace_back( extract<bool>( iss, "bool" ) );
|
||||
break;
|
||||
|
||||
case DataType::int8:
|
||||
fields.emplace_back( extract<int8_t>( stream, "int8_t" ) );
|
||||
fields.emplace_back( extract<int8_t>( iss, "int8_t" ) );
|
||||
break;
|
||||
|
||||
case DataType::uint8:
|
||||
fields.emplace_back( extract<uint8_t>( stream, "uint8_t" ) );
|
||||
fields.emplace_back( extract<uint8_t>( iss, "uint8_t" ) );
|
||||
break;
|
||||
|
||||
case DataType::int16:
|
||||
fields.emplace_back( extract<int16_t>( stream, "int16_t", false ) );
|
||||
fields.emplace_back( extract<int16_t>( iss, "int16_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::uint16:
|
||||
fields.emplace_back( extract<uint16_t>( stream, "uint16_t", false ) );
|
||||
fields.emplace_back( extract<uint16_t>( iss, "uint16_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::int32:
|
||||
fields.emplace_back( extract<int32_t>( stream, "int32_t", false ) );
|
||||
fields.emplace_back( extract<int32_t>( iss, "int32_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::uint32:
|
||||
fields.emplace_back( extract<uint32_t>( stream, "uint32_t", false ) );
|
||||
fields.emplace_back( extract<uint32_t>( iss, "uint32_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::float32:
|
||||
fields.emplace_back( extract<float>( stream, "float", false ) );
|
||||
fields.emplace_back( extract<float>( iss, "float", false ) );
|
||||
break;
|
||||
|
||||
case DataType::uint64:
|
||||
fields.emplace_back( extract<uint64_t>( stream, "uint64_t", false ) );
|
||||
fields.emplace_back( extract<uint64_t>( iss, "uint64_t", false ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
auto type = static_cast< uint16_t >( member_entry.type );
|
||||
if( type < 0x19 || type > 0x20 )
|
||||
throw std::runtime_error("Unknown DataType: " + std::to_string( type ));
|
||||
uint64_t val = extract< uint64_t >( stream, "bool" );
|
||||
uint64_t val = extract< uint64_t >( iss, "bool" );
|
||||
int32_t shift = type - 0x19;
|
||||
int32_t i = 1 << shift;
|
||||
val &= i;
|
||||
|
@ -180,12 +179,11 @@ namespace xiv
|
|||
{
|
||||
// Get a stream
|
||||
std::vector< char > dataCpy = file_ptr->get_data_sections().front();
|
||||
xiv::utils::stream::vectorwrapbuf<char> databuf(dataCpy);
|
||||
std::istream stream(&databuf);
|
||||
std::istringstream iss( std::string( dataCpy.begin(), dataCpy.end() ) );
|
||||
|
||||
// Extract the header and skip to the record indices
|
||||
auto exd_header = extract<ExdHeader>( stream );
|
||||
stream.seekg( 0x20 );
|
||||
auto exd_header = extract<ExdHeader>( iss );
|
||||
iss.seekg( 0x20 );
|
||||
|
||||
// Preallocate and extract the record_indices
|
||||
const uint32_t record_count = exd_header.index_size / sizeof( ExdRecordIndex );
|
||||
|
@ -193,7 +191,7 @@ namespace xiv
|
|||
record_indices.reserve( record_count );
|
||||
for( uint32_t i = 0; i < record_count; ++i )
|
||||
{
|
||||
record_indices.emplace_back( extract<ExdRecordIndex>( stream ) );
|
||||
record_indices.emplace_back( extract<ExdRecordIndex>( iss ) );
|
||||
}
|
||||
|
||||
for( auto& record_index : record_indices )
|
||||
|
@ -207,7 +205,7 @@ namespace xiv
|
|||
{
|
||||
// Seek to the position of the member to extract.
|
||||
// 6 is because we have uint32_t/uint16_t at the start of each record
|
||||
stream.seekg( record_index.offset + 6 + member_entry.offset );
|
||||
iss.seekg( record_index.offset + 6 + member_entry.offset );
|
||||
|
||||
// Switch depending on the type to extract
|
||||
switch( member_entry.type )
|
||||
|
@ -216,53 +214,53 @@ namespace xiv
|
|||
// Extract the offset to the actual string
|
||||
// Seek to it then extract the actual string
|
||||
{
|
||||
auto string_offset = extract<uint32_t>( stream, "string_offset", false );
|
||||
stream.seekg( record_index.offset + 6 + _exh->get_header().data_offset + string_offset );
|
||||
fields.emplace_back( utils::bparse::extract_cstring( stream, "string" ) );
|
||||
auto string_offset = extract<uint32_t>( iss, "string_offset", false );
|
||||
iss.seekg( record_index.offset + 6 + _exh->get_header().data_offset + string_offset );
|
||||
fields.emplace_back( utils::bparse::extract_cstring( iss, "string" ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case DataType::boolean:
|
||||
fields.emplace_back( extract<bool>( stream, "bool" ) );
|
||||
fields.emplace_back( extract<bool>( iss, "bool" ) );
|
||||
break;
|
||||
|
||||
case DataType::int8:
|
||||
fields.emplace_back( extract<int8_t>( stream, "int8_t" ) );
|
||||
fields.emplace_back( extract<int8_t>( iss, "int8_t" ) );
|
||||
break;
|
||||
|
||||
case DataType::uint8:
|
||||
fields.emplace_back( extract<uint8_t>( stream, "uint8_t" ) );
|
||||
fields.emplace_back( extract<uint8_t>( iss, "uint8_t" ) );
|
||||
break;
|
||||
|
||||
case DataType::int16:
|
||||
fields.emplace_back( extract<int16_t>( stream, "int16_t", false ) );
|
||||
fields.emplace_back( extract<int16_t>( iss, "int16_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::uint16:
|
||||
fields.emplace_back( extract<uint16_t>( stream, "uint16_t", false ) );
|
||||
fields.emplace_back( extract<uint16_t>( iss, "uint16_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::int32:
|
||||
fields.emplace_back( extract<int32_t>( stream, "int32_t", false ) );
|
||||
fields.emplace_back( extract<int32_t>( iss, "int32_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::uint32:
|
||||
fields.emplace_back( extract<uint32_t>( stream, "uint32_t", false ) );
|
||||
fields.emplace_back( extract<uint32_t>( iss, "uint32_t", false ) );
|
||||
break;
|
||||
|
||||
case DataType::float32:
|
||||
fields.emplace_back( extract<float>( stream, "float", false ) );
|
||||
fields.emplace_back( extract<float>( iss, "float", false ) );
|
||||
break;
|
||||
|
||||
case DataType::uint64:
|
||||
fields.emplace_back( extract<uint64_t>( stream, "uint64_t", false ) );
|
||||
fields.emplace_back( extract<uint64_t>( iss, "uint64_t", false ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
auto type = static_cast< uint16_t >( member_entry.type );
|
||||
if( type < 0x19 || type > 0x20 )
|
||||
throw std::runtime_error("Unknown DataType: " + std::to_string( type ));
|
||||
uint64_t val = extract< uint64_t >( stream, "bool" );
|
||||
uint64_t val = extract< uint64_t >( iss, "bool" );
|
||||
int32_t shift = type - 0x19;
|
||||
int32_t i = 1 << shift;
|
||||
val &= i;
|
||||
|
|
4
deps/datReader/ExdCat.cpp
vendored
4
deps/datReader/ExdCat.cpp
vendored
|
@ -28,11 +28,11 @@ namespace xiv
|
|||
_name(i_name)
|
||||
{
|
||||
//XIV_INFO(xiv_exd_logger, "Initializing Cat with name: " << i_name);
|
||||
|
||||
// creates the header .exh
|
||||
{
|
||||
auto header_file = i_game_data.getFile("exd/" + i_name + ".exh");
|
||||
_header = std::shared_ptr<Exh>(new Exh(*header_file));
|
||||
_header = std::shared_ptr< Exh >( new Exh( *header_file ) );
|
||||
|
||||
}
|
||||
|
||||
for(auto language: _header->get_languages())
|
||||
|
|
1
deps/datReader/ExdData.cpp
vendored
1
deps/datReader/ExdData.cpp
vendored
|
@ -23,7 +23,6 @@ ExdData::ExdData(dat::GameData& i_game_data) try :
|
|||
xiv::utils::stream::vectorwrapbuf<char> databuf(dataCpy);
|
||||
std::istream stream(&databuf);
|
||||
|
||||
|
||||
// Iterates over the lines while skipping the first one
|
||||
std::string line;
|
||||
std::getline(stream, line); // extract first line EXLT,2
|
||||
|
|
16
deps/datReader/Exh.cpp
vendored
16
deps/datReader/Exh.cpp
vendored
|
@ -3,6 +3,7 @@
|
|||
#include "stream.h"
|
||||
|
||||
#include "File.h"
|
||||
#include <sstream>
|
||||
|
||||
using xiv::utils::bparse::extract;
|
||||
|
||||
|
@ -10,38 +11,37 @@ namespace xiv
|
|||
{
|
||||
namespace exd
|
||||
{
|
||||
|
||||
Exh::Exh(const dat::File& i_file)
|
||||
{
|
||||
// Get a stream from the file
|
||||
std::vector< char > dataCpy = i_file.get_data_sections().front();
|
||||
xiv::utils::stream::vectorwrapbuf<char> databuf(dataCpy);
|
||||
std::istream stream(&databuf);
|
||||
std::istringstream iss( std::string( dataCpy.begin(), dataCpy.end() ) );
|
||||
|
||||
// Extract header and skip to member definitions
|
||||
_header = extract<ExhHeader>(stream);
|
||||
stream.seekg(0x20);
|
||||
_header = extract<ExhHeader>(iss);
|
||||
iss.seekg(0x20);
|
||||
|
||||
// Extract all the members and feed the _members map
|
||||
for (auto i = 0; i < _header.field_count; ++i)
|
||||
{
|
||||
auto member = extract<ExhMember>(stream);
|
||||
auto member = extract<ExhMember>(iss);
|
||||
_members[member.offset] = member;
|
||||
_exh_defs.push_back( member );
|
||||
std::cout << "member_offset: " << member.offset << "\n";
|
||||
}
|
||||
|
||||
// Extract all the exd_defs
|
||||
_exd_defs.reserve(_header.exd_count);
|
||||
for (auto i = 0; i < _header.exd_count; ++i)
|
||||
{
|
||||
_exd_defs.emplace_back(extract<ExhExdDef>(stream));
|
||||
_exd_defs.emplace_back(extract<ExhExdDef>(iss));
|
||||
}
|
||||
|
||||
// Extract all the languages
|
||||
_languages.reserve(_header.language_count);
|
||||
for (auto i = 0; i < _header.language_count; ++i)
|
||||
{
|
||||
_languages.emplace_back(Language(extract<uint16_t>(stream, "language")));
|
||||
_languages.emplace_back(Language(extract<uint16_t>(iss, "language")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
deps/datReader/GameData.cpp
vendored
2
deps/datReader/GameData.cpp
vendored
|
@ -57,7 +57,7 @@ GameData::GameData(const std::experimental::filesystem::path& path) try :
|
|||
m_path(path)
|
||||
{
|
||||
int maxExLevel = 0;
|
||||
|
||||
|
||||
// Determine which expansions are available
|
||||
while( std::experimental::filesystem::exists( std::experimental::filesystem::path( m_path.string() + "\\ex" + std::to_string( maxExLevel + 1) + "\\ex" + std::to_string( maxExLevel + 1) + ".ver" ) ) )
|
||||
{
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
cmake_minimum_required(VERSION 3.0.2)
|
||||
cmake_policy(SET CMP0015 NEW)
|
||||
project(Sapphire)
|
||||
cmake_minimum_required( VERSION 3.0.2 )
|
||||
cmake_policy( SET CMP0015 NEW )
|
||||
project( Sapphire )
|
||||
|
||||
file(GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
||||
file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*")
|
||||
file( GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*" )
|
||||
file( GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*" )
|
||||
|
||||
|
||||
add_executable(sapphire_lobby ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES})
|
||||
add_executable( sapphire_lobby ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES} )
|
||||
|
||||
set_target_properties(sapphire_lobby PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS ON
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
)
|
||||
set_target_properties( sapphire_lobby
|
||||
PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS ON
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
|
||||
)
|
||||
|
||||
target_link_libraries( sapphire_lobby PRIVATE common )
|
||||
target_link_libraries( sapphire_lobby
|
||||
PRIVATE
|
||||
common
|
||||
stdc++fs )
|
||||
|
||||
cotire( sapphire_lobby )
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
#include <Forwards.h>
|
||||
|
||||
#include <thread>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
Core::Logger g_log;
|
||||
Core::Network::RestConnector g_restConnector;
|
||||
|
@ -76,9 +73,13 @@ void ServerLobby::run( int32_t argc, char* argv[] )
|
|||
"Lobby server running on " + m_pConfig->getValue< std::string >( "LobbyNetwork.ListenIp", "0.0.0.0" ) + ":" +
|
||||
m_pConfig->getValue< std::string >( "LobbyNetwork.ListenPort", "80" ) );
|
||||
|
||||
boost::thread_group worker_threads;
|
||||
worker_threads.create_thread( boost::bind( &Network::Hive::Run, hive.get() ) );
|
||||
worker_threads.join_all();
|
||||
std::vector< std::thread > threadGroup;
|
||||
|
||||
threadGroup.emplace_back( std::bind( &Network::Hive::Run, hive.get() ) );
|
||||
|
||||
for( auto& thread : threadGroup )
|
||||
if( thread.joinable() )
|
||||
thread.join();
|
||||
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,7 @@ bool ServerLobby::loadSettings( int32_t argc, char* argv[] )
|
|||
|
||||
try
|
||||
{
|
||||
arg = boost::to_lower_copy( std::string( args[ i ] ) );
|
||||
std::transform( arg.begin(), arg.end(), arg.begin(), [](unsigned char c){ return std::tolower( c ); } );
|
||||
val = std::string( args[ i + 1 ] );
|
||||
|
||||
// trim '-' from start of arg
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef CLIENT_HTTP_HPP
|
||||
#define CLIENT_HTTP_HPP
|
||||
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
|
@ -68,7 +67,7 @@ namespace SimpleWeb {
|
|||
/// Set before calling request
|
||||
Config config;
|
||||
|
||||
std::shared_ptr<Response> request( const std::string& request_type, const std::string& path = "/", boost::string_ref content = "",
|
||||
std::shared_ptr<Response> request( const std::string& request_type, const std::string& path = "/", std::string_view content = "",
|
||||
const std::map<std::string, std::string>& header = std::map<std::string, std::string>() ) {
|
||||
auto corrected_path = path;
|
||||
if( corrected_path == "" )
|
||||
|
|
|
@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.6)
|
|||
cmake_policy(SET CMP0015 NEW)
|
||||
project(Tool_ExdStructTest)
|
||||
|
||||
set(SAPPHIRE_BOOST_VER 1.63.0)
|
||||
set(SAPPHIRE_BOOST_FOLDER_NAME boost_1_63_0)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin/")
|
||||
|
||||
|
||||
|
@ -24,10 +22,8 @@ set_target_properties(exd_struct_test PROPERTIES
|
|||
)
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries (exd_struct_test common xivdat pthread mysqlclient dl z)
|
||||
target_link_libraries (exd_struct_test common xivdat pthread mysqlclient dl z stdc++fs )
|
||||
else()
|
||||
target_link_libraries (exd_struct_test common xivdat libmysql zlib1)
|
||||
endif()
|
||||
|
||||
target_link_libraries(exd_struct_test ${Boost_LIBRARIES} ${Boost_LIBRARIES})
|
||||
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
#include <set>
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Logging/Logger.h>
|
||||
#include <boost/range/algorithm/remove_if.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <streambuf>
|
||||
|
|
Loading…
Add table
Reference in a new issue