1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

ServerZone -> ServerMgr

This commit is contained in:
Mordred 2018-11-20 21:32:13 +01:00
parent 017391e899
commit a746bd5e60
20 changed files with 65 additions and 66 deletions

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;

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

@ -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

@ -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"
@ -385,7 +385,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

@ -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

@ -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

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();
@ -256,7 +255,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

@ -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>
@ -20,7 +20,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 >();
@ -34,7 +34,7 @@ bool setupFramework()
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 );
@ -54,6 +54,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;
}