mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 14:07:46 +00:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
c0533349f5
21 changed files with 195 additions and 62 deletions
|
@ -49,7 +49,17 @@ public:
|
||||||
void onEnterTerritory( QuestBattle& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
void onEnterTerritory( QuestBattle& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
||||||
uint16_t param2 ) override
|
uint16_t param2 ) override
|
||||||
{
|
{
|
||||||
|
player.playScene( instance.getDirectorId(), 1,
|
||||||
|
NO_DEFAULT_CAMERA | CONDITION_CUTSCENE | SILENT_ENTER_TERRI_ENV |
|
||||||
|
HIDE_HOTBAR | SILENT_ENTER_TERRI_BGM | SILENT_ENTER_TERRI_SE |
|
||||||
|
DISABLE_STEALTH | 0x00100000 | LOCK_HUD | LOCK_HOTBAR |
|
||||||
|
// todo: wtf is 0x00100000
|
||||||
|
DISABLE_CANCEL_EMOTE, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void onDutyComplete( QuestBattle& instance, Entity::Player& player ) override
|
||||||
|
{
|
||||||
|
player.updateQuest( instance.getQuestId(), 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -69,6 +69,14 @@ class ManFst005 : public Sapphire::ScriptAPI::EventScript
|
||||||
Scene00002( player );
|
Scene00002( player );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) override
|
||||||
|
{
|
||||||
|
if( player.getQuestSeq( eventId ) == Seq2 )
|
||||||
|
{
|
||||||
|
Scene00005( player );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Available Scenes in this quest, not necessarly all are used
|
// Available Scenes in this quest, not necessarly all are used
|
||||||
|
@ -129,9 +137,14 @@ class ManFst005 : public Sapphire::ScriptAPI::EventScript
|
||||||
|
|
||||||
void Scene00005( Entity::Player& player )
|
void Scene00005( Entity::Player& player )
|
||||||
{
|
{
|
||||||
player.playScene( getId(), 5, HIDE_HOTBAR,
|
player.playScene( getId(), 5, NO_DEFAULT_CAMERA | CONDITION_CUTSCENE | SILENT_ENTER_TERRI_ENV |
|
||||||
|
HIDE_HOTBAR | SILENT_ENTER_TERRI_BGM | SILENT_ENTER_TERRI_SE |
|
||||||
|
DISABLE_STEALTH | 0x00100000 | LOCK_HUD | LOCK_HOTBAR |
|
||||||
|
// todo: wtf is 0x00100000
|
||||||
|
DISABLE_CANCEL_EMOTE,
|
||||||
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
||||||
{
|
{
|
||||||
|
player.updateQuest( result.eventId, Seq3 );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2102,3 +2102,8 @@ void Sapphire::Entity::Player::updateHuntingLog( uint16_t id )
|
||||||
sendHuntingLog();
|
sendHuntingLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sapphire::World::SessionPtr Sapphire::Entity::Player::getSession()
|
||||||
|
{
|
||||||
|
return m_pSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -972,6 +972,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
void updateHuntingLog( uint16_t id );
|
void updateHuntingLog( uint16_t id );
|
||||||
|
|
||||||
|
World::SessionPtr getSession();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
uint64_t m_lastMoveTime;
|
uint64_t m_lastMoveTime;
|
||||||
|
@ -982,6 +984,8 @@ namespace Sapphire::Entity
|
||||||
uint32_t m_lastWrite;
|
uint32_t m_lastWrite;
|
||||||
uint32_t m_lastPing;
|
uint32_t m_lastPing;
|
||||||
|
|
||||||
|
World::SessionPtr m_pSession;
|
||||||
|
|
||||||
bool m_bIsLogin;
|
bool m_bIsLogin;
|
||||||
|
|
||||||
uint64_t m_contentId; // This id will be the name of the folder for character settings in "My Games"
|
uint64_t m_contentId; // This id will be the name of the folder for character settings in "My Games"
|
||||||
|
|
|
@ -31,6 +31,7 @@ bool Sapphire::Entity::Player::load( uint32_t charId, World::SessionPtr pSession
|
||||||
{
|
{
|
||||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||||
auto pTeriMgr = m_pFw->get< TerritoryMgr >();
|
auto pTeriMgr = m_pFw->get< TerritoryMgr >();
|
||||||
|
m_pSession = pSession;
|
||||||
|
|
||||||
const std::string char_id_str = std::to_string( charId );
|
const std::string char_id_str = std::to_string( charId );
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ Sapphire::World::Manager::DebugCommandMgr::DebugCommandMgr( FrameworkPtr pFw ) :
|
||||||
registerCommand( "script", &DebugCommandMgr::script, "Server script utilities.", 1 );
|
registerCommand( "script", &DebugCommandMgr::script, "Server script utilities.", 1 );
|
||||||
registerCommand( "instance", &DebugCommandMgr::instance, "Instance utilities", 1 );
|
registerCommand( "instance", &DebugCommandMgr::instance, "Instance utilities", 1 );
|
||||||
registerCommand( "questbattle", &DebugCommandMgr::questBattle, "Quest battle utilities", 1 );
|
registerCommand( "questbattle", &DebugCommandMgr::questBattle, "Quest battle utilities", 1 );
|
||||||
|
registerCommand( "qb", &DebugCommandMgr::questBattle, "Quest battle utilities", 1 );
|
||||||
registerCommand( "housing", &DebugCommandMgr::housing, "Housing utilities", 1 );
|
registerCommand( "housing", &DebugCommandMgr::housing, "Housing utilities", 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,6 +1031,26 @@ void Sapphire::World::Manager::DebugCommandMgr::questBattle( char* data, Entity:
|
||||||
else
|
else
|
||||||
player.sendDebug( "Failed to create instance with id#{0}", contentFinderConditionId );
|
player.sendDebug( "Failed to create instance with id#{0}", contentFinderConditionId );
|
||||||
}
|
}
|
||||||
|
else if( subCommand == "complete" )
|
||||||
|
{
|
||||||
|
|
||||||
|
auto instance = std::dynamic_pointer_cast< QuestBattle >( player.getCurrentZone() );
|
||||||
|
if( !instance )
|
||||||
|
return;
|
||||||
|
|
||||||
|
instance->success();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if( subCommand == "fail" )
|
||||||
|
{
|
||||||
|
|
||||||
|
auto instance = std::dynamic_pointer_cast< QuestBattle >( player.getCurrentZone() );
|
||||||
|
if( !instance )
|
||||||
|
return;
|
||||||
|
|
||||||
|
instance->fail();
|
||||||
|
|
||||||
|
}
|
||||||
else if( subCommand == "createzone" || subCommand == "crz" )
|
else if( subCommand == "createzone" || subCommand == "crz" )
|
||||||
{
|
{
|
||||||
uint32_t zoneId;
|
uint32_t zoneId;
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool Sapphire::World::Manager::TerritoryMgr::createDefaultTerritories()
|
||||||
|
|
||||||
InstanceIdToZonePtrMap instanceMap;
|
InstanceIdToZonePtrMap instanceMap;
|
||||||
instanceMap[ guid ] = pZone;
|
instanceMap[ guid ] = pZone;
|
||||||
m_instanceIdToZonePtrMap[ guid ] = pZone;
|
m_guIdToZonePtrMap[ guid ] = pZone;
|
||||||
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ] = instanceMap;
|
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ] = instanceMap;
|
||||||
m_zoneSet.insert( { pZone } );
|
m_zoneSet.insert( { pZone } );
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ bool Sapphire::World::Manager::TerritoryMgr::createHousingTerritories()
|
||||||
|
|
||||||
InstanceIdToZonePtrMap instanceMap;
|
InstanceIdToZonePtrMap instanceMap;
|
||||||
instanceMap[ guid ] = pHousingZone;
|
instanceMap[ guid ] = pHousingZone;
|
||||||
m_instanceIdToZonePtrMap[ guid ] = pHousingZone;
|
m_guIdToZonePtrMap[ guid ] = pHousingZone;
|
||||||
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ][ guid ] = pHousingZone;
|
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ][ guid ] = pHousingZone;
|
||||||
m_landSetIdToZonePtrMap[ pHousingZone->getLandSetId() ] = pHousingZone;
|
m_landSetIdToZonePtrMap[ pHousingZone->getLandSetId() ] = pHousingZone;
|
||||||
m_zoneSet.insert( { pHousingZone } );
|
m_zoneSet.insert( { pHousingZone } );
|
||||||
|
@ -266,7 +266,7 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::createTerritoryInstanc
|
||||||
auto pZone = make_Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name, framework() );
|
auto pZone = make_Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name, framework() );
|
||||||
pZone->init();
|
pZone->init();
|
||||||
|
|
||||||
m_instanceIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
m_guIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
||||||
m_territoryTypeIdToInstanceGuidMap[ pZone->getTerritoryTypeId() ][ pZone->getGuId() ] = pZone;
|
m_territoryTypeIdToInstanceGuidMap[ pZone->getTerritoryTypeId() ][ pZone->getGuId() ] = pZone;
|
||||||
m_zoneSet.insert( { pZone } );
|
m_zoneSet.insert( { pZone } );
|
||||||
|
|
||||||
|
@ -305,8 +305,8 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::createQuestBattle( uin
|
||||||
pTeri->name, pQuestInfo->name, questBattleId, framework() );
|
pTeri->name, pQuestInfo->name, questBattleId, framework() );
|
||||||
pZone->init();
|
pZone->init();
|
||||||
|
|
||||||
m_instanceContentIdToInstanceMap[ questBattleId ][ pZone->getGuId() ] = pZone;
|
m_questBattleIdToInstanceMap[ questBattleId ][ pZone->getGuId() ] = pZone;
|
||||||
m_instanceIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
m_guIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
||||||
m_instanceZoneSet.insert( pZone );
|
m_instanceZoneSet.insert( pZone );
|
||||||
|
|
||||||
return pZone;
|
return pZone;
|
||||||
|
@ -340,7 +340,7 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::createInstanceContent(
|
||||||
pZone->init();
|
pZone->init();
|
||||||
|
|
||||||
m_instanceContentIdToInstanceMap[ instanceContentId ][ pZone->getGuId() ] = pZone;
|
m_instanceContentIdToInstanceMap[ instanceContentId ][ pZone->getGuId() ] = pZone;
|
||||||
m_instanceIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
m_guIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
||||||
m_instanceZoneSet.insert( pZone );
|
m_instanceZoneSet.insert( pZone );
|
||||||
|
|
||||||
return pZone;
|
return pZone;
|
||||||
|
@ -413,19 +413,19 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousingInt
|
||||||
zone->init();
|
zone->init();
|
||||||
|
|
||||||
m_landIdentToZonePtrMap[ ident ] = zone;
|
m_landIdentToZonePtrMap[ ident ] = zone;
|
||||||
m_instanceIdToZonePtrMap[ zone->getGuId() ] = zone;
|
m_guIdToZonePtrMap[ zone->getGuId() ] = zone;
|
||||||
m_zoneSet.insert( { zone } );
|
m_zoneSet.insert( { zone } );
|
||||||
|
|
||||||
return zone;
|
return zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::World::Manager::TerritoryMgr::removeTerritoryInstance( uint32_t instanceId )
|
bool Sapphire::World::Manager::TerritoryMgr::removeTerritoryInstance( uint32_t guId )
|
||||||
{
|
{
|
||||||
ZonePtr pZone;
|
ZonePtr pZone;
|
||||||
if( ( pZone = getInstanceZonePtr( instanceId ) ) == nullptr )
|
if( ( pZone = getInstanceZonePtr( guId ) ) == nullptr )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_instanceIdToZonePtrMap.erase( pZone->getGuId() );
|
m_guIdToZonePtrMap.erase( pZone->getGuId() );
|
||||||
|
|
||||||
m_instanceZoneSet.erase( pZone );
|
m_instanceZoneSet.erase( pZone );
|
||||||
m_zoneSet.erase( pZone );
|
m_zoneSet.erase( pZone );
|
||||||
|
@ -438,14 +438,13 @@ bool Sapphire::World::Manager::TerritoryMgr::removeTerritoryInstance( uint32_t i
|
||||||
else
|
else
|
||||||
m_territoryTypeIdToInstanceGuidMap[ pZone->getTerritoryTypeId() ].erase( pZone->getGuId() );
|
m_territoryTypeIdToInstanceGuidMap[ pZone->getTerritoryTypeId() ].erase( pZone->getGuId() );
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::getInstanceZonePtr( uint32_t instanceId ) const
|
Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::getInstanceZonePtr( uint32_t guId ) const
|
||||||
{
|
{
|
||||||
auto it = m_instanceIdToZonePtrMap.find( instanceId );
|
auto it = m_guIdToZonePtrMap.find( guId );
|
||||||
if( it == m_instanceIdToZonePtrMap.end() )
|
if( it == m_guIdToZonePtrMap.end() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -521,7 +520,7 @@ void Sapphire::World::Manager::TerritoryMgr::updateTerritoryInstances( uint64_t
|
||||||
auto diff = std::difftime( tickCount, zone->getLastActivityTime() );
|
auto diff = std::difftime( tickCount, zone->getLastActivityTime() );
|
||||||
|
|
||||||
// todo: make this timeout configurable, though should be pretty relaxed in any case
|
// todo: make this timeout configurable, though should be pretty relaxed in any case
|
||||||
if( diff > 6000 )
|
if( diff > 60000 )
|
||||||
{
|
{
|
||||||
Logger::info( "Removing HousingInteriorTerritory#{0} - has been inactive for 60 seconds", zone->getGuId() );
|
Logger::info( "Removing HousingInteriorTerritory#{0} - has been inactive for 60 seconds", zone->getGuId() );
|
||||||
|
|
||||||
|
@ -532,9 +531,37 @@ void Sapphire::World::Manager::TerritoryMgr::updateTerritoryInstances( uint64_t
|
||||||
else
|
else
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove internal house zones with nobody in them
|
||||||
|
for( auto it = m_questBattleIdToInstanceMap.begin(); it != m_questBattleIdToInstanceMap.end(); ++it )
|
||||||
|
{
|
||||||
|
for( auto inIt = it->second.begin(); inIt != it->second.end(); )
|
||||||
|
{
|
||||||
|
auto zone = std::dynamic_pointer_cast< QuestBattle >( inIt->second );
|
||||||
|
if( !zone )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto diff = std::difftime( tickCount, zone->getLastActivityTime() );
|
||||||
|
|
||||||
|
// todo: make this timeout configurable, though should be pretty relaxed in any case
|
||||||
|
if( diff > 60000 )
|
||||||
|
{
|
||||||
|
Logger::info( "Removing QuestBattle#{0} - has been inactive for 60 seconds", zone->getGuId() );
|
||||||
|
|
||||||
|
// remove zone from maps
|
||||||
|
m_instanceZoneSet.erase( zone );
|
||||||
|
m_guIdToZonePtrMap.erase( zone->getGuId() );
|
||||||
|
inIt = m_questBattleIdToInstanceMap[ zone->getQuestBattleId() ].erase( inIt );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
inIt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::World::Manager::TerritoryMgr::InstanceIdList Sapphire::World::Manager::TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const
|
Sapphire::World::Manager::TerritoryMgr::InstanceIdList
|
||||||
|
Sapphire::World::Manager::TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const
|
||||||
{
|
{
|
||||||
std::vector< uint32_t > idList;
|
std::vector< uint32_t > idList;
|
||||||
auto zoneMap = m_instanceContentIdToInstanceMap.find( instanceContentId );
|
auto zoneMap = m_instanceContentIdToInstanceMap.find( instanceContentId );
|
||||||
|
|
|
@ -111,10 +111,10 @@ namespace Sapphire::World::Manager
|
||||||
ZonePtr findOrCreateHousingInterior( const Common::LandIdent landIdent );
|
ZonePtr findOrCreateHousingInterior( const Common::LandIdent landIdent );
|
||||||
|
|
||||||
/*! 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 guId );
|
||||||
|
|
||||||
/*! returns a ZonePtr to the instance or nullptr if not found */
|
/*! returns a ZonePtr to the instance or nullptr if not found */
|
||||||
ZonePtr getInstanceZonePtr( uint32_t instanceId ) const;
|
ZonePtr getInstanceZonePtr( uint32_t guId ) const;
|
||||||
|
|
||||||
/*! returns the cached detail of a territory, nullptr if not found */
|
/*! returns the cached detail of a territory, nullptr if not found */
|
||||||
Data::TerritoryTypePtr getTerritoryDetail( uint32_t territoryTypeId ) const;
|
Data::TerritoryTypePtr getTerritoryDetail( uint32_t territoryTypeId ) const;
|
||||||
|
@ -165,6 +165,7 @@ namespace Sapphire::World::Manager
|
||||||
using LandSetIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >;
|
using LandSetIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >;
|
||||||
using TerritoryTypeIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
using TerritoryTypeIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||||
using InstanceContentIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
using InstanceContentIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||||
|
using QuestBattleIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||||
using PlayerIdToInstanceIdMap = std::unordered_map< uint32_t, uint32_t >;
|
using PlayerIdToInstanceIdMap = std::unordered_map< uint32_t, uint32_t >;
|
||||||
using PositionMap = std::unordered_map< int32_t, ZonePositionPtr >;
|
using PositionMap = std::unordered_map< int32_t, ZonePositionPtr >;
|
||||||
using InstanceIdList = std::vector< uint32_t >;
|
using InstanceIdList = std::vector< uint32_t >;
|
||||||
|
@ -182,8 +183,11 @@ namespace Sapphire::World::Manager
|
||||||
/*! map holding actual instances of InstanceContent */
|
/*! map holding actual instances of InstanceContent */
|
||||||
InstanceContentIdToInstanceMap m_instanceContentIdToInstanceMap;
|
InstanceContentIdToInstanceMap m_instanceContentIdToInstanceMap;
|
||||||
|
|
||||||
|
/*! map holding actual instances of InstanceContent */
|
||||||
|
QuestBattleIdToInstanceMap m_questBattleIdToInstanceMap;
|
||||||
|
|
||||||
/*! flat map for easier lookup of instances by guid */
|
/*! flat map for easier lookup of instances by guid */
|
||||||
InstanceIdToZonePtrMap m_instanceIdToZonePtrMap;
|
InstanceIdToZonePtrMap m_guIdToZonePtrMap;
|
||||||
|
|
||||||
/*! map holding positions for zonelines */
|
/*! map holding positions for zonelines */
|
||||||
PositionMap m_territoryPositionMap;
|
PositionMap m_territoryPositionMap;
|
||||||
|
|
|
@ -222,6 +222,7 @@ void Sapphire::Network::GameConnection::handleZonePacket( Sapphire::Network::Pac
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger::debug( "[{0}] Undefined Zone IPC : Unknown ( {1:04X} )", m_pSession->getId(), opcode );
|
Logger::debug( "[{0}] Undefined Zone IPC : Unknown ( {1:04X} )", m_pSession->getId(), opcode );
|
||||||
|
|
||||||
Logger::debug( "Dump:\n{0}", Util::binaryToHexDump( const_cast< uint8_t* >( &pPacket.data[ 0 ] ),
|
Logger::debug( "Dump:\n{0}", Util::binaryToHexDump( const_cast< uint8_t* >( &pPacket.data[ 0 ] ),
|
||||||
pPacket.segHdr.size ) );
|
pPacket.segHdr.size ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,6 +201,11 @@ namespace Sapphire::ScriptAPI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuestBattleScript::onDutyComplete( Sapphire::QuestBattle& instance, Entity::Player& player )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void QuestBattleScript::onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player )
|
void QuestBattleScript::onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,8 @@ namespace Sapphire::ScriptAPI
|
||||||
public:
|
public:
|
||||||
explicit QuestBattleScript( uint32_t questBattleId );
|
explicit QuestBattleScript( uint32_t questBattleId );
|
||||||
|
|
||||||
|
virtual void onDutyComplete( Sapphire::QuestBattle& instance, Entity::Player& player );
|
||||||
|
|
||||||
virtual void onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player );
|
virtual void onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player );
|
||||||
|
|
||||||
virtual void onInit( Sapphire::QuestBattle& instance );
|
virtual void onInit( Sapphire::QuestBattle& instance );
|
||||||
|
|
|
@ -516,3 +516,16 @@ Sapphire::Scripting::NativeScriptMgr& Sapphire::Scripting::ScriptMgr::getNativeS
|
||||||
{
|
{
|
||||||
return *m_nativeScriptMgr;
|
return *m_nativeScriptMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Sapphire::Scripting::ScriptMgr::onDutyComplete( Sapphire::QuestBattlePtr instance, Sapphire::Entity::Player& player )
|
||||||
|
{
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance->getDirectorId() );
|
||||||
|
if( script )
|
||||||
|
{
|
||||||
|
script->onDutyComplete( *instance, player );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -109,6 +109,8 @@ namespace Sapphire::Scripting
|
||||||
bool onInstanceEnterTerritory( QuestBattlePtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
bool onInstanceEnterTerritory( QuestBattlePtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
||||||
uint16_t param2 );
|
uint16_t param2 );
|
||||||
|
|
||||||
|
bool onDutyComplete( QuestBattlePtr instance, Entity::Player& player );
|
||||||
|
|
||||||
bool loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext );
|
bool loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext );
|
||||||
|
|
||||||
NativeScriptMgr& getNativeScriptHandler();
|
NativeScriptMgr& getNativeScriptHandler();
|
||||||
|
|
|
@ -39,7 +39,7 @@ void Sapphire::Cell::addActor( Entity::ActorPtr pAct )
|
||||||
m_actors.insert( pAct );
|
m_actors.insert( pAct );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Cell::removeActor( Entity::ActorPtr pAct )
|
void Sapphire::Cell::removeActorFromCell( Entity::ActorPtr pAct )
|
||||||
{
|
{
|
||||||
if( pAct->isPlayer() )
|
if( pAct->isPlayer() )
|
||||||
--m_playerCount;
|
--m_playerCount;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
void addActor( Entity::ActorPtr pAct );
|
void addActor( Entity::ActorPtr pAct );
|
||||||
|
|
||||||
void removeActor( Entity::ActorPtr pAct );
|
void removeActorFromCell( Entity::ActorPtr pAct );
|
||||||
|
|
||||||
bool hasActor( Entity::ActorPtr pAct )
|
bool hasActor( Entity::ActorPtr pAct )
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,6 @@ Sapphire::World::Territory::Housing::HousingInteriorTerritory::HousingInteriorTe
|
||||||
Zone( territoryTypeId, guId, internalName, contentName, pFw ),
|
Zone( territoryTypeId, guId, internalName, contentName, pFw ),
|
||||||
m_landIdent( ident )
|
m_landIdent( ident )
|
||||||
{
|
{
|
||||||
m_lastActivityTime = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Housing::HousingInteriorTerritory::~HousingInteriorTerritory() = default;
|
Housing::HousingInteriorTerritory::~HousingInteriorTerritory() = default;
|
||||||
|
@ -105,13 +104,7 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::onPlayerZone
|
||||||
|
|
||||||
void Sapphire::World::Territory::Housing::HousingInteriorTerritory::onUpdate( uint64_t tickCount )
|
void Sapphire::World::Territory::Housing::HousingInteriorTerritory::onUpdate( uint64_t tickCount )
|
||||||
{
|
{
|
||||||
if( m_playerMap.size() > 0 )
|
|
||||||
m_lastActivityTime = tickCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Sapphire::World::Territory::Housing::HousingInteriorTerritory::getLastActivityTime() const
|
|
||||||
{
|
|
||||||
return m_lastActivityTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Common::LandIdent Sapphire::World::Territory::Housing::HousingInteriorTerritory::getLandIdent() const
|
const Common::LandIdent Sapphire::World::Territory::Housing::HousingInteriorTerritory::getLandIdent() const
|
||||||
|
|
|
@ -21,8 +21,6 @@ namespace Sapphire::World::Territory::Housing
|
||||||
void onPlayerZoneIn( Entity::Player& player ) override;
|
void onPlayerZoneIn( Entity::Player& player ) override;
|
||||||
void onUpdate( uint64_t tickCount ) override;
|
void onUpdate( uint64_t tickCount ) override;
|
||||||
|
|
||||||
uint64_t getLastActivityTime() const;
|
|
||||||
|
|
||||||
const Common::LandIdent getLandIdent() const;
|
const Common::LandIdent getLandIdent() const;
|
||||||
|
|
||||||
void updateHousingObjects();
|
void updateHousingObjects();
|
||||||
|
@ -34,7 +32,6 @@ namespace Sapphire::World::Territory::Housing
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::LandIdent m_landIdent;
|
Common::LandIdent m_landIdent;
|
||||||
uint64_t m_lastActivityTime;
|
|
||||||
|
|
||||||
std::array< Sapphire::Common::HousingObject, 400 > m_housingObjects;
|
std::array< Sapphire::Common::HousingObject, 400 > m_housingObjects;
|
||||||
};
|
};
|
||||||
|
|
|
@ -315,14 +315,6 @@ Sapphire::QuestBattle::onEnterTerritory( Entity::Player& player, uint32_t eventI
|
||||||
{
|
{
|
||||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||||
pScriptMgr->onInstanceEnterTerritory( getAsQuestBattle(), player, eventId, param1, param2 );
|
pScriptMgr->onInstanceEnterTerritory( getAsQuestBattle(), player, eventId, param1, param2 );
|
||||||
|
|
||||||
// TODO: this may or may not be correct for questbattles
|
|
||||||
player.playScene( getDirectorId(), 1, NO_DEFAULT_CAMERA | CONDITION_CUTSCENE | SILENT_ENTER_TERRI_ENV |
|
|
||||||
HIDE_HOTBAR | SILENT_ENTER_TERRI_BGM | SILENT_ENTER_TERRI_SE |
|
|
||||||
DISABLE_STEALTH | 0x00100000 | LOCK_HUD | LOCK_HOTBAR |
|
|
||||||
// todo: wtf is 0x00100000
|
|
||||||
DISABLE_CANCEL_EMOTE, 0 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::QuestBattle::clearDirector( Entity::Player& player )
|
void Sapphire::QuestBattle::clearDirector( Entity::Player& player )
|
||||||
|
@ -333,3 +325,34 @@ void Sapphire::QuestBattle::clearDirector( Entity::Player& player )
|
||||||
// remove "bound by duty" state
|
// remove "bound by duty" state
|
||||||
player.unsetStateFlag( PlayerStateFlag::BoundByDuty );
|
player.unsetStateFlag( PlayerStateFlag::BoundByDuty );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::QuestBattle::success()
|
||||||
|
{
|
||||||
|
|
||||||
|
m_pPlayer->eventStart( m_pPlayer->getId(), getDirectorId(), Event::EventHandler::GameProgress, 1, 0 );
|
||||||
|
m_pPlayer->playScene( getDirectorId(), 60001, 0x40000,
|
||||||
|
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
||||||
|
{
|
||||||
|
player.eventFinish( getDirectorId(), 1 );
|
||||||
|
player.eventStart( player.getId(), getDirectorId(), Event::EventHandler::GameProgress, 1, 0 );
|
||||||
|
player.playScene( getDirectorId(), 6, HIDE_HOTBAR | NO_DEFAULT_CAMERA,
|
||||||
|
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
||||||
|
{
|
||||||
|
player.eventFinish( getDirectorId(), 1 );
|
||||||
|
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||||
|
pScriptMgr->onDutyComplete( getAsQuestBattle(), *m_pPlayer );
|
||||||
|
player.exitInstance();
|
||||||
|
} );
|
||||||
|
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sapphire::QuestBattle::fail()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Sapphire::QuestBattle::getQuestId() const
|
||||||
|
{
|
||||||
|
return m_pBattleDetails->quest;
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,11 @@ namespace Sapphire
|
||||||
|
|
||||||
void endEventCutscene();
|
void endEventCutscene();
|
||||||
|
|
||||||
|
uint32_t getQuestId() const;
|
||||||
|
|
||||||
|
void fail();
|
||||||
|
void success();
|
||||||
|
|
||||||
void clearDirector( Entity::Player& player );
|
void clearDirector( Entity::Player& player );
|
||||||
|
|
||||||
Event::Director::DirectorState getState() const;
|
Event::Director::DirectorState getState() const;
|
||||||
|
|
|
@ -69,7 +69,8 @@ Sapphire::Zone::Zone( uint16_t territoryTypeId, uint32_t guId,
|
||||||
m_nextEObjId( 0x400D0000 ),
|
m_nextEObjId( 0x400D0000 ),
|
||||||
m_nextActorId( 0x500D0000 ),
|
m_nextActorId( 0x500D0000 ),
|
||||||
m_pFw( pFw ),
|
m_pFw( pFw ),
|
||||||
m_lastUpdate( 0 )
|
m_lastUpdate( 0 ),
|
||||||
|
m_lastActivityTime( Util::getTimeMs() )
|
||||||
{
|
{
|
||||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||||
m_guId = guId;
|
m_guId = guId;
|
||||||
|
@ -234,9 +235,6 @@ void Sapphire::Zone::pushActor( Entity::ActorPtr pActor )
|
||||||
auto pPlayer = pActor->getAsPlayer();
|
auto pPlayer = pActor->getAsPlayer();
|
||||||
|
|
||||||
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
||||||
auto pSession = pServerZone->getSession( pPlayer->getId() );
|
|
||||||
if( pSession )
|
|
||||||
m_sessionSet.insert( pSession );
|
|
||||||
m_playerMap[ pPlayer->getId() ] = pPlayer;
|
m_playerMap[ pPlayer->getId() ] = pPlayer;
|
||||||
updateCellActivity( cx, cy, 2 );
|
updateCellActivity( cx, cy, 2 );
|
||||||
}
|
}
|
||||||
|
@ -259,7 +257,7 @@ void Sapphire::Zone::removeActor( Entity::ActorPtr pActor )
|
||||||
|
|
||||||
Cell* pCell = getCellPtr( cx, cy );
|
Cell* pCell = getCellPtr( cx, cy );
|
||||||
if( pCell && pCell->hasActor( pActor ) )
|
if( pCell && pCell->hasActor( pActor ) )
|
||||||
pCell->removeActor( pActor );
|
pCell->removeActorFromCell( pActor );
|
||||||
|
|
||||||
if( pActor->isPlayer() )
|
if( pActor->isPlayer() )
|
||||||
{
|
{
|
||||||
|
@ -442,6 +440,10 @@ void Sapphire::Zone::updateBNpcs( uint64_t tickCount )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Sapphire::Zone::getLastActivityTime() const
|
||||||
|
{
|
||||||
|
return m_lastActivityTime;
|
||||||
|
}
|
||||||
|
|
||||||
bool Sapphire::Zone::update( uint64_t tickCount )
|
bool Sapphire::Zone::update( uint64_t tickCount )
|
||||||
{
|
{
|
||||||
|
@ -453,32 +455,32 @@ bool Sapphire::Zone::update( uint64_t tickCount )
|
||||||
onUpdate( tickCount );
|
onUpdate( tickCount );
|
||||||
|
|
||||||
updateSpawnPoints();
|
updateSpawnPoints();
|
||||||
|
|
||||||
|
if( m_playerMap.size() > 0 )
|
||||||
|
m_lastActivityTime = tickCount;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Zone::updateSessions( uint64_t tickCount, bool changedWeather )
|
void Sapphire::Zone::updateSessions( uint64_t tickCount, bool changedWeather )
|
||||||
{
|
{
|
||||||
// update sessions in this zone
|
// update sessions in this zone
|
||||||
for( auto it = m_sessionSet.begin(); it != m_sessionSet.end(); ++it )
|
for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it )
|
||||||
{
|
{
|
||||||
|
|
||||||
auto pSession = *it;
|
auto pPlayer = it->second;
|
||||||
|
|
||||||
if( !pSession )
|
if( !pPlayer )
|
||||||
{
|
{
|
||||||
it = m_sessionSet.erase( it );
|
m_playerMap.erase( it );
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pPlayer = pSession->getPlayer();
|
|
||||||
|
|
||||||
// this session is not linked to this area anymore, remove it from zone session list
|
// this session is not linked to this area anymore, remove it from zone session list
|
||||||
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
||||||
{
|
{
|
||||||
removeActor( pSession->getPlayer() );
|
removeActor( pPlayer );
|
||||||
|
return;
|
||||||
it = m_sessionSet.erase( it );
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastUpdate = tickCount;
|
m_lastUpdate = tickCount;
|
||||||
|
@ -488,11 +490,15 @@ void Sapphire::Zone::updateSessions( uint64_t tickCount, bool changedWeather )
|
||||||
auto weatherChangePacket = makeZonePacket< FFXIVIpcWeatherChange >( pPlayer->getId() );
|
auto weatherChangePacket = makeZonePacket< FFXIVIpcWeatherChange >( pPlayer->getId() );
|
||||||
weatherChangePacket->data().weatherId = static_cast< uint8_t >( m_currentWeather );
|
weatherChangePacket->data().weatherId = static_cast< uint8_t >( m_currentWeather );
|
||||||
weatherChangePacket->data().delay = 5.0f;
|
weatherChangePacket->data().delay = 5.0f;
|
||||||
pSession->getPlayer()->queuePacket( weatherChangePacket );
|
pPlayer->queuePacket( weatherChangePacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform session duties
|
// perform session duties
|
||||||
pSession->update();
|
pPlayer->getSession()->update();
|
||||||
|
|
||||||
|
// this session is not linked to this area anymore, remove it from zone session list
|
||||||
|
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +605,7 @@ void Sapphire::Zone::updateActorPosition( Entity::Actor& actor )
|
||||||
|
|
||||||
if( pOldCell )
|
if( pOldCell )
|
||||||
{
|
{
|
||||||
pOldCell->removeActor( actor.shared_from_this() );
|
pOldCell->removeActorFromCell( actor.shared_from_this() );
|
||||||
}
|
}
|
||||||
|
|
||||||
pCell->addActor( actor.shared_from_this() );
|
pCell->addActor( actor.shared_from_this() );
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace Sapphire
|
||||||
|
|
||||||
class ZonePosition;
|
class ZonePosition;
|
||||||
|
|
||||||
using SessionSet = std::set< World::SessionPtr >;
|
|
||||||
using FestivalPair = std::pair< uint16_t, uint16_t >;
|
using FestivalPair = std::pair< uint16_t, uint16_t >;
|
||||||
|
|
||||||
namespace Data
|
namespace Data
|
||||||
|
@ -44,8 +43,6 @@ namespace Sapphire
|
||||||
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
|
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
|
||||||
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
|
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
|
||||||
|
|
||||||
SessionSet m_sessionSet;
|
|
||||||
|
|
||||||
Common::Weather m_currentWeather;
|
Common::Weather m_currentWeather;
|
||||||
Common::Weather m_weatherOverride;
|
Common::Weather m_weatherOverride;
|
||||||
std::map< uint8_t, int32_t > m_weatherRateMap;
|
std::map< uint8_t, int32_t > m_weatherRateMap;
|
||||||
|
@ -53,6 +50,8 @@ namespace Sapphire
|
||||||
int64_t m_lastMobUpdate;
|
int64_t m_lastMobUpdate;
|
||||||
int64_t m_lastUpdate;
|
int64_t m_lastUpdate;
|
||||||
|
|
||||||
|
uint64_t m_lastActivityTime;
|
||||||
|
|
||||||
FestivalPair m_currentFestival;
|
FestivalPair m_currentFestival;
|
||||||
|
|
||||||
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
|
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
|
||||||
|
@ -84,6 +83,8 @@ namespace Sapphire
|
||||||
|
|
||||||
std::shared_ptr< Data::TerritoryType > getTerritoryTypeInfo() const;
|
std::shared_ptr< Data::TerritoryType > getTerritoryTypeInfo() const;
|
||||||
|
|
||||||
|
uint64_t getLastActivityTime() const;
|
||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
|
|
||||||
virtual void loadCellCache();
|
virtual void loadCellCache();
|
||||||
|
|
Loading…
Add table
Reference in a new issue