mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 14:07:46 +00:00
Seems like everything works again... here is hoping
This commit is contained in:
parent
199d7a6ec6
commit
c345033aa5
43 changed files with 177 additions and 162 deletions
|
@ -62,6 +62,8 @@ namespace Sapphire::Action
|
|||
|
||||
bool m_bInterrupt;
|
||||
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -22,16 +22,16 @@ using namespace Sapphire::Network::Packets;
|
|||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
Sapphire::Action::ActionCast::ActionCast()
|
||||
{
|
||||
m_handleActionType = Common::HandleActionType::Event;
|
||||
}
|
||||
|
||||
Sapphire::Action::ActionCast::ActionCast( Entity::CharaPtr pActor, Entity::CharaPtr pTarget, uint16_t actionId )
|
||||
Sapphire::Action::ActionCast::ActionCast( Entity::CharaPtr pActor, Entity::CharaPtr pTarget,
|
||||
uint16_t actionId, FrameworkPtr pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
m_pFw = pFw;
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
m_startTime = 0;
|
||||
m_id = actionId;
|
||||
m_handleActionType = HandleActionType::Spell;
|
||||
|
@ -70,7 +70,7 @@ void Sapphire::Action::ActionCast::onFinish()
|
|||
if( !m_pSource )
|
||||
return;
|
||||
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
|
||||
auto pPlayer = m_pSource->getAsPlayer();
|
||||
pPlayer->sendDebug( "onFinish()" );
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Sapphire::Action
|
|||
|
||||
~ActionCast();
|
||||
|
||||
ActionCast( Entity::CharaPtr pActor, Entity::CharaPtr pTarget, uint16_t actionId );
|
||||
ActionCast( Entity::CharaPtr pActor, Entity::CharaPtr pTarget, uint16_t actionId, FrameworkPtr pFw );
|
||||
|
||||
void onStart() override;
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "EventAction.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
@ -25,14 +23,15 @@ 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,
|
||||
FrameworkPtr pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
|
||||
m_additional = additional;
|
||||
m_handleActionType = HandleActionType::Event;
|
||||
m_eventId = eventId;
|
||||
m_id = action;
|
||||
m_pFw = pFw;
|
||||
auto pExdData = pFw->get< Data::ExdDataGenerated >();
|
||||
m_castTime = pExdData->get< Sapphire::Data::EventAction >( action )->castTime * 1000; // TODO: Add security checks.
|
||||
m_onActionFinishClb = finishRef;
|
||||
m_onActionInterruptClb = interruptRef;
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace 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, FrameworkPtr pFw );
|
||||
|
||||
void onStart() override;
|
||||
|
||||
|
|
|
@ -35,11 +35,14 @@ using namespace Sapphire::Network::Packets;
|
|||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
Sapphire::Entity::BNpc::BNpc() : Npc( ObjKind::BattleNpc )
|
||||
Sapphire::Entity::BNpc::BNpc( FrameworkPtr pFw ) :
|
||||
Npc( ObjKind::BattleNpc, pFw )
|
||||
{
|
||||
}
|
||||
|
||||
Sapphire::Entity::BNpc::BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ, uint8_t level ) : Npc( ObjKind::BattleNpc )
|
||||
Sapphire::Entity::BNpc::BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ,
|
||||
uint8_t level, FrameworkPtr pFw ) :
|
||||
Npc( ObjKind::BattleNpc, pFw )
|
||||
{
|
||||
m_modelChara = pTemplate->getModelChara();
|
||||
m_displayFlags = pTemplate->getDisplayFlags();
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace Sapphire::Entity
|
|||
{
|
||||
|
||||
public:
|
||||
BNpc();
|
||||
BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ, uint8_t level );
|
||||
BNpc( FrameworkPtr pFw );
|
||||
BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ, uint8_t level, FrameworkPtr pFw );
|
||||
|
||||
virtual ~BNpc() override;
|
||||
|
||||
|
|
|
@ -29,17 +29,16 @@
|
|||
#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;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
Sapphire::Entity::Chara::Chara( ObjKind type ) :
|
||||
Sapphire::Entity::Chara::Chara( ObjKind type, FrameworkPtr pFw ) :
|
||||
Actor( type ),
|
||||
m_pose( 0 ),
|
||||
m_targetId( INVALID_GAME_OBJECT_ID )
|
||||
m_targetId( INVALID_GAME_OBJECT_ID ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
// initialize the free slot queue
|
||||
for( uint8_t i = 0; i < MAX_STATUS_EFFECTS; i++ )
|
||||
|
@ -430,7 +429,7 @@ ChaiScript Skill Handler.
|
|||
void Sapphire::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1,
|
||||
uint64_t param2, Entity::Chara& target )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
if( isPlayer() )
|
||||
{
|
||||
getAsPlayer()->sendDebug( std::to_string( target.getId() ) );
|
||||
|
@ -510,7 +509,8 @@ void Sapphire::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionI
|
|||
case ActionEffectType::Heal:
|
||||
{
|
||||
uint32_t calculatedHeal = Math::CalcBattle::calculateHealValue( getAsPlayer(),
|
||||
static_cast< uint32_t >( param1 ) );
|
||||
static_cast< uint32_t >( param1 ),
|
||||
m_pFw );
|
||||
|
||||
Server::EffectEntry effectEntry{};
|
||||
effectEntry.value = calculatedHeal;
|
||||
|
@ -594,7 +594,7 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf
|
|||
/*! \param StatusEffectPtr to be applied to the actor */
|
||||
void Sapphire::Entity::Chara::addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param )
|
||||
{
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000 );
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
||||
effect->setParam( param );
|
||||
addStatusEffect( effect );
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ void Sapphire::Entity::Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_
|
|||
if( hasStatusEffect( id ) )
|
||||
return;
|
||||
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000 );
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
||||
effect->setParam( param );
|
||||
addStatusEffect( effect );
|
||||
|
||||
|
|
|
@ -109,9 +109,10 @@ namespace Sapphire::Entity
|
|||
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
|
||||
std::vector< std::pair< uint8_t, uint32_t > > m_statusEffectList;
|
||||
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
public:
|
||||
Chara( Common::ObjKind type );
|
||||
Chara( Common::ObjKind type, FrameworkPtr pFw );
|
||||
|
||||
virtual ~Chara() override;
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ using namespace Sapphire::Network::Packets;
|
|||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
Sapphire::Entity::Npc::Npc( ObjKind type ) :
|
||||
Chara( type )
|
||||
Sapphire::Entity::Npc::Npc( ObjKind type, FrameworkPtr pFw ) :
|
||||
Chara( type, pFw )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Sapphire::Entity
|
|||
{
|
||||
|
||||
public:
|
||||
Npc( Common::ObjKind type );
|
||||
Npc( Common::ObjKind type, FrameworkPtr pFw );
|
||||
|
||||
virtual ~Npc() override;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ using InvSlotPairVec = std::vector< InvSlotPair >;
|
|||
|
||||
// player constructor
|
||||
Sapphire::Entity::Player::Player( FrameworkPtr pFw ) :
|
||||
Chara( ObjKind::Player ),
|
||||
Chara( ObjKind::Player, pFw ),
|
||||
m_lastWrite( 0 ),
|
||||
m_lastPing( 0 ),
|
||||
m_bIsLogin( false ),
|
||||
|
@ -75,8 +75,7 @@ Sapphire::Entity::Player::Player( FrameworkPtr pFw ) :
|
|||
m_mount( 0 ),
|
||||
m_emoteMode( 0 ),
|
||||
m_directorInitialized( false ),
|
||||
m_onEnterEventDone( false ),
|
||||
m_pFw( pFw )
|
||||
m_onEnterEventDone( false )
|
||||
{
|
||||
m_id = 0;
|
||||
m_currentStance = Stance::Passive;
|
||||
|
@ -279,9 +278,9 @@ void Sapphire::Entity::Player::calculateStats()
|
|||
m_baseStats.healingPotMagic = paramGrowthInfo->baseSpeed;
|
||||
m_baseStats.tenacity = paramGrowthInfo->baseSpeed;
|
||||
|
||||
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() );
|
||||
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer(), m_pFw );
|
||||
|
||||
m_baseStats.max_hp = Math::CalcStats::calculateMaxHp( getAsPlayer() );
|
||||
m_baseStats.max_hp = Math::CalcStats::calculateMaxHp( getAsPlayer(), m_pFw );
|
||||
|
||||
if( m_mp > m_baseStats.max_mp )
|
||||
m_mp = m_baseStats.max_mp;
|
||||
|
|
|
@ -1047,9 +1047,6 @@ namespace Sapphire::Entity
|
|||
|
||||
Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator;
|
||||
Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator;
|
||||
|
||||
// todo: temporary store ptr to framework
|
||||
FrameworkPtr m_pFw;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
|||
uint64_t additional )
|
||||
{
|
||||
auto pEventAction = Action::make_EventAction( getAsChara(), eventId, action,
|
||||
finishCallback, interruptCallback, additional );
|
||||
finishCallback, interruptCallback, additional, m_pFw );
|
||||
|
||||
setCurrentAction( pEventAction );
|
||||
auto pEvent = getEvent( eventId );
|
||||
|
|
|
@ -43,7 +43,7 @@ void Sapphire::Entity::Player::initInventory()
|
|||
{
|
||||
auto setupContainer = [ this ]( InventoryType type, uint8_t maxSize, const std::string& tableName,
|
||||
bool isMultiStorage, bool isPersistentStorage = true )
|
||||
{ m_storageMap[ type ] = make_ItemContainer( type, maxSize, tableName, isMultiStorage, isPersistentStorage ); };
|
||||
{ m_storageMap[ type ] = make_ItemContainer( type, maxSize, tableName, isMultiStorage, m_pFw, isPersistentStorage ); };
|
||||
|
||||
// main bags
|
||||
setupContainer( Bag0, 34, "charaiteminventory", true );
|
||||
|
|
|
@ -581,7 +581,8 @@ Sapphire::ItemPtr Sapphire::Entity::Player::createItem( uint32_t catalogId, uint
|
|||
ItemPtr pItem = make_Item( itemMgr->getNextUId(),
|
||||
catalogId,
|
||||
itemInfo->modelMain,
|
||||
itemInfo->modelSub );
|
||||
itemInfo->modelSub,
|
||||
m_pFw );
|
||||
|
||||
pItem->setStackSize( quantity );
|
||||
|
||||
|
|
|
@ -5,18 +5,17 @@
|
|||
#include "Framework.h"
|
||||
#include "Item.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
Sapphire::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq ) :
|
||||
Sapphire::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, FrameworkPtr pFw, bool isHq ) :
|
||||
m_id( catalogId ),
|
||||
m_uId( uId ),
|
||||
m_model1( model1 ),
|
||||
m_model2( model2 ),
|
||||
m_isHq( isHq ),
|
||||
m_stain( 0 ),
|
||||
m_durability( 30000 )
|
||||
m_durability( 30000 ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
auto itemInfo = pExdData->get< Sapphire::Data::Item >( catalogId );
|
||||
|
||||
m_delayMs = itemInfo->delayms;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _ITEM_H_
|
||||
|
||||
#include <Common.h>
|
||||
#include "ForwardsZone.h"
|
||||
|
||||
namespace Sapphire
|
||||
{
|
||||
|
@ -10,7 +11,7 @@ namespace Sapphire
|
|||
{
|
||||
|
||||
public:
|
||||
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq = false );
|
||||
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, FrameworkPtr pFw, bool isHq = false );
|
||||
|
||||
~Item() = default;
|
||||
|
||||
|
@ -88,6 +89,8 @@ namespace Sapphire
|
|||
uint16_t m_durability;
|
||||
uint16_t m_stain;
|
||||
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
#include "Forwards.h"
|
||||
#include "ItemContainer.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName,
|
||||
bool isMultiStorage, bool isPersistentStorage ) :
|
||||
bool isMultiStorage, FrameworkPtr pFw, bool isPersistentStorage ) :
|
||||
m_id( storageId ),
|
||||
m_size( maxSize ),
|
||||
m_tableName( tableName ),
|
||||
m_bMultiStorage( isMultiStorage ),
|
||||
m_pFw( pFw ),
|
||||
m_isPersistentStorage( isPersistentStorage )
|
||||
{
|
||||
|
||||
|
@ -39,7 +38,7 @@ uint16_t Sapphire::ItemContainer::getEntryCount() const
|
|||
|
||||
void Sapphire::ItemContainer::removeItem( uint16_t slotId )
|
||||
{
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
ItemMap::iterator it = m_itemMap.find( slotId );
|
||||
|
||||
if( it != m_itemMap.end() )
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Sapphire
|
|||
|
||||
public:
|
||||
ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName, bool isMultiStorage,
|
||||
bool isPersistentStorage = true );
|
||||
FrameworkPtr pFw, bool isPersistentStorage = true );
|
||||
|
||||
~ItemContainer();
|
||||
|
||||
|
@ -48,6 +48,7 @@ namespace Sapphire
|
|||
uint16_t m_size;
|
||||
std::string m_tableName;
|
||||
bool m_bMultiStorage;
|
||||
FrameworkPtr m_pFw;
|
||||
bool m_isPersistentStorage;
|
||||
ItemMap m_itemMap;
|
||||
Entity::PlayerPtr m_pOwner;
|
||||
|
|
|
@ -408,7 +408,8 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player&
|
|||
|
||||
sscanf( params.c_str(), "%d %d %hu", &id, &duration, ¶m );
|
||||
|
||||
auto effect = StatusEffect::make_StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(), duration, 3000 );
|
||||
auto effect = StatusEffect::make_StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(),
|
||||
duration, 3000, framework() );
|
||||
effect->setParam( param );
|
||||
|
||||
player.addStatusEffect( effect );
|
||||
|
@ -431,9 +432,10 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player&
|
|||
player.sendNotice( "Template " + params + " not found in cache!" );
|
||||
|
||||
auto pBNpc = std::make_shared< Entity::BNpc >( bNpcTemplate,
|
||||
player.getPos().x,
|
||||
player.getPos().y,
|
||||
player.getPos().z, 1 );
|
||||
player.getPos().x,
|
||||
player.getPos().y,
|
||||
player.getPos().z,
|
||||
1, framework() );
|
||||
|
||||
auto playerZone = player.getCurrentZone();
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ Sapphire::ItemPtr Sapphire::World::Manager::ItemMgr::loadItem( uint64_t uId )
|
|||
itemRes->getUInt( 1 ),
|
||||
itemInfo->modelMain,
|
||||
itemInfo->modelSub,
|
||||
framework(),
|
||||
isHq );
|
||||
|
||||
pItem->setStackSize( itemRes->getUInt( 2 ) );
|
||||
|
|
|
@ -160,7 +160,7 @@ bool Sapphire::World::Manager::TerritoryMgr::createDefaultTerritories()
|
|||
"\t" + ( isPrivateTerritory( territoryTypeId ) ? "PRIVATE" : "PUBLIC" ) +
|
||||
"\t" + pPlaceName->name );
|
||||
|
||||
auto pZone = make_Zone( territoryTypeId, guid, territoryInfo->name, pPlaceName->name );
|
||||
auto pZone = make_Zone( territoryTypeId, guid, territoryInfo->name, pPlaceName->name, framework() );
|
||||
pZone->init();
|
||||
|
||||
InstanceIdToZonePtrMap instanceMap;
|
||||
|
@ -204,7 +204,8 @@ bool Sapphire::World::Manager::TerritoryMgr::createHousingTerritories()
|
|||
"\t" + pPlaceName->name +
|
||||
"#" + std::to_string( wardNum ) );
|
||||
|
||||
auto pHousingZone = make_HousingZone( wardNum, territoryTypeId, guid, territoryInfo->name, pPlaceName->name );
|
||||
auto pHousingZone = make_HousingZone( wardNum, territoryTypeId, guid, territoryInfo->name,
|
||||
pPlaceName->name, framework() );
|
||||
pHousingZone->init();
|
||||
wardMaxNum = 18;
|
||||
|
||||
|
@ -239,7 +240,7 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::createTerritoryInstanc
|
|||
Logger::debug(
|
||||
"Starting instance for territory: " + std::to_string( territoryTypeId ) + " (" + pPlaceName->name + ")" );
|
||||
|
||||
auto pZone = make_Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name );
|
||||
auto pZone = make_Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name, framework() );
|
||||
pZone->init();
|
||||
|
||||
m_instanceIdToZonePtrMap[ pZone->getGuId() ] = pZone;
|
||||
|
@ -274,7 +275,7 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::createInstanceContent(
|
|||
" (" + pInstanceContent->name + ")" );
|
||||
|
||||
auto pZone = make_InstanceContent( pInstanceContent, pContentFinderCondition->territoryType, getNextInstanceId(),
|
||||
pTeri->name, pInstanceContent->name, instanceContentId );
|
||||
pTeri->name, pInstanceContent->name, instanceContentId, framework() );
|
||||
pZone->init();
|
||||
|
||||
m_instanceContentToInstanceMap[ instanceContentId ][ pZone->getGuId() ] = pZone;
|
||||
|
@ -344,8 +345,9 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousingInt
|
|||
if( !terriInfo )
|
||||
return nullptr;
|
||||
|
||||
auto zone = World::Territory::Housing::make_HousingInteriorTerritory( landIdent, territoryTypeId, getNextInstanceId(),
|
||||
terriInfo->name, house->getHouseName() );
|
||||
auto zone = World::Territory::Housing::make_HousingInteriorTerritory( landIdent, territoryTypeId,
|
||||
getNextInstanceId(), terriInfo->name,
|
||||
house->getHouseName(), framework() );
|
||||
|
||||
zone->init();
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include "CalcBattle.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Math;
|
||||
using namespace Sapphire::Entity;
|
||||
|
||||
|
@ -31,9 +29,9 @@ using namespace Sapphire::Entity;
|
|||
|
||||
*/
|
||||
|
||||
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
||||
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency, Sapphire::FrameworkPtr pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = pFw->get< Data::ExdDataGenerated >();
|
||||
auto classInfo = pExdData->get< Sapphire::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = pExdData->get< Sapphire::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Sapphire::Math
|
|||
class CalcBattle
|
||||
{
|
||||
public:
|
||||
static uint32_t calculateHealValue( Sapphire::Entity::PlayerPtr pPlayer, uint32_t potency );
|
||||
static uint32_t calculateHealValue( Sapphire::Entity::PlayerPtr pPlayer, uint32_t potency, FrameworkPtr pFw );
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
using namespace Sapphire::Math;
|
||||
using namespace Sapphire::Entity;
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
/*
|
||||
Class used for battle-related formulas and calculations.
|
||||
Big thanks to the Theoryjerks group!
|
||||
|
@ -57,9 +55,9 @@ float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
|
|||
// Leggerless' HP Formula
|
||||
// ROUNDDOWN(JobModHP * (BaseHP / 100)) + ROUNDDOWN(VitHPMod / 100 * (VIT - BaseDET))
|
||||
|
||||
uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
||||
uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer, Sapphire::FrameworkPtr pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = pFw->get< Data::ExdDataGenerated >();
|
||||
// TODO: Replace ApproxBaseHP with something that can get us an accurate BaseHP.
|
||||
// Is there any way to pull reliable BaseHP without having to manually use a pet for every level, and using the values from a table?
|
||||
// More info here: https://docs.google.com/spreadsheets/d/1de06KGT0cNRUvyiXNmjNgcNvzBCCQku7jte5QxEQRbs/edit?usp=sharing
|
||||
|
@ -96,9 +94,9 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
|||
// Leggerless' MP Formula
|
||||
// ROUNDDOWN(((ROUNDDOWN(((PIE - BaseDET) * PieMPMod/100),0) + BaseMP) * JobModMP / 100),0)
|
||||
|
||||
uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer )
|
||||
uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer, Sapphire::FrameworkPtr pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = pFw->get< Data::ExdDataGenerated >();
|
||||
auto classInfo = pExdData->get< Sapphire::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = pExdData->get< Sapphire::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Sapphire::Math
|
|||
public:
|
||||
static float calculateBaseStat( Sapphire::Entity::PlayerPtr pPlayer );
|
||||
|
||||
static uint32_t calculateMaxMp( Sapphire::Entity::PlayerPtr pPlayer );
|
||||
static uint32_t calculateMaxMp( Sapphire::Entity::PlayerPtr pPlayer, FrameworkPtr pFw );
|
||||
|
||||
static uint32_t calculateMaxHp( Sapphire::Entity::PlayerPtr pPlayer );
|
||||
static uint32_t calculateMaxHp( Sapphire::Entity::PlayerPtr pPlayer, FrameworkPtr pFw );
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw,
|
|||
}
|
||||
else
|
||||
{
|
||||
auto pActionCast = Action::make_ActionCast( player.getAsPlayer(), targetActor->getAsChara(), action );
|
||||
auto pActionCast = Action::make_ActionCast( player.getAsPlayer(), targetActor->getAsChara(), action, m_pFw );
|
||||
player.setCurrentAction( pActionCast );
|
||||
player.sendDebug( "setCurrentAction()" );
|
||||
player.getCurrentAction()->onStart();
|
||||
|
|
|
@ -173,6 +173,7 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
|
|||
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 ) );
|
||||
|
|
|
@ -13,19 +13,22 @@
|
|||
#include "StatusEffect.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
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 )
|
||||
:
|
||||
m_id( id ), m_sourceActor( sourceActor ), m_targetActor( targetActor ), m_duration( duration ), m_startTime( 0 ),
|
||||
m_tickRate( tickRate ), m_lastTick( 0 )
|
||||
uint32_t duration, uint32_t tickRate, FrameworkPtr pFw ) :
|
||||
m_id( id ),
|
||||
m_sourceActor( sourceActor ),
|
||||
m_targetActor( targetActor ),
|
||||
m_duration( duration ),
|
||||
m_startTime( 0 ),
|
||||
m_tickRate( tickRate ),
|
||||
m_lastTick( 0 ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
auto entry = pExdData->get< Sapphire::Data::Status >( id );
|
||||
m_name = entry->name;
|
||||
|
||||
|
@ -59,7 +62,7 @@ std::pair< uint8_t, uint32_t > Sapphire::StatusEffect::StatusEffect::getTickEffe
|
|||
|
||||
void Sapphire::StatusEffect::StatusEffect::onTick()
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
m_lastTick = Util::getTimeMs();
|
||||
pScriptMgr->onStatusTick( m_targetActor, *this );
|
||||
}
|
||||
|
@ -82,7 +85,7 @@ uint16_t Sapphire::StatusEffect::StatusEffect::getParam() const
|
|||
void Sapphire::StatusEffect::StatusEffect::applyStatus()
|
||||
{
|
||||
m_startTime = Util::getTimeMs();
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
|
||||
// this is only right when an action is being used by the player
|
||||
// else you probably need to use an actorcontrol
|
||||
|
@ -107,7 +110,7 @@ void Sapphire::StatusEffect::StatusEffect::applyStatus()
|
|||
|
||||
void Sapphire::StatusEffect::StatusEffect::removeStatus()
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onStatusTimeOut( m_targetActor, m_id );
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class StatusEffect
|
|||
{
|
||||
public:
|
||||
StatusEffect( uint32_t id, Entity::CharaPtr sourceActor, Entity::CharaPtr targetActor,
|
||||
uint32_t duration, uint32_t tickRate );
|
||||
uint32_t duration, uint32_t tickRate, FrameworkPtr pFw );
|
||||
|
||||
~StatusEffect();
|
||||
|
||||
|
@ -58,6 +58,7 @@ private:
|
|||
uint16_t m_param;
|
||||
std::string m_name;
|
||||
std::pair< uint8_t, uint32_t > m_currTickEffect;
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
#include <unordered_map>
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
Sapphire::House::House( uint32_t houseId, uint32_t landSetId, Common::LandIdent ident ) :
|
||||
Sapphire::House::House( uint32_t houseId, uint32_t landSetId, Common::LandIdent ident, FrameworkPtr pFw ) :
|
||||
m_houseId( houseId ),
|
||||
m_landSetId( landSetId ),
|
||||
m_landIdent( ident )
|
||||
m_landIdent( ident ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
auto pDB = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pDB = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
|
||||
// todo: convert to prepared statement
|
||||
auto res = pDB->query( "SELECT * FROM house WHERE HouseId = " + std::to_string( houseId ) );
|
||||
|
@ -67,7 +66,7 @@ Sapphire::House::~House()
|
|||
|
||||
void Sapphire::House::updateHouseDb()
|
||||
{
|
||||
auto pDB = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pDB = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
|
||||
// BuildTime = 1, Aetheryte = 2, Comment = 3, HouseName = 4, Endorsements = 5,
|
||||
// HousePartModels = 6, HousePartColours = 7, HouseId = 8
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Sapphire
|
|||
class House
|
||||
{
|
||||
public:
|
||||
House( uint32_t houseId, uint32_t landSetId, Common::LandIdent ident );
|
||||
House( uint32_t houseId, uint32_t landSetId, Common::LandIdent ident, FrameworkPtr pFw );
|
||||
virtual ~House();
|
||||
|
||||
using HousePart = std::pair< uint32_t, uint8_t >;
|
||||
|
@ -53,6 +53,7 @@ namespace Sapphire
|
|||
|
||||
std::string m_estateMessage;
|
||||
std::string m_houseName;
|
||||
FrameworkPtr m_pFw;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "HousingInteriorTerritory.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
|
@ -31,8 +29,9 @@ using namespace Sapphire::World::Territory;
|
|||
Housing::HousingInteriorTerritory::HousingInteriorTerritory( Common::LandIdent ident, uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName ) :
|
||||
Zone( territoryTypeId, guId, internalName, contentName ),
|
||||
const std::string& contentName,
|
||||
FrameworkPtr pFw ) :
|
||||
Zone( territoryTypeId, guId, internalName, contentName, pFw ),
|
||||
m_landIdent( ident )
|
||||
{
|
||||
m_lastActivityTime = static_cast< uint32_t >( Util::getTimeSeconds() );
|
||||
|
@ -50,7 +49,7 @@ bool Housing::HousingInteriorTerritory::init()
|
|||
|
||||
void Housing::HousingInteriorTerritory::onPlayerZoneIn( Entity::Player& player )
|
||||
{
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
auto pHousingMgr = m_pFw->get< HousingMgr >();
|
||||
Logger::debug(
|
||||
"HousingInteriorTerritory::onPlayerZoneIn: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryTypeId() ) +
|
||||
", Entity#" + std::to_string( player.getId() ) );
|
||||
|
|
|
@ -9,7 +9,8 @@ namespace Sapphire::World::Territory::Housing
|
|||
HousingInteriorTerritory( Common::LandIdent ident, uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName );
|
||||
const std::string& contentName,
|
||||
FrameworkPtr pFw );
|
||||
|
||||
virtual ~HousingInteriorTerritory();
|
||||
|
||||
|
|
|
@ -18,22 +18,22 @@
|
|||
#include "Manager/HousingMgr.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;
|
||||
|
||||
Sapphire::HousingZone::HousingZone( uint8_t wardNum,
|
||||
uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName ) :
|
||||
Zone( territoryTypeId, guId, internalName, contentName ),
|
||||
uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName,
|
||||
FrameworkPtr pFw ) :
|
||||
Zone( territoryTypeId, guId, internalName, contentName, pFw ),
|
||||
m_wardNum( wardNum ),
|
||||
m_territoryTypeId( territoryTypeId ),
|
||||
m_landSetId( ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardNum )
|
||||
m_landSetId( ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardNum ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ Sapphire::HousingZone::HousingZone( uint8_t wardNum,
|
|||
bool Sapphire::HousingZone::init()
|
||||
{
|
||||
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
{
|
||||
auto res = pDb->query( "SELECT * FROM landset WHERE landsetid = " + std::to_string( m_landSetId ) );
|
||||
if( !res->next() )
|
||||
|
@ -50,7 +50,6 @@ bool Sapphire::HousingZone::init()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int housingIndex;
|
||||
if( m_territoryTypeId == 339 )
|
||||
housingIndex = 0;
|
||||
|
@ -61,7 +60,7 @@ bool Sapphire::HousingZone::init()
|
|||
else if( m_territoryTypeId == 641 )
|
||||
housingIndex = 3;
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Sapphire::Data::HousingLandSet >( housingIndex );
|
||||
|
||||
auto stmt = pDb->getPreparedStatement( Db::LANDSET_SEL );
|
||||
|
@ -91,7 +90,7 @@ bool Sapphire::HousingZone::init()
|
|||
// spawn land
|
||||
for( auto& init : landInit )
|
||||
{
|
||||
auto land = make_Land( m_territoryTypeId, getWardNum(), init.m_landId, m_landSetId, info );
|
||||
auto land = make_Land( m_territoryTypeId, getWardNum(), init.m_landId, m_landSetId, info, m_pFw );
|
||||
land->init( init.m_type, init.m_size, init.m_status, init.m_currentPrice, init.m_ownerId, init.m_houseId );
|
||||
|
||||
m_landPtrMap[ init.m_landId ] = land;
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace Sapphire
|
|||
uint16_t territoryTypeId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName );
|
||||
const std::string& contentName,
|
||||
FrameworkPtr pFw );
|
||||
|
||||
virtual ~HousingZone();
|
||||
|
||||
|
@ -70,6 +71,7 @@ namespace Sapphire
|
|||
uint8_t m_wardNum;
|
||||
uint32_t m_landSetId;
|
||||
uint32_t m_territoryTypeId;
|
||||
FrameworkPtr m_pFw;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -22,21 +22,19 @@
|
|||
#include "InstanceContent.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::Network::ActorControl;
|
||||
|
||||
Sapphire::InstanceContent::InstanceContent( std::shared_ptr< Sapphire::Data::InstanceContent > pInstanceConfiguration,
|
||||
uint16_t territoryType,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName,
|
||||
uint32_t instanceContentId )
|
||||
:
|
||||
Zone( static_cast< uint16_t >( territoryType ), guId, internalName, contentName ),
|
||||
uint16_t territoryType,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName,
|
||||
uint32_t instanceContentId,
|
||||
FrameworkPtr pFw ) :
|
||||
Zone( static_cast< uint16_t >( territoryType ), guId, internalName, contentName, pFw ),
|
||||
Director( Event::Director::InstanceContent, instanceContentId ),
|
||||
m_instanceConfiguration( pInstanceConfiguration ),
|
||||
m_instanceContentId( instanceContentId ),
|
||||
|
@ -50,7 +48,7 @@ Sapphire::InstanceContent::InstanceContent( std::shared_ptr< Sapphire::Data::Ins
|
|||
|
||||
bool Sapphire::InstanceContent::init()
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onInstanceInit( getAsInstanceContent() );
|
||||
|
||||
return true;
|
||||
|
@ -160,7 +158,7 @@ void Sapphire::InstanceContent::onUpdate( uint32_t currTime )
|
|||
break;
|
||||
}
|
||||
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onInstanceUpdate( getAsInstanceContent(), currTime );
|
||||
}
|
||||
|
||||
|
@ -313,7 +311,7 @@ void Sapphire::InstanceContent::onRegisterEObj( Entity::EventObjectPtr object )
|
|||
if( object->getObjectId() == 2000182 ) // start
|
||||
m_pEntranceEObj = object;
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
auto objData = pExdData->get< Sapphire::Data::EObj >( object->getObjectId() );
|
||||
if( objData )
|
||||
// todo: data should be renamed to eventId
|
||||
|
@ -386,7 +384,7 @@ void Sapphire::InstanceContent::onTalk( Sapphire::Entity::Player& player, uint32
|
|||
void
|
||||
Sapphire::InstanceContent::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 )
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onInstanceEnterTerritory( getAsInstanceContent(), player, eventId, param1, param2 );
|
||||
|
||||
if( !hasPlayerPreviouslySpawned( player ) )
|
||||
|
|
|
@ -25,7 +25,8 @@ public:
|
|||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName,
|
||||
uint32_t instanceContentId );
|
||||
uint32_t instanceContentId,
|
||||
FrameworkPtr pFw );
|
||||
|
||||
virtual ~InstanceContent();
|
||||
|
||||
|
|
|
@ -24,12 +24,10 @@
|
|||
#include "Framework.h"
|
||||
#include "House.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
|
||||
Sapphire::Land::Land( uint16_t territoryTypeId, uint8_t wardNum, uint8_t landId, uint32_t landSetId,
|
||||
Sapphire::Data::HousingLandSetPtr info ) :
|
||||
Sapphire::Data::HousingLandSetPtr info, FrameworkPtr pFw ) :
|
||||
m_currentPrice( 0 ),
|
||||
m_minPrice( 0 ),
|
||||
m_nextDrop( static_cast< uint32_t >( Util::getTimeSeconds() ) + 21600 ),
|
||||
|
@ -40,7 +38,8 @@ Sapphire::Land::Land( uint16_t territoryTypeId, uint8_t wardNum, uint8_t landId,
|
|||
m_fcIcon( 0 ),
|
||||
m_fcIconColor( 0 ),
|
||||
m_fcId( 0 ),
|
||||
m_iconAddIcon( 0 )
|
||||
m_iconAddIcon( 0 ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
memset( &m_tag, 0x00, 3 );
|
||||
|
||||
|
@ -55,7 +54,8 @@ Sapphire::Land::Land( uint16_t territoryTypeId, uint8_t wardNum, uint8_t landId,
|
|||
|
||||
Sapphire::Land::~Land() = default;
|
||||
|
||||
void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice, uint64_t ownerId, uint64_t houseId )
|
||||
void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice,
|
||||
uint64_t ownerId, uint64_t houseId )
|
||||
{
|
||||
m_type = type;
|
||||
m_size = size;
|
||||
|
@ -65,9 +65,9 @@ void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, u
|
|||
|
||||
// fetch the house if we have one for this land
|
||||
if( houseId > 0 )
|
||||
m_pHouse = make_House( houseId, m_landSetId, getLandIdent() );
|
||||
m_pHouse = make_House( houseId, m_landSetId, getLandIdent(), m_pFw );
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Sapphire::Data::HousingMapMarkerInfo >( m_landIdent.territoryTypeId, m_landIdent.landId );
|
||||
if( info )
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, u
|
|||
// init item containers
|
||||
auto setupContainer = [ this ]( InventoryType type, uint16_t maxSize )
|
||||
{
|
||||
m_landInventoryMap[ type ] = make_ItemContainer( type, maxSize, "houseiteminventory", true, true );
|
||||
m_landInventoryMap[ type ] = make_ItemContainer( type, maxSize, "houseiteminventory", true, m_pFw, true );
|
||||
};
|
||||
|
||||
setupContainer( InventoryType::HousingOutdoorAppearance, 8 );
|
||||
|
@ -122,8 +122,8 @@ void Sapphire::Land::loadItemContainerContents()
|
|||
auto ident = *reinterpret_cast< uint64_t* >( &m_landIdent );
|
||||
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 pDB = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pItemMgr = m_pFw->get< World::Manager::ItemMgr >();
|
||||
|
||||
auto stmt = pDB->getPreparedStatement( Db::LAND_INV_SEL_HOUSE );
|
||||
stmt->setUInt64( 1, ident );
|
||||
|
@ -159,7 +159,7 @@ void Sapphire::Land::loadItemContainerContents()
|
|||
|
||||
uint32_t Sapphire::Land::convertItemIdToHousingItemId( uint32_t itemId )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Sapphire::Data::Item >( itemId );
|
||||
return info->additionalData;
|
||||
}
|
||||
|
@ -297,15 +297,15 @@ void Sapphire::Land::updateLandDb()
|
|||
houseId = getHouse()->getHouseId();
|
||||
|
||||
// todo: change to prepared statement
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
pDb->directExecute( "UPDATE land SET status = " + std::to_string( m_state )
|
||||
+ ", LandPrice = " + std::to_string( getCurrentPrice() )
|
||||
+ ", UpdateTime = " + std::to_string( getDevaluationTime() )
|
||||
+ ", OwnerId = " + std::to_string( getOwnerId() )
|
||||
+ ", HouseId = " + std::to_string( houseId )
|
||||
+ ", Type = " + std::to_string( static_cast< uint32_t >( m_type ) ) //TODO: add house id
|
||||
+ " WHERE LandSetId = " + std::to_string( m_landSetId )
|
||||
+ " AND LandId = " + std::to_string( m_landIdent.landId ) + ";" );
|
||||
+ ", LandPrice = " + std::to_string( getCurrentPrice() )
|
||||
+ ", UpdateTime = " + std::to_string( getDevaluationTime() )
|
||||
+ ", OwnerId = " + std::to_string( getOwnerId() )
|
||||
+ ", HouseId = " + std::to_string( houseId )
|
||||
+ ", Type = " + std::to_string( static_cast< uint32_t >( m_type ) ) //TODO: add house id
|
||||
+ " WHERE LandSetId = " + std::to_string( m_landSetId )
|
||||
+ " AND LandId = " + std::to_string( m_landIdent.landId ) + ";" );
|
||||
|
||||
if( auto house = getHouse() )
|
||||
house->updateHouseDb();
|
||||
|
@ -326,7 +326,7 @@ void Sapphire::Land::update( uint32_t currTime )
|
|||
|
||||
uint32_t Sapphire::Land::getNextHouseId()
|
||||
{
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pQR = pDb->query( "SELECT MAX( HouseId ) FROM house" );
|
||||
|
||||
if( !pQR->next() )
|
||||
|
@ -339,7 +339,7 @@ bool Sapphire::Land::setPreset( uint32_t itemId )
|
|||
{
|
||||
auto housingItemId = convertItemIdToHousingItemId( itemId );
|
||||
|
||||
auto exdData = g_fw.get< Sapphire::Data::ExdDataGenerated >();
|
||||
auto exdData = m_pFw->get< Sapphire::Data::ExdDataGenerated >();
|
||||
if( !exdData )
|
||||
return false;
|
||||
|
||||
|
@ -351,7 +351,7 @@ bool Sapphire::Land::setPreset( uint32_t itemId )
|
|||
{
|
||||
// todo: i guess we'd create a house here?
|
||||
auto newId = getNextHouseId();
|
||||
m_pHouse = make_House( newId, getLandSetId(), getLandIdent() );
|
||||
m_pHouse = make_House( newId, getLandSetId(), getLandIdent(), m_pFw );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ namespace Sapphire
|
|||
{
|
||||
public:
|
||||
|
||||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId, Sapphire::Data::HousingLandSetPtr info );
|
||||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId,
|
||||
Sapphire::Data::HousingLandSetPtr info, FrameworkPtr pFw );
|
||||
virtual ~Land();
|
||||
void init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice, uint64_t ownerId, uint64_t houseId );
|
||||
|
||||
|
@ -100,6 +101,8 @@ namespace Sapphire
|
|||
//information
|
||||
char fcTag[7];
|
||||
uint8_t m_tag[3];
|
||||
|
||||
FrameworkPtr m_pFw;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ using namespace Sapphire::Network::Packets::Server;
|
|||
using namespace Sapphire::Network::ActorControl;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
/**
|
||||
* \brief
|
||||
*/
|
||||
|
@ -58,11 +56,13 @@ Sapphire::Zone::Zone() :
|
|||
}
|
||||
|
||||
Sapphire::Zone::Zone( uint16_t territoryTypeId, uint32_t guId,
|
||||
const std::string& internalName, const std::string& placeName ) :
|
||||
const std::string& internalName, const std::string& placeName,
|
||||
FrameworkPtr pFw ) :
|
||||
m_currentWeather( Weather::FairSkies ),
|
||||
m_nextEObjId( 0x400D0000 )
|
||||
m_nextEObjId( 0x400D0000 ),
|
||||
m_pFw( pFw )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
m_guId = guId;
|
||||
|
||||
m_territoryTypeId = territoryTypeId;
|
||||
|
@ -83,7 +83,7 @@ void Sapphire::Zone::loadWeatherRates()
|
|||
if( !m_territoryTypeInfo )
|
||||
return;
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
|
||||
uint8_t weatherRateId = m_territoryTypeInfo->weatherRate > pExdData->getWeatherRateIdList().size() ?
|
||||
uint8_t{ 0 } : m_territoryTypeInfo->weatherRate;
|
||||
|
@ -109,7 +109,7 @@ Sapphire::Zone::~Zone()
|
|||
|
||||
bool Sapphire::Zone::init()
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
|
||||
if( pScriptMgr->onZoneInit( shared_from_this() ) )
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ void Sapphire::Zone::pushActor( Entity::ActorPtr pActor )
|
|||
{
|
||||
auto pPlayer = pActor->getAsPlayer();
|
||||
|
||||
auto pServerZone = g_fw.get< World::ServerMgr >();
|
||||
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
||||
auto pSession = pServerZone->getSession( pPlayer->getId() );
|
||||
if( pSession )
|
||||
m_sessionSet.insert( pSession );
|
||||
|
@ -281,11 +281,11 @@ void Sapphire::Zone::removeActor( Entity::ActorPtr pActor )
|
|||
void Sapphire::Zone::queuePacketForRange( Entity::Player& sourcePlayer, uint32_t range,
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry )
|
||||
{
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
auto pTeriMgr = m_pFw->get< TerritoryMgr >();
|
||||
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
|
||||
return;
|
||||
|
||||
auto pServerZone = g_fw.get< World::ServerMgr >();
|
||||
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
||||
for( auto entry : m_playerMap )
|
||||
{
|
||||
auto player = entry.second;
|
||||
|
@ -307,11 +307,11 @@ void Sapphire::Zone::queuePacketForZone( Entity::Player& sourcePlayer,
|
|||
Network::Packets::FFXIVPacketBasePtr pPacketEntry,
|
||||
bool forSelf )
|
||||
{
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
auto pTeriMgr = m_pFw->get< TerritoryMgr >();
|
||||
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
|
||||
return;
|
||||
|
||||
auto pServerZone = g_fw.get< World::ServerMgr >();
|
||||
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
||||
for( auto entry : m_playerMap )
|
||||
{
|
||||
auto player = entry.second;
|
||||
|
@ -627,7 +627,7 @@ void Sapphire::Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
|
|||
if( pCell == nullptr )
|
||||
return;
|
||||
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
auto pTeriMgr = m_pFw->get< TerritoryMgr >();
|
||||
// TODO: make sure gms can overwrite this. Potentially temporary solution
|
||||
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
|
||||
return;
|
||||
|
|
|
@ -57,11 +57,13 @@ namespace Sapphire
|
|||
std::map< uint8_t, int32_t > m_weatherRateMap;
|
||||
|
||||
uint32_t m_nextEObjId;
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
public:
|
||||
Zone();
|
||||
|
||||
Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName, const std::string& placeName );
|
||||
Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName,
|
||||
const std::string& placeName, FrameworkPtr pFw );
|
||||
|
||||
virtual ~Zone();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue