mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
housing item containers and some minor cleanup/refactoring
This commit is contained in:
parent
e2b7012f3d
commit
ef7a448ebc
4 changed files with 48 additions and 35 deletions
9
sql/houseiteminventory.sql
Normal file
9
sql/houseiteminventory.sql
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
CREATE TABLE `houseiteminventory` (
|
||||||
|
`landIdent` BIGINT(20) UNSIGNED NOT NULL,
|
||||||
|
`containerId` INT(10) UNSIGNED NOT NULL,
|
||||||
|
`itemId` INT(20) NOT NULL,
|
||||||
|
INDEX `landIdent` (`landIdent`)
|
||||||
|
)
|
||||||
|
COLLATE='latin1_swedish_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
|
@ -223,8 +223,9 @@ namespace Sapphire::Common
|
||||||
FreeCompanyCrystal = 22001,
|
FreeCompanyCrystal = 22001,
|
||||||
|
|
||||||
HousingExternalAppearance = 25000,
|
HousingExternalAppearance = 25000,
|
||||||
HousingOutdoorItems = 25001,
|
HousingOutdoorItemStoreroom = 25001,
|
||||||
HousingInternalAppearance = 25002,
|
HousingInternalAppearance = 25002,
|
||||||
|
HousingIndoorItemStoreroom = 25003,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ContainerType : uint16_t
|
enum ContainerType : uint16_t
|
||||||
|
@ -826,9 +827,9 @@ namespace Sapphire::Common
|
||||||
|
|
||||||
enum HouseSize : uint8_t
|
enum HouseSize : uint8_t
|
||||||
{
|
{
|
||||||
small,
|
Cottage,
|
||||||
medium,
|
House,
|
||||||
big
|
Mansion
|
||||||
};
|
};
|
||||||
|
|
||||||
enum HouseState : uint8_t
|
enum HouseState : uint8_t
|
||||||
|
|
|
@ -45,7 +45,7 @@ Sapphire::Land::Land( uint16_t territoryTypeId, uint8_t wardNum, uint8_t landId,
|
||||||
{
|
{
|
||||||
memset( &m_tag, 0x00, 3 );
|
memset( &m_tag, 0x00, 3 );
|
||||||
|
|
||||||
load();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::Land::~Land()
|
Sapphire::Land::~Land()
|
||||||
|
@ -53,7 +53,7 @@ Sapphire::Land::~Land()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Land::load()
|
void Sapphire::Land::init()
|
||||||
{
|
{
|
||||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||||
auto res = pDb->query( "SELECT * FROM land WHERE LandSetId = " + std::to_string( m_landSetId ) + " "
|
auto res = pDb->query( "SELECT * FROM land WHERE LandSetId = " + std::to_string( m_landSetId ) + " "
|
||||||
|
@ -98,7 +98,34 @@ void Sapphire::Land::load()
|
||||||
m_mapMarkerPosition.z = info->z;
|
m_mapMarkerPosition.z = info->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
switch( m_size )
|
||||||
|
{
|
||||||
|
case HouseSize::Cottage:
|
||||||
|
m_maxPlacedExternalItems = 20;
|
||||||
|
m_maxPlacedInternalItems = 200;
|
||||||
|
break;
|
||||||
|
case HouseSize::House:
|
||||||
|
m_maxPlacedExternalItems = 30;
|
||||||
|
m_maxPlacedInternalItems = 300;
|
||||||
|
break;
|
||||||
|
case HouseSize::Mansion:
|
||||||
|
m_maxPlacedExternalItems = 40;
|
||||||
|
m_maxPlacedInternalItems = 400;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// init item containers
|
||||||
|
auto setupContainer = [ this ]( InventoryType type, uint8_t maxSize )
|
||||||
|
{
|
||||||
|
m_landInventoryMap[ type ] = make_ItemContainer( type, maxSize, "houseiteminventory", true, true );
|
||||||
|
};
|
||||||
|
|
||||||
|
setupContainer( InventoryType::HousingExternalAppearance, 8 );
|
||||||
|
setupContainer( InventoryType::HousingInternalAppearance, 8 );
|
||||||
|
setupContainer( InventoryType::HousingOutdoorItemStoreroom, m_maxPlacedExternalItems );
|
||||||
|
setupContainer( InventoryType::HousingIndoorItemStoreroom, m_maxPlacedInternalItems );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Sapphire::Land::convertItemIdToHousingItemId( uint32_t itemId )
|
uint32_t Sapphire::Land::convertItemIdToHousingItemId( uint32_t itemId )
|
||||||
|
@ -223,11 +250,6 @@ uint32_t Sapphire::Land::getPlayerOwner()
|
||||||
return m_ownerPlayerId;
|
return m_ownerPlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Sapphire::Land::getMaxItems()
|
|
||||||
{
|
|
||||||
return m_maxItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Sapphire::Land::getDevaluationTime()
|
uint32_t Sapphire::Land::getDevaluationTime()
|
||||||
{
|
{
|
||||||
return m_nextDrop - static_cast< uint32_t >( Util::getTimeSeconds() );
|
return m_nextDrop - static_cast< uint32_t >( Util::getTimeSeconds() );
|
||||||
|
@ -248,25 +270,6 @@ uint8_t Sapphire::Land::getLandTag( uint8_t slot )
|
||||||
return m_tag[ slot ];
|
return m_tag[ slot ];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Land::init()
|
|
||||||
{
|
|
||||||
|
|
||||||
switch( m_size )
|
|
||||||
{
|
|
||||||
case HouseSize::small:
|
|
||||||
m_maxItems = 20;
|
|
||||||
break;
|
|
||||||
case HouseSize::medium:
|
|
||||||
m_maxItems = 30;
|
|
||||||
break;
|
|
||||||
case HouseSize::big:
|
|
||||||
m_maxItems = 40;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sapphire::Land::updateLandDb()
|
void Sapphire::Land::updateLandDb()
|
||||||
{
|
{
|
||||||
uint32_t houseId = 0;
|
uint32_t houseId = 0;
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Sapphire
|
||||||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId, Sapphire::Data::HousingLandSetPtr info );
|
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId, Sapphire::Data::HousingLandSetPtr info );
|
||||||
virtual ~Land();
|
virtual ~Land();
|
||||||
|
|
||||||
void load();
|
using LandInventoryMap = std::unordered_map< uint32_t, ItemContainerPtr >;
|
||||||
|
|
||||||
//Primary state
|
//Primary state
|
||||||
void setSize( uint8_t size );
|
void setSize( uint8_t size );
|
||||||
|
@ -53,7 +53,6 @@ namespace Sapphire
|
||||||
void updateLandDb();
|
void updateLandDb();
|
||||||
void update( uint32_t currTime );
|
void update( uint32_t currTime );
|
||||||
|
|
||||||
uint32_t getMaxItems();
|
|
||||||
uint32_t getCurrentPrice() const;
|
uint32_t getCurrentPrice() const;
|
||||||
uint32_t getMaxPrice() const;
|
uint32_t getMaxPrice() const;
|
||||||
uint32_t getDevaluationTime();
|
uint32_t getDevaluationTime();
|
||||||
|
@ -87,8 +86,9 @@ namespace Sapphire
|
||||||
Sapphire::HousePtr m_pHouse;
|
Sapphire::HousePtr m_pHouse;
|
||||||
|
|
||||||
//item storage
|
//item storage
|
||||||
Sapphire::ItemContainerPtr ItemsOutdoorContainer;
|
LandInventoryMap m_landInventoryMap;
|
||||||
uint32_t m_maxItems;
|
uint32_t m_maxPlacedExternalItems;
|
||||||
|
uint32_t m_maxPlacedInternalItems;
|
||||||
|
|
||||||
//price
|
//price
|
||||||
uint32_t m_initPrice;
|
uint32_t m_initPrice;
|
||||||
|
|
Loading…
Add table
Reference in a new issue