1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 06:27:45 +00:00
This commit is contained in:
Mordred 2017-11-16 23:20:59 +01:00
commit 692f5fbf2f
15 changed files with 130 additions and 34 deletions

View file

@ -136,6 +136,7 @@ namespace Packets {
IPCTYPE_UNK_320 = 0x0207, // updated 4.1 IPCTYPE_UNK_320 = 0x0207, // updated 4.1
IPCTYPE_UNK_322 = 0x0209, // updated 4.1 IPCTYPE_UNK_322 = 0x0209, // updated 4.1
ActorGauge = 0x249
}; };
// TODO: Include structures for the individual packet segment types // TODO: Include structures for the individual packet segment types

View file

@ -1314,6 +1314,12 @@ struct FFXIVIpcMount : FFXIVIpcBasePacket<Mount>
}; };
struct FFXIVIpcActorGauge : FFXIVIpcBasePacket<ActorGauge>
{
uint8_t classJobId;
uint8_t data[15]; // depends on classJobId
};
} /* Server */ } /* Server */
} /* Packets */ } /* Packets */
} /* Network */ } /* Network */

View file

@ -18,6 +18,7 @@ set_target_properties(server_lobby PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${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_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
) )
if (UNIX) if (UNIX)

View file

@ -139,7 +139,7 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
serverListPacket.data().server[0].id = g_serverLobby.getConfig()->getValue<uint16_t>( "Settings.Parameters.WorldID", 1 ); serverListPacket.data().server[0].id = g_serverLobby.getConfig()->getValue<uint16_t>( "Settings.Parameters.WorldID", 1 );
serverListPacket.data().server[0].index = 0; serverListPacket.data().server[0].index = 0;
serverListPacket.data().final = 1; serverListPacket.data().final = 1;
sprintf( serverListPacket.data().server[0].name, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() ); strcpy( serverListPacket.data().server[0].name, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
pRP.addPacket( serverListPacket ); pRP.addPacket( serverListPacket );

View file

@ -17,12 +17,17 @@ set_target_properties(server_rest PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${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_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
) )
if (UNIX) if (UNIX)
target_link_libraries (server_rest Common xivdat pthread mysqlclient mysqlConnector dl z) target_link_libraries (server_rest Common xivdat pthread mysqlclient mysqlConnector dl z)
else() else()
# ignore unchecked iterators warnings from msvc
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
target_link_libraries (server_rest Common xivdat libmysql mysqlConnector zlib1) target_link_libraries (server_rest Common xivdat libmysql mysqlConnector zlib1)
endif() endif()
target_link_libraries( server_rest ${Boost_LIBRARIES} ${Boost_LIBRARIES} ) target_link_libraries( server_rest ${Boost_LIBRARIES} ${Boost_LIBRARIES} )

View file

@ -33,6 +33,7 @@ set_target_properties(server_zone PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${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_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
) )
if (UNIX) if (UNIX)

View file

@ -32,6 +32,8 @@
#include <Server_Common/Database/DatabaseDef.h> #include <Server_Common/Database/DatabaseDef.h>
#include <cinttypes>
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
extern Core::Logger g_log; extern Core::Logger g_log;
@ -256,7 +258,7 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
else if ( subCommand == "eorzeatime" ) else if ( subCommand == "eorzeatime" )
{ {
uint64_t timestamp; uint64_t timestamp;
sscanf( params.c_str(), "%llu", &timestamp ); sscanf( params.c_str(), "%" SCNu64, &timestamp );
pPlayer->setEorzeaTimeOffset( timestamp ); pPlayer->setEorzeaTimeOffset( timestamp );
pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) ); pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );

View file

@ -328,7 +328,11 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
fseek( fp, 0, SEEK_END ); fseek( fp, 0, SEEK_END );
int32_t size = ftell( fp ); int32_t size = ftell( fp );
rewind( fp ); rewind( fp );
fread( packet, sizeof( char ), size, fp ); if ( fread( packet, sizeof( char ), size, fp ) != size )
{
g_log.error( "Packet " + packetpath + " did not read full size: " + std::to_string( size ) );
return;
}
fclose( fp ); fclose( fp );
// cycle through the packet entries and queue each one // cycle through the packet entries and queue each one

View file

@ -333,7 +333,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() ); GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = param1; searchInfoPacket.data().onlineStatusFlags = param1;
searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion(); searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket ); targetPlayer->queuePacket( searchInfoPacket );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon, targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,

View file

@ -84,7 +84,7 @@ void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePac
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( pPlayer->getId() ); GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( pPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = status; searchInfoPacket.data().onlineStatusFlags = status;
searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion(); searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() );
queueOutPacket( searchInfoPacket ); queueOutPacket( searchInfoPacket );
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon, pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,
@ -98,7 +98,7 @@ void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePac
GamePacketNew< FFXIVIpcInitSearchInfo, ServerZoneIpcType > searchInfoPacket( pPlayer->getId() ); GamePacketNew< FFXIVIpcInitSearchInfo, ServerZoneIpcType > searchInfoPacket( pPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = pPlayer->getOnlineStatusMask(); searchInfoPacket.data().onlineStatusFlags = pPlayer->getOnlineStatusMask();
searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion(); searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() );
queueOutPacket( searchInfoPacket ); queueOutPacket( searchInfoPacket );
} }

View file

@ -51,7 +51,7 @@ private:
memset( &m_data.name[0], 0, sizeof( m_data.name ) ); memset( &m_data.name[0], 0, sizeof( m_data.name ) );
sprintf( &m_data.name[0], player->getName().c_str() ); strcpy( &m_data.name[0], player->getName().c_str() );
memcpy( m_data.aetheryte, player->getAetheryteArray(), sizeof ( m_data.aetheryte ) ); memcpy( m_data.aetheryte, player->getAetheryteArray(), sizeof ( m_data.aetheryte ) );

View file

@ -125,7 +125,7 @@ void Core::Session::update()
m_pZoneConnection->processOutQueue(); m_pZoneConnection->processOutQueue();
} }
if( m_pZoneConnection ) if( m_pChatConnection )
{ {
m_pChatConnection->processInQueue(); m_pChatConnection->processInQueue();
m_pChatConnection->processOutQueue(); m_pChatConnection->processOutQueue();

View file

@ -0,0 +1,24 @@
collision data exporter for sapphire
compile with STANDALONE defined to compile without boost and sapphire dependencies
usage:
- regular
- compile with root sapphire dir cmakelists
- sapphire/src/tools/bin/pcb_reader2 "<path/to/game/sqpack/ffxiv>" <territory>
- standalone
- compile main.cpp with STANDALONE defined in build arg
- download ffxivexplorer <http://ffxivexplorer.fragmenterworks.com/>
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/020000.dat
- ctrl click the following:
- `bg/ffxiv/[REGION]/common/collision`
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/common/collision/`
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/collision/`
- `bg/ffxiv/region/shared/[for_bg|for_hou]/`
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/ZONE/level/`
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/ZONE/collision/`
- `bgcommon/world/sys/shared/for_bg/`
and `File > Export Raw` to pcb_reader exe dir (common and shared files are optional but you will be missing a lot of objects if you skip them)
- note: at this time ffxivexplorer is still missing some hashes, though any tool which can export the exds should work fine
- main "" <territory>

View file

@ -1,21 +1,23 @@
#include <stdio.h> #include <stdio.h>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <iostream>
#include <chrono>
#include <fstream>
#include "pcb.h" #include "pcb.h"
#include "lgb.h" #include "lgb.h"
#include "sgb.h" #include "sgb.h"
#ifndef STANDALONE
#include <GameData.h> #include <GameData.h>
#include <File.h> #include <File.h>
#include <DatCat.h> #include <DatCat.h>
#include <ExdData.h> #include <ExdData.h>
#include <ExdCat.h> #include <ExdCat.h>
#include <Exd.h> #include <Exd.h>
//#include <boost/algorithm/string.hpp>
#include <iostream> #endif
#include <boost/algorithm/string.hpp>
#include <chrono>
using namespace std::chrono_literals; using namespace std::chrono_literals;
@ -86,7 +88,7 @@ std::string zoneNameToPath( const std::string& name )
char region = name[1]; char region = name[1];
char type = name[2]; char type = name[2];
char zone = name[3]; char zone = name[3];
static std::map<char, std::string> teriMap static std::map< char, std::string > teriMap
{ {
{ 'r', "roc" }, { 'r', "roc" },
{ 'w', "wil" }, { 'w', "wil" },
@ -98,7 +100,7 @@ std::string zoneNameToPath( const std::string& name )
{ 'z', "zon" } { 'z', "zon" }
}; };
static std::map<char, std::string> typeMap static std::map< char, std::string > typeMap
{ {
{ 'f', "fld" }, { 'f', "fld" },
{ 't', "twn" }, { 't', "twn" },
@ -117,6 +119,24 @@ std::string zoneNameToPath( const std::string& name )
return ret; return ret;
} }
void readFileToBuffer( const std::string& path, std::vector< char >& buf )
{
auto inFile = std::ifstream( path, std::ios::binary );
if( inFile.good() )
{
inFile.seekg( 0, inFile.end );
int32_t fileSize = inFile.tellg();
buf.resize( fileSize );
inFile.seekg( 0, inFile.beg );
inFile.read( &buf[0], fileSize );
inFile.close();
}
else
{
throw std::runtime_error( "Unable to open " + path );
}
}
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
auto startTime = std::chrono::system_clock::now(); auto startTime = std::chrono::system_clock::now();
@ -136,21 +156,35 @@ int main( int argc, char* argv[] )
try try
{ {
std::string listPcbPath( "bg/ffxiv/" + zonePath + "/collision/list.pcb" );
std::string bgLgbPath( "bg/ffxiv/" + zonePath + "/level/bg.lgb" );
std::string collisionFilePath( "bg/ffxiv/" + zonePath + "/collision/" );
std::vector< char > section;
std::vector< char > section1;
#ifndef STANDALONE
xiv::dat::GameData data1( gamePath ); xiv::dat::GameData data1( gamePath );
xiv::exd::ExdData eData( data1 ); xiv::exd::ExdData eData( data1 );
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( bgLgbPath );
auto section = test_file->access_data_sections().at( 0 ); section = test_file->access_data_sections().at( 0 );
int32_t list_offset = *(uint32_t*)&section[0x18];
int32_t size = *(uint32_t*)&section[4];
std::vector<std::string> stringList; auto test_file1 = data1.get_file( listPcbPath );
section1 = test_file1->access_data_sections().at( 0 );
#else
{
readFileToBuffer( bgLgbPath, section );
readFileToBuffer( listPcbPath, section1 );
}
#endif
int32_t list_offset = *( uint32_t* )&section[0x18];
int32_t size = *( uint32_t* )&section[4];
std::vector< std::string > stringList;
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/";
uint32_t offset1 = 0x20; uint32_t offset1 = 0x20;
for( ; ; ) for( ; ; )
{ {
@ -158,7 +192,7 @@ int main( int argc, char* argv[] )
uint16_t trId = *(uint16_t*)&section1[offset1]; uint16_t trId = *(uint16_t*)&section1[offset1];
char someString[200]; char someString[200];
sprintf( someString, "%str%04d.pcb", path.c_str(), trId ); sprintf( someString, "%str%04d.pcb", collisionFilePath.c_str(), trId );
stringList.push_back( std::string( someString ) ); stringList.push_back( std::string( someString ) );
//std::cout << someString << "\n"; //std::cout << someString << "\n";
offset1 += 0x20; offset1 += 0x20;
@ -191,18 +225,24 @@ int main( int argc, char* argv[] )
fp_out = fopen( ( zoneName + ".obj" ).c_str(), "ab+" ); fp_out = fopen( ( zoneName + ".obj" ).c_str(), "ab+" );
if( fp_out ) if( fp_out )
{ {
std::map<std::string, PCB_FILE> pcbFiles; std::map< std::string, PCB_FILE > pcbFiles;
std::map<std::string, SGB_FILE> sgbFiles; std::map< std::string, SGB_FILE > sgbFiles;
std::map<std::string, uint32_t> objCount; std::map< std::string, uint32_t > objCount;
auto loadPcbFile = [&]( const std::string& fileName ) -> bool auto loadPcbFile = [&]( const std::string& fileName ) -> bool
{ {
try try
{ {
char* dataSection = nullptr;
//std::cout << fileName << " "; //std::cout << fileName << " ";
#ifndef STANDALONE
auto file = data1.get_file( fileName ); auto file = data1.get_file( fileName );
auto sections = file->get_data_sections(); auto sections = file->get_data_sections();
auto dataSection = &sections.at( 0 )[0]; dataSection = &sections.at( 0 )[0];
#else
std::vector< char > buf;
readFileToBuffer( fileName, buf );
dataSection = &buf[0];
#endif
//std::cout << sections.size() << "\n"; //std::cout << sections.size() << "\n";
uint32_t offset = 0; uint32_t offset = 0;
@ -244,9 +284,17 @@ int main( int argc, char* argv[] )
SGB_FILE sgbFile; SGB_FILE sgbFile;
try try
{ {
char* dataSection = nullptr;
//std::cout << fileName << " ";
#ifndef STANDALONE
auto file = data1.get_file( fileName ); auto file = data1.get_file( fileName );
auto sections = file->get_data_sections(); auto sections = file->get_data_sections();
auto dataSection = &sections.at( 0 )[0]; dataSection = &sections.at( 0 )[0];
#else
std::vector< char > buf;
readFileToBuffer( fileName, buf );
dataSection = &buf[0];
#endif
sgbFile = SGB_FILE( &dataSection[0] ); sgbFile = SGB_FILE( &dataSection[0] );
sgbFiles.insert( std::make_pair( fileName, sgbFile ) ); sgbFiles.insert( std::make_pair( fileName, sgbFile ) );
return true; return true;
@ -356,8 +404,8 @@ int main( int argc, char* argv[] )
totalGroups++; totalGroups++;
for( const auto& pEntry : group.entries ) for( const auto& pEntry : group.entries )
{ {
auto pGimmick = dynamic_cast<LGB_GIMMICK_ENTRY*>( pEntry.get() ); auto pGimmick = dynamic_cast< LGB_GIMMICK_ENTRY* >( pEntry.get() );
auto pBgParts = dynamic_cast<LGB_BGPARTS_ENTRY*>( pEntry.get() ); auto pBgParts = dynamic_cast< LGB_BGPARTS_ENTRY* >( pEntry.get() );
std::string fileName( "" ); std::string fileName( "" );
fileName.resize( 256 ); fileName.resize( 256 );
@ -410,7 +458,7 @@ int main( int argc, char* argv[] )
{ {
for( const auto& pEntry : group.entries ) for( const auto& pEntry : group.entries )
{ {
auto pModel = dynamic_cast<SGB_MODEL_ENTRY*>( pEntry.get() ); auto pModel = dynamic_cast< SGB_MODEL_ENTRY* >( pEntry.get() );
fileName = pModel->collisionFileName; fileName = pModel->collisionFileName;
writeOutput( fileName, &pGimmick->header.scale, &pGimmick->header.rotation, &pGimmick->header.translation, pModel ); writeOutput( fileName, &pGimmick->header.scale, &pGimmick->header.rotation, &pGimmick->header.translation, pModel );
} }
@ -423,7 +471,7 @@ int main( int argc, char* argv[] )
std::cout << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n"; std::cout << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n";
} }
std::cout << "Finished exporting " << zoneName << " in " << std::cout << "Finished exporting " << zoneName << " in " <<
std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now() - startTime ).count() << " seconds\n"; std::chrono::duration_cast< std::chrono::seconds >( std::chrono::system_clock::now() - startTime ).count() << " seconds\n";
} }
catch( std::exception& e ) catch( std::exception& e )
{ {

View file

@ -303,7 +303,11 @@ int main()
outputFile1.write(&section[0], section.size()); outputFile1.write(&section[0], section.size());
outputFile1.close(); outputFile1.close();
std::string command= std::string("java -jar unluac_2015_06_13.jar ") + "generated/" + questInfo->name_intern + ".luab" + ">> " + "generated/" + questInfo->name_intern + ".lua"; std::string command= std::string("java -jar unluac_2015_06_13.jar ") + "generated/" + questInfo->name_intern + ".luab" + ">> " + "generated/" + questInfo->name_intern + ".lua";
system(command.c_str()); if ( system( command.c_str() ) == -1 )
{
g_log.error( "Error executing java command:\n" + command + "\nerrno: " + std::strerror( errno ) );
return errno;
}
for( ; ; ) for( ; ; )
{ {