1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-30 05:07:46 +00:00

Merge master

This commit is contained in:
Maru 2018-06-03 15:29:32 -03:00
commit ec6729ebbd
42 changed files with 298 additions and 426 deletions

View file

@ -1,6 +1,3 @@
/**
* Structural definitions common to all FFXIV:ARR packets.
*/
#ifndef _CORE_NETWORK_PACKETS_COMMON_H
#define _CORE_NETWORK_PACKETS_COMMON_H
@ -25,7 +22,7 @@ namespace Packets {
*
* std::stringstream buf;
* buf << pkt_hdr;
* for (int i = 0; i < n; i++)
* for( int i = 0; i < n; i++ )
* {
* buf << pkt_seg_hdr[i];
* buf << {pkt_seg_data[i]};
@ -46,6 +43,8 @@ namespace Packets {
*
* 0 4 8 12 14 16
* +-------------------------------+---------------+-------+-------+
* | unknown_0 | unknown_8 |
* +-------------------------------+---------------+-------+-------+
* | timestamp | size | cType | count |
* +---+---+-------+---------------+---------------+-------+-------+
* | ? |CMP| ? | ? |
@ -54,13 +53,10 @@ namespace Packets {
*/
struct FFXIVARR_PACKET_HEADER
{
/** Unknown data, no actual use has been determined */
uint64_t unknown_0;
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;
/** The size of the packet header and its payload */
uint32_t size;
@ -74,14 +70,14 @@ struct FFXIVARR_PACKET_HEADER
uint32_t unknown_24;
};
inline ostream& operator<<(ostream& os, const FFXIVARR_PACKET_HEADER& hdr)
inline ostream& operator << ( ostream& os, const FFXIVARR_PACKET_HEADER& hdr )
{
return os.write(reinterpret_cast<const char*>(&hdr), sizeof hdr);
return os.write( reinterpret_cast< const char* >( &hdr ), sizeof hdr );
}
inline istream& operator>>(istream& is, FFXIVARR_PACKET_HEADER& hdr)
inline istream& operator >> ( istream& is, FFXIVARR_PACKET_HEADER& hdr )
{
return is.read(reinterpret_cast<char*>(&hdr), sizeof hdr);
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
}
/**
@ -92,7 +88,7 @@ inline istream& operator>>(istream& is, FFXIVARR_PACKET_HEADER& hdr)
*
* 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 :
@ -109,22 +105,20 @@ struct FFXIVARR_PACKET_SEGMENT_HEADER
uint32_t target_actor;
/** The segment type. (1, 2, 3, 7, 8, 9, 10) */
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 )
{
return os.write(reinterpret_cast<const char*>(&hdr), sizeof hdr);
return os.write( reinterpret_cast< const char* >( &hdr ), sizeof hdr );
}
inline istream& operator>>(istream& is, FFXIVARR_PACKET_SEGMENT_HEADER& hdr)
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 */
enum { _ServerIpcType = T };
@ -133,7 +127,7 @@ template <int T> struct FFXIVIpcBasePacket
struct FFXIVARR_PACKET_RAW
{
FFXIVARR_PACKET_SEGMENT_HEADER segHdr;
std::vector<uint8_t> data;
std::vector< uint8_t > data;
};
/**
@ -142,7 +136,7 @@ struct FFXIVARR_PACKET_RAW
*
* 0 4 6 8 12 16
* +-------+-------+------+----------+---------------+---------------+
* | 14 00 | type | ?? | serverId | timestamp | ??? |
* | 14 00 | type | pad | serverId | timestamp | pad1 |
* +-------+-------+------+----------+---------------+---------------+
* | |
* : data :
@ -153,24 +147,22 @@ struct FFXIVARR_IPC_HEADER
{
uint16_t reserved;
uint16_t type;
uint16_t unknown_2;
uint16_t padding;
uint16_t serverId;
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 )
{
return os.write(reinterpret_cast<const char*>(&hdr), sizeof hdr);
return os.write( reinterpret_cast< const char* >( &hdr ), sizeof hdr );
}
inline istream& operator>>(istream& is, FFXIVARR_IPC_HEADER& hdr)
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 */
} /* Network */
} /* Core */

View file

@ -23,7 +23,7 @@ void Core::Network::Packets::GamePacket::setHeader( uint16_t size, uint16_t type
m_segHdr.type = type;
m_segHdr.source_actor = id1;
m_segHdr.target_actor = id2;
m_segHdr._reserved_E = 0x00;
//m_segHdr._reserved_E = 0x00;
m_subType = subType;
m_timeStamp = static_cast< uint32_t >( time( nullptr ) );
@ -88,7 +88,7 @@ Core::Network::Packets::GamePacket::~GamePacket()
void Core::Network::Packets::GamePacket::savePacket()
{
char filename[20];
sprintf( filename, "dump_0x%x.dat", m_subType );
sprintf( filename, "dump_0x%x_%i.dat", m_subType, Util::getTimeMs() );
FILE * fp = nullptr;
fp = fopen( filename, "wb" );
fwrite( &m_dataBuf[0], 1, m_segHdr.size, fp );

View file

@ -16,11 +16,11 @@ namespace Packets {
// Must forward define these in order to enable the compiler to produce the
// correct template functions.
template <typename T, typename T1>
template < typename T, typename T1 >
class GamePacketNew;
template <typename T, typename T1>
std::ostream& operator<< ( std::ostream& os, const GamePacketNew<T, T1>& packet );
template < typename T, typename T1 >
std::ostream& operator<< ( std::ostream& os, const GamePacketNew< T, T1 >& packet );
template< class T >
using ZoneChannelPacket = GamePacketNew< T, ServerZoneIpcType >;
@ -31,11 +31,11 @@ using ChatChannelPacket = GamePacketNew< T, ServerChatIpcType >;
/**
* The base implementation of a game packet. Needed for parsing packets.
*/
template <typename T1>
class GamePacketNewBase
template < typename T1 >
class FFXIVPacketBase
{
public:
virtual ~GamePacketNewBase() = default;
virtual ~FFXIVPacketBase() = default;
/**
* @brief Gets the IPC type of this packet. (Useful for determining the
* type of a parsed packet.)
@ -49,8 +49,8 @@ public:
* type that represents just the IPC data portion (the bytes after the initial
* 32 byte header information.)
*/
template <typename T, typename T1>
class GamePacketNew : public GamePacketNewBase<T1>
template < typename T, typename T1 >
class GamePacketNew : public FFXIVPacketBase< T1 >
{
public:
/**
@ -58,7 +58,7 @@ public:
* @param sourceActorId The source actor id.
* @param targetActorId The target actor id.
*/
GamePacketNew<T, T1>( uint32_t sourceActorId, uint32_t targetActorId )
GamePacketNew< T, T1 >( uint32_t sourceActorId, uint32_t targetActorId )
{
initialize();
m_segHdr.source_actor = sourceActorId;
@ -69,7 +69,7 @@ public:
* @brief Constructs a new game packet with the specified actors.
* @param sourceActorId The source and target actor id.
*/
GamePacketNew<T, T1>( uint32_t bothActorId )
GamePacketNew< T, T1 >( uint32_t bothActorId )
{
initialize();
m_segHdr.source_actor = bothActorId;
@ -109,7 +109,7 @@ public:
* @param actorId The source actor id.
* @return This IPC packet object (can be used for chaining).
*/
GamePacketNew<T, T1> sourceActor( uint32_t actorId )
GamePacketNew< T, T1 > sourceActor( uint32_t actorId )
{
m_segHdr.source_actor = actorId;
return this;
@ -129,7 +129,7 @@ public:
* @param actorId The target actor id.
* @return This IPC packet object (can be used for chaining).
*/
GamePacketNew<T, T1> targetActor( uint32_t actorId )
GamePacketNew< T, T1 > targetActor( uint32_t actorId )
{
m_segHdr.target_actor = actorId;
return this;
@ -144,7 +144,7 @@ public:
return m_segHdr.target_actor;
};
friend std::ostream& operator<< <> ( std::ostream& os, const GamePacketNew<T, T1>& packet );
friend std::ostream& operator<< <> ( std::ostream& os, const GamePacketNew< T, T1 >& packet );
friend class GamePacketFactory;
@ -205,7 +205,7 @@ private:
};
};
template <typename T, typename T1>
template < typename T, typename T1 >
std::ostream& operator<<( std::ostream& os, const GamePacketNew<T, T1>& packet )
{
#if 0

View file

@ -11,80 +11,67 @@ namespace Core
{
namespace Packets
{
PacketParseResult getHeader(
const std::vector< uint8_t > &buffer,
const uint32_t offset,
FFXIVARR_PACKET_HEADER &header)
PacketParseResult getHeader( const std::vector< uint8_t > &buffer,
const uint32_t offset,
FFXIVARR_PACKET_HEADER &header )
{
const auto headerSize = sizeof( FFXIVARR_PACKET_HEADER );
// Check if we have enough bytes in the buffer.
auto remainingBytes = buffer.size() - offset;
if ( remainingBytes < headerSize )
{
if( remainingBytes < headerSize )
return Incomplete;
}
// Copy packet header.
memcpy( &header, buffer.data() + offset, headerSize );
if ( !checkHeader(header) )
{
if( !checkHeader(header) )
return Malformed;
}
return Success;
}
PacketParseResult getSegmentHeader(
const std::vector< uint8_t > &buffer,
const uint32_t offset,
FFXIVARR_PACKET_SEGMENT_HEADER &header)
PacketParseResult getSegmentHeader( const std::vector< uint8_t > &buffer,
const uint32_t offset,
FFXIVARR_PACKET_SEGMENT_HEADER &header )
{
const auto headerSize = sizeof( FFXIVARR_PACKET_SEGMENT_HEADER );
// Check if we have enough bytes in the buffer.
auto remainingBytes = buffer.size() - offset;
if (remainingBytes < headerSize)
{
if( remainingBytes < headerSize )
return Incomplete;
}
// Copy segment header
memcpy(&header, buffer.data() + offset, headerSize);
memcpy( &header, buffer.data() + offset, headerSize );
return Success;
}
PacketParseResult getPackets(
const std::vector< uint8_t > &buffer,
const uint32_t offset,
const FFXIVARR_PACKET_HEADER &packetHeader,
std::vector< FFXIVARR_PACKET_RAW > &packets)
PacketParseResult getPackets( const std::vector< uint8_t > &buffer,
const uint32_t offset,
const FFXIVARR_PACKET_HEADER &packetHeader,
std::vector< FFXIVARR_PACKET_RAW > &packets )
{
// sanity check: check there's enough bytes in the buffer
const auto bytesExpected = packetHeader.size - sizeof(struct FFXIVARR_PACKET_HEADER);
if ( buffer.size() - offset < bytesExpected )
{
const auto bytesExpected = packetHeader.size - sizeof( struct FFXIVARR_PACKET_HEADER );
if( buffer.size() - offset < bytesExpected )
return Incomplete;
}
// Loop each message
uint32_t count = 0;
uint32_t bytesProcessed = 0;
while ( count < packetHeader.count )
while( count < packetHeader.count )
{
FFXIVARR_PACKET_RAW rawPacket;
// Copy ipc packet message
const auto packetResult = getPacket(buffer, offset + bytesProcessed, rawPacket);
if ( packetResult != Success )
{
const auto packetResult = getPacket( buffer, offset + bytesProcessed, rawPacket );
if( packetResult != Success )
return packetResult;
}
// NOTE: isn't rawPacket is allocated on stack?
// why is okay to do this?
// why is okay to do this?
packets.push_back( rawPacket );
// Add message size and count
@ -94,34 +81,25 @@ namespace Core
// 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.
if ( bytesExpected != bytesProcessed )
{
if( bytesExpected != bytesProcessed )
return Malformed;
}
return Success;
}
PacketParseResult getPacket(
const std::vector< uint8_t > &buffer,
const uint32_t offset,
FFXIVARR_PACKET_RAW &packet
)
PacketParseResult getPacket( const std::vector< uint8_t > &buffer, const uint32_t offset,
FFXIVARR_PACKET_RAW &packet )
{
// Copy segment header
const auto headerResult = getSegmentHeader(buffer, offset, packet.segHdr);
if ( headerResult != Success )
{
const auto headerResult = getSegmentHeader( buffer, offset, packet.segHdr );
if( headerResult != Success )
return headerResult;
}
// Check header sanity and it's size
if ( !checkSegmentHeader( packet.segHdr ) )
{
if( !checkSegmentHeader( packet.segHdr ) )
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;
// Allocate data buffer and copy
@ -131,30 +109,24 @@ namespace Core
return Success;
}
bool checkHeader(const FFXIVARR_PACKET_HEADER &header)
bool checkHeader( const FFXIVARR_PACKET_HEADER &header )
{
// 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;
}
// Max number of message is capped at 255 for now.
if ( header.count > 255 )
{
if( header.count > 255 )
return false;
}
return true;
}
bool checkSegmentHeader(const FFXIVARR_PACKET_SEGMENT_HEADER &header)
bool checkSegmentHeader( const FFXIVARR_PACKET_SEGMENT_HEADER &header )
{
// Max size of individual message is capped at 256KB for now.
if ( header.size > 256 * 1024 )
{
if( header.size > 256 * 1024 )
return false;
}
return true;
}

View file

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

View file

@ -16,14 +16,14 @@ class GamePacket;
class PacketContainer
{
public:
PacketContainer( void );
~PacketContainer( void );
PacketContainer();
~PacketContainer();
void addPacket( GamePacket pEntry );
FFXIVARR_PACKET_HEADER m_ipcHdr;
std::vector<GamePacket> m_entryList;
std::vector< GamePacket > m_entryList;
std::string toString();

View file

@ -45,11 +45,10 @@ namespace Packets {
enum ServerZoneIpcType : uint16_t
{
// static opcode ( the ones that rarely if ever change )
// static opcode ( the ones that rarely, if ever, change )
Ping = 0x0065,
Init = 0x0066,
//ActorSpawn = 0x0190, // DEPRECATED
ActorFreeSpawn = 0x0191,
InitZone = 0x019A,
@ -71,6 +70,7 @@ namespace Packets {
Playtime = 0x00DF, // updated 4.2
CFRegistered = 0x00B8, // updated 4.1
CancelAllianceForming = 0x00C6, // updated 4.2
Chat = 0x00F7, // updated 4.3
SocialList = 0x00FD, // updated 4.3
@ -83,12 +83,13 @@ namespace Packets {
CountdownInitiate = 0x0111, // updated 4.3
CountdownCancel = 0x0112, // updated 4.3
BlackList = 0x00FF, // updated 4.2
BlackList = 0x0115, // updated 4.3
LogMessage = 0x00D0,
LinkshellList = 0x0106, // updated 4.2
SetCharacterFCInfo = 0x0114, // updated 4.2
LinkshellList = 0x011C, // updated 4.3
SetCharaFCTag = 0x013B, // updated 4.3
SetFreeCompanyInfo = 0x013D, // updated 4.3
StatusEffectList = 0x014E, // updated 4.3
Effect = 0x0151, // updated 4.3
@ -107,7 +108,8 @@ namespace Packets {
ObjectSpawn = 0x017D, // updated 4.3
ObjectDespawn = 0x017E, // updated 4.3
UpdateClassInfo = 0x018A, // updated 4.3
InventoryActionAck = 0x0180, // updated 4.2 ?
InitUI = 0x0181, // updated 4.3
PlayerStats = 0x0182, // updated 4.3
@ -116,13 +118,14 @@ namespace Packets {
PlayerClassInfo = 0x0185, // updated 4.3
ModelEquip = 0x0186, // updated 4.3
UpdateClassInfo = 0x018A, // updated 4.3
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
InventoryActionAck = 0x0180, // updated 4.2 ?
UpdateInventorySlot = 0x0198, // updated 4.3
EventPlay = 0x01A6, // updated 4.3
@ -133,21 +136,24 @@ namespace Packets {
EventLinkshell = 0x1169,
QuestMessage = 0x01CE, // updated 4.3
QuestTracker = 0x01D3, // updated 4.3
QuestActiveList = 0x01C3, // updated 4.3
QuestUpdate = 0x01C4, // updated 4.3
QuestCompleteList = 0x01C5, // updated 4.3
QuestFinish = 0x01C6, // updated 4.3
MSQTrackerComplete = 0x01C7, // updated 4.3
MSQTrackerProgress = 0x01C8, // updated 4.3
QuestActiveList = 0x01C3, // updated 4.3
QuestUpdate = 0x01C4, // updated 4.3
QuestCompleteList = 0x01C5, // updated 4.3
QuestMessage = 0x01CE, // updated 4.3
QuestTracker = 0x01D3, // updated 4.3
Mount = 0x01E3, // updated 4.3
DirectorVars = 0x01E5, // updated 4.3
CFAvailableContents = 0x01FD, // updated 4.2
WeatherChange = 0x0200, // updated 4.3
PlayerTitleList = 0x0201, // updated 4.3
Discovery = 0x0202, // updated 4.3
@ -156,13 +162,13 @@ namespace Packets {
EquipDisplayFlags = 0x0210, // updated 4.3
CFAvailableContents = 0x01FD, // updated 4.2
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.3
// Unknown IPC types that still need to be sent
// TODO: figure all these out properly
@ -171,8 +177,6 @@ namespace Packets {
};
// TODO: Include structures for the individual packet segment types
/**
* Client IPC Zone Type Codes.
*/
@ -195,8 +199,8 @@ namespace Packets {
CFDutyInfoHandler = 0x0078, // updated 4.2
SocialReqSendHandler = 0x00CA, // updated 4.2
SocialReqProcessHandler = 0x00CC, // updated 4.2
SocialReqSendHandler = 0x00AE, // updated 4.1
CreateCrossWorldLS = 0x00AF, // updated 4.3
ChatHandler = 0x00D3, // updated 4.3

View file

@ -660,113 +660,108 @@ struct FFXIVIpcInitZone : FFXIVIpcBasePacket<InitZone>
*/
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;
uint32_t unknown8;
uint32_t unknownC;
uint32_t charId;
uint32_t restedExp;
uint32_t companionCurrentExp;
uint32_t unknown3C;
uint32_t fishCaught;
uint32_t useBaitCatalogId;
uint32_t pvpWolfFoldMatches;
uint16_t pvpWolfFoldWeeklyMatches;
uint16_t pvpWolfFoldWeeklyVictories;
uint16_t pvpStats[6];
uint16_t playerCommendations;
uint16_t pvpStats1;
uint8_t frontlineCampaigns[4];
uint16_t frontlineCampaigns[4];
uint16_t frontlineCampaignsWeekly;
uint8_t currentRelic;
uint8_t currentBook;
uint8_t masterCrafterMask;
uint8_t unknown69;
uint8_t unknown6A;
uint8_t unknown6B;
uint8_t unknown6C[4];
uint8_t unknown70[34];
uint16_t currentRelic;
uint16_t currentBook;
uint16_t masterCrafterMask;
uint16_t unknown69;
uint16_t unknown6A;
uint16_t unknown6B;
uint16_t unknown6C[4];
uint16_t unknown50[34];
uint16_t unknown18;
uint8_t maxLevel;
uint8_t expansion;
uint8_t unknown;
uint8_t race;
uint8_t tribe;
uint8_t gender;
uint8_t currentJob;
uint8_t currentClass;
uint8_t deity;
uint8_t namedayMonth;
uint8_t namedayDay;
uint8_t cityState;
uint8_t homepoint;
uint8_t unknown26;
uint8_t petHotBar;
uint8_t companionRank;
uint8_t companionStars;
uint8_t companionSp;
uint8_t companionUnk2B;
uint8_t companionColor;
uint8_t companionFavoFeed;
uint8_t companionUnk2E;
uint8_t companionTimePassed[4];
uint16_t unknown38[11];
uint16_t maxLevel;
uint16_t expansion;
uint16_t unknown76;
uint16_t race;
uint16_t tribe;
uint16_t gender;
uint16_t currentJob;
uint16_t currentClass;
uint16_t deity;
uint16_t namedayMonth;
uint16_t namedayDay;
uint16_t cityState;
uint16_t homepoint;
uint16_t unknown26;
uint16_t petHotBar;
uint16_t companionRank;
uint16_t companionStars;
uint16_t companionSp;
uint16_t companionUnk2B;
uint16_t companionColor;
uint16_t companionFavoFeed;
uint16_t companionUnk89;
uint16_t companionUnk90[5];
uint16_t unknown90[7];
uint16_t unknown9E;
uint16_t unknownA0;
uint32_t exp[25];
uint8_t unknown564[16];
uint16_t unknown564[16];
uint32_t pvpFrontlineOverall1st;
uint32_t pvpFrontlineOverall2nd;
uint32_t pvpFrontlineOverall3rd;
uint8_t relicBookCompletion1[4];
uint16_t relicBookCompletion1[4];
uint16_t levels[25];
uint16_t levelsPadding;
uint8_t unknown__[16];
uint16_t unknown15C[8];
uint16_t fishingRecordsFish[26];
uint16_t fishingRecordsFishWeight[26];
uint8_t unknownMask554[44];
uint8_t companion_name[21];
uint8_t companionDefRank;
uint8_t companionAttRank;
uint8_t companionHealRank;
uint8_t mountGuideMask[16];
uint16_t unknownMask554[44];
uint16_t companion_name[21];
uint16_t companionDefRank;
uint16_t companionAttRank;
uint16_t companionHealRank;
uint16_t mountGuideMask[16];
char name[32];
uint8_t unknownOword[16];
uint8_t unlockBitmask[64];
uint8_t aetheryte[17];
uint8_t discovery[421];
uint8_t howto[33];
uint8_t minions[38];
uint8_t chocoboTaxiMask[8];
uint8_t contentClearMask[111];
uint8_t contentClearPadding;
uint16_t unknownOword[16];
uint16_t unknown258;
uint16_t unlockBitmask[64];
uint16_t aetheryte[17];
uint16_t discovery[421];
uint16_t howto[33];
uint16_t minions[38];
uint16_t chocoboTaxiMask[8];
uint16_t contentClearMask[111];
uint16_t contentClearPadding;
uint16_t unknown428[8];
uint8_t companionBardingMask[8];
uint8_t companionEquippedHead;
uint8_t companionEquippedBody;
uint8_t companionEquippedFeet;
uint8_t companionUnk4[4];
uint8_t companion_fields[11];
uint8_t fishingGuideMask[89];
uint8_t fishingSpotVisited[25];
uint8_t unknownMask4Padding;
uint8_t rankAmalJaa;
uint8_t rankSylph;
uint8_t rankKobold;
uint8_t rankSahagin;
uint8_t rankIxal;
uint8_t rankVanu;
uint8_t rankVath;
uint8_t rankMoogle;
uint8_t rankKojin;
uint8_t rankAnata;
uint16_t companionBardingMask[8];
uint16_t companionEquippedHead;
uint16_t companionEquippedBody;
uint16_t companionEquippedFeet;
uint16_t companionUnk4[4];
uint16_t companion_fields[11];
uint16_t fishingGuideMask[89];
uint16_t fishingSpotVisited[25];
uint16_t unknownMask4Padding;
uint16_t rankAmalJaa;
uint16_t rankSylph;
uint16_t rankKobold;
uint16_t rankSahagin;
uint16_t rankIxal;
uint16_t rankVanu;
uint16_t rankVath;
uint16_t rankMoogle;
uint16_t rankKojin;
uint16_t rankAnata;
uint16_t expAmalJaa;
uint16_t expSylph;
uint16_t expKobold;
@ -777,40 +772,37 @@ struct FFXIVIpcInitUI : FFXIVIpcBasePacket<InitUI>
uint16_t expMoogle;
uint16_t expKojin;
uint16_t expAnata;
uint8_t unknown596[10];
uint16_t unknown596[10];
uint16_t unknown5A0[5];
uint8_t unknownMask59E[5];
uint8_t unknown5A3[18];
uint8_t unknownMask5C1[28];
uint8_t unknown_03411;
uint16_t unknownMask59E[5];
uint16_t unknown5A3[18];
uint16_t unknownMask5C1[28];
uint16_t unknown_03411;
uint32_t unknownDword5E0;
uint16_t pvpFrontlineWeekly1st;
uint16_t pvpFrontlineWeekly2nd;
uint16_t pvpFrontlineWeekly3rd;
uint8_t relicBookCompletion2[8];
uint8_t sightseeingMask[26];
uint16_t relicBookCompletion2[8];
uint16_t sightseeingMask[26];
uint16_t unknown_XXX;
uint8_t unknown61E;
uint8_t unknown61F[32];
uint8_t unknown63F[22];
uint8_t tripleTriadCards[28];
uint8_t unknown671[11];
uint8_t unknownMask67C[22];
uint8_t unknown692[3];
uint8_t orchestrionMask[40];
uint8_t hallOfNoviceCompleteMask[3];
uint8_t unknownMask6C0[11];
uint8_t unknownMask6CB[16];
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[13];
uint16_t unknown61E[20];
uint16_t unknown656[29];
uint16_t unknown63F[22];
uint16_t tripleTriadCards[28];
uint16_t unknown671[11];
uint16_t unknownMask67C[22];
uint16_t unknown692[3];
uint16_t orchestrionMask[40];
uint16_t hallOfNoviceCompleteMask[3];
uint16_t unknownMask6C0[11];
uint16_t unknownMask6CB[16];
uint16_t unknown6DB[14];
uint16_t unlockedRaids[28];
uint16_t unlockedDungeons[18];
uint16_t unlockedGuildhests[10];
uint16_t unlockedTrials[7];
uint16_t unlockedPvp[5];
uint16_t unknownMask72D[28];
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,10 +10,11 @@ namespace Entity
class EventObject : public Actor
{
public:
EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId, uint8_t initialState, Common::FFXIVARR_POSITION3 pos,
float rotation, const std::string& givenName = "none" );
EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId, uint8_t initialState,
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;
void setGimmickId( uint32_t gimmickId );

View file

@ -16,12 +16,7 @@
#include "Action/EventAction.h"
#include "Action/EventItemAction.h"
#include "Event/EventHandler.h"
#include "Zone/Zone.h"
#include "Player.h"
#include "Forwards.h"
#include "ServerZone.h"
#include "Framework.h"

View file

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

View file

@ -1,6 +1,4 @@
#include <set>
#include <stdio.h>
#include <time.h>
#include <Common.h>
#include <Network/GamePacket.h>
@ -19,11 +17,7 @@
#include "Zone/TerritoryMgr.h"
#include "Zone/Zone.h"
#include "Inventory/Inventory.h"
#include "Player.h"
#include "ServerZone.h"
#include "Forwards.h"
#include "Framework.h"
#include "Social/Manager/SocialMgr.h"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,6 @@
#include <Network/PacketContainer.h>
#include <unordered_map>
#include <boost/format.hpp>
#include "Network/GameConnection.h"
@ -16,9 +15,7 @@
#include "Zone/TerritoryMgr.h"
#include "Zone/Zone.h"
#include "Zone/InstanceContent.h"
#include "Zone/ZonePosition.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
@ -31,20 +28,7 @@
#include "Network/PacketWrappers/EventFinishPacket.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 "Forwards.h"
#include "Framework.h"
extern Core::Framework g_fw;

View file

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

View file

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

View file

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

View file

@ -77,7 +77,7 @@ private:
// df stuff
// todo: actually do this properly
m_data.unknown70[4] = 1; // enable df
// m_data.unknown70[4] = 1; // enable df
// enable all raids/guildhests/dungeons
memset( m_data.unlockedDungeons, 0xFF, sizeof( m_data.unlockedDungeons ) );

View file

@ -3,7 +3,6 @@
#include <Version.h>
#include <Logging/Logger.h>
#include <Config/XMLConfig.h>
#include <Version.h>
#include <MySqlBase.h>
#include <Connection.h>
@ -26,17 +25,14 @@
#include "Zone/TerritoryMgr.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Script/ScriptMgr.h"
#include "Linkshell/LinkshellMgr.h"
#include "Social/Manager/SocialMgr.h"
#include "Forwards.h"
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
#include <boost/algorithm/string.hpp>
#include <thread>
#include "Framework.h"
@ -219,7 +215,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
void Core::ServerZone::printBanner() const
{
auto pLog = g_fw.get< Core::Logger>();
auto pLog = g_fw.get< Core::Logger >();
pLog->info("===========================================================" );
pLog->info( "Sapphire Server Project " );
@ -349,15 +345,6 @@ void Core::ServerZone::removeSession( uint32_t 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 )
{
//std::lock_guard<std::mutex> lock( m_sessionMutex );
@ -399,14 +386,6 @@ void Core::ServerZone::removeSession( std::string 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
{

View file

@ -28,8 +28,6 @@ namespace Core {
SessionPtr getSession( uint32_t id );
SessionPtr getSession( uint64_t contentId );
SessionPtr getSession( std::string playerName );
void updateSession( uint32_t id );
void updateSession( std::string playerName );
size_t getSessionCount() const;
@ -39,7 +37,6 @@ namespace Core {
void printBanner() const;
private:
uint16_t m_port;

View file

@ -16,11 +16,12 @@
#include <DatCat.h>
#include <Exd/ExdData.h>
#include <Exd/ExdDataGenerated.h>
#include <Logging/Logger.h>
Core::Logger g_log;
Core::Data::ExdData g_exdData;
Core::Data::ExdDataGenerated g_exdDataGen;
const std::string onTalkStr(
" 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;
}
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(
"// 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"
);
std::size_t splitPos( pQuestData->name_intern.find( "_" ) );
std::string className( pQuestData->name_intern.substr( 0, splitPos ) );
std::size_t splitPos( pQuestData->id.find( "_" ) );
std::string className( pQuestData->id.substr( 0, splitPos ) );
//className = "Quest" + className;
std::string sceneStr( " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n" );
std::string seqStr;
@ -131,26 +132,26 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
std::string rewards;
rewards.reserve( 0xFFF );
rewards += " // Quest rewards \n";
rewards += ( pQuestData->reward_exp_factor != 0 ) ? " static constexpr auto RewardExpFactor = " + std::to_string( pQuestData->reward_exp_factor ) + ";\n" : "";
rewards += ( pQuestData->reward_gil != 0 ) ? " static constexpr auto RewardGil = " + std::to_string( pQuestData->reward_gil ) + ";\n" : "";
rewards += ( pQuestData->reward_emote != 0 ) ? " static constexpr auto RewardEmote = " + std::to_string( pQuestData->reward_emote ) + ";\n" : "";
rewards += ( pQuestData->reward_action != 0 ) ? " static constexpr auto RewardAction = " + std::to_string( pQuestData->reward_action ) + ";\n" : "";
rewards += ( pQuestData->reward_action_general1 != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + std::to_string( pQuestData->reward_action_general1 ) + ";\n" : "";
rewards += ( pQuestData->reward_action_general2 != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + std::to_string( pQuestData->reward_action_general2 ) + ";\n" : "";
rewards += ( pQuestData->reward_gc_seals != 0 ) ? " static constexpr auto RewardGCSeals = " + std::to_string( pQuestData->reward_gc_seals ) + ";\n" : "";
rewards += ( pQuestData->reward_other != 0 ) ? " static constexpr auto RewardOther = " + std::to_string( pQuestData->reward_other ) + ";\n" : "";
rewards += ( pQuestData->reward_reputation != 0 ) ? " static constexpr auto RewardReputation = " + std::to_string( pQuestData->reward_reputation ) + ";\n" : "";
rewards += ( pQuestData->reward_tome_type != 0 ) ? " static constexpr auto RewardTomeType = " + std::to_string( pQuestData->reward_tome_type ) + ";\n" : "";
rewards += ( pQuestData->reward_tome_count != 0 ) ? " static constexpr auto RewardTomeCount = " + std::to_string( pQuestData->reward_tome_count ) + ";\n" : "";
rewards += ( pQuestData->instanced_content_unlock != 0 ) ? " static constexpr auto InstancedContentUnlock = " + std::to_string( pQuestData->instanced_content_unlock ) + ";\n" : "";
rewards += ( pQuestData->expFactor != 0 ) ? " static constexpr auto RewardExpFactor = " + std::to_string( pQuestData->expFactor ) + ";\n" : "";
rewards += ( pQuestData->gilReward != 0 ) ? " static constexpr auto RewardGil = " + std::to_string( pQuestData->gilReward ) + ";\n" : "";
rewards += ( pQuestData->emoteReward != 0 ) ? " static constexpr auto RewardEmote = " + std::to_string( pQuestData->emoteReward ) + ";\n" : "";
rewards += ( pQuestData->actionReward != 0 ) ? " static constexpr auto RewardAction = " + std::to_string( pQuestData->actionReward ) + ";\n" : "";
rewards += ( pQuestData->generalActionReward[0] != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + std::to_string( pQuestData->generalActionReward[0] ) + ";\n" : "";
rewards += ( pQuestData->generalActionReward[1] != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + std::to_string( pQuestData->generalActionReward[1] ) + ";\n" : "";
rewards += ( pQuestData->gCSeals != 0 ) ? " static constexpr auto RewardGCSeals = " + std::to_string( pQuestData->gCSeals ) + ";\n" : "";
rewards += ( pQuestData->otherReward != 0 ) ? " static constexpr auto RewardOther = " + std::to_string( pQuestData->otherReward ) + ";\n" : "";
rewards += ( pQuestData->reputationReward != 0 ) ? " static constexpr auto RewardReputation = " + std::to_string( pQuestData->reputationReward ) + ";\n" : "";
rewards += ( pQuestData->tomestoneReward != 0 ) ? " static constexpr auto RewardTomeType = " + std::to_string( pQuestData->tomestoneReward ) + ";\n" : "";
rewards += ( pQuestData->tomestoneCountReward != 0 ) ? " static constexpr auto RewardTomeCount = " + std::to_string( pQuestData->tomestoneCountReward ) + ";\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[] = { ";
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 ) );
if( ca != pQuestData->reward_item.size() - 1 )
rewards += std::to_string( pQuestData->itemReward0.at( ca ) );
if( ca != pQuestData->itemReward0.size() - 1 )
{
rewards += ", ";
}
@ -158,13 +159,13 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
rewards += " };\n";
}
if( pQuestData->reward_item.size() > 0 )
if( !pQuestData->itemReward0.empty() )
{
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 ) );
if( ca != pQuestData->reward_item_count.size() - 1 )
rewards += std::to_string( pQuestData->itemCountReward0.at( ca ) );
if( ca != pQuestData->itemCountReward0.size() - 1 )
{
rewards += ", ";
}
@ -172,13 +173,13 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
rewards += " };\n";
}
if( pQuestData->reward_item_optional.size() > 0 )
if( !pQuestData->itemReward1.empty() )
{
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 ) );
if( ca != pQuestData->reward_item_optional.size() - 1 )
rewards += std::to_string( pQuestData->itemReward1.at( ca ) );
if( ca != pQuestData->itemReward1.size() - 1 )
{
rewards += ", ";
}
@ -186,13 +187,13 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
rewards += " };\n";
}
if( pQuestData->reward_item_optional_count.size() > 0 )
if( !pQuestData->itemCountReward1.empty() )
{
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 ) );
if( ca != pQuestData->reward_item_optional_count.size() - 1 )
rewards += std::to_string( pQuestData->itemCountReward1.at( ca ) );
if( ca != pQuestData->itemCountReward1.size() - 1 )
{
rewards += ", ";
}
@ -207,21 +208,22 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
std::vector< std::string > script_entities;
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;
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;
if( pQuestData->script_entity.at( ca ).find( "ENEMY" ) != std::string::npos )
if( pQuestData->scriptInstruction.at( ca ).find( "ENEMY" ) != std::string::npos )
{
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() );
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";
}
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 ID: " + std::to_string( pQuestData->id ) + "\n";
additional += "// Start NPC: " + std::to_string( pQuestData->enpc_resident_start ) + "\n";
additional += "// End NPC: " + std::to_string( pQuestData->enpc_resident_end ) + "\n\n";
additional += "// Quest ID: " + std::to_string( questId ) + "\n";
additional += "// Start NPC: " + std::to_string( pQuestData->eNpcResidentStart ) + "\n";
additional += "// End NPC: " + std::to_string( pQuestData->eNpcResidentEnd ) + "\n\n";
std::string scriptEntry;
scriptEntry.reserve(0xFFFF);
@ -271,7 +273,7 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
constructor += rewards + "\n";
constructor += sentities + "\n";
constructor += " public:\n";
constructor += " " + className + "() : EventScript" + "( " + std::to_string( pQuestData->id ) + " ){}; \n";
constructor += " " + className + "() : EventScript" + "( " + std::to_string( questId ) + " ){}; \n";
constructor += " ~" + className + "(){}; \n";
std::string classString(
@ -287,7 +289,7 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::
std::ofstream outputFile;
outputFile.open( "generated/" + className + ".cpp_generated" );
outputFile.open( "generated/" + className + ".cpp" );
outputFile << header << additional << classString;
outputFile.close();
}
@ -308,8 +310,8 @@ int main( int argc, char** argv )
unluac = true;
g_log.info( "Setting up EXD data" );
if( !g_exdData.init( datLocation ) )
g_log.info( "Setting up generated EXD data" );
if( !g_exdDataGen.init( datLocation ) )
{
std::cout << datLocation << "\n";
g_log.fatal( "Error setting up EXD data " );
@ -318,33 +320,33 @@ int main( int argc, char** argv )
}
xiv::dat::GameData data( datLocation );
xiv::exd::ExdData eData( data );
auto QuestDat = g_exdData.setupDatAccess( "Quest", xiv::exd::Language::en );
auto rows = QuestDat.get_rows();
auto rows = g_exdDataGen.getQuestIdList();
if ( !boost::filesystem::exists( "./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 i = 0;
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;
}
size_t pos_seperator = questInfo->name_intern.find_first_of( "_" );
size_t pos_seperator = questInfo->id.find_first_of( "_" );
std::string folder;
if( pos_seperator != std::string::npos )
{
folder = questInfo->name_intern.substr( pos_seperator + 1, 3 );
folder = questInfo->id.substr( pos_seperator + 1, 3 );
}
else
{
@ -355,7 +357,7 @@ int main( int argc, char** argv )
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 );
auto &section = test_file->access_data_sections().at( 0 );
@ -366,12 +368,12 @@ int main( int argc, char** argv )
uint32_t offset = 0;
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.close();
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 )
{
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;
if( i % updateInterval == 0 )
std::cout << ".";