mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 00:27:44 +00:00
housing instance
This commit is contained in:
parent
ea2acfcd8f
commit
7d042d264e
13 changed files with 164 additions and 25 deletions
|
@ -2,3 +2,4 @@ ALTER TABLE `land` ADD `Type` SMALLINT(6) NOT NULL DEFAULT '0' AFTER `LandId`;
|
|||
ALTER TABLE `house` ADD `HouseName` binary(23) DEFAULT "" AFTER `Comment`;
|
||||
ALTER TABLE `house` ADD `HousePartModels` BINARY(32) DEFAULT "" AFTER `Endorsements`;
|
||||
ALTER TABLE `house` ADD `HousePartColours` BINARY(8) DEFAULT "" AFTER `HousePartModels`;
|
||||
ALTER TABLE `house` ADD `HouseInteriorModels` BINARY(40) DEFAULT "" AFTER `HousePartColours`;
|
|
@ -751,6 +751,20 @@ namespace Sapphire::Common
|
|||
YardSign
|
||||
};
|
||||
|
||||
enum HousingInteriorSlot
|
||||
{
|
||||
InteriorWall,
|
||||
InteriorFloor,
|
||||
InteriorLight,
|
||||
InteriorWall_Attic,
|
||||
InteriorFloor_Attic,
|
||||
InteriorLight_Attic,
|
||||
InteriorWall_Basement,
|
||||
InteriorFloor_Basement,
|
||||
InteriorLight_Basement,
|
||||
InteriorLight_Mansion
|
||||
};
|
||||
|
||||
enum HouseTagSlot
|
||||
{
|
||||
MainTag,
|
||||
|
|
|
@ -197,7 +197,7 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
|
|||
CONNECTION_BOTH );
|
||||
|
||||
prepareStatement( HOUSING_HOUSE_UP,
|
||||
"UPDATE house SET BuildTime = ?, Aetheryte = ?, Comment = ?, HouseName = ?, Endorsements = ?, HousePartModels = ?, HousePartColours = ? WHERE HouseId = ?;",
|
||||
"UPDATE house SET BuildTime = ?, Aetheryte = ?, Comment = ?, HouseName = ?, Endorsements = ?, HousePartModels = ?, HousePartColours = ?, HouseInteriorModels = ? WHERE HouseId = ?;",
|
||||
CONNECTION_BOTH );
|
||||
|
||||
/*prepareStatement( LAND_INS,
|
||||
|
|
|
@ -186,7 +186,7 @@ namespace Sapphire::Network::Packets
|
|||
LandSetInitialize = 0x0220, // updated 4.4
|
||||
LandUpdate = 0x0221, // updated 4.4
|
||||
YardObjectSpawn = 0x0222, // updated 4.4
|
||||
|
||||
HousingIndoorInitialize = 0x0223,
|
||||
LandPriceUpdate = 0x0224, // updated 4.4
|
||||
LandInfoSign = 0x0225, // updated 4.4
|
||||
LandRename = 0x0226, // updated 4.4
|
||||
|
@ -197,7 +197,7 @@ namespace Sapphire::Network::Packets
|
|||
HousingLandFlags = 0x0229, // updated 4.4
|
||||
HousingShowEstateGuestAccess = 0x022A, // updated 4.4
|
||||
|
||||
LandSetYardInitialize = 0x022C, // updated 4.4
|
||||
HousingObjectInitialize = 0x022C, // updated 4.4
|
||||
|
||||
HousingWardInfo = 0x022F, // updated 4.4
|
||||
|
||||
|
|
|
@ -1704,17 +1704,27 @@ struct FFXIVIpcYardObjectMove : FFXIVIpcBasePacket<YardObjectMove>
|
|||
uint16_t unknown3;
|
||||
};
|
||||
|
||||
struct FFXIVIpcLandSetYardInitialize : FFXIVIpcBasePacket< LandSetYardInitialize >
|
||||
struct FFXIVIpcHousingObjectInitialize : FFXIVIpcBasePacket< HousingObjectInitialize >
|
||||
{
|
||||
uint32_t unknown1; //always 0xFFFFFFFF
|
||||
uint32_t unknown2; //always 0xFFFFFFFF
|
||||
uint8_t unknown3; //always 0xFF
|
||||
Common::LandIdent landIdent;
|
||||
int8_t u1; //Outdoor -1 / Indoor 0 - probably indicator
|
||||
uint8_t packetNum;
|
||||
uint16_t packetTotal;
|
||||
uint8_t packetTotal;
|
||||
uint8_t u2; //Outdoor 0 / Indoor 100(?)
|
||||
Common::YardObject object[100];
|
||||
uint32_t unknown4; //unused
|
||||
};
|
||||
|
||||
struct FFXIVIpcHousingIndoorInitialize : FFXIVIpcBasePacket< HousingIndoorInitialize >
|
||||
{
|
||||
uint16_t u1;
|
||||
uint16_t u2;
|
||||
uint16_t u3;
|
||||
uint16_t u4;
|
||||
uint32_t indoorItems[10];
|
||||
};
|
||||
|
||||
|
||||
struct FFXIVIpcHousingWardInfo : FFXIVIpcBasePacket< HousingWardInfo >
|
||||
{
|
||||
Common::LandIdent landIdent;
|
||||
|
|
|
@ -45,7 +45,13 @@ public:
|
|||
if( result.param2 != 1 )
|
||||
return;
|
||||
|
||||
// param2 == 1, zone into instance
|
||||
if( result.param2 == 1 )
|
||||
{
|
||||
//player.eventFinish( 131148, 0 );
|
||||
//player.eventFinish( this->getId(), 1 );
|
||||
player.setPos( {0, 0, 0} );
|
||||
player.setInstance( internalZone );
|
||||
}
|
||||
} );
|
||||
}
|
||||
};
|
|
@ -341,7 +341,7 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousingInt
|
|||
if( !terriInfo )
|
||||
return nullptr;
|
||||
|
||||
auto zone = World::Territory::Housing::make_HousingInteriorTerritory( ident, territoryTypeId, getNextInstanceId(),
|
||||
auto zone = World::Territory::Housing::make_HousingInteriorTerritory( landIdent, territoryTypeId, getNextInstanceId(),
|
||||
terriInfo->name, house->getHouseName() );
|
||||
|
||||
zone->init();
|
||||
|
|
|
@ -48,11 +48,18 @@ Sapphire::House::House( uint32_t houseId, uint32_t landSetId, uint8_t landId, ui
|
|||
auto housePartColours = res->getBlobVector( "HousePartColours" );
|
||||
|
||||
auto models = reinterpret_cast< uint32_t* >( &housePartModels[ 0 ] );
|
||||
|
||||
for( auto i = 0; i < 8; i++ )
|
||||
{
|
||||
m_houseParts[ i ] = { models[ i ], housePartColours[ i ] };
|
||||
}
|
||||
|
||||
auto houseInteriorModels = res->getBlobVector( "HouseInteriorModels" );
|
||||
|
||||
models = reinterpret_cast<uint32_t*>( &houseInteriorModels[0] );
|
||||
for( auto i = 0; i < 10; i++ )
|
||||
{
|
||||
m_houseInteriorParts[ i ] = houseInteriorModels[ i ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +74,7 @@ void Sapphire::House::updateHouseDb()
|
|||
// BuildTime = 1, Aetheryte = 2, Comment = 3, HouseName = 4, Endorsements = 5,
|
||||
// HousePartModels = 6, HousePartColours = 7, HouseId = 8
|
||||
auto stmt = pDB->getPreparedStatement( Db::HOUSING_HOUSE_UP );
|
||||
stmt->setUInt( 8, m_houseId );
|
||||
stmt->setUInt( 9, m_houseId );
|
||||
|
||||
stmt->setInt64( 1, m_buildTime );
|
||||
stmt->setInt( 2, 0 );
|
||||
|
@ -94,6 +101,18 @@ void Sapphire::House::updateHouseDb()
|
|||
stmt->setBinary( 6, tmpModels );
|
||||
stmt->setBinary( 7, colours );
|
||||
|
||||
models.clear();
|
||||
|
||||
for( auto i = 0; i < 10; i++ )
|
||||
{
|
||||
models.push_back( m_houseInteriorParts[ i ] );
|
||||
}
|
||||
|
||||
std::vector< uint8_t > tmp2Models( models.size() * 4 );
|
||||
memcpy( tmp2Models.data(), models.data(), tmp2Models.size() );
|
||||
|
||||
stmt->setBinary( 8, tmp2Models );
|
||||
|
||||
pDB->execute( stmt );
|
||||
}
|
||||
|
||||
|
@ -127,6 +146,11 @@ uint8_t Sapphire::House::getHousePartColor( Common::HousePartSlot slot ) const
|
|||
return m_houseParts[ slot ].second;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::House::getHouseInteriorPart( Common::HousingInteriorSlot slot ) const
|
||||
{
|
||||
return m_houseInteriorParts[ slot ];
|
||||
}
|
||||
|
||||
void Sapphire::House::setHousePart( Common::HousePartSlot slot, uint32_t id )
|
||||
{
|
||||
m_houseParts[ slot ].first = id;
|
||||
|
@ -137,6 +161,11 @@ void Sapphire::House::setHousePartColor( Common::HousePartSlot slot, uint32_t id
|
|||
m_houseParts[ slot ].second = id;
|
||||
}
|
||||
|
||||
void Sapphire::House::setHouseInteriorPart( Common::HousingInteriorSlot slot, uint32_t id )
|
||||
{
|
||||
m_houseInteriorParts[ slot ] = id;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::House::getHousePart( Common::HousePartSlot slot ) const
|
||||
{
|
||||
return m_houseParts[ slot ].first;
|
||||
|
|
|
@ -34,8 +34,10 @@ namespace Sapphire
|
|||
//functions
|
||||
void setHousePart( Common::HousePartSlot slot, uint32_t id );
|
||||
void setHousePartColor( Common::HousePartSlot slot, uint32_t id );
|
||||
void setHouseInteriorPart( Common::HousingInteriorSlot slot, uint32_t id );
|
||||
uint32_t getHousePart( Common::HousePartSlot slot ) const;
|
||||
uint8_t getHousePartColor( Common::HousePartSlot slot ) const;
|
||||
uint32_t getHouseInteriorPart( Common::HousingInteriorSlot slot ) const;
|
||||
|
||||
HousePartsArray const& getHouseParts() const;
|
||||
|
||||
|
@ -51,6 +53,7 @@ namespace Sapphire
|
|||
uint64_t m_buildTime;
|
||||
|
||||
HousePartsArray m_houseParts;
|
||||
uint32_t m_houseInteriorParts[10];
|
||||
|
||||
std::string m_estateMessage;
|
||||
std::string m_houseName;
|
||||
|
|
|
@ -1,10 +1,34 @@
|
|||
#include <Common.h>
|
||||
#include <Logging/Logger.h>
|
||||
#include <Util/Util.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Network/GamePacketNew.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/Actor.h"
|
||||
#include "Actor/EventObject.h"
|
||||
#include "Manager/HousingMgr.h"
|
||||
#include "Territory/Land.h"
|
||||
#include "Territory/House.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "HousingInteriorTerritory.h"
|
||||
#include "Common.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::World::Territory;
|
||||
|
||||
Housing::HousingInteriorTerritory::HousingInteriorTerritory( uint64_t ident, uint16_t territoryTypeId,
|
||||
Housing::HousingInteriorTerritory::HousingInteriorTerritory( Common::LandIdent ident, uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName ) :
|
||||
|
@ -21,11 +45,52 @@ Housing::HousingInteriorTerritory::~HousingInteriorTerritory()
|
|||
|
||||
bool Housing::HousingInteriorTerritory::init()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Housing::HousingInteriorTerritory::onPlayerZoneIn( Entity::Player& player )
|
||||
{
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->debug(
|
||||
"HousingInteriorTerritory::onPlayerZoneIn: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryTypeId() ) +
|
||||
", Entity#" + std::to_string( player.getId() ) );
|
||||
|
||||
auto housingIndoorInitializPacket = makeZonePacket< FFXIVIpcHousingIndoorInitialize >( player.getId() );
|
||||
housingIndoorInitializPacket->data().u1 = 2578;
|
||||
housingIndoorInitializPacket->data().u2 = 10;
|
||||
housingIndoorInitializPacket->data().u3 = 530;
|
||||
housingIndoorInitializPacket->data().u4 = 266;
|
||||
|
||||
auto landSetId = pHousingMgr->toLandSetId( m_landIdent.territoryTypeId, m_landIdent.wardNum );
|
||||
auto pLand = pHousingMgr->getHousingZoneByLandSetId( landSetId )->getLand( m_landIdent.landId );
|
||||
auto pHouse = pLand->getHouse();
|
||||
|
||||
|
||||
uint32_t yardPacketNum;
|
||||
uint32_t yardPacketTotal = 2 + pLand->getSize();
|
||||
|
||||
for( auto i = 0; i < 10; i++ )
|
||||
{
|
||||
housingIndoorInitializPacket->data().indoorItems[ i ] = pHouse->getHouseInteriorPart( (Common::HousingInteriorSlot)i );
|
||||
}
|
||||
|
||||
player.queuePacket( housingIndoorInitializPacket );
|
||||
|
||||
for( yardPacketNum = 0; yardPacketNum < yardPacketTotal; yardPacketNum++ )
|
||||
{
|
||||
auto housingObjectInitializPacket = makeZonePacket< FFXIVIpcHousingObjectInitialize >( player.getId() );
|
||||
memcpy( &housingObjectInitializPacket->data().landIdent, &m_landIdent, sizeof( Common::LandIdent ) );
|
||||
housingObjectInitializPacket->data().landIdent.worldId = 67;
|
||||
housingObjectInitializPacket->data().u1 = 0;
|
||||
housingObjectInitializPacket->data().u2 = 100;
|
||||
housingObjectInitializPacket->data().packetNum = yardPacketNum;
|
||||
housingObjectInitializPacket->data().packetTotal = yardPacketTotal;
|
||||
|
||||
//TODO: Add Objects here
|
||||
|
||||
player.queuePacket( housingObjectInitializPacket );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Sapphire::World::Territory::Housing
|
|||
class HousingInteriorTerritory : public Zone
|
||||
{
|
||||
public:
|
||||
HousingInteriorTerritory( uint64_t ident, uint16_t territoryTypeId,
|
||||
HousingInteriorTerritory( Common::LandIdent ident, uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName );
|
||||
|
@ -19,6 +19,6 @@ namespace Sapphire::World::Territory::Housing
|
|||
void onUpdate( uint32_t currTime ) override;
|
||||
|
||||
private:
|
||||
uint64_t m_landIdent;
|
||||
Common::LandIdent m_landIdent;
|
||||
};
|
||||
}
|
|
@ -96,16 +96,15 @@ void Sapphire::HousingZone::onPlayerZoneIn( Entity::Player& player )
|
|||
|
||||
for( yardPacketNum = 0; yardPacketNum < yardPacketTotal; yardPacketNum++ )
|
||||
{
|
||||
auto landsetYardInitializePacket = makeZonePacket< FFXIVIpcLandSetYardInitialize >( player.getId() );
|
||||
landsetYardInitializePacket->data().unknown1 = 0xFFFFFFFF;
|
||||
landsetYardInitializePacket->data().unknown2 = 0xFFFFFFFF;
|
||||
landsetYardInitializePacket->data().unknown3 = 0xFF;
|
||||
landsetYardInitializePacket->data().packetNum = yardPacketNum;
|
||||
landsetYardInitializePacket->data().packetTotal = yardPacketTotal;
|
||||
auto housingObjectInitializPacket = makeZonePacket< FFXIVIpcHousingObjectInitialize >( player.getId() );
|
||||
memset( &housingObjectInitializPacket->data().landIdent, 0xFF, sizeof( Common::LandIdent ) );
|
||||
housingObjectInitializPacket->data().u1 = 0xFF;
|
||||
housingObjectInitializPacket->data().packetNum = yardPacketNum;
|
||||
housingObjectInitializPacket->data().packetTotal = yardPacketTotal;
|
||||
|
||||
//TODO: Add Objects here
|
||||
|
||||
player.queuePacket( landsetYardInitializePacket );
|
||||
player.queuePacket( housingObjectInitializPacket );
|
||||
}
|
||||
|
||||
auto landSetMap = makeZonePacket< FFXIVIpcLandSetMap >( player.getId() );
|
||||
|
|
|
@ -337,5 +337,17 @@ bool Sapphire::Land::setPreset( uint32_t itemId )
|
|||
getHouse()->setHousePart( Common::HousePartSlot::ExteriorWindow, convertItemIdToHousingItemId( housingPreset->exteriorWindow ) );
|
||||
getHouse()->setHousePart( Common::HousePartSlot::ExteriorDoor, convertItemIdToHousingItemId( housingPreset->exteriorDoor ) );
|
||||
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorWall, convertItemIdToHousingItemId( housingPreset->interiorWall ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorFloor, convertItemIdToHousingItemId( housingPreset->interiorFlooring ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorLight, convertItemIdToHousingItemId( housingPreset->interiorLighting ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorWall_Attic, convertItemIdToHousingItemId( housingPreset->otherFloorWall ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorFloor_Attic, convertItemIdToHousingItemId( housingPreset->otherFloorFlooring ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorLight_Attic, convertItemIdToHousingItemId( housingPreset->otherFloorLighting ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorWall_Basement, convertItemIdToHousingItemId( housingPreset->basementWall ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorFloor_Basement, convertItemIdToHousingItemId( housingPreset->basementFlooring ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorLight_Basement, convertItemIdToHousingItemId( housingPreset->basementLighting ) );
|
||||
getHouse()->setHouseInteriorPart(Common::HousingInteriorSlot::InteriorLight_Mansion, convertItemIdToHousingItemId( housingPreset->mansionLighting ) );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue