2017-08-08 13:53:47 +02:00
|
|
|
#ifndef _ZONE_H
|
|
|
|
#define _ZONE_H
|
|
|
|
|
|
|
|
#include <unordered_map>
|
2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Common.h>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
#include "Cell.h"
|
|
|
|
#include "CellHandler.h"
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Forwards.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <boost/enable_shared_from_this.hpp>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2018-02-01 23:32:59 +01:00
|
|
|
#include <common/Exd/ExdDataGenerated.h>
|
2017-08-08 13:53:47 +02:00
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
class Session;
|
|
|
|
|
|
|
|
class ZonePosition;
|
|
|
|
|
2018-01-27 23:52:49 +01:00
|
|
|
using SessionSet = std::set< SessionPtr >;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
class Zone : public CellHandler< Cell >, public boost::enable_shared_from_this< Zone >
|
|
|
|
{
|
|
|
|
protected:
|
2018-01-27 23:52:49 +01:00
|
|
|
uint32_t m_territoryId;
|
|
|
|
uint32_t m_guId;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-01-27 23:52:49 +01:00
|
|
|
std::string m_placeName;
|
|
|
|
std::string m_internalName;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
bool m_bPrivate;
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
|
|
|
|
std::unordered_map< int32_t, Entity::BattleNpcPtr > m_BattleNpcMap;
|
2018-01-20 22:03:41 +01:00
|
|
|
std::unordered_map< int32_t, Entity::EventNpcPtr > m_EventNpcMap;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
std::set< Entity::BattleNpcPtr > m_BattleNpcDeadMap;
|
|
|
|
|
|
|
|
SessionSet m_sessionSet;
|
|
|
|
|
|
|
|
CellCache** m_pCellCache[_sizeX];
|
|
|
|
|
|
|
|
Common::RegionType m_type;
|
|
|
|
|
|
|
|
uint8_t m_currentWeather;
|
|
|
|
uint8_t m_weatherOverride;
|
|
|
|
|
|
|
|
uint64_t m_lastMobUpdate;
|
|
|
|
|
2018-02-03 02:11:29 +11:00
|
|
|
uint16_t m_currentFestivalId;
|
2018-02-01 23:32:59 +01:00
|
|
|
boost::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
|
|
|
|
|
|
|
|
std::map< uint8_t, int32_t> m_weatherRateMap;
|
2018-02-03 02:11:29 +11:00
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
public:
|
|
|
|
Zone();
|
|
|
|
|
2018-01-29 18:10:11 +11:00
|
|
|
Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName );
|
2017-08-08 13:53:47 +02:00
|
|
|
virtual ~Zone();
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
|
|
|
|
bool isPrivateZone() const;
|
|
|
|
|
|
|
|
/*! overrides the zone's weather, set to 0 to unlock */
|
|
|
|
void setWeatherOverride( uint8_t weather );
|
|
|
|
|
|
|
|
uint8_t getCurrentWeather() const;
|
|
|
|
|
2018-02-03 02:11:29 +11:00
|
|
|
uint16_t getCurrentFestival() const;
|
|
|
|
void setCurrentFestival( uint16_t festivalId );
|
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
CellCache* getCellCacheList( uint32_t cellx, uint32_t celly );
|
|
|
|
|
|
|
|
CellCache* getCellCacheAndCreate( uint32_t cellx, uint32_t celly );
|
|
|
|
|
|
|
|
virtual void loadCellCache();
|
2018-02-04 23:35:16 +01:00
|
|
|
virtual uint32_t getTerritoryId();
|
|
|
|
virtual void onEnterTerritory( Entity::PlayerPtr pPlayer );
|
|
|
|
virtual void onLeaveTerritory( Entity::PlayerPtr pPlayer );
|
|
|
|
virtual void onUpdate( uint32_t currTime );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
uint8_t getNextWeather();
|
|
|
|
|
|
|
|
void pushActor( Entity::ActorPtr pActor );
|
|
|
|
|
|
|
|
void removeActor( Entity::ActorPtr pActor );
|
|
|
|
|
|
|
|
void changeActorPosition( Entity::ActorPtr pActor );
|
|
|
|
|
|
|
|
bool isCellActive( uint32_t x, uint32_t y );
|
|
|
|
|
2017-08-11 22:56:30 +01:00
|
|
|
void updateCellActivity( uint32_t x, uint32_t y, int32_t radius );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
void queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
Common::RegionType getType() const;
|
|
|
|
|
2018-01-27 23:52:49 +01:00
|
|
|
uint16_t getGuId() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
bool isInstance() const;
|
|
|
|
|
|
|
|
const std::string& getName() const;
|
|
|
|
|
|
|
|
const std::string& getInternalName() const;
|
|
|
|
|
|
|
|
std::size_t getPopCount() const;
|
|
|
|
bool checkWeather();
|
|
|
|
void updateBnpcs( int64_t tickCount );
|
|
|
|
|
2018-02-04 23:35:16 +01:00
|
|
|
bool update( uint32_t currTime );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|