1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

Merge pull request #10 from SapphireServer/housing

Housing
This commit is contained in:
XeAri 2018-11-23 09:11:42 +01:00 committed by GitHub
commit 7721f63f51
38 changed files with 298 additions and 143 deletions

View file

@ -19,12 +19,6 @@ MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURR
ALTER TABLE charainfosearch
MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE charaitemcrystal
MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE charaitemcurrency
MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE charaitemgearset
MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

View file

@ -218,7 +218,8 @@ INSERT INTO `zonepositions` (`id`, `target_zone_id`, `pos_x`, `pos_y`, `pos_z`,
(1359650, 153, -226.643, 21.23, 351.76, -0.74, 2),
(3965709, 147, 22.9166, 48.309, -26.801, -2.406, 2),
(3965584, 146, -320.39, 8.262, 406.08, -1.455, 2),
(5668783, 144, -0.3458, 1.0425, -5.786, 0.0603, 2);
(5668783, 144, -0.3458, 1.0425, -5.786, 0.0603, 2),
(4656744, 341, 29.4298, -11.0766, -211.529, -0.5092, 2);
/*!40000 ALTER TABLE `zonepositions` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;

View file

@ -295,7 +295,7 @@ enum ActorControlType : uint16_t
RequestWardLandInfo = 0x453,
RequestLandRelinquish = 0x454,
RequestEstateRename = 0x45A,
RequestEstateGreeting = 0x45C,
RequestEstateGreeting = 0x45C, // sends FFXIVIpcHousingEstateGreeting in return
RequestHousingItemUI = 0x463,
RequestSharedEstateSettings = 0x46F,

View file

@ -94,7 +94,7 @@ namespace Core::Network::Packets
MailDeleteRequest = 0x0118, // updated 4.4
ReqMoogleMailList = 0x0119, // updated 4.4
ReqMoogleMailLetter = 0x01A, // updated 4.4
ReqMoogleMailLetter = 0x011A, // updated 4.4
MailLetterNotification = 0x011B, // updated 4.4
ExamineFreeCompanyInfo = 0x013A, // updated 4.1
@ -191,6 +191,8 @@ namespace Core::Network::Packets
LandInfoSign = 0x0225, // updated 4.4
LandRename = 0x0226, // updated 4.4
HousingEstateGreeting = 0x0227, // updated 4.4
LandPermissionSlot = 0x0228, // updated 4.4
LandPermission = 0x0229, // updated 4.4
@ -291,11 +293,13 @@ namespace Core::Network::Packets
OutOfRangeEventHandler = 0x014E, // updated 4.4
EnterTeriEventHandler = 0x014F, // updated 4.4
ShopEventHandler = 0x0151, // updated 4.4
ReturnEventHandler = 0x0154, // updated 4.4
TradeReturnEventHandler = 0x0155, // updated 4.4
LinkshellEventHandler = 0x0150, // updated 4.1 ??
LinkshellEventHandler1 = 0x0151, // updated 4.1 ??
LinkshellEventHandler = 0x1150, // updated 4.1 ??
LinkshellEventHandler1 = 0x1151, // updated 4.1 ??
LandRenameHandler = 0x0171, // updated 4.4

View file

@ -163,6 +163,13 @@ struct FFXIVIpcChatHandler :
/* 001A */ char message[1012];
};
struct FFXIVIpcShopEventHandler :
FFXIVIpcBasePacket< ShopEventHandler >
{
/* 0000 */ uint32_t eventId;
/* 0004 */ uint32_t param;
};
struct FFXIVIpcLinkshellEventHandler :
FFXIVIpcBasePacket< LinkshellEventHandler >
{

View file

@ -1738,6 +1738,15 @@ struct FFXIVIpcHousingWardInfo : FFXIVIpcBasePacket< HousingWardInfo >
} houseInfoEntry[60];
};
struct FFXIVIpcHousingEstateGreeting : FFXIVIpcBasePacket< HousingEstateGreeting >
{
uint8_t plotId;
uint8_t pad[3]; // unsure
uint16_t territoryTypeId;
uint16_t unk;
char message[200];
};
/**
* Structural representation of the packet sent by the server
* to show the current shared estate settings

View file

@ -2,10 +2,8 @@
#include <Actor/Player.h>
#include <Exd/ExdDataGenerated.h>
#include <Zone/TerritoryMgr.h>
#include <Zone/HousingMgr.h>
#include <Zone/ZonePosition.h>
#include <Framework.h>
#include <Manager/PlayerMgr.h>
using namespace Core;
@ -29,37 +27,13 @@ public:
player.eventFinish( 1310721, 0 );
player.eventFinish( getId(), 1 );
// todo: this is shit, move to housingmgr? handle moving players in and out of it there?
auto exdData = getFramework()->get< Core::Data::ExdDataGenerated >();
auto warp = exdData->get< Core::Data::Warp >( getId() );
if( !warp )
return;
auto level = exdData->get< Core::Data::Level >( warp->level );
if( !level )
{
// fetch from cache
auto teriMgr = getFramework()->get< Core::TerritoryMgr >();
auto pos = teriMgr->getTerritoryPosition( warp->level );
if( !pos )
return;
// lookup instance
auto housingMgr = getFramework()->get< Core::HousingMgr >();
auto landSetId = housingMgr->toLandSetId( 341, result.param3 );
auto hZone = housingMgr->getHousingZoneByLandSetId( landSetId );
if( !hZone )
return;
player.setPos( pos->getTargetPosition() );
player.setRot( pos->getTargetRotation() );
player.setInstance( hZone );
}
auto playerMgr = getFramework()->get< Sapphire::World::Manager::PlayerMgr >();
playerMgr->movePlayerToLandDestination( player, warp->level, result.param3 );
}
else
{

View file

@ -0,0 +1,42 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Framework.h>
#include <Exd/ExdDataGenerated.h>
#include <Zone/Zone.h>
using namespace Core;
class HousingAethernet :
public Sapphire::ScriptAPI::EventScript
{
public:
HousingAethernet() :
Sapphire::ScriptAPI::EventScript( 0x001E0000 )
{
}
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
player.playScene( eventId, 0, HIDE_HOTBAR | NO_DEFAULT_CAMERA, [this, eventId]( Entity::Player& player, const Event::SceneResult& result )
{
auto pExdData = getFramework()->get< Core::Data::ExdDataGenerated >();
if( !pExdData )
return;
auto housingAethernetIds = pExdData->getHousingAethernetIdList();
auto terrritoryTypeId = player.getCurrentZone()->getTerritoryTypeId();
// param2 is the index starting from 0 inside housingaethernet.exd, but the ID column starts at 0x001E0000........ wtf
auto pHousingAethernet = pExdData->get< Core::Data::HousingAethernet >( getId() + result.param2 );
if( !pHousingAethernet )
return;
// check we're teleporting to the same territorytype
if( player.getCurrentZone()->getTerritoryTypeId() != pHousingAethernet->territoryType )
return;
player.sendDebug( "got level entry: " + std::to_string( pHousingAethernet->level ) );
} );
}
};

View file

@ -18,7 +18,7 @@
#include "Player.h"
#include "BNpc.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Session.h"
#include "Zone/TerritoryMgr.h"
@ -301,7 +301,7 @@ Send a packet to all players in range, potentially to self if set and is player
*/
void Core::Entity::Actor::sendToInRangeSet( Network::Packets::FFXIVPacketBasePtr pPacket, bool bToSelf )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
if( bToSelf && isPlayer() )
{
auto pPlayer = getAsPlayer();

View file

@ -20,7 +20,7 @@
#include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Session.h"
#include "Math/CalcBattle.h"
#include "Chara.h"

View file

@ -20,7 +20,7 @@
#include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Session.h"
#include "Math/CalcBattle.h"
#include "Chara.h"

View file

@ -20,7 +20,7 @@
#include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Session.h"
#include "Math/CalcBattle.h"
#include "Chara.h"

View file

@ -40,7 +40,7 @@
#include "Math/CalcStats.h"
#include "Math/CalcBattle.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"
extern Core::Framework g_fw;
@ -108,7 +108,7 @@ Core::Entity::Player::~Player()
void Core::Entity::Player::injectPacket( const std::string& path )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
auto session = pServerZone->getSession( getId() );
if( session )
session->getZoneConnection()->injectPacket( path, *this );
@ -1191,7 +1191,7 @@ const uint8_t* Core::Entity::Player::getGcRankArray() const
void Core::Entity::Player::queuePacket( Network::Packets::FFXIVPacketBasePtr pPacket )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
auto pSession = pServerZone->getSession( m_id );
if( !pSession )
@ -1206,7 +1206,7 @@ void Core::Entity::Player::queuePacket( Network::Packets::FFXIVPacketBasePtr pPa
void Core::Entity::Player::queueChatPacket( Network::Packets::FFXIVPacketBasePtr pPacket )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
auto pSession = pServerZone->getSession( m_id );
if( !pSession )

View file

@ -16,7 +16,7 @@
#include "Action/EventItemAction.h"
#include "Zone/Zone.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"
extern Core::Framework g_fw;
@ -158,23 +158,18 @@ void Core::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags,
Core::Event::EventHandlerPtr Core::Entity::Player::bootstrapSceneEvent( uint32_t eventId, uint32_t flags )
{
if( flags & 0x02 )
setStateFlag( PlayerStateFlag::WatchingCutscene );
auto pEvent = getEvent( eventId );
if( !pEvent && getEventCount() )
{
// We're trying to play a nested event, need to start it first.
//eventStart( getId(), eventId, Event::EventHandler::Nest, 0, 0 );
//pEvent = getEvent( eventId );
}
else if( !pEvent )
if( !pEvent )
{
auto pLog = g_fw.get< Logger >();
pLog->error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
return nullptr;
}
if( flags & 0x02 )
setStateFlag( PlayerStateFlag::WatchingCutscene );
return pEvent;
}
@ -266,21 +261,6 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
if( callback )
callback( *this, pEvent->getActorId() );
auto events = eventList();
/*for( auto it : events )
{
if( it.second->hasPlayedScene() == false )
{
// TODO: not happy with this, this is also prone to break wit more than one remaining event in there
queuePacket( std::make_shared< EventFinishPacket >( getId(), it.second->getId(),
it.second->getEventType(),
it.second->getEventParam() ) );
removeEvent( it.second->getId() );
}
}*/
break;
}
default:

View file

@ -18,7 +18,7 @@
#include "Inventory/ItemContainer.h"
#include "Inventory/ItemUtil.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"
extern Core::Framework g_fw;

View file

@ -12,6 +12,7 @@ file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Event/*.c*
Inventory/*.c*
Linkshell/*.c*
Manager/*.c*
Math/*.c*
Network/*.c*
Network/Handlers/*.c*

View file

@ -32,7 +32,7 @@
#include "Zone/TerritoryMgr.h"
#include "Event/EventDefs.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Session.h"
#include "Framework.h"
@ -422,7 +422,7 @@ void Core::DebugCommandHandler::add( char* data, Entity::Player& player, std::sh
}
else if( subCommand == "bnpc" )
{
auto serverZone = g_fw.get< ServerZone >();
auto serverZone = g_fw.get< ServerMgr >();
auto bNpcTemplate = serverZone->getBNpcTemplate( params );
@ -557,7 +557,7 @@ void Core::DebugCommandHandler::get( char* data, Entity::Player& player, std::sh
void
Core::DebugCommandHandler::injectPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
auto pSession = pServerZone->getSession( player.getId() );
if( pSession )
pSession->getZoneConnection()->injectPacket( data + 7, player );
@ -566,7 +566,7 @@ Core::DebugCommandHandler::injectPacket( char* data, Entity::Player& player, std
void Core::DebugCommandHandler::injectChatPacket( char* data, Entity::Player& player,
std::shared_ptr< DebugCommand > command )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
auto pSession = pServerZone->getSession( player.getId() );
if( pSession )
pSession->getChatConnection()->injectPacket( data + 8, player );
@ -575,7 +575,7 @@ void Core::DebugCommandHandler::injectChatPacket( char* data, Entity::Player& pl
void Core::DebugCommandHandler::replay( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command )
{
auto pLog = g_fw.get< Logger >();
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
std::string subCommand;
std::string params = "";
@ -673,7 +673,7 @@ void Core::DebugCommandHandler::nudge( char* data, Entity::Player& player, std::
void
Core::DebugCommandHandler::serverInfo( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command )
{
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
player.sendDebug( "SapphireZone " + Version::VERSION + "\nRev: " + Version::GIT_HASH );
player.sendDebug( "Compiled: " __DATE__ " " __TIME__ );
player.sendDebug( "Sessions: " + std::to_string( pServerZone->getSessionCount() ) );

View file

@ -69,6 +69,7 @@ namespace Core::Event
Story = 0x001A,
SpecialShop = 0x001B,
BahamutGuide = 0x001C,
HousingAethernet = 0x001E,
FcTalk = 0x001F,
ICDirector = 0x8003,
};

View file

@ -74,14 +74,19 @@ std::string Core::Event::getEventName( uint32_t eventId )
return "WarpTaxi";
return unknown + "ChocoboWarp"; //who know
}
case Event::EventHandler::EventHandlerType::Shop:
{
auto shopInfo = pExdData->get< Core::Data::GilShop >( eventId );
if( shopInfo )
return "GilShop" + std::to_string( eventId );
/*if( shopInfo )
{
if( shopInfo->name.empty() || shopInfo->name == " " )
return "GilShop" + std::to_string( eventId );
return shopInfo->name;
return unknown + "GilShop";
}*/
//return unknown + "GilShop";
}
default:
{

View file

@ -0,0 +1,66 @@
#include "PlayerMgr.h"
#include <Framework.h>
#include <Exd/ExdDataGenerated.h>
#include <Zone/TerritoryMgr.h>
#include <Zone/ZonePosition.h>
#include <Zone/HousingMgr.h>
#include <Actor/Player.h>
extern Core::Framework g_fw;
void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Core::Entity::Player& player, uint32_t landId, uint16_t param )
{
// check if we have one in the db first
auto terriMgr = g_fw.get< Core::TerritoryMgr >();
if( !terriMgr )
return;
Core::ZonePtr destinationZone;
auto terriPos = terriMgr->getTerritoryPosition( landId );
if( terriPos )
{
// check if its a housing zone, zoning is different here
if( terriMgr->isHousingTerritory( terriPos->getTargetZoneId() ) )
{
auto housingMgr = g_fw.get< Core::HousingMgr >();
auto landSetId = housingMgr->toLandSetId( terriPos->getTargetZoneId(), param );
auto housingZone = housingMgr->getHousingZoneByLandSetId( landSetId );
if( !housingZone )
return;
destinationZone = housingZone;
}
else if( terriMgr->isInstanceContentTerritory( terriPos->getTargetZoneId() ) )
{
// todo: instance dungeon handling
// will need to use setInstance so old pos gets set
return;
}
else
{
// normal zones
destinationZone = terriMgr->getZoneByTerritoryTypeId( terriPos->getTargetZoneId() );
}
}
else
{
// todo: lookup land.exd and see if it's in there if its not in our db
return;
}
if( !destinationZone )
return;
player.setPos( terriPos->getTargetPosition() );
player.setRot( terriPos->getTargetRotation() );
if( terriMgr->movePlayer( destinationZone, player.getAsPlayer() ) )
player.sendZonePackets();
}

View file

@ -0,0 +1,10 @@
#include "ForwardsZone.h"
namespace Sapphire::World::Manager
{
class PlayerMgr
{
public:
void movePlayerToLandDestination( Core::Entity::Player& player, uint32_t landId, uint16_t param = 0 );
};
}

View file

@ -15,7 +15,7 @@
#include "DebugCommand/DebugCommandHandler.h"
#include "GameConnection.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Session.h"
#include "Framework.h"
#include "Forwards.h"
@ -83,7 +83,7 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::InventoryModifyHandler, "InventoryModifyHandler",
&GameConnection::inventoryModifyHandler );
setZoneHandler( ClientZoneIpcType::BuildPresetHandler, "BuildPresetHandler", &GameConnection::eventHandlerTalk );
setZoneHandler( ClientZoneIpcType::BuildPresetHandler, "BuildPresetHandler", &GameConnection::buildPresetHandler );
setZoneHandler( ClientZoneIpcType::LandRenameHandler, "LandRenameHandler", &GameConnection::landRenameHandler );
setZoneHandler( ClientZoneIpcType::TalkEventHandler, "EventHandlerTalk", &GameConnection::eventHandlerTalk );
setZoneHandler( ClientZoneIpcType::EmoteEventHandler, "EventHandlerEmote", &GameConnection::eventHandlerEmote );
@ -98,8 +98,12 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::TradeReturnEventHandler, "EventHandlerReturn",
&GameConnection::eventHandlerReturn );
setZoneHandler( ClientZoneIpcType::ShopEventHandler, "ShopEventHandler",
&GameConnection::eventHandlerShop );
setZoneHandler( ClientZoneIpcType::LinkshellEventHandler, "LinkshellEventHandler",
&GameConnection::eventHandlerLinkshell );
setZoneHandler( ClientZoneIpcType::LinkshellEventHandler1, "LinkshellEventHandler1",
&GameConnection::eventHandlerLinkshell );
@ -385,7 +389,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
const std::vector< Core::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
{
auto pLog = g_fw.get< Logger >();
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
// if a session is set, update the last time it recieved a game packet
if( m_pSession )
m_pSession->updateLastDataTime();

View file

@ -139,6 +139,8 @@ namespace Core::Network
DECLARE_HANDLER( eventHandlerReturn );
DECLARE_HANDLER( eventHandlerShop );
DECLARE_HANDLER( eventHandlerLinkshell );
DECLARE_HANDLER( logoutHandler );
@ -150,8 +152,7 @@ namespace Core::Network
DECLARE_HANDLER( cfRegisterRoulette );
DECLARE_HANDLER( cfDutyAccepted );
DECLARE_HANDLER( actionHandler );
DECLARE_HANDLER( gm1Handler );

View file

@ -33,7 +33,7 @@
#include "Session.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Forwards.h"
#include "Framework.h"
#include <Network/PacketDef/Lobby/ServerLobbyDef.h>
@ -49,7 +49,7 @@ void examineHandler( Core::Entity::Player& player, uint32_t targetId )
{
using namespace Core;
auto pSession = g_fw.get< Core::ServerZone >()->getSession( targetId );
auto pSession = g_fw.get< Core::ServerMgr >()->getSession( targetId );
if( pSession )
{
auto pTarget = pSession->getPlayer();

View file

@ -1,4 +1,5 @@
#include <Common.h>
#include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h>
#include <Network/CommonNetwork.h>
#include <Network/GamePacketNew.h>
@ -251,4 +252,29 @@ void Core::Network::GameConnection::eventHandlerLinkshell( const Packets::FFXIVA
}
void Core::Network::GameConnection::eventHandlerShop( const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player )
{
const auto packet = ZoneChannelPacket< Client::FFXIVIpcShopEventHandler >( inPacket );
auto pLog = g_fw.get< Logger >();
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
const auto eventId = packet.data().eventId;
auto eventType = static_cast< uint16_t >( eventId >> 16 );
std::string eventName = "onOpen";
std::string objName = Event::getEventName( eventId );
player.sendDebug( "EventId: " +
std::to_string( eventId ) +
" (0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + ")" );
player.sendDebug( "Calling: " + objName + "." + eventName );
player.eventStart( 0, eventId, Event::EventHandler::UI, 0, packet.data().param );
}

View file

@ -29,7 +29,7 @@
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"
extern Core::Framework g_fw;
@ -551,7 +551,7 @@ void Core::Network::GameConnection::gm2Handler( const Packets::FFXIVARR_PACKET_R
return;
auto pLog = g_fw.get< Logger >();
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand2 >( inPacket );

View file

@ -15,7 +15,7 @@
#include "Actor/Player.h"
#include "Session.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"

View file

@ -41,7 +41,7 @@
#include "Action/ActionTeleport.h"
#include "Session.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Forwards.h"
#include "Framework.h"
@ -111,7 +111,7 @@ void Core::Network::GameConnection::reqExamineSearchCommentHandler( const Core::
{
auto targetId = *reinterpret_cast< const uint32_t* >( &inPacket.data[ 0x10 ] );
auto pSession = g_fw.get< Core::ServerZone >()->getSession( targetId );
auto pSession = g_fw.get< Core::ServerMgr >()->getSession( targetId );
g_fw.get< Core::Logger >()->debug( std::to_string( targetId ) );
@ -138,7 +138,7 @@ void Core::Network::GameConnection::reqExamineFcInfo( const Core::Network::Packe
{
auto targetId = *reinterpret_cast< const uint32_t* >( &inPacket.data[ 0x18 ] );
auto pSession = g_fw.get< Core::ServerZone >()->getSession( targetId );
auto pSession = g_fw.get< Core::ServerMgr >()->getSession( targetId );
g_fw.get< Core::Logger >()->debug( std::to_string( targetId ) );
@ -598,7 +598,7 @@ void Core::Network::GameConnection::tellHandler( const Core::Network::Packets::F
{
const auto packet = ZoneChannelPacket< Client::FFXIVIpcTellHandler >( inPacket );
auto pZoneServer = g_fw.get< ServerZone >();
auto pZoneServer = g_fw.get< ServerMgr >();
auto pSession = pZoneServer->getSession( packet.data().targetPCName );

View file

@ -3,7 +3,7 @@
#include <Logging/Logger.h>
#include <Config/ConfigMgr.h>
#include <Util/Util.h>
#include "ServerZone.h"
#include "ServerMgr.h"
#include <experimental/filesystem>

View file

@ -7,7 +7,7 @@
#include "Zone/Zone.h"
#include "Zone/InstanceContent.h"
#include "Actor/Player.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Event/EventHandler.h"
#include "Event/EventHelper.h"
@ -18,7 +18,7 @@
#include "Script/ScriptMgr.h"
#include "NativeScriptMgr.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"
// enable the ambiguity fix for every platform to avoid #define nonsense
@ -168,7 +168,7 @@ void Core::Scripting::ScriptMgr::onPlayerFirstEnterWorld( Entity::Player& player
bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId & 0xFFFF0000 );
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
if( script )
{
script->onTalk( eventId, player, actorId );
@ -176,7 +176,7 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI
}
else
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId & 0xFFFF0000 );
if( !script )
return false;
@ -184,7 +184,7 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI
return true;
}
return true;
return false;
}
bool Core::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId,

View file

@ -5,7 +5,7 @@
#include <Network/PacketContainer.h>
#include "Network/GameConnection.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "Framework.h"
#include <Version.h>
@ -28,7 +28,7 @@
extern Core::Framework g_fw;
Core::ServerZone::ServerZone( const std::string& configName ) :
Core::ServerMgr::ServerMgr( const std::string& configName ) :
m_configName( configName ),
m_bRunning( true ),
m_lastDBPingTime( 0 ),
@ -36,16 +36,16 @@ Core::ServerZone::ServerZone( const std::string& configName ) :
{
}
Core::ServerZone::~ServerZone()
Core::ServerMgr::~ServerMgr()
{
}
size_t Core::ServerZone::getSessionCount() const
size_t Core::ServerMgr::getSessionCount() const
{
return m_sessionMapById.size();
}
bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
bool Core::ServerMgr::loadSettings( int32_t argc, char* argv[] )
{
auto pLog = g_fw.get< Core::Logger >();
auto pConfig = g_fw.get< Core::ConfigMgr >();
@ -143,7 +143,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
return true;
}
void Core::ServerZone::run( int32_t argc, char* argv[] )
void Core::ServerMgr::run( int32_t argc, char* argv[] )
{
auto pLog = g_fw.get< Core::Logger >();
auto pScript = g_fw.get< Scripting::ScriptMgr >();
@ -189,17 +189,17 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
}
uint16_t Core::ServerZone::getWorldId() const
uint16_t Core::ServerMgr::getWorldId() const
{
return m_worldId;
}
void Core::ServerZone::setWorldId( uint16_t worldId )
void Core::ServerMgr::setWorldId( uint16_t worldId )
{
m_worldId = worldId;
}
void Core::ServerZone::printBanner() const
void Core::ServerMgr::printBanner() const
{
auto pLog = g_fw.get< Core::Logger >();
@ -211,7 +211,7 @@ void Core::ServerZone::printBanner() const
pLog->info( "===========================================================" );
}
void Core::ServerZone::mainLoop()
void Core::ServerMgr::mainLoop()
{
auto pLog = g_fw.get< Logger >();
auto pTeriMgr = g_fw.get< TerritoryMgr >();
@ -292,7 +292,7 @@ void Core::ServerZone::mainLoop()
}
}
bool Core::ServerZone::createSession( uint32_t sessionId )
bool Core::ServerMgr::createSession( uint32_t sessionId )
{
auto pLog = g_fw.get< Core::Logger >();
@ -325,12 +325,12 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
}
void Core::ServerZone::removeSession( uint32_t sessionId )
void Core::ServerMgr::removeSession( uint32_t sessionId )
{
m_sessionMapById.erase( sessionId );
}
Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
Core::SessionPtr Core::ServerMgr::getSession( uint32_t id )
{
//std::lock_guard<std::mutex> lock( m_sessionMutex );
@ -342,7 +342,7 @@ Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
return nullptr;
}
Core::SessionPtr Core::ServerZone::getSession( const std::string& playerName )
Core::SessionPtr Core::ServerMgr::getSession( const std::string& playerName )
{
//std::lock_guard<std::mutex> lock( m_sessionMutex );
@ -354,18 +354,18 @@ Core::SessionPtr Core::ServerZone::getSession( const std::string& playerName )
return nullptr;
}
void Core::ServerZone::removeSession( const std::string& playerName )
void Core::ServerMgr::removeSession( const std::string& playerName )
{
m_sessionMapByName.erase( playerName );
}
bool Core::ServerZone::isRunning() const
bool Core::ServerMgr::isRunning() const
{
return m_bRunning;
}
std::string Core::ServerZone::getPlayerNameFromDb( uint32_t playerId )
std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId )
{
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
auto res = pDb->query( "SELECT name FROM charainfo WHERE characterid = " + std::to_string( playerId ) );
@ -376,7 +376,7 @@ std::string Core::ServerZone::getPlayerNameFromDb( uint32_t playerId )
return res->getString( 1 );
}
void Core::ServerZone::loadBNpcTemplates()
void Core::ServerMgr::loadBNpcTemplates()
{
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
auto pTeriMgr = g_fw.get< TerritoryMgr >();
@ -419,7 +419,7 @@ void Core::ServerZone::loadBNpcTemplates()
}
Core::Entity::BNpcTemplatePtr Core::ServerZone::getBNpcTemplate( const std::string& key )
Core::Entity::BNpcTemplatePtr Core::ServerMgr::getBNpcTemplate( const std::string& key )
{
auto it = m_bNpcTemplateMap.find( key );
@ -429,7 +429,7 @@ Core::Entity::BNpcTemplatePtr Core::ServerZone::getBNpcTemplate( const std::stri
return it->second;
}
Core::Entity::BNpcTemplatePtr Core::ServerZone::getBNpcTemplate( uint32_t id )
Core::Entity::BNpcTemplatePtr Core::ServerMgr::getBNpcTemplate( uint32_t id )
{
for( auto entry : m_bNpcTemplateMap )
{

View file

@ -10,12 +10,12 @@
namespace Core {
class ServerZone
class ServerMgr
{
public:
ServerZone( const std::string& configName );
ServerMgr( const std::string& configName );
~ServerZone();
~ServerMgr();
void run( int32_t argc, char* argv[] );

View file

@ -18,7 +18,7 @@
#include "HousingMgr.h"
#include "Land.h"
#include "Framework.h"
#include "ServerZone.h"
#include "ServerMgr.h"
using namespace Core::Common;
using namespace Core::Network;
@ -43,7 +43,6 @@ bool Core::HousingMgr::init()
return true;
}
uint32_t Core::HousingMgr::toLandSetId( uint16_t territoryTypeId, uint8_t wardId ) const
{
return ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardId;
@ -89,7 +88,7 @@ void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t wardId
auto landInfoSignPacket = makeZonePacket< Server::FFXIVIpcLandInfoSign >( player.getId() );
uint32_t playerId = land->getPlayerOwner();
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId );
std::string playerName = g_fw.get< Core::ServerMgr >()->getPlayerNameFromDb( playerId );
//memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 );
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
landInfoSignPacket->data().houseSize = land->getSize();
@ -184,6 +183,25 @@ bool Core::HousingMgr::relinquishLand( Entity::Player& player, uint8_t plot )
auto pLand = pHousing->getLand( plot );
auto plotMaxPrice = pLand->getCurrentPrice();
auto landOwnerId = pLand->getPlayerOwner();
// can't relinquish when you are not the owner
// TODO: actually use permissions here for FC houses
if( landOwnerId != player.getId() )
{
auto msgPkt = makeActorControl143( player.getId(), ActorControl::LogMsg, 3304, 0 );
player.queuePacket( msgPkt );
return false;
}
// unable to relinquish if there is a house built
// TODO: additionally check for yard items
if( pLand->getHouse() )
{
auto msgPkt = makeActorControl143( player.getId(), ActorControl::LogMsg, 3315, 0 );
player.queuePacket( msgPkt );
return false;
}
pLand->setCurrentPrice( pLand->getMaxPrice() );
pLand->setPlayerOwner( 0 );
@ -222,8 +240,13 @@ void Core::HousingMgr::sendWardLandInfo( Entity::Player& player, uint8_t wardId,
auto& entry = wardInfoPacket->data().houseInfoEntry[ i ];
// retail always sends the house price in this packet, even after the house has been sold
// so I guess we do the same
entry.housePrice = land->getCurrentPrice();
if( land->getState() == Common::HouseState::forSale )
continue;
switch( land->getLandType() )
{
case LandType::FreeCompany:
@ -237,7 +260,7 @@ void Core::HousingMgr::sendWardLandInfo( Entity::Player& player, uint8_t wardId,
entry.infoFlags = Common::WardEstateFlags::IsEstateOwned;
auto owner = land->getPlayerOwner();
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( owner );
std::string playerName = g_fw.get< Core::ServerMgr >()->getPlayerNameFromDb( owner );
memcpy( &entry.estateOwnerName, playerName.c_str(), playerName.size() );
break;

View file

@ -410,14 +410,18 @@ bool Core::TerritoryMgr::movePlayer( ZonePtr pZone, Core::Entity::PlayerPtr pPla
if( isHousingTerritory( pZone->getTerritoryTypeId() ) )
{
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pZone );
if( pHousing )
if( pHousing )
pPlayer->setTerritoryId( pHousing->getLandSetId() );
}
}
else if( isInstanceContentTerritory( pZone->getTerritoryTypeId() ) )
{
pPlayer->setTerritoryId( pZone->getGuId() );
}
else
{
pPlayer->setTerritoryId( 0 );
}
// mark character as zoning in progress
pPlayer->setLoadingComplete( false );

View file

@ -31,7 +31,7 @@
#include "Session.h"
#include "ForwardsZone.h"
#include "ServerZone.h"
#include "ServerMgr.h"
#include "CellHandler.h"
#include "Zone.h"
#include "TerritoryMgr.h"
@ -222,7 +222,7 @@ void Core::Zone::pushActor( Entity::ActorPtr pActor )
{
auto pPlayer = pActor->getAsPlayer();
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
auto pSession = pServerZone->getSession( pPlayer->getId() );
if( pSession )
m_sessionSet.insert( pSession );
@ -284,7 +284,7 @@ void Core::Zone::queuePacketForRange( Entity::Player& sourcePlayer, uint32_t ran
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
return;
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
for( auto entry : m_playerMap )
{
auto player = entry.second;
@ -314,7 +314,7 @@ void Core::Zone::queuePacketForZone( Entity::Player& sourcePlayer,
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
return;
auto pServerZone = g_fw.get< ServerZone >();
auto pServerZone = g_fw.get< ServerMgr >();
for( auto entry : m_playerMap )
{
auto player = entry.second;

View file

@ -1,6 +1,6 @@
#include <iostream>
#include "ServerZone.h"
#include "ServerMgr.h"
#include <Framework.h>
#include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h>
@ -11,6 +11,7 @@
#include "Zone/TerritoryMgr.h"
#include "Zone/HousingMgr.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Manager/PlayerMgr.h"
#include <Config/ConfigMgr.h>
@ -20,7 +21,7 @@ using namespace Core;
bool setupFramework()
{
auto pServer = std::make_shared< ServerZone >( "config.ini" );
auto pServer = std::make_shared< ServerMgr >( "config.ini" );
auto pLogger = std::make_shared< Logger >();
auto pExdData = std::make_shared< Data::ExdDataGenerated >();
auto pScript = std::make_shared< Scripting::ScriptMgr >();
@ -30,11 +31,12 @@ bool setupFramework()
auto pTeriMgr = std::make_shared< TerritoryMgr >();
auto pDebugCom = std::make_shared< DebugCommandHandler >();
auto pConfig = std::make_shared< ConfigMgr >();
auto pPlayerMgr = std::make_shared< Sapphire::World::Manager::PlayerMgr >();
pLogger->setLogPath( "log/SapphireZone" );
pLogger->init();
g_fw.set< ServerZone >( pServer );
g_fw.set< ServerMgr >( pServer );
g_fw.set< Logger >( pLogger );
g_fw.set< Data::ExdDataGenerated >( pExdData );
g_fw.set< Scripting::ScriptMgr >( pScript );
@ -44,6 +46,7 @@ bool setupFramework()
g_fw.set< TerritoryMgr >( pTeriMgr );
g_fw.set< DebugCommandHandler >( pDebugCom );
g_fw.set< ConfigMgr >( pConfig );
g_fw.set< Sapphire::World::Manager::PlayerMgr >( pPlayerMgr );
// actuall catch errors here...
return true;
@ -54,6 +57,6 @@ int main( int32_t argc, char* argv[] )
if( !setupFramework() )
return 0; // too fucking bad...
g_fw.get< ServerZone >()->run( argc, argv );
g_fw.get< ServerMgr >()->run( argc, argv );
return 0;
}

View file

@ -127,7 +127,7 @@ int main()
result += generateEnum( "Tribe", 0, "uint8_t" );
result += generateEnum( "Town", 0, "uint8_t" );
result += generateEnum( "Weather", 1, "uint8_t" );
result += generateEnum( "HosuingAppeal", 0, "uint8_t" );
result += generateEnum( "HousingAppeal", 0, "uint8_t" );
result += "}\n";
result += "}\n#endif\n";
g_log.info( result );