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

Begin of InstanceContent implementation

This commit is contained in:
Mordred 2018-01-28 13:49:51 +01:00
parent 04f5823c4b
commit d9da17cd35
6 changed files with 84 additions and 17 deletions

View file

@ -16,9 +16,26 @@ namespace Event {
class Director
{
public:
enum DirectorType
{
InstanceContent = 0x8003, // used for dungeons/raids
CompanyLeve = 0x8007,
QuestBattle = 0x8006,
GatheringLeve = 0x8002,
BattleLeve = 0x8001,
GoldSaucer = 0x800A,
Fate = 0x801A,
DpsChallange = 0x800D
};
private:
/*! Id of the director */
uint32_t m_id;
/*! Id of the content of the director */
uint16_t m_id;
/*! DirectorType | ContentId */
uint32_t m_directorId;
/*! currect sequence */
uint8_t m_sequence;
@ -29,9 +46,14 @@ private:
/*! raw storage for flags/vars */
uint8_t m_unionData[10];
public:
uint8_t getId() const;
/*! type of the director */
DirectorType m_type;
uint32_t getDirectorId() const;
uint16_t getContentId() const;
DirectorType getType() const;
uint8_t getSequence() const;
uint8_t getBranch() const;
};

View file

@ -36,6 +36,7 @@ namespace Core
namespace Event
{
TYPE_FORWARD( Director );
TYPE_FORWARD( EventHandler );
}

View file

@ -0,0 +1 @@
#include "InstanceContent.h"

View file

@ -0,0 +1,22 @@
#ifndef SAPPHIRE_INSTANCECONTENT_H
#define SAPPHIRE_INSTANCECONTENT_H
#include "Zone.h"
#include "Forwards.h"
namespace Core
{
class InstanceContent : public Zone
{
public:
InstanceContent( uint32_t instanceContentId, uint32_t guid );
virtual ~InstanceContent();
private:
DirectorPtr m_pDirector;
};
}
#endif //SAPPHIRE_INSTANCECONTENT_H

View file

@ -120,7 +120,7 @@ bool Core::TerritoryMgr::createDefaultTerritories()
InstanceIdToZonePtrMap instanceMap;
instanceMap[guid] = pZone;
m_instanceIdToZonePtrMap[guid] = pZone;
m_territoryInstanceMap[territoryId] = instanceMap;
}
@ -179,8 +179,6 @@ Core::ZonePtr Core::TerritoryMgr::getZoneByTerriId( uint32_t territoryId ) const
// TODO: actually select the proper one
return zoneMap->second.begin()->second;
return nullptr;
}
void Core::TerritoryMgr::updateTerritoryInstances( uint32_t currentTime )
@ -190,7 +188,22 @@ void Core::TerritoryMgr::updateTerritoryInstances( uint32_t currentTime )
for( auto zone : zoneMap.second )
zone.second->runZoneLogic( currentTime );
}
}
Core::TerritoryMgr::InstanceIdList Core::TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const
{
std::vector< uint32_t > idList;
auto zoneMap = m_instanceContentToInstanceMap.find( instanceContentId );
if( zoneMap == m_instanceContentToInstanceMap.end() )
return idList;
for( auto& entry : zoneMap->second )
{
idList.push_back( entry.first );
}
return idList;
}

View file

@ -87,18 +87,15 @@ namespace Core
/*! removes instance by instanceId, return true if successful */
bool removeTerritoryInstance( uint32_t territoryTypeId );
/*! returns a ZonePtr to the instance or nullptr if not found */
ZonePtr getTerritoryZonePtr( uint32_t instanceId ) const;
/*! returns the cached detail of a territory, nullptr if not found */
Data::TerritoryTypePtr getTerritoryDetail( uint32_t territoryTypeId ) const;
/*! loop for processing territory logic, iterating all existing instances */
void updateTerritoryInstances( uint32_t currentTime );
/*! pushes a new instances onto the handling map */
bool addInstance( ZonePtr pInstance );
/*! returns a ZonePtr to the instance or nullptr if not found */
ZonePtr getInstance( uint32_t instanceId ) const;
/*! returns a ZonePositionPtr if found, else nullptr */
ZonePositionPtr getTerritoryPosition( uint32_t territoryPositionId ) const;
@ -110,22 +107,33 @@ namespace Core
using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >;
using InstanceIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >;
using TerritoryIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
using InstanceContentIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
using PlayerIdToInstanceIdMap = std::unordered_map< uint32_t, uint32_t >;
using PositionMap = std::unordered_map< int32_t, ZonePositionPtr >;
using InstanceIdList = std::vector< uint32_t >;
/*! map holding details for territory templates */
TerritoryTypeDetailCache m_territoryTypeDetailCacheMap;
/*! map holding actual instances of territories */
/*! map holding actual instances of default territories */
TerritoryIdToInstanceMap m_territoryInstanceMap;
/*! map holding actual instances of InstanceContent */
InstanceContentIdToInstanceMap m_instanceContentToInstanceMap;
/*! flat map for easier lookup of instances by guid */
InstanceIdToZonePtrMap m_instanceIdToZonePtrMap;
/*! map holding positions for zonelines */
PositionMap m_territoryPositionMap;
/*! internal counter for instanceIds
TODO: it should be ensured that this does not overflow if the server runs for a loooong time
( as if that will ever happen ;) ) */
/*! internal counter for instanceIds */
uint32_t m_lastInstanceId;
public:
/*! returns a list of instanceContent InstanceIds currently active */
InstanceIdList getInstanceContentIdList( uint16_t instanceContentId ) const;
};
}