1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

Map previously unmapped eobj and enpc

This commit is contained in:
Mordred 2022-01-23 23:00:50 +01:00
parent 453f441ad3
commit 4cef7cdab9
15 changed files with 70 additions and 45 deletions

View file

@ -86,7 +86,7 @@ public:
}; };
}; };
class LGB_ENPC_ENTRY : public LgbEntry struct LGB_ENPC_ENTRY : public LgbEntry
{ {
public: public:
ENpcData data; ENpcData data;
@ -100,7 +100,7 @@ public:
}; };
}; };
class LGB_EOBJ_ENTRY : public LgbEntry struct LGB_EOBJ_ENTRY : public LgbEntry
{ {
public: public:
EObjData data; EObjData data;

View file

@ -196,7 +196,7 @@ public:
}; };
}; };
class LGB_EOBJ_ENTRY : public LgbEntry struct LGB_EOBJ_ENTRY : public LgbEntry
{ {
public: public:
EObjData data; EObjData data;

View file

@ -126,40 +126,38 @@ public:
void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override
{ {
auto actor = eventMgr().mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ); switch( actorId )
switch( actor )
{ {
case Eobject0: case Eobject0:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00001( quest, player ); Scene00001( quest, player );
break; break;
case Eobject1: case Eobject1:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00002( quest, player ); Scene00002( quest, player );
break; break;
case Eobject2: case Eobject2:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00003( quest, player ); Scene00003( quest, player );
break; break;
case Eobject3: case Eobject3:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00004( quest, player ); Scene00004( quest, player );
break; break;
case Eobject4: case Eobject4:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00005( quest, player ); Scene00005( quest, player );
break; break;
case Eobject5: case Eobject5:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00006( quest, player ); Scene00006( quest, player );
break; break;
case Eobject6: case Eobject6:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00007( quest, player ); Scene00007( quest, player );
break; break;
case Eobject7: case Eobject7:
eventMgr().eventStart( player, actor, getId(), Event::EventHandler::Nest, 0, 0 ); eventMgr().eventStart( player, actorId, getId(), Event::EventHandler::Nest, 0, 0 );
Scene00008( quest, player ); Scene00008( quest, player );
break; break;
} }

View file

@ -112,9 +112,8 @@ public:
} }
void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actor, uint32_t actionId ) override
{ {
auto actor = eventMgr().mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
switch( actor ) switch( actor )
{ {

View file

@ -140,9 +140,8 @@ public:
} }
} }
void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actor, uint32_t actionId ) override
{ {
auto actor = eventMgr().mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
switch( actor ) switch( actor )
{ {

View file

@ -216,9 +216,8 @@ public:
} }
} }
void onEventItem( World::Quest& quest, Entity::Player& player, uint64_t actorId ) override void onEventItem( World::Quest& quest, Entity::Player& player, uint64_t actor ) override
{ {
auto actor = eventMgr().mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
if( actor == Eobject0 ) if( actor == Eobject0 )
{ {
@ -238,9 +237,8 @@ public:
} }
} }
void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actor, uint32_t actionId ) override
{ {
auto actor = eventMgr().mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
if( actor == Actor3 && actionId == Action0 ) if( actor == Actor3 && actionId == Action0 )
{ {

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

@ -69,7 +69,6 @@ Sapphire::Entity::Player::Player() :
m_lastActionTick( 0 ), m_lastActionTick( 0 ),
m_bInCombat( false ), m_bInCombat( false ),
m_bLoadingComplete( false ), m_bLoadingComplete( false ),
m_bMarkedForZoning( false ),
m_zoningType( Common::ZoneingType::None ), m_zoningType( Common::ZoneingType::None ),
m_bAutoattack( false ), m_bAutoattack( false ),
m_markedForRemoval( false ), m_markedForRemoval( false ),
@ -476,7 +475,6 @@ void Sapphire::Entity::Player::forceZoneing( uint32_t zoneId )
void Sapphire::Entity::Player::performZoning( uint16_t territoryTypeId, uint32_t territoryId, const Common::FFXIVARR_POSITION3& pos, float rotation ) void Sapphire::Entity::Player::performZoning( uint16_t territoryTypeId, uint32_t territoryId, const Common::FFXIVARR_POSITION3& pos, float rotation )
{ {
m_pos = pos; m_pos = pos;
m_bMarkedForZoning = true;
setRot( rotation ); setRot( rotation );
auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto& teriMgr = Common::Service< TerritoryMgr >::ref();
@ -1228,11 +1226,6 @@ void Sapphire::Entity::Player::setLoadingComplete( bool bComplete )
m_bLoadingComplete = bComplete; m_bLoadingComplete = bComplete;
} }
bool Sapphire::Entity::Player::isMarkedForZoning() const
{
return m_bMarkedForZoning;
}
ZoneingType Sapphire::Entity::Player::getZoningType() const ZoneingType Sapphire::Entity::Player::getZoningType() const
{ {
return m_zoningType; return m_zoningType;
@ -1632,7 +1625,6 @@ void Sapphire::Entity::Player::sendZonePackets()
partyMgr.onMoveZone( *this ); partyMgr.onMoveZone( *this );
} }
m_bMarkedForZoning = false;
} }
void Sapphire::Entity::Player::setDirectorInitialized( bool isInitialized ) void Sapphire::Entity::Player::setDirectorInitialized( bool isInitialized )

View file

@ -585,9 +585,6 @@ namespace Sapphire::Entity
/*! mark this player for zoning, notify worldserver */ /*! mark this player for zoning, notify worldserver */
void performZoning( uint16_t territoryTypeId, uint32_t territoryId, const Common::FFXIVARR_POSITION3& pos, float rotation ); void performZoning( uint16_t territoryTypeId, uint32_t territoryId, const Common::FFXIVARR_POSITION3& pos, float rotation );
/*! return true if the player is marked for zoning */
bool isMarkedForZoning() const;
void sendZoneInPackets( uint32_t param1, bool pSetStatus ); void sendZoneInPackets( uint32_t param1, bool pSetStatus );
void finishZoning(); void finishZoning();
@ -928,7 +925,6 @@ namespace Sapphire::Entity
Common::ZoneingType m_zoningType; Common::ZoneingType m_zoningType;
bool m_bMarkedForZoning;
bool m_bNewAdventurer{}; bool m_bNewAdventurer{};
uint64_t m_onlineStatus; uint64_t m_onlineStatus;
uint64_t m_onlineStatusCustom; uint64_t m_onlineStatusCustom;

View file

@ -1,5 +1,4 @@
#include <Common.h> #include <Common.h>
#include <Exd/ExdData.h>
#include <Util/Util.h> #include <Util/Util.h>
#include <Service.h> #include <Service.h>
@ -10,6 +9,10 @@
#include "Event/Director.h" #include "Event/Director.h"
#include "Event/EventDefs.h" #include "Event/EventDefs.h"
#include <Exd/ExdData.h>
#include <datReader/DatCategories/bg/LgbTypes.h>
#include <datReader/DatCategories/bg/lgb.h>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket.h" #include "Network/PacketWrappers/ActorControlPacket.h"
#include "Network/PacketWrappers/PlayerSetupPacket.h" #include "Network/PacketWrappers/PlayerSetupPacket.h"
@ -19,6 +22,8 @@
#include "Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/Notice2Packet.h" #include "Network/PacketWrappers/Notice2Packet.h"
#include "Territory/InstanceObjectCache.h"
#include "Territory/Territory.h" #include "Territory/Territory.h"
#include "Territory/InstanceContent.h" #include "Territory/InstanceContent.h"
#include "Territory/QuestBattle.h" #include "Territory/QuestBattle.h"
@ -217,10 +222,16 @@ std::string Sapphire::World::Manager::EventMgr::getErrorCodeName( uint8_t errorC
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::ExdData >::ref(); auto& exdData = Common::Service< Data::ExdData >::ref();
auto levelInfo = exdData.getRow< Component::Excel::Level >( eventActorId ); auto levelInfo = exdData.getRow< Component::Excel::Level >( eventActorId );
if( levelInfo ) if( levelInfo )
return levelInfo->data().BaseId; return levelInfo->data().BaseId;
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

@ -197,10 +197,6 @@ void Sapphire::Network::GameConnection::joinChatChannelHandler( const Packets::F
void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{ {
// if the player is marked for zoning we no longer want to update his pos
if( player.isMarkedForZoning() )
return;
const auto updatePositionPacket = ZoneChannelPacket< Client::FFXIVIpcUpdatePosition >( inPacket ); const auto updatePositionPacket = ZoneChannelPacket< Client::FFXIVIpcUpdatePosition >( inPacket );
auto& data = updatePositionPacket.data(); auto& data = updatePositionPacket.data();

View file

@ -382,6 +382,9 @@ bool Sapphire::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32
std::string objName = eventMgr.getEventName( eventId ); std::string objName = eventMgr.getEventName( eventId );
PlayerMgr::sendDebug( player, "Calling: {0}.{1} - {2}", objName, eventName, eventId ); PlayerMgr::sendDebug( player, "Calling: {0}.{1} - {2}", objName, eventName, eventId );
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( targetId ) );
auto eventType = static_cast< uint16_t >( eventId >> 16 ); auto eventType = static_cast< uint16_t >( eventId >> 16 );
auto& exdData = Common::Service< Data::ExdData >::ref(); auto& exdData = Common::Service< Data::ExdData >::ref();
if( eventType == Event::EventHandler::EventHandlerType::Quest ) if( eventType == Event::EventHandler::EventHandlerType::Quest )
@ -396,7 +399,7 @@ bool Sapphire::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32
auto questIdx = player.getQuestIndex( questId ); auto questIdx = player.getQuestIndex( questId );
auto& quest = player.getQuestByIndex( questIdx ); auto& quest = player.getQuestByIndex( questIdx );
preQ = quest; preQ = quest;
script->onEventItem( quest, player, targetId ); script->onEventItem( quest, player, actor );
if( quest != preQ ) if( quest != preQ )
player.updateQuest( quest ); player.updateQuest( quest );
return true; return true;
@ -443,6 +446,9 @@ bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref(); auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
bool didCallScript = false; bool didCallScript = false;
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
for( size_t i = 0; i < 30; i++ ) for( size_t i = 0; i < 30; i++ )
{ {
auto quest = player.getQuestByIndex( static_cast< uint16_t >( i )); auto quest = player.getQuestByIndex( static_cast< uint16_t >( i ));
@ -457,10 +463,10 @@ bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player
didCallScript = true; didCallScript = true;
std::string objName = eventMgr.getEventName( questId ); std::string objName = eventMgr.getEventName( questId );
PlayerMgr::sendDebug( player, "Calling: {0}.onEObjHit actorId#{1}, questId#{2}", objName, actorId, quest.getId() ); PlayerMgr::sendDebug( player, "Calling: {0}.onEObjHit actorId#{1}, questId#{2}", objName, actor, quest.getId() );
World::Quest preQ = quest; World::Quest preQ = quest;
script->onEObjHit( quest, player, actorId, actionId ); script->onEObjHit( quest, player, actor, actionId );
if( quest != preQ ) if( quest != preQ )
player.updateQuest( quest ); player.updateQuest( quest );
} }

View file

@ -102,6 +102,16 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
{ {
} }
else if( pEntry->getType() == LgbEntryType::EventObject )
{
auto pEObj = std::reinterpret_pointer_cast< LGB_EOBJ_ENTRY >( pEntry );
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 );
}
} }
} }
} }
@ -131,4 +141,16 @@ Sapphire::InstanceObjectCache::PopRangePtr
Sapphire::InstanceObjectCache::getPopRange( uint16_t zoneId, uint32_t popRangeId ) Sapphire::InstanceObjectCache::getPopRange( uint16_t zoneId, uint32_t popRangeId )
{ {
return m_popRangeCache.get( zoneId, popRangeId ); return m_popRangeCache.get( zoneId, popRangeId );
}
Sapphire::InstanceObjectCache::EObjPtr
Sapphire::InstanceObjectCache::getEObj( uint32_t eObjId )
{
return m_eobjCache.get( 0, eObjId );
}
Sapphire::InstanceObjectCache::ENpcPtr
Sapphire::InstanceObjectCache::getENpc( uint32_t eNpcId )
{
return m_enpcCache.get( 0, eNpcId );
} }

View file

@ -7,6 +7,8 @@
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_EOBJ_ENTRY;
struct LGB_ENPC_ENTRY;
namespace Sapphire namespace Sapphire
@ -65,6 +67,8 @@ 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 EObjPtr = std::shared_ptr< LGB_EOBJ_ENTRY >;
using ENpcPtr = std::shared_ptr< LGB_ENPC_ENTRY >;
InstanceObjectCache(); InstanceObjectCache();
~InstanceObjectCache() = default; ~InstanceObjectCache() = default;
@ -72,11 +76,15 @@ 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 );
EObjPtr getEObj( uint32_t eObjId );
ENpcPtr getENpc( uint32_t eNpcId );
private: private:
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_EOBJ_ENTRY > m_eobjCache;
ObjectCache< LGB_ENPC_ENTRY > m_enpcCache;
std::shared_ptr< Framework > m_pFramework; std::shared_ptr< Framework > m_pFramework;
}; };