1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Merge pull request #306 from NotAdam/develop

remove xmlconfig and implement new configmgr
This commit is contained in:
Mordred 2018-06-11 09:49:09 +02:00 committed by GitHub
commit cb2e45a5a4
71 changed files with 4055 additions and 1193 deletions

View file

@ -17,25 +17,7 @@ Sapphire requires the following software:
| Boost 1.63.0 | [Win32 precompiled binaries](https://sourceforge.net/projects/boost/files/boost-binaries/1.63.0/boost_1_63_0-msvc-14.0-32.exe/download) | Boost libraries from your distribution's package manager | | Boost 1.63.0 | [Win32 precompiled binaries](https://sourceforge.net/projects/boost/files/boost-binaries/1.63.0/boost_1_63_0-msvc-14.0-32.exe/download) | Boost libraries from your distribution's package manager |
| MySQL Server 5.7 | [Official Site](https://dev.mysql.com/downloads/mysql/) | MySQL server from your distribution's package manager | | MySQL Server 5.7 | [Official Site](https://dev.mysql.com/downloads/mysql/) | MySQL server from your distribution's package manager |
**Windows** Please check the [wiki](https://github.com/SapphireMordred/Sapphire/wiki) for detailed installation/build instructions for your OS.
Set the environment variables ``BOOST_ROOT_DIR`` and ``BOOST_LIB_DIR`` to ``[boost main folder]`` and ``[boost main folder]/lib32-msvc-14.0`` respectively **or** copy your boost installation into the project's ``src/lib`` folder.
Visual Studio 2017 users: open `Visual Studio Installer` and ensure `Individual Components > SDKs, libraries, and frameworks > Windows Universal C Runtime` is installed. You may also need to install `Individual Components > Compilers, build tools, and runtimes > VC++ 2015.3 v140 toolset for desktop (x86, 64)`.
To enable [Edit and Continue](https://msdn.microsoft.com/en-us/library/esaeyddf.aspx) ensure you define `-DCMAKE_BUILD_TYPE="Debug"` when generating with CMake.
If you installed CMake outside of Visual Studio and have it in your `PATH` environment variable, navigate to Sapphire folder and `cmake -DCMAKE_BUILD_TYPE="Debug" && cmake --build .`.
Otherwise:
* In *Visual Studio 2017*: Open the project via ``File`` > ``Open`` > ``Folder`` and wait, till CMake automatically finishes cache generation. Right click any CMakeLists.txt and select build to build a application.
To configure debug startup parameters, select ``Debug and Launch settings``, the application you want to set up parameters for, and add a ``args`` json array containing your launch parameters in ``configurations``.
If Visual Studio fails to generate a CMake Cache or does not show options to build, make sure that the newest version of it is installed and all environment variables are set correctly. Keep in mind that generating a cache can take a while on some machines.
The solution `Sapphire.sln` is also generated in the main Sapphire folder.
**Linux**
`cmake . -DSAPPHIRE_BOOST_VER="your.boost.ver" && make -j JOBS` where `JOBS` is number of cores on your system.
`-j JOBS` can be omitted if your system lacks resources (spoiler: your system probably lacks resources if running on 1GB RAM or lower, or if the build fails due to being out of memory)
## Links ## Links

View file

@ -0,0 +1,22 @@
[Database]
Host = 127.0.0.1
Port = 3306
Database = sapphire
Username = sapphire
Password =
SyncThreads = 2
AsyncThreads = 2
[GlobalParameters]
ServerSecret = default
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
[GlobalNetwork]
ZoneHost = 127.0.0.1
ZonePort = 54992
LobbyHost = 127.0.0.1
LobbyPort = 54994
RestHost = 127.0.0.1
RestPort = 80

View file

@ -0,0 +1,4 @@
[Lobby]
WorldID = 67
AllowNoSessionConnect = false
WorldName = Sapphire

View file

@ -0,0 +1,2 @@
[CharacterCreation]
DefaultGMRank = 255

View file

@ -1,34 +0,0 @@
<Settings>
<General>
<!-- Port the lobby server accepts client connections on -->
<ListenPort>54994</ListenPort>
<AuthPort>54998</AuthPort>
<!-- Ip the lobby server listens on -->
<ListenIp>127.0.0.1</ListenIp>
<!-- IP of the world server -->
<ZoneIp>127.0.0.1</ZoneIp>
<!-- Port the world server listens for clients -->
<ZonePort>54992</ZonePort>
<!-- Address to connect to the rest server -->
<RestHost>127.0.0.1:80</RestHost>
<!-- Secret for server authentication -->
<ServerSecret>default</ServerSecret>
<!-- Connection settings for the mysql db -->
<Mysql>
<Host>127.0.0.1</Host>
<Port>3306</Port>
<Username>root</Username>
<Pass></Pass>
<Database>sapphire</Database>
</Mysql>
</General>
<Parameters>
<!-- Do not disconnect players without a session - this should be definitely disabled unless you are testing on a PS4 -->
<AllowNoSessionConnect>false</AllowNoSessionConnect>
<!-- The ID of the Sapphire world - this is what the game determines your datacenter with, check world.exh -->
<WorldID>67</WorldID>
<!-- The name of the world -->
<!-- TODO: Allow multiple world servers -->
<WorldName>Sapphire</WorldName>
</Parameters>
</Settings>

View file

@ -1,32 +0,0 @@
<Settings>
<General>
<!-- Port the lobby server accepts client connections on -->
<ListenPort>54994</ListenPort>
<AuthPort>54998</AuthPort>
<!-- Ip the lobby server listens on -->
<ListenIp>127.0.0.1</ListenIp>
<!-- Path of FFXIV dat files -->
<DataPath>C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack</DataPath>
<!-- <DataPath>/opt/sapphire_3_15_0/bin/sqpack</DataPath> -->
<!-- IP of the lobby server -->
<LobbyHost>127.0.0.1</LobbyHost>
<!-- IP of the frontier server -->
<FrontierHost>127.0.0.1</FrontierHost>
<!-- Secret used for server auth - you *must* change this for public servers -->
<ServerSecret>default</ServerSecret>
<!-- Web server port -->
<HttpPort>80</HttpPort>
<Mysql>
<Host>127.0.0.1</Host>
<Port>3306</Port>
<Username>root</Username>
<Pass></Pass>
<Database>sapphire</Database>
</Mysql>
</General>
<Parameters>
<!-- GM Rank for newly created characters - should be changed to 0 for public servers -->
<DefaultGMRank>255</DefaultGMRank>
</Parameters>
</Settings>

View file

@ -1,45 +0,0 @@
<Settings>
<General>
<!-- Port the zone server accepts game conenctions on -->
<ListenPort>54992</ListenPort>
<!-- Ip the zone server conenctions on -->
<ListenIp>127.0.0.1</ListenIp>
<!-- Path of FFXIV dat files -->
<DataPath>C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack</DataPath>
<Scripts>
<!-- where compiled scripts are placed -->
<Path>./compiledscripts/</Path>
<CachePath>./cache/</CachePath>
<HotSwap>
<Enabled>true</Enabled>
<ScriptsDir>../scripts/native/</ScriptsDir>
<BuildDir>../cmake-build-debug/</BuildDir>
<BuildCmd>cmake --build %1% --target %2%</BuildCmd>
</HotSwap>
</Scripts>
<!-- Path of Chai script files -->
<ScriptPath>./compiledscripts/</ScriptPath>
<!-- Connection settings for the mysql db -->
<Mysql>
<Host>127.0.0.1</Host>
<Port>3306</Port>
<Username>root</Username>
<Pass></Pass>
<Database>sapphire</Database>
<SyncThreads>2</SyncThreads>
<AsyncThreads>2</AsyncThreads>
</Mysql>
</General>
<Parameters>
<!-- Messages players see upon logging in - These *must* be smaller than 307 characters -->
<MotDArray>
<MotD>&lt;&lt;&lt;Welcome to Sapphire&gt;&gt;&gt;</MotD>
<MotD>This is a very good server</MotD>
<MotD>You can change these messages by editing MotDArray in config/settings_zone.xml</MotD>
</MotDArray>
</Parameters>
</Settings>

View file

@ -0,0 +1,14 @@
[Scripts]
; where compiled script modules are located
Path = ./compiledscripts/
; relative to Path, where we copy and load modules from
CachePath = ./cache/
; whether we should detect changes to script modules and reload them
HotSwap = true
[Network]
DisconnectTimeout = 20
[General]
; Sent on login - each line must be shorter than 307 characters, split lines with ';'
MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/zone.ini

View file

@ -553,6 +553,7 @@ namespace Common {
AetherReductionDlg = 0x17D, AetherReductionDlg = 0x17D,
Unk6 = 0x19C, Unk6 = 0x19C,
EObjAnimation = 0x19D,
SetTitle = 0x1F4, SetTitle = 0x1F4,
@ -562,6 +563,7 @@ namespace Common {
SetFavorite = 0x1FC, SetFavorite = 0x1FC,
LearnTeleport = 0x1FD, LearnTeleport = 0x1FD,
OpenRecommendationGuide = 0x200,
ArmoryErrorMsg = 0x201, ArmoryErrorMsg = 0x201,
AchievementPopup = 0x203, AchievementPopup = 0x203,

View file

@ -0,0 +1,66 @@
#include "ConfigMgr.h"
#include <boost/property_tree/ini_parser.hpp>
#include <boost/filesystem.hpp>
/**
* Loads an ini file and parses it
* @param configName the name of ini file relative to m_configFolderRoot to load alongside global.ini
* @return true if loading was successful
*/
bool Core::ConfigMgr::loadConfig( const std::string& configName )
{
std::stringstream configStream;
// get global config
auto configDir = boost::filesystem::path( m_configFolderRoot );
if( !boost::filesystem::exists( configDir ) )
{
return false;
}
auto globalConfig = boost::filesystem::path( configDir / m_globalConfigFile );
if( !boost::filesystem::exists( globalConfig ) )
{
if( !copyDefaultConfig( globalConfig.filename().string() ) )
return false;
}
std::ifstream globalConfigFile( globalConfig.c_str() );
configStream << globalConfigFile.rdbuf();
// add some newlines just in case there's no newline at the end of the global file
configStream << "\n\n";
// get local config
auto localConfig = boost::filesystem::path( configDir / configName );
if( !boost::filesystem::exists( localConfig ) )
{
if( !copyDefaultConfig( localConfig.filename().string() ) )
return false;
}
std::ifstream configFile( localConfig.c_str() );
configStream << configFile.rdbuf();
// parse the tree and we're fuckin done
boost::property_tree::read_ini( configStream, m_propTree );
return true;
}
bool Core::ConfigMgr::copyDefaultConfig( const std::string& configName )
{
boost::filesystem::path configPath( m_configFolderRoot );
configPath /= configName;
if( !boost::filesystem::exists( configPath.string() + m_configDefaultSuffix ) )
{
// no default file :(
return false;
}
boost::filesystem::copy_file( configPath.string() + m_configDefaultSuffix, configPath );
return true;
}

View file

@ -0,0 +1,45 @@
#ifndef SAPPHIRE_CONFIGMGR_H
#define SAPPHIRE_CONFIGMGR_H
#include <boost/property_tree/ptree.hpp>
namespace Core
{
class ConfigMgr
{
public:
ConfigMgr() = default;
~ConfigMgr() = default;
bool loadConfig( const std::string& configName );
template< class T >
T getValue( const std::string& name, T defaultValue = T() )
{
try
{
return m_propTree.get< T >( name );
}
catch( ... )
{
return defaultValue;
}
}
template< class T >
void setValue( const std::string& name, T defaultValue = T() )
{
m_propTree.put( name, defaultValue );
}
private:
bool copyDefaultConfig( const std::string& configName );
boost::property_tree::ptree m_propTree;
const std::string m_globalConfigFile = "global.ini";
const std::string m_configFolderRoot = "./config/";
const std::string m_configDefaultSuffix = ".default";
};
}
#endif //SAPPHIRE_CONFIGMGR_H

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -6,9 +6,9 @@
namespace Core namespace Core
{ {
class XMLConfig; class ConfigMgr;
typedef boost::shared_ptr<XMLConfig> XMLConfigPtr; typedef boost::shared_ptr< ConfigMgr > ConfigMgrPtr;
namespace Network namespace Network

View file

@ -1,6 +1,3 @@
/**
* Structural definitions common to all FFXIV:ARR packets.
*/
#ifndef _CORE_NETWORK_PACKETS_COMMON_H #ifndef _CORE_NETWORK_PACKETS_COMMON_H
#define _CORE_NETWORK_PACKETS_COMMON_H #define _CORE_NETWORK_PACKETS_COMMON_H
@ -46,6 +43,8 @@ namespace Packets {
* *
* 0 4 8 12 14 16 * 0 4 8 12 14 16
* +-------------------------------+---------------+-------+-------+ * +-------------------------------+---------------+-------+-------+
* | unknown_0 | unknown_8 |
* +-------------------------------+---------------+-------+-------+
* | timestamp | size | cType | count | * | timestamp | size | cType | count |
* +---+---+-------+---------------+---------------+-------+-------+ * +---+---+-------+---------------+---------------+-------+-------+
* | ? |CMP| ? | ? | * | ? |CMP| ? | ? |
@ -54,13 +53,10 @@ namespace Packets {
*/ */
struct FFXIVARR_PACKET_HEADER struct FFXIVARR_PACKET_HEADER
{ {
/** Unknown data, no actual use has been determined */
uint64_t unknown_0; uint64_t unknown_0;
uint64_t unknown_8; uint64_t unknown_8;
/** /** Represents the number of milliseconds since epoch that the packet was sent. */
* Represents the number of milliseconds since epoch that the packet was
* sent.
*/
uint64_t timestamp; uint64_t timestamp;
/** The size of the packet header and its payload */ /** The size of the packet header and its payload */
uint32_t size; uint32_t size;
@ -92,7 +88,7 @@ inline istream& operator>>(istream& is, FFXIVARR_PACKET_HEADER& hdr)
* *
* 0 4 8 12 16 * 0 4 8 12 16
* +---------------+---------------+---------------+-------+-------+ * +---------------+---------------+---------------+-------+-------+
* | size | source_actor | target_actor | type | ? | * | size | source_actor | target_actor | type | pad |
* +---------------+---------------+---------------+-------+-------+ * +---------------+---------------+---------------+-------+-------+
* | | * | |
* : type-specific data of length, size, follows : * : type-specific data of length, size, follows :
@ -109,7 +105,7 @@ struct FFXIVARR_PACKET_SEGMENT_HEADER
uint32_t target_actor; uint32_t target_actor;
/** The segment type. (1, 2, 3, 7, 8, 9, 10) */ /** The segment type. (1, 2, 3, 7, 8, 9, 10) */
uint16_t type; uint16_t type;
uint16_t _reserved_E; uint16_t padding;
}; };
inline ostream& operator << ( ostream& os, const FFXIVARR_PACKET_SEGMENT_HEADER& hdr ) inline ostream& operator << ( ostream& os, const FFXIVARR_PACKET_SEGMENT_HEADER& hdr )
@ -122,8 +118,6 @@ inline istream& operator>>(istream& is, FFXIVARR_PACKET_SEGMENT_HEADER& hdr)
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr ); return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
} }
// TODO: Include structures for the individual packet segment types
template < int T > struct FFXIVIpcBasePacket template < int T > struct FFXIVIpcBasePacket
{ {
/** Creates a constant representing the IPC type */ /** Creates a constant representing the IPC type */
@ -142,7 +136,7 @@ struct FFXIVARR_PACKET_RAW
* *
* 0 4 6 8 12 16 * 0 4 6 8 12 16
* +-------+-------+------+----------+---------------+---------------+ * +-------+-------+------+----------+---------------+---------------+
* | 14 00 | type | ?? | serverId | timestamp | ??? | * | 14 00 | type | pad | serverId | timestamp | pad1 |
* +-------+-------+------+----------+---------------+---------------+ * +-------+-------+------+----------+---------------+---------------+
* | | * | |
* : data : * : data :
@ -153,10 +147,10 @@ struct FFXIVARR_IPC_HEADER
{ {
uint16_t reserved; uint16_t reserved;
uint16_t type; uint16_t type;
uint16_t unknown_2; uint16_t padding;
uint16_t serverId; uint16_t serverId;
uint32_t timestamp; uint32_t timestamp;
uint32_t unknown_C; uint32_t padding1;
}; };
inline ostream& operator << ( ostream& os, const FFXIVARR_IPC_HEADER& hdr ) inline ostream& operator << ( ostream& os, const FFXIVARR_IPC_HEADER& hdr )
@ -169,8 +163,6 @@ inline istream& operator>>(istream& is, FFXIVARR_IPC_HEADER& hdr)
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr ); return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
} }
} /* Packets */ } /* Packets */
} /* Network */ } /* Network */
} /* Core */ } /* Core */

View file

@ -7,23 +7,24 @@
#include <boost/format.hpp> #include <boost/format.hpp>
#include "Util/Util.h" #include "Util/Util.h"
Core::Network::Packets::GamePacket::GamePacket( uint16_t subType, uint16_t size, uint32_t id1, uint32_t id2, uint16_t type ) Core::Network::Packets::GamePacket::GamePacket( uint16_t subType, uint16_t size,
uint32_t id1, uint32_t id2, uint16_t type )
{ {
m_dataBuf = std::vector< uint8_t >( size ); m_dataBuf = std::vector< uint8_t >( size );
memset( &m_segHdr, 0, sizeof( m_segHdr ) ); memset( &m_segHdr, 0, sizeof( m_segHdr ) );
setHeader( size, type, id1, id2, subType, 0x00 ); setHeader( size, type, id1, id2, subType, 0x00 );
} }
void Core::Network::Packets::GamePacket::setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown ) void Core::Network::Packets::GamePacket::setHeader( uint16_t size, uint16_t type, uint32_t id1,
uint32_t id2, uint16_t subType, uint32_t unknown )
{ {
m_segHdr.size = size; m_segHdr.size = size;
m_segHdr.type = type; m_segHdr.type = type;
m_segHdr.source_actor = id1; m_segHdr.source_actor = id1;
m_segHdr.target_actor = id2; m_segHdr.target_actor = id2;
m_segHdr._reserved_E = 0x00; //m_segHdr._reserved_E = 0x00;
m_subType = subType; m_subType = subType;
m_timeStamp = static_cast< uint32_t >( time( nullptr ) ); m_timeStamp = static_cast< uint32_t >( time( nullptr ) );
@ -67,7 +68,10 @@ Core::Network::Packets::GamePacket::GamePacket( const Packets::FFXIVARR_PACKET_R
m_segHdr = packetData.segHdr; m_segHdr = packetData.segHdr;
m_dataBuf = std::vector< uint8_t >( m_segHdr.size ); m_dataBuf = std::vector< uint8_t >( m_segHdr.size );
memcpy( &m_dataBuf[0] + sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ), &packetData.data[0], m_segHdr.size - sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ) ); memcpy( &m_dataBuf[0] + sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ),
&packetData.data[0],
m_segHdr.size - sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ) );
memcpy( &m_dataBuf[0], &m_segHdr, sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ) ); memcpy( &m_dataBuf[0], &m_segHdr, sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ) );
m_subType = *reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x12 ); m_subType = *reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x12 );
@ -88,7 +92,7 @@ Core::Network::Packets::GamePacket::~GamePacket()
void Core::Network::Packets::GamePacket::savePacket() void Core::Network::Packets::GamePacket::savePacket()
{ {
char filename[20]; char filename[20];
sprintf( filename, "dump_0x%x.dat", m_subType ); sprintf( filename, "dump_0x%x_%li.dat", m_subType, Util::getTimeMs() );
FILE* fp = nullptr; FILE* fp = nullptr;
fp = fopen( filename, "wb" ); fp = fopen( filename, "wb" );
fwrite( &m_dataBuf[0], 1, m_segHdr.size, fp ); fwrite( &m_dataBuf[0], 1, m_segHdr.size, fp );

View file

@ -32,15 +32,15 @@ using ChatChannelPacket = GamePacketNew< T, ServerChatIpcType >;
* The base implementation of a game packet. Needed for parsing packets. * The base implementation of a game packet. Needed for parsing packets.
*/ */
template < typename T1 > template < typename T1 >
class GamePacketNewBase class FFXIVIpcPacketBase
{ {
public: public:
virtual ~GamePacketNewBase() = default; virtual ~FFXIVIpcPacketBase() = default;
/** /**
* @brief Gets the IPC type of this packet. (Useful for determining the * @brief Gets the IPC type of this packet. (Useful for determining the
* type of a parsed packet.) * type of a parsed packet.)
*/ */
virtual T1 ipcType( void ) = 0; virtual T1 ipcType() = 0;
}; };
/** /**
@ -50,7 +50,7 @@ public:
* 32 byte header information.) * 32 byte header information.)
*/ */
template < typename T, typename T1 > template < typename T, typename T1 >
class GamePacketNew : public GamePacketNewBase<T1> class GamePacketNew : public FFXIVIpcPacketBase< T1 >
{ {
public: public:
/** /**
@ -96,7 +96,7 @@ protected:
}; };
public: public:
virtual T1 ipcType( void ) virtual T1 ipcType()
{ {
return static_cast< T1 >( m_data._ServerIpcType ); return static_cast< T1 >( m_data._ServerIpcType );
}; };

View file

@ -5,14 +5,7 @@
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
namespace Core PacketParseResult Core::Network::Packets::getHeader( const std::vector< uint8_t > &buffer,
{
namespace Network
{
namespace Packets
{
PacketParseResult getHeader(
const std::vector< uint8_t > &buffer,
const uint32_t offset, const uint32_t offset,
FFXIVARR_PACKET_HEADER &header ) FFXIVARR_PACKET_HEADER &header )
{ {
@ -21,23 +14,18 @@ namespace Core
// Check if we have enough bytes in the buffer. // Check if we have enough bytes in the buffer.
auto remainingBytes = buffer.size() - offset; auto remainingBytes = buffer.size() - offset;
if( remainingBytes < headerSize ) if( remainingBytes < headerSize )
{
return Incomplete; return Incomplete;
}
// Copy packet header. // Copy packet header.
memcpy( &header, buffer.data() + offset, headerSize ); memcpy( &header, buffer.data() + offset, headerSize );
if( !checkHeader(header) ) if( !checkHeader(header) )
{
return Malformed; return Malformed;
}
return Success; return Success;
} }
PacketParseResult getSegmentHeader( PacketParseResult Core::Network::Packets::getSegmentHeader( const std::vector< uint8_t > &buffer,
const std::vector< uint8_t > &buffer,
const uint32_t offset, const uint32_t offset,
FFXIVARR_PACKET_SEGMENT_HEADER &header ) FFXIVARR_PACKET_SEGMENT_HEADER &header )
{ {
@ -46,9 +34,7 @@ namespace Core
// Check if we have enough bytes in the buffer. // Check if we have enough bytes in the buffer.
auto remainingBytes = buffer.size() - offset; auto remainingBytes = buffer.size() - offset;
if( remainingBytes < headerSize ) if( remainingBytes < headerSize )
{
return Incomplete; return Incomplete;
}
// Copy segment header // Copy segment header
memcpy( &header, buffer.data() + offset, headerSize ); memcpy( &header, buffer.data() + offset, headerSize );
@ -56,8 +42,7 @@ namespace Core
return Success; return Success;
} }
PacketParseResult getPackets( PacketParseResult Core::Network::Packets::getPackets( const std::vector< uint8_t > &buffer,
const std::vector< uint8_t > &buffer,
const uint32_t offset, const uint32_t offset,
const FFXIVARR_PACKET_HEADER &packetHeader, const FFXIVARR_PACKET_HEADER &packetHeader,
std::vector< FFXIVARR_PACKET_RAW > &packets ) std::vector< FFXIVARR_PACKET_RAW > &packets )
@ -65,9 +50,7 @@ namespace Core
// sanity check: check there's enough bytes in the buffer // sanity check: check there's enough bytes in the buffer
const auto bytesExpected = packetHeader.size - sizeof( struct FFXIVARR_PACKET_HEADER ); const auto bytesExpected = packetHeader.size - sizeof( struct FFXIVARR_PACKET_HEADER );
if( buffer.size() - offset < bytesExpected ) if( buffer.size() - offset < bytesExpected )
{
return Incomplete; return Incomplete;
}
// Loop each message // Loop each message
uint32_t count = 0; uint32_t count = 0;
@ -79,9 +62,7 @@ namespace Core
// Copy ipc packet message // Copy ipc packet message
const auto packetResult = getPacket( buffer, offset + bytesProcessed, rawPacket ); const auto packetResult = getPacket( buffer, offset + bytesProcessed, rawPacket );
if( packetResult != Success ) if( packetResult != Success )
{
return packetResult; return packetResult;
}
// NOTE: isn't rawPacket is allocated on stack? // NOTE: isn't rawPacket is allocated on stack?
// why is okay to do this? // why is okay to do this?
@ -95,31 +76,22 @@ namespace Core
// sanity check: check if we processed all bytes. // sanity check: check if we processed all bytes.
// this check can fail if size of messages don't add up to size reported from packet header. // this check can fail if size of messages don't add up to size reported from packet header.
if( bytesExpected != bytesProcessed ) if( bytesExpected != bytesProcessed )
{
return Malformed; return Malformed;
}
return Success; return Success;
} }
PacketParseResult getPacket( PacketParseResult Core::Network::Packets::getPacket( const std::vector< uint8_t > &buffer, const uint32_t offset,
const std::vector< uint8_t > &buffer, FFXIVARR_PACKET_RAW &packet )
const uint32_t offset,
FFXIVARR_PACKET_RAW &packet
)
{ {
// Copy segment header // Copy segment header
const auto headerResult = getSegmentHeader( buffer, offset, packet.segHdr ); const auto headerResult = getSegmentHeader( buffer, offset, packet.segHdr );
if( headerResult != Success ) if( headerResult != Success )
{
return headerResult; return headerResult;
}
// Check header sanity and it's size // Check header sanity and it's size
if( !checkSegmentHeader( packet.segHdr ) ) if( !checkSegmentHeader( packet.segHdr ) )
{
return Malformed; return Malformed;
}
const auto dataOffset = offset + sizeof( struct FFXIVARR_PACKET_SEGMENT_HEADER ); const auto dataOffset = offset + sizeof( struct FFXIVARR_PACKET_SEGMENT_HEADER );
const auto dataSize = packet.segHdr.size; const auto dataSize = packet.segHdr.size;
@ -131,33 +103,24 @@ namespace Core
return Success; return Success;
} }
bool checkHeader(const FFXIVARR_PACKET_HEADER &header) bool Core::Network::Packets::checkHeader( const FFXIVARR_PACKET_HEADER &header )
{ {
// Max size of the packet is capped at 1MB for now. // Max size of the packet is capped at 1MB for now.
if( header.size > 1 * 1024 * 1024 ) if( header.size > 1 * 1024 * 1024 )
{
return false; return false;
}
// Max number of message is capped at 255 for now. // Max number of message is capped at 255 for now.
if( header.count > 255 ) if( header.count > 255 )
{
return false; return false;
}
return true; return true;
} }
bool checkSegmentHeader(const FFXIVARR_PACKET_SEGMENT_HEADER &header) bool Core::Network::Packets::checkSegmentHeader( const FFXIVARR_PACKET_SEGMENT_HEADER &header )
{ {
// Max size of individual message is capped at 256KB for now. // Max size of individual message is capped at 256KB for now.
if( header.size > 256 * 1024 ) if( header.size > 256 * 1024 )
{
return false; return false;
}
return true; return true;
} }
}
}
}

View file

@ -2,12 +2,10 @@
#define _GAMEPACKETPARSER_H #define _GAMEPACKETPARSER_H
#include "CommonNetwork.h" #include "CommonNetwork.h"
namespace Core namespace Core {
{ namespace Network {
namespace Network namespace Packets {
{
namespace Packets
{
enum PacketParseResult enum PacketParseResult
{ {
/// Dissected game packet successfully /// Dissected game packet successfully
@ -22,36 +20,25 @@ namespace Core
/// Read packet header from buffer with given offset. /// Read packet header from buffer with given offset.
/// Buffer with given offset must be pointing to start of the new FFXIV packet. /// Buffer with given offset must be pointing to start of the new FFXIV packet.
PacketParseResult getHeader( PacketParseResult getHeader( const std::vector< uint8_t > &buffer, const uint32_t offset,
const std::vector< uint8_t > &buffer, FFXIVARR_PACKET_HEADER &header );
const uint32_t offset,
FFXIVARR_PACKET_HEADER &header
);
/// Read packet header from buffer with given offset. /// Read packet header from buffer with given offset.
/// Buffer with given offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data. /// Buffer with given offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data.
/// Keep in mind that this function does check for data validity. Call checkSegmentHeader() if that's needed. /// Keep in mind that this function does check for data validity. Call checkSegmentHeader() if that's needed.
PacketParseResult getSegmentHeader( PacketParseResult getSegmentHeader( const std::vector< uint8_t > &buffer, const uint32_t offset,
const std::vector< uint8_t > &buffer, FFXIVARR_PACKET_SEGMENT_HEADER &header );
const uint32_t offset,
FFXIVARR_PACKET_SEGMENT_HEADER &header
);
/// Read packets from the buffer with given offset. /// Read packets from the buffer with given offset.
/// Buffer with given offset must be pointing to end of FFXIVARR_PACKET_HEADER data. /// Buffer with given offset must be pointing to end of FFXIVARR_PACKET_HEADER data.
PacketParseResult getPackets( PacketParseResult getPackets( const std::vector< uint8_t > &buffer, const uint32_t offset,
const std::vector< uint8_t > &buffer,
const uint32_t offset,
const FFXIVARR_PACKET_HEADER &header, const FFXIVARR_PACKET_HEADER &header,
std::vector< Packets::FFXIVARR_PACKET_RAW > &packets ); std::vector< Packets::FFXIVARR_PACKET_RAW > &packets );
/// Read single packet from the buffer with given offset. /// Read single packet from the buffer with given offset.
/// Buffer with an offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data. /// Buffer with an offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data.
PacketParseResult getPacket( PacketParseResult getPacket( const std::vector< uint8_t > &buffer, const uint32_t offset,
const std::vector< uint8_t > &buffer, FFXIVARR_PACKET_RAW &packet );
const uint32_t offset,
FFXIVARR_PACKET_RAW &packet
);
bool checkHeader(const FFXIVARR_PACKET_HEADER &header); bool checkHeader(const FFXIVARR_PACKET_HEADER &header);
bool checkSegmentHeader(const FFXIVARR_PACKET_SEGMENT_HEADER &header); bool checkSegmentHeader(const FFXIVARR_PACKET_SEGMENT_HEADER &header);

View file

@ -7,14 +7,14 @@
#include <chrono> #include <chrono>
Core::Network::Packets::PacketContainer::PacketContainer( void ) Core::Network::Packets::PacketContainer::PacketContainer()
{ {
memset( &m_ipcHdr, 0, sizeof( FFXIVARR_PACKET_HEADER ) ); memset( &m_ipcHdr, 0, sizeof( FFXIVARR_PACKET_HEADER ) );
m_ipcHdr.size = sizeof( FFXIVARR_PACKET_HEADER ); m_ipcHdr.size = sizeof( FFXIVARR_PACKET_HEADER );
m_ipcHdr.count = 0; m_ipcHdr.count = 0;
} }
Core::Network::Packets::PacketContainer::~PacketContainer( void ) Core::Network::Packets::PacketContainer::~PacketContainer()
{ {
m_entryList.clear(); m_entryList.clear();
} }

View file

@ -16,8 +16,8 @@ class GamePacket;
class PacketContainer class PacketContainer
{ {
public: public:
PacketContainer( void ); PacketContainer();
~PacketContainer( void ); ~PacketContainer();
void addPacket( GamePacket pEntry ); void addPacket( GamePacket pEntry );

View file

@ -45,11 +45,10 @@ namespace Packets {
enum ServerZoneIpcType : uint16_t enum ServerZoneIpcType : uint16_t
{ {
// static opcode ( the ones that rarely if ever change ) // static opcode ( the ones that rarely, if ever, change )
Ping = 0x0065, Ping = 0x0065,
Init = 0x0066, Init = 0x0066,
ActorSpawn = 0x0190, // DEPRECATED
ActorFreeSpawn = 0x0191, ActorFreeSpawn = 0x0191,
InitZone = 0x019A, InitZone = 0x019A,
@ -62,7 +61,7 @@ namespace Packets {
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
ChatBanned = 0x006B, ChatBanned = 0x006B,
Logout = 0x0077, Logout = 0x0077, // updated 4.3
CFNotify = 0x0078, CFNotify = 0x0078,
CFMemberStatus = 0x0079, CFMemberStatus = 0x0079,
CFDutyInfo = 0x007A, CFDutyInfo = 0x007A,
@ -74,118 +73,126 @@ namespace Packets {
CFRegistered = 0x00B8, // updated 4.1 CFRegistered = 0x00B8, // updated 4.1
SocialRequestResponse = 0x00BB, // updated 4.1 SocialRequestResponse = 0x00BB, // updated 4.1
CancelAllianceForming = 0x00C6, // updated 4.2 CancelAllianceForming = 0x00C6, // updated 4.2
Chat = 0x00E1, // updated 4.2
SocialList = 0x00E7, // updated 4.2
UpdateSearchInfo = 0x00EA, // updated 4.2 Chat = 0x00F7, // updated 4.3
InitSearchInfo = 0x00EB, // updated 4.2 SocialList = 0x00FD, // updated 4.3
ServerNotice = 0x00F0, // updated 4.2 UpdateSearchInfo = 0x0100, // updated 4.3
SetOnlineStatus = 0x00F1, // updated 4.2 InitSearchInfo = 0x0101, // updated 4.3
CountdownInitiate = 0x00FB, // updated 4.2 ServerNotice = 0x0106, // updated 4.3
CountdownCancel = 0x00FC, // updated 4.2 SetOnlineStatus = 0x0107, // updated 4.3
BlackList = 0x00FF, // updated 4.2 CountdownInitiate = 0x0111, // updated 4.3
CountdownCancel = 0x0112, // updated 4.3
BlackList = 0x0115, // updated 4.3
LogMessage = 0x00D0, LogMessage = 0x00D0,
LinkshellList = 0x0106, // updated 4.2 LinkshellList = 0x011C, // updated 4.3
SetCharacterFCInfo = 0x0114, // updated 4.2 SetCharaFCTag = 0x013B, // updated 4.3
StatusEffectList = 0x0125, // updated 4.2 SetFreeCompanyInfo = 0x013D, // updated 4.3
Effect = 0x0128, // updated 4.2
PersistantEffect = 0x013B, // updated 4.2 StatusEffectList = 0x014E, // updated 4.3
Effect = 0x0151, // updated 4.3
PersistantEffect = 0x0158, // updated 4.3
GCAffiliation = 0xCCFC, // OUTDATED GCAffiliation = 0xCCFC, // OUTDATED
PlayerSpawn = 0x015C, // updated 4.2 PlayerSpawn = 0x0172, // updated 4.3
NpcSpawn = 0x015D, // updated 4.2 NpcSpawn = 0x0173, // updated 4.3
ActorMove = 0x015E, // updated 4.2 ActorMove = 0x0174, // updated 4.3
ActorSetPos = 0x0160, // updated 4.2 ActorSetPos = 0x0176, // updated 4.3
ActorCast = 0x0162, // updated 4.2 ActorCast = 0x0178, // updated 4.3
HateList = 0x0165, // updated 4.2 PartyList = 0x017A, // updated 4.3
HateList = 0x017B, // updated 4.3
ObjectSpawn = 0x0167, // updated 4.2 ObjectSpawn = 0x017D, // updated 4.3
ObjectDespawn = 0x0168, // updated 4.2 ObjectDespawn = 0x017E, // updated 4.3
UpdateClassInfo = 0x0169, // updated 4.2
InitUI = 0x016B, // updated 4.2 SetLevelSync = 0x017F, // updated 4.3
PlayerStats = 0x016C, // updated 4.2
ActorOwner = 0x016D, // updated 4.2 ?
PlayerStateFlags = 0x016E, // updated 4.2
PlayerClassInfo = 0x016F, // updated 4.2
ModelEquip = 0x0170, // updated 4.2
ItemInfo = 0x017A, // updated 4.2
ContainerInfo = 0x017B, // updated 4.2
InventoryTransactionFinish = 0x017C, // updated 4.2
InventoryTransaction = 0x017D, // updated 4.2
CurrencyCrystalInfo = 0x017E, // updated 4.2
InventoryActionAck = 0x0180, // updated 4.2 ? InventoryActionAck = 0x0180, // updated 4.2 ?
UpdateInventorySlot = 0x0181, // updated 4.2
EventPlay = 0x018E, // updated 4.2 InitUI = 0x0181, // updated 4.3
DirectorPlayScene = 0x0192, // updated 4.2 PlayerStats = 0x0182, // updated 4.3
ActorOwner = 0x0183, // updated 4.3 ?
PlayerStateFlags = 0x0184, // updated 4.3
PlayerClassInfo = 0x0185, // updated 4.3
ModelEquip = 0x0186, // updated 4.3
EventStart = 0x0198, // updated 4.2 UpdateClassInfo = 0x018A, // updated 4.3
EventFinish = 0x0199, // updated 4.2
ItemInfo = 0x0190, // updated 4.3
ContainerInfo = 0x0192, // updated 4.3
InventoryTransactionFinish = 0x0193, // updated 4.3
InventoryTransaction = 0x0194, // updated 4.3
CurrencyCrystalInfo = 0x0197, // updated 4.3
UpdateInventorySlot = 0x0198, // updated 4.3
EventPlay = 0x01A6, // updated 4.3
DirectorPlayScene = 0x01AA, // updated 4.3
EventStart = 0x01AF, // updated 4.3
EventFinish = 0x01B0, // updated 4.3
EventLinkshell = 0x1169, EventLinkshell = 0x1169,
QuestMessage = 0x01B8, // updated 4.2 QuestActiveList = 0x01C3, // updated 4.3
QuestTracker = 0x01BD, // updated 4.2 QuestUpdate = 0x01C4, // updated 4.3
QuestCompleteList = 0x01C5, // updated 4.3
QuestFinish = 0x01B0, // updated 4.2 QuestFinish = 0x01C6, // updated 4.3
MSQTrackerComplete = 0x01B1, // updated 4.2 MSQTrackerComplete = 0x01C7, // updated 4.3
MSQTrackerProgress = 0x01B2, // updated 4.2 MSQTrackerProgress = 0x01C8, // updated 4.3
QuestActiveList = 0x01AD, // updated 4.2 QuestMessage = 0x01CE, // updated 4.3
QuestUpdate = 0x01AE, // updated 4.2 QuestTracker = 0x01D3, // updated 4.3
QuestCompleteList = 0x01AF, // updated 4.2
Mount = 0x01CD, // updated 4.2 Mount = 0x01E3, // updated 4.3
DirectorVars = 0x01CF, // updated 4.2 DirectorVars = 0x01E5, // updated 4.3
WeatherChange = 0x01EA, // updated 4.2
PlayerTitleList = 0x01EB, // updated 4.2
Discovery = 0x01EC, // updated 4.2
EorzeaTimeOffset = 0x01EE, // updated 4.2
EquipDisplayFlags = 0x01FA, // updated 4.2
CFAvailableContents = 0x01FD, // updated 4.2 CFAvailableContents = 0x01FD, // updated 4.2
PrepareZoning = 0x027C, // updated 4.2 WeatherChange = 0x0200, // updated 4.3
ActorGauge = 0x027D, // updated 4.2 PlayerTitleList = 0x0201, // updated 4.3
Discovery = 0x0202, // updated 4.3
EorzeaTimeOffset = 0x0204, // updated 4.3
EquipDisplayFlags = 0x0210, // updated 4.3
DuelChallenge = 0x0277, // 4.2; this is responsible for opening the ui
PerformNote = 0x0286, // updated 4.3
PrepareZoning = 0x0291, // updated 4.3
ActorGauge = 0x0292, // updated 4.3
DuelChallenge = 0x0277, // 4.2; this is the responsible for opening an ui
PerformNote = 0x0286, // updated 4.2
// Unknown IPC types that still need to be sent // Unknown IPC types that still need to be sent
// TODO: figure all these out properly // TODO: figure all these out properly
IPCTYPE_UNK_320 = 0x0235, // updated 4.2 IPCTYPE_UNK_320 = 0x024C, // updated 4.3
IPCTYPE_UNK_322 = 0x0237, // updated 4.2 IPCTYPE_UNK_322 = 0x024E, // updated 4.3
}; };
// TODO: Include structures for the individual packet segment types
/** /**
* Client IPC Zone Type Codes. * Client IPC Zone Type Codes.
*/ */
enum ClientZoneIpcType : uint16_t enum ClientZoneIpcType : uint16_t
{ {
PingHandler = 0x0065, // unchanged 4.2 PingHandler = 0x0065, // unchanged 4.3
InitHandler = 0x0066, // unchanged 4.2 InitHandler = 0x0066, // unchanged 4.3
FinishLoadingHandler = 0x0069, // unchanged 4.2 FinishLoadingHandler = 0x0069, // unchanged 4.3
CFCommenceHandler = 0x006F, CFCommenceHandler = 0x006F,
@ -193,23 +200,24 @@ namespace Packets {
CFRegisterDuty = 0x0071, CFRegisterDuty = 0x0071,
CFRegisterRoulette = 0x0072, CFRegisterRoulette = 0x0072,
PlayTimeHandler = 0x0073, // unchanged 4.2 PlayTimeHandler = 0x0073, // unchanged 4.3
LogoutHandler = 0x0074, // unchanged 4.2 LogoutHandler = 0x0074, // unchanged 4.3
CFDutyInfoHandler = 0x0078, // updated 4.2 CFDutyInfoHandler = 0x0078, // updated 4.2
SocialReqSendHandler = 0x00AE, // updated 4.1 SocialReqSendHandler = 0x00AE, // updated 4.1
CreateCrossWorldLS = 0x00AF, // updated 4.3
ChatHandler = 0x00C7, // updated 4.2 ChatHandler = 0x00D3, // updated 4.3
SocialListHandler = 0x00CF, // updated 4.2 SocialListHandler = 0x00DB, // updated 4.3
ReqSearchInfoHandler = 0x00D4, // updated 4.2 ReqSearchInfoHandler = 0x00E0, // updated 4.3
SetSearchInfoHandler = 0x00D2, // updated 4.2 SetSearchInfoHandler = 0x00DE, // updated 4.3
BlackListHandler = 0x00E0, // updated 4.2 BlackListHandler = 0x00EC, // updated 4.3
PlayerSearchHandler = 0x00E2, // updated 4.2 PlayerSearchHandler = 0x00E2, // updated 4.2
LinkshellListHandler = 0x00E8, // updated 4.2 LinkshellListHandler = 0x00F4, // updated 4.3
FcInfoReqHandler = 0x011A, // updated 4.2 FcInfoReqHandler = 0x011A, // updated 4.2
@ -218,34 +226,34 @@ namespace Packets {
ReqCountdownInitiate = 0x012C, // updated 4.2 ReqCountdownInitiate = 0x012C, // updated 4.2
ReqCountdownCancel = 0x012D, // updated 4.2 ReqCountdownCancel = 0x012D, // updated 4.2
ZoneLineHandler = 0x0130, // updated 4.2 ZoneLineHandler = 0x013C, // updated 4.3
ActionHandler = 0x0131, // updated 4.2 ActionHandler = 0x013D, // updated 4.3
DiscoveryHandler = 0x0132, // updated 4.2 DiscoveryHandler = 0x013E, // updated 4.3
SkillHandler = 0x0134, // updated 4.2 SkillHandler = 0x0140, // updated 4.3
GMCommand1 = 0x0135, // updated 4.2 GMCommand1 = 0x0141, // updated 4.3
GMCommand2 = 0x0136, // updated 4.2 GMCommand2 = 0x0142, // updated 4.3
UpdatePositionHandler = 0x0138, // updated 4.2
UpdatePositionInstance = 0x0177, // updated 4.2
InventoryModifyHandler = 0x013F, // updated 4.2 UpdatePositionHandler = 0x0144, // updated 4.3
UpdatePositionInstance = 0x0183, // updated 4.3
TalkEventHandler = 0x0148, // updated 4.2 InventoryModifyHandler = 0x014B, // updated 4.3
EmoteEventHandler = 0x0149, // updated 4.2
WithinRangeEventHandler = 0x014A, // updated 4.2
OutOfRangeEventHandler = 0x014B, // updated 4.2
EnterTeriEventHandler = 0x014C, // updated 4.2
ReturnEventHandler = 0x0151, // updated 4.2 TalkEventHandler = 0x0154, // updated 4.3
TradeReturnEventHandler = 0x0152, // updated 4.2 EmoteEventHandler = 0x0155, // updated 4.3
WithinRangeEventHandler = 0x0156, // updated 4.3
OutOfRangeEventHandler = 0x0157, // updated 4.3
EnterTeriEventHandler = 0x0158, // updated 4.3
ReturnEventHandler = 0x015D, // updated 4.3
TradeReturnEventHandler = 0x015E, // updated 4.3
LinkshellEventHandler = 0x0144, // updated 4.1 ?? LinkshellEventHandler = 0x0150, // updated 4.1 ??
LinkshellEventHandler1 = 0x0145, // updated 4.1 ?? LinkshellEventHandler1 = 0x0151, // updated 4.1 ??
PerformNoteHandler = 0x0160, PerformNoteHandler = 0x029B, // updated 4.3
ReqEquipDisplayFlagsChange = 0x016C, // updated 4.2 ReqEquipDisplayFlagsChange = 0x0178, // updated 4.3
}; };

View file

@ -87,8 +87,10 @@ struct FFXIVIpcCharList : FFXIVIpcBasePacket<LobbyCharList>
uint32_t index; uint32_t index;
uint32_t padding2; uint32_t padding2;
uint16_t serverId; uint16_t serverId;
uint16_t serverId1;
char nameChara[32]; char nameChara[32];
char nameServer[32]; char nameServer[32];
char nameServer1[32];
char charDetailJson[1030]; char charDetailJson[1030];
} charaDetails[2]; } charaDetails[2];

View file

@ -609,146 +609,156 @@ struct FFXIVIpcInitZone : FFXIVIpcBasePacket<InitZone>
*/ */
struct FFXIVIpcInitUI : FFXIVIpcBasePacket<InitUI> struct FFXIVIpcInitUI : FFXIVIpcBasePacket<InitUI>
{ {
// plain C types for a bit until the packet is actually fixed.
// makes conversion between different editors easier.
uint64_t contentId; uint64_t contentId;
uint32_t unknown8; unsigned int unknown8;
uint32_t unknownC; unsigned int unknownC;
uint32_t charId; unsigned int charId;
uint32_t restedExp; unsigned int restedExp;
uint16_t currentLevel; unsigned int companionCurrentExp;
uint8_t maxLevel; unsigned int unknown3C;
uint8_t expansion; unsigned int fishCaught;
uint8_t unknown1A; unsigned int useBaitCatalogId;
uint8_t race; unsigned int pvpWolfFoldMatches;
uint8_t tribe; unsigned short pvpWolfFoldWeeklyMatches;
uint8_t gender; unsigned short pvpWolfFoldWeeklyVictories;
uint8_t currentJob; unsigned short pvpStats[6];
uint8_t currentClass; unsigned short playerCommendations;
uint8_t deity; unsigned short pvpStats1;
uint8_t namedayMonth; unsigned char frontlineCampaigns[4];
uint8_t namedayDay; unsigned short frontlineCampaignsWeekly;
uint8_t cityState; unsigned char currentRelic;
uint8_t homepoint; unsigned char currentBook;
uint8_t unknown26; // 2 if "warrior of light" unsigned char masterCrafterMask;
uint8_t petHotBar; unsigned char unknown69;
uint8_t companionRank; unsigned char unknown6A;
uint8_t companionStars; unsigned char unknown6B;
uint8_t companionSp; unsigned char unknown6C[4];
uint8_t companionUnk2B; unsigned char unknown70[34];
uint8_t companionColor; unsigned short unknown18;
uint8_t companionFavoFeed; unsigned char maxLevel;
uint8_t companionUnk2E; unsigned char expansion;
float companionTimePassed; unsigned char unknown;
uint32_t companionCurrentExp; unsigned char race;
uint32_t unknown38; unsigned char tribe;
uint32_t unknown3C; unsigned char gender;
uint32_t fishCaught; unsigned char currentJob;
uint32_t useBaitCatalogId; unsigned char currentClass;
uint32_t pvpWolfFoldMatches; unsigned char deity;
uint16_t pvpWolfFoldWeeklyMatches; unsigned char namedayMonth;
uint16_t pvpWolfFoldWeeklyVictories; unsigned char namedayDay;
uint16_t pvpStats[6]; unsigned char cityState;
uint16_t playerCommendations; unsigned char homepoint;
uint16_t pvpStats1; unsigned char unknown26;
uint8_t frontlineCampaigns[4]; unsigned char petHotBar;
uint16_t frontlineCampaignsWeekly; unsigned char companionRank;
uint8_t currentRelic; unsigned char companionStars;
uint8_t currentBook; unsigned char companionSp;
uint8_t masterCrafterMask; unsigned char companionUnk2B;
uint8_t unknown69; unsigned char companionColor;
uint8_t unknown6A; unsigned char companionFavoFeed;
uint8_t unknown6B; unsigned char companionUnk2E;
uint8_t unknown6C[4]; unsigned char companionTimePassed[4];
uint8_t unknown70[61]; unsigned short unknown38[11];
uint8_t preNamePadding;
unsigned int exp[25];
unsigned char unknown564[16];
unsigned int pvpFrontlineOverall1st;
unsigned int pvpFrontlineOverall2nd;
unsigned int pvpFrontlineOverall3rd;
unsigned char relicBookCompletion1[4];
unsigned short levels[25];
unsigned short levelsPadding;
unsigned char unknown__[16];
unsigned short fishingRecordsFish[26];
unsigned short fishingRecordsFishWeight[26];
unsigned char unknownMask554[44];
unsigned char companion_name[21];
unsigned char companionDefRank;
unsigned char companionAttRank;
unsigned char companionHealRank;
unsigned char mountGuideMask[16];
char name[32]; char name[32];
uint8_t unknownOword[16]; unsigned char unknownOword[16];
uint8_t unknownDE[2]; unsigned char unlockBitmask[64];
uint16_t levels[25]; unsigned char aetheryte[17];
uint16_t levelsPadding; unsigned char discovery[421];
uint32_t exp[25]; unsigned char howto[33];
uint8_t unlockBitmask[64]; unsigned char minions[38];
uint8_t aetheryte[16]; unsigned char chocoboTaxiMask[8];
uint8_t discovery[421]; unsigned char contentClearMask[111];
uint8_t howto[33]; unsigned char contentClearPadding;
uint8_t minions[37]; unsigned short unknown428[8];
uint8_t chocoboTaxiMask[8]; unsigned char companionBardingMask[8];
uint8_t contentClearMask[108]; unsigned char companionEquippedHead;
uint8_t contentClearPadding; unsigned char companionEquippedBody;
uint16_t unknown428[8]; unsigned char companionEquippedFeet;
uint8_t companionBardingMask[8]; unsigned char companionUnk4[4];
uint8_t companionEquippedHead; unsigned char companion_fields[11];
uint8_t companionEquippedBody;
uint8_t companionEquippedFeet; unsigned char fishingGuideMask[89];
uint8_t companionUnk4[4]; unsigned char fishingSpotVisited[25];
uint8_t companion_fields[11];
uint8_t companion_name[21];
uint8_t companionDefRank; unsigned char unknownMask4Padding;
uint8_t companionAttRank;
uint8_t companionHealRank; unsigned char rankAmalJaa;
uint8_t mountGuideMask[15]; unsigned char rankSylph;
uint8_t fishingGuideMask[89]; unsigned char rankKobold;
uint8_t fishingSpotVisited[25]; unsigned char rankSahagin;
uint16_t fishingRecordsFish[26]; unsigned char rankIxal;
uint16_t fishingRecordsFishWeight[26]; unsigned char rankVanu;
uint8_t unknownMask554[15]; unsigned char rankVath;
uint8_t unknownMask4Padding; unsigned char rankMoogle;
uint8_t unknown564[19]; unsigned char rankKojin;
uint8_t rankAmalJaa; unsigned char rankAnata;
uint8_t rankSylph; unsigned short expAmalJaa;
uint8_t rankKobold; unsigned short expSylph;
uint8_t rankSahagin; unsigned short expKobold;
uint8_t rankIxal; unsigned short expSahagin;
uint8_t rankVanu; unsigned short expIxal;
uint8_t rankVath; unsigned short expVanu;
uint8_t rankMoogle; unsigned short expVath;
uint8_t rankKojin; unsigned short expMoogle;
uint8_t rankAnata; unsigned short expKojin;
uint16_t expAmalJaa; unsigned short expAnata;
uint16_t expSylph; unsigned char unknown596[10];
uint16_t expKobold; unsigned short unknown5A0[5];
uint16_t expSahagin; unsigned char unknownMask59E[5];
uint16_t expIxal; unsigned char unknown5A3[18];
uint16_t expVanu; unsigned char unknownMask5C1[28];
uint16_t expVath; unsigned char unknown_03411;
uint16_t expMoogle; unsigned int unknownDword5E0;
uint16_t expKojin; unsigned short pvpFrontlineWeekly1st;
uint16_t expAnata; unsigned short pvpFrontlineWeekly2nd;
uint8_t unknown596[10]; unsigned short pvpFrontlineWeekly3rd;
uint16_t unknown5A0[5]; unsigned char relicBookCompletion2[8];
uint8_t unknownMask59E[5]; unsigned char sightseeingMask[26];
uint8_t unknown5A3[18]; unsigned short unknown_XXX;
uint8_t unknownMask5C1[28];
uint8_t unknown_03411; unsigned char unknown61E;
uint32_t unknownDword5E0; unsigned char unknown61F[32];
uint8_t relicBookCompletion[12]; unsigned char unknown63F[22];
uint8_t sightseeingMask[26]; unsigned char tripleTriadCards[28];
uint16_t unknown_XXX; unsigned char unknown671[11];
uint32_t pvpFrontlineOverall1st; unsigned char unknownMask67C[22];
uint32_t pvpFrontlineOverall2nd; unsigned char unknown692[3];
uint32_t pvpFrontlineOverall3rd; unsigned char orchestrionMask[40];
uint16_t pvpFrontlineWeekly1st; unsigned char hallOfNoviceCompleteMask[3];
uint16_t pvpFrontlineWeekly2nd; unsigned char unknownMask6C0[11];
uint16_t pvpFrontlineWeekly3rd; unsigned char unknownMask6CB[16];
uint8_t unknown61E; unsigned char unknown6DB[14];
uint8_t centurioSealHunts[32]; unsigned char unlockedRaids[28];
uint8_t alliedSealHunts[22]; unsigned char unlockedDungeons[18];
uint8_t tripleTriadCards[28]; unsigned char unlockedGuildhests[10];
uint8_t unknown671[11]; unsigned char unlockedTrials[7];
uint8_t unknownMask67C[22]; unsigned char unlockedPvp[5];
uint8_t unknown692[3]; unsigned char unknownMask72D[28];
uint8_t orchestrionMask[40]; // unsigned char unknownMask749[18];
uint8_t hallOfNoviceCompleteMask[3]; //unsigned char unknown749[13];
uint8_t unknownMask6C0[11];
uint8_t animaRelicMask[16]; // [2] = anima glass key item, [1] = ulan's note key item
uint8_t unknown6DB[14];
uint8_t unlockedRaids[28];
uint8_t unlockedDungeons[18];
uint8_t unlockedGuildhests[10];
uint8_t unlockedTrials[7];
uint8_t unlockedPvp[5];
uint8_t unknownMask72D[28];
uint8_t unknownMask749[18];
uint8_t unknown749[23];
}; };
/** /**

View file

@ -0,0 +1,36 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
class TheWeaponsRefrainUltimate : public InstanceContentScript
{
public:
TheWeaponsRefrainUltimate() : InstanceContentScript( 30067 )
{ }
void onInit( InstanceContentPtr instance ) override
{
instance->registerEObj( "unknown_0", 2009480, 0, 4, { 94.011192f, 0.000000f, 107.700996f }, 1.000000f, 0.000000f );
instance->registerEObj( "sgvf_w1fz_b1432", 2007457, 7372735, 4, { 100.000000f, 0.000000f, 100.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_1", 2007457, 7373056, 4, { 100.000000f, 0.000000f, 100.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_2", 2009481, 0, 4, { 101.695602f, 0.000000f, 101.959396f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_3", 2007457, 7237754, 4, { 100.000000f, 0.000000f, 100.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_4", 2007457, 7237753, 4, { 100.000000f, 0.000000f, 100.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_5", 2007457, 7237756, 4, { 100.000000f, 0.000000f, 100.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_6", 2007457, 7237755, 4, { 100.000000f, 0.000000f, 100.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "Entrance", 2007457, 7343478, 5, { 100.000000f, 0.000000f, 116.000000f }, 1.000000f, 0.000000f );
// States -> vf_lock_on vf_lock_of
instance->registerEObj( "Exit", 2000139, 0, 4, { 100.000000f, 0.000000f, 85.000000f }, 1.000000f, 0.000000f );
instance->registerEObj( "unknown_7", 2007457, 7538258, 4, { 100.160004f, 0.000000f, 101.443398f }, 1.000000f, 0.000000f );
}
void onUpdate( InstanceContentPtr instance, uint32_t currTime ) override
{
}
void onEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) override
{
}
};

View file

@ -110,12 +110,20 @@ namespace Core {
std::string PlayerMinimal::getInfoJson() std::string PlayerMinimal::getInfoJson()
{ {
std::string charDetails = "{\"content\":[\"" + std::string( getName() ) + "\"," + std::string charDetails = "{\"content\":[\"" + std::string( getName() ) + "\"," +
"[" + getClassString() + "]," + //"[" + getClassString() + "]," +
"\"0\",\"0\",\"0\",\"" + std::to_string( getBirthMonth() ) + "\",\"" + std::to_string( getBirthDay() ) + "\",\"" + std::to_string( getGuardianDeity() ) + "\",\"" + std::to_string( m_class ) + "\",\"0\",\"" + std::to_string( getZoneId() ) + "\"," + "[\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"],"
"\"0\",\"0\",\"0\",\"" +
std::to_string( getBirthMonth() ) +
"\",\"" + std::to_string( getBirthDay() ) +
"\",\"" + std::to_string( getGuardianDeity() ) +
"\",\"" + std::to_string( m_class ) +
"\",\"0\",\"" + std::to_string( getZoneId() ) +
"\",\"0\"," +
"[" + getLookString() + "]," + "[" + getLookString() + "]," +
"\"0\",\"0\"," + "\"0\",\"0\"," +
"[" + getModelString() + "]," + "[" + getModelString() + "]," +
"\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]," + "\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"\",\"0\",\"0\"]," +
"\"classname\":\"ClientSelectData\",\"classid\":116}"; "\"classname\":\"ClientSelectData\",\"classid\":116}";
return charDetails; return charDetails;
} }

View file

@ -7,7 +7,7 @@
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Config/XMLConfig.h> #include <Config/ConfigMgr.h>
#include <Network/Connection.h> #include <Network/Connection.h>
#include <Network/Hive.h> #include <Network/Hive.h>
@ -52,13 +52,13 @@ void default_resource_send( const HttpServer &server, const shared_ptr< HttpServ
const shared_ptr< ifstream > &ifs ); const shared_ptr< ifstream > &ifs );
auto m_pConfig = boost::make_shared< Core::XMLConfig >(); auto m_pConfig = boost::make_shared< Core::ConfigMgr >();
HttpServer server; HttpServer server;
std::string configPath( "config/settings_rest.xml" ); std::string configPath( "rest.ini" );
void reloadConfig() void reloadConfig()
{ {
m_pConfig = boost::make_shared< Core::XMLConfig >(); m_pConfig = boost::make_shared< Core::ConfigMgr >();
if( !m_pConfig->loadConfig( configPath ) ) if( !m_pConfig->loadConfig( configPath ) )
throw "Error loading config "; throw "Error loading config ";
@ -96,43 +96,43 @@ bool loadSettings( int32_t argc, char* argv[] )
if( arg == "ip" ) if( arg == "ip" )
{ {
// todo: ip addr in config // todo: ip addr in config
m_pConfig->setValue< std::string >( "Settings.General.ListenIP", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.RestHost", val );
} }
else if( arg == "p" || arg == "port" ) else if( arg == "p" || arg == "port" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.RestPort", val );
} }
else if( arg == "exdpath" || arg == "datapath" ) else if( arg == "exdpath" || arg == "datapath" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.DataPath", val ); m_pConfig->setValue< std::string >( "GlobalParameters.DataPath", val );
} }
else if( arg == "h" || arg == "dbhost" ) else if( arg == "h" || arg == "dbhost" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Host", val ); m_pConfig->setValue< std::string >( "Database.Host", val );
} }
else if( arg == "dbport" ) else if( arg == "dbport" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Port", val ); m_pConfig->setValue< std::string >( "Database.Port", val );
} }
else if( arg == "u" || arg == "user" || arg == "dbuser" ) else if( arg == "u" || arg == "user" || arg == "dbuser" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Username", val ); m_pConfig->setValue< std::string >( "Database.Username", val );
} }
else if( arg == "pass" || arg == "dbpass" ) else if( arg == "pass" || arg == "dbpass" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Pass", val ); m_pConfig->setValue< std::string >( "Database.Password", val );
} }
else if( arg == "d" || arg == "db" || arg == "database" ) else if( arg == "d" || arg == "db" || arg == "database" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Database", val ); m_pConfig->setValue< std::string >( "Database.Database", val );
} }
else if ( arg == "lobbyip" || arg == "lobbyhost" ) else if ( arg == "lobbyip" || arg == "lobbyhost" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.LobbyHost", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyHost", val );
} }
else if ( arg == "lobbyport" ) else if ( arg == "lobbyport" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.LobbyPort", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyPort", val );
} }
} }
catch( ... ) catch( ... )
@ -143,7 +143,7 @@ bool loadSettings( int32_t argc, char* argv[] )
} }
g_log.info( "Setting up generated EXD data" ); g_log.info( "Setting up generated EXD data" );
if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "GlobalParameters.DataPath", "" ) ) )
{ {
g_log.fatal( "Error setting up generated EXD data " ); g_log.fatal( "Error setting up generated EXD data " );
return false; return false;
@ -152,19 +152,19 @@ bool loadSettings( int32_t argc, char* argv[] )
Core::Db::DbLoader loader; Core::Db::DbLoader loader;
Core::Db::ConnectionInfo info; Core::Db::ConnectionInfo info;
info.password = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Pass", "" ); info.password = m_pConfig->getValue< std::string >( "Database.Password", "" );
info.host = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Host", "127.0.0.1" ); info.host = m_pConfig->getValue< std::string >( "Database.Host", "127.0.0.1" );
info.database = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Database", "sapphire" ); info.database = m_pConfig->getValue< std::string >( "Database.Database", "sapphire" );
info.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 ); info.port = m_pConfig->getValue< uint16_t >( "Database.Port", 3306 );
info.user = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" ); info.user = m_pConfig->getValue< std::string >( "Database.Username", "root" );
info.syncThreads = m_pConfig->getValue< uint8_t >( "Settings.General.Mysql.SyncThreads", 2 ); info.syncThreads = m_pConfig->getValue< uint8_t >( "Database.SyncThreads", 2 );
info.asyncThreads = m_pConfig->getValue< uint8_t >( "Settings.General.Mysql.AsyncThreads", 2 ); info.asyncThreads = m_pConfig->getValue< uint8_t >( "Database.AsyncThreads", 2 );
loader.addDb( g_charaDb, info ); loader.addDb( g_charaDb, info );
if( !loader.initDbs() ) if( !loader.initDbs() )
return false; return false;
server.config.port = static_cast< uint16_t >( std::stoul( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) ) ); server.config.port = static_cast< uint16_t >( std::stoul( m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) ) );
g_log.info( "Database: Connected to " + info.host + ":" + std::to_string( info.port ) ); g_log.info( "Database: Connected to " + info.host + ":" + std::to_string( info.port ) );
@ -269,8 +269,8 @@ void createAccount( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSe
if( g_sapphireAPI.createAccount( user, pass, sId ) ) if( g_sapphireAPI.createAccount( user, pass, sId ) )
{ {
std::string json_string = "{\"sId\":\"" + sId + std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.LobbyHost" ) + "\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost" ) +
"\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}"; "\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + "\"}";
*response << buildHttpResponse( 200, json_string, JSON ); *response << buildHttpResponse( 200, json_string, JSON );
} }
else else
@ -301,8 +301,8 @@ void login( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Re
if( g_sapphireAPI.login( user, pass, sId ) ) if( g_sapphireAPI.login( user, pass, sId ) )
{ {
std::string json_string = "{\"sId\":\"" + sId + std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >("Settings.General.LobbyHost") + "\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost" ) +
"\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}"; "\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + "\"}";
*response << buildHttpResponse( 200, json_string, JSON ); *response << buildHttpResponse( 200, json_string, JSON );
} }
else else
@ -333,7 +333,7 @@ void deleteCharacter( shared_ptr<HttpServer::Response> response, shared_ptr<Http
int32_t accountId = g_sapphireAPI.checkSession( sId ); int32_t accountId = g_sapphireAPI.checkSession( sId );
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -374,14 +374,14 @@ void createCharacter( shared_ptr<HttpServer::Response> response, shared_ptr<Http
if( result != -1 ) if( result != -1 )
{ {
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
} }
else else
{ {
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >( "Settings.Parameters.DefaultGMRank", 255 ) ); int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >( "CharacterCreation.DefaultGMRank", 255 ) );
std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}"; std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}";
*response << buildHttpResponse( 200, json_string, JSON ); *response << buildHttpResponse( 200, json_string, JSON );
@ -414,7 +414,7 @@ void insertSession( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSe
uint32_t accountId = pt.get<uint32_t>( "accountId" ); uint32_t accountId = pt.get<uint32_t>( "accountId" );
std::string secret = pt.get<string>( "secret" ); std::string secret = pt.get<string>( "secret" );
// reloadConfig(); // reloadConfig();
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -448,7 +448,7 @@ void checkNameTaken( shared_ptr<HttpServer::Response> response, shared_ptr<HttpS
// reloadConfig(); // reloadConfig();
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -486,7 +486,7 @@ void checkSession( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSer
if( result != -1 ) if( result != -1 )
{ {
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -523,7 +523,7 @@ void getNextCharId( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSe
// reloadConfig(); // reloadConfig();
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -555,7 +555,7 @@ void getNextContentId( shared_ptr<HttpServer::Response> response, shared_ptr<Htt
// reloadConfig(); // reloadConfig();
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -591,7 +591,7 @@ void getCharacterList( shared_ptr<HttpServer::Response> response, shared_ptr<Htt
if( result != -1 ) if( result != -1 )
{ {
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
{ {
std::string json_string = "{\"result\":\"invalid_secret\"}"; std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON ); *response << buildHttpResponse( 403, json_string, JSON );
@ -756,8 +756,8 @@ int main( int argc, char* argv[] )
if( !loadSettings( argc, argv ) ) if( !loadSettings( argc, argv ) )
throw std::exception(); throw std::exception();
server.config.port = stoi( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) ); server.config.port = stoi( m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) );
g_log.info( "Starting API server at port " + m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) + "..." ); g_log.info( "Starting API server at port " + m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) + "..." );
server.resource["^/ZoneName/([0-9]+)$"]["GET"] = &getZoneName; server.resource["^/ZoneName/([0-9]+)$"]["GET"] = &getZoneName;
server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = &createAccount; server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = &createAccount;

View file

@ -10,6 +10,7 @@
#include <Network/GamePacketParser.h> #include <Network/GamePacketParser.h>
#include <Crypt/md5.h> #include <Crypt/md5.h>
#include <Crypt/blowfish.h> #include <Crypt/blowfish.h>
#include <Config/ConfigMgr.h>
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
@ -129,10 +130,10 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
serverListPacket.data().seq = 1; serverListPacket.data().seq = 1;
serverListPacket.data().offset = 0; serverListPacket.data().offset = 0;
serverListPacket.data().numServers = 1; serverListPacket.data().numServers = 1;
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>( "Lobby.WorldID", 1 );
serverListPacket.data().server[0].index = 0; serverListPacket.data().server[0].index = 0;
serverListPacket.data().final = 1; serverListPacket.data().final = 1;
strcpy( 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 >( "Lobby.WorldName", "Sapphire" ).c_str() );
pRP.addPacket( serverListPacket ); pRP.addPacket( serverListPacket );
@ -166,11 +167,11 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
auto& charEntry = charList[charIndex]; auto& charEntry = charList[charIndex];
details.uniqueId = get< 1 >( charEntry ); details.uniqueId = get< 1 >( charEntry );
details.contentId = get< 2 >( charEntry ); details.contentId = get< 2 >( charEntry );
details.serverId = g_serverLobby.getConfig()->getValue<uint16_t>( "Settings.Parameters.WorldID", 1 ); details.serverId = g_serverLobby.getConfig()->getValue<uint16_t>( "Lobby.WorldID", 1 );
details.index = charIndex; details.index = charIndex;
strcpy( details.charDetailJson, get< 3 >( charEntry ).c_str() ); strcpy( details.charDetailJson, get< 3 >( charEntry ).c_str() );
strcpy( details.nameChara, get< 0 >( charEntry ).c_str() ); strcpy( details.nameChara, get< 0 >( charEntry ).c_str() );
strcpy( details.nameServer, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() ); strcpy( details.nameServer, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
charListPacket.data().charaDetails[j] = details; charListPacket.data().charaDetails[j] = details;
@ -238,8 +239,8 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin
enterWorldPacket.data().contentId = lookupId; enterWorldPacket.data().contentId = lookupId;
enterWorldPacket.data().seq = sequence; enterWorldPacket.data().seq = sequence;
strcpy( enterWorldPacket.data().host, g_serverLobby.getConfig()->getValue< std::string >( "Settings.General.ZoneIp" ).c_str() ); strcpy( enterWorldPacket.data().host, g_serverLobby.getConfig()->getValue< std::string >( "GlobalNetwork.ZoneHost" ).c_str() );
enterWorldPacket.data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "Settings.General.ZonePort" ); enterWorldPacket.data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "GlobalNetwork.ZonePort" );
enterWorldPacket.data().charId = logInCharId; enterWorldPacket.data().charId = logInCharId;
memcpy( enterWorldPacket.data().sid, m_pSession->getSessionId(), 66 ); memcpy( enterWorldPacket.data().sid, m_pSession->getSessionId(), 66 );
@ -251,7 +252,7 @@ bool Core::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_RAW&
{ {
LobbySessionPtr pSession = g_serverLobby.getSession( ( char* )&packet.data[0] + 0x20 ); LobbySessionPtr pSession = g_serverLobby.getSession( ( char* )&packet.data[0] + 0x20 );
if( g_serverLobby.getConfig()->getValue< bool >( "Settings.Parameters.AllowNoSessionConnect" ) && pSession == nullptr ) if( g_serverLobby.getConfig()->getValue< bool >( "Lobby.AllowNoSessionConnect" ) && pSession == nullptr )
{ {
auto session = make_LobbySession(); auto session = make_LobbySession();
session->setAccountID( 0 ); session->setAccountID( 0 );
@ -319,7 +320,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
charCreatePacket.data().content_id = newContentId; charCreatePacket.data().content_id = newContentId;
strcpy( charCreatePacket.data().name, name.c_str() ); strcpy( charCreatePacket.data().name, name.c_str() );
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() ); strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
charCreatePacket.data().type = 1; charCreatePacket.data().type = 1;
charCreatePacket.data().seq = sequence; charCreatePacket.data().seq = sequence;
charCreatePacket.data().unknown = 1; charCreatePacket.data().unknown = 1;
@ -343,7 +344,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
charCreatePacket.data().content_id = newContentId; charCreatePacket.data().content_id = newContentId;
strcpy( charCreatePacket.data().name, name.c_str() ); strcpy( charCreatePacket.data().name, name.c_str() );
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() ); strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
charCreatePacket.data().type = 2; charCreatePacket.data().type = 2;
charCreatePacket.data().seq = sequence; charCreatePacket.data().seq = sequence;
charCreatePacket.data().unknown = 1; charCreatePacket.data().unknown = 1;
@ -374,7 +375,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
//charCreatePacket.data().content_id = deletePlayer.getContentId(); //charCreatePacket.data().content_id = deletePlayer.getContentId();
charCreatePacket.data().content_id = 0; charCreatePacket.data().content_id = 0;
strcpy( charCreatePacket.data().name, name.c_str() ); strcpy( charCreatePacket.data().name, name.c_str() );
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() ); strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
charCreatePacket.data().type = 4; charCreatePacket.data().type = 4;
charCreatePacket.data().seq = sequence; charCreatePacket.data().seq = sequence;
charCreatePacket.data().unknown = 1; charCreatePacket.data().unknown = 1;
@ -475,8 +476,8 @@ void Core::Network::GameConnection::generateEncryptionKey( uint32_t key, const s
m_baseKey[2] = 0x34; m_baseKey[2] = 0x34;
m_baseKey[3] = 0x12; m_baseKey[3] = 0x12;
memcpy( m_baseKey + 0x04, &key, 4 ); memcpy( m_baseKey + 0x04, &key, 4 );
m_baseKey[8] = 0xA0; m_baseKey[8] = 0xCC;
m_baseKey[9] = 0x0F; m_baseKey[9] = 0x10;
memcpy( ( char* )m_baseKey + 0x0C, keyPhrase.c_str(), keyPhrase.size() ); memcpy( ( char* )m_baseKey + 0x0C, keyPhrase.c_str(), keyPhrase.size() );
Core::Util::md5( m_baseKey, m_encKey, 0x2C ); Core::Util::md5( m_baseKey, m_encKey, 0x2C );
} }

View file

@ -8,7 +8,7 @@
#include <Version.h> #include <Version.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Config/XMLConfig.h> #include <Config/ConfigMgr.h>
//#include "LobbySession.h" //#include "LobbySession.h"
@ -37,7 +37,7 @@ namespace Core {
m_configPath( configPath ), m_configPath( configPath ),
m_numConnections( 0 ) m_numConnections( 0 )
{ {
m_pConfig = boost::shared_ptr<XMLConfig>( new XMLConfig ); m_pConfig = boost::shared_ptr< ConfigMgr >( new ConfigMgr );
} }
ServerLobby::~ServerLobby( void ) ServerLobby::~ServerLobby( void )
@ -49,7 +49,7 @@ namespace Core {
return g_restConnector.getSession( sessionId ); return g_restConnector.getSession( sessionId );
} }
XMLConfigPtr ServerLobby::getConfig() const ConfigMgrPtr ServerLobby::getConfig() const
{ {
return m_pConfig; return m_pConfig;
} }
@ -109,23 +109,19 @@ namespace Core {
if( arg == "ip" ) if( arg == "ip" )
{ {
// todo: ip addr in config // todo: ip addr in config
m_pConfig->setValue< std::string >( "Settings.General.ListenIp", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyHost", val );
} }
else if( arg == "p" || arg == "port" ) else if( arg == "p" || arg == "port" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyPort", val );
}
else if( arg == "ap" || arg == "auth" || arg == "authport" )
{
m_pConfig->setValue< std::string>( "Settings.General.AuthPort", val );
} }
else if( arg == "worldip" || arg == "worldip" ) else if( arg == "worldip" || arg == "worldip" )
{ {
m_pConfig->setValue < std::string >( "Settings.General.WorldIp", val ); m_pConfig->setValue < std::string >( "GlobalNetwork.ZoneHost", val );
} }
else if( arg == "worldport" ) else if( arg == "worldport" )
{ {
m_pConfig->setValue< std::string >( "Settings.General.WorldPort", val ); m_pConfig->setValue< std::string >( "GlobalNetwork.ZonePort", val );
} }
} }
catch( ... ) catch( ... )
@ -135,11 +131,11 @@ namespace Core {
} }
} }
m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54994 ); m_port = m_pConfig->getValue< uint16_t >( "GlobalNetwork.LobbyPort", 54994 );
m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" ); m_ip = m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost", "0.0.0.0" );
g_restConnector.restHost = m_pConfig->getValue< std::string >( "Settings.General.RestHost" ); g_restConnector.restHost = m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + ":" + m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort" );
g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ); g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" );
return true; return true;
} }

View file

@ -6,7 +6,6 @@
#include <map> #include <map>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <Config/XMLConfig.h>
#include "Forwards.h" #include "Forwards.h"
@ -15,7 +14,7 @@ const std::string LOBBY_VERSION = "0.0.5";
namespace Core namespace Core
{ {
class LobbySession; class LobbySession;
class XMLConfig; class ConfigMgr;
typedef std::map< std::string, LobbySessionPtr > LobbySessionMap; typedef std::map< std::string, LobbySessionPtr > LobbySessionMap;
class ServerLobby class ServerLobby
@ -30,7 +29,7 @@ namespace Core
uint16_t m_port; uint16_t m_port;
std::string m_ip; std::string m_ip;
boost::shared_ptr<XMLConfig> m_pConfig; boost::shared_ptr< ConfigMgr > m_pConfig;
public: public:
ServerLobby( const std::string& configPath ); ServerLobby( const std::string& configPath );
@ -45,7 +44,7 @@ namespace Core
m_sessionMap[std::string( sessionId )] = pSession; m_sessionMap[std::string( sessionId )] = pSession;
} }
boost::shared_ptr<XMLConfig> getConfig() const; boost::shared_ptr< ConfigMgr > getConfig() const;
LobbySessionPtr getSession( char* sessionId ); LobbySessionPtr getSession( char* sessionId );
uint32_t m_numConnections; uint32_t m_numConnections;

View file

@ -1,6 +1,6 @@
#include "ServerLobby.h" #include "ServerLobby.h"
Core::ServerLobby g_serverLobby( "config/settings_lobby.xml" ); Core::ServerLobby g_serverLobby( "lobby.ini" );
int main( int32_t argc, char* argv[] ) int main( int32_t argc, char* argv[] )
{ {

View file

@ -9,7 +9,6 @@
#include "Actor/Player.h" #include "Actor/Player.h"
#include <cmath> #include <cmath>
#include <boost/make_shared.hpp>
using namespace Core::Entity; using namespace Core::Entity;
using namespace Core::Common; using namespace Core::Common;

View file

@ -2,14 +2,14 @@
#define _ACTIONCOLLISION_H #define _ACTIONCOLLISION_H
#include <Common.h> #include <Common.h>
#include "Action.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Data namespace Data
{ {
struct Action; struct Action;
} }
namespace Entity { namespace Entity {
enum class TargetFilter enum class TargetFilter

View file

@ -1,7 +1,7 @@
#ifndef _ACTIONMOUNT_H_ #ifndef _ACTIONMOUNT_H_
#define _ACTIONMOUNT_H_ #define _ACTIONMOUNT_H_
#include "../Forwards.h" #include "Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Core {

View file

@ -1,7 +1,7 @@
#ifndef _ACTIONTELEPORT_H_ #ifndef _ACTIONTELEPORT_H_
#define _ACTIONTELEPORT_H_ #define _ACTIONTELEPORT_H_
#include "../Forwards.h" #include "Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Core {

View file

@ -6,7 +6,6 @@
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Event/EventHandler.h"
#include "EventAction.h" #include "EventAction.h"
#include "Framework.h" #include "Framework.h"

View file

@ -3,7 +3,7 @@
#include <Common.h> #include <Common.h>
#include "../Forwards.h" #include "Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Core {

View file

@ -1,7 +1,7 @@
#ifndef _EVENTITEMACTION_H_ #ifndef _EVENTITEMACTION_H_
#define _EVENTITEMACTION_H_ #define _EVENTITEMACTION_H_
#include "../Forwards.h" #include "Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Core {

View file

@ -1,11 +1,10 @@
#include "Actor.h" #include "Actor.h"
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Network/GamePacket.h>
#include <Util/Util.h> #include <Util/Util.h>
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include "Forwards.h"
#include "Action/Action.h" #include "Action/Action.h"
#include "Action/ActionCollision.h" #include "Action/ActionCollision.h"
@ -19,8 +18,6 @@
#include "ServerZone.h" #include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Zone/Zone.h"
#include "Zone/TerritoryMgr.h" #include "Zone/TerritoryMgr.h"
@ -28,11 +25,6 @@
#include "Math/CalcBattle.h" #include "Math/CalcBattle.h"
#include "ServerZone.h"
#include "Session.h"
#include "Actor.h"
#include "Player.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -2,7 +2,6 @@
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Network/GamePacket.h>
#include "Forwards.h" #include "Forwards.h"
#include "Action/Action.h" #include "Action/Action.h"

View file

@ -6,9 +6,7 @@
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Network/GamePacket.h> #include <Network/GamePacket.h>
#include <Network/GamePacketNew.h> #include <Network/GamePacketNew.h>
#include <Network/CommonNetwork.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h> #include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/PacketContainer.h>
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
using namespace Core::Common; using namespace Core::Common;

View file

@ -10,10 +10,11 @@ namespace Entity
class EventObject : public Actor class EventObject : public Actor
{ {
public: public:
EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId, uint8_t initialState, Common::FFXIVARR_POSITION3 pos, EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId, uint8_t initialState,
float rotation, const std::string& givenName = "none" ); Common::FFXIVARR_POSITION3 pos, float rotation, const std::string& givenName = "none" );
using OnTalkEventHandler = std::function< void( Entity::Player&, Entity::EventObjectPtr, InstanceContentPtr, uint64_t ) >; using OnTalkEventHandler = std::function< void( Entity::Player&, Entity::EventObjectPtr,
InstanceContentPtr, uint64_t ) >;
uint32_t getGimmickId() const; uint32_t getGimmickId() const;
void setGimmickId( uint32_t gimmickId ); void setGimmickId( uint32_t gimmickId );

View file

@ -3,7 +3,6 @@
#include <Common.h> #include <Common.h>
#include <Util/Util.h> #include <Util/Util.h>
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include <Config/XMLConfig.h>
#include <Network/GamePacket.h> #include <Network/GamePacket.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
@ -30,11 +29,6 @@
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Inventory/Item.h"
#include "Inventory/Inventory.h"
#include "Event/EventHandler.h"
#include "Action/Action.h" #include "Action/Action.h"
#include "Action/ActionTeleport.h" #include "Action/ActionTeleport.h"
#include "Action/EventAction.h" #include "Action/EventAction.h"
@ -317,7 +311,7 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
} }
setStateFlag( PlayerStateFlag::BetweenAreas ); setStateFlag( PlayerStateFlag::BetweenAreas );
auto targetPos = pTeriMgr->getTerritoryPosition( data->levelId ); auto targetPos = pTeriMgr->getTerritoryPosition( data->level.at( 0 ) );
Common::FFXIVARR_POSITION3 pos; Common::FFXIVARR_POSITION3 pos;
pos.x = 0; pos.x = 0;

View file

@ -2,7 +2,7 @@
#include <Network/GamePacket.h> #include <Network/GamePacket.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Config/XMLConfig.h> #include <Config/ConfigMgr.h>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
@ -16,12 +16,7 @@
#include "Action/EventAction.h" #include "Action/EventAction.h"
#include "Action/EventItemAction.h" #include "Action/EventItemAction.h"
#include "Event/EventHandler.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Player.h"
#include "Forwards.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Framework.h" #include "Framework.h"
@ -312,10 +307,14 @@ void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
void Core::Entity::Player::onLogin() void Core::Entity::Player::onLogin()
{ {
auto pConfig = g_fw.get< XMLConfig >(); auto pConfig = g_fw.get< ConfigMgr >();
for( auto& child : pConfig->getChild( "Settings.Parameters.MotDArray" ) ) auto motd = pConfig->getValue< std::string >( "General.MotD", "" );
std::istringstream ss( motd );
std::string msg;
while( std::getline( ss, msg, ';' ) )
{ {
sendNotice( child.second.data() ); sendNotice( msg );
} }
} }

View file

@ -8,8 +8,6 @@
#include "Network/PacketWrappers/QuestMessagePacket.h" #include "Network/PacketWrappers/QuestMessagePacket.h"
#include "Session.h" #include "Session.h"
#include "Inventory/Inventory.h"
#include "Player.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -1,12 +1,9 @@
#include <set> #include <set>
#include <stdio.h>
#include <time.h>
#include <Common.h> #include <Common.h>
#include <Network/GamePacket.h> #include <Network/GamePacket.h>
#include <Util/Util.h> #include <Util/Util.h>
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include <Config/XMLConfig.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
@ -19,11 +16,7 @@
#include "Zone/TerritoryMgr.h" #include "Zone/TerritoryMgr.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Inventory/Inventory.h"
#include "Player.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Forwards.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -6,7 +6,6 @@
#include <Common.h> #include <Common.h>
#include <Version.h> #include <Version.h>
#include <Network/GamePacketNew.h> #include <Network/GamePacketNew.h>
#include <Network/CommonNetwork.h>
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
@ -25,7 +24,6 @@
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Script/NativeScriptMgr.h" #include "Script/NativeScriptMgr.h"
#include "Actor/Player.h"
#include "Actor/EventObject.h" #include "Actor/EventObject.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
@ -34,7 +32,6 @@
#include "ServerZone.h" #include "ServerZone.h"
#include "StatusEffect/StatusEffect.h"
#include "Session.h" #include "Session.h"
#include "Framework.h" #include "Framework.h"

View file

@ -69,12 +69,6 @@ namespace Core
EVENT_TABLE_GAME = 24 EVENT_TABLE_GAME = 24
}; };
enum EventFinishState
{
UNLOCK = 1,
KEEPLOCK = 0
};
enum DamageType enum DamageType
{ {
STD_DAMAGE = 0X03, STD_DAMAGE = 0X03,

View file

@ -1,7 +1,7 @@
#ifndef _EVENT_H #ifndef _EVENT_H
#define _EVENT_H #define _EVENT_H
#include "../Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Event { namespace Event {

View file

@ -1,10 +1,12 @@
#include <Common.h> #include <Common.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/algorithm/string/classification.hpp>
#include "Framework.h" #include "Framework.h"
#include "EventHelper.h" #include "EventHelper.h"
#include "EventHandler.h" #include "EventHandler.h"
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/algorithm/string/classification.hpp>
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -2,7 +2,7 @@
#include <boost/algorithm/clamp.hpp> #include <boost/algorithm/clamp.hpp>
#include <Network/PacketDef/Zone/ServerZoneDef.h> #include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Common.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Database/DatabaseDef.h> #include <Database/DatabaseDef.h>
@ -12,8 +12,6 @@
#include "Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Forwards.h"
#include "Inventory.h"
#include "ItemContainer.h" #include "ItemContainer.h"
#include "Item.h" #include "Item.h"
#include "Framework.h" #include "Framework.h"

View file

@ -2,7 +2,7 @@
#define INVENTORY_H_ #define INVENTORY_H_
#include <map> #include <map>
#include <Common.h> #include <Common.h>
#include "../Forwards.h" #include "Forwards.h"
namespace Core namespace Core
{ {

View file

@ -5,7 +5,7 @@
#include <Common.h> #include <Common.h>
#include "../Forwards.h" #include "Forwards.h"
namespace Core namespace Core
{ {

View file

@ -4,8 +4,11 @@
#include <Network/CommonNetwork.h> #include <Network/CommonNetwork.h>
#include <Util/Util.h> #include <Util/Util.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Network/Acceptor.h>
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Network/GamePacketParser.h> #include <Network/GamePacketParser.h>
#include <Network/GamePacket.h>
#include "Zone/Zone.h" #include "Zone/Zone.h"
@ -13,8 +16,6 @@
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "GameConnection.h" #include "GameConnection.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Session.h" #include "Session.h"

View file

@ -2,9 +2,9 @@
#define GAMECONNECTION_H #define GAMECONNECTION_H
#include <Network/Connection.h> #include <Network/Connection.h>
#include <Network/Acceptor.h>
#include <Network/CommonNetwork.h> #include <Network/CommonNetwork.h>
#include <Network/GamePacket.h> //#include <Network/GamePacket.h>
#include <Util/LockedQueue.h> #include <Util/LockedQueue.h>
#include "Forwards.h" #include "Forwards.h"
@ -13,7 +13,9 @@
namespace Core { namespace Core {
namespace Network { namespace Network {
namespace Packets {
class GamePacket;
}
enum ConnectionType : uint8_t enum ConnectionType : uint8_t
{ {
Zone = 1, Zone = 1,

View file

@ -25,10 +25,6 @@
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Action/Action.h" #include "Action/Action.h"

View file

@ -15,9 +15,6 @@
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Actor/Player.h"
#include "Forwards.h"
#include "Framework.h" #include "Framework.h"
#include "Session.h" #include "Session.h"

View file

@ -19,14 +19,12 @@
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Actor/Player.h"
#include "Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Zone/InstanceContent.h" #include "Zone/InstanceContent.h"
#include "Session.h" #include "Session.h"
#include "Forwards.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -7,7 +7,6 @@
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <unordered_map> #include <unordered_map>
#include <boost/format.hpp>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
@ -16,9 +15,7 @@
#include "Zone/TerritoryMgr.h" #include "Zone/TerritoryMgr.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/InstanceContent.h" #include "Zone/InstanceContent.h"
#include "Zone/ZonePosition.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/PingPacket.h" #include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h" #include "Network/PacketWrappers/MoveActorPacket.h"
@ -31,20 +28,7 @@
#include "Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Event/EventHelper.h"
#include "Action/Action.h"
#include "Action/ActionTeleport.h"
#include "Session.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Forwards.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -17,11 +17,10 @@
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Session.h" #include "Session.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Forwards.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -7,10 +7,7 @@
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Network/PacketDef/Chat/ServerChatDef.h> #include <Network/PacketDef/Chat/ServerChatDef.h>
#include <Database/DatabaseDef.h> #include <Database/DatabaseDef.h>
#include <Database/DbWorkerPool.h>
#include <Database/CharaDbConnection.h>
#include <boost/format.hpp>
#include <unordered_map> #include <unordered_map>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
@ -32,10 +29,6 @@
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Action/Action.h" #include "Action/Action.h"
@ -55,9 +48,10 @@ using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket,
Entity::Player& player ) Entity::Player& player )
{ {
GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) ); // TODO: use new packet struct for this
pPe->setValAt< uint8_t >( 0x48, 0x01 ); //GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) );
queueOutPacket( pPe ); //pPe->setValAt< uint8_t >( 0x48, 0x01 );
//queueOutPacket( pPe );
} }
void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket,

View file

@ -18,8 +18,6 @@
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Action/Action.h" #include "Action/Action.h"
#include "Action/ActionCast.h" #include "Action/ActionCast.h"
#include "Action/ActionMount.h" #include "Action/ActionMount.h"
@ -27,7 +25,6 @@
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Session.h" #include "Session.h"
#include "Forwards.h"
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;

View file

@ -38,7 +38,7 @@ private:
m_data.gender = player.getLookAt( Common::CharaLook::Gender ); m_data.gender = player.getLookAt( Common::CharaLook::Gender );
m_data.currentClass = static_cast< uint8_t >( player.getClass() ); m_data.currentClass = static_cast< uint8_t >( player.getClass() );
m_data.currentJob = static_cast< uint8_t >( player.getClass() ); m_data.currentJob = static_cast< uint8_t >( player.getClass() );
m_data.currentLevel = player.getLevel(); m_data.maxLevel = player.getLevel();
m_data.deity = static_cast< uint8_t >( player.getGuardianDeity() ); m_data.deity = static_cast< uint8_t >( player.getGuardianDeity() );
m_data.namedayMonth = player.getBirthMonth(); m_data.namedayMonth = player.getBirthMonth();
m_data.namedayDay = player.getBirthDay(); m_data.namedayDay = player.getBirthDay();
@ -77,7 +77,7 @@ private:
// df stuff // df stuff
// todo: actually do this properly // todo: actually do this properly
m_data.unknown70[4] = 1; // enable df // m_data.unknown70[4] = 1; // enable df
// enable all raids/guildhests/dungeons // enable all raids/guildhests/dungeons
memset( m_data.unlockedDungeons, 0xFF, sizeof( m_data.unlockedDungeons ) ); memset( m_data.unlockedDungeons, 0xFF, sizeof( m_data.unlockedDungeons ) );

View file

@ -1,7 +1,7 @@
#include "ScriptLoader.h" #include "ScriptLoader.h"
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Config/XMLConfig.h> #include <Config/ConfigMgr.h>
#include "ServerZone.h" #include "ServerZone.h"
@ -53,7 +53,7 @@ bool Core::Scripting::ScriptLoader::unloadModule( ModuleHandle handle )
Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const std::string& path ) Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const std::string& path )
{ {
auto pLog = g_fw.get< Logger >(); auto pLog = g_fw.get< Logger >();
auto pConfig = g_fw.get< XMLConfig >(); auto pConfig = g_fw.get< ConfigMgr >();
fs::path f( path ); fs::path f( path );
if( isModuleLoaded( f.stem().string() ) ) if( isModuleLoaded( f.stem().string() ) )
@ -63,7 +63,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
} }
// copy to temp dir // copy to temp dir
fs::path cacheDir( f.parent_path() /= pConfig->getValue< std::string >( "Settings.General.Scripts.CachePath", "./cache/" ) ); fs::path cacheDir( f.parent_path() /= pConfig->getValue< std::string >( "Scripts.CachePath", "./cache/" ) );
fs::create_directories( cacheDir ); fs::create_directories( cacheDir );
fs::path dest( cacheDir /= f.filename().string() ); fs::path dest( cacheDir /= f.filename().string() );

View file

@ -6,7 +6,7 @@
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Config/XMLConfig.h> #include <Config/ConfigMgr.h>
#include "watchdog/Watchdog.h" #include "watchdog/Watchdog.h"
@ -51,10 +51,10 @@ void Core::Scripting::ScriptMgr::update()
bool Core::Scripting::ScriptMgr::init() bool Core::Scripting::ScriptMgr::init()
{ {
std::set< std::string > files; std::set< std::string > files;
auto pConfig = g_fw.get< XMLConfig >(); auto pConfig = g_fw.get< ConfigMgr >();
auto pLog = g_fw.get< Logger >(); auto pLog = g_fw.get< Logger >();
auto status = loadDir( pConfig->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ), auto status = loadDir( pConfig->getValue< std::string >( "Scripts.Path", "./compiledscripts/" ),
files, m_nativeScriptMgr->getModuleExtension() ); files, m_nativeScriptMgr->getModuleExtension() );
if( !status ) if( !status )
@ -85,12 +85,12 @@ bool Core::Scripting::ScriptMgr::init()
void Core::Scripting::ScriptMgr::watchDirectories() void Core::Scripting::ScriptMgr::watchDirectories()
{ {
auto pConfig = g_fw.get< XMLConfig >(); auto pConfig = g_fw.get< ConfigMgr >();
auto shouldWatch = pConfig->getValue< bool >( "Settings.General.Scripts.HotSwap.Enabled", true ); auto shouldWatch = pConfig->getValue< bool >( "Scripts.HotSwap", true );
if( !shouldWatch ) if( !shouldWatch )
return; return;
Watchdog::watchMany( pConfig->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ) + "*" + m_nativeScriptMgr->getModuleExtension(), Watchdog::watchMany( pConfig->getValue< std::string >( "Scripts.Path", "./compiledscripts/" ) + "*" + m_nativeScriptMgr->getModuleExtension(),
[ this ]( const std::vector< ci::fs::path >& paths ) [ this ]( const std::vector< ci::fs::path >& paths )
{ {
if( !m_firstScriptChangeNotificiation ) if( !m_firstScriptChangeNotificiation )

View file

@ -2,8 +2,7 @@
#include <Version.h> #include <Version.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Config/XMLConfig.h> #include <Config/ConfigMgr.h>
#include <Version.h>
#include <MySqlBase.h> #include <MySqlBase.h>
#include <Connection.h> #include <Connection.h>
@ -26,23 +25,20 @@
#include "Zone/TerritoryMgr.h" #include "Zone/TerritoryMgr.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Linkshell/LinkshellMgr.h" #include "Linkshell/LinkshellMgr.h"
#include "Forwards.h" #include "Forwards.h"
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/algorithm/string.hpp>
#include <thread> #include <thread>
#include "Framework.h" #include "Framework.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;
Core::ServerZone::ServerZone( const std::string& configPath ) : Core::ServerZone::ServerZone( const std::string& configName ) :
m_configPath( configPath ), m_configName( configName ),
m_bRunning( true ), m_bRunning( true ),
m_lastDBPingTime( 0 ) m_lastDBPingTime( 0 )
{ {
@ -60,15 +56,15 @@ size_t Core::ServerZone::getSessionCount() const
bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
{ {
auto pLog = g_fw.get< Core::Logger >(); auto pLog = g_fw.get< Core::Logger >();
auto pConfig = g_fw.get< Core::XMLConfig >(); auto pConfig = g_fw.get< Core::ConfigMgr >();
auto pExd = g_fw.get< Data::ExdDataGenerated >(); auto pExd = g_fw.get< Data::ExdDataGenerated >();
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
pLog->info( "Loading config " + m_configPath ); pLog->info( "Loading config " + m_configName );
if( !pConfig->loadConfig( m_configPath ) ) if( !pConfig->loadConfig( m_configName ) )
{ {
pLog->fatal( "Error loading config " + m_configPath ); pLog->fatal( "Error loading config " + m_configName );
return false; return false;
} }
@ -89,39 +85,35 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
if( arg == "ip" ) if( arg == "ip" )
{ {
// todo: ip addr in config // todo: ip addr in config
pConfig->setValue< std::string >( "Settings.General.ListenIP", val ); pConfig->setValue< std::string >( "GlobalNetwork.ZoneIP", val );
} }
else if( arg == "p" || arg == "port" ) else if( arg == "p" || arg == "port" )
{ {
pConfig->setValue< std::string >( "Settings.General.ListenPort", val ); pConfig->setValue< std::string >( "GlobalNetwork.ZonePort", val );
} }
else if( arg == "exdpath" || arg == "datapath" ) else if( arg == "exdpath" || arg == "datapath" )
{ {
pConfig->setValue< std::string >( "Settings.General.DataPath", val ); pConfig->setValue< std::string >( "GlobalParameters.DataPath", val );
}
else if( arg == "s" || arg == "scriptpath" )
{
pConfig->setValue< std::string >( "Settings.General.ScriptPath", val );
} }
else if( arg == "h" || arg == "dbhost" ) else if( arg == "h" || arg == "dbhost" )
{ {
pConfig->setValue< std::string >( "Settings.General.Mysql.Host", val ); pConfig->setValue< std::string >( "Database.Host", val );
} }
else if( arg == "dbport" ) else if( arg == "dbport" )
{ {
pConfig->setValue< std::string >( "Settings.General.Mysql.Port", val ); pConfig->setValue< std::string >( "Database.Port", val );
} }
else if( arg == "u" || arg == "user" || arg == "dbuser" ) else if( arg == "u" || arg == "user" || arg == "dbuser" )
{ {
pConfig->setValue< std::string >( "Settings.General.Mysql.Username", val ); pConfig->setValue< std::string >( "Database.Username", val );
} }
else if( arg == "pass" || arg == "dbpass" ) else if( arg == "pass" || arg == "dbpass" )
{ {
pConfig->setValue< std::string >( "Settings.General.Mysql.Pass", val ); pConfig->setValue< std::string >( "Database.Password", val );
} }
else if( arg == "d" || arg == "db" || arg == "database" ) else if( arg == "d" || arg == "db" || arg == "database" )
{ {
pConfig->setValue< std::string >( "Settings.General.Mysql.Database", val ); pConfig->setValue< std::string >( "Database.Database", val );
} }
} }
catch( ... ) catch( ... )
@ -132,7 +124,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
} }
pLog->info( "Setting up generated EXD data" ); pLog->info( "Setting up generated EXD data" );
if( !pExd->init( pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) if( !pExd->init( pConfig->getValue< std::string >( "GlobalParameters.DataPath", "" ) ) )
{ {
pLog->fatal( "Error setting up generated EXD data " ); pLog->fatal( "Error setting up generated EXD data " );
return false; return false;
@ -141,20 +133,20 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
Core::Db::DbLoader loader; Core::Db::DbLoader loader;
Core::Db::ConnectionInfo info; Core::Db::ConnectionInfo info;
info.password = pConfig->getValue< std::string >( "Settings.General.Mysql.Pass", "" ); info.password = pConfig->getValue< std::string >( "Database.Password", "" );
info.host = pConfig->getValue< std::string >( "Settings.General.Mysql.Host", "127.0.0.1" ); info.host = pConfig->getValue< std::string >( "Database.Host", "127.0.0.1" );
info.database = pConfig->getValue< std::string >( "Settings.General.Mysql.Database", "sapphire" ); info.database = pConfig->getValue< std::string >( "Database.Database", "sapphire" );
info.port = pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 ); info.port = pConfig->getValue< uint16_t >( "Database.Port", 3306 );
info.user = pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" ); info.user = pConfig->getValue< std::string >( "Database.Username", "root" );
info.syncThreads = pConfig->getValue< uint8_t >( "Settings.General.Mysql.SyncThreads", 2 ); info.syncThreads = pConfig->getValue< uint8_t >( "Database.SyncThreads", 2 );
info.asyncThreads = pConfig->getValue< uint8_t >( "Settings.General.Mysql.AsyncThreads", 2 ); info.asyncThreads = pConfig->getValue< uint8_t >( "Database.AsyncThreads", 2 );
loader.addDb( *pDb, info ); loader.addDb( *pDb, info );
if( !loader.initDbs() ) if( !loader.initDbs() )
return false; return false;
m_port = pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54992 ); m_port = pConfig->getValue< uint16_t >( "GlobalNetwork.ZonePort", 54992 );
m_ip = pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" ); m_ip = pConfig->getValue< std::string >( "GlobalNetwork.ZoneIP", "0.0.0.0" );
return true; return true;
} }
@ -335,15 +327,6 @@ void Core::ServerZone::removeSession( uint32_t sessionId )
m_sessionMapById.erase( sessionId ); m_sessionMapById.erase( sessionId );
} }
void Core::ServerZone::updateSession( uint32_t id )
{
std::lock_guard< std::mutex > lock( m_sessionMutex );
auto it = m_sessionMapById.find( id );
if( it != m_sessionMapById.end() )
it->second->loadPlayer();
}
Core::SessionPtr Core::ServerZone::getSession( uint32_t id ) Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
{ {
//std::lock_guard<std::mutex> lock( m_sessionMutex ); //std::lock_guard<std::mutex> lock( m_sessionMutex );
@ -373,14 +356,6 @@ void Core::ServerZone::removeSession( std::string playerName )
m_sessionMapByName.erase( playerName ); m_sessionMapByName.erase( playerName );
} }
void Core::ServerZone::updateSession( std::string playerName )
{
std::lock_guard< std::mutex > lock( m_sessionMutex );
auto it = m_sessionMapByName.find( playerName );
if( it != m_sessionMapByName.end() )
it->second->loadPlayer();
}
bool Core::ServerZone::isRunning() const bool Core::ServerZone::isRunning() const
{ {

View file

@ -14,7 +14,7 @@ namespace Core {
class ServerZone class ServerZone
{ {
public: public:
ServerZone( const std::string& configPath ); ServerZone( const std::string& configName );
~ServerZone(); ~ServerZone();
void run( int32_t argc, char* argv[] ); void run( int32_t argc, char* argv[] );
@ -27,8 +27,6 @@ namespace Core {
SessionPtr getSession( uint32_t id ); SessionPtr getSession( uint32_t id );
SessionPtr getSession( std::string playerName ); SessionPtr getSession( std::string playerName );
void updateSession( uint32_t id );
void updateSession( std::string playerName );
size_t getSessionCount() const; size_t getSessionCount() const;
@ -38,7 +36,6 @@ namespace Core {
void printBanner() const; void printBanner() const;
private: private:
uint16_t m_port; uint16_t m_port;
@ -47,7 +44,7 @@ namespace Core {
bool m_bRunning; bool m_bRunning;
std::string m_configPath; std::string m_configName;
std::mutex m_sessionMutex; std::mutex m_sessionMutex;

View file

@ -4,7 +4,6 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <Framework.h> #include <Framework.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Config/XMLConfig.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include <Database/CharaDbConnection.h> #include <Database/CharaDbConnection.h>
@ -13,34 +12,36 @@
#include "Zone/TerritoryMgr.h" #include "Zone/TerritoryMgr.h"
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include <Config/ConfigMgr.h>
Core::Framework g_fw; Core::Framework g_fw;
using namespace Core; using namespace Core;
bool setupFramework() bool setupFramework()
{ {
auto pServer = boost::make_shared< ServerZone >( "config/settings_zone.xml" ); auto pServer = boost::make_shared< ServerZone >( "zone.ini" );
auto pLogger = boost::make_shared< Logger >(); auto pLogger = boost::make_shared< Logger >();
auto pConfig = boost::make_shared< XMLConfig >();
auto pExdData = boost::make_shared< Data::ExdDataGenerated >(); auto pExdData = boost::make_shared< Data::ExdDataGenerated >();
auto pScript = boost::make_shared< Scripting::ScriptMgr >(); auto pScript = boost::make_shared< Scripting::ScriptMgr >();
auto pDb = boost::make_shared< Db::DbWorkerPool< Db::CharaDbConnection > >(); auto pDb = boost::make_shared< Db::DbWorkerPool< Db::CharaDbConnection > >();
auto pLsMgr = boost::make_shared< LinkshellMgr >(); auto pLsMgr = boost::make_shared< LinkshellMgr >();
auto pTeriMgr = boost::make_shared< TerritoryMgr >(); auto pTeriMgr = boost::make_shared< TerritoryMgr >();
auto pDebugCom = boost::make_shared< DebugCommandHandler >(); auto pDebugCom = boost::make_shared< DebugCommandHandler >();
auto pConfig = boost::make_shared< ConfigMgr >();
pLogger->setLogPath( "log/SapphireZone_" ); pLogger->setLogPath( "log/SapphireZone_" );
pLogger->init(); pLogger->init();
g_fw.set< ServerZone >( pServer ); g_fw.set< ServerZone >( pServer );
g_fw.set< Logger >( pLogger ); g_fw.set< Logger >( pLogger );
g_fw.set< XMLConfig >( pConfig );
g_fw.set< Data::ExdDataGenerated >( pExdData ); g_fw.set< Data::ExdDataGenerated >( pExdData );
g_fw.set< Scripting::ScriptMgr >( pScript ); g_fw.set< Scripting::ScriptMgr >( pScript );
g_fw.set< Db::DbWorkerPool< Db::CharaDbConnection > >( pDb ); g_fw.set< Db::DbWorkerPool< Db::CharaDbConnection > >( pDb );
g_fw.set< LinkshellMgr >( pLsMgr ); g_fw.set< LinkshellMgr >( pLsMgr );
g_fw.set< TerritoryMgr >( pTeriMgr ); g_fw.set< TerritoryMgr >( pTeriMgr );
g_fw.set< DebugCommandHandler >( pDebugCom ); g_fw.set< DebugCommandHandler >( pDebugCom );
g_fw.set< ConfigMgr >( pConfig );
// actuall catch errors here... // actuall catch errors here...
return true; return true;
@ -48,7 +49,6 @@ bool setupFramework()
int main( int32_t argc, char* argv[] ) int main( int32_t argc, char* argv[] )
{ {
if( !setupFramework() ) if( !setupFramework() )
return 0; // too fucking bad... return 0; // too fucking bad...

File diff suppressed because it is too large Load diff

View file

@ -25,14 +25,35 @@
#include <fstream> #include <fstream>
#include <streambuf> #include <streambuf>
#include <regex> #include <regex>
#include <boost/archive/iterators/ostream_iterator.hpp>
Core::Logger g_log; Core::Logger g_log;
Core::Data::ExdData g_exdData; Core::Data::ExdData g_exdData;
bool skipUnmapped = true; bool skipUnmapped = true;
std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" ); std::map< char, std::string > numberToStringMap
//std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" ); {
{ '0', "zero" },
{ '1', "one" },
{ '2', "two" },
{ '3', "three" },
{ '4', "four" },
{ '5', "five" },
{ '6', "six" },
{ '7', "seven" },
{ '8', "eight" },
{ '9', "nine" },
};
std::vector< std::string > cppKeyWords
{
"new",
"class"
};
//std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
std::map< uint8_t, std::string > g_typeMap; std::map< uint8_t, std::string > g_typeMap;
@ -180,6 +201,22 @@ std::string generateStruct( const std::string &exd )
} }
fieldName[0] = std::tolower( fieldName[0] ); fieldName[0] = std::tolower( fieldName[0] );
fieldName.erase( boost::remove_if( fieldName, boost::is_any_of(",-':![](){}<>% \x02\x1f\x01\x03") ), fieldName.end() ); fieldName.erase( boost::remove_if( fieldName, boost::is_any_of(",-':![](){}<>% \x02\x1f\x01\x03") ), fieldName.end() );
for( auto entry : numberToStringMap )
{
if( fieldName[0] == entry.first )
{
fieldName.erase( 0, 1 );
fieldName.insert( 0, entry.second );
}
}
for( std::string keyword : cppKeyWords )
{
if( fieldName == keyword )
fieldName[0] = toupper( fieldName[0] );
}
indexToNameMap[count] = fieldName; indexToNameMap[count] = fieldName;
indexToTypeMap[count] = type; indexToTypeMap[count] = type;
if( indexToTarget.find( count ) != indexToTarget.end() ) if( indexToTarget.find( count ) != indexToTarget.end() )

View file

@ -16,11 +16,12 @@
#include <DatCat.h> #include <DatCat.h>
#include <Exd/ExdData.h> #include <Exd/ExdData.h>
#include <Exd/ExdDataGenerated.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
Core::Logger g_log; Core::Logger g_log;
Core::Data::ExdData g_exdData; Core::Data::ExdDataGenerated g_exdDataGen;
const std::string onTalkStr( const std::string onTalkStr(
" void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n" " void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n"
@ -58,7 +59,7 @@ std::string titleCase( const std::string& str )
return retStr; return retStr;
} }
void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::set< std::string >& additionalList ) void createScript( boost::shared_ptr< Core::Data::Quest >& pQuestData, std::set< std::string >& additionalList, int questId )
{ {
std::string header( std::string header(
"// This is an automatically generated C++ script template\n" "// This is an automatically generated C++ script template\n"
@ -69,8 +70,8 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
"#include <ScriptObject.h>\n\n" "#include <ScriptObject.h>\n\n"
); );
std::size_t splitPos( pQuestData->name_intern.find( "_" ) ); std::size_t splitPos( pQuestData->id.find( "_" ) );
std::string className( pQuestData->name_intern.substr( 0, splitPos ) ); std::string className( pQuestData->id.substr( 0, splitPos ) );
//className = "Quest" + className; //className = "Quest" + className;
std::string sceneStr( " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n" ); std::string sceneStr( " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n" );
std::string seqStr; std::string seqStr;
@ -131,26 +132,26 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
std::string rewards; std::string rewards;
rewards.reserve( 0xFFF ); rewards.reserve( 0xFFF );
rewards += " // Quest rewards \n"; rewards += " // Quest rewards \n";
rewards += ( pQuestData->reward_exp_factor != 0 ) ? " static constexpr auto RewardExpFactor = " + std::to_string( pQuestData->reward_exp_factor ) + ";\n" : ""; rewards += ( pQuestData->expFactor != 0 ) ? " static constexpr auto RewardExpFactor = " + std::to_string( pQuestData->expFactor ) + ";\n" : "";
rewards += ( pQuestData->reward_gil != 0 ) ? " static constexpr auto RewardGil = " + std::to_string( pQuestData->reward_gil ) + ";\n" : ""; rewards += ( pQuestData->gilReward != 0 ) ? " static constexpr auto RewardGil = " + std::to_string( pQuestData->gilReward ) + ";\n" : "";
rewards += ( pQuestData->reward_emote != 0 ) ? " static constexpr auto RewardEmote = " + std::to_string( pQuestData->reward_emote ) + ";\n" : ""; rewards += ( pQuestData->emoteReward != 0 ) ? " static constexpr auto RewardEmote = " + std::to_string( pQuestData->emoteReward ) + ";\n" : "";
rewards += ( pQuestData->reward_action != 0 ) ? " static constexpr auto RewardAction = " + std::to_string( pQuestData->reward_action ) + ";\n" : ""; rewards += ( pQuestData->actionReward != 0 ) ? " static constexpr auto RewardAction = " + std::to_string( pQuestData->actionReward ) + ";\n" : "";
rewards += ( pQuestData->reward_action_general1 != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + std::to_string( pQuestData->reward_action_general1 ) + ";\n" : ""; rewards += ( pQuestData->generalActionReward[0] != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + std::to_string( pQuestData->generalActionReward[0] ) + ";\n" : "";
rewards += ( pQuestData->reward_action_general2 != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + std::to_string( pQuestData->reward_action_general2 ) + ";\n" : ""; rewards += ( pQuestData->generalActionReward[1] != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + std::to_string( pQuestData->generalActionReward[1] ) + ";\n" : "";
rewards += ( pQuestData->reward_gc_seals != 0 ) ? " static constexpr auto RewardGCSeals = " + std::to_string( pQuestData->reward_gc_seals ) + ";\n" : ""; rewards += ( pQuestData->gCSeals != 0 ) ? " static constexpr auto RewardGCSeals = " + std::to_string( pQuestData->gCSeals ) + ";\n" : "";
rewards += ( pQuestData->reward_other != 0 ) ? " static constexpr auto RewardOther = " + std::to_string( pQuestData->reward_other ) + ";\n" : ""; rewards += ( pQuestData->otherReward != 0 ) ? " static constexpr auto RewardOther = " + std::to_string( pQuestData->otherReward ) + ";\n" : "";
rewards += ( pQuestData->reward_reputation != 0 ) ? " static constexpr auto RewardReputation = " + std::to_string( pQuestData->reward_reputation ) + ";\n" : ""; rewards += ( pQuestData->reputationReward != 0 ) ? " static constexpr auto RewardReputation = " + std::to_string( pQuestData->reputationReward ) + ";\n" : "";
rewards += ( pQuestData->reward_tome_type != 0 ) ? " static constexpr auto RewardTomeType = " + std::to_string( pQuestData->reward_tome_type ) + ";\n" : ""; rewards += ( pQuestData->tomestoneReward != 0 ) ? " static constexpr auto RewardTomeType = " + std::to_string( pQuestData->tomestoneReward ) + ";\n" : "";
rewards += ( pQuestData->reward_tome_count != 0 ) ? " static constexpr auto RewardTomeCount = " + std::to_string( pQuestData->reward_tome_count ) + ";\n" : ""; rewards += ( pQuestData->tomestoneCountReward != 0 ) ? " static constexpr auto RewardTomeCount = " + std::to_string( pQuestData->tomestoneCountReward ) + ";\n" : "";
rewards += ( pQuestData->instanced_content_unlock != 0 ) ? " static constexpr auto InstancedContentUnlock = " + std::to_string( pQuestData->instanced_content_unlock ) + ";\n" : ""; rewards += ( pQuestData->instanceContentUnlock != 0 ) ? " static constexpr auto InstancedContentUnlock = " + std::to_string( pQuestData->instanceContentUnlock ) + ";\n" : "";
if( pQuestData->reward_item.size() > 0 ) if( !pQuestData->itemReward0.empty() )
{ {
rewards += " static constexpr auto RewardItem[] = { "; rewards += " static constexpr auto RewardItem[] = { ";
for( size_t ca = 0; ca < pQuestData->reward_item.size(); ca++ ) for( size_t ca = 0; ca < pQuestData->itemReward0.size(); ca++ )
{ {
rewards += std::to_string( pQuestData->reward_item.at( ca ) ); rewards += std::to_string( pQuestData->itemReward0.at( ca ) );
if( ca != pQuestData->reward_item.size() - 1 ) if( ca != pQuestData->itemReward0.size() - 1 )
{ {
rewards += ", "; rewards += ", ";
} }
@ -158,13 +159,13 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
rewards += " };\n"; rewards += " };\n";
} }
if( pQuestData->reward_item.size() > 0 ) if( !pQuestData->itemReward0.empty() )
{ {
rewards += " static constexpr auto RewardItemCount[] = { "; rewards += " static constexpr auto RewardItemCount[] = { ";
for( size_t ca = 0; ca < pQuestData->reward_item_count.size(); ca++ ) for( size_t ca = 0; ca < pQuestData->itemCountReward0.size(); ca++ )
{ {
rewards += std::to_string( pQuestData->reward_item_count.at( ca ) ); rewards += std::to_string( pQuestData->itemCountReward0.at( ca ) );
if( ca != pQuestData->reward_item_count.size() - 1 ) if( ca != pQuestData->itemCountReward0.size() - 1 )
{ {
rewards += ", "; rewards += ", ";
} }
@ -172,13 +173,13 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
rewards += " };\n"; rewards += " };\n";
} }
if( pQuestData->reward_item_optional.size() > 0 ) if( !pQuestData->itemReward1.empty() )
{ {
rewards += " static constexpr auto RewardItemOptional[] = { "; rewards += " static constexpr auto RewardItemOptional[] = { ";
for( size_t ca = 0; ca < pQuestData->reward_item_optional.size(); ca++ ) for( size_t ca = 0; ca < pQuestData->itemReward1.size(); ca++ )
{ {
rewards += std::to_string( pQuestData->reward_item_optional.at( ca ) ); rewards += std::to_string( pQuestData->itemReward1.at( ca ) );
if( ca != pQuestData->reward_item_optional.size() - 1 ) if( ca != pQuestData->itemReward1.size() - 1 )
{ {
rewards += ", "; rewards += ", ";
} }
@ -186,13 +187,13 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
rewards += " };\n"; rewards += " };\n";
} }
if( pQuestData->reward_item_optional_count.size() > 0 ) if( !pQuestData->itemCountReward1.empty() )
{ {
rewards += " static constexpr auto RewardItemOptionalCount[] = { "; rewards += " static constexpr auto RewardItemOptionalCount[] = { ";
for( size_t ca = 0; ca < pQuestData->reward_item_optional_count.size(); ca++ ) for( size_t ca = 0; ca < pQuestData->itemCountReward1.size(); ca++ )
{ {
rewards += std::to_string( pQuestData->reward_item_optional_count.at( ca ) ); rewards += std::to_string( pQuestData->itemCountReward1.at( ca ) );
if( ca != pQuestData->reward_item_optional_count.size() - 1 ) if( ca != pQuestData->itemCountReward1.size() - 1 )
{ {
rewards += ", "; rewards += ", ";
} }
@ -207,21 +208,22 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
std::vector< std::string > script_entities; std::vector< std::string > script_entities;
std::string sentities = " // Entities found in the script data of the quest\n"; std::string sentities = " // Entities found in the script data of the quest\n";
for( size_t ca = 0; ca < pQuestData->script_entity.size(); ca ++ ) for( size_t ca = 0; ca < pQuestData->scriptInstruction.size(); ca ++ )
{ {
if( ( pQuestData->script_entity.at( ca ).find( "HOWTO" ) != std::string::npos ) || ( pQuestData->script_entity.at( ca ).find( "HOW_TO" ) != std::string::npos ) ) if( ( pQuestData->scriptInstruction.at( ca ).find( "HOWTO" ) != std::string::npos ) || ( pQuestData->scriptInstruction.at( ca ).find( "HOW_TO" ) != std::string::npos ) )
continue; continue;
if( ( pQuestData->script_entity.at( ca ).find( "EMOTENO" ) != std::string::npos ) || ( pQuestData->script_entity.at( ca ).find( "EMOTEOK" ) != std::string::npos ) ) if( ( pQuestData->scriptInstruction.at( ca ).find( "EMOTENO" ) != std::string::npos ) || ( pQuestData->scriptInstruction.at( ca ).find( "EMOTEOK" ) != std::string::npos ) )
hasEmote = true; hasEmote = true;
if( pQuestData->script_entity.at( ca ).find( "ENEMY" ) != std::string::npos ) if( pQuestData->scriptInstruction.at( ca ).find( "ENEMY" ) != std::string::npos )
{ {
hasEnemies = true; hasEnemies = true;
enemy_ids.push_back( pQuestData->script_value.at( ca ) ); enemy_ids.push_back( pQuestData->scriptArg.at( ca ) );
} }
script_entities.push_back( pQuestData->script_entity.at( ca ) + " = " + std::to_string( pQuestData->script_value.at( ca ) ) ); if( !pQuestData->scriptInstruction.at( ca ).empty() )
script_entities.push_back( pQuestData->scriptInstruction.at( ca ) + " = " + std::to_string( pQuestData->scriptArg.at( ca ) ) );
} }
std::sort( script_entities.begin(), script_entities.end() ); std::sort( script_entities.begin(), script_entities.end() );
for( auto& entity : script_entities ) for( auto& entity : script_entities )
@ -231,11 +233,11 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
sentities += " static constexpr auto " + name + ";\n"; sentities += " static constexpr auto " + name + ";\n";
} }
std::string additional = "// Quest Script: " + pQuestData->name_intern + "\n"; std::string additional = "// Quest Script: " + pQuestData->id + "\n";
additional += "// Quest Name: " + pQuestData->name + "\n"; additional += "// Quest Name: " + pQuestData->name + "\n";
additional += "// Quest ID: " + std::to_string( pQuestData->id ) + "\n"; additional += "// Quest ID: " + std::to_string( questId ) + "\n";
additional += "// Start NPC: " + std::to_string( pQuestData->enpc_resident_start ) + "\n"; additional += "// Start NPC: " + std::to_string( pQuestData->eNpcResidentStart ) + "\n";
additional += "// End NPC: " + std::to_string( pQuestData->enpc_resident_end ) + "\n\n"; additional += "// End NPC: " + std::to_string( pQuestData->eNpcResidentEnd ) + "\n\n";
std::string scriptEntry; std::string scriptEntry;
scriptEntry.reserve(0xFFFF); scriptEntry.reserve(0xFFFF);
@ -271,7 +273,7 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
constructor += rewards + "\n"; constructor += rewards + "\n";
constructor += sentities + "\n"; constructor += sentities + "\n";
constructor += " public:\n"; constructor += " public:\n";
constructor += " " + className + "() : EventScript" + "( " + std::to_string( pQuestData->id ) + " ){}; \n"; constructor += " " + className + "() : EventScript" + "( " + std::to_string( questId ) + " ){}; \n";
constructor += " ~" + className + "(){}; \n"; constructor += " ~" + className + "(){}; \n";
std::string classString( std::string classString(
@ -287,7 +289,7 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
std::ofstream outputFile; std::ofstream outputFile;
outputFile.open( "generated/" + className + ".cpp_generated" ); outputFile.open( "generated/" + className + ".cpp" );
outputFile << header << additional << classString; outputFile << header << additional << classString;
outputFile.close(); outputFile.close();
} }
@ -308,8 +310,8 @@ int main( int argc, char** argv )
unluac = true; unluac = true;
g_log.info( "Setting up EXD data" ); g_log.info( "Setting up generated EXD data" );
if( !g_exdData.init( datLocation ) ) if( !g_exdDataGen.init( datLocation ) )
{ {
std::cout << datLocation << "\n"; std::cout << datLocation << "\n";
g_log.fatal( "Error setting up EXD data " ); g_log.fatal( "Error setting up EXD data " );
@ -318,33 +320,33 @@ int main( int argc, char** argv )
} }
xiv::dat::GameData data( datLocation ); xiv::dat::GameData data( datLocation );
xiv::exd::ExdData eData( data );
auto QuestDat = g_exdData.setupDatAccess( "Quest", xiv::exd::Language::en ); auto rows = g_exdDataGen.getQuestIdList();
auto rows = QuestDat.get_rows();
if ( !boost::filesystem::exists( "./generated" ) ) if ( !boost::filesystem::exists( "./generated" ) )
boost::filesystem::create_directory( "./generated" ); boost::filesystem::create_directory( "./generated" );
std::cout << "Export in progress"; g_log.info( "Export in progress" );
uint32_t updateInterval = rows.size() / 20; uint32_t updateInterval = rows.size() / 20;
uint32_t i = 0; uint32_t i = 0;
for( const auto& row : rows ) for( const auto& row : rows )
{ {
auto questInfo = g_exdData.getQuestInfo( row.first ); g_log.info( "Generating " + std::to_string( row ) );
auto questInfo = g_exdDataGen.get<Core::Data::Quest>( row );
if( questInfo->name.empty() || questInfo->name_intern.empty() ) if( questInfo->name.empty() || questInfo->id.empty() )
{ {
continue; continue;
} }
size_t pos_seperator = questInfo->name_intern.find_first_of( "_" ); size_t pos_seperator = questInfo->id.find_first_of( "_" );
std::string folder; std::string folder;
if( pos_seperator != std::string::npos ) if( pos_seperator != std::string::npos )
{ {
folder = questInfo->name_intern.substr( pos_seperator + 1, 3 ); folder = questInfo->id.substr( pos_seperator + 1, 3 );
} }
else else
{ {
@ -355,7 +357,7 @@ int main( int argc, char** argv )
const xiv::dat::Cat& test = data.getCategory( "game_script" ); const xiv::dat::Cat& test = data.getCategory( "game_script" );
const std::string questPath = "game_script/quest/" + folder + "/" + questInfo->name_intern + ".luab"; const std::string questPath = "game_script/quest/" + folder + "/" + questInfo->id + ".luab";
const auto &test_file = data.getFile( questPath ); const auto &test_file = data.getFile( questPath );
auto &section = test_file->access_data_sections().at( 0 ); auto &section = test_file->access_data_sections().at( 0 );
@ -366,12 +368,12 @@ int main( int argc, char** argv )
uint32_t offset = 0; uint32_t offset = 0;
std::ofstream outputFile1; std::ofstream outputFile1;
outputFile1.open( "generated/" + questInfo->name_intern + ".luab", std::ios::binary ); outputFile1.open( "generated/" + questInfo->id + ".luab", std::ios::binary );
outputFile1.write( &section[0], section.size() ); outputFile1.write( &section[0], section.size() );
outputFile1.close(); outputFile1.close();
if( unluac ) if( unluac )
{ {
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->id + ".luab" + ">> " + "generated/" + questInfo->id + ".lua";
if ( system( command.c_str() ) == -1 ) if ( system( command.c_str() ) == -1 )
{ {
g_log.error( "Error executing java command:\n" + command + "\nerrno: " + std::strerror( errno ) ); g_log.error( "Error executing java command:\n" + command + "\nerrno: " + std::strerror( errno ) );
@ -402,7 +404,7 @@ int main( int argc, char** argv )
} }
createScript( questInfo, stringList ); createScript( questInfo, stringList, row );
++i; ++i;
if( i % updateInterval == 0 ) if( i % updateInterval == 0 )
std::cout << "."; std::cout << ".";