mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
commit
3c9a34a63a
10 changed files with 153 additions and 61 deletions
|
@ -1 +1,2 @@
|
|||
ALTER TABLE `land` ADD `Type` SMALLINT(6) NOT NULL DEFAULT '0' AFTER `LandId`;
|
||||
ALTER TABLE `land` ADD `Type` SMALLINT(6) NOT NULL DEFAULT '0' AFTER `LandId`;
|
||||
ALTER TABLE `house` ADD `HouseName` binary(23) DEFAULT "" AFTER `Comment`;
|
|
@ -37,8 +37,8 @@ public:
|
|||
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pTerritory );
|
||||
auto pHouMgr = pFw->get< Core::HousingMgr >();
|
||||
|
||||
LandPurchaseResult res = pHouMgr->purchseLand( player, activeLand.plot,
|
||||
static_cast< uint8_t >( result.param2 ) );
|
||||
LandPurchaseResult res = pHouMgr->purchaseLand( player, activeLand.plot,
|
||||
static_cast< uint8_t >( result.param2 ) );
|
||||
|
||||
switch( res )
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ TYPE_FORWARD( Cell );
|
|||
TYPE_FORWARD( Zone );
|
||||
TYPE_FORWARD( HousingZone );
|
||||
TYPE_FORWARD( HousingMgr );
|
||||
TYPE_FORWARD( House );
|
||||
TYPE_FORWARD( InstanceContent );
|
||||
TYPE_FORWARD( Item );
|
||||
TYPE_FORWARD( ItemContainer );
|
||||
|
|
73
src/servers/sapphire_zone/Zone/House.cpp
Normal file
73
src/servers/sapphire_zone/Zone/House.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include <set>
|
||||
#include <string.h>
|
||||
|
||||
#include <Logging/Logger.h>
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
|
||||
#include "House.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
Core::House::House( uint32_t houseId, uint32_t landSetId, uint8_t landId, uint8_t wardNum, uint16_t territoryTypeId ) :
|
||||
m_houseId( houseId ),
|
||||
m_landSetId( landSetId ),
|
||||
m_landId( landId ),
|
||||
m_wardNum( wardNum ),
|
||||
m_territoryTypeId( territoryTypeId )
|
||||
{
|
||||
memset( &m_houseParts, 0x00, sizeof( m_houseParts ) );
|
||||
memset( &m_commentMsg, 0x00, sizeof( m_commentMsg ) );
|
||||
}
|
||||
|
||||
Core::House::~House()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Core::House::getLandSetId() const
|
||||
{
|
||||
return m_landSetId;
|
||||
}
|
||||
|
||||
uint8_t Core::House::getLandId() const
|
||||
{
|
||||
return m_landId;
|
||||
}
|
||||
|
||||
uint8_t Core::House::getWardNum() const
|
||||
{
|
||||
return m_wardNum;
|
||||
}
|
||||
|
||||
uint16_t Core::House::getTerritoryTypeId() const
|
||||
{
|
||||
return m_territoryTypeId;
|
||||
}
|
||||
|
||||
uint32_t Core::House::getHouseId() const
|
||||
{
|
||||
return m_houseId;
|
||||
}
|
||||
|
||||
uint8_t Core::House::getHousePartColor( Common::HousePartSlot slot ) const
|
||||
{
|
||||
return m_housePartsColor[ slot ];
|
||||
}
|
||||
|
||||
void Core::House::setHousePart( Common::HousePartSlot slot, uint32_t id )
|
||||
{
|
||||
m_houseParts[ slot ] = id;
|
||||
}
|
||||
|
||||
void Core::House::setHousePartColor( Common::HousePartSlot slot, uint32_t id )
|
||||
{
|
||||
m_housePartsColor[ slot ] = id;
|
||||
}
|
||||
|
||||
uint32_t Core::House::getHousePart( Common::HousePartSlot slot ) const
|
||||
{
|
||||
return m_houseParts[ slot ];
|
||||
}
|
47
src/servers/sapphire_zone/Zone/House.h
Normal file
47
src/servers/sapphire_zone/Zone/House.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef SAPPHIRE_HOUSE_H
|
||||
#define SAPPHIRE_HOUSE_H
|
||||
|
||||
#include "Forwards.h"
|
||||
#include <Common.h>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
||||
class House
|
||||
{
|
||||
|
||||
public:
|
||||
House( uint32_t houseId, uint32_t landSetId, uint8_t landId, uint8_t wardNum, uint16_t territoryTypeId );
|
||||
virtual ~House();
|
||||
|
||||
//gerneral
|
||||
uint32_t getLandSetId() const;
|
||||
uint8_t getLandId() const;
|
||||
uint8_t getWardNum() const;
|
||||
uint16_t getTerritoryTypeId() const;
|
||||
uint32_t getHouseId() const;
|
||||
|
||||
//functions
|
||||
void setHousePart( Common::HousePartSlot slot, uint32_t id );
|
||||
void setHousePartColor( Common::HousePartSlot slot, uint32_t id );
|
||||
uint32_t getHousePart( Common::HousePartSlot slot ) const;
|
||||
uint8_t getHousePartColor( Common::HousePartSlot slot ) const;
|
||||
|
||||
private:
|
||||
uint32_t m_landSetId;
|
||||
uint8_t m_landId;
|
||||
uint8_t m_wardNum;
|
||||
uint16_t m_territoryTypeId;
|
||||
uint32_t m_houseId;
|
||||
|
||||
uint32_t m_houseParts[ 8 ];
|
||||
uint8_t m_housePartsColor[ 8 ];
|
||||
|
||||
char m_commentMsg[ 193 ];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SAPPHIRE_HOUSE_H
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "TerritoryMgr.h"
|
||||
#include "Zone.h"
|
||||
#include "HousingZone.h"
|
||||
#include "HousingMgr.h"
|
||||
|
@ -26,8 +27,7 @@ using namespace Core::Network::Packets::Server;
|
|||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
Core::HousingMgr::HousingMgr() :
|
||||
m_lastLandId( 0 )
|
||||
Core::HousingMgr::HousingMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -43,61 +43,32 @@ bool Core::HousingMgr::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
uint16_t Core::HousingMgr::getNexLandId()
|
||||
{
|
||||
return ++m_lastLandId;
|
||||
}
|
||||
|
||||
uint32_t Core::HousingMgr::toLandSetId( uint16_t territoryTypeId, uint8_t wardId ) const
|
||||
{
|
||||
return ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardId;
|
||||
}
|
||||
|
||||
void Core::HousingMgr::insertHousingZone( Core::Data::HousingZonePtr hZone )
|
||||
{
|
||||
uint16_t id = getNexLandId();
|
||||
m_housingZonePtrMap[id] = hZone;
|
||||
}
|
||||
|
||||
Core::Data::HousingZonePtr Core::HousingMgr::getHousingZone( uint16_t id )
|
||||
{
|
||||
auto it = m_housingZonePtrMap.find( id );
|
||||
if( it == m_housingZonePtrMap.end() )
|
||||
return nullptr;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
Core::Data::HousingZonePtr Core::HousingMgr::getHousingZoneByLandSetId( uint32_t id )
|
||||
{
|
||||
for( const auto& hZoneIt : m_housingZonePtrMap )
|
||||
{
|
||||
auto pHousingZone = hZoneIt.second;
|
||||
for( uint8_t landId = 0; landId < 60; landId++ )
|
||||
{
|
||||
if( pHousingZone->getLandSetId() == id )
|
||||
{
|
||||
return pHousingZone;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
return std::dynamic_pointer_cast< HousingZone >( pTeriMgr->getZoneByLandSetId( id ) );
|
||||
}
|
||||
|
||||
Core::LandPtr Core::HousingMgr::getLandByOwnerId( uint32_t id )
|
||||
{
|
||||
for( const auto& hZoneIt : m_housingZonePtrMap )
|
||||
{
|
||||
auto pHousingZone = hZoneIt.second;
|
||||
for( uint8_t landId = 0; landId < 60; landId++ )
|
||||
{
|
||||
if( pHousingZone->getLand( landId )->getPlayerOwner() == id )
|
||||
{
|
||||
return pHousingZone->getLand( landId );
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT LandSetId, LandId FROM land WHERE OwnerId = " + std::to_string( id ) );
|
||||
|
||||
if( !res->next() )
|
||||
return nullptr;
|
||||
|
||||
auto hZone = getHousingZoneByLandSetId( res->getUInt( 1 ) );
|
||||
|
||||
if( !hZone )
|
||||
return nullptr;
|
||||
|
||||
return hZone->getLand( res->getUInt( 2 ) );
|
||||
}
|
||||
|
||||
void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
||||
|
@ -149,7 +120,7 @@ void Core::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t wardId,
|
|||
player.queuePacket( plotPricePacket );
|
||||
}
|
||||
|
||||
Core::LandPurchaseResult Core::HousingMgr::purchseLand( Entity::Player& player, uint8_t plot, uint8_t state )
|
||||
Core::LandPurchaseResult Core::HousingMgr::purchaseLand( Entity::Player& player, uint8_t plot, uint8_t state )
|
||||
{
|
||||
auto pHousing = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
|
||||
|
||||
|
|
|
@ -23,22 +23,17 @@ namespace Core
|
|||
bool init();
|
||||
|
||||
uint32_t toLandSetId( uint16_t territoryTypeId, uint8_t wardId ) const;
|
||||
uint16_t getNexLandId();
|
||||
void insertHousingZone( Core::Data::HousingZonePtr hZone );
|
||||
Core::Data::HousingZonePtr getHousingZone( uint16_t id );
|
||||
Core::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
||||
Core::LandPtr getLandByOwnerId( uint32_t id );
|
||||
|
||||
void sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
||||
void sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
||||
LandPurchaseResult purchseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
||||
LandPurchaseResult purchaseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
||||
|
||||
bool relinquishLand( Entity::Player& player, uint8_t plot );
|
||||
|
||||
private:
|
||||
using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >;
|
||||
uint16_t m_lastLandId;
|
||||
HousingZonePtrMap m_housingZonePtrMap;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -65,9 +65,6 @@ bool Core::HousingZone::init()
|
|||
m_landPtrMap[ landId ] = pObject;
|
||||
}
|
||||
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
pHousingMgr->insertHousingZone( (HousingZonePtr)this );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -108,10 +105,9 @@ void Core::HousingZone::onPlayerZoneIn( Entity::Player& player )
|
|||
for( uint8_t i = startIndex, count = 0; i < ( startIndex + 30 ); i++, count++ )
|
||||
{
|
||||
landSetMap->data().landInfo[ count ].status = 1;
|
||||
//memcpy( , &getLand( i )->getLand(), sizeof( Common::LandStruct ) );
|
||||
}
|
||||
|
||||
//player.queuePacket( landSetMap );
|
||||
player.queuePacket( landSetMap );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,11 @@ uint16_t Core::Land::getZoneId() const
|
|||
return m_zoneId;
|
||||
}
|
||||
|
||||
Core::HousePtr Core::Land::getHouse() const
|
||||
{
|
||||
return m_pHouse;
|
||||
}
|
||||
|
||||
Core::Common::LandType Core::Land::getLandType() const
|
||||
{
|
||||
return m_type;
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Core
|
|||
uint8_t getLandId() const;
|
||||
uint16_t getZoneId() const;
|
||||
Common::LandType getLandType() const;
|
||||
Core::HousePtr getHouse() const;
|
||||
|
||||
//Free Comapny
|
||||
void setFreeCompany( uint32_t id, uint32_t icon, uint32_t color );
|
||||
|
@ -79,6 +80,8 @@ namespace Core
|
|||
uint32_t m_ownerPlayerId;
|
||||
Core::Data::HousingLandSetPtr m_landInfo;
|
||||
|
||||
Core::HousePtr m_pHouse;
|
||||
|
||||
//item storage
|
||||
Core::ItemContainerPtr ItemsOutdoorContainer;
|
||||
uint32_t m_maxItems;
|
||||
|
|
Loading…
Add table
Reference in a new issue