2018-11-10 19:00:13 +01:00
|
|
|
#ifndef SAPPHIRE_HOUSINGMGR_H
|
|
|
|
#define SAPPHIRE_HOUSINGMGR_H
|
|
|
|
|
|
|
|
#include "Forwards.h"
|
2018-12-01 00:27:16 +11:00
|
|
|
#include "Territory/HousingZone.h"
|
2018-11-10 19:00:13 +01:00
|
|
|
#include <set>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
namespace Sapphire::Data
|
2018-11-10 19:00:13 +01:00
|
|
|
{
|
2018-11-29 16:55:48 +01:00
|
|
|
using HousingZonePtr = std::shared_ptr< HousingZone >;
|
|
|
|
}
|
2018-11-10 19:00:13 +01:00
|
|
|
|
2018-12-01 00:27:16 +11:00
|
|
|
namespace Sapphire::World::Manager
|
2018-11-29 16:55:48 +01:00
|
|
|
{
|
2018-11-10 19:00:13 +01:00
|
|
|
class HousingMgr
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2018-12-22 11:33:21 +11:00
|
|
|
|
|
|
|
struct LandCacheEntry
|
|
|
|
{
|
|
|
|
// land table
|
|
|
|
uint64_t m_landSetId;
|
|
|
|
uint64_t m_landId;
|
|
|
|
|
2018-12-22 12:00:03 +11:00
|
|
|
Common::LandType m_type;
|
2018-12-22 11:33:21 +11:00
|
|
|
uint8_t m_size;
|
|
|
|
uint8_t m_status;
|
|
|
|
|
2018-12-22 12:00:03 +11:00
|
|
|
uint64_t m_currentPrice;
|
2018-12-22 11:33:21 +11:00
|
|
|
|
|
|
|
uint64_t m_updateTime;
|
|
|
|
uint64_t m_ownerId;
|
|
|
|
uint64_t m_houseId;
|
|
|
|
|
|
|
|
// house table
|
|
|
|
|
|
|
|
std::string m_estateWelcome;
|
|
|
|
std::string m_estateComment;
|
2018-12-22 14:35:42 +11:00
|
|
|
std::string m_estateName;
|
2018-12-22 11:33:21 +11:00
|
|
|
|
|
|
|
uint64_t m_buildTime;
|
|
|
|
uint64_t m_endorsements;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Maps land id to a list of cached entries
|
|
|
|
*/
|
|
|
|
using LandSetLandCacheMap = std::unordered_map< uint64_t, std::vector< LandCacheEntry > >;
|
|
|
|
|
2018-12-22 14:35:42 +11:00
|
|
|
/*!
|
|
|
|
* @brief Maps container IDs to their relevant ItemContainerPtr
|
|
|
|
*/
|
|
|
|
using ContainerIdToContainerMap = std::unordered_map< uint16_t, ItemContainerPtr >;
|
|
|
|
/*!
|
|
|
|
* @brief Maps land idents to a container containing ItemContainerPtrs
|
|
|
|
*/
|
|
|
|
using LandIdentToInventoryContainerMap = std::unordered_map< uint64_t, ContainerIdToContainerMap >;
|
|
|
|
|
2018-11-10 19:00:13 +01:00
|
|
|
HousingMgr();
|
|
|
|
virtual ~HousingMgr();
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
|
2018-11-16 17:07:22 +01:00
|
|
|
uint32_t toLandSetId( uint16_t territoryTypeId, uint8_t wardId ) const;
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
|
|
|
Sapphire::LandPtr getLandByOwnerId( uint32_t id );
|
2018-11-10 19:00:13 +01:00
|
|
|
|
2018-12-05 16:55:14 +11:00
|
|
|
void sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident );
|
|
|
|
void sendLandSignFree( Entity::Player& player, const Common::LandIdent ident );
|
2018-11-19 09:40:44 +01:00
|
|
|
LandPurchaseResult purchaseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
2018-11-13 23:46:10 +01:00
|
|
|
|
2018-12-05 19:58:43 +11:00
|
|
|
/*!
|
|
|
|
* @brief Converts param1 of a client trigger into a Common::LandIndent
|
|
|
|
*/
|
2018-12-19 01:03:41 +11:00
|
|
|
Common::LandIdent clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12, bool use16bits = true ) const;
|
2018-12-05 16:55:14 +11:00
|
|
|
|
2018-11-20 22:52:57 +11:00
|
|
|
void sendWardLandInfo( Entity::Player& player, uint8_t wardId, uint16_t territoryTypeId );
|
|
|
|
|
2018-11-17 01:16:44 +01:00
|
|
|
bool relinquishLand( Entity::Player& player, uint8_t plot );
|
|
|
|
|
2018-11-24 15:17:18 +11:00
|
|
|
void buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetItem );
|
|
|
|
|
2018-12-05 16:55:14 +11:00
|
|
|
void requestEstateRename( Entity::Player& player, const Common::LandIdent ident );
|
2018-11-28 21:59:28 +11:00
|
|
|
|
2018-12-05 16:55:14 +11:00
|
|
|
void requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident );
|
|
|
|
void updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting );
|
2018-11-28 21:24:00 +11:00
|
|
|
|
2018-12-05 16:55:14 +11:00
|
|
|
void requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident );
|
2018-11-29 00:19:37 +11:00
|
|
|
|
2018-12-04 22:20:41 +11:00
|
|
|
void sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident );
|
|
|
|
|
2018-12-22 17:22:24 +11:00
|
|
|
/*!
|
|
|
|
* @brief Updates the cached models on a house from the relevant apperance inventories.
|
|
|
|
* Does not send the subsequent update to clients.
|
|
|
|
*
|
|
|
|
* @param house The house to update the models for
|
|
|
|
*/
|
|
|
|
void updateHouseModels( HousePtr house );
|
|
|
|
|
2018-12-05 19:58:43 +11:00
|
|
|
/*!
|
|
|
|
* @brief Sends the house inventory for the specified type to a player.
|
|
|
|
*
|
2018-12-22 11:33:21 +11:00
|
|
|
* This enforces permissions on the inventory too so random players can't request an estates items
|
2018-12-05 19:58:43 +11:00
|
|
|
*/
|
2018-12-22 11:33:21 +11:00
|
|
|
void sendEstateInventory( Entity::Player& player, uint16_t inventoryType, uint8_t plotNum );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Get the land & house data that was cached on world startup.
|
|
|
|
* @return
|
|
|
|
*/
|
2018-12-22 17:25:30 +11:00
|
|
|
const LandSetLandCacheMap& getLandCacheMap();
|
2018-12-22 11:33:21 +11:00
|
|
|
|
2018-12-22 14:35:42 +11:00
|
|
|
/*!
|
|
|
|
* @brief Get all loaded inventories for housing estates
|
|
|
|
* @return
|
|
|
|
*/
|
2018-12-22 17:25:30 +11:00
|
|
|
LandIdentToInventoryContainerMap& getEstateInventories();
|
2018-12-22 14:35:42 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Get an estate inventory for a specific estate
|
|
|
|
* @param ident LandIdent for the specified estate
|
|
|
|
* @return A map containing container ids to ItemContainerPtr
|
|
|
|
*/
|
2018-12-22 17:25:30 +11:00
|
|
|
ContainerIdToContainerMap& getEstateInventory( uint64_t ident );
|
2018-12-22 14:35:42 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Get an estate inventory for a specific estate
|
|
|
|
* @param ident LandIdent for the specified estate
|
|
|
|
* @return A map containing container ids to ItemContainerPtr
|
|
|
|
*/
|
2018-12-22 17:25:30 +11:00
|
|
|
ContainerIdToContainerMap& getEstateInventory( Common::LandIdent ident );
|
2018-12-22 11:33:21 +11:00
|
|
|
private:
|
2018-12-22 14:35:42 +11:00
|
|
|
void loadLandCache();
|
|
|
|
bool loadEstateInventories();
|
|
|
|
|
2018-12-22 11:33:21 +11:00
|
|
|
LandSetLandCacheMap m_landCache;
|
2018-12-22 14:35:42 +11:00
|
|
|
LandIdentToInventoryContainerMap m_estateInventories;
|
2018-12-05 19:58:43 +11:00
|
|
|
|
2018-11-10 19:00:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SAPPHIRE_HOUSINGMGR_H
|