1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 08:27:46 +00:00
sapphire/src/world/Territory/Zone.h

166 lines
4.1 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _ZONE_H
#define _ZONE_H
#include <unordered_map>
2018-03-06 22:22:19 +01:00
#include <Common.h>
2017-08-08 13:53:47 +02:00
#include "Cell.h"
#include "CellHandler.h"
#include "ForwardsZone.h"
2017-08-08 13:53:47 +02:00
#include <set>
#include <map>
2018-10-25 12:44:51 +11:00
#include <memory>
2017-08-08 13:53:47 +02:00
#include <stdio.h>
#include <string.h>
namespace Sapphire
2018-11-06 10:36:45 +01:00
{
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
class ZonePosition;
2017-08-08 13:53:47 +02:00
using SessionSet = std::set< World::SessionPtr >;
2018-12-02 02:01:41 +01:00
using FestivalPair = std::pair< uint16_t, uint16_t >;
2018-12-02 02:01:41 +01:00
namespace Data
{
struct InstanceContent;
struct TerritoryType;
}
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
class Zone : public CellHandler< Cell >, public std::enable_shared_from_this< Zone >
{
protected:
uint32_t m_territoryTypeId;
uint32_t m_guId;
std::string m_placeName;
std::string m_internalName;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
SessionSet m_sessionSet;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
Common::Weather m_currentWeather;
Common::Weather m_weatherOverride;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
uint64_t m_lastMobUpdate;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
FestivalPair m_currentFestival;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
2018-12-02 02:01:41 +01:00
std::map< uint8_t, int32_t > m_weatherRateMap;
2018-02-03 02:11:29 +11:00
2018-12-02 02:01:41 +01:00
uint32_t m_nextEObjId;
uint32_t m_nextActorId;
FrameworkPtr m_pFw;
2019-01-06 23:34:19 +01:00
std::vector< Entity::SpawnGroup > m_spawnGroups;
2018-12-02 02:01:41 +01:00
public:
Zone();
Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName,
const std::string& placeName, FrameworkPtr pFw );
2018-12-02 02:01:41 +01:00
virtual ~Zone();
2018-12-02 02:01:41 +01:00
/*! overrides the zone's weather, set to 0 to unlock */
void setWeatherOverride( Common::Weather weather );
2018-12-02 02:01:41 +01:00
Common::Weather getCurrentWeather() const;
2018-12-02 02:01:41 +01:00
const FestivalPair& getCurrentFestival() const;
2018-12-02 02:01:41 +01:00
void setCurrentFestival( uint16_t festivalId, uint16_t additionalFestivalId = 0 );
std::shared_ptr< Data::TerritoryType > getTerritoryTypeInfo() const;
2018-12-02 02:01:41 +01:00
virtual bool init();
2018-12-02 02:01:41 +01:00
virtual void loadCellCache();
2018-12-02 02:01:41 +01:00
virtual uint32_t getTerritoryTypeId() const;
2018-12-02 02:01:41 +01:00
virtual void onBeforePlayerZoneIn( Entity::Player& player ) {};
2018-12-02 02:01:41 +01:00
virtual void onPlayerZoneIn( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onFinishLoading( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onInitDirector( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onDirectorSync( Entity::Player& player ) {};
2018-12-02 02:01:41 +01:00
virtual void onLeaveTerritory( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onUpdate( uint32_t currTime );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
virtual void onRegisterEObj( Entity::EventObjectPtr object ) {};
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
virtual void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
Common::Weather getNextWeather();
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void pushActor( Entity::ActorPtr pActor );
2018-02-03 02:11:29 +11:00
2018-12-02 02:01:41 +01:00
void removeActor( Entity::ActorPtr pActor );
2018-12-02 02:01:41 +01:00
void updateActorPosition( Entity::Actor& pActor );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
bool isCellActive( uint32_t x, uint32_t y );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void updateCellActivity( uint32_t x, uint32_t y, int32_t radius );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void queuePacketForRange( Entity::Player& sourcePlayer, uint32_t range,
Network::Packets::FFXIVPacketBasePtr pPacketEntry );
2018-12-02 02:01:41 +01:00
void queuePacketForZone( Entity::Player& sourcePlayer, Network::Packets::FFXIVPacketBasePtr pPacketEntry,
bool forSelf = false );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
uint32_t getGuId() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
uint32_t getNextEObjId();
2017-08-08 13:53:47 +02:00
uint32_t getNextActorId();
2018-12-02 02:01:41 +01:00
const std::string& getName() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
const std::string& getInternalName() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
std::size_t getPopCount() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void loadWeatherRates();
2018-12-31 13:54:31 +01:00
bool loadSpawnGroups();
2018-12-02 02:01:41 +01:00
bool checkWeather();
//void updateBnpcs( int64_t tickCount );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
bool update( uint32_t currTime );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void updateSessions( bool changedWeather );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
Entity::EventObjectPtr registerEObj( const std::string& name, uint32_t objectId, uint32_t mapLink,
uint8_t state, Common::FFXIVARR_POSITION3 pos, float scale, float rotation );
2018-12-02 02:01:41 +01:00
void registerEObj( Entity::EventObjectPtr object );
2018-12-02 02:01:41 +01:00
Entity::EventObjectPtr getEObj( uint32_t objId );
2018-12-02 02:01:41 +01:00
InstanceContentPtr getAsInstanceContent();
void updateSpawnPoints();
2018-12-02 02:01:41 +01:00
};
2017-08-08 13:53:47 +02:00
}
#endif