1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-24 13:47:46 +00:00

Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
NotAdam 2018-10-14 23:36:05 +11:00
commit c06ce46e38
70 changed files with 11578 additions and 8935 deletions

View file

@ -1,15 +1,14 @@
cmake_policy(SET CMP0014 NEW) cmake_policy( SET CMP0014 NEW )
cmake_minimum_required(VERSION 3.0.2) cmake_minimum_required( VERSION 3.0.2 )
project (Sapphire) project( Sapphire )
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin) set( CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin )
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) set( EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin )
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) set( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin )
set(EXECUTABLE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set( EXECUTABLE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin )
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
########################################################################## ##########################################################################
# Boost stuff # Boost stuff

View file

@ -43,10 +43,11 @@ MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURR
ALTER TABLE charainfo ALTER TABLE charainfo
ADD `Orchestrion` binary(38) DEFAULT NULL AFTER `Mounts`; ADD `Orchestrion` binary(38) DEFAULT NULL AFTER `Mounts`;
ALTER TABLE `charainfo` CHANGE `Mounts` `Mounts` BINARY(15) NULL DEFAULT NULL; ALTER TABLE `charainfo` CHANGE `Mounts` `Mounts` BINARY(17) NULL DEFAULT NULL;
ALTER TABLE `charainfo` CHANGE `Orchestrion` `Orchestrion` BINARY(40) NULL DEFAULT NULL; ALTER TABLE `charainfo` CHANGE `Orchestrion` `Orchestrion` BINARY(40) NULL DEFAULT NULL;
ALTER TABLE `charainfo` CHANGE `Minions` `Minions` BINARY(37) NULL DEFAULT NULL; ALTER TABLE `charainfo` CHANGE `Minions` `Minions` BINARY(40) NULL DEFAULT NULL;
ALTER TABLE `charainfo` CHANGE `QuestCompleteFlags` `QuestCompleteFlags` VARBINARY(396) NULL DEFAULT NULL; ALTER TABLE `charainfo` CHANGE `QuestCompleteFlags` `QuestCompleteFlags` VARBINARY(396) NULL DEFAULT NULL;
ALTER TABLE `charainfo` CHANGE `Aetheryte` `Minions` BINARY(17) NULL DEFAULT NULL;
ALTER TABLE `charainfo` ADD COLUMN `EquipDisplayFlags` INT(3) NULL DEFAULT '0' AFTER `GMRank`; ALTER TABLE `charainfo` ADD COLUMN `EquipDisplayFlags` INT(3) NULL DEFAULT '0' AFTER `GMRank`;
ALTER TABLE `charainfo` ADD COLUMN `Pose` INT(3) NULL DEFAULT '0' AFTER `EquipDisplayFlags`; ALTER TABLE `charainfo` ADD COLUMN `Pose` INT(3) NULL DEFAULT '0' AFTER `EquipDisplayFlags`;

View file

@ -15,7 +15,6 @@ file(GLOB UTILS_SOURCE_FILES
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
add_library( common ${UTILS_PUBLIC_INCLUDE_FILES} ${UTILS_SOURCE_FILES} ) add_library( common ${UTILS_PUBLIC_INCLUDE_FILES} ${UTILS_SOURCE_FILES} )
set_target_properties( common PROPERTIES set_target_properties( common PROPERTIES
@ -28,14 +27,24 @@ set_target_properties( common PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/"
) )
target_link_libraries( common PUBLIC ${Boost_LIBRARIES} )
target_link_libraries( common PUBLIC xivdat ) target_link_libraries( common PUBLIC xivdat )
target_link_libraries( common PUBLIC mysqlConnector )
target_link_libraries( common PUBLIC mysqlConnector )
if( UNIX ) if( UNIX )
target_link_libraries( common PUBLIC mysqlclient ) target_link_libraries( common PUBLIC mysqlclient )
target_link_libraries( common PUBLIC pthread )
else() else()
target_link_libraries( common PUBLIC libmysql ) target_link_libraries( common
PUBLIC
libmysql )
endif() endif()
target_include_directories( common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/" ) target_include_directories( common
target_include_directories( common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/libraries/external/") PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/"
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/libraries/external/" )

View file

@ -4,7 +4,6 @@
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include <boost/make_shared.hpp>
#include "CommonGen.h" #include "CommonGen.h"
// +--------------------------------------------------------------------------- // +---------------------------------------------------------------------------
@ -27,8 +26,7 @@ struct FFXIVARR_POSITION3
float z; float z;
}; };
enum InventoryOperation : enum InventoryOperation : uint8_t
uint8_t
{ {
Discard = 0x07, Discard = 0x07,
Move = 0x08, Move = 0x08,
@ -37,8 +35,7 @@ enum InventoryOperation :
Split = 0x0A Split = 0x0A
}; };
enum ClientLanguage : enum ClientLanguage : uint8_t
uint8_t
{ {
Japanese = 1, Japanese = 1,
English = 2, English = 2,
@ -46,8 +43,7 @@ enum ClientLanguage :
French = 8 French = 8
}; };
enum ObjKind : enum ObjKind : uint8_t
uint8_t
{ {
None = 0x00, None = 0x00,
Player = 0x01, Player = 0x01,
@ -66,15 +62,13 @@ enum ObjKind :
CardStand = 0x0E, CardStand = 0x0E,
}; };
enum Stance : enum Stance : uint8_t
uint8_t
{ {
Passive = 0, Passive = 0,
Active = 1, Active = 1,
}; };
enum class DisplayFlags : enum class DisplayFlags : uint16_t
uint16_t
{ {
ActiveStance = 0x001, ActiveStance = 0x001,
Invisible = 0x020, Invisible = 0x020,
@ -84,8 +78,7 @@ enum class DisplayFlags :
Visor = 0x800, Visor = 0x800,
}; };
enum struct ActorStatus : enum struct ActorStatus : uint8_t
uint8_t
{ {
Idle = 0x01, Idle = 0x01,
Dead = 0x02, Dead = 0x02,
@ -99,8 +92,7 @@ enum struct ActorStatus :
EmoteMode = 0x0B EmoteMode = 0x0B
}; };
enum GearSetSlot : enum GearSetSlot : uint8_t
uint8_t
{ {
MainHand = 0, MainHand = 0,
OffHand = 1, OffHand = 1,
@ -173,8 +165,7 @@ enum EquipSlotCategory : uint8_t
BodyDisallowLegsFeet = 21, BodyDisallowLegsFeet = 21,
}; };
enum InventoryType : enum InventoryType : uint16_t
uint16_t
{ {
Bag0 = 0, Bag0 = 0,
Bag1 = 1, Bag1 = 1,
@ -226,8 +217,7 @@ enum InventoryType :
FreeCompanyCrystal = 22001 FreeCompanyCrystal = 22001
}; };
enum ContainerType : enum ContainerType : uint16_t
uint16_t
{ {
Unknown = 0, Unknown = 0,
Bag = 1, Bag = 1,
@ -237,8 +227,7 @@ enum ContainerType :
}; };
enum CurrencyType : enum CurrencyType : uint8_t
uint8_t
{ {
Gil = 0x01, Gil = 0x01,
StormSeal = 0x02, StormSeal = 0x02,
@ -256,8 +245,7 @@ enum CurrencyType :
TomestoneLore = 0x0E TomestoneLore = 0x0E
}; };
enum CrystalType : enum CrystalType : uint8_t
uint8_t
{ {
FireShard = 0x01, FireShard = 0x01,
IceShard = 0x02, IceShard = 0x02,
@ -281,8 +269,7 @@ enum CrystalType :
WaterCluster = 0x12 WaterCluster = 0x12
}; };
enum struct ZoneingType : enum struct ZoneingType : uint8_t
uint8_t
{ {
None = 1, None = 1,
Teleport = 2, Teleport = 2,
@ -291,24 +278,21 @@ enum struct ZoneingType :
FadeIn = 5, FadeIn = 5,
}; };
enum struct ResurrectType : enum struct ResurrectType : uint8_t
uint8_t
{ {
None = 0, None = 0,
RaiseSpell = 5, RaiseSpell = 5,
Return = 8 Return = 8
}; };
enum Gender : enum Gender : uint8_t
uint8_t
{ {
Male = 0, Male = 0,
Female = 1, Female = 1,
}; };
enum struct GCRank : enum struct GCRank : uint8_t
uint8_t
{ {
None = 0, None = 0,
PrivateThirdClass = 1, PrivateThirdClass = 1,

View file

@ -50,8 +50,8 @@ void Core::Db::ZoneDbConnection::doPrepareStatements()
"CFPenaltyUntil = ?, Pose = ? WHERE CharacterId = ?;", CONNECTION_ASYNC ); "CFPenaltyUntil = ?, Pose = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
prepareStatement( CHARA_SEL_MINIMAL, "SELECT Name, Customize, ModelEquip, TerritoryId, GuardianDeity, " prepareStatement( CHARA_SEL_MINIMAL, "SELECT Name, Customize, ModelMainWeapon, ModelSubWeapon, ModelEquip, TerritoryId, GuardianDeity, "
"Class, ContentId, BirthDay, BirthMonth " "Class, ContentId, BirthDay, BirthMonth, EquipDisplayFlags "
"FROM charainfo WHERE CharacterId = ?;", CONNECTION_SYNC ); "FROM charainfo WHERE CharacterId = ?;", CONNECTION_SYNC );
prepareStatement( CHARA_INS, "INSERT INTO charainfo (AccountId, CharacterId, ContentId, Name, Hp, Mp, " prepareStatement( CHARA_INS, "INSERT INTO charainfo (AccountId, CharacterId, ContentId, Name, Hp, Mp, "

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,4 @@
#include "Framework.h" #include "Framework.h"
#include "Logging/Logger.h"
#include <Logging/Logger.h>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>

View file

@ -5,9 +5,7 @@
namespace Core { namespace Core {
enum struct LoggingSeverity : uint8_t
enum struct LoggingSeverity :
uint8_t
{ {
trace = 0, trace = 0,
debug = 1, debug = 1,

View file

@ -2,7 +2,6 @@
#define ACCEPTOR_H_ #define ACCEPTOR_H_
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "Forwards.h" #include "Forwards.h"

View file

@ -200,6 +200,8 @@ enum ActorControlType :
SetCharaGearParamUI = 0x260, SetCharaGearParamUI = 0x260,
ToggleWireframeRendering = 0x261, ToggleWireframeRendering = 0x261,
ExamineError = 0x2BF,
GearSetEquipMsg = 0x321, GearSetEquipMsg = 0x321,
SetFestival = 0x386, // param1: festival.exd index SetFestival = 0x386, // param1: festival.exd index
@ -285,6 +287,8 @@ enum ClientTriggerType
AchievementCritReq = 0x3E8, AchievementCritReq = 0x3E8,
AchievementList = 0x3E9, AchievementList = 0x3E9,
RequestSharedEstateSettings = 0x46F,
CompanionAction = 0x6A4, CompanionAction = 0x6A4,
CompanionSetBarding = 0x6A5, CompanionSetBarding = 0x6A5,
CompanionActionUnlock = 0x6A6, CompanionActionUnlock = 0x6A6,

View file

@ -5,8 +5,6 @@
#include <vector> #include <vector>
#include "PacketDef/Ipcs.h" #include "PacketDef/Ipcs.h"
using namespace std;
namespace Core { namespace Core {
namespace Network { namespace Network {
namespace Packets { namespace Packets {
@ -70,12 +68,12 @@ struct FFXIVARR_PACKET_HEADER
uint32_t unknown_24; uint32_t unknown_24;
}; };
inline ostream& operator<<( ostream& os, const FFXIVARR_PACKET_HEADER& hdr ) inline std::ostream& operator<<( std::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 std::istream& operator>>( std::istream& is, FFXIVARR_PACKET_HEADER& hdr )
{ {
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr ); return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
} }
@ -108,12 +106,12 @@ struct FFXIVARR_PACKET_SEGMENT_HEADER
uint16_t padding; uint16_t padding;
}; };
inline ostream& operator<<( ostream& os, const FFXIVARR_PACKET_SEGMENT_HEADER& hdr ) inline std::ostream& operator<<( std::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 std::istream& operator>>( std::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 );
} }
@ -171,12 +169,12 @@ struct FFXIVARR_IPC_HEADER
uint32_t padding1; uint32_t padding1;
}; };
inline ostream& operator<<( ostream& os, const FFXIVARR_IPC_HEADER& hdr ) inline std::ostream& operator<<( std::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 std::istream& operator>>( std::istream& is, FFXIVARR_IPC_HEADER& hdr )
{ {
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr ); return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
} }

View file

@ -64,6 +64,7 @@ enum ServerZoneIpcType :
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
ChatBanned = 0x006B, ChatBanned = 0x006B,
Playtime = 0x006C, // updated 4.4
Logout = 0x0077, // updated 4.4 Logout = 0x0077, // updated 4.4
CFNotify = 0x0078, CFNotify = 0x0078,
CFMemberStatus = 0x0079, CFMemberStatus = 0x0079,
@ -78,7 +79,6 @@ enum ServerZoneIpcType :
Playtime = 0x00F5, // updated 4.3
Chat = 0x00F4, // updated 4.4 Chat = 0x00F4, // updated 4.4
SocialList = 0x00FB, // updated 4.4 SocialList = 0x00FB, // updated 4.4
@ -99,6 +99,11 @@ enum ServerZoneIpcType :
LinkshellList = 0x0117, // updated 4.4 LinkshellList = 0x0117, // updated 4.4
MailDeleteRequest = 0x0118, // updated 4.4
ReqMoogleMailList = 0x0119, // updated 4.4
ReqMoogleMailLetter = 0x01A, // updated 4.4
MailLetterNotification = 0x011B, // updated 4.4
ExamineFreeCompanyInfo = 0x013A, // updated 4.1 ExamineFreeCompanyInfo = 0x013A, // updated 4.1
CharaFreeCompanyTag = 0x0127, // updated 4.4 CharaFreeCompanyTag = 0x0127, // updated 4.4
FreeCompanyBoardMsg = 0x0128, // updated 4.4 FreeCompanyBoardMsg = 0x0128, // updated 4.4
@ -119,7 +124,7 @@ enum ServerZoneIpcType :
ActorMove = 0x0170, // updated 4.4 ActorMove = 0x0170, // updated 4.4
ActorSetPos = 0x0172, // updated 4.4 ActorSetPos = 0x0172, // updated 4.4
ActorCast = 0x0170, // updated 4.4 ActorCast = 0x0174, // updated 4.4
PartyList = 0x0176, // updated 4.4 PartyList = 0x0176, // updated 4.4
HateList = 0x0177, // updated 4.4 HateList = 0x0177, // updated 4.4
@ -127,7 +132,7 @@ enum ServerZoneIpcType :
ObjectSpawn = 0x0179, // updated 4.4 ObjectSpawn = 0x0179, // updated 4.4
ObjectDespawn = 0x017A, // updated 4.4 ObjectDespawn = 0x017A, // updated 4.4
SetLevelSync = 0x017B, // updated 4.4 UpdateClassInfo = 0x017B, // updated 4.4
SilentSetClassJob = 0x017C, // updated 4.4 - seems to be the case, not sure if it's actually used for anything SilentSetClassJob = 0x017C, // updated 4.4 - seems to be the case, not sure if it's actually used for anything
InitUI = 0x017D, // updated 4.4 InitUI = 0x017D, // updated 4.4
@ -138,7 +143,7 @@ enum ServerZoneIpcType :
ModelEquip = 0x0182, // updated 4.4 ModelEquip = 0x0182, // updated 4.4
Examine = 0x0183, // updated 4.4 Examine = 0x0183, // updated 4.4
CharaNameReq = 0x0185, // updated 4.4 CharaNameReq = 0x0185, // updated 4.4
UpdateClassInfo = 0x0186, // updated 4.4 SetLevelSync = 0x0186, // not updated for 4.4, not sure what it is anymore
ItemInfo = 0x018C, // updated 4.4 ItemInfo = 0x018C, // updated 4.4
ContainerInfo = 0x018D, // updated 4.4 ContainerInfo = 0x018D, // updated 4.4
@ -179,13 +184,15 @@ enum ServerZoneIpcType :
PlayerTitleList = 0x01FD, // updated 4.4 PlayerTitleList = 0x01FD, // updated 4.4
Discovery = 0x01FE, // updated 4.4 Discovery = 0x01FE, // updated 4.4
EorzeaTimeOffset = 0x01FF, // updated 4.4 EorzeaTimeOffset = 0x0200, // updated 4.4
EquipDisplayFlags = 0x020C, // updated 4.4 EquipDisplayFlags = 0x020C, // updated 4.4
WardInfo = 0x0220, // updated 4.4 WardInfo = 0x0220, // updated 4.4
WardHousingPermission = 0x0229, // updated 4.4 WardHousingPermission = 0x0229, // updated 4.4
WardYardInfo = 0x022B, // updated 4.4 WardYardInfo = 0x022C, // updated 4.4
SharedEstateSettingsResponse = 0x023C, // updated 4.4
DuelChallenge = 0x0277, // 4.2; this is responsible for opening the ui DuelChallenge = 0x0277, // 4.2; this is responsible for opening the ui
PerformNote = 0x0286, // updated 4.3 PerformNote = 0x0286, // updated 4.3
@ -197,7 +204,7 @@ enum ServerZoneIpcType :
// 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 = 0x0248, // updated 4.4 IPCTYPE_UNK_320 = 0x0249, // updated 4.4
IPCTYPE_UNK_322 = 0x024B, // updated 4.4 IPCTYPE_UNK_322 = 0x024B, // updated 4.4
}; };
@ -249,40 +256,42 @@ enum ClientZoneIpcType :
ReqJoinNoviceNetwork = 0x0129, // updated 4.2 ReqJoinNoviceNetwork = 0x0129, // updated 4.2
ReqCountdownInitiate = 0x0138, // updated 4.3 ReqCountdownInitiate = 0x012F, // updated 4.4
ReqCountdownCancel = 0x0139, // updated 4.3 ReqCountdownCancel = 0x0130, // updated 4.4
ClearWaymarks = 0x013A, // updated 4.3 ClearWaymarks = 0x0131, // updated 4.4
ZoneLineHandler = 0x013C, // updated 4.3 ZoneLineHandler = 0x0133, // updated 4.4
ClientTrigger = 0x013D, // updated 4.3 ClientTrigger = 0x0134, // updated 4.4 was 13D in 4.3
DiscoveryHandler = 0x013E, // updated 4.3 DiscoveryHandler = 0x0135, // updated 4.4
AddWaymark = 0x013F, // updated 4.3 AddWaymark = 0x013F, // updated 4.3
SkillHandler = 0x0140, // updated 4.3 SkillHandler = 0x0137, // updated 4.4
GMCommand1 = 0x0141, // updated 4.3 GMCommand1 = 0x0138, // updated 4.4
GMCommand2 = 0x0142, // updated 4.3 GMCommand2 = 0x0139, // updated 4.4
UpdatePositionHandler = 0x0144, // updated 4.3 UpdatePositionHandler = 0x013B, // updated 4.4 was 144
UpdatePositionInstance = 0x0183, // updated 4.3 UpdatePositionInstance = 0x0183, // updated 4.3
InventoryModifyHandler = 0x014B, // updated 4.3 InventoryModifyHandler = 0x0142, // updated 4.4
TalkEventHandler = 0x0154, // updated 4.3 TalkEventHandler = 0x014B, // updated 4.4
EmoteEventHandler = 0x0155, // updated 4.3 EmoteEventHandler = 0x014C, // updated 4.4
WithinRangeEventHandler = 0x0156, // updated 4.3 WithinRangeEventHandler = 0x014D, // updated 4.4
OutOfRangeEventHandler = 0x0157, // updated 4.3 OutOfRangeEventHandler = 0x014E, // updated 4.4
EnterTeriEventHandler = 0x0158, // updated 4.3 EnterTeriEventHandler = 0x014F, // updated 4.4
ReturnEventHandler = 0x015D, // updated 4.3 ReturnEventHandler = 0x0154, // updated 4.4
TradeReturnEventHandler = 0x015E, // updated 4.3 TradeReturnEventHandler = 0x0155, // updated 4.4
LinkshellEventHandler = 0x0150, // updated 4.1 ?? LinkshellEventHandler = 0x0150, // updated 4.1 ??
LinkshellEventHandler1 = 0x0151, // updated 4.1 ?? LinkshellEventHandler1 = 0x0151, // updated 4.1 ??
SetSharedEstateSettings = 0x0177, // updated 4.4
PerformNoteHandler = 0x029B, // updated 4.3 PerformNoteHandler = 0x029B, // updated 4.3
ReqEquipDisplayFlagsChange = 0x0178, // updated 4.3 ReqEquipDisplayFlagsChange = 0x016F, // updated 4.4
}; };

View file

@ -59,8 +59,7 @@ struct FFXIVIpcServerList :
} server[6]; } server[6];
}; };
struct FFXIVIpcCharList : struct FFXIVIpcCharList : FFXIVIpcBasePacket< LobbyCharList >
FFXIVIpcBasePacket< LobbyCharList >
{ {
uint64_t seq; uint64_t seq;
uint8_t counter; // current packet count * 4, count * 4 +1 on last packet. uint8_t counter; // current packet count * 4, count * 4 +1 on last packet.
@ -82,6 +81,8 @@ struct FFXIVIpcCharList :
uint16_t unknown8; uint16_t unknown8;
uint32_t entitledExpansion; uint32_t entitledExpansion;
uint32_t padding2; uint32_t padding2;
uint32_t padding3;
uint32_t padding4;
struct CharaDetails struct CharaDetails
{ {
@ -92,16 +93,16 @@ struct FFXIVIpcCharList :
uint32_t padding2; uint32_t padding2;
uint16_t serverId; uint16_t serverId;
uint16_t serverId1; uint16_t serverId1;
uint8_t unknown[9];
char nameChara[32]; char nameChara[32];
char nameServer[32]; char nameServer[32];
char nameServer1[32]; char nameServer1[32];
char charDetailJson[1028]; char charDetailJson[1051];
} charaDetails[2]; } charaDetails[2];
}; };
struct FFXIVIpcEnterWorld : struct FFXIVIpcEnterWorld : FFXIVIpcBasePacket< LobbyEnterWorld >
FFXIVIpcBasePacket< LobbyEnterWorld >
{ {
uint64_t seq; uint64_t seq;
uint32_t charId; uint32_t charId;
@ -115,8 +116,7 @@ struct FFXIVIpcEnterWorld :
uint64_t padding4; uint64_t padding4;
}; };
struct FFXIVIpcCharCreate : struct FFXIVIpcCharCreate : FFXIVIpcBasePacket< LobbyCharCreate >
FFXIVIpcBasePacket< LobbyCharCreate >
{ {
uint64_t seq; uint64_t seq;
uint8_t unknown; uint8_t unknown;
@ -126,17 +126,23 @@ struct FFXIVIpcCharCreate :
uint32_t unknown_3; uint32_t unknown_3;
uint32_t unknown_4; uint32_t unknown_4;
uint32_t unknown_5; uint32_t unknown_5;
uint64_t unknown_6;
uint64_t unknown_61;
uint64_t unknown_62;
uint64_t unknown_63;
uint64_t content_id; uint64_t content_id;
uint16_t unknown_7; uint16_t unknown_7;
uint16_t unknown_8; uint16_t unknown_8;
uint32_t unknown_9; uint32_t unknown_9;
uint16_t unknown_10; uint16_t unknown_10;
uint8_t unknown_11[11];
char name[32]; char name[32];
char world[32]; char world[32];
char world2[32];
uint8_t unknown_12[0x953];
}; };
struct FFXIVIpcLobbyError : struct FFXIVIpcLobbyError : FFXIVIpcBasePacket< LobbyError >
FFXIVIpcBasePacket< LobbyError >
{ {
uint64_t seq; uint64_t seq;
uint32_t error_id; uint32_t error_id;

View file

@ -15,16 +15,22 @@ struct FFXIVIpcGmCommand1 :
/* 0000 */ uint32_t commandId; /* 0000 */ uint32_t commandId;
/* 0004 */ uint32_t param1; /* 0004 */ uint32_t param1;
/* 0008 */ uint32_t param2; /* 0008 */ uint32_t param2;
/* 000C */ uint8_t unknown_C[0xC]; /* 000C */ uint32_t param3;
/* 0018 */ uint32_t param3; /* 0010 */ uint32_t param4;
/* 0014 */ uint32_t unknown1;
/* 0018 */ uint32_t target;
}; };
struct FFXIVIpcGmCommand2 : struct FFXIVIpcGmCommand2 :
FFXIVIpcBasePacket< GMCommand2 > FFXIVIpcBasePacket< GMCommand2 >
{ {
/* 0000 */ uint32_t commandId; /* 0000 */ uint32_t commandId;
/* 0004 */ char unk_4[0x10]; /* 0004 */ uint32_t param1;
/* 0014 */ char param1[0x20]; /* 0008 */ uint32_t param2;
/* 000C */ uint32_t param3;
/* 0010 */ uint32_t param4;
/* 0014 */ char target[0x20];
/* 0034 */ uint32_t unknown1;
}; };
struct FFXIVIpcClientTrigger : struct FFXIVIpcClientTrigger :
@ -183,6 +189,20 @@ struct FFXIVIpcInventoryModifyHandler :
/* 0028 */ uint32_t splitCount; /* 0028 */ uint32_t splitCount;
}; };
struct FFXIVIpcSetSharedEstateSettings :
FFXIVIpcBasePacket< SetSharedEstateSettings >
{
/* 0000 */ uint64_t char1ContentId;
/* 0008 */ uint64_t char2ContentId;
/* 0010 */ uint64_t char3ContentId;
/* 0018 */ uint8_t char1Permissions;
/* 0019 */ char padding1[0x7];
/* 0020 */ uint8_t char2Permissions;
/* 0021 */ char padding2[0x7];
/* 0028 */ uint8_t char3Permissions;
/* 0029 */ char padding3[0x7];
};
} }
} }
} }

View file

@ -210,6 +210,44 @@ struct FFXIVIpcLinkshellList :
} entry[8]; } entry[8];
}; };
/**
* Structural representation of the packet sent by the server
* to send a list of mail the player has
*/
struct FFXIVIpcReqMoogleMailList :
FFXIVIpcBasePacket< ReqMoogleMailList >
{
struct letterEntry
{
char unk[0x8];
uint32_t timeStamp; // The time the mail was sent (this also seems to be used as a Id)
char unk1[0x30]; // This should be items, gil, etc for the letter
uint8_t read; // 0 = false | 1 = true
uint8_t type; // 0 = Friends | 1 = Rewards | 2 = GM
uint8_t unk2;
char senderName[0x20]; // The name of the sender
char summary[0x3C]; // The start of the full letter text
char padding2[0x5];
} letter[5];
char unk3[0x08];
};
/**
* Structural representation of the packet sent by the server
* to show the mail delivery notification
*/
struct FFXIVIpcMailLetterNotificationt :
FFXIVIpcBasePacket< MailLetterNotification >
{
uint32_t sendbackCount; // The amount of letters sent back since you ran out of room (moogle dialog changes based on this)
uint16_t friendLetters; // The amount of letters in the friends section of the letterbox
uint16_t unreadCount; // The amount of unreads in the letterbox (this is the number that shows up)
uint16_t rewardLetters; // The amount of letters in the rewards section of the letterbox
uint8_t isGmLetter; // Makes the letter notification flash red
uint8_t isSupportDesk; // After setting this to 1 we can no longer update mail notifications (more research needed on the support desk)
char unk2[0x4]; // This has probs something to do with the support desk (inquiry id?)
};
struct FFXIVIpcExamineFreeCompanyInfo : struct FFXIVIpcExamineFreeCompanyInfo :
FFXIVIpcBasePacket< ExamineFreeCompanyInfo > FFXIVIpcBasePacket< ExamineFreeCompanyInfo >
{ {
@ -446,15 +484,18 @@ struct FFXIVIpcPlayerSpawn :
uint16_t u1b; uint16_t u1b;
uint8_t u2b; uint8_t u2b;
uint8_t u2ab; uint8_t u2ab;
uint8_t gmRank; uint8_t u3a;
uint8_t u3b; uint8_t u3b;
uint8_t u3a; uint8_t gmRank;
uint8_t onlineStatus;
uint8_t u3c; uint8_t u3c;
uint8_t pose; uint8_t u4;
uint8_t onlineStatus;
uint32_t u4; uint8_t pose;
uint8_t u5a;
uint8_t u5b;
uint8_t u5c;
uint64_t targetId; uint64_t targetId;
uint32_t u6; uint32_t u6;
@ -691,8 +732,7 @@ struct FFXIVIpcUpdateClassInfo :
* Structural representation of the packet sent by the server * Structural representation of the packet sent by the server
* to send the titles available to the player * to send the titles available to the player
*/ */
struct FFXIVIpcPlayerTitleList : struct FFXIVIpcPlayerTitleList : FFXIVIpcBasePacket< PlayerTitleList >
FFXIVIpcBasePacket< PlayerTitleList >
{ {
uint8_t titleList[48]; uint8_t titleList[48];
}; };
@ -701,8 +741,7 @@ struct FFXIVIpcPlayerTitleList :
* Structural representation of the packet sent by the server * Structural representation of the packet sent by the server
* to initialize a zone for the player * to initialize a zone for the player
*/ */
struct FFXIVIpcInitZone : struct FFXIVIpcInitZone : FFXIVIpcBasePacket< InitZone >
FFXIVIpcBasePacket< InitZone >
{ {
uint16_t serverId; uint16_t serverId;
uint16_t zoneId; uint16_t zoneId;
@ -711,11 +750,14 @@ struct FFXIVIpcInitZone :
uint32_t unknown3; uint32_t unknown3;
uint32_t unknown4; uint32_t unknown4;
uint8_t weatherId; uint8_t weatherId;
uint8_t bitmask; uint16_t bitmask;
uint16_t unknown5; uint8_t unknown5;
uint16_t festivalId; uint16_t festivalId;
uint16_t additionalFestivalId; uint16_t additionalFestivalId;
uint32_t unknown8; uint32_t unknown8;
uint32_t unknown9;
uint32_t unknown10;
uint32_t unknown11;
Common::FFXIVARR_POSITION3 pos; Common::FFXIVARR_POSITION3 pos;
}; };
@ -724,8 +766,7 @@ struct FFXIVIpcInitZone :
* Structural representation of the packet sent by the server to initialize * Structural representation of the packet sent by the server to initialize
* the client UI upon initial connection. * the client UI upon initial connection.
*/ */
struct FFXIVIpcInitUI : struct FFXIVIpcInitUI : FFXIVIpcBasePacket< InitUI >
FFXIVIpcBasePacket< InitUI >
{ {
// plain C types for a bit until the packet is actually fixed. // plain C types for a bit until the packet is actually fixed.
// makes conversion between different editors easier. // makes conversion between different editors easier.
@ -756,11 +797,11 @@ struct FFXIVIpcInitUI :
unsigned short unknown5E; unsigned short unknown5E;
unsigned short pvpFrontlineWeeklyCampaigns; unsigned short pvpFrontlineWeeklyCampaigns;
unsigned short enhancedAnimaGlassProgress; unsigned short enhancedAnimaGlassProgress;
unsigned short unknown64[4]; // needs confirmation, probably pvp total/weeklies unsigned short unknown64[4];
unsigned short pvpRivalWingsTotalMatches; unsigned short pvpRivalWingsTotalMatches;
unsigned short pvpRivalWingsTotalVictories; unsigned short pvpRivalWingsTotalVictories;
unsigned short pvpRivalWingsWeeklyMatches; // needs confirmation unsigned short pvpRivalWingsWeeklyMatches;
unsigned short pvpRivalWingsWeeklyVictories; // needs confirmation unsigned short pvpRivalWingsWeeklyVictories;
unsigned char maxLevel; unsigned char maxLevel;
unsigned char expansion; unsigned char expansion;
unsigned char unknown76; unsigned char unknown76;
@ -810,7 +851,7 @@ struct FFXIVIpcInitUI :
unsigned char companionDefRank; unsigned char companionDefRank;
unsigned char companionAttRank; unsigned char companionAttRank;
unsigned char companionHealRank; unsigned char companionHealRank;
unsigned char mountGuideMask[16]; unsigned char mountGuideMask[17];
char name[32]; char name[32];
unsigned char unknownOword[16]; unsigned char unknownOword[16];
unsigned char unknown258; unsigned char unknown258;
@ -818,9 +859,9 @@ struct FFXIVIpcInitUI :
unsigned char aetheryte[17]; unsigned char aetheryte[17];
unsigned char discovery[421]; unsigned char discovery[421];
unsigned char howto[33]; unsigned char howto[33];
unsigned char minions[38]; unsigned char minions[40];
unsigned char chocoboTaxiMask[8]; unsigned char chocoboTaxiMask[8];
unsigned char watchedCutscenes[111]; unsigned char watchedCutscenes[115];
unsigned char companionBardingMask[9]; unsigned char companionBardingMask[9];
unsigned char companionEquippedHead; unsigned char companionEquippedHead;
unsigned char companionEquippedBody; unsigned char companionEquippedBody;
@ -840,12 +881,12 @@ struct FFXIVIpcInitUI :
unsigned char unknownMask5C4[3]; unsigned char unknownMask5C4[3];
unsigned char unknown5C9[2]; unsigned char unknown5C9[2];
unsigned char challengeLogComplete[9]; unsigned char challengeLogComplete[9];
unsigned char unknown5D4[9]; unsigned char unknown5D4[11];
unsigned char unknownMask5DD[28]; unsigned char unknownMask5DD[28];
unsigned char relicCompletion[12]; unsigned char relicCompletion[12];
unsigned char sightseeingMask[26]; unsigned char sightseeingMask[26];
unsigned char huntingMarkMask[55]; unsigned char huntingMarkMask[55];
unsigned char tripleTriadCards[29]; unsigned char tripleTriadCards[30];
unsigned char unknownMask673[10]; unsigned char unknownMask673[10];
unsigned char unknown67D; unsigned char unknown67D;
unsigned char aetherCurrentMask[22]; unsigned char aetherCurrentMask[22];
@ -853,18 +894,17 @@ struct FFXIVIpcInitUI :
unsigned char orchestrionMask[40]; unsigned char orchestrionMask[40];
unsigned char hallOfNoviceCompleteMask[3]; unsigned char hallOfNoviceCompleteMask[3];
unsigned char animaCompletion[11]; unsigned char animaCompletion[11];
unsigned char unknown6CD[3]; unsigned char unknown6CD[16];
unsigned char unknownMask6C0[11]; unsigned char unknownMask6DB[11];
unsigned char unknownMask6DB[13];
unsigned char unlockedRaids[28]; unsigned char unlockedRaids[28];
unsigned char unlockedDungeons[18]; unsigned char unlockedDungeons[18];
unsigned char unlockedGuildhests[10]; unsigned char unlockedGuildhests[10];
unsigned char unlockedTrials[7]; unsigned char unlockedTrials[8];
unsigned char unlockedPvp[5]; unsigned char unlockedPvp[5];
unsigned char clearedRaids[28]; unsigned char clearedRaids[28];
unsigned char clearedDungeons[18]; unsigned char clearedDungeons[18];
unsigned char clearedGuildhests[10]; unsigned char clearedGuildhests[10];
unsigned char clearedTrials[7]; unsigned char clearedTrials[8];
unsigned char clearedPvp[5]; unsigned char clearedPvp[5];
}; };
@ -1590,6 +1630,22 @@ struct FFXIVIpcWardYardInfo :
} object[100]; } object[100];
}; };
/**
* Structural representation of the packet sent by the server
* to show the current shared estate settings
*/
struct FFXIVIpcSharedEstateSettingsResponse :
FFXIVIpcBasePacket< SharedEstateSettingsResponse >
{
struct playerEntry
{
uint64_t contentId;
uint8_t permissions;
char name[0x20];
char padding[0x7];
} entry[3];
};
struct FFXIVIpcMSQTrackerProgress : struct FFXIVIpcMSQTrackerProgress :
FFXIVIpcBasePacket< MSQTrackerProgress > FFXIVIpcBasePacket< MSQTrackerProgress >
{ {

View file

@ -1,6 +1,7 @@
#include "Util.h" #include "Util.h"
#include <chrono> #include <chrono>
#include <boost/variant/detail/substitute.hpp> #include <boost/variant/detail/substitute.hpp>
#include <boost/format.hpp>
std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size ) std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size )
{ {

View file

@ -2,7 +2,7 @@
#define _UTIL_H #define _UTIL_H
#include <stdint.h> #include <stdint.h>
#include <boost/format.hpp> #include <string>
namespace Core { namespace Core {
namespace Util { namespace Util {

View file

@ -27,22 +27,18 @@ uint16_t floatToUInt16Rot( float val );
uint8_t floatToUInt8Rot( float val ); uint8_t floatToUInt8Rot( float val );
template template < typename T >
< typename T >
T clamp( T val, T minimum, T maximum ) T clamp( T val, T minimum, T maximum )
{ {
if( val > maximum ) if( val > maximum )
{
return maximum; return maximum;
}
if( val < minimum ) if( val < minimum )
{
return minimum; return minimum;
}
return val; return val;
} }
} }
} }
} }

View file

@ -1,13 +1,5 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required( VERSION 3.0 )
project (Sapphire) project( Sapphire )
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
include_directories("${PROJECT_INCLUDE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}")
add_subdirectory(${PROJECT_SOURCE_DIR}/sapphire_lobby) add_subdirectory(${PROJECT_SOURCE_DIR}/sapphire_lobby)
add_subdirectory(${PROJECT_SOURCE_DIR}/sapphire_api) add_subdirectory(${PROJECT_SOURCE_DIR}/sapphire_api)

View file

@ -39,7 +39,7 @@ foreach(_scriptDir ${children})
target_link_libraries( "script_${_name}" sapphire_zone ) target_link_libraries( "script_${_name}" sapphire_zone )
if(MSVC) if(MSVC)
target_link_libraries( "script_${_name}" ${Boost_LIBRARIES}) #target_link_libraries( "script_${_name}" ${Boost_LIBRARIES})
set_target_properties( "script_${_name}" PROPERTIES set_target_properties( "script_${_name}" PROPERTIES
CXX_STANDARD 14 CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON CXX_STANDARD_REQUIRED ON

View file

@ -1,7 +1,7 @@
#ifndef SAPPHIRE_SCRIPTOBJECT_H #ifndef SAPPHIRE_SCRIPTOBJECT_H
#define SAPPHIRE_SCRIPTOBJECT_H #define SAPPHIRE_SCRIPTOBJECT_H
#include <Forwards.h> #include <ForwardsZone.h>
#include <Script/NativeScriptApi.h> #include <Script/NativeScriptApi.h>
#include <Event/EventDefs.h> #include <Event/EventDefs.h>

View file

@ -1,7 +1,7 @@
#include <Actor/Player.h> #include <Actor/Player.h>
#include <sapphire_zone/Event/EventHandler.h>
#include <ScriptObject.h> #include <ScriptObject.h>
#include "Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Event/EventHandler.h"
// Quest Script: ManFst001_00039 // Quest Script: ManFst001_00039
// Quest Name: Coming to Gridania // Quest Name: Coming to Gridania

View file

@ -1,7 +1,7 @@
#include <Actor/Player.h> #include <Actor/Player.h>
#include <sapphire_zone/Event/EventHandler.h>
#include "Event/EventHelper.h"
#include <ScriptObject.h> #include <ScriptObject.h>
#include "Event/EventHandler.h"
#include "Event/EventHelper.h"
// Quest Script: ManFst002_00124 // Quest Script: ManFst002_00124
// Quest Name: Close to Home // Quest Name: Close to Home
@ -9,8 +9,7 @@
// Start NPC: 1001140 // Start NPC: 1001140
// End NPC: 1000100 // End NPC: 1000100
class ManFst002 : class ManFst002 : public EventScript
public EventScript
{ {
private: private:

View file

@ -5,7 +5,6 @@ project(Sapphire)
file(GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*") file(GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*")
file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/")
add_executable(sapphire_api ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) add_executable(sapphire_api ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES})
set_target_properties(sapphire_api PROPERTIES set_target_properties(sapphire_api PROPERTIES
@ -19,10 +18,5 @@ set_target_properties(sapphire_api PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
) )
if (UNIX) target_link_libraries (sapphire_api common)
target_link_libraries (sapphire_api common pthread dl z)
else()
target_link_libraries (sapphire_api common zlib1)
endif()
target_link_libraries( sapphire_api ${Boost_LIBRARIES} ${Boost_LIBRARIES} )

View file

@ -55,22 +55,32 @@ void PlayerMinimal::load( uint32_t charId )
auto modelEquip = res->getBlobVector( "ModelEquip" ); auto modelEquip = res->getBlobVector( "ModelEquip" );
memcpy( ( char* ) m_modelEquip, modelEquip.data(), modelEquip.size() ); memcpy( ( char* ) m_modelEquip, modelEquip.data(), modelEquip.size() );
m_modelMainWeapon = res->getUInt64( "ModelMainWeapon" );
m_modelSubWeapon = res->getUInt64( "ModelSubWeapon" );
m_equipDisplayFlags = res->getUInt8( "EquipDisplayFlags" );
setBirthDay( res->getUInt8( "BirthDay" ), res->getUInt8( "BirthMonth" ) ); setBirthDay( res->getUInt8( "BirthDay" ), res->getUInt8( "BirthMonth" ) );
m_guardianDeity = res->getUInt8( "GuardianDeity" ); m_guardianDeity = res->getUInt8( "GuardianDeity" );
m_class = res->getUInt8( "Class" ); m_class = res->getUInt8( "Class" );
m_contentId = res->getUInt64( "ContentId" ); m_contentId = res->getUInt64( "ContentId" );
m_zoneId = res->getUInt8( "TerritoryId" ); m_zoneId = res->getUInt16( "TerritoryId" );
res.reset();
// SELECT ClassIdx, Exp, Lvl // SELECT ClassIdx, Exp, Lvl
auto stmtClass = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_SEL_MINIMAL ); auto stmtClass = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_CLASS_SEL );
stmtClass->setInt( 1, m_id ); stmtClass->setInt( 1, m_id );
auto resClass = g_charaDb.query( stmt ); auto resClass = g_charaDb.query( stmtClass );
while( resClass->next() ) while( resClass->next() )
{ {
m_classMap[ resClass->getUInt( 1 ) ] = resClass->getUInt( 3 ); auto classIdx = resClass->getUInt( 1 );
auto lvl = resClass->getUInt( 3 );
m_classMap[ classIdx ] = lvl;
m_classLevel = getClassLevel();
} }
} }
@ -100,19 +110,24 @@ std::string PlayerMinimal::getLookString()
std::string PlayerMinimal::getModelString() std::string PlayerMinimal::getModelString()
{ {
std::string modelString = "\"" std::string modelString = "\""
+ std::to_string( m_modelEquip[ 0 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 1 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 2 ] ) + "\",\"" + std::to_string( m_modelEquip[ 2 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 3 ] ) + "\",\"" + std::to_string( m_modelEquip[ 3 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 4 ] ) + "\",\"" + std::to_string( m_modelEquip[ 4 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 5 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 6 ] ) + "\",\"" + std::to_string( m_modelEquip[ 6 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 7 ] ) + "\",\"5\",\"6\",\"7\",\"8\",\"9\""; + std::to_string( m_modelEquip[ 7 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 8 ] ) + "\",\""
+ std::to_string( m_modelEquip[ 9 ] ) + "\"";
return modelString; return modelString;
} }
std::string PlayerMinimal::getInfoJson() std::string PlayerMinimal::getInfoJson()
{ {
std::string charDetails = "{\"content\":[\"" + std::string( getName() ) + "\"," + std::string charDetails = "{\"content\":[\"" + std::string( getName() ) + "\"," +
//"[" + getClassString() + "]," + "[\"0\",\"0\",\"0\",\"0\",\"" + std::to_string( m_classLevel ) +
"[\"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\",\"0\",\"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( getBirthMonth() ) +
"\",\"" + std::to_string( getBirthDay() ) + "\",\"" + std::to_string( getBirthDay() ) +
@ -120,15 +135,21 @@ std::string PlayerMinimal::getInfoJson()
"\",\"" + std::to_string( m_class ) + "\",\"" + std::to_string( m_class ) +
"\",\"0\",\"" + std::to_string( getZoneId() ) + "\",\"0\",\"" + std::to_string( getZoneId() ) +
"\",\"0\"," + "\",\"0\"," +
"[" + getLookString() + "]," + "[" + getLookString() + "]," +
"\"0\",\"0\"," + "\"" + std::to_string( m_modelMainWeapon ) + "\",\"" + std::to_string( m_modelSubWeapon ) + "\"," +
"[" + getModelString() + "]," + "[" + getModelString() + "]," +
"\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"\",\"0\",\"0\"]," + "\"1\",\"0\",\"0\",\"0\",\"" + std::to_string( m_equipDisplayFlags ) +
"\",\"0\",\"\",\"0\",\"0\"]," +
"\"classname\":\"ClientSelectData\",\"classid\":116}"; "\"classname\":\"ClientSelectData\",\"classid\":116}";
return charDetails; return charDetails;
} }
uint8_t PlayerMinimal::getClassLevel()
{
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( m_class ) )->expArrayIndex;
return static_cast< uint8_t >( m_classMap[ classJobIndex ] );
}
std::string PlayerMinimal::getClassString() std::string PlayerMinimal::getClassString()
{ {

View file

@ -31,6 +31,8 @@ public:
std::string getClassString(); std::string getClassString();
uint8_t getClassLevel();
// return the id of the actor // return the id of the actor
uint32_t getId() const uint32_t getId() const
{ {
@ -177,6 +179,7 @@ private:
uint8_t m_birthMonth; uint8_t m_birthMonth;
uint8_t m_birthDay; uint8_t m_birthDay;
uint8_t m_class; uint8_t m_class;
uint8_t m_classLevel;
uint8_t m_voice; uint8_t m_voice;
@ -184,10 +187,15 @@ private:
uint16_t m_zoneId; uint16_t m_zoneId;
uint64_t m_modelMainWeapon;
uint64_t m_modelSubWeapon;
uint8_t m_equipDisplayFlags;
std::map< uint8_t, uint8_t > m_lookMap; std::map< uint8_t, uint8_t > m_lookMap;
std::map< uint8_t, uint16_t > m_classMap; std::map< uint8_t, uint16_t > m_classMap;
uint8_t m_look[26]; uint8_t m_look[26];
uint8_t m_gmRank; uint8_t m_gmRank;
bool m_gmInvis; bool m_gmInvis;

View file

@ -6,7 +6,7 @@
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp> #include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Config/ConfigMgr.h> #include <Config/ConfigMgr.h>

View file

@ -1,11 +1,10 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 3.0.2)
cmake_policy(SET CMP0015 NEW) cmake_policy(SET CMP0015 NEW)
project(Sapphire) project(Sapphire)
file(GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*") file(GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*")
file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/")
add_executable(sapphire_lobby ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) add_executable(sapphire_lobby ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES})
@ -18,13 +17,8 @@ set_target_properties(sapphire_lobby PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
) )
if (UNIX) target_link_libraries(sapphire_lobby PRIVATE common)
target_link_libraries(sapphire_lobby common pthread dl z)
else()
target_link_libraries(sapphire_lobby common zlib1)
endif()
target_link_libraries(sapphire_lobby ${Boost_LIBRARIES} ${Boost_LIBRARIES})
cotire( sapphire_lobby ) cotire( sapphire_lobby )

View file

@ -160,22 +160,25 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
memset( &details, 0, sizeof( FFXIVIpcCharList::CharaDetails ) ); memset( &details, 0, sizeof( FFXIVIpcCharList::CharaDetails ) );
auto& charEntry = charList[ charIndex ]; auto& charEntry = charList[ charIndex ];
details.uniqueId = get< 1 >( charEntry ); details.uniqueId = std::get< 1 >( charEntry );
details.contentId = get< 2 >( charEntry ); details.contentId = std::get< 2 >( charEntry );
details.serverId = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 ); details.serverId = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 );
details.serverId1 = 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, std::get< 3 >( charEntry ).c_str() );
strcpy( details.nameChara, get< 0 >( charEntry ).c_str() ); strcpy( details.nameChara, std::get< 0 >( charEntry ).c_str() );
strcpy( details.nameServer, strcpy( details.nameServer,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
strcpy( details.nameServer1,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
charListPacket->data().charaDetails[ j ] = details; charListPacket->data().charaDetails[ j ] = details;
g_log.debug( "[" + std::to_string( charIndex ) + "] " + std::to_string( details.index ) + " - " g_log.debug( "[" + std::to_string( charIndex ) + "] " + std::to_string( details.index ) + " - "
+ get< 0 >( charEntry ) + " - " + + std::get< 0 >( charEntry ) + " - " +
std::to_string( get< 1 >( charEntry ) ) + " - " + std::to_string( std::get< 1 >( charEntry ) ) + " - " +
std::to_string( get< 2 >( charEntry ) ) + " - " + std::to_string( std::get< 2 >( charEntry ) ) + " - " +
get< 3 >( charEntry ) ); std::get< 3 >( charEntry ) );
} }
charIndex++; charIndex++;
} }
@ -212,12 +215,12 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin
auto charList = g_restConnector.getCharList( ( char* ) m_pSession->getSessionId() ); auto charList = g_restConnector.getCharList( ( char* ) m_pSession->getSessionId() );
for( uint32_t i = 0; i < charList.size(); i++ ) for( uint32_t i = 0; i < charList.size(); i++ )
{ {
uint64_t thisContentId = get< 2 >( charList[ i ] ); uint64_t thisContentId = std::get< 2 >( charList[ i ] );
if( thisContentId == lookupId ) if( thisContentId == lookupId )
{ {
logInCharId = get< 1 >( charList[ i ] ); logInCharId = std::get< 1 >( charList[ i ] );
logInCharName = get< 0 >( charList[ i ] ); logInCharName = std::get< 0 >( charList[ i ] );
break; break;
} }
} }
@ -342,6 +345,8 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
strcpy( charCreatePacket->data().name, name.c_str() ); strcpy( charCreatePacket->data().name, name.c_str() );
strcpy( charCreatePacket->data().world, strcpy( charCreatePacket->data().world,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
strcpy( charCreatePacket->data().world2,
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;

View file

@ -17,8 +17,7 @@
namespace Core { namespace Core {
namespace Network { namespace Network {
class GameConnection : class GameConnection : public Connection
public Connection
{ {
private: private:

View file

@ -2,7 +2,7 @@
#define _ACTION_H_ #define _ACTION_H_
#include <Common.h> #include <Common.h>
#include "../ForwardsZone.h" #include "ForwardsZone.h"
namespace Core { namespace Core {
namespace Action { namespace Action {

View file

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

View file

@ -3,11 +3,11 @@
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EffectPacket.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"

View file

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

View file

@ -2,11 +2,11 @@
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#include <Util/UtilMath.h> #include <Util/UtilMath.h>
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/EffectPacket.h"
#include "Actor/Player.h" #include "Actor/Player.h"

View file

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

View file

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

View file

@ -1,14 +1,13 @@
#ifndef _EVENTITEMACTION_H_ #ifndef _EVENTITEMACTION_H_
#define _EVENTITEMACTION_H_ #define _EVENTITEMACTION_H_
#include "Forwards.h" #include "ForwardsZone.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Core {
namespace Action { namespace Action {
class EventItemAction : class EventItemAction : public Action
public Action
{ {
public: public:

View file

@ -4,7 +4,7 @@
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <utility> #include <utility>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h> #include <Network/PacketWrappers/EffectPacket.h>
#include "Forwards.h" #include "Forwards.h"
#include "Action/Action.h" #include "Action/Action.h"

View file

@ -4,7 +4,7 @@
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <utility> #include <utility>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#include "Forwards.h" #include "Forwards.h"
#include "Action/Action.h" #include "Action/Action.h"
@ -16,6 +16,7 @@
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h" #include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "Network/PacketWrappers/EffectPacket.h"
#include "StatusEffect/StatusEffect.h" #include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h" #include "Action/ActionCollision.h"
@ -457,7 +458,8 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket->addEffect( effectEntry ); effectPacket->addEffect( effectEntry );
if( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 || actionInfoPtr->castType != 1 ) if( ( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 ) ||
( actionInfoPtr->castType != 1 ) )
{ {
// If action on this specific target is valid... // If action on this specific target is valid...
if( isPlayer() && !ActionCollision::isActorApplicable( target, TargetFilter::Enemies ) ) if( isPlayer() && !ActionCollision::isActorApplicable( target, TargetFilter::Enemies ) )
@ -517,7 +519,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket->addEffect( effectEntry ); effectPacket->addEffect( effectEntry );
if( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 || actionInfoPtr->castType != 1 ) if( ( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 ) || actionInfoPtr->castType != 1 )
{ {
if( isPlayer() && !ActionCollision::isActorApplicable( target, TargetFilter::Allies ) ) if( isPlayer() && !ActionCollision::isActorApplicable( target, TargetFilter::Allies ) )
break; break;

View file

@ -4,7 +4,7 @@
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <utility> #include <utility>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#include "Forwards.h" #include "Forwards.h"
#include "Action/Action.h" #include "Action/Action.h"
@ -16,6 +16,7 @@
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h" #include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "Network/PacketWrappers/EffectPacket.h"
#include "StatusEffect/StatusEffect.h" #include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h" #include "Action/ActionCollision.h"

View file

@ -1561,7 +1561,7 @@ void Core::Entity::Player::sendZonePackets()
auto initZonePacket = makeZonePacket< FFXIVIpcInitZone >( getId() ); auto initZonePacket = makeZonePacket< FFXIVIpcInitZone >( getId() );
initZonePacket->data().zoneId = getCurrentZone()->getTerritoryId(); initZonePacket->data().zoneId = getCurrentZone()->getTerritoryId();
initZonePacket->data().weatherId = static_cast< uint8_t >( getCurrentZone()->getCurrentWeather() ); initZonePacket->data().weatherId = static_cast< uint8_t >( getCurrentZone()->getCurrentWeather() );
initZonePacket->data().bitmask = 0x1; initZonePacket->data().bitmask = 0x1; //Setting this to 16 (deciaml) makes it so you can fly in the area (more research needed!)
initZonePacket->data().unknown5 = 0x2A; initZonePacket->data().unknown5 = 0x2A;
initZonePacket->data().festivalId = getCurrentZone()->getCurrentFestival().first; initZonePacket->data().festivalId = getCurrentZone()->getCurrentFestival().first;
initZonePacket->data().additionalFestivalId = getCurrentZone()->getCurrentFestival().second; initZonePacket->data().additionalFestivalId = getCurrentZone()->getCurrentFestival().second;

View file

@ -1,7 +1,7 @@
#ifndef _PLAYER_H #ifndef _PLAYER_H
#define _PLAYER_H #define _PLAYER_H
#include "Forwards.h" #include "ForwardsZone.h"
#include <Common.h> #include <Common.h>
#include <Util/SpawnIndexAllocator.h> #include <Util/SpawnIndexAllocator.h>
@ -953,8 +953,8 @@ private:
uint16_t m_activeTitle; uint16_t m_activeTitle;
uint8_t m_titleList[48]; uint8_t m_titleList[48];
uint8_t m_howTo[33]; uint8_t m_howTo[33];
uint8_t m_minions[37]; uint8_t m_minions[40];
uint8_t m_mountGuide[15]; uint8_t m_mountGuide[17];
uint8_t m_homePoint; uint8_t m_homePoint;
uint8_t m_startTown; uint8_t m_startTown;
uint16_t m_townWarpFstFlags; uint16_t m_townWarpFstFlags;

View file

@ -313,6 +313,7 @@ bool Core::Entity::Player::loadSearchInfo()
// todo: internally use an std::string instead of a char[] // todo: internally use an std::string instead of a char[]
auto searchMessage = res->getString( 4 ); auto searchMessage = res->getString( 4 );
memset( m_searchMessage, 0, sizeof( m_searchMessage ) );
std::copy( searchMessage.begin(), searchMessage.end(), m_searchMessage ); std::copy( searchMessage.begin(), searchMessage.end(), m_searchMessage );
return true; return true;
@ -501,7 +502,7 @@ void Core::Entity::Player::updateDbSearchInfo() const
pDb->execute( stmtS1 ); pDb->execute( stmtS1 );
auto stmtS2 = pDb->getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SEARCHCOMMENT ); auto stmtS2 = pDb->getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SEARCHCOMMENT );
stmtS2->setString( 1, string( m_searchMessage != nullptr ? m_searchMessage : "" ) ); stmtS2->setString( 1, std::string( m_searchMessage ) );
stmtS2->setInt( 2, m_id ); stmtS2->setInt( 2, m_id );
pDb->execute( stmtS2 ); pDb->execute( stmtS2 );
} }

View file

@ -0,0 +1,28 @@
#ifndef SAPPHIRE_SPAWNGROUP_H
#define SAPPHIRE_SPAWNGROUP_H
#include "ForwardsZone.h"
namespace Core {
namespace Entity {
class SpawnGroup
{
private:
BNpcTemplatePtr m_bNpcTemplate;
uint32_t m_level;
uint32_t m_spawnCount;
std::vector< SpawnPointPtr > m_spawnPoints;
public:
SpawnGroup();
};
}
}
#endif //SAPPHIRE_SPAWNGROUP_H

View file

@ -0,0 +1,51 @@
#include "SpawnPoint.h"
#include "BNpc.h"
Core::Entity::SpawnPoint::SpawnPoint()
{
}
Core::Entity::SpawnPoint::SpawnPoint( float x, float y, float z, float rot, uint32_t gimmickId ) :
m_posX( x ),
m_posY( y ),
m_posZ( z ),
m_rotation( rot ),
m_gimmickId( gimmickId )
{
}
float Core::Entity::SpawnPoint::getPosX() const
{
return m_posX;
}
float Core::Entity::SpawnPoint::getPosY() const
{
return m_posY;
}
float Core::Entity::SpawnPoint::getPosZ() const
{
return m_posZ;
}
float Core::Entity::SpawnPoint::getRotation() const
{
return m_rotation;
}
uint32_t Core::Entity::SpawnPoint::getGimmickId() const
{
return m_gimmickId;
}
Core::Entity::BNpcPtr Core::Entity::SpawnPoint::getLinkedBNpc()
{
return m_pLinkedBnpc;
}
void Core::Entity::SpawnPoint::setLinkedBNpc( BNpcPtr pBnpc )
{
m_pLinkedBnpc = pBnpc;
}

View file

@ -0,0 +1,41 @@
#ifndef SAPPHIRE_SPAWNPOINT_H
#define SAPPHIRE_SPAWNPOINT_H
#include "ForwardsZone.h"
namespace Core {
namespace Entity {
class SpawnPoint
{
private:
float m_posX;
float m_posY;
float m_posZ;
float m_rotation;
uint32_t m_gimmickId;
uint32_t m_lastSpawn;
BNpcPtr m_pLinkedBnpc;
public:
SpawnPoint();
SpawnPoint( float x, float y, float z, float rot, uint32_t gimmickId );
float getPosX() const;
float getPosY() const;
float getPosZ() const;
float getRotation() const;
uint32_t getGimmickId() const;
BNpcPtr getLinkedBNpc();
void setLinkedBNpc( BNpcPtr pBnpc );
};
}
}
#endif //SAPPHIRE_SPAWNPOINT_H

View file

@ -4,22 +4,6 @@ cmake_policy(SET CMP0014 OLD)
project(sapphire_zone) project(sapphire_zone)
file(GLOB SERVER_PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
/*.h
Actor/*.h
Action/*.h
DebugCommand/*.h
Event/*.h
Inventory/*.h
Linkshell/*.h
Math/*.h
Network/*.h
Network/Handlers/*.h
Network/PacketWrappers/*.h
Script/*.h
StatusEffect/*.h
Zone/*.h)
file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.c* *.c*
Actor/*.c* Actor/*.c*
@ -36,9 +20,7 @@ file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
StatusEffect/*.c* StatusEffect/*.c*
Zone/*.c*) Zone/*.c*)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/") add_executable( sapphire_zone ${SERVER_SOURCE_FILES} )
add_executable(sapphire_zone ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES} )
set_target_properties(sapphire_zone PROPERTIES set_target_properties(sapphire_zone PROPERTIES
CXX_STANDARD 14 CXX_STANDARD 14
@ -51,22 +33,13 @@ set_target_properties(sapphire_zone PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
) )
target_link_libraries( sapphire_zone common ) target_link_libraries( sapphire_zone PUBLIC common )
if (UNIX)
target_link_libraries( sapphire_zone pthread )
target_link_libraries( sapphire_zone dl )
target_link_libraries( sapphire_zone z )
else()
target_link_libraries( sapphire_zone zlib1 )
endif()
target_link_libraries( sapphire_zone ${Boost_LIBRARIES} )
target_include_directories( sapphire_zone PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ) target_include_directories( sapphire_zone PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" )
target_include_directories( sapphire_zone PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Script" )
target_include_directories( sapphire_zone PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../libraries/external" )
if (UNIX) if (UNIX)
cotire( sapphire_zone ) cotire( sapphire_zone )
endif() endif()

View file

@ -18,8 +18,7 @@ struct SceneResult
class EventHandler class EventHandler
{ {
public: public:
enum EventType : enum EventType : uint8_t
uint8_t
{ {
Talk = 1, Talk = 1,
Emote = 2, Emote = 2,
@ -45,8 +44,7 @@ public:
TableGame = 24, TableGame = 24,
}; };
enum EventHandlerType : enum EventHandlerType : uint16_t
uint16_t
{ {
Quest = 0x0001, Quest = 0x0001,
Warp = 0x0002, Warp = 0x0002,

View file

@ -96,7 +96,7 @@ uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId )
auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto pExdData = g_fw.get< Data::ExdDataGenerated >();
auto levelInfo = pExdData->get< Core::Data::Level >( eventActorId ); auto levelInfo = pExdData->get< Core::Data::Level >( eventActorId );
if( levelInfo ) if( levelInfo )
return levelInfo->objectKey; return levelInfo->object;
return 0; return 0;
} }

View file

@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <vector> #include <vector>
#include "Common.h"
#define TYPE_FORWARD( x ) \ #define TYPE_FORWARD( x ) \
class x; \ class x; \

View file

@ -401,7 +401,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
case SEGMENTTYPE_SESSIONINIT: case SEGMENTTYPE_SESSIONINIT:
{ {
char* id = ( char* ) &( inPacket.data[ 4 ] ); char* id = ( char* ) &( inPacket.data[ 4 ] );
uint32_t playerId = boost::lexical_cast< uint32_t >( id ); uint32_t playerId = std::stoi( id );
auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() ); auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() );
// try to retrieve the session for this id // try to retrieve the session for this id

View file

@ -25,8 +25,7 @@ enum ConnectionType :
None None
}; };
class GameConnection : class GameConnection : public Connection
public Connection
{ {
private: private:

View file

@ -52,10 +52,17 @@ void examineHandler( Core::Entity::Player& player, uint32_t targetId )
{ {
auto pTarget = pSession->getPlayer(); auto pTarget = pSession->getPlayer();
if( pTarget ) if( pTarget )
{
if( pTarget->isActingAsGm() || pTarget->getZoneId() != player.getZoneId() )
{
player.queuePacket( makeActorControl142( player.getId(), ActorControlType::ExamineError ) );
}
else
{ {
player.queuePacket( boost::make_shared< ExaminePacket >( player, pTarget ) ); player.queuePacket( boost::make_shared< ExaminePacket >( player, pTarget ) );
} }
} }
}
} }
void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,

View file

@ -6,7 +6,6 @@
#include <Network/GamePacketNew.h> #include <Network/GamePacketNew.h>
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h> #include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <sapphire_zone/Event/EventHandler.h>
#include <Network/PacketDef/Zone/ClientZoneDef.h> #include <Network/PacketDef/Zone/ClientZoneDef.h>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
@ -17,6 +16,7 @@
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Event/EventHandler.h"
#include "Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Zone/InstanceContent.h" #include "Zone/InstanceContent.h"

View file

@ -7,6 +7,7 @@
#include <Network/PacketContainer.h> #include <Network/PacketContainer.h>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <Network/PacketDef/Zone/ClientZoneDef.h> #include <Network/PacketDef/Zone/ClientZoneDef.h>
#include <Exd/ExdDataGenerated.h>
#include <unordered_map> #include <unordered_map>
@ -98,16 +99,19 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
const auto param1 = packet.data().param1; const auto param1 = packet.data().param1;
const auto param2 = packet.data().param2; const auto param2 = packet.data().param2;
const auto param3 = packet.data().param3; const auto param3 = packet.data().param3;
const auto param4 = packet.data().param4;
const auto target = packet.data().target;
auto pLog = g_fw.get< Logger >(); auto pLog = g_fw.get< Logger >();
pLog->debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) + pLog->debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) +
", params: " + std::to_string( param1 ) + ", " + ", params: " + std::to_string( param1 ) + ", " +
std::to_string( param2 ) + ", " + std::to_string( param3 ) ); std::to_string( param2 ) + ", " + std::to_string( param3 ) + ", " + std::to_string( param4 ) +
", target: " + std::to_string( target ) );
Core::Entity::ActorPtr targetActor; Core::Entity::ActorPtr targetActor;
if( player.getId() == param3 ) if( player.getId() == target )
{ {
targetActor = player.getAsPlayer(); targetActor = player.getAsPlayer();
} }
@ -116,7 +120,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
auto inRange = player.getInRangeActors(); auto inRange = player.getInRangeActors();
for( auto& actor : inRange ) for( auto& actor : inRange )
{ {
if( actor->getId() == param3 ) if( actor->getId() == target )
targetActor = actor; targetActor = actor;
} }
} }
@ -455,8 +459,41 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
break; break;
} }
bool doTeleport = false;
uint16_t teleport;
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
auto idList = pExdData->getAetheryteIdList();
for( auto i : idList )
{
auto data = pExdData->get< Core::Data::Aetheryte >( i );
if( !data )
{
continue;
}
if( data->territory == param1 )
{
if( data->isAetheryte )
{
doTeleport = true;
teleport = i;
break;
}
}
}
if( doTeleport )
{
player.teleport( teleport );
}
else
{
targetPlayer->setPos( targetPlayer->getPos() ); targetPlayer->setPos( targetPlayer->getPos() );
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 ); targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
}
player.sendNotice( targetPlayer->getName() + " was warped to zone " + player.sendNotice( targetPlayer->getName() + " was warped to zone " +
std::to_string( param1 ) + " (" + pZone->getName() + ")" ); std::to_string( param1 ) + " (" + pZone->getName() + ")" );
} }
@ -506,11 +543,18 @@ void Core::Network::GameConnection::gm2Handler( const Packets::FFXIVARR_PACKET_R
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand2 >( inPacket ); const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand2 >( inPacket );
const auto commandId = packet.data().commandId; const auto commandId = packet.data().commandId;
const auto param1 = std::string( packet.data().param1 ); const auto param1 = packet.data().param1;
const auto param2 = packet.data().param2;
const auto param3 = packet.data().param3;
const auto param4 = packet.data().param4;
const auto target = std::string( packet.data().target );
pLog->debug( player.getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 ); pLog->debug( player.getName() + " used GM2 commandId: " + std::to_string( commandId ) +
", params: " + std::to_string( param1 ) + ", " +
std::to_string( param2 ) + ", " + std::to_string( param3 ) + ", " + std::to_string( param4 ) +
", target: " + target );
auto targetSession = pServerZone->getSession( param1 ); auto targetSession = pServerZone->getSession( target );
Core::Entity::CharaPtr targetActor; Core::Entity::CharaPtr targetActor;
if( targetSession != nullptr ) if( targetSession != nullptr )
@ -519,13 +563,13 @@ void Core::Network::GameConnection::gm2Handler( const Packets::FFXIVARR_PACKET_R
} }
else else
{ {
if( param1 == "self" ) if( target == "self" )
{ {
targetActor = player.getAsPlayer(); targetActor = player.getAsPlayer();
} }
else else
{ {
player.sendUrgent( "Player " + param1 + " not found on this server." ); player.sendUrgent( "Player " + target + " not found on this server." );
return; return;
} }
} }

View file

@ -120,6 +120,9 @@ void Core::Network::GameConnection::reqExamineSearchCommentHandler( const Core::
if( pPlayer ) if( pPlayer )
{ {
if( pPlayer->isActingAsGm() || pPlayer->getZoneId() != player.getZoneId() )
return;
// retail sends the requester's id as both (isForSelf) // retail sends the requester's id as both (isForSelf)
auto searchInfoPacket = makeZonePacket< FFXIVIpcExamineSearchComment >( player.getId() ); auto searchInfoPacket = makeZonePacket< FFXIVIpcExamineSearchComment >( player.getId() );
searchInfoPacket->data().charId = targetId; searchInfoPacket->data().charId = targetId;
@ -144,6 +147,9 @@ void Core::Network::GameConnection::reqExamineFcInfo( const Core::Network::Packe
if( pPlayer ) if( pPlayer )
{ {
if( pPlayer->isActingAsGm() || pPlayer->getZoneId() != player.getZoneId() )
return;
// retail sends the requester's id as both (isForSelf) // retail sends the requester's id as both (isForSelf)
auto examineFcInfoPacket = makeZonePacket< FFXIVIpcExamineFreeCompanyInfo >( player.getId() ); auto examineFcInfoPacket = makeZonePacket< FFXIVIpcExamineFreeCompanyInfo >( player.getId() );
examineFcInfoPacket->data().charId = targetId; examineFcInfoPacket->data().charId = targetId;
@ -365,7 +371,7 @@ void Core::Network::GameConnection::discoveryHandler( const Core::Network::Packe
if( !pQR->next() ) if( !pQR->next() )
{ {
player.sendNotice( "Discovery ref pos ID: " + std::to_string( positionRef ) + " not found. " ); player.sendDebug( "Discovery ref pos ID: " + std::to_string( positionRef ) + " not found. " );
return; return;
} }
@ -374,7 +380,7 @@ void Core::Network::GameConnection::discoveryHandler( const Core::Network::Packe
discoveryPacket->data().map_part_id = pQR->getUInt( 3 ); discoveryPacket->data().map_part_id = pQR->getUInt( 3 );
player.queuePacket( discoveryPacket ); player.queuePacket( discoveryPacket );
player.sendNotice( "Discovery ref pos ID: " + std::to_string( positionRef ) ); player.sendDebug( "Discovery ref pos ID: " + std::to_string( positionRef ) );
player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) ); player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) );

View file

@ -50,16 +50,16 @@ private:
memcpy( m_data.look, pTarget->getLookArray(), sizeof( m_data.look ) ); memcpy( m_data.look, pTarget->getLookArray(), sizeof( m_data.look ) );
m_data.models[ Common::GearModelSlot::ModelHead ] = player.getModelForSlot( Common::GearModelSlot::ModelHead ); m_data.models[ Common::GearModelSlot::ModelHead ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelHead );
m_data.models[ Common::GearModelSlot::ModelBody ] = player.getModelForSlot( Common::GearModelSlot::ModelBody ); m_data.models[ Common::GearModelSlot::ModelBody ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelBody );
m_data.models[ Common::GearModelSlot::ModelHands ] = player.getModelForSlot( Common::GearModelSlot::ModelHands ); m_data.models[ Common::GearModelSlot::ModelHands ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelHands );
m_data.models[ Common::GearModelSlot::ModelLegs ] = player.getModelForSlot( Common::GearModelSlot::ModelLegs ); m_data.models[ Common::GearModelSlot::ModelLegs ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelLegs );
m_data.models[ Common::GearModelSlot::ModelFeet ] = player.getModelForSlot( Common::GearModelSlot::ModelFeet ); m_data.models[ Common::GearModelSlot::ModelFeet ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelFeet );
m_data.models[ Common::GearModelSlot::ModelNeck ] = player.getModelForSlot( Common::GearModelSlot::ModelNeck ); m_data.models[ Common::GearModelSlot::ModelNeck ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelNeck );
m_data.models[ Common::GearModelSlot::ModelEar ] = player.getModelForSlot( Common::GearModelSlot::ModelEar ); m_data.models[ Common::GearModelSlot::ModelEar ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelEar );
m_data.models[ Common::GearModelSlot::ModelRing1 ] = player.getModelForSlot( Common::GearModelSlot::ModelRing1 ); m_data.models[ Common::GearModelSlot::ModelRing1 ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelRing1 );
m_data.models[ Common::GearModelSlot::ModelRing2 ] = player.getModelForSlot( Common::GearModelSlot::ModelRing2 ); m_data.models[ Common::GearModelSlot::ModelRing2 ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelRing2 );
m_data.models[ Common::GearModelSlot::ModelWrist ] = player.getModelForSlot( Common::GearModelSlot::ModelWrist ); m_data.models[ Common::GearModelSlot::ModelWrist ] = pTarget->getModelForSlot( Common::GearModelSlot::ModelWrist );
// todo: main/sub/other stuff too // todo: main/sub/other stuff too

View file

@ -0,0 +1,167 @@
#include <string>
#include <typeinfo>
#include <typeindex>
#include <Event/EventHandler.h>
#include "NativeScriptApi.h"
#ifdef _MSC_VER
#define EXPORT __declspec( dllexport )
#else
#define EXPORT __attribute__((visibility("default")))
#endif
using namespace Core;
ScriptObject::ScriptObject( uint32_t id, std::size_t type ) :
m_id( id ),
m_type( type )
{
}
uint32_t ScriptObject::getId() const
{
return m_id;
}
std::size_t ScriptObject::getType() const
{
return m_type;
}
///////////////////////////////////////////////////////////////////
StatusEffectScript::StatusEffectScript( uint32_t effectId ) :
ScriptObject( effectId, typeid( StatusEffectScript ).hash_code() )
{
}
void StatusEffectScript::onTick( Entity::Chara& actor )
{
}
void StatusEffectScript::onApply( Entity::Chara& actor )
{
}
void StatusEffectScript::onRemove( Entity::Chara& actor )
{
}
void StatusEffectScript::onExpire( Entity::Chara& actor )
{
}
void StatusEffectScript::onPlayerCollision( Entity::Chara& actor, Entity::Chara& actorHit )
{
}
void StatusEffectScript::onPlayerFinishCast( Entity::Chara& actor )
{
}
void StatusEffectScript::onPlayerDamaged( Entity::Chara& actor )
{
}
void StatusEffectScript::onPlayerDeath( Entity::Chara& actor )
{
}
///////////////////////////////////////////////////////////////////
ActionScript::ActionScript( uint32_t abilityId ) :
ScriptObject( abilityId, typeid( ActionScript ).hash_code() )
{
}
void ActionScript::onStart( Entity::Chara& sourceActor, Entity::Chara& targetActor )
{
}
void ActionScript::onCastFinish( Entity::Player& player, Entity::Chara& targetActor )
{
}
void ActionScript::onInterrupt( Entity::Chara& sourceActor/*, Core::Entity::Chara targetActor*/ )
{
}
///////////////////////////////////////////////////////////////////
EventScript::EventScript( uint32_t questId ) :
ScriptObject( questId, typeid( EventScript ).hash_code() )
{
}
void EventScript::onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId )
{
}
void EventScript::onNpcKill( uint32_t npcId, Entity::Player& player )
{
}
void EventScript::onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Entity::Player& player )
{
}
void EventScript::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 )
{
}
void EventScript::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
{
}
void EventScript::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
{
}
void
EventScript::onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId )
{
}
void EventScript::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
uint32_t catalogId )
{
}
///////////////////////////////////////////////////////////////////
BattleNpcScript::BattleNpcScript( uint32_t npcId ) :
ScriptObject( npcId, typeid( BattleNpcScript ).hash_code() )
{
}
///////////////////////////////////////////////////////////////////
ZoneScript::ZoneScript( uint32_t zoneId ) :
ScriptObject( zoneId, typeid( ZoneScript ).hash_code() )
{
}
void ZoneScript::onZoneInit()
{
}
///////////////////////////////////////////////////////////////////
InstanceContentScript::InstanceContentScript( uint32_t instanceContentId ) :
ScriptObject( uint32_t{ 0x8003 } << 16 | instanceContentId, typeid( InstanceContentScript ).hash_code() )
{
}
void InstanceContentScript::onInit( InstanceContentPtr instance )
{
}
void InstanceContentScript::onUpdate( InstanceContentPtr instance, uint32_t currTime )
{
}
void InstanceContentScript::onEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
uint16_t param2 )
{
}

View file

@ -2,10 +2,7 @@
#define NATIVE_SCRIPT_API #define NATIVE_SCRIPT_API
#include <string> #include <string>
#include <typeinfo> #include "ForwardsZone.h"
#include <typeindex>
#include <Event/EventHandler.h>
#include "Forwards.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#define EXPORT __declspec( dllexport ) #define EXPORT __declspec( dllexport )
@ -34,81 +31,59 @@ public:
* @param id an ID which uniquely identifies this script in relation to it's type * @param id an ID which uniquely identifies this script in relation to it's type
* @param type The RTTI hash code of the implementing type to uniquely identify it * @param type The RTTI hash code of the implementing type to uniquely identify it
*/ */
ScriptObject( uint32_t id, std::size_t type ) : ScriptObject( uint32_t id, std::size_t type );
m_id( id ),
m_type( type )
{
}
/*! /*!
* @brief Gets the ID set for this script * @brief Gets the ID set for this script
* *
* @return The allocated ID of the script set during object construction * @return The allocated ID of the script set during object construction
*/ */
virtual uint32_t getId() const virtual uint32_t getId() const;
{
return m_id;
}
/*! /*!
* @brief Gets the unique identifier (hash_code) of the script * @brief Gets the unique identifier (hash_code) of the script
* *
* @return The hash_code of the script * @return The hash_code of the script
*/ */
virtual std::size_t getType() const virtual std::size_t getType() const;
{
return m_type;
}
}; };
/*! /*!
* @brief The base class for any scripts that implement behaviour related to status effects. * @brief The base class for any scripts that implement behaviour related to status effects.
*/ */
class StatusEffectScript : class StatusEffectScript : public ScriptObject
public ScriptObject
{ {
public: public:
explicit StatusEffectScript( uint32_t effectId ) : explicit StatusEffectScript( uint32_t effectId );
ScriptObject( effectId, typeid( StatusEffectScript ).hash_code() )
{
}
/*! /*!
* @brief Called on each tick that a status effect is active on an actor * @brief Called on each tick that a status effect is active on an actor
* *
* @param actor the actor the status effect is ticking on * @param actor the actor the status effect is ticking on
*/ */
virtual void onTick( Entity::Chara& actor ) virtual void onTick( Entity::Chara& actor );
{
}
/*! /*!
* @brief Called when the status effect is applied to an actor * @brief Called when the status effect is applied to an actor
* *
* @param actor the actor on which the status effect was applied to * @param actor the actor on which the status effect was applied to
*/ */
virtual void onApply( Entity::Chara& actor ) virtual void onApply( Entity::Chara& actor );
{
}
/*! /*!
* @brief Called when the actor (usually a player) removes the status effect by right clicking it * @brief Called when the actor (usually a player) removes the status effect by right clicking it
* *
* @param actor The actor on which the effect was removed from * @param actor The actor on which the effect was removed from
*/ */
virtual void onRemove( Entity::Chara& actor ) virtual void onRemove( Entity::Chara& actor );
{
}
/*! /*!
* @brief Called when the status effect expires * @brief Called when the status effect expires
* *
* @param actor The actor on which the efect expired on * @param actor The actor on which the efect expired on
*/ */
virtual void onExpire( Entity::Chara& actor ) virtual void onExpire( Entity::Chara& actor );
{
}
/*! /*!
* @brief Called when the player with the status effect collides with another player, eg. hot potato * @brief Called when the player with the status effect collides with another player, eg. hot potato
@ -116,175 +91,116 @@ public:
* @param actor The actor which has status effect * @param actor The actor which has status effect
* @param actorHit The actor who collided with the status effect owner * @param actorHit The actor who collided with the status effect owner
*/ */
virtual void onPlayerCollision( Entity::Chara& actor, Entity::Chara& actorHit ) virtual void onPlayerCollision( Entity::Chara& actor, Entity::Chara& actorHit );
{
}
/*! /*!
* @brief Called when the owner finishes a cast * @brief Called when the owner finishes a cast
* *
* @param actor The actor who finished a cast * @param actor The actor who finished a cast
*/ */
virtual void onPlayerFinishCast( Entity::Chara& actor ) virtual void onPlayerFinishCast( Entity::Chara& actor );
{
}
/*! /*!
* @brief Called when the status effect owner was damaged * @brief Called when the status effect owner was damaged
* *
* @param actor The actor that was damaged * @param actor The actor that was damaged
*/ */
virtual void onPlayerDamaged( Entity::Chara& actor ) virtual void onPlayerDamaged( Entity::Chara& actor );
{
}
/*! /*!
* @brief Called when the status effect owner dies * @brief Called when the status effect owner dies
* *
* @param actor The actor that died * @param actor The actor that died
*/ */
virtual void onPlayerDeath( Entity::Chara& actor ) virtual void onPlayerDeath( Entity::Chara& actor );
{
}
}; };
/*! /*!
* @brief The base class for any scripts that implement behaviour related to actions * @brief The base class for any scripts that implement behaviour related to actions
*/ */
class ActionScript : class ActionScript : public ScriptObject
public ScriptObject
{ {
public: public:
explicit ActionScript( uint32_t abilityId ) : explicit ActionScript( uint32_t abilityId );
ScriptObject( abilityId, typeid( ActionScript ).hash_code() )
{
}
virtual void onStart( Entity::Chara& sourceActor, Entity::Chara& targetActor ) virtual void onStart( Entity::Chara& sourceActor, Entity::Chara& targetActor );
{
}
virtual void onCastFinish( Entity::Player& player, Entity::Chara& targetActor ) virtual void onCastFinish( Entity::Player& player, Entity::Chara& targetActor );
{
}
virtual void onInterrupt( Entity::Chara& sourceActor/*, Core::Entity::Chara targetActor*/ ) virtual void onInterrupt( Entity::Chara& sourceActor/*, Core::Entity::Chara targetActor*/ );
{
}
}; };
/*! /*!
* @brief The base class for any scripts that implement behaviour related to the event system. * @brief The base class for any scripts that implement behaviour related to the event system.
* This includes but is not limited to: NPCs, shops, some world objects * This includes but is not limited to: NPCs, shops, some world objects
*/ */
class EventScript : class EventScript : public ScriptObject
public ScriptObject
{ {
protected: protected:
template< typename Ret, class Obj > template< typename Ret, class Obj >
inline Event::EventHandler::SceneChainCallback bindScene( Ret ( Obj::*f )( Entity::Player& ) ) inline std::function< void( Entity::Player& ) > bindScene( Ret ( Obj::*f )( Entity::Player& ) )
{ {
return std::bind( f, static_cast< Obj* >( this ), std::placeholders::_1 ); return std::bind( f, static_cast< Obj* >( this ), std::placeholders::_1 );
} }
public: public:
explicit EventScript( uint32_t questId ) : explicit EventScript( uint32_t questId );
ScriptObject( questId, typeid( EventScript ).hash_code() )
{
}
virtual void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) virtual void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId );
{
}
virtual void onNpcKill( uint32_t npcId, Entity::Player& player ) virtual void onNpcKill( uint32_t npcId, Entity::Player& player );
{
}
virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Entity::Player& player ) virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Entity::Player& player );
{
}
virtual void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) virtual void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
{
}
virtual void onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z ) virtual void onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
{
}
virtual void onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z ) virtual void onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
{
}
virtual void virtual void
onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId ) onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId );
{
}
virtual void onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, virtual void onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
uint32_t catalogId ) uint32_t catalogId );
{
}
}; };
/*! /*!
* @brief The base class for any scripts that implement behaviour related to BattleNPCs * @brief The base class for any scripts that implement behaviour related to BattleNPCs
*/ */
class BattleNpcScript : class BattleNpcScript : public ScriptObject
public ScriptObject
{ {
public: public:
explicit BattleNpcScript( uint32_t npcId ) : explicit BattleNpcScript( uint32_t npcId );
ScriptObject( npcId, typeid( BattleNpcScript ).hash_code() )
{
}
}; };
/*! /*!
* @brief The base class for any scripts that implement behaviour related to zones * @brief The base class for any scripts that implement behaviour related to zones
*/ */
class ZoneScript : class ZoneScript : public ScriptObject
public ScriptObject
{ {
public: public:
explicit ZoneScript( uint32_t zoneId ) : explicit ZoneScript( uint32_t zoneId );
ScriptObject( zoneId, typeid( ZoneScript ).hash_code() )
{
}
virtual void onZoneInit() virtual void onZoneInit();
{
}
}; };
/*! /*!
* @brief The base class for any scripts that implement behaviour related to instance content zones * @brief The base class for any scripts that implement behaviour related to instance content zones
*/ */
class InstanceContentScript : class InstanceContentScript : public ScriptObject
public ScriptObject
{ {
public: public:
explicit InstanceContentScript( uint32_t instanceContentId ) : explicit InstanceContentScript( uint32_t instanceContentId );
ScriptObject( uint32_t{ 0x8003 } << 16 | instanceContentId, typeid( InstanceContentScript ).hash_code() )
{
}
virtual void onInit( InstanceContentPtr instance ) virtual void onInit( InstanceContentPtr instance );
{
}
virtual void onUpdate( InstanceContentPtr instance, uint32_t currTime ) virtual void onUpdate( InstanceContentPtr instance, uint32_t currTime );
{
}
virtual void onEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, virtual void onEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
uint16_t param2 ) uint16_t param2 );
{
}
}; };
#endif #endif

View file

@ -8,7 +8,7 @@
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Config/ConfigMgr.h> #include <Config/ConfigMgr.h>
#include "watchdog/Watchdog.h" #include "Watchdog.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/InstanceContent.h" #include "Zone/InstanceContent.h"
@ -141,7 +141,7 @@ bool Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set<
boost::filesystem::directory_iterator iter( targetDir ); boost::filesystem::directory_iterator iter( targetDir );
boost::filesystem::directory_iterator eod; boost::filesystem::directory_iterator eod;
BOOST_FOREACH( boost::filesystem::path const& i, make_pair( iter, eod ) ) BOOST_FOREACH( boost::filesystem::path const& i, std::make_pair( iter, eod ) )
{ {
if( is_regular_file( i ) && boost::filesystem::extension( i.string() ) == ext ) if( is_regular_file( i ) && boost::filesystem::extension( i.string() ) == ext )
{ {

View file

@ -29,6 +29,8 @@
#include "ForwardsZone.h" #include "ForwardsZone.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <thread> #include <thread>
#include "Framework.h" #include "Framework.h"
@ -216,7 +218,7 @@ void Core::ServerZone::mainLoop()
while( isRunning() ) while( isRunning() )
{ {
this_thread::sleep_for( chrono::milliseconds( 50 ) ); std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
auto currTime = Util::getTimeSeconds(); auto currTime = Util::getTimeSeconds();
@ -224,7 +226,7 @@ void Core::ServerZone::mainLoop()
pScriptMgr->update(); pScriptMgr->update();
lock_guard< std::mutex > lock( m_sessionMutex ); std::lock_guard< std::mutex > lock( m_sessionMutex );
for( auto sessionIt : m_sessionMapById ) for( auto sessionIt : m_sessionMapById )
{ {
auto session = sessionIt.second; auto session = sessionIt.second;

View file

@ -9,8 +9,6 @@
#include "ForwardsZone.h" #include "ForwardsZone.h"
#include "Actor/BNpcTemplate.h"
namespace Core { namespace Core {
class ServerZone class ServerZone

View file

@ -0,0 +1,322 @@
/*
Watchdog
Copyright (c) 2014, Simon Geilfus
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <map>
#include <string>
#include <thread>
#include <memory>
#include <atomic>
#include <mutex>
#include <boost/filesystem.hpp>
namespace ci { namespace fs = boost::filesystem; }
//! Exception for when Watchdog can't locate a file or parse the wildcard
class WatchedFileSystemExc : public std::exception {
public:
WatchedFileSystemExc( const ci::fs::path &path )
{
m_message = "Failed to find the file or directory at: " + path.string();
}
virtual const char* what() const throw() { return m_message.c_str(); }
std::string m_message;
};
//! Watchdog class.
class Watchdog {
public:
//! Watches a file or directory for modification and call back the specified std::function. The path specified is passed as argument of the callback even if there is multiple files. Use the second watch method if you want to receive a list of all the files that have been modified.
static void watch( const ci::fs::path &path, const std::function<void(const ci::fs::path&)> &callback )
{
watchImpl( path, callback, std::function<void(const std::vector<ci::fs::path>&)>() );
}
//! Watches a file or directory for modification and call back the specified std::function. A list of modified files or directory is passed as argument of the callback. Use this version only if you are watching multiple files or a directory.
static void watchMany( const ci::fs::path &path, const std::function<void(const std::vector<ci::fs::path>&)> &callback )
{
watchImpl( path, std::function<void(const ci::fs::path&)>(), callback );
}
//! Unwatches a previously registrated file or directory
static void unwatch( const ci::fs::path &path )
{
watchImpl( path );
}
//! Unwatches all previously registrated file or directory
static void unwatchAll()
{
watchImpl( ci::fs::path() );
}
//! Sets the last modification time of a file or directory. by default sets the time to the current time
static void touch( const ci::fs::path &path, std::time_t time = std::time( nullptr ) )
{
// if the file or directory exists change its last write time
if( ci::fs::exists( path ) ){
ci::fs::last_write_time( path, time );
return;
}
// if not, visit each path if there's a wildcard
if( path.string().find( "*" ) != std::string::npos ){
visitWildCardPath( path, [time]( const ci::fs::path &p ){
ci::fs::last_write_time( p, time );
return false;
} );
}
// otherwise throw an exception
else {
throw WatchedFileSystemExc( path );
}
}
protected:
Watchdog()
: mWatching(false)
{
}
void close()
{
// remove all watchers
unwatchAll();
// stop the thread
mWatching = false;
if( mThread->joinable() ) mThread->join();
}
void start()
{
mWatching = true;
mThread = std::unique_ptr<std::thread>( new std::thread( [this](){
// keep watching for modifications every ms milliseconds
auto ms = std::chrono::milliseconds( 500 );
while( mWatching ) {
do {
// iterate through each watcher and check for modification
std::lock_guard<std::mutex> lock( mMutex );
auto end = mFileWatchers.end();
for( auto it = mFileWatchers.begin(); it != end; ++it ) {
it->second.watch();
}
// lock will be released before this thread goes to sleep
} while( false );
// make this thread sleep for a while
std::this_thread::sleep_for( ms );
}
} ) );
}
static void watchImpl( const ci::fs::path &path, const std::function<void(const ci::fs::path&)> &callback = std::function<void(const ci::fs::path&)>(), const std::function<void(const std::vector<ci::fs::path>&)> &listCallback = std::function<void(const std::vector<ci::fs::path>&)>() )
{
// create the static Watchdog instance
static Watchdog wd;
// and start its thread
if( !wd.mWatching ) {
wd.start();
}
const std::string key = path.string();
// add a new watcher
if( callback || listCallback ){
std::string filter;
ci::fs::path p = path;
// try to see if there's a match for the wildcard
if( path.string().find( "*" ) != std::string::npos ){
bool found = false;
std::pair<ci::fs::path,std::string> pathFilter = visitWildCardPath( path, [&found]( const ci::fs::path &p ){
found = true;
return true;
} );
if( !found ){
throw WatchedFileSystemExc( path );
}
else {
p = pathFilter.first;
filter = pathFilter.second;
}
}
std::lock_guard<std::mutex> lock( wd.mMutex );
if( wd.mFileWatchers.find( key ) == wd.mFileWatchers.end() ){
wd.mFileWatchers.emplace( make_pair( key, Watcher( p, filter, callback, listCallback ) ) );
}
}
// if there is no callback that means that we are unwatching
else {
// if the path is empty we unwatch all files
if( path.empty() ){
std::lock_guard<std::mutex> lock( wd.mMutex );
for( auto it = wd.mFileWatchers.begin(); it != wd.mFileWatchers.end(); ) {
it = wd.mFileWatchers.erase( it );
}
}
// or the specified file or directory
else {
std::lock_guard<std::mutex> lock( wd.mMutex );
auto watcher = wd.mFileWatchers.find( key );
if( watcher != wd.mFileWatchers.end() ){
wd.mFileWatchers.erase( watcher );
}
}
}
}
static std::pair<ci::fs::path,std::string> getPathFilterPair( const ci::fs::path &path )
{
// extract wildcard and parent path
std::string key = path.string();
ci::fs::path p = path;
size_t wildCardPos = key.find( "*" );
std::string filter;
if( wildCardPos != std::string::npos ){
filter = path.filename().string();
p = path.parent_path();
}
// throw an exception if the file doesn't exist
if( filter.empty() && !ci::fs::exists( p ) ){
throw WatchedFileSystemExc( path );
}
return std::make_pair( p, filter );
}
static std::pair<ci::fs::path,std::string> visitWildCardPath( const ci::fs::path &path, const std::function<bool(const ci::fs::path&)> &visitor ){
std::pair<ci::fs::path, std::string> pathFilter = getPathFilterPair( path );
if( !pathFilter.second.empty() ){
std::string full = ( pathFilter.first / pathFilter.second ).string();
size_t wildcardPos = full.find( "*" );
std::string before = full.substr( 0, wildcardPos );
std::string after = full.substr( wildcardPos + 1 );
ci::fs::directory_iterator end;
for( ci::fs::directory_iterator it( pathFilter.first ); it != end; ++it ){
std::string current = it->path().string();
size_t beforePos = current.find( before );
size_t afterPos = current.find( after );
if( ( beforePos != std::string::npos || before.empty() )
&& ( afterPos != std::string::npos || after.empty() ) ) {
if( visitor( it->path() ) ){
break;
}
}
}
}
return pathFilter;
}
class Watcher {
public:
Watcher( const ci::fs::path &path, const std::string &filter, const std::function<void(const ci::fs::path&)> &callback, const std::function<void(const std::vector<ci::fs::path>&)> &listCallback )
: mPath(path), mFilter(filter), mCallback(callback), mListCallback(listCallback)
{
// make sure we store all initial write time
if( !mFilter.empty() ) {
std::vector<ci::fs::path> paths;
visitWildCardPath( path / filter, [this,&paths]( const ci::fs::path &p ){
hasChanged( p );
paths.push_back( p );
return false;
} );
// this means that the first watch won't call the callback function
// so we have to manually call it here
if( mCallback ){
mCallback( mPath / mFilter );
}
else {
mListCallback( paths );
}
}
}
void watch()
{
// if there's no filter we just check for one item
if( mFilter.empty() && hasChanged( mPath ) && mCallback ){
mCallback( mPath );
//#error TODO: still have to figure out an elegant way to do this without cinder
}
// otherwise we check the whole parent directory
else if( !mFilter.empty() ){
std::vector<ci::fs::path> paths;
visitWildCardPath( mPath / mFilter, [this,&paths]( const ci::fs::path &p ){
bool pathHasChanged = hasChanged( p );
if( pathHasChanged && mCallback ){
mCallback( mPath / mFilter );
//#error TODO: still have to figure out an elegant way to do this without cinder
return true;
}
else if( pathHasChanged && mListCallback ){
paths.push_back( p );
}
return false;
} );
if( paths.size() && mListCallback ){
mListCallback( paths );
}
}
}
bool hasChanged( const ci::fs::path &path )
{
// get the last modification time
auto time = ci::fs::last_write_time( path );
// add a new modification time to the map
std::string key = path.string();
if( mModificationTimes.find( key ) == mModificationTimes.end() ) {
mModificationTimes[ key ] = time;
return true;
}
// or compare with an older one
auto &prev = mModificationTimes[ key ];
if( prev < time ) {
prev = time;
return true;
}
return false;
};
protected:
ci::fs::path mPath;
std::string mFilter;
std::function<void(const ci::fs::path&)> mCallback;
std::function<void(const std::vector<ci::fs::path>&)> mListCallback;
std::map< std::string, std::time_t > mModificationTimes;
};
std::mutex mMutex;
std::atomic<bool> mWatching;
std::unique_ptr<std::thread> mThread;
std::map<std::string,Watcher> mFileWatchers;
};

View file

@ -30,12 +30,13 @@ using namespace Core::Network::Packets::Server;
using namespace Core::Network::ActorControl; using namespace Core::Network::ActorControl;
Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration, Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration,
uint16_t territoryType,
uint32_t guId, uint32_t guId,
const std::string& internalName, const std::string& internalName,
const std::string& contentName, const std::string& contentName,
uint32_t instanceContentId ) uint32_t instanceContentId )
: :
Zone( static_cast< uint16_t >( pInstanceConfiguration->territoryType ), guId, internalName, contentName ), Zone( static_cast< uint16_t >( territoryType ), guId, internalName, contentName ),
Director( Event::Director::InstanceContent, instanceContentId ), Director( Event::Director::InstanceContent, instanceContentId ),
m_instanceConfiguration( pInstanceConfiguration ), m_instanceConfiguration( pInstanceConfiguration ),
m_instanceContentId( instanceContentId ), m_instanceContentId( instanceContentId ),

View file

@ -9,8 +9,7 @@ namespace Core {
namespace Data { namespace Data {
struct InstanceContent; struct InstanceContent;
} }
class InstanceContent : class InstanceContent : public Event::Director, public Zone
public Event::Director, public Zone
{ {
public: public:
enum InstanceContentState enum InstanceContentState
@ -22,6 +21,7 @@ public:
}; };
InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration, InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration,
uint16_t territoryType,
uint32_t guId, uint32_t guId,
const std::string& internalName, const std::string& internalName,
const std::string& contentName, const std::string& contentName,

View file

@ -218,17 +218,23 @@ Core::ZonePtr Core::TerritoryMgr::createTerritoryInstance( uint32_t territoryTyp
return pZone; return pZone;
} }
Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceContentId ) Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t contentFinderConditionId )
{ {
auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto pExdData = g_fw.get< Data::ExdDataGenerated >();
auto pContentFinderCondition = pExdData->get< Core::Data::ContentFinderCondition >( contentFinderConditionId );
if( !pContentFinderCondition )
return nullptr;
auto instanceContentId = pContentFinderCondition->instanceContent;
auto pInstanceContent = pExdData->get< Core::Data::InstanceContent >( instanceContentId ); auto pInstanceContent = pExdData->get< Core::Data::InstanceContent >( instanceContentId );
if( !pInstanceContent ) if( !pInstanceContent )
return nullptr; return nullptr;
if( !isInstanceContentTerritory( pInstanceContent->territoryType ) ) if( !isInstanceContentTerritory( pContentFinderCondition->territoryType ) )
return nullptr; return nullptr;
auto pTeri = getTerritoryDetail( pInstanceContent->territoryType ); auto pTeri = getTerritoryDetail( pContentFinderCondition->territoryType );
if( !pTeri || pInstanceContent->name.empty() ) if( !pTeri || pInstanceContent->name.empty() )
return nullptr; return nullptr;
@ -237,7 +243,7 @@ Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceConten
pLog->debug( "Starting instance for InstanceContent id: " + std::to_string( instanceContentId ) + pLog->debug( "Starting instance for InstanceContent id: " + std::to_string( instanceContentId ) +
" (" + pInstanceContent->name + ")" ); " (" + pInstanceContent->name + ")" );
auto pZone = make_InstanceContent( pInstanceContent, getNextInstanceId(), auto pZone = make_InstanceContent( pInstanceContent, pContentFinderCondition->territoryType, getNextInstanceId(),
pTeri->name, pInstanceContent->name, instanceContentId ); pTeri->name, pInstanceContent->name, instanceContentId );
pZone->init(); pZone->init();

View file

@ -95,7 +95,7 @@ public:
/*! creates a new instance for a given territoryTypeId */ /*! creates a new instance for a given territoryTypeId */
ZonePtr createTerritoryInstance( uint32_t territoryTypeId ); ZonePtr createTerritoryInstance( uint32_t territoryTypeId );
ZonePtr createInstanceContent( uint32_t instanceContentId ); ZonePtr createInstanceContent( uint32_t contentFinderConditionId );
/*! removes instance by instanceId, return true if successful */ /*! removes instance by instanceId, return true if successful */
bool removeTerritoryInstance( uint32_t territoryTypeId ); bool removeTerritoryInstance( uint32_t territoryTypeId );

View file

@ -1,7 +1,6 @@
#include <iostream> #include <iostream>
#include "ServerZone.h" #include "ServerZone.h"
#include <boost/algorithm/string.hpp>
#include <Framework.h> #include <Framework.h>
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>