From 24520a84915e250f69d9fe2bb27d983ae9038391 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 23 Dec 2018 20:54:21 +1100 Subject: [PATCH] more refactoring + sql --- src/common/Database/ZoneDbConnection.cpp | 2 +- src/world/Manager/HousingMgr.cpp | 14 ++++++++++++++ src/world/Manager/HousingMgr.h | 1 + src/world/Territory/House.cpp | 2 +- src/world/Territory/House.h | 2 +- src/world/Territory/Land.cpp | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/common/Database/ZoneDbConnection.cpp b/src/common/Database/ZoneDbConnection.cpp index e1d66758..fe8c90e9 100644 --- a/src/common/Database/ZoneDbConnection.cpp +++ b/src/common/Database/ZoneDbConnection.cpp @@ -193,7 +193,7 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements() /// HOUSING prepareStatement( HOUSING_HOUSE_INS, - "INSERT INTO house ( LandSetId, HouseId ) VALUES ( ?, ? );", + "INSERT INTO house ( LandSetId, HouseId, HouseName ) VALUES ( ?, ?, ? );", CONNECTION_BOTH ); prepareStatement( HOUSING_HOUSE_UP, diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index 7680128e..f1c4c0f5 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -521,6 +521,20 @@ bool Sapphire::World::Manager::HousingMgr::initHouseModels( Entity::Player& play return true; } +void Sapphire::World::Manager::HousingMgr::createHouse( Sapphire::HousePtr house ) const +{ + auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); + + auto stmt = pDb->getPreparedStatement( Db::HOUSING_HOUSE_INS ); + // LandSetId, HouseId, HouseName + + stmt->setUInt( 1, house->getLandSetId() ); + stmt->setUInt( 2, house->getId() ); + stmt->setString( 3, house->getHouseName() ); + + pDb->execute( stmt ); +} + void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetItem ) { auto hZone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() ); diff --git a/src/world/Manager/HousingMgr.h b/src/world/Manager/HousingMgr.h index 4cd07a57..6fcf53b7 100644 --- a/src/world/Manager/HousingMgr.h +++ b/src/world/Manager/HousingMgr.h @@ -142,6 +142,7 @@ namespace Sapphire::World::Manager */ bool initHouseModels( Entity::Player& player, LandPtr land, uint32_t presetCatalogId ); + void createHouse( HousePtr house ) const; private: /*! diff --git a/src/world/Territory/House.cpp b/src/world/Territory/House.cpp index 34718ff7..4e5d3855 100644 --- a/src/world/Territory/House.cpp +++ b/src/world/Territory/House.cpp @@ -53,7 +53,7 @@ Sapphire::Common::LandIdent Sapphire::House::getLandIdent() const return m_landIdent; } -uint32_t Sapphire::House::getHouseId() const +uint32_t Sapphire::House::getId() const { return m_houseId; } diff --git a/src/world/Territory/House.h b/src/world/Territory/House.h index d0a0e5a3..b307ecd6 100644 --- a/src/world/Territory/House.h +++ b/src/world/Territory/House.h @@ -22,7 +22,7 @@ namespace Sapphire //gerneral uint32_t getLandSetId() const; Common::LandIdent getLandIdent() const; - uint32_t getHouseId() const; + uint32_t getId() const; const std::string& getHouseName() const; void setHouseName( const std::string& name ); diff --git a/src/world/Territory/Land.cpp b/src/world/Territory/Land.cpp index 3e0abc1b..c2e3af65 100644 --- a/src/world/Territory/Land.cpp +++ b/src/world/Territory/Land.cpp @@ -232,7 +232,7 @@ void Sapphire::Land::updateLandDb() uint32_t houseId = 0; if( getHouse() ) - houseId = getHouse()->getHouseId(); + houseId = getHouse()->getId(); // todo: change to prepared statement auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();