1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-06-21 14:17:45 +00:00

Merge pull request #865 from collett8192/Sapphire5.58

Miscellaneous fixes and LGB/Cell updates ported from 3.x
This commit is contained in:
Mordred 2023-02-04 23:38:38 +01:00 committed by GitHub
commit 882eadbf47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 272 additions and 153 deletions

View file

@ -137,7 +137,7 @@ struct EObjData : public InstanceObject
uint8_t unknown1[0xC]; uint8_t unknown1[0xC];
}; };
enum TriggerBoxShape : uint32_t enum TriggerBoxShape : int32_t
{ {
TriggerBoxShapeBox = 0x1, TriggerBoxShapeBox = 0x1,
TriggerBoxShapeSphere = 0x2, TriggerBoxShapeSphere = 0x2,
@ -156,13 +156,18 @@ struct TriggerBoxInstanceObject
uint32_t reserved; uint32_t reserved;
}; };
struct EventRangeData : public InstanceObject
{
TriggerBoxInstanceObject triggerBox;
};
struct ExitRangeData : public InstanceObject struct ExitRangeData : public InstanceObject
{ {
TriggerBoxInstanceObject triggerBoxType; TriggerBoxInstanceObject triggerBoxType;
uint32_t exitType; uint32_t exitType;
uint16_t zoneId; uint16_t zoneId;
uint16_t destTerritoryType; uint16_t destTerritoryType;
int index; int32_t index;
uint32_t destInstanceObjectId; uint32_t destInstanceObjectId;
uint32_t returnInstanceObjectId; uint32_t returnInstanceObjectId;
float direction; float direction;

View file

@ -34,10 +34,10 @@ public:
memset( &header, 0, sizeof( header ) ); memset( &header, 0, sizeof( header ) );
}; };
LgbEntry( char* buf, uint32_t offset ) LgbEntry( char* buf, size_t offset )
{ {
m_buf = buf; m_buf = buf;
m_offset = offset; m_offset = static_cast< uint32_t >( offset );
header = *reinterpret_cast< InstanceObject* >( buf + offset ); header = *reinterpret_cast< InstanceObject* >( buf + offset );
}; };
@ -60,11 +60,9 @@ public:
std::string modelFileName; std::string modelFileName;
std::string collisionFileName; std::string collisionFileName;
LGB_BGPARTS_ENTRY() LGB_BGPARTS_ENTRY() = default;
{
};
LGB_BGPARTS_ENTRY( char* buf, uint32_t offset ) : LgbEntry( buf, offset ) LGB_BGPARTS_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< BgPartsData* >( buf + offset ); data = *reinterpret_cast< BgPartsData* >( buf + offset );
name = std::string( buf + offset + header.nameOffset ); name = std::string( buf + offset + header.nameOffset );
@ -80,7 +78,7 @@ public:
std::string name; std::string name;
std::string gimmickFileName; std::string gimmickFileName;
LGB_GIMMICK_ENTRY( char* buf, uint32_t offset ) : LgbEntry( buf, offset ) LGB_GIMMICK_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< GimmickData* >( buf + offset ); data = *reinterpret_cast< GimmickData* >( buf + offset );
name = std::string( buf + offset + header.nameOffset ); name = std::string( buf + offset + header.nameOffset );
@ -88,13 +86,13 @@ public:
}; };
}; };
class LGB_ENPC_ENTRY : public LgbEntry struct LGB_ENPC_ENTRY : public LgbEntry
{ {
public: public:
ENpcData data; ENpcData data;
std::string name; std::string name;
LGB_ENPC_ENTRY( char* buf, uint32_t offset ) : LGB_ENPC_ENTRY( char* buf, size_t offset ) :
LgbEntry( buf, offset ) LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< ENpcData* >( buf + offset ); data = *reinterpret_cast< ENpcData* >( buf + offset );
@ -102,13 +100,13 @@ public:
}; };
}; };
class LGB_EOBJ_ENTRY : public LgbEntry struct LGB_EOBJ_ENTRY : public LgbEntry
{ {
public: public:
EObjData data; EObjData data;
std::string name; std::string name;
LGB_EOBJ_ENTRY( char* buf, uint32_t offset ) : LgbEntry( buf, offset ) LGB_EOBJ_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< EObjData* >( buf + offset ); data = *reinterpret_cast< EObjData* >( buf + offset );
name = std::string( buf + offset + header.nameOffset ); name = std::string( buf + offset + header.nameOffset );
@ -121,7 +119,7 @@ public:
MapRangeData data; MapRangeData data;
std::string name; std::string name;
LGB_MAP_RANGE_ENTRY( char* buf, uint32_t offset ) : LgbEntry( buf, offset ) LGB_MAP_RANGE_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< MapRangeData* >( buf + offset ); data = *reinterpret_cast< MapRangeData* >( buf + offset );
name = std::string( buf + offset + header.nameOffset ); name = std::string( buf + offset + header.nameOffset );
@ -134,7 +132,7 @@ public:
ExitRangeData data; ExitRangeData data;
std::string name; std::string name;
LGB_EXIT_RANGE_ENTRY( char* buf, uint32_t offset ) : LgbEntry( buf, offset ) LGB_EXIT_RANGE_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< ExitRangeData* >( buf + offset ); data = *reinterpret_cast< ExitRangeData* >( buf + offset );
name = std::string( buf + offset + header.nameOffset ); name = std::string( buf + offset + header.nameOffset );
@ -146,41 +144,89 @@ struct LGB_POP_RANGE_ENTRY : public LgbEntry
public: public:
PopRangeData data; PopRangeData data;
LGB_POP_RANGE_ENTRY( char* buf, uint32_t offset ) : LgbEntry( buf, offset ) LGB_POP_RANGE_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{ {
data = *reinterpret_cast< PopRangeData* >( buf + offset ); data = *reinterpret_cast< PopRangeData* >( buf + offset );
}; };
}; };
struct LGB_EVENT_RANGE_ENTRY : public LgbEntry
{
public:
EventRangeData data;
LGB_EVENT_RANGE_ENTRY( char* buf, size_t offset ) : LgbEntry( buf, offset )
{
data = *reinterpret_cast< EventRangeData* >( buf + offset );
};
};
enum LayerSetReferencedType
{
All = 0x0,
Include = 0x1,
Exclude = 0x2,
Undetermined = 0x3,
};
struct LayerSetReferenced
{
uint32_t LayerSetID;
};
struct LayerSetReferencedList
{
LayerSetReferencedType ReferencedType;
int32_t LayerSets;
int32_t LayerSetCount;
};
struct LGB_GROUP_HEADER struct LGB_GROUP_HEADER
{ {
uint32_t id; uint32_t id;
int32_t groupNameOffset; int32_t groupNameOffset;
int32_t entriesOffset; int32_t entriesOffset;
int32_t entryCount; int32_t entryCount;
uint32_t unknown2; int8_t ToolModeVisible;
uint32_t unknown3; int8_t ToolModeReadOnly;
uint32_t unknown4; int8_t IsBushLayer;
uint32_t unknown5; int8_t PS3Visible;
uint32_t unknown6; int32_t LayerSetRef;
uint32_t unknown7; uint16_t FestivalID;
uint32_t unknown8; uint16_t FestivalPhaseID;
uint32_t unknown9; int8_t IsTemporary;
uint32_t unknown10; int8_t IsHousing;
uint16_t VersionMask;
uint32_t Reserved;
int32_t OBSetReferencedList;
int32_t OBSetReferencedList_Count;
int32_t OBSetEnableReferencedList;
int32_t OBSetEnableReferencedList_Count;
}; };
struct LGB_GROUP struct LGB_GROUP
{ {
LGB_FILE* parent; LGB_FILE* parent;
LGB_GROUP_HEADER header; LGB_GROUP_HEADER header;
LayerSetReferencedList layerSetReferencedList;
std::string name; std::string name;
std::vector< std::shared_ptr< LgbEntry > > entries; std::vector< std::shared_ptr< LgbEntry > > entries;
std::vector< LayerSetReferenced > refs;
LGB_GROUP( char* buf, LGB_FILE* parentStruct, uint32_t offset ) LGB_GROUP( char* buf, LGB_FILE* parentStruct, size_t offset )
{ {
parent = parentStruct; parent = parentStruct;
header = *reinterpret_cast< LGB_GROUP_HEADER* >( buf + offset ); header = *reinterpret_cast< LGB_GROUP_HEADER* >( buf + offset );
name = std::string( buf + offset + header.groupNameOffset ); name = std::string( buf + offset + header.groupNameOffset );
layerSetReferencedList = *reinterpret_cast< LayerSetReferencedList* >( buf + offset + header.LayerSetRef );
if( layerSetReferencedList.LayerSetCount > 0 )
{
refs.resize( layerSetReferencedList.LayerSetCount );
memcpy( (char*)&refs[0], buf + offset + header.LayerSetRef + layerSetReferencedList.LayerSets, layerSetReferencedList.LayerSetCount * sizeof( LayerSetReferenced ) );
}
const auto entriesOffset = offset + header.entriesOffset; const auto entriesOffset = offset + header.entriesOffset;
for( auto i = 0; i < header.entryCount; ++i ) for( auto i = 0; i < header.entryCount; ++i )
{ {
@ -209,6 +255,14 @@ struct LGB_GROUP
{ {
entries.push_back( std::make_shared< LGB_EXIT_RANGE_ENTRY >( buf, entryOffset ) ); entries.push_back( std::make_shared< LGB_EXIT_RANGE_ENTRY >( buf, entryOffset ) );
} }
else if( type == LgbEntryType::EventRange )
{
entries.push_back( std::make_shared< LGB_EVENT_RANGE_ENTRY >( buf, entryOffset ) );
}
else if( type == LgbEntryType::PopRange )
{
entries.push_back( std::make_shared< LGB_POP_RANGE_ENTRY >( buf, entryOffset ) );
}
else if( type == LgbEntryType::MapRange ) else if( type == LgbEntryType::MapRange )
{ {
entries.push_back( std::make_shared< LGB_MAP_RANGE_ENTRY >( buf, entryOffset ) ); entries.push_back( std::make_shared< LGB_MAP_RANGE_ENTRY >( buf, entryOffset ) );
@ -257,7 +311,7 @@ struct LGB_FILE
throw std::runtime_error( "Invalid LGB file!" ); throw std::runtime_error( "Invalid LGB file!" );
constexpr auto baseOffset = sizeof( header ); constexpr auto baseOffset = sizeof( header );
for( auto i = 0; i < header.groupCount; ++i ) for( size_t i = 0; i < header.groupCount; ++i )
{ {
const auto groupOffset = baseOffset + *reinterpret_cast< int32_t* >( buf + ( baseOffset + i * 4 ) ); const auto groupOffset = baseOffset + *reinterpret_cast< int32_t* >( buf + ( baseOffset + i * 4 ) );
const auto group = LGB_GROUP( buf, this, groupOffset ); const auto group = LGB_GROUP( buf, this, groupOffset );

View file

@ -907,10 +907,10 @@ namespace Sapphire::Network::Packets::Server
{ {
uint16_t serverId; uint16_t serverId;
uint16_t zoneId; uint16_t zoneId;
uint16_t unknown1; uint16_t zoneIndex;
uint16_t contentfinderConditionId; uint16_t contentfinderConditionId;
uint32_t unknown3; uint32_t layerSetId;
uint32_t unknown4; uint32_t layoutId;
uint8_t weatherId; uint8_t weatherId;
uint8_t bitmask; uint8_t bitmask;
uint8_t bitmask1; uint8_t bitmask1;

View file

@ -202,7 +202,7 @@ struct EObjData :
uint8_t unknown1[0xC]; uint8_t unknown1[0xC];
}; };
class LGB_EOBJ_ENTRY : struct LGB_EOBJ_ENTRY :
public LgbEntry public LgbEntry
{ {
public: public:

View file

@ -178,7 +178,7 @@ struct ENpcData :
uint8_t unknown1[0x24]; uint8_t unknown1[0x24];
}; };
class LGB_ENPC_ENTRY : struct LGB_ENPC_ENTRY :
public LgbEntry public LgbEntry
{ {
public: public:
@ -202,7 +202,7 @@ struct EObjData :
uint8_t unknown1[0xC]; uint8_t unknown1[0xC];
}; };
class LGB_EOBJ_ENTRY : struct LGB_EOBJ_ENTRY :
public LgbEntry public LgbEntry
{ {
public: public:

View file

@ -54,7 +54,7 @@ namespace Sapphire::Event
Aetheryte = 0x0005, Aetheryte = 0x0005,
GuildLeveAssignment = 0x0006, GuildLeveAssignment = 0x0006,
DefaultTalk = 0x0009, DefaultTalk = 0x0009,
Craft = 0x000A, Crafting = 0x000A,
CustomTalk = 0x000B, CustomTalk = 0x000B,
CompanyLeveOfficer = 0x000C, CompanyLeveOfficer = 0x000C,
Array = 0x000D, Array = 0x000D,
@ -65,7 +65,7 @@ namespace Sapphire::Event
ChocoboTaxiStand = 0x0012, ChocoboTaxiStand = 0x0012,
Opening = 0x0013, Opening = 0x0013,
ExitRange = 0x0014, ExitRange = 0x0014,
Fishing = 0x0015, Fish = 0x0015,
GCShop = 0x0016, GCShop = 0x0016,
GuildOrderGuide = 0x0017, GuildOrderGuide = 0x0017,
GuildOrderOfficer = 0x0018, GuildOrderOfficer = 0x0018,
@ -75,9 +75,9 @@ namespace Sapphire::Event
BahamutGuide = 0x001C, BahamutGuide = 0x001C,
InstanceContentGuide = 0x001D, InstanceContentGuide = 0x001D,
HousingAethernet = 0x001E, HousingAethernet = 0x001E,
FcTalk = 0x001F, SwitchTalk = 0x001F,
Adventure = 0x0021, Adventure = 0x0020,
DailyQuestSupply = 0x0022, DailyQuestSupply = 0x0021,
TripleTriad = 0x0023, TripleTriad = 0x0023,
PreHandler = 0x0036, PreHandler = 0x0036,
ICDirector = 0x8003, ICDirector = 0x8003,

View file

@ -3,9 +3,17 @@
#include <Util/Util.h> #include <Util/Util.h>
#include <Service.h> #include <Service.h>
#include <Exd/ExdDataGenerated.h>
#include <datReader/DatCategories/bg/LgbTypes.h>
#include <datReader/DatCategories/bg/lgb.h>
#include "EventMgr.h" #include "EventMgr.h"
#include "Event/EventHandler.h" #include "Event/EventHandler.h"
#include "Territory/InstanceObjectCache.h"
#include "Actor/Player.h"
using namespace Sapphire::Common; using namespace Sapphire::Common;
std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId ) std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId )
@ -104,6 +112,11 @@ std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId )
}*/ }*/
//return unknown + "GilShop"; //return unknown + "GilShop";
} }
case Event::EventHandler::EventHandlerType::SwitchTalk:
{
return "FcTalk";
}
default: default:
{ {
return unknown; return unknown;
@ -113,10 +126,15 @@ std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId )
uint32_t Sapphire::World::Manager::EventMgr::mapEventActorToRealActor( uint32_t eventActorId ) uint32_t Sapphire::World::Manager::EventMgr::mapEventActorToRealActor( uint32_t eventActorId )
{ {
auto& instanceObjectCache = Common::Service< InstanceObjectCache >::ref();
auto& exdData = Common::Service< Data::ExdDataGenerated >::ref(); auto& exdData = Common::Service< Data::ExdDataGenerated >::ref();
auto levelInfo = exdData.get< Sapphire::Data::Level >( eventActorId ); auto levelInfo = exdData.get< Sapphire::Data::Level >( eventActorId );
if( levelInfo ) if( levelInfo )
return levelInfo->object; return levelInfo->object;
else if( auto pObj = instanceObjectCache.getEObj( eventActorId ) )
return pObj->data.eobjId;
else if( auto pNpc = instanceObjectCache.getENpc( eventActorId ) )
return pNpc->data.enpcId;
return 0; return 0;
} }

View file

@ -19,11 +19,14 @@ void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::E
{ {
auto sequence = player.getNextInventorySequence(); auto sequence = player.getNextInventorySequence();
auto pMap = container->getItemMap(); auto pMap = container->getItemMap();
uint32_t itemCount = 0;
for( auto itM = pMap.begin(); itM != pMap.end(); ++itM ) for( auto itM = pMap.begin(); itM != pMap.end(); ++itM )
{ {
if( !itM->second ) if( !itM->second )
return; continue;
itemCount++;
if( container->getId() == Common::InventoryType::Currency || container->getId() == Common::InventoryType::Crystal ) if( container->getId() == Common::InventoryType::Currency || container->getId() == Common::InventoryType::Crystal )
{ {
@ -57,7 +60,7 @@ void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::E
auto containerInfoPacket = makeZonePacket< Server::FFXIVIpcContainerInfo >( player.getId() ); auto containerInfoPacket = makeZonePacket< Server::FFXIVIpcContainerInfo >( player.getId() );
containerInfoPacket->data().containerSequence = sequence; containerInfoPacket->data().containerSequence = sequence;
containerInfoPacket->data().numItems = container->getEntryCount(); containerInfoPacket->data().numItems = itemCount;
containerInfoPacket->data().containerId = container->getId(); containerInfoPacket->data().containerId = container->getId();
player.queuePacket( containerInfoPacket ); player.queuePacket( containerInfoPacket );

View file

@ -788,7 +788,14 @@ void Sapphire::World::Manager::TerritoryMgr::createAndJoinQuestBattle( Entity::P
{ {
auto qb = createQuestBattle( questBattleId ); auto qb = createQuestBattle( questBattleId );
if( !qb ) if( !qb )
{
auto& exdData = Common::Service< Data::ExdDataGenerated >::ref();
auto instanceInfo = exdData.get< Sapphire::Data::InstanceContent >( questBattleId );
if( !instanceInfo )
return; return;
qb = createInstanceContent( instanceInfo->order );
qb->getAsInstanceContent()->bindPlayer( player.getId() );
}
player.setInstance( qb ); player.setInstance( qb );

View file

@ -154,7 +154,7 @@ void Sapphire::Network::GameConnection::eventHandlerOutsideRange( const Packets:
std::string objName = eventMgr.getEventName( eventId ); std::string objName = eventMgr.getEventName( eventId );
player.sendDebug( "Calling: {0}.{1} - {2} p1: {3}", objName, eventName, eventId, param1 ); player.sendDebug( "Calling: {0}.{1} - {2} p1: {3}", objName, eventName, eventId, param1 );
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 ); player.eventStart( player.getId(), eventId, Event::EventHandler::OutsideRange, 1, param1 );
scriptMgr.onOutsideRange( player, eventId, param1, pos.x, pos.y, pos.z ); scriptMgr.onOutsideRange( player, eventId, param1, pos.x, pos.y, pos.z );

View file

@ -10,9 +10,7 @@
Sapphire::Cell::Cell() : Sapphire::Cell::Cell() :
m_bActive( false ), m_bActive( false ),
m_bLoaded( false ), m_playerCount( 0 )
m_playerCount( 0 ),
m_bUnloadPending( false )
{ {
m_bForcedActive = false; m_bForcedActive = false;
} }
@ -22,9 +20,8 @@ Sapphire::Cell::~Cell()
removeActors(); removeActors();
} }
void Sapphire::Cell::init( uint32_t x, uint32_t y, TerritoryPtr pZone ) void Sapphire::Cell::init( uint32_t x, uint32_t y )
{ {
m_pZone = pZone;
m_posX = static_cast< uint16_t >( x ); m_posX = static_cast< uint16_t >( x );
m_posY = static_cast< uint16_t >( y ); m_posY = static_cast< uint16_t >( y );
@ -57,9 +54,6 @@ void Sapphire::Cell::setActivity( bool state )
//} //}
if( m_bUnloadPending )
cancelPendingUnload();
} }
else if( m_bActive && !state ) else if( m_bActive && !state )
{ {
@ -94,40 +88,17 @@ void Sapphire::Cell::removeActors()
continue; continue;
} }
if( m_bUnloadPending )
{
}
} }
m_playerCount = 0; m_playerCount = 0;
m_bLoaded = false;
}
void Sapphire::Cell::queueUnloadPending()
{
if( m_bUnloadPending )
return;
m_bUnloadPending = true;
}
void Sapphire::Cell::cancelPendingUnload()
{
if( !m_bUnloadPending )
return;
} }
void Sapphire::Cell::unload() void Sapphire::Cell::unload()
{ {
assert( m_bUnloadPending );
if( m_bActive ) if( m_bActive )
return; return;
removeActors(); removeActors();
m_bUnloadPending = false;
} }

View file

@ -21,18 +21,15 @@ private:
uint16_t m_posY; uint16_t m_posY;
ActorSet m_actors; ActorSet m_actors;
bool m_bActive; bool m_bActive;
bool m_bLoaded;
bool m_bUnloadPending;
uint16_t m_playerCount; uint16_t m_playerCount;
TerritoryPtr m_pZone;
public: public:
Cell(); Cell();
~Cell(); ~Cell();
void init( uint32_t x, uint32_t y, TerritoryPtr pZone ); void init( uint32_t x, uint32_t y );
void addActor( Entity::ActorPtr pAct ); void addActor( Entity::ActorPtr pAct );
@ -72,37 +69,8 @@ public:
return m_bActive; return m_bActive;
} }
bool isLoaded() const
{
return m_bLoaded;
}
uint32_t getPlayerCount() const
{
return m_playerCount;
}
bool isUnloadPending() const
{
return m_bUnloadPending;
}
void setUnloadPending( bool up )
{
m_bUnloadPending = up;
}
void queueUnloadPending();
void cancelPendingUnload();
void unload(); void unload();
void setPermanentActivity( bool val )
{
m_bForcedActive = val;
}
bool isForcedActive() const bool isForcedActive() const
{ {
return m_bForcedActive; return m_bForcedActive;

View file

@ -6,10 +6,15 @@
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Network/CommonActorControl.h> #include <Network/CommonActorControl.h>
#include <Service.h> #include <Service.h>
#include <datReader/DatCategories/bg/pcb.h>
#include <datReader/DatCategories/bg/lgb.h>
#include <datReader/DatCategories/bg/sgb.h>
#include "Event/Director.h" #include "Event/Director.h"
#include "Event/EventDefs.h" #include "Event/EventDefs.h"
#include "Script/ScriptMgr.h" #include "Script/ScriptMgr.h"
#include "Manager/PlayerMgr.h"
#include "Manager/TerritoryMgr.h"
#include "Manager/EventMgr.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Actor/EventObject.h" #include "Actor/EventObject.h"
@ -21,6 +26,8 @@
#include "Event/EventHandler.h" #include "Event/EventHandler.h"
#include "InstanceContent.h" #include "InstanceContent.h"
#include "InstanceObjectCache.h"
using namespace Sapphire::Common; using namespace Sapphire::Common;
using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets;
@ -339,11 +346,22 @@ void Sapphire::InstanceContent::onBeforePlayerZoneIn( Sapphire::Entity::Player&
// if a player has already spawned once inside this instance, don't move them if they happen to zone in again // if a player has already spawned once inside this instance, don't move them if they happen to zone in again
if( !hasPlayerPreviouslySpawned( player ) ) if( !hasPlayerPreviouslySpawned( player ) )
{ {
auto& exdData = Common::Service< Data::ExdDataGenerated >::ref();
auto& instanceObjectCache = Common::Service< InstanceObjectCache >::ref();
auto contentInfo = exdData.get< Data::InstanceContent >( m_instanceContentId );
auto rect = instanceObjectCache.getEventRange( contentInfo->lGBEventRange );
if( m_pEntranceEObj != nullptr ) if( m_pEntranceEObj != nullptr )
{ {
player.setRot( PI ); player.setRot( PI );
player.setPos( m_pEntranceEObj->getPos() ); player.setPos( m_pEntranceEObj->getPos() );
} }
else if( rect )
{
player.setRot( PI );
player.setPos( { rect->header.transform.translation.x, rect->header.transform.translation.y, rect->header.transform.translation.z } );
}
else else
{ {
player.setRot( PI ); player.setRot( PI );

View file

@ -23,6 +23,65 @@ namespace Sapphire
DutyFinished DutyFinished
}; };
/*0x40000001 - INSTANCE_CONTENT_ORDER_SYSTEM_START
0x40000002 - INSTANCE_CONTENT_ORDER_SYSTEM_CLEAR_NORMAL
0x40000003 - INSTANCE_CONTENT_ORDER_SYSTEM_RESET_???? ( not really sure about that, seems like reset, arg1 must be 1 )
0x40000004 - INSTANCE_CONTENT_ORDER_PVP_READY ( unsure )
0x40000005 - INSTANCE_CONTENT_ORDER_SYSTEM_RESET
0x40000006 - INSTANCE_CONTENT_ORDER_SYSTEM_RESTART
0x40000007 - INSTANCE_CONTENT_ORDER_SYSTEM_VOTE_ENABLE
0x40000008 - INSTANCE_CONTENT_ORDER_SYSTEM_VOTE_START
0x40000009 - INSTANCE_CONTENT_ORDER_SYSTEM_VOTE_RESULT
0x4000000A - INSTANCE_CONTENT_ORDER_SYSTEM_VOTE_CANCEL
0x4000000B - INSTANCE_CONTENT_ORDER_SYSTEM_UPDATE_CLEAR_MEMBER
0x4000000C - INSTANCE_CONTENT_ORDER_SYSTEM_PLAY_SHARED_GROUP
0x4000000D - INSTANCE_CONTENT_ORDER_SYSTEM_SyncTime?
0x4000000E - INSTANCE_CONTENT_ORDER_SYSTEM_Unknown - no args - some timer set */
enum DirectorEventId : uint32_t
{
DEBUG_TimeSync = 0xC0000001,
DutyCommence = 0x40000001,
BattleGroundMusic = 0x40000002,
SetStringendoMode = 0x40000003,
DutyComplete = 0x40000004,
InvalidateTodoList = 0x40000005,
LoadingScreen = 0x40000007,
Forward = 0x40000008,
VoteState = 0x40000009,
VoteStart = 0x4000000A,
VoteResult = 0x4000000B,
VoteFinish = 0x4000000C,
TreasureVoteRefresh = 0x4000000D,
SetSharedGroupId = 0x4000000E,
FirstTimeNotify = 0x4000000F
};
enum EventHandlerOrderId : uint32_t
{
SheetDataReady = 0x80000000,
AbortContent = 0x40000001, //forceFlag
LuaOnStartCutscene = 0x40000002, //returnCode
VoteRequest = 0x40000003, //voteType
VoteReplay = 0x40000004 //voteType, accept
};
enum DirectorSceneId
{
None = 0,
SetupEventArgsOnStart = 1,
SetupEventArgsInProgress = 2,
DutyFailed = 5
};
enum TerminateReason : uint8_t
{
TimeExpired,
TimeLimitReached,
Abandoned,
Ended
};
InstanceContent( std::shared_ptr< Sapphire::Data::InstanceContent > pInstanceConfiguration, InstanceContent( std::shared_ptr< Sapphire::Data::InstanceContent > pInstanceConfiguration,
uint16_t territoryType, uint16_t territoryType,
uint32_t guId, uint32_t guId,

View file

@ -100,6 +100,7 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
{ {
for( const auto& pEntry : group.entries ) for( const auto& pEntry : group.entries )
{ {
if( pEntry->getType() == LgbEntryType::MapRange ) if( pEntry->getType() == LgbEntryType::MapRange )
{ {
auto pMapRange = std::reinterpret_pointer_cast< LGB_MAP_RANGE_ENTRY >( pEntry ); auto pMapRange = std::reinterpret_pointer_cast< LGB_MAP_RANGE_ENTRY >( pEntry );
@ -115,15 +116,24 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
auto pPopRange = std::reinterpret_pointer_cast< LGB_POP_RANGE_ENTRY >( pEntry ); auto pPopRange = std::reinterpret_pointer_cast< LGB_POP_RANGE_ENTRY >( pEntry );
m_popRangeCache.insert( id, pPopRange ); m_popRangeCache.insert( id, pPopRange );
} }
else if( pEntry->getType() == LgbEntryType::EventNpc ) else if( pEntry->getType() == LgbEntryType::SharedGroup6 )
{ {
auto pEventNpc = std::reinterpret_pointer_cast< LGB_ENPC_ENTRY >( pEntry );
m_eventNpcCache.insert( id, pEventNpc );
} }
else if( pEntry->getType() == LgbEntryType::EventObject ) else if( pEntry->getType() == LgbEntryType::EventObject )
{ {
auto pEventObj = std::reinterpret_pointer_cast< LGB_EOBJ_ENTRY >( pEntry ); auto pEObj = std::reinterpret_pointer_cast< LGB_EOBJ_ENTRY >( pEntry );
m_eventObjCache.insert( id, pEventObj ); m_eobjCache.insert( 0, pEObj );
}
else if( pEntry->getType() == LgbEntryType::EventNpc )
{
auto pENpc = std::reinterpret_pointer_cast< LGB_ENPC_ENTRY >( pEntry );
m_enpcCache.insert( 0, pENpc );
}
else if( pEntry->getType() == LgbEntryType::EventRange )
{
auto pEventRange = std::reinterpret_pointer_cast< LGB_EVENT_RANGE_ENTRY >( pEntry );
m_eventRangeCache.insert( 0, pEventRange );
} }
} }
} }
@ -132,8 +142,8 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
std::cout << "\n"; std::cout << "\n";
Logger::debug( Logger::debug(
"InstanceObjectCache Cached: MapRange: {} ExitRange: {} PopRange: {} ENpc: {} Eobj: {}", "InstanceObjectCache Cached: MapRange: {} ExitRange: {} PopRange: {} EventNpc: {} EventRange: {}",
m_mapRangeCache.size(), m_exitRangeCache.size(), m_popRangeCache.size(), m_eventNpcCache.size(), m_eventObjCache.size() m_mapRangeCache.size(), m_exitRangeCache.size(), m_popRangeCache.size(), m_enpcCache.size(), m_eventRangeCache.size()
); );
} }
@ -156,26 +166,31 @@ Sapphire::InstanceObjectCache::PopRangePtr
return m_popRangeCache.get( zoneId, popRangeId ); return m_popRangeCache.get( zoneId, popRangeId );
} }
Sapphire::InstanceObjectCache::EventNpcPtr Sapphire::InstanceObjectCache::EObjPtr
Sapphire::InstanceObjectCache::getEventNpc( uint16_t zoneId, uint32_t eventNpcId ) Sapphire::InstanceObjectCache::getEObj( uint32_t eObjId )
{ {
return m_eventNpcCache.get( zoneId, eventNpcId ); return m_eobjCache.get( 0, eObjId );
} }
Sapphire::InstanceObjectCache::EventObjPtr Sapphire::InstanceObjectCache::ENpcPtr
Sapphire::InstanceObjectCache::getEventObj( uint16_t zoneId, uint32_t eventObjId ) Sapphire::InstanceObjectCache::getENpc( uint32_t eNpcId )
{ {
return m_eventObjCache.get( zoneId, eventObjId ); return m_enpcCache.get( 0, eNpcId );
}
Sapphire::InstanceObjectCache::EventRangePtr Sapphire::InstanceObjectCache::getEventRange( uint32_t eventRangeId )
{
return m_eventRangeCache.get( 0, eventRangeId );
} }
Sapphire::InstanceObjectCache::EventNpcMapPtr Sapphire::InstanceObjectCache::EventNpcMapPtr
Sapphire::InstanceObjectCache::getAllEventNpc( uint16_t zoneId ) Sapphire::InstanceObjectCache::getAllEventNpc( uint16_t zoneId )
{ {
return m_eventNpcCache.getAll( zoneId ); return m_enpcCache.getAll( zoneId );
} }
Sapphire::InstanceObjectCache::EventObjMapPtr Sapphire::InstanceObjectCache::EventObjMapPtr
Sapphire::InstanceObjectCache::getAllEventObj( uint16_t zoneId ) Sapphire::InstanceObjectCache::getAllEventObj( uint16_t zoneId )
{ {
return m_eventObjCache.getAll( zoneId ); return m_eobjCache.getAll( zoneId );
} }

View file

@ -7,8 +7,9 @@
struct LGB_MAP_RANGE_ENTRY; struct LGB_MAP_RANGE_ENTRY;
struct LGB_EXIT_RANGE_ENTRY; struct LGB_EXIT_RANGE_ENTRY;
struct LGB_POP_RANGE_ENTRY; struct LGB_POP_RANGE_ENTRY;
struct LGB_ENPC_ENTRY;
struct LGB_EOBJ_ENTRY; struct LGB_EOBJ_ENTRY;
struct LGB_ENPC_ENTRY;
struct LGB_EVENT_RANGE_ENTRY;
namespace Sapphire namespace Sapphire
@ -65,9 +66,13 @@ namespace Sapphire
} }
} }
uint32_t size() const size_t size() const
{ {
return m_objectCache.size(); size_t size = 0;
for( auto& it = m_objectCache.begin(); it != m_objectCache.end(); ++it )
size += it->second.size();
return size;
} }
}; };
@ -77,11 +82,12 @@ namespace Sapphire
using MapRangePtr = std::shared_ptr< LGB_MAP_RANGE_ENTRY >; using MapRangePtr = std::shared_ptr< LGB_MAP_RANGE_ENTRY >;
using ExitRangePtr = std::shared_ptr< LGB_EXIT_RANGE_ENTRY >; using ExitRangePtr = std::shared_ptr< LGB_EXIT_RANGE_ENTRY >;
using PopRangePtr = std::shared_ptr< LGB_POP_RANGE_ENTRY >; using PopRangePtr = std::shared_ptr< LGB_POP_RANGE_ENTRY >;
using EventNpcPtr = std::shared_ptr< LGB_ENPC_ENTRY >; using EObjPtr = std::shared_ptr< LGB_EOBJ_ENTRY >;
using EventObjPtr = std::shared_ptr< LGB_EOBJ_ENTRY >; using ENpcPtr = std::shared_ptr< LGB_ENPC_ENTRY >;
using EventRangePtr = std::shared_ptr< LGB_EVENT_RANGE_ENTRY >;
using EventNpcMapPtr = std::unordered_map< uint32_t, EventNpcPtr >*; using EventNpcMapPtr = std::unordered_map< uint32_t, ENpcPtr >*;
using EventObjMapPtr = std::unordered_map< uint32_t, EventObjPtr >*; using EventObjMapPtr = std::unordered_map< uint32_t, EObjPtr >*;
InstanceObjectCache(); InstanceObjectCache();
~InstanceObjectCache() = default; ~InstanceObjectCache() = default;
@ -89,8 +95,9 @@ namespace Sapphire
MapRangePtr getMapRange( uint16_t zoneId, uint32_t mapRangeId ); MapRangePtr getMapRange( uint16_t zoneId, uint32_t mapRangeId );
ExitRangePtr getExitRange( uint16_t zoneId, uint32_t exitRangeId ); ExitRangePtr getExitRange( uint16_t zoneId, uint32_t exitRangeId );
PopRangePtr getPopRange( uint16_t zoneId, uint32_t popRangeId ); PopRangePtr getPopRange( uint16_t zoneId, uint32_t popRangeId );
EventNpcPtr getEventNpc( uint16_t zoneId, uint32_t eventNpcId ); EObjPtr getEObj( uint32_t eObjId );
EventObjPtr getEventObj( uint16_t zoneId, uint32_t eventObjId ); ENpcPtr getENpc( uint32_t eNpcId );
EventRangePtr getEventRange( uint32_t eventRangeId );
EventNpcMapPtr getAllEventNpc( uint16_t zoneId ); EventNpcMapPtr getAllEventNpc( uint16_t zoneId );
EventObjMapPtr getAllEventObj( uint16_t zoneId ); EventObjMapPtr getAllEventObj( uint16_t zoneId );
@ -99,8 +106,9 @@ namespace Sapphire
ObjectCache< LGB_MAP_RANGE_ENTRY > m_mapRangeCache; ObjectCache< LGB_MAP_RANGE_ENTRY > m_mapRangeCache;
ObjectCache< LGB_EXIT_RANGE_ENTRY > m_exitRangeCache; ObjectCache< LGB_EXIT_RANGE_ENTRY > m_exitRangeCache;
ObjectCache< LGB_POP_RANGE_ENTRY > m_popRangeCache; ObjectCache< LGB_POP_RANGE_ENTRY > m_popRangeCache;
ObjectCache< LGB_ENPC_ENTRY > m_eventNpcCache; ObjectCache< LGB_EOBJ_ENTRY > m_eobjCache;
ObjectCache< LGB_EOBJ_ENTRY > m_eventObjCache; ObjectCache< LGB_ENPC_ENTRY > m_enpcCache;
ObjectCache< LGB_EVENT_RANGE_ENTRY > m_eventRangeCache;
std::shared_ptr< Framework > m_pFramework; std::shared_ptr< Framework > m_pFramework;
}; };

View file

@ -214,7 +214,7 @@ void Sapphire::Territory::pushActor( Entity::ActorPtr pActor )
if( !pCell ) if( !pCell )
{ {
pCell = create( cx, cy ); pCell = create( cx, cy );
pCell->init( cx, cy, shared_from_this() ); pCell->init( cx, cy );
} }
pCell->addActor( pActor ); pCell->addActor( pActor );
@ -576,12 +576,10 @@ void Sapphire::Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t ra
if( isCellActive( posX, posY ) ) if( isCellActive( posX, posY ) )
{ {
pCell = create( posX, posY ); pCell = create( posX, posY );
pCell->init( posX, posY, shared_from_this() ); pCell->init( posX, posY );
pCell->setActivity( true ); pCell->setActivity( true );
assert( !pCell->isLoaded() );
} }
} }
else else
@ -590,11 +588,6 @@ void Sapphire::Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t ra
if( isCellActive( posX, posY ) && !pCell->isActive() ) if( isCellActive( posX, posY ) && !pCell->isActive() )
{ {
pCell->setActivity( true ); pCell->setActivity( true );
if( !pCell->isLoaded() )
{
}
} }
else if( !isCellActive( posX, posY ) && pCell->isActive() ) else if( !isCellActive( posX, posY ) && pCell->isActive() )
pCell->setActivity( false ); pCell->setActivity( false );
@ -623,7 +616,7 @@ void Sapphire::Territory::updateActorPosition( Entity::Actor& actor )
if( !pCell ) if( !pCell )
{ {
pCell = create( cellX, cellY ); pCell = create( cellX, cellY );
pCell->init( cellX, cellY, shared_from_this() ); pCell->init( cellX, cellY );
} }
// If object moved cell // If object moved cell