mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
More fw related cleanup
This commit is contained in:
parent
f52588cdb2
commit
101f284003
17 changed files with 78 additions and 95 deletions
|
@ -32,8 +32,6 @@
|
|||
#include "Forwards.h"
|
||||
#include "SapphireAPI.h"
|
||||
|
||||
|
||||
Sapphire::Framework g_fw;
|
||||
Sapphire::Db::DbWorkerPool< Sapphire::Db::ZoneDbConnection > g_charaDb;
|
||||
Sapphire::Data::ExdDataGenerated g_exdDataGen;
|
||||
Sapphire::Network::SapphireAPI g_sapphireAPI;
|
||||
|
|
|
@ -25,7 +25,7 @@ Sapphire::Action::EventAction::EventAction()
|
|||
}
|
||||
|
||||
Sapphire::Action::EventAction::EventAction( Entity::CharaPtr pActor, uint32_t eventId, uint16_t action,
|
||||
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional )
|
||||
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
|
||||
|
|
|
@ -28,11 +28,8 @@
|
|||
#include "BNpc.h"
|
||||
#include "BNpcTemplate.h"
|
||||
#include "Manager/TerritoryMgr.h"
|
||||
#include "Framework.h"
|
||||
#include "Common.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
|
|
|
@ -18,10 +18,6 @@ using namespace Sapphire::Network::Packets;
|
|||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
Sapphire::Entity::EventObject::EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId,
|
||||
uint8_t initialState, Common::FFXIVARR_POSITION3 pos,
|
||||
float rotation, const std::string& givenName ) :
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include "Framework.h"
|
||||
#include "Common.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "Inventory/Item.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/ItemUtil.h"
|
||||
|
||||
|
||||
#include "Player.h"
|
||||
#include "Framework.h"
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Manager/InventoryMgr.h"
|
||||
#include "Manager/ItemMgr.h"
|
||||
|
||||
#include "Framework.h"
|
||||
#include <Network/CommonActorControl.h>
|
||||
|
@ -510,7 +511,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_
|
|||
// add the related armoury bag to the applicable bags and try and fill a free slot there before falling back to regular inventory
|
||||
if( itemInfo->isEquippable && getEquipDisplayFlags() & StoreNewItemsInArmouryChest )
|
||||
{
|
||||
auto bag = Items::Util::getCharaEquipSlotCategoryToArmoryId( itemInfo->equipSlotCategory );
|
||||
auto bag = World::Manager::ItemMgr::getCharaEquipSlotCategoryToArmoryId( itemInfo->equipSlotCategory );
|
||||
|
||||
bags.insert( bags.begin(), bag );
|
||||
}
|
||||
|
@ -622,7 +623,7 @@ Sapphire::Entity::Player::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId
|
|||
|
||||
bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem )
|
||||
{
|
||||
auto containerType = Items::Util::getContainerType( storageId );
|
||||
auto containerType = World::Manager::ItemMgr::getContainerType( storageId );
|
||||
|
||||
m_storageMap[ storageId ]->setItem( slotId, pItem );
|
||||
|
||||
|
@ -733,17 +734,17 @@ void Sapphire::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromS
|
|||
|
||||
// An item is being moved from bag0-3 to equippment, meaning
|
||||
// the swapped out item will be placed in the matching armory.
|
||||
if( Items::Util::isEquipment( toInventoryId )
|
||||
&& !Items::Util::isEquipment( fromInventoryId )
|
||||
&& !Items::Util::isArmory( fromInventoryId ) )
|
||||
if( World::Manager::ItemMgr::isEquipment( toInventoryId )
|
||||
&& !World::Manager::ItemMgr::isEquipment( fromInventoryId )
|
||||
&& !World::Manager::ItemMgr::isArmory( fromInventoryId ) )
|
||||
{
|
||||
updateContainer( fromInventoryId, fromSlotId, nullptr );
|
||||
fromInventoryId = Items::Util::getCharaEquipSlotCategoryToArmoryId( toSlot );
|
||||
fromInventoryId = World::Manager::ItemMgr::getCharaEquipSlotCategoryToArmoryId( toSlot );
|
||||
fromSlotId = static_cast < uint8_t >( m_storageMap[ fromInventoryId ]->getFreeSlot() );
|
||||
}
|
||||
|
||||
auto containerTypeFrom = Items::Util::getContainerType( fromInventoryId );
|
||||
auto containerTypeTo = Items::Util::getContainerType( toInventoryId );
|
||||
auto containerTypeFrom = World::Manager::ItemMgr::getContainerType( fromInventoryId );
|
||||
auto containerTypeTo = World::Manager::ItemMgr::getContainerType( toInventoryId );
|
||||
|
||||
updateContainer( toInventoryId, toSlot, fromItem );
|
||||
updateContainer( fromInventoryId, fromSlotId, toItem );
|
||||
|
@ -805,7 +806,7 @@ uint16_t Sapphire::Entity::Player::calculateEquippedGearItemLevel()
|
|||
iLvlResult += currItem->getItemLevel();
|
||||
|
||||
// If item is weapon and isn't one-handed
|
||||
if( currItem->isWeapon() && !Items::Util::isOneHandedWeapon( currItem->getCategory() ) )
|
||||
if( currItem->isWeapon() && !World::Manager::ItemMgr::isOneHandedWeapon( currItem->getCategory() ) )
|
||||
{
|
||||
iLvlResult += currItem->getItemLevel();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "Territory/Zone.h"
|
||||
#include "Inventory/Item.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/ItemUtil.h"
|
||||
#include "Manager/ItemMgr.h"
|
||||
|
||||
#include "ServerMgr.h"
|
||||
#include "Framework.h"
|
||||
|
@ -570,6 +570,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::createItem( uint32_t catalogId, uint
|
|||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto itemInfo = pExdData->get< Sapphire::Data::Item >( catalogId );
|
||||
auto itemMgr = g_fw.get< World::Manager::ItemMgr >();
|
||||
|
||||
if( !itemInfo )
|
||||
return nullptr;
|
||||
|
@ -579,7 +580,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::createItem( uint32_t catalogId, uint
|
|||
|
||||
uint8_t flags = 0;
|
||||
|
||||
ItemPtr pItem = make_Item( Items::Util::getNextUId(),
|
||||
ItemPtr pItem = make_Item( itemMgr->getNextUId(),
|
||||
catalogId,
|
||||
itemInfo->modelMain,
|
||||
itemInfo->modelSub );
|
||||
|
@ -598,6 +599,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::createItem( uint32_t catalogId, uint
|
|||
|
||||
bool Sapphire::Entity::Player::loadInventory()
|
||||
{
|
||||
auto itemMgr = g_fw.get< World::Manager::ItemMgr >();
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// load active gearset
|
||||
|
@ -619,7 +621,7 @@ bool Sapphire::Entity::Player::loadInventory()
|
|||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
ItemPtr pItem = Items::Util::loadItem( uItemId );
|
||||
ItemPtr pItem = itemMgr->loadItem( uItemId );
|
||||
|
||||
if( pItem == nullptr )
|
||||
continue;
|
||||
|
@ -652,7 +654,7 @@ bool Sapphire::Entity::Player::loadInventory()
|
|||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
ItemPtr pItem = Items::Util::loadItem( uItemId );
|
||||
ItemPtr pItem = itemMgr->loadItem( uItemId );
|
||||
|
||||
if( pItem == nullptr )
|
||||
continue;
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef SAPPHIRE_ITEMUTIL_H
|
||||
#define SAPPHIRE_ITEMUTIL_H
|
||||
|
||||
#include <Common.h>
|
||||
#include "ForwardsZone.h"
|
||||
|
||||
namespace Sapphire::Items::Util
|
||||
{
|
||||
|
||||
ItemPtr loadItem( uint64_t uId );
|
||||
|
||||
/*! check if weapon category qualifies the weapon as onehanded */
|
||||
bool isOneHandedWeapon( Common::ItemUICategory weaponCategory );
|
||||
|
||||
bool isArmory( uint16_t containerId );
|
||||
|
||||
bool isEquipment( uint16_t containerId );
|
||||
|
||||
uint16_t getCharaEquipSlotCategoryToArmoryId( uint8_t slotId );
|
||||
|
||||
Common::ContainerType getContainerType( uint32_t containerId );
|
||||
|
||||
uint32_t getNextUId();
|
||||
|
||||
}
|
||||
|
||||
#endif //SAPPHIRE_ITEMMGR_H
|
|
@ -1,7 +1,7 @@
|
|||
#include "ItemUtil.h"
|
||||
#include "ItemMgr.h"
|
||||
|
||||
#include "ItemContainer.h"
|
||||
#include "Item.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/Item.h"
|
||||
#include "Framework.h"
|
||||
#include <Network/CommonActorControl.h>
|
||||
|
||||
|
@ -12,7 +12,13 @@
|
|||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
bool Sapphire::Items::Util::isArmory( uint16_t containerId )
|
||||
Sapphire::World::Manager::ItemMgr::ItemMgr( Sapphire::FrameworkPtr pFw ) :
|
||||
BaseManager( pFw )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Sapphire::World::Manager::ItemMgr::isArmory( uint16_t containerId )
|
||||
{
|
||||
return
|
||||
containerId == Common::ArmoryBody ||
|
||||
|
@ -29,7 +35,8 @@ bool Sapphire::Items::Util::isArmory( uint16_t containerId )
|
|||
containerId == Common::ArmorySoulCrystal;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Items::Util::getCharaEquipSlotCategoryToArmoryId( uint8_t slotId )
|
||||
|
||||
uint16_t Sapphire::World::Manager::ItemMgr::getCharaEquipSlotCategoryToArmoryId( uint8_t slotId )
|
||||
{
|
||||
|
||||
switch( slotId )
|
||||
|
@ -87,13 +94,12 @@ uint16_t Sapphire::Items::Util::getCharaEquipSlotCategoryToArmoryId( uint8_t slo
|
|||
}
|
||||
|
||||
|
||||
bool Sapphire::Items::Util::isEquipment( uint16_t containerId )
|
||||
bool Sapphire::World::Manager::ItemMgr::isEquipment( uint16_t containerId )
|
||||
{
|
||||
return containerId == Common::GearSet0;
|
||||
}
|
||||
|
||||
|
||||
bool Sapphire::Items::Util::isOneHandedWeapon( Common::ItemUICategory weaponCategory )
|
||||
bool Sapphire::World::Manager::ItemMgr::isOneHandedWeapon( Common::ItemUICategory weaponCategory )
|
||||
{
|
||||
switch( weaponCategory )
|
||||
{
|
||||
|
@ -117,7 +123,7 @@ bool Sapphire::Items::Util::isOneHandedWeapon( Common::ItemUICategory weaponCate
|
|||
}
|
||||
}
|
||||
|
||||
Sapphire::ItemPtr Sapphire::Items::Util::loadItem( uint64_t uId )
|
||||
Sapphire::ItemPtr Sapphire::World::Manager::ItemMgr::loadItem( uint64_t uId )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
|
@ -148,7 +154,8 @@ Sapphire::ItemPtr Sapphire::Items::Util::loadItem( uint64_t uId )
|
|||
}
|
||||
}
|
||||
|
||||
Sapphire::Common::ContainerType Sapphire::Items::Util::getContainerType( uint32_t containerId )
|
||||
|
||||
Sapphire::Common::ContainerType Sapphire::World::Manager::ItemMgr::getContainerType( uint32_t containerId )
|
||||
{
|
||||
if( containerId < 5 )
|
||||
{
|
||||
|
@ -172,8 +179,7 @@ Sapphire::Common::ContainerType Sapphire::Items::Util::getContainerType( uint32_
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t Sapphire::Items::Util::getNextUId()
|
||||
uint32_t Sapphire::World::Manager::ItemMgr::getNextUId()
|
||||
{
|
||||
uint32_t charId = 0;
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
30
src/world/Manager/ItemMgr.h
Normal file
30
src/world/Manager/ItemMgr.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef SAPPHIRE_ITEMMGR_H
|
||||
#define SAPPHIRE_ITEMMGR_H
|
||||
|
||||
#include <Common.h>
|
||||
#include "ForwardsZone.h"
|
||||
#include "BaseManager.h"
|
||||
|
||||
namespace Sapphire::World::Manager
|
||||
{
|
||||
|
||||
class ItemMgr : public BaseManager
|
||||
{
|
||||
public:
|
||||
ItemMgr( FrameworkPtr pFw );
|
||||
|
||||
ItemPtr loadItem( uint64_t uId );
|
||||
|
||||
uint32_t getNextUId();
|
||||
|
||||
/*! check if weapon category qualifies the weapon as onehanded */
|
||||
static bool isOneHandedWeapon( Common::ItemUICategory weaponCategory );
|
||||
static bool isArmory( uint16_t containerId );
|
||||
static bool isEquipment( uint16_t containerId );
|
||||
static uint16_t getCharaEquipSlotCategoryToArmoryId( uint8_t slotId );
|
||||
static Common::ContainerType getContainerType( uint32_t containerId );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SAPPHIRE_ITEMMGR_H
|
|
@ -20,8 +20,6 @@
|
|||
#include "Framework.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
|
@ -386,7 +384,7 @@ void Sapphire::Network::GameConnection::injectPacket( const std::string& packetp
|
|||
void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||
const std::vector< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
||||
{
|
||||
auto pServerZone = g_fw.get< World::ServerMgr >();
|
||||
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
||||
// if a session is set, update the last time it recieved a game packet
|
||||
if( m_pSession )
|
||||
m_pSession->updateLastDataTime();
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "Manager/ShopMgr.h"
|
||||
#include "Manager/InventoryMgr.h"
|
||||
#include "Manager/EventMgr.h"
|
||||
#include "Manager/ItemMgr.h"
|
||||
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
|
@ -166,12 +167,13 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
|
|||
auto pShopMgr = std::make_shared< Manager::ShopMgr >( framework() );
|
||||
auto pInventoryMgr = std::make_shared< Manager::InventoryMgr >();
|
||||
auto pEventMgr = std::make_shared< Manager::EventMgr >( framework() );
|
||||
auto pItemMgr = std::make_shared< Manager::ItemMgr >( framework() );
|
||||
|
||||
framework()->set< DebugCommandMgr >( pDebugCom );
|
||||
framework()->set< Manager::PlayerMgr >( pPlayerMgr );
|
||||
framework()->set< Manager::ShopMgr >( pShopMgr );
|
||||
framework()->set< Manager::InventoryMgr >( pInventoryMgr );
|
||||
framework()->set< Manager::EventMgr >( pEventMgr );
|
||||
framework()->set< Manager::ItemMgr >( pItemMgr );
|
||||
|
||||
Logger::info( "World server running on " + m_ip + ":" + std::to_string( m_port ) );
|
||||
|
||||
|
|
|
@ -9,10 +9,7 @@
|
|||
#include "Actor/Player.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Framework.h"
|
||||
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
Sapphire::World::Session::Session( uint32_t sessionId ) :
|
||||
|
|
|
@ -20,7 +20,7 @@ using namespace Sapphire::Network::Packets;
|
|||
using namespace Sapphire::Network::Packets::Server;
|
||||
|
||||
Sapphire::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::CharaPtr sourceActor, Entity::CharaPtr targetActor,
|
||||
uint32_t duration, uint32_t tickRate )
|
||||
uint32_t duration, uint32_t tickRate )
|
||||
:
|
||||
m_id( id ), m_sourceActor( sourceActor ), m_targetActor( targetActor ), m_duration( duration ), m_startTime( 0 ),
|
||||
m_tickRate( tickRate ), m_lastTick( 0 )
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
#include "Zone.h"
|
||||
#include <Logging/Logger.h>
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
// TODO: the entire zone / areahandling is a bit outdated ( in parts i used this for the 1.0 iteration )
|
||||
// likely this could be greatly improved or redone
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
#include "Actor/Player.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/Item.h"
|
||||
#include "Inventory/ItemUtil.h"
|
||||
|
||||
#include "Manager/ItemMgr.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "Land.h"
|
||||
|
@ -122,6 +123,7 @@ void Sapphire::Land::loadItemContainerContents()
|
|||
Logger::debug( "Loading housing inventory for ident: " + std::to_string( ident ) );
|
||||
|
||||
auto pDB = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pItemMgr = g_fw.get< World::Manager::ItemMgr >();
|
||||
|
||||
auto stmt = pDB->getPreparedStatement( Db::LAND_INV_SEL_HOUSE );
|
||||
stmt->setUInt64( 1, ident );
|
||||
|
@ -148,7 +150,7 @@ void Sapphire::Land::loadItemContainerContents()
|
|||
// todo: delet this
|
||||
for( auto fuck = it->second.begin(); fuck != it->second.end(); fuck++ )
|
||||
{
|
||||
auto item = Sapphire::Items::Util::loadItem( fuck->second );
|
||||
auto item = pItemMgr->loadItem( fuck->second );
|
||||
if( item )
|
||||
container->setItem( fuck->first, item );
|
||||
}
|
||||
|
|
|
@ -3,27 +3,14 @@
|
|||
#include "ServerMgr.h"
|
||||
#include <Framework.h>
|
||||
|
||||
#include <Config/ConfigMgr.h>
|
||||
|
||||
Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::World;
|
||||
|
||||
bool setupFramework()
|
||||
int main( int32_t argc, char* argv[] )
|
||||
{
|
||||
auto pFramework = Sapphire::make_Framework();
|
||||
auto pServer = std::make_shared< ServerMgr >( "config.ini", pFramework );
|
||||
g_fw.set< ServerMgr >( pServer );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main( int32_t argc, char* argv[] )
|
||||
{
|
||||
if( !setupFramework() )
|
||||
return 0; // too fucking bad...
|
||||
|
||||
g_fw.get< ServerMgr >()->run( argc, argv );
|
||||
pFramework->set< ServerMgr >( pServer );
|
||||
pServer->run( argc, argv );
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue