1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-09 12:17:45 +00:00
sapphire/src/world/Territory/HousingZone.h

95 lines
2.6 KiB
C
Raw Normal View History

2018-07-15 23:59:15 +02:00
#ifndef SAPPHIRE_HOUSINGZONE_H
#define SAPPHIRE_HOUSINGZONE_H
#include "Zone.h"
#include "Forwards.h"
#include <array>
namespace Sapphire
2018-07-15 23:59:15 +02:00
{
2018-11-11 17:20:47 +01:00
enum class LandPurchaseResult
2018-11-10 23:47:19 +01:00
{
SUCCESS,
ERR_NOT_ENOUGH_GIL,
ERR_NOT_AVAILABLE,
2018-11-11 17:20:47 +01:00
ERR_NO_MORE_LANDS_FOR_CHAR,
2018-11-10 23:47:19 +01:00
ERR_INTERNAL,
};
2018-11-11 17:20:47 +01:00
enum class LandPurchaseMode
{
FC = 1,
PRIVATE = 2,
RELOCATE = 4,
};
2018-11-01 00:18:19 +01:00
class HousingZone : public Zone
{
public:
2018-11-01 23:56:43 +01:00
HousingZone( uint8_t landSetId,
uint16_t territoryTypeId,
2018-11-01 00:18:19 +01:00
uint32_t guId,
const std::string& internalName,
const std::string& contentName,
FrameworkPtr pFw );
2018-11-01 00:18:19 +01:00
virtual ~HousingZone();
2018-11-01 00:18:19 +01:00
bool init() override;
2018-11-01 00:18:19 +01:00
void onPlayerZoneIn( Entity::Player& player ) override;
void onUpdate( uint32_t currTime ) override;
2018-11-04 23:47:10 +01:00
void sendLandSet( Entity::Player& player );
2018-11-07 11:56:49 +01:00
void sendLandUpdate( uint8_t landId );
2018-11-01 00:18:19 +01:00
bool isPlayerSubInstance( Entity::Player& player );
bool onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId );
2018-11-01 00:18:19 +01:00
/* returns current ward number for this zone */
2018-11-04 23:47:10 +01:00
uint8_t getWardNum() const;
uint32_t getLandSetId() const;
Sapphire::LandPtr getLand( uint8_t id );
2018-11-01 00:18:19 +01:00
2018-12-25 23:43:39 +11:00
Entity::EventObjectPtr registerEstateEntranceEObj( uint8_t landId );
2018-12-26 00:43:27 +11:00
void updateYardObjects( Common::LandIdent ident );
void spawnYardObject( uint8_t landId, uint16_t slotId, Sapphire::Inventory::HousingItem& item );
void updateYardObjectPos( Entity::Player& sourcePlayer, uint16_t slot, uint16_t landId,
Inventory::HousingItem& item );
void despawnYardObject( uint16_t landId, uint16_t slot );
2018-12-26 00:43:27 +11:00
2018-11-01 00:18:19 +01:00
private:
using LandPtrMap = std::unordered_map< uint8_t, Sapphire::LandPtr >;
using YardObjectArray = std::array< Common::HousingObject, 800 >;
2018-12-26 01:05:28 +11:00
using YardObjectSubdivisionArray = std::array< YardObjectArray, 2 >;
2018-12-25 23:43:39 +11:00
2018-12-26 00:43:27 +11:00
/*!
* @brief Maps the start and end index of the yard object array for a specific plot
*
* pair.first = start index
* pair.second = end index
*/
2018-12-25 23:43:39 +11:00
using YardObjectArrayBoundsPair = std::pair< uint16_t, uint16_t >;
2018-12-26 00:43:27 +11:00
/*!
* @brief Maps each plot to a YardObjectArrayBoundsPair to the start/end index of the yard object array.
*/
using YardObjectArrayBoundsArray = std::array< YardObjectArrayBoundsPair, 60 >;
2018-11-04 23:47:10 +01:00
const uint32_t m_landSetMax = 18;
2018-11-01 23:56:43 +01:00
LandPtrMap m_landPtrMap;
2018-11-04 23:47:10 +01:00
uint8_t m_wardNum;
uint32_t m_landSetId;
uint32_t m_territoryTypeId;
2018-12-25 23:43:39 +11:00
2018-12-26 01:05:28 +11:00
YardObjectSubdivisionArray m_yardObjects;
2018-12-26 00:43:27 +11:00
YardObjectArrayBoundsArray m_yardObjectArrayBounds;
FrameworkPtr m_pFw;
2018-11-01 00:18:19 +01:00
};
2018-07-15 23:59:15 +02:00
}
#endif //SAPPHIRE_HOUSINGZONE_H