mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
Framework; Refactors, styling, other minor stuff;
This commit is contained in:
parent
6b801474b7
commit
b3318f14a3
44 changed files with 795 additions and 653 deletions
|
@ -1,5 +1,3 @@
|
|||
#include "ActionCast.h"
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
|
@ -9,17 +7,20 @@
|
|||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "ActionCast.h"
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::Action::ActionCast::ActionCast()
|
||||
{
|
||||
|
@ -31,7 +32,7 @@ Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr
|
|||
m_startTime = 0;
|
||||
m_id = actionId;
|
||||
m_handleActionType = HandleActionType::Spell;
|
||||
m_castTime = g_exdDataGen.get< Core::Data::Action >( actionId )->cast100ms * 100; // TODO: Add security checks.
|
||||
m_castTime = g_framework.getExdDataGen().get< Core::Data::Action >( actionId )->cast100ms * 100; // TODO: Add security checks.
|
||||
m_pSource = pActor;
|
||||
m_pTarget = pTarget;
|
||||
m_bInterrupt = false;
|
||||
|
@ -75,7 +76,7 @@ void Core::Action::ActionCast::onFinish()
|
|||
0x219, m_id, m_id, m_id, m_id );
|
||||
m_pSource->sendToInRangeSet( control, true );*/
|
||||
|
||||
g_scriptMgr.onCastFinish( *pPlayer, m_pTarget, m_id );
|
||||
g_framework.getScriptMgr().onCastFinish( *pPlayer, m_pTarget, m_id );
|
||||
}
|
||||
|
||||
void Core::Action::ActionCast::onInterrupt()
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include "ActionMount.h"
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
|
@ -8,16 +6,19 @@
|
|||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "ActionMount.h"
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::Action::ActionMount::ActionMount()
|
||||
{
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
#include "ActionTeleport.h"
|
||||
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "ActionTeleport.h"
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::Action::ActionTeleport::ActionTeleport()
|
||||
{
|
||||
|
@ -26,7 +27,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t
|
|||
m_startTime = 0;
|
||||
m_id = 5;
|
||||
m_handleActionType = HandleActionType::Teleport;
|
||||
m_castTime = g_exdDataGen.get< Core::Data::Action >( 5 )->cast100ms * 100; // TODO: Add security checks.
|
||||
m_castTime = g_framework.getExdDataGen().get< Core::Data::Action >( 5 )->cast100ms * 100; // TODO: Add security checks.
|
||||
m_pSource = pActor;
|
||||
m_bInterrupt = false;
|
||||
m_targetAetheryte = targetZone;
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
#include <common/Logging/Logger.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
|
||||
#include "EventAction.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Event/EventHandler.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
#include "EventAction.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network;
|
||||
|
@ -28,7 +30,7 @@ Core::Action::EventAction::EventAction( Entity::ActorPtr pActor, uint32_t eventI
|
|||
m_handleActionType = HandleActionType::Event;
|
||||
m_eventId = eventId;
|
||||
m_id = action;
|
||||
m_castTime = g_exdDataGen.get< Core::Data::EventAction >( action )->castTime * 1000; // TODO: Add security checks.
|
||||
m_castTime = g_framework.getExdDataGen().get< Core::Data::EventAction >( action )->castTime * 1000; // TODO: Add security checks.
|
||||
m_onActionFinishClb = finishRef;
|
||||
m_onActionInterruptClb = interruptRef;
|
||||
m_pSource = pActor;
|
||||
|
@ -90,7 +92,7 @@ void Core::Action::EventAction::onFinish()
|
|||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
g_log.error( e.what() );
|
||||
g_framework.getLogger().error( e.what() );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -129,7 +131,7 @@ void Core::Action::EventAction::onInterrupt()
|
|||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
g_log.error( e.what() );
|
||||
g_framework.getLogger().error( e.what() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
#include "EventItemAction.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "EventItemAction.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network;
|
||||
|
@ -84,7 +86,7 @@ void Core::Action::EventItemAction::onFinish()
|
|||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
g_log.error( e.what() );
|
||||
g_framework.getLogger().error( e.what() );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -113,7 +115,7 @@ void Core::Action::EventItemAction::onInterrupt()
|
|||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
g_log.error( e.what() );
|
||||
g_framework.getLogger().error( e.what() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "Forwards.h"
|
||||
#include "Action/Action.h"
|
||||
#include "Action/ActionCollision.h"
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
|
@ -15,18 +16,20 @@
|
|||
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
||||
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
|
||||
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
#include "Action/ActionCollision.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Session.h"
|
||||
#include "Math/CalcBattle.h"
|
||||
#include "Actor.h"
|
||||
#include "Player.h"
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
|
||||
#include "Math/CalcBattle.h"
|
||||
|
||||
#include "ServerZone.h"
|
||||
#include "Session.h"
|
||||
#include "Actor.h"
|
||||
#include "Player.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -451,7 +454,7 @@ void Core::Entity::Actor::sendToInRangeSet( Network::Packets::GamePacketPtr pPac
|
|||
{
|
||||
auto pPlayer = getAsPlayer();
|
||||
|
||||
auto pSession = g_serverZone.getSession( pPlayer->getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( pPlayer->getId() );
|
||||
|
||||
// it might be that the player DC'd in which case the session would be invalid
|
||||
if( pSession )
|
||||
|
@ -671,7 +674,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
|
|||
getAsPlayer()->sendDebug( "Handle script skill type: " + std::to_string( type ) );
|
||||
}
|
||||
|
||||
auto actionInfoPtr = g_exdDataGen.get< Core::Data::Action >( actionId );
|
||||
auto actionInfoPtr = g_framework.getExdDataGen().get< Core::Data::Action >( actionId );
|
||||
|
||||
// Todo: Effect packet generator. 90% of this is basically setting params and it's basically unreadable.
|
||||
// Prepare packet. This is seemingly common for all packets in the action handler.
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
|
||||
#include "Player.h"
|
||||
#include "BattleNpc.h"
|
||||
|
||||
#include "Network/PacketWrappers/MoveActorPacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "BattleNpc.h"
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
uint32_t Core::Entity::BattleNpc::m_nextID = 1149241694;
|
||||
|
||||
|
@ -101,7 +101,7 @@ void Core::Entity::BattleNpc::spawn( PlayerPtr pTarget )
|
|||
//spawnPacket.data().bnpcBaseId = m_bnpcBaseId;
|
||||
//spawnPacket.data().nameId = m_nameId;
|
||||
//spawnPacket.data().spawnIndex = pTarget->getSpawnIdForActorId( getId() );
|
||||
//g_log.info(std::to_string(spawnPacket.data().spawnIndex) + " " + std::to_string(getId()));
|
||||
//g_framework.getLogger().info(std::to_string(spawnPacket.data().spawnIndex) + " " + std::to_string(getId()));
|
||||
//spawnPacket.data().status = static_cast< uint8_t >( m_status );
|
||||
//spawnPacket.data().mobAgressive = m_behavior;
|
||||
//spawnPacket.data().type = static_cast< uint8_t >( m_type );
|
||||
|
@ -418,7 +418,7 @@ void Core::Entity::BattleNpc::onDeath()
|
|||
auto levelDiff = static_cast< int32_t >( this->m_level ) - level;
|
||||
auto cappedLevelDiff = Math::Util::clamp( levelDiff, 1, 6 );
|
||||
|
||||
auto expNeeded = g_exdDataGen.get< Core::Data::ParamGrow >( m_level + cappedLevelDiff - 1 )->expToNext;
|
||||
auto expNeeded = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( m_level + cappedLevelDiff - 1 )->expToNext;
|
||||
int32_t exp = 0;
|
||||
|
||||
// todo: arbitrary numbers pulled out of my ass
|
||||
|
|
|
@ -8,18 +8,19 @@
|
|||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
|
||||
#include "Player.h"
|
||||
#include "EventNpc.h"
|
||||
|
||||
#include "Network/PacketWrappers/MoveActorPacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "EventNpc.h"
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
uint32_t Core::Entity::EventNpc::m_nextID = 1249241694;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
|
@ -13,8 +15,7 @@
|
|||
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "ServerZone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
|
@ -27,25 +28,24 @@
|
|||
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
#include "Network/PacketWrappers/PlayerSpawnPacket.h"
|
||||
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "Inventory/Item.h"
|
||||
|
||||
#include "Inventory/Inventory.h"
|
||||
|
||||
#include "Event/EventHandler.h"
|
||||
|
||||
#include "Action/Action.h"
|
||||
#include "Action/EventAction.h"
|
||||
#include "Action/EventItemAction.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
|
||||
#include "Math/CalcStats.h"
|
||||
#include "Math/CalcBattle.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
#include "ServerZone.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -210,9 +210,9 @@ void Core::Entity::Player::calculateStats()
|
|||
uint8_t level = getLevel();
|
||||
uint8_t job = static_cast< uint8_t >( getClass() );
|
||||
|
||||
auto classInfo = g_exdDataGen.get< Core::Data::ClassJob >( job );
|
||||
auto tribeInfo = g_exdDataGen.get< Core::Data::Tribe >( tribe );
|
||||
auto paramGrowthInfo = g_exdDataGen.get< Core::Data::ParamGrow >( level );
|
||||
auto classInfo = g_framework.getExdDataGen().get< Core::Data::ClassJob >( job );
|
||||
auto tribeInfo = g_framework.getExdDataGen().get< Core::Data::Tribe >( tribe );
|
||||
auto paramGrowthInfo = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( level );
|
||||
|
||||
// TODO: put formula somewhere else...
|
||||
float base = Math::CalcStats::calculateBaseStat( getAsPlayer() );
|
||||
|
@ -290,7 +290,7 @@ void Core::Entity::Player::sendStats()
|
|||
|
||||
void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
||||
{
|
||||
auto data = g_exdDataGen.get< Core::Data::Aetheryte >( aetheryteId );
|
||||
auto data = g_framework.getExdDataGen().get< Core::Data::Aetheryte >( aetheryteId );
|
||||
|
||||
if( data == nullptr )
|
||||
{
|
||||
|
@ -299,7 +299,7 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
|||
|
||||
setStateFlag( PlayerStateFlag::BetweenAreas );
|
||||
|
||||
auto z_pos = g_territoryMgr.getTerritoryPosition( data->territory );
|
||||
auto z_pos = g_framework.getTerritoryMgr().getTerritoryPosition( data->territory );
|
||||
|
||||
Common::FFXIVARR_POSITION3 pos;
|
||||
pos.x = 0;
|
||||
|
@ -313,8 +313,8 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
|||
rot = z_pos->getTargetRotation();
|
||||
}
|
||||
|
||||
sendDebug( "Teleport: " + g_exdDataGen.get< Core::Data::PlaceName >( data->placeName )->name + " " +
|
||||
g_exdDataGen.get< Core::Data::PlaceName >( data->aethernetName )->name +
|
||||
sendDebug( "Teleport: " + g_framework.getExdDataGen().get< Core::Data::PlaceName >( data->placeName )->name + " " +
|
||||
g_framework.getExdDataGen().get< Core::Data::PlaceName >( data->aethernetName )->name +
|
||||
"(" + std::to_string( data->territory ) + ")" );
|
||||
|
||||
// TODO: this should be simplified and a type created in server_common/common.h.
|
||||
|
@ -356,14 +356,14 @@ void Core::Entity::Player::returnToHomepoint()
|
|||
|
||||
void Core::Entity::Player::setZone( uint32_t zoneId )
|
||||
{
|
||||
if( !g_territoryMgr.movePlayer( zoneId, getAsPlayer() ) )
|
||||
if( !g_framework.getTerritoryMgr().movePlayer( zoneId, getAsPlayer() ) )
|
||||
{
|
||||
// todo: this will require proper handling, for now just return the player to their previous area
|
||||
m_pos = m_prevPos;
|
||||
m_rot = m_prevRot;
|
||||
m_zoneId = m_prevZoneId;
|
||||
|
||||
if( !g_territoryMgr.movePlayer( m_zoneId, getAsPlayer() ) )
|
||||
if( !g_framework.getTerritoryMgr().movePlayer( m_zoneId, getAsPlayer() ) )
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
|
|||
|
||||
bool Core::Entity::Player::setInstance( uint32_t instanceContentId )
|
||||
{
|
||||
auto instance = g_territoryMgr.getInstanceZonePtr( instanceContentId );
|
||||
auto instance = g_framework.getTerritoryMgr().getInstanceZonePtr( instanceContentId );
|
||||
if( !instance )
|
||||
return false;
|
||||
|
||||
|
@ -392,7 +392,7 @@ bool Core::Entity::Player::setInstance( ZonePtr instance )
|
|||
m_prevZoneId = m_zoneId;
|
||||
}
|
||||
|
||||
if( !g_territoryMgr.movePlayer( instance, getAsPlayer() ) )
|
||||
if( !g_framework.getTerritoryMgr().movePlayer( instance, getAsPlayer() ) )
|
||||
return false;
|
||||
|
||||
sendZonePackets();
|
||||
|
@ -402,7 +402,7 @@ bool Core::Entity::Player::setInstance( ZonePtr instance )
|
|||
|
||||
bool Core::Entity::Player::exitInstance()
|
||||
{
|
||||
if( !g_territoryMgr.movePlayer( m_prevZoneId, getAsPlayer() ) )
|
||||
if( !g_framework.getTerritoryMgr().movePlayer( m_prevZoneId, getAsPlayer() ) )
|
||||
return false;
|
||||
|
||||
m_pos = m_prevPos;
|
||||
|
@ -493,7 +493,7 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id )
|
|||
|
||||
int32_t offset = 4;
|
||||
|
||||
auto info = g_exdDataGen.get< Core::Data::Map >( g_exdDataGen.get< Core::Data::TerritoryType >( getCurrentZone()->getTerritoryId() )->map );
|
||||
auto info = g_framework.getExdDataGen().get< Core::Data::Map >( g_framework.getExdDataGen().get< Core::Data::TerritoryType >( getCurrentZone()->getTerritoryId() )->map );
|
||||
if( info->discoveryArrayByte )
|
||||
offset = 4 + 2 * info->discoveryIndex;
|
||||
else
|
||||
|
@ -508,7 +508,7 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id )
|
|||
|
||||
uint16_t level = getLevel();
|
||||
|
||||
uint32_t exp = ( g_exdDataGen.get< Core::Data::ParamGrow >( level )->expToNext * 5 / 100 );
|
||||
uint32_t exp = ( g_framework.getExdDataGen().get< Core::Data::ParamGrow >( level )->expToNext * 5 / 100 );
|
||||
|
||||
gainExp( exp );
|
||||
|
||||
|
@ -585,9 +585,9 @@ void Core::Entity::Player::gainExp( uint32_t amount )
|
|||
|
||||
uint16_t level = getLevel();
|
||||
|
||||
uint32_t neededExpToLevel = g_exdDataGen.get< Core::Data::ParamGrow >( level )->expToNext;
|
||||
uint32_t neededExpToLevel = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( level )->expToNext;
|
||||
|
||||
uint32_t neededExpToLevelplus1 = g_exdDataGen.get< Core::Data::ParamGrow >( level + 1 )->expToNext;
|
||||
uint32_t neededExpToLevelplus1 = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( level + 1 )->expToNext;
|
||||
|
||||
queuePacket( ActorControlPacket143( getId(), GainExpMsg, static_cast< uint8_t >( getClass() ), amount ) );
|
||||
|
||||
|
@ -671,25 +671,25 @@ void Core::Entity::Player::sendStatusUpdate( bool toSelf )
|
|||
|
||||
uint8_t Core::Entity::Player::getLevel() const
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
return static_cast< uint8_t >( m_classArray[classJobIndex] );
|
||||
}
|
||||
|
||||
uint8_t Core::Entity::Player::getLevelForClass( Common::ClassJob pClass ) const
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( pClass ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( pClass ) )->expArrayIndex;
|
||||
return static_cast< uint8_t >( m_classArray[classJobIndex] );
|
||||
}
|
||||
|
||||
uint32_t Core::Entity::Player::getExp() const
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
return m_expArray[classJobIndex];
|
||||
}
|
||||
|
||||
void Core::Entity::Player::setExp( uint32_t amount )
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
m_expArray[classJobIndex] = amount;
|
||||
}
|
||||
|
||||
|
@ -729,13 +729,13 @@ void Core::Entity::Player::setClassJob( Common::ClassJob classJob )
|
|||
|
||||
void Core::Entity::Player::setLevel( uint8_t level )
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( getClass() ) )->expArrayIndex;
|
||||
m_classArray[classJobIndex] = level;
|
||||
}
|
||||
|
||||
void Core::Entity::Player::setLevelForClass( uint8_t level, Common::ClassJob classjob )
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( classjob ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( classjob ) )->expArrayIndex;
|
||||
|
||||
if( m_classArray[classJobIndex] == 0 )
|
||||
insertDbClass( classJobIndex );
|
||||
|
@ -809,7 +809,7 @@ void Core::Entity::Player::setLookAt( uint8_t index, uint8_t value )
|
|||
// spawn this player for pTarget
|
||||
void Core::Entity::Player::spawn( Entity::PlayerPtr pTarget )
|
||||
{
|
||||
g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " +
|
||||
getName() + " for " +
|
||||
pTarget->getName() );
|
||||
|
||||
|
@ -885,7 +885,7 @@ const uint8_t* Core::Entity::Player::getStateFlags() const
|
|||
|
||||
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases
|
||||
{
|
||||
auto actionInfoPtr = g_exdDataGen.get< Core::Data::Action >( actionId );
|
||||
auto actionInfoPtr = g_framework.getExdDataGen().get< Core::Data::Action >( actionId );
|
||||
if( actionInfoPtr->preservesCombo )
|
||||
return false;
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ void Core::Entity::Player::update( int64_t currTime )
|
|||
|
||||
void Core::Entity::Player::onMobKill( uint16_t nameId )
|
||||
{
|
||||
g_scriptMgr.onMobKill( *getAsPlayer(), nameId );
|
||||
g_framework.getScriptMgr().onMobKill( *getAsPlayer(), nameId );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::freePlayerSpawnId( uint32_t actorId )
|
||||
|
@ -1157,7 +1157,7 @@ const uint8_t* Core::Entity::Player::getGcRankArray() const
|
|||
|
||||
void Core::Entity::Player::queuePacket( Network::Packets::GamePacketPtr pPacket )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( m_id );
|
||||
auto pSession = g_framework.getServerZone().getSession( m_id );
|
||||
|
||||
if( !pSession )
|
||||
return;
|
||||
|
@ -1171,7 +1171,7 @@ void Core::Entity::Player::queuePacket( Network::Packets::GamePacketPtr pPacket
|
|||
|
||||
void Core::Entity::Player::queueChatPacket( Network::Packets::GamePacketPtr pPacket )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( m_id );
|
||||
auto pSession = g_framework.getServerZone().getSession( m_id );
|
||||
|
||||
if( !pSession )
|
||||
return;
|
||||
|
|
|
@ -4,12 +4,6 @@
|
|||
#include <common/Network/PacketContainer.h>
|
||||
#include <common/Config/XMLConfig.h>
|
||||
|
||||
#include "Player.h"
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
|
@ -23,10 +17,15 @@
|
|||
|
||||
#include "Event/EventHandler.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include "ServerZone.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "Forwards.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -126,7 +125,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
}
|
||||
else if( !pEvent )
|
||||
{
|
||||
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
g_framework.getLogger().error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -154,7 +153,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
}
|
||||
else if( !pEvent )
|
||||
{
|
||||
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
g_framework.getLogger().error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,7 +171,7 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
|
|||
|
||||
if( !pEvent )
|
||||
{
|
||||
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
g_framework.getLogger().error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -241,7 +240,7 @@ void Core::Entity::Player::eventActionStart( uint32_t eventId,
|
|||
}
|
||||
else if( !pEvent )
|
||||
{
|
||||
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
g_framework.getLogger().error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -269,7 +268,7 @@ void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
|
|||
|
||||
void Core::Entity::Player::onLogin()
|
||||
{
|
||||
for( auto& child : g_serverZone.getConfig()->getChild( "Settings.Parameters.MotDArray" ) )
|
||||
for( auto& child : g_framework.getServerZone().getConfig()->getChild( "Settings.Parameters.MotDArray" ) )
|
||||
{
|
||||
sendNotice( child.second.data() );
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
#include <common/Network/GamePacket.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include "Player.h"
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
|
@ -12,7 +10,10 @@
|
|||
#include "Inventory/Inventory.h"
|
||||
#include "Inventory/Item.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
#include "Player.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -87,7 +88,7 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
|
|||
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem, bool sendUpdate )
|
||||
{
|
||||
|
||||
//g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
|
||||
//g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) );
|
||||
|
||||
uint64_t model = pItem->getModelId1();
|
||||
uint64_t model2 = pItem->getModelId2();
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
#include <common/Network/PacketContainer.h>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Network/PacketWrappers/QuestMessagePacket.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Player.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -1015,13 +1015,13 @@ void Core::Entity::Player::removeQuestsCompleted( uint32_t questId )
|
|||
bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optionalChoice )
|
||||
{
|
||||
uint32_t playerLevel = getLevel();
|
||||
auto questInfo = g_exdDataGen.get< Core::Data::Quest >( questId );
|
||||
auto questInfo = g_framework.getExdDataGen().get< Core::Data::Quest >( questId );
|
||||
|
||||
|
||||
if( !questInfo )
|
||||
return false;
|
||||
|
||||
auto paramGrowth = g_exdDataGen.get< Core::Data::ParamGrow >( questInfo->classJobLevel0 );
|
||||
auto paramGrowth = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( questInfo->classJobLevel0 );
|
||||
|
||||
// TODO: use the correct formula, this one is wrong
|
||||
uint32_t exp = ( questInfo->expFactor * paramGrowth->questExpModifier * ( 45 + 5 * questInfo->classJobLevel0 ) ) / 100;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#include <set>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/GamePacket.h>
|
||||
#include <common/Util/Util.h>
|
||||
|
@ -9,30 +13,20 @@
|
|||
#include <common/Common.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
|
||||
#include <set>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "Player.h"
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
#include "Inventory/Inventory.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -43,10 +37,10 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
{
|
||||
const std::string char_id_str = std::to_string( charId );
|
||||
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_SEL );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CharaDbStatements::CHARA_SEL );
|
||||
|
||||
stmt->setUInt( 1, charId );
|
||||
auto res = g_charaDb.query( stmt );
|
||||
auto res = g_framework.getCharaDb().query( stmt );
|
||||
|
||||
if( !res->next() )
|
||||
return false;
|
||||
|
@ -74,10 +68,10 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
ZonePtr pCurrZone = nullptr;
|
||||
|
||||
// if the zone is an instanceContent zone, we need to actually find the instance
|
||||
if( g_territoryMgr.isInstanceContentTerritory( zoneId ) )
|
||||
if( g_framework.getTerritoryMgr().isInstanceContentTerritory( zoneId ) )
|
||||
{
|
||||
// try to find an instance actually linked to this player
|
||||
pCurrZone = g_territoryMgr.getLinkedInstance( m_id );
|
||||
pCurrZone = g_framework.getTerritoryMgr().getLinkedInstance( m_id );
|
||||
// if none found, revert to previous zone and position
|
||||
if( !pCurrZone )
|
||||
{
|
||||
|
@ -86,12 +80,12 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
m_pos.y = m_prevPos.y;
|
||||
m_pos.z = m_prevPos.z;
|
||||
setRotation( m_prevRot );
|
||||
pCurrZone = g_territoryMgr.getZoneByTerriId( zoneId );
|
||||
pCurrZone = g_framework.getTerritoryMgr().getZoneByTerriId( zoneId );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pCurrZone = g_territoryMgr.getZoneByTerriId( zoneId );
|
||||
pCurrZone = g_framework.getTerritoryMgr().getZoneByTerriId( zoneId );
|
||||
}
|
||||
|
||||
m_zoneId = zoneId;
|
||||
|
@ -100,12 +94,12 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
// see if a valid zone could be found for the character
|
||||
if( !pCurrZone )
|
||||
{
|
||||
g_log.error( "[" + char_id_str + "] Zone " + std::to_string( zoneId ) + " not found!" );
|
||||
g_log.error( "[" + char_id_str + "] Setting default zone instead" );
|
||||
g_framework.getLogger().error( "[" + char_id_str + "] Zone " + std::to_string( zoneId ) + " not found!" );
|
||||
g_framework.getLogger().error( "[" + char_id_str + "] Setting default zone instead" );
|
||||
|
||||
// default to new gridania
|
||||
// TODO: should probably just abort and mark character as corrupt
|
||||
pCurrZone = g_territoryMgr.getZoneByTerriId( 132 );
|
||||
pCurrZone = g_framework.getTerritoryMgr().getZoneByTerriId( 132 );
|
||||
|
||||
m_pos.x = 0.0f;
|
||||
m_pos.y = 0.0f;
|
||||
|
@ -192,7 +186,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
m_pCell = nullptr;
|
||||
|
||||
if( !loadActiveQuests() || !loadClassData() || !loadSearchInfo() )
|
||||
g_log.error( "Player id " + char_id_str + " data corrupt!" );
|
||||
g_framework.getLogger().error( "Player id " + char_id_str + " data corrupt!" );
|
||||
|
||||
m_maxHp = getMaxHp();
|
||||
m_maxMp = getMaxMp();
|
||||
|
@ -210,7 +204,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
// first login, run the script event
|
||||
if( m_bNewGame )
|
||||
{
|
||||
//g_scriptMgr.onPlayerFirstEnterWorld( pPlayer );
|
||||
//g_framework.getScriptMgr().onPlayerFirstEnterWorld( pPlayer );
|
||||
m_bNewGame = false;
|
||||
m_hp = getMaxHp();
|
||||
m_mp = getMaxMp();
|
||||
|
@ -239,7 +233,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
if( !m_playerIdToSpawnIdMap.empty() )
|
||||
m_playerIdToSpawnIdMap.clear();
|
||||
|
||||
if( !g_territoryMgr.movePlayer( pCurrZone, getAsPlayer() ) )
|
||||
if( !g_framework.getTerritoryMgr().movePlayer( pCurrZone, getAsPlayer() ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -248,10 +242,10 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
bool Core::Entity::Player::loadActiveQuests()
|
||||
{
|
||||
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_QUEST_SEL );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CharaDbStatements::CHARA_QUEST_SEL );
|
||||
|
||||
stmt->setUInt( 1, m_id );
|
||||
auto res = g_charaDb.query( stmt );
|
||||
auto res = g_framework.getCharaDb().query( stmt );
|
||||
|
||||
while( res->next() )
|
||||
{
|
||||
|
@ -285,9 +279,9 @@ bool Core::Entity::Player::loadClassData()
|
|||
{
|
||||
|
||||
// ClassIdx, Exp, Lvl
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_CLASS_SEL );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CharaDbStatements::CHARA_CLASS_SEL );
|
||||
stmt->setUInt( 1, m_id );
|
||||
auto res = g_charaDb.query( stmt );
|
||||
auto res = g_framework.getCharaDb().query( stmt );
|
||||
|
||||
while( res->next() )
|
||||
{
|
||||
|
@ -304,9 +298,9 @@ bool Core::Entity::Player::loadClassData()
|
|||
|
||||
bool Core::Entity::Player::loadSearchInfo()
|
||||
{
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_SEARCHINFO_SEL );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CharaDbStatements::CHARA_SEARCHINFO_SEL );
|
||||
stmt->setUInt( 1, m_id );
|
||||
auto res = g_charaDb.query( stmt );
|
||||
auto res = g_framework.getCharaDb().query( stmt );
|
||||
|
||||
if( !res->next() )
|
||||
return false;
|
||||
|
@ -332,7 +326,7 @@ void Core::Entity::Player::updateSql()
|
|||
"EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, "
|
||||
"QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, "
|
||||
"CFPenaltyUntil 54"*/
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_UP );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CharaDbStatements::CHARA_UP );
|
||||
|
||||
stmt->setInt( 1, getHp() );
|
||||
stmt->setInt( 2, getMp() );
|
||||
|
@ -441,7 +435,7 @@ void Core::Entity::Player::updateSql()
|
|||
|
||||
stmt->setInt( 55, m_id );
|
||||
|
||||
g_charaDb.execute( stmt );
|
||||
g_framework.getCharaDb().execute( stmt );
|
||||
|
||||
////// Searchinfo
|
||||
updateDbSearchInfo();
|
||||
|
@ -456,43 +450,43 @@ void Core::Entity::Player::updateSql()
|
|||
|
||||
void Core::Entity::Player::updateDbClass() const
|
||||
{
|
||||
uint8_t classJobIndex = g_exdDataGen.get< Core::Data::ClassJob >( static_cast<uint8_t>( getClass() ) )->expArrayIndex;
|
||||
uint8_t classJobIndex = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast<uint8_t>( getClass() ) )->expArrayIndex;
|
||||
|
||||
//Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?
|
||||
auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_UP );
|
||||
auto stmtS = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_CLASS_UP );
|
||||
stmtS->setInt( 1, getExp() );
|
||||
stmtS->setInt( 2, getLevel() );
|
||||
stmtS->setInt( 3, m_id );
|
||||
stmtS->setInt( 4, classJobIndex );
|
||||
g_charaDb.execute( stmtS );
|
||||
g_framework.getCharaDb().execute( stmtS );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::insertDbClass( const uint8_t classJobIndex ) const
|
||||
{
|
||||
auto stmtClass = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_INS );
|
||||
auto stmtClass = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_CLASS_INS );
|
||||
stmtClass->setInt( 1, getId() );
|
||||
stmtClass->setInt( 2, classJobIndex );
|
||||
stmtClass->setInt( 3, 0 );
|
||||
stmtClass->setInt( 4, 1 );
|
||||
g_charaDb.directExecute( stmtClass );
|
||||
g_framework.getCharaDb().directExecute( stmtClass );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::updateDbSearchInfo() const
|
||||
{
|
||||
auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTCLASS );
|
||||
auto stmtS = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTCLASS );
|
||||
stmtS->setInt( 1, m_searchSelectClass );
|
||||
stmtS->setInt( 2, m_id );
|
||||
g_charaDb.execute( stmtS );
|
||||
g_framework.getCharaDb().execute( stmtS );
|
||||
|
||||
auto stmtS1 = g_charaDb.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTREGION );
|
||||
auto stmtS1 = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTREGION );
|
||||
stmtS1->setInt( 1, m_searchSelectRegion );
|
||||
stmtS1->setInt( 2, m_id );
|
||||
g_charaDb.execute( stmtS1 );
|
||||
g_framework.getCharaDb().execute( stmtS1 );
|
||||
|
||||
auto stmtS2 = g_charaDb.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTREGION );
|
||||
auto stmtS2 = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTREGION );
|
||||
stmtS2->setString( 1, string( m_searchMessage != nullptr ? m_searchMessage : "" ) );
|
||||
stmtS2->setInt( 2, m_id );
|
||||
g_charaDb.execute( stmtS2 );
|
||||
g_framework.getCharaDb().execute( stmtS2 );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::updateDbAllQuests() const
|
||||
|
@ -503,7 +497,7 @@ void Core::Entity::Player::updateDbAllQuests() const
|
|||
if( !m_activeQuests[i] )
|
||||
continue;
|
||||
|
||||
auto stmtS3 = g_charaDb.getPreparedStatement( Db::CHARA_QUEST_UP );
|
||||
auto stmtS3 = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_QUEST_UP );
|
||||
stmtS3->setInt( 1, m_activeQuests[i]->c.sequence );
|
||||
stmtS3->setInt( 2, m_activeQuests[i]->c.flags );
|
||||
stmtS3->setInt( 3, m_activeQuests[i]->c.UI8A );
|
||||
|
@ -515,22 +509,22 @@ void Core::Entity::Player::updateDbAllQuests() const
|
|||
stmtS3->setInt( 9, m_activeQuests[i]->c.padding1 );
|
||||
stmtS3->setInt( 10, m_id);
|
||||
stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
|
||||
g_charaDb.execute( stmtS3 );
|
||||
g_framework.getCharaDb().execute( stmtS3 );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Entity::Player::deleteQuest( uint16_t questId ) const
|
||||
{
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CHARA_QUEST_DEL );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_QUEST_DEL );
|
||||
stmt->setInt( 1, m_id );
|
||||
stmt->setInt( 2, questId );
|
||||
g_charaDb.execute( stmt );
|
||||
g_framework.getCharaDb().execute( stmt );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::insertQuest( uint16_t questId, uint8_t index, uint8_t seq ) const
|
||||
{
|
||||
auto stmt = g_charaDb.getPreparedStatement( Db::CHARA_QUEST_INS );
|
||||
auto stmt = g_framework.getCharaDb().getPreparedStatement( Db::CHARA_QUEST_INS );
|
||||
stmt->setInt( 1, m_id );
|
||||
stmt->setInt( 2, index );
|
||||
stmt->setInt( 3, questId );
|
||||
|
@ -543,5 +537,5 @@ void Core::Entity::Player::insertQuest( uint16_t questId, uint8_t index, uint8_t
|
|||
stmt->setInt( 10, 0 );
|
||||
stmt->setInt( 11, 0 );
|
||||
stmt->setInt( 12, 0 );
|
||||
g_charaDb.execute( stmt );
|
||||
g_framework.getCharaDb().execute( stmt );
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <cinttypes>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Version.h>
|
||||
|
@ -17,9 +20,10 @@
|
|||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
#include "Network/PacketWrappers/PlayerSpawnPacket.h"
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Script/NativeScriptManager.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
#include "Script/NativeScriptMgr.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/BattleNpc.h"
|
||||
|
@ -27,24 +31,15 @@
|
|||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/InstanceContent.h"
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
#include "Session.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include "Framework.h"
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
#include "Network/PacketWrappers/PlayerSpawnPacket.h"
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
// instanciate and initialize commands
|
||||
Core::DebugCommandHandler::DebugCommandHandler()
|
||||
|
@ -158,7 +153,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
|||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
||||
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
||||
|
||||
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
"subCommand " + subCommand + " params: " + params );
|
||||
|
||||
|
||||
|
@ -226,8 +221,8 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
|||
"', '" + std::to_string( map_id ) +
|
||||
"', '" + std::to_string( discover_id ) + "')";
|
||||
|
||||
g_charaDb.execute( query1 );
|
||||
g_charaDb.execute( query2 );
|
||||
g_framework.getCharaDb().execute( query1 );
|
||||
g_framework.getCharaDb().execute( query2 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -333,7 +328,7 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
|
|||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
||||
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
||||
|
||||
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
"subCommand " + subCommand + " params: " + params );
|
||||
|
||||
|
||||
|
@ -474,14 +469,14 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost:
|
|||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
||||
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
||||
|
||||
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
"subCommand " + subCommand + " params: " + params );
|
||||
|
||||
|
||||
if( ( subCommand == "pos" ) )
|
||||
{
|
||||
|
||||
int16_t map_id = g_exdDataGen.get< Core::Data::TerritoryType >( player.getCurrentZone()->getTerritoryId() )->map;
|
||||
int16_t map_id = g_framework.getExdDataGen().get< Core::Data::TerritoryType >( player.getCurrentZone()->getTerritoryId() )->map;
|
||||
|
||||
player.sendNotice( "Pos:\n" +
|
||||
std::to_string( player.getPos().x ) + "\n" +
|
||||
|
@ -500,14 +495,14 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost:
|
|||
|
||||
void Core::DebugCommandHandler::injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( player.getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( player.getId() );
|
||||
if( pSession )
|
||||
pSession->getZoneConnection()->injectPacket( data + 7, player );
|
||||
}
|
||||
|
||||
void Core::DebugCommandHandler::injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( player.getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( player.getId() );
|
||||
if( pSession )
|
||||
pSession->getChatConnection()->injectPacket( data + 8, player );
|
||||
}
|
||||
|
@ -532,25 +527,25 @@ void Core::DebugCommandHandler::replay( char * data, Entity::Player& player, boo
|
|||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
||||
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
||||
|
||||
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
"subCommand " + subCommand + " params: " + params );
|
||||
|
||||
|
||||
if( subCommand == "start" )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( player.getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( player.getId() );
|
||||
if( pSession )
|
||||
pSession->startReplay( params );
|
||||
}
|
||||
else if( subCommand == "stop" )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( player.getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( player.getId() );
|
||||
if( pSession )
|
||||
pSession->stopReplay();
|
||||
}
|
||||
else if( subCommand == "info" )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( player.getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( player.getId() );
|
||||
if( pSession )
|
||||
pSession->sendReplayInfo();
|
||||
}
|
||||
|
@ -613,7 +608,7 @@ void Core::DebugCommandHandler::serverInfo( char * data, Entity::Player& player,
|
|||
{
|
||||
player.sendDebug( "SapphireServer " + Version::VERSION + "\nRev: " + Version::GIT_HASH );
|
||||
player.sendDebug( "Compiled: " __DATE__ " " __TIME__ );
|
||||
player.sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) );
|
||||
player.sendDebug( "Sessions: " + std::to_string( g_framework.getServerZone().getSessionCount() ) );
|
||||
}
|
||||
|
||||
void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||
|
@ -642,7 +637,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
|
|||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
||||
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
||||
|
||||
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( player.getId() ) + "] " +
|
||||
"subCommand " + subCommand + " params: " + params );
|
||||
|
||||
if( subCommand == "unload" )
|
||||
|
@ -650,7 +645,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
|
|||
if ( subCommand == params )
|
||||
player.sendDebug( "Command failed: requires name of script" );
|
||||
else
|
||||
if( g_scriptMgr.getNativeScriptHandler().unloadScript( params ) )
|
||||
if( g_framework.getScriptMgr().getNativeScriptHandler().unloadScript( params ) )
|
||||
player.sendDebug( "Unloaded script successfully." );
|
||||
else
|
||||
player.sendDebug( "Failed to unload script: " + params );
|
||||
|
@ -662,7 +657,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
|
|||
else
|
||||
{
|
||||
std::set< Core::Scripting::ScriptInfo* > scripts;
|
||||
g_scriptMgr.getNativeScriptHandler().findScripts( scripts, params );
|
||||
g_framework.getScriptMgr().getNativeScriptHandler().findScripts( scripts, params );
|
||||
|
||||
if( !scripts.empty() )
|
||||
{
|
||||
|
@ -686,7 +681,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
|
|||
player.sendDebug( "Command failed: requires relative path to script" );
|
||||
else
|
||||
{
|
||||
if ( g_scriptMgr.getNativeScriptHandler().loadScript( params ) )
|
||||
if ( g_framework.getScriptMgr().getNativeScriptHandler().loadScript( params ) )
|
||||
player.sendDebug( "Loaded '" + params + "' successfully" );
|
||||
else
|
||||
player.sendDebug( "Failed to load '" + params + "'" );
|
||||
|
@ -699,7 +694,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
|
|||
player.sendDebug( "Command failed: requires name of script to reload" );
|
||||
else
|
||||
{
|
||||
g_scriptMgr.getNativeScriptHandler().queueScriptReload( params );
|
||||
g_framework.getScriptMgr().getNativeScriptHandler().queueScriptReload( params );
|
||||
player.sendDebug( "Queued script reload for script: " + params );
|
||||
}
|
||||
}
|
||||
|
@ -734,7 +729,7 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
|
|||
uint32_t instanceContentId;
|
||||
sscanf( params.c_str(), "%d", &instanceContentId );
|
||||
|
||||
auto instance = g_territoryMgr.createInstanceContent( instanceContentId );
|
||||
auto instance = g_framework.getTerritoryMgr().createInstanceContent( instanceContentId );
|
||||
if( instance )
|
||||
player.sendDebug( "Created instance with id: " + std::to_string( instance->getGuId() ) + " -> " + instance->getName() );
|
||||
else
|
||||
|
@ -745,7 +740,7 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
|
|||
uint32_t terriId;
|
||||
sscanf( params.c_str(), "%d", &terriId );
|
||||
|
||||
if( g_territoryMgr.removeTerritoryInstance( terriId ) )
|
||||
if( g_framework.getTerritoryMgr().removeTerritoryInstance( terriId ) )
|
||||
player.sendDebug( "Removed instance with id: " + std::to_string( terriId ) );
|
||||
else
|
||||
player.sendDebug( "Failed to remove instance with id: " + std::to_string( terriId ) );
|
||||
|
@ -761,7 +756,7 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
|
|||
uint32_t value;
|
||||
sscanf( params.c_str(), "%d %d %d", &instanceId, &index, &value );
|
||||
|
||||
auto pInstance = g_territoryMgr.getInstanceZonePtr( instanceId );
|
||||
auto pInstance = g_framework.getTerritoryMgr().getInstanceZonePtr( instanceId );
|
||||
if( !pInstance )
|
||||
return;
|
||||
auto instance = boost::dynamic_pointer_cast< InstanceContent >( pInstance );
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#include "EventHelper.h"
|
||||
#include "EventHandler.h"
|
||||
#include <common/Common.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
#include "Framework.h"
|
||||
#include "EventHelper.h"
|
||||
#include "EventHandler.h"
|
||||
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
|
||||
|
@ -17,7 +20,7 @@ std::string Core::Event::getEventName( uint32_t eventId )
|
|||
{
|
||||
case Event::EventHandler::EventHandlerType::Quest:
|
||||
{
|
||||
auto questInfo = g_exdDataGen.get< Core::Data::Quest >( eventId );
|
||||
auto questInfo = g_framework.getExdDataGen().get< Core::Data::Quest >( eventId );
|
||||
if( !questInfo )
|
||||
return unknown + "Quest";
|
||||
|
||||
|
@ -28,7 +31,7 @@ std::string Core::Event::getEventName( uint32_t eventId )
|
|||
}
|
||||
case Event::EventHandler::EventHandlerType::CustomTalk:
|
||||
{
|
||||
auto customTalkInfo = g_exdDataGen.get< Core::Data::CustomTalk >( eventId );
|
||||
auto customTalkInfo = g_framework.getExdDataGen().get< Core::Data::CustomTalk >( eventId );
|
||||
if( !customTalkInfo )
|
||||
return unknown + "CustomTalk";
|
||||
|
||||
|
@ -39,14 +42,14 @@ std::string Core::Event::getEventName( uint32_t eventId )
|
|||
}
|
||||
case Event::EventHandler::EventHandlerType::Opening:
|
||||
{
|
||||
auto openingInfo = g_exdDataGen.get< Core::Data::Opening >( eventId );
|
||||
auto openingInfo = g_framework.getExdDataGen().get< Core::Data::Opening >( eventId );
|
||||
if( openingInfo )
|
||||
return openingInfo->name;
|
||||
return unknown + "Opening";
|
||||
}
|
||||
case Event::EventHandler::EventHandlerType::Aetheryte:
|
||||
{
|
||||
auto aetherInfo = g_exdDataGen.get< Core::Data::Aetheryte >( eventId & 0xFFFF );
|
||||
auto aetherInfo = g_framework.getExdDataGen().get< Core::Data::Aetheryte >( eventId & 0xFFFF );
|
||||
if( aetherInfo->isAetheryte )
|
||||
return "Aetheryte";
|
||||
return "Aethernet";
|
||||
|
@ -65,7 +68,7 @@ std::string Core::Event::getEventName( uint32_t eventId )
|
|||
|
||||
uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId )
|
||||
{
|
||||
auto levelInfo = g_exdDataGen.get< Core::Data::Level >( eventActorId );
|
||||
auto levelInfo = g_framework.getExdDataGen().get< Core::Data::Level >( eventActorId );
|
||||
if( levelInfo )
|
||||
return levelInfo->objectKey;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Core
|
|||
|
||||
namespace Scripting
|
||||
{
|
||||
class NativeScriptManager;
|
||||
class NativeScriptMgr;
|
||||
}
|
||||
|
||||
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
|
||||
|
|
54
src/servers/sapphire_zone/Framework.cpp
Normal file
54
src/servers/sapphire_zone/Framework.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <boost/make_shared.hpp>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
Core::ServerZone g_serverZone( "config/settings_zone.xml" );
|
||||
|
||||
Core::Logger& Core::Framework::getLogger()
|
||||
{
|
||||
g_log.debug( "loogu" );
|
||||
return g_log;
|
||||
}
|
||||
|
||||
Core::DebugCommandHandler& Core::Framework::getDebugCommandHandler()
|
||||
{
|
||||
g_log.debug( "debugu" );
|
||||
return g_debugCmdHandler;
|
||||
}
|
||||
|
||||
Core::Scripting::ScriptMgr& Core::Framework::getScriptMgr()
|
||||
{
|
||||
g_log.debug( "sukiriputo" );
|
||||
return g_scriptMgr;
|
||||
}
|
||||
|
||||
Core::Data::ExdDataGenerated& Core::Framework::getExdDataGen()
|
||||
{
|
||||
g_log.debug( "ekkusudegen" );
|
||||
return g_exdDataGen;
|
||||
}
|
||||
|
||||
Core::TerritoryMgr& Core::Framework::getTerritoryMgr()
|
||||
{
|
||||
g_log.debug( "teriitoru" );
|
||||
return g_territoryMgr;
|
||||
}
|
||||
|
||||
Core::LinkshellMgr& Core::Framework::getLinkshellMgr()
|
||||
{
|
||||
g_log.debug( "linkusheru" );
|
||||
return g_linkshellMgr;
|
||||
}
|
||||
|
||||
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection >& Core::Framework::getCharaDb()
|
||||
{
|
||||
g_log.debug( "chiyaradebee" );
|
||||
return g_charaDb;
|
||||
}
|
||||
|
||||
Core::ServerZone& Core::Framework::getServerZone()
|
||||
{
|
||||
g_log.debug( "seruvaa zone" );
|
||||
return g_serverZone;
|
||||
}
|
59
src/servers/sapphire_zone/Framework.h
Normal file
59
src/servers/sapphire_zone/Framework.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
#ifndef CORE_FRAMEWORK_H
|
||||
#define CORE_FRAMEWORK_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <map>
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Database/DbLoader.h>
|
||||
#include <common/Database/CharaDbConnection.h>
|
||||
#include <common/Database/DbWorkerPool.h>
|
||||
#include <common/Database/PreparedStatement.h>
|
||||
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "Linkshell/LinkshellMgr.h"
|
||||
|
||||
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
||||
class Framework
|
||||
{
|
||||
private:
|
||||
|
||||
Core::Logger g_log;
|
||||
Core::DebugCommandHandler g_debugCmdHandler;
|
||||
Core::Scripting::ScriptMgr g_scriptMgr;
|
||||
Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
Core::TerritoryMgr g_territoryMgr;
|
||||
Core::LinkshellMgr g_linkshellMgr;
|
||||
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
|
||||
public:
|
||||
|
||||
bool init();
|
||||
Core::Logger& getLogger();
|
||||
Core::DebugCommandHandler& getDebugCommandHandler();
|
||||
Core::Scripting::ScriptMgr& getScriptMgr();
|
||||
Core::Data::ExdDataGenerated& getExdDataGen();
|
||||
Core::TerritoryMgr& getTerritoryMgr();
|
||||
Core::LinkshellMgr& getLinkshellMgr();
|
||||
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection >& getCharaDb();
|
||||
Core::ServerZone& Core::Framework::getServerZone();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // CORE_FRAMEWORK_H
|
|
@ -1,27 +1,24 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/clamp.hpp>
|
||||
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
|
||||
#include "Inventory.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "ItemContainer.h"
|
||||
#include "Item.h"
|
||||
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/clamp.hpp>
|
||||
|
||||
#include "../Forwards.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "Inventory.h"
|
||||
#include "ItemContainer.h"
|
||||
#include "Item.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network;
|
||||
|
@ -135,7 +132,7 @@ Core::ItemPtr Core::Inventory::getItemAt( uint16_t containerId, uint8_t slotId )
|
|||
|
||||
Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity )
|
||||
{
|
||||
auto itemInfo = g_exdDataGen.get< Core::Data::Item >( catalogId );
|
||||
auto itemInfo = g_framework.getExdDataGen().get< Core::Data::Item >( catalogId );
|
||||
|
||||
uint8_t itemAmount = quantity;
|
||||
|
||||
|
@ -156,7 +153,7 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity
|
|||
pItem->setModelIds( itemInfo->modelMain, itemInfo->modelSub );
|
||||
pItem->setCategory( static_cast< ItemUICategory >( itemInfo->itemUICategory ) );
|
||||
|
||||
g_charaDb.execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
|
||||
g_framework.getCharaDb().execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
|
||||
std::to_string( m_pOwner->getId() ) + ", " +
|
||||
std::to_string( pItem->getUId() ) + ", " +
|
||||
std::to_string( pItem->getId() ) + ", " +
|
||||
|
@ -259,7 +256,7 @@ void Core::Inventory::updateCurrencyDb()
|
|||
|
||||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() );
|
||||
|
||||
g_charaDb.execute( query );
|
||||
g_framework.getCharaDb().execute( query );
|
||||
}
|
||||
|
||||
|
||||
|
@ -286,7 +283,7 @@ void Core::Inventory::updateCrystalDb()
|
|||
|
||||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() );
|
||||
|
||||
g_charaDb.execute( query );
|
||||
g_framework.getCharaDb().execute( query );
|
||||
}
|
||||
|
||||
void Core::Inventory::updateBagDb( InventoryType type )
|
||||
|
@ -306,7 +303,7 @@ void Core::Inventory::updateBagDb( InventoryType type )
|
|||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
||||
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
||||
|
||||
g_charaDb.execute( query );
|
||||
g_framework.getCharaDb().execute( query );
|
||||
}
|
||||
|
||||
bool Core::Inventory::isArmory( uint16_t containerId )
|
||||
|
@ -389,14 +386,14 @@ void Core::Inventory::updateMannequinDb( InventoryType type )
|
|||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
||||
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
||||
|
||||
g_log.Log( LoggingSeverity::debug, query );
|
||||
g_charaDb.execute( query );
|
||||
g_framework.getLogger().debug( query );
|
||||
g_framework.getCharaDb().execute( query );
|
||||
}
|
||||
|
||||
|
||||
void Core::Inventory::updateItemDb( Core::ItemPtr pItem ) const
|
||||
{
|
||||
g_charaDb.execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
|
||||
g_framework.getCharaDb().execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
|
||||
// TODO: add other attributes
|
||||
" WHERE itemId = " + std::to_string( pItem->getUId() ) );
|
||||
}
|
||||
|
@ -473,7 +470,7 @@ bool Core::Inventory::isObtainable( uint32_t catalogId, uint8_t quantity )
|
|||
int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint8_t quantity )
|
||||
{
|
||||
|
||||
auto itemInfo = g_exdDataGen.get< Core::Data::Item >( catalogId );
|
||||
auto itemInfo = g_framework.getExdDataGen().get< Core::Data::Item >( catalogId );
|
||||
|
||||
// if item data doesn't exist or it's a blank field
|
||||
if( !itemInfo || itemInfo->levelItem == 0 )
|
||||
|
@ -506,7 +503,7 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
|
|||
|
||||
m_inventoryMap[inventoryId]->setItem( rSlotId, item );
|
||||
|
||||
g_charaDb.execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) +
|
||||
g_framework.getCharaDb().execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) +
|
||||
" WHERE storageId = " + std::to_string( inventoryId ) +
|
||||
" AND CharacterId = " + std::to_string( m_pOwner->getId() ) );
|
||||
|
||||
|
@ -650,13 +647,13 @@ void Core::Inventory::discardItem( uint16_t fromInventoryId, uint8_t fromSlotId
|
|||
Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
|
||||
{
|
||||
// load actual item
|
||||
auto itemRes = g_charaDb.query( "SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
|
||||
auto itemRes = g_framework.getCharaDb().query( "SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
|
||||
if( !itemRes->next() )
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
auto itemInfo = g_exdDataGen.get< Core::Data::Item >( itemRes->getUInt( 1 ) );
|
||||
auto itemInfo = g_framework.getExdDataGen().get< Core::Data::Item >( itemRes->getUInt( 1 ) );
|
||||
bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false;
|
||||
ItemPtr pItem( new Item( uId,
|
||||
itemRes->getUInt( 1 ),
|
||||
|
@ -678,7 +675,7 @@ bool Core::Inventory::load()
|
|||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// load active gearset
|
||||
auto res = g_charaDb.query( "SELECT storageId, container_0, container_1, container_2, container_3, "
|
||||
auto res = g_framework.getCharaDb().query( "SELECT storageId, container_0, container_1, container_2, container_3, "
|
||||
"container_4, container_5, container_6, container_7, "
|
||||
"container_8, container_9, container_10, container_11, "
|
||||
"container_12, container_13 "
|
||||
|
@ -708,7 +705,7 @@ bool Core::Inventory::load()
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load Bags
|
||||
auto bagRes = g_charaDb.query( "SELECT storageId, "
|
||||
auto bagRes = g_framework.getCharaDb().query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11, container_12, container_13, container_14, "
|
||||
|
@ -741,7 +738,7 @@ bool Core::Inventory::load()
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load Currency
|
||||
auto curRes = g_charaDb.query( "SELECT storageId, "
|
||||
auto curRes = g_framework.getCharaDb().query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11 "
|
||||
|
@ -770,7 +767,7 @@ bool Core::Inventory::load()
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load Crystals
|
||||
auto crystalRes = g_charaDb.query( "SELECT storageId, "
|
||||
auto crystalRes = g_framework.getCharaDb().query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11, container_12, container_13, container_14, "
|
||||
|
@ -877,7 +874,7 @@ uint16_t Core::Inventory::calculateEquippedGearItemLevel()
|
|||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( "Is one handed" );
|
||||
g_framework.getLogger().debug( "Is one handed" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -927,7 +924,7 @@ uint32_t Core::Inventory::getNextUId()
|
|||
{
|
||||
uint32_t charId = 0;
|
||||
|
||||
auto pQR = g_charaDb.query( "SELECT MAX(ItemId) FROM charaglobalitem" );
|
||||
auto pQR = g_framework.getCharaDb().query( "SELECT MAX(ItemId) FROM charaglobalitem" );
|
||||
|
||||
if( !pQR->next() )
|
||||
return 0x00500001;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include <common/Common.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
|
||||
#include "Framework.h"
|
||||
#include "Item.h"
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::Item::Item()
|
||||
{
|
||||
|
@ -24,7 +26,7 @@ Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t mo
|
|||
m_model2( model2 ),
|
||||
m_isHq( isHq )
|
||||
{
|
||||
auto itemInfo = g_exdDataGen.get< Core::Data::Item >( catalogId );
|
||||
auto itemInfo = g_framework.getExdDataGen().get< Core::Data::Item >( catalogId );
|
||||
m_delayMs = itemInfo->delayms;
|
||||
m_physicalDmg = itemInfo->damagePhys;
|
||||
m_magicalDmg = itemInfo->damageMag;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#include "../Forwards.h"
|
||||
#include "ItemContainer.h"
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
|
@ -8,9 +5,11 @@
|
|||
#include "Actor/Player.h"
|
||||
|
||||
#include "Item.h"
|
||||
#include "Framework.h"
|
||||
#include "Forwards.h"
|
||||
#include "ItemContainer.h"
|
||||
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::ItemContainer::ItemContainer( uint16_t locationId ) :
|
||||
m_id( locationId ),
|
||||
|
@ -40,15 +39,15 @@ void Core::ItemContainer::removeItem( uint8_t slotId )
|
|||
|
||||
if( it != m_itemMap.end() )
|
||||
{
|
||||
g_charaDb.execute( "DELETE FROM charaglobalitem WHERE itemId = " + std::to_string( it->second->getUId() ) );
|
||||
g_framework.getCharaDb().execute( "DELETE FROM charaglobalitem WHERE itemId = " + std::to_string( it->second->getUId() ) );
|
||||
|
||||
m_itemMap.erase( it );
|
||||
|
||||
g_log.debug( "Dropped item from slot " + std::to_string( slotId ) );
|
||||
g_framework.getLogger().debug( "Dropped item from slot " + std::to_string( slotId ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( "Item could not be dropped from slot " + std::to_string( slotId ) );
|
||||
g_framework.getLogger().debug( "Item could not be dropped from slot " + std::to_string( slotId ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +78,7 @@ Core::ItemPtr Core::ItemContainer::getItem( uint8_t slotId )
|
|||
|
||||
if( ( slotId > m_size ) || ( slotId == -1 ) )
|
||||
{
|
||||
g_log.error( "Slot out of range " + std::to_string( slotId ) );
|
||||
g_framework.getLogger().error( "Slot out of range " + std::to_string( slotId ) );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#include "LinkshellMgr.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
|
||||
#include "Linkshell.h"
|
||||
#include "Framework.h"
|
||||
#include "LinkshellMgr.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::LinkshellMgr::LinkshellMgr()
|
||||
{
|
||||
|
@ -15,7 +17,7 @@ Core::LinkshellMgr::LinkshellMgr()
|
|||
bool Core::LinkshellMgr::loadLinkshells()
|
||||
{
|
||||
|
||||
auto res = g_charaDb.query( "SELECT LinkshellId, MasterCharacterId, CharacterIdList, "
|
||||
auto res = g_framework.getCharaDb().query( "SELECT LinkshellId, MasterCharacterId, CharacterIdList, "
|
||||
"LinkshellName, LeaderIdList, InviteIdList "
|
||||
"FROM infolinkshell "
|
||||
"ORDER BY LinkshellId ASC;" );
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
#include "Actor/Actor.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "CalcBattle.h"
|
||||
|
||||
#include "CalcBattle.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Math;
|
||||
using namespace Core::Entity;
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
|
||||
/*
|
||||
Class used for battle-related formulas and calculations.
|
||||
Big thanks to the Theoryjerks group!
|
||||
|
@ -30,8 +32,8 @@ extern Core::Data::ExdDataGenerated g_exdDataGen;
|
|||
|
||||
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
||||
{
|
||||
auto classInfo = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = g_exdDataGen.get< Core::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
auto classInfo = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
|
||||
if ( !classInfo || !paramGrowthInfo )
|
||||
return 0;
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
#include "Actor/Actor.h"
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "CalcStats.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Core::Math;
|
||||
using namespace Core::Entity;
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
/*
|
||||
Class used for battle-related formulas and calculations.
|
||||
|
@ -61,8 +62,8 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
|||
// 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
|
||||
|
||||
auto classInfo = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = g_exdDataGen.get< Core::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
auto classInfo = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
|
||||
if ( !classInfo || !paramGrowthInfo )
|
||||
return 0;
|
||||
|
@ -94,8 +95,8 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
|||
|
||||
uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer )
|
||||
{
|
||||
auto classInfo = g_exdDataGen.get< Core::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = g_exdDataGen.get< Core::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
auto classInfo = g_framework.getExdDataGen().get< Core::Data::ClassJob >( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfo = g_framework.getExdDataGen().get< Core::Data::ParamGrow >( pPlayer->getLevel() );
|
||||
|
||||
if ( !classInfo || !paramGrowthInfo )
|
||||
return 0;
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Network/PacketContainer.h>
|
||||
#include <common/Network/GamePacketParser.h>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "GameConnection.h"
|
||||
|
||||
#include "ServerZone.h"
|
||||
#include "Session.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "Framework.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
extern Core::DebugCommandHandler g_gameCommandMgr;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -109,13 +112,13 @@ void Core::Network::GameConnection::OnAccept( const std::string & host, uint16_t
|
|||
GameConnectionPtr connection( new GameConnection( m_hive, m_pAcceptor ) );
|
||||
m_pAcceptor->Accept( connection );
|
||||
|
||||
g_log.info( "Connect from " + m_socket.remote_endpoint().address().to_string() );
|
||||
g_framework.getLogger().info( "Connect from " + m_socket.remote_endpoint().address().to_string() );
|
||||
}
|
||||
|
||||
|
||||
void Core::Network::GameConnection::OnDisconnect()
|
||||
{
|
||||
g_log.debug( "GameConnection DISCONNECT" );
|
||||
g_framework.getLogger().debug( "GameConnection DISCONNECT" );
|
||||
m_pSession = nullptr;
|
||||
}
|
||||
|
||||
|
@ -128,14 +131,14 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
|||
|
||||
if( headerResult == Incomplete )
|
||||
{
|
||||
g_log.info( "Dropping connection due to incomplete packet header." );
|
||||
g_log.info( "FIXME: Packet message bounary is not implemented." );
|
||||
g_framework.getLogger().info( "Dropping connection due to incomplete packet header." );
|
||||
g_framework.getLogger().info( "FIXME: Packet message bounary is not implemented." );
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
else if( headerResult == Malformed )
|
||||
{
|
||||
g_log.info( "Dropping connection due to malformed packet header." );
|
||||
g_framework.getLogger().info( "Dropping connection due to malformed packet header." );
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
@ -147,14 +150,14 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
|||
|
||||
if( packetResult == Incomplete )
|
||||
{
|
||||
g_log.info( "Dropping connection due to incomplete packets." );
|
||||
g_log.info( "FIXME: Packet message bounary is not implemented." );
|
||||
g_framework.getLogger().info( "Dropping connection due to incomplete packets." );
|
||||
g_framework.getLogger().info( "FIXME: Packet message bounary is not implemented." );
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
else if( packetResult == Malformed )
|
||||
{
|
||||
g_log.info( "Dropping connection due to malformed packets." );
|
||||
g_framework.getLogger().info( "Dropping connection due to malformed packets." );
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
@ -165,7 +168,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
|||
|
||||
void Core::Network::GameConnection::OnError( const boost::system::error_code & error )
|
||||
{
|
||||
g_log.debug( "GameConnection ERROR: " + error.message() );
|
||||
g_framework.getLogger().debug( "GameConnection ERROR: " + error.message() );
|
||||
}
|
||||
|
||||
void Core::Network::GameConnection::queueInPacket( Core::Network::Packets::GamePacketPtr inPacket )
|
||||
|
@ -192,7 +195,7 @@ void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket&
|
|||
if( pPacket.getSubType() != PingHandler &&
|
||||
pPacket.getSubType() != UpdatePositionHandler )
|
||||
|
||||
g_log.debug( sessionStr + " Handling Zone IPC : " + name + "( " +
|
||||
g_framework.getLogger().debug( sessionStr + " Handling Zone IPC : " + name + "( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
|
||||
|
@ -200,10 +203,10 @@ void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket&
|
|||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( sessionStr + " Undefined Zone IPC : Unknown ( " +
|
||||
g_framework.getLogger().debug( sessionStr + " Undefined Zone IPC : Unknown ( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
g_log.debug( "\n" + pPacket.toString() );
|
||||
g_framework.getLogger().debug( "\n" + pPacket.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +223,7 @@ void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket&
|
|||
std::string name = itStr != m_chatHandlerStrMap.end() ? itStr->second : "unknown";
|
||||
// dont display packet notification if it is a ping or pos update, don't want the spam
|
||||
|
||||
g_log.debug( sessionStr + " Handling Chat IPC : " + name + "( " +
|
||||
g_framework.getLogger().debug( sessionStr + " Handling Chat IPC : " + name + "( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
|
||||
|
@ -228,10 +231,10 @@ void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket&
|
|||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( sessionStr + " Undefined Chat IPC : Unknown ( " +
|
||||
g_framework.getLogger().debug( sessionStr + " Undefined Chat IPC : Unknown ( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
g_log.debug( pPacket.toString() );
|
||||
g_framework.getLogger().debug( pPacket.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +290,7 @@ void Core::Network::GameConnection::processOutQueue()
|
|||
{
|
||||
if( pPacket->getSize() == 0 )
|
||||
{
|
||||
g_log.debug( "end of packet set" );
|
||||
g_framework.getLogger().debug( "end of packet set" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -374,23 +377,23 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
|||
auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() );
|
||||
|
||||
// try to retrieve the session for this id
|
||||
auto session = g_serverZone.getSession( playerId );
|
||||
auto session = g_framework.getServerZone().getSession( playerId );
|
||||
|
||||
if( !session )
|
||||
{
|
||||
g_log.info( "[" + std::string( id ) + "] Session not registered, creating" );
|
||||
g_framework.getLogger().info( "[" + std::string( id ) + "] Session not registered, creating" );
|
||||
// return;
|
||||
if( !g_serverZone.createSession( playerId ) )
|
||||
if( !g_framework.getServerZone().createSession( playerId ) )
|
||||
{
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
session = g_serverZone.getSession( playerId );
|
||||
session = g_framework.getServerZone().getSession( playerId );
|
||||
}
|
||||
//TODO: Catch more things in lobby and send real errors
|
||||
else if( !session->isValid() || ( session->getPlayer() && session->getPlayer()->getLastPing() != 0 ) )
|
||||
{
|
||||
g_log.error( "[" + std::string(id) + "] Session INVALID, disconnecting" );
|
||||
g_framework.getLogger().error( "[" + std::string(id) + "] Session INVALID, disconnecting" );
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
@ -411,7 +414,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
|||
pPe = GamePacket( 0x00, 0x38, 0, 0, 0x02 );
|
||||
pPe.setValAt< uint32_t >( 0x10, playerId );
|
||||
sendSinglePacket( &pPe );
|
||||
g_log.info( "[" + std::string( id ) + "] Setting session for zone connection" );
|
||||
g_framework.getLogger().info( "[" + std::string( id ) + "] Setting session for zone connection" );
|
||||
session->setZoneConnection( pCon );
|
||||
}
|
||||
// chat connection, assinging it to the session
|
||||
|
@ -421,7 +424,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
|||
pPe.setValAt< uint32_t >( 0x10, playerId );
|
||||
sendSinglePacket( &pPe );
|
||||
|
||||
g_log.info( "[" + std::string( id ) + "] Setting session for chat connection" );
|
||||
g_framework.getLogger().info( "[" + std::string( id ) + "] Setting session for chat connection" );
|
||||
session->setChatConnection( pCon );
|
||||
pPe = GamePacket( 0x02, 0x28, playerId, playerId, 0x03 );
|
||||
sendSinglePacket( &pPe );
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
#include <common/Network/GamePacketNew.h>
|
||||
|
@ -5,15 +7,10 @@
|
|||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Network/PacketContainer.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
#include "Network/PacketWrappers/PingPacket.h"
|
||||
#include "Network/PacketWrappers/MoveActorPacket.h"
|
||||
|
@ -27,17 +24,22 @@
|
|||
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Event/EventHelper.h"
|
||||
|
||||
#include "Action/Action.h"
|
||||
#include "Action/ActionTeleport.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::DebugCommandHandler g_gameCommandMgr;
|
||||
#include "Session.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -53,7 +55,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
|
|||
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x2C );
|
||||
uint64_t param3 = inPacket.getValAt< uint64_t >( 0x38 );
|
||||
|
||||
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " +
|
||||
boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) +
|
||||
"\nparam1: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t ) ( param1 & 0xFFFFFFFFFFFFFFF ) ) +
|
||||
"\nparam2: " + boost::str( boost::format( "%|08X|" ) % ( uint32_t ) ( param2 & 0xFFFFFFFF ) ) +
|
||||
|
@ -200,11 +202,11 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
|
|||
case 0xCA: // Teleport
|
||||
{
|
||||
// TODO: only register this action if enough gil is in possession
|
||||
auto targetAetheryte = g_exdDataGen.get< Core::Data::Aetheryte >( param11 );
|
||||
auto targetAetheryte = g_framework.getExdDataGen().get< Core::Data::Aetheryte >( param11 );
|
||||
|
||||
if( targetAetheryte )
|
||||
{
|
||||
auto fromAetheryte = g_exdDataGen.get< Core::Data::Aetheryte >( g_exdDataGen.get< Core::Data::TerritoryType >( player.getZoneId() )->aetheryte );
|
||||
auto fromAetheryte = g_framework.getExdDataGen().get< Core::Data::Aetheryte >( g_framework.getExdDataGen().get< Core::Data::TerritoryType >( player.getZoneId() )->aetheryte );
|
||||
|
||||
// calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets
|
||||
auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->aetherstreamX - targetAetheryte->aetherstreamX, 2 ) +
|
||||
|
@ -236,7 +238,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
|
|||
}
|
||||
default:
|
||||
{
|
||||
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +
|
||||
g_framework.getLogger().debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +
|
||||
boost::str( boost::format( "%|04X|" ) % (uint32_t) ( commandId & 0xFFFF ) ) );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -3,24 +3,26 @@
|
|||
#include <common/Network/GamePacketNew.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Network/PacketContainer.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Session.h"
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
||||
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Framework.h"
|
||||
#include "Session.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -70,11 +72,11 @@ void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& i
|
|||
cfCancelPacket.data().state2 = 1; // Your registration is withdrawn.
|
||||
queueOutPacket( cfCancelPacket );
|
||||
|
||||
auto cfCondition = g_exdDataGen.get< Core::Data::ContentFinderCondition >( contentId1 );
|
||||
auto cfCondition = g_framework.getExdDataGen().get< Core::Data::ContentFinderCondition >( contentId1 );
|
||||
if( !cfCondition )
|
||||
return;
|
||||
|
||||
auto instance = g_territoryMgr.createInstanceContent( cfCondition->instanceContent );
|
||||
auto instance = g_framework.getTerritoryMgr().createInstanceContent( cfCondition->instanceContent );
|
||||
if( !instance )
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
|
@ -5,10 +7,7 @@
|
|||
#include <common/Network/PacketContainer.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Session.h"
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
@ -16,13 +15,17 @@
|
|||
#include "Network/PacketWrappers/EventStartPacket.h"
|
||||
#include "Network/PacketWrappers/EventFinishPacket.h"
|
||||
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "Forwards.h"
|
||||
#include "Event/EventHelper.h"
|
||||
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Event/EventHelper.h"
|
||||
#include "Session.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -49,10 +52,10 @@ void Core::Network::GameConnection::eventHandlerTalk( const Packets::GamePacket&
|
|||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||
player.eventStart( actorId, eventId, Event::EventHandler::Talk, 0, 0 );
|
||||
|
||||
if( !g_scriptMgr.onTalk( player, actorId, eventId ) &&
|
||||
if( !g_framework.getScriptMgr().onTalk( player, actorId, eventId ) &&
|
||||
eventType == Event::EventHandler::EventHandlerType::Quest )
|
||||
{
|
||||
auto questInfo = g_exdDataGen.get< Core::Data::Quest >( eventId );
|
||||
auto questInfo = g_framework.getExdDataGen().get< Core::Data::Quest >( eventId );
|
||||
if ( questInfo )
|
||||
player.sendUrgent( "Quest not implemented: " + questInfo->name + " (" + questInfo->id + ")" );
|
||||
}
|
||||
|
@ -84,10 +87,10 @@ void Core::Network::GameConnection::eventHandlerEmote( const Packets::GamePacket
|
|||
|
||||
player.eventStart( actorId, eventId, Event::EventHandler::Emote, 0, emoteId );
|
||||
|
||||
if( !g_scriptMgr.onEmote( player, actorId, eventId, static_cast< uint8_t >( emoteId ) ) &&
|
||||
if( !g_framework.getScriptMgr().onEmote( player, actorId, eventId, static_cast< uint8_t >( emoteId ) ) &&
|
||||
eventType == Event::EventHandler::EventHandlerType::Quest )
|
||||
{
|
||||
auto questInfo = g_exdDataGen.get< Core::Data::Quest >( eventId );
|
||||
auto questInfo = g_framework.getExdDataGen().get< Core::Data::Quest >( eventId );
|
||||
if( questInfo )
|
||||
player.sendUrgent( "Quest not implemented: " + questInfo->name );
|
||||
}
|
||||
|
@ -112,7 +115,7 @@ void Core::Network::GameConnection::eventHandlerWithinRange( const Packets::Game
|
|||
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 );
|
||||
|
||||
g_scriptMgr.onWithinRange( player, eventId, param1, x, y, z );
|
||||
g_framework.getScriptMgr().onWithinRange( player, eventId, param1, x, y, z );
|
||||
|
||||
player.checkEvent( eventId );
|
||||
}
|
||||
|
@ -134,7 +137,7 @@ void Core::Network::GameConnection::eventHandlerOutsideRange( const Packets::Gam
|
|||
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 );
|
||||
|
||||
g_scriptMgr.onOutsideRange( player, eventId, param1, x, y, z );
|
||||
g_framework.getScriptMgr().onOutsideRange( player, eventId, param1, x, y, z );
|
||||
|
||||
player.checkEvent( eventId );
|
||||
}
|
||||
|
@ -154,7 +157,7 @@ void Core::Network::GameConnection::eventHandlerEnterTerritory( const Packets::G
|
|||
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::EnterTerritory, 0, player.getZoneId() );
|
||||
|
||||
g_scriptMgr.onEnterTerritory( player, eventId, param1, param2 );
|
||||
g_framework.getScriptMgr().onEnterTerritory( player, eventId, param1, param2 );
|
||||
|
||||
player.checkEvent( eventId );
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
#include <common/Network/GamePacketNew.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Network/PacketContainer.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/InitUIPacket.h"
|
||||
#include "Network/PacketWrappers/PingPacket.h"
|
||||
#include "Network/PacketWrappers/MoveActorPacket.h"
|
||||
|
@ -27,17 +24,22 @@
|
|||
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Event/EventHelper.h"
|
||||
|
||||
#include "Action/Action.h"
|
||||
#include "Action/ActionTeleport.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
extern Core::DebugCommandHandler g_gameCommandMgr;
|
||||
#include "Session.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -100,7 +102,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 );
|
||||
uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 );
|
||||
|
||||
g_log.debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) +
|
||||
g_framework.getLogger().debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) +
|
||||
", params: " + std::to_string( param1 ) + ", " +
|
||||
std::to_string( param2 ) + ", " + std::to_string( param3 ) );
|
||||
|
||||
|
@ -401,19 +403,19 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
}
|
||||
case GmCommand::Teri:
|
||||
{
|
||||
if( auto instance = g_territoryMgr.getInstanceZonePtr( param1 ) )
|
||||
if( auto instance = g_framework.getTerritoryMgr().getInstanceZonePtr( param1 ) )
|
||||
{
|
||||
player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) );
|
||||
|
||||
player.setInstance( instance );
|
||||
}
|
||||
else if( !g_territoryMgr.isValidTerritory( param1 ) )
|
||||
else if( !g_framework.getTerritoryMgr().isValidTerritory( param1 ) )
|
||||
{
|
||||
player.sendUrgent( "Invalid zone " + std::to_string( param1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pZone = g_territoryMgr.getZoneByTerriId( param1 );
|
||||
auto pZone = g_framework.getTerritoryMgr().getZoneByTerriId( param1 );
|
||||
if( !pZone )
|
||||
{
|
||||
player.sendUrgent( "No zone instance found for " + std::to_string( param1 ) );
|
||||
|
@ -463,9 +465,9 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
|
|||
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
|
||||
std::string param1 = inPacket.getStringAt( 0x34 );
|
||||
|
||||
g_log.debug( player.getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 );
|
||||
g_framework.getLogger().debug( player.getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 );
|
||||
|
||||
auto targetSession = g_serverZone.getSession( param1 );
|
||||
auto targetSession = g_framework.getServerZone().getSession( param1 );
|
||||
Core::Entity::ActorPtr targetActor;
|
||||
|
||||
if( targetSession != nullptr )
|
||||
|
|
|
@ -1,36 +1,43 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
#include <common/Network/GamePacketNew.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Network/PacketContainer.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::DebugCommandHandler g_gameCommandMgr;
|
||||
#include "Session.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
enum InventoryOperation
|
||||
{
|
||||
Discard = 0x07,
|
||||
Move = 0x08,
|
||||
Swap = 0x09,
|
||||
Merge = 0x0C,
|
||||
Split = 0x0A
|
||||
};
|
||||
|
||||
void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GamePacket& inPacket,
|
||||
Entity::Player& player )
|
||||
|
@ -48,38 +55,38 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP
|
|||
player.queuePacket( ackPacket );
|
||||
|
||||
|
||||
g_log.debug( inPacket.toString() );
|
||||
g_log.debug( "InventoryAction: " + std::to_string( action ) );
|
||||
g_framework.getLogger().debug( inPacket.toString() );
|
||||
g_framework.getLogger().debug( "InventoryAction: " + std::to_string( action ) );
|
||||
|
||||
// TODO: other inventory operations need to be implemented
|
||||
switch( action )
|
||||
{
|
||||
|
||||
case 0x07: // discard item action
|
||||
case InventoryOperation::Discard: // discard item action
|
||||
{
|
||||
player.getInventory()->discardItem( fromContainer, fromSlot );
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x08: // move item action
|
||||
case InventoryOperation::Move: // move item action
|
||||
{
|
||||
player.getInventory()->moveItem( fromContainer, fromSlot, toContainer, toSlot );
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x09: // swap item action
|
||||
case InventoryOperation::Swap: // swap item action
|
||||
{
|
||||
player.getInventory()->swapItem( fromContainer, fromSlot, toContainer, toSlot );
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0C: // merge stack action
|
||||
case InventoryOperation::Merge: // merge stack action
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0A: // split stack action
|
||||
case InventoryOperation::Split: // split stack action
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
#include <common/Network/GamePacketNew.h>
|
||||
|
@ -6,12 +8,8 @@
|
|||
#include <common/Network/PacketDef/Chat/ServerChatDef.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
|
@ -29,18 +27,22 @@
|
|||
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Event/EventHelper.h"
|
||||
|
||||
#include "Action/Action.h"
|
||||
#include "Action/ActionTeleport.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
extern Core::DebugCommandHandler g_gameCommandMgr;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -282,7 +284,7 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
|
|||
void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket,
|
||||
Entity::Player& player )
|
||||
{
|
||||
g_log.info( "[" + std::to_string( player.getId() ) + "] Setting EquipDisplayFlags to " + std::to_string( inPacket.getValAt< uint8_t >( 0x20 ) ) );
|
||||
g_framework.getLogger().info( "[" + std::to_string( player.getId() ) + "] Setting EquipDisplayFlags to " + std::to_string( inPacket.getValAt< uint8_t >( 0x20 ) ) );
|
||||
player.setEquipDisplayFlags( inPacket.getValAt< uint8_t >( 0x20 ) );
|
||||
}
|
||||
|
||||
|
@ -295,7 +297,7 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
|
|||
|
||||
auto pZone = player.getCurrentZone();
|
||||
|
||||
auto pLine = g_territoryMgr.getTerritoryPosition( zoneLineId );
|
||||
auto pLine = g_framework.getTerritoryMgr().getTerritoryPosition( zoneLineId );
|
||||
|
||||
Common::FFXIVARR_POSITION3 targetPos{};
|
||||
uint32_t targetZone;
|
||||
|
@ -334,7 +336,7 @@ void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket&
|
|||
{
|
||||
uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
|
||||
|
||||
auto pQR = g_charaDb.query( "SELECT id, map_id, discover_id "
|
||||
auto pQR = g_framework.getCharaDb().query( "SELECT id, map_id, discover_id "
|
||||
"FROM discoveryinfo "
|
||||
"WHERE id = " + std::to_string( ref_position_id ) + ";" );
|
||||
|
||||
|
@ -493,7 +495,7 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
|
|||
if( chatString.at( 0 ) == '!' )
|
||||
{
|
||||
// execute game console command
|
||||
g_gameCommandMgr.execCommand( const_cast< char * >( chatString.c_str() ) + 1, player );
|
||||
g_framework.getDebugCommandHandler().execCommand( const_cast< char * >( chatString.c_str() ) + 1, player );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -550,7 +552,7 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
|
|||
std::string targetPcName = inPacket.getStringAt( 0x21 );
|
||||
std::string msg = inPacket.getStringAt( 0x41 );
|
||||
|
||||
auto pSession = g_serverZone.getSession( targetPcName );
|
||||
auto pSession = g_framework.getServerZone().getSession( targetPcName );
|
||||
|
||||
if( !pSession )
|
||||
{
|
||||
|
@ -558,7 +560,7 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
|
|||
strcpy( tellErrPacket.data().receipientName, targetPcName.c_str() );
|
||||
sendSinglePacket( tellErrPacket );
|
||||
|
||||
g_log.debug( "TargetPc not found" );
|
||||
g_framework.getLogger().debug( "TargetPc not found" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/CommonNetwork.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
|
@ -5,12 +7,7 @@
|
|||
#include <common/Network/PacketContainer.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Session.h"
|
||||
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
@ -23,17 +20,17 @@
|
|||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Action/Action.h"
|
||||
#include "Action/ActionCast.h"
|
||||
#include "Action/ActionMount.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Logger g_log;
|
||||
#include "Session.h"
|
||||
#include "Forwards.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -60,7 +57,7 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
|
|||
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
|
||||
player.sendDebug( "---------------------------------------" );
|
||||
player.sendDebug( "ActionHandler ( " + actionIdStr + " | " +
|
||||
g_exdDataGen.get< Core::Data::Action >( action )->name +
|
||||
g_framework.getExdDataGen().get< Core::Data::Action >( action )->name +
|
||||
" | " + std::to_string( targetId ) + " )" );
|
||||
|
||||
player.queuePacket( ActorControlPacket142( player.getId(), ActorControlType::ActionStart, 0x01, action ) );
|
||||
|
@ -83,7 +80,7 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
|
|||
|
||||
if( !player.actionHasCastTime( action ) )
|
||||
{
|
||||
g_scriptMgr.onCastFinish( player, targetActor, action );
|
||||
g_framework.getScriptMgr().onCastFinish( player, targetActor, action );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,11 +97,11 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
|
|||
}
|
||||
else if( action < 3000000 ) // item action
|
||||
{
|
||||
auto info = g_exdDataGen.get< Core::Data::EventItem >( action );
|
||||
auto info = g_framework.getExdDataGen().get< Core::Data::EventItem >( action );
|
||||
if( info )
|
||||
{
|
||||
g_log.debug( info->name );
|
||||
g_scriptMgr.onEventItem( player, action, info->quest, info->castTime, targetId );
|
||||
g_framework.getLogger().debug( info->name );
|
||||
g_framework.getScriptMgr().onEventItem( player, action, info->quest, info->castTime, targetId );
|
||||
}
|
||||
}
|
||||
else if( action > 3000000 ) // unknown
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "NativeScriptManager.h"
|
||||
#include "NativeScriptMgr.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Scripting {
|
||||
|
||||
bool NativeScriptManager::loadScript( const std::string& path )
|
||||
bool NativeScriptMgr::loadScript( const std::string& path )
|
||||
{
|
||||
auto module = m_loader.loadModule( path );
|
||||
if( !module )
|
||||
|
@ -41,12 +41,12 @@ namespace Scripting {
|
|||
return true;
|
||||
}
|
||||
|
||||
const std::string NativeScriptManager::getModuleExtension()
|
||||
const std::string NativeScriptMgr::getModuleExtension()
|
||||
{
|
||||
return m_loader.getModuleExtension();
|
||||
}
|
||||
|
||||
bool NativeScriptManager::unloadScript( const std::string& name )
|
||||
bool NativeScriptMgr::unloadScript( const std::string& name )
|
||||
{
|
||||
auto info = m_loader.getScriptInfo( name );
|
||||
if( !info )
|
||||
|
@ -55,7 +55,7 @@ namespace Scripting {
|
|||
return unloadScript( info );
|
||||
}
|
||||
|
||||
bool NativeScriptManager::unloadScript( ScriptInfo* info )
|
||||
bool NativeScriptMgr::unloadScript( ScriptInfo* info )
|
||||
{
|
||||
for( auto& script : info->scripts )
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ namespace Scripting {
|
|||
return m_loader.unloadScript( info );
|
||||
}
|
||||
|
||||
void NativeScriptManager::queueScriptReload( const std::string &name )
|
||||
void NativeScriptMgr::queueScriptReload( const std::string &name )
|
||||
{
|
||||
auto info = m_loader.getScriptInfo( name );
|
||||
if( !info )
|
||||
|
@ -82,7 +82,7 @@ namespace Scripting {
|
|||
m_scriptLoadQueue.push( libPath );
|
||||
}
|
||||
|
||||
void NativeScriptManager::processLoadQueue()
|
||||
void NativeScriptMgr::processLoadQueue()
|
||||
{
|
||||
std::vector< std::string > deferredLoads;
|
||||
|
||||
|
@ -104,21 +104,21 @@ namespace Scripting {
|
|||
}
|
||||
}
|
||||
|
||||
void NativeScriptManager::findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search )
|
||||
void NativeScriptMgr::findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search )
|
||||
{
|
||||
return m_loader.findScripts( scripts, search );
|
||||
}
|
||||
|
||||
bool NativeScriptManager::isModuleLoaded( const std::string &name )
|
||||
bool NativeScriptMgr::isModuleLoaded( const std::string &name )
|
||||
{
|
||||
return m_loader.isModuleLoaded( name );
|
||||
}
|
||||
|
||||
|
||||
|
||||
boost::shared_ptr< NativeScriptManager > createNativeScriptMgr()
|
||||
boost::shared_ptr< NativeScriptMgr > createNativeScriptMgr()
|
||||
{
|
||||
return boost::make_shared< NativeScriptManager >();
|
||||
return boost::make_shared< NativeScriptMgr >();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
namespace Core {
|
||||
namespace Scripting {
|
||||
|
||||
class NativeScriptManager
|
||||
class NativeScriptMgr
|
||||
{
|
||||
protected:
|
||||
std::unordered_map< std::size_t, std::unordered_map< uint32_t, ScriptObject* > > m_scripts;
|
||||
|
@ -28,7 +28,7 @@ namespace Scripting {
|
|||
bool unloadScript( ScriptInfo* info );
|
||||
|
||||
public:
|
||||
NativeScriptManager( ) = default;
|
||||
NativeScriptMgr( ) = default;
|
||||
|
||||
bool loadScript( const std::string& path );
|
||||
bool unloadScript( const std::string& name );
|
||||
|
@ -55,7 +55,7 @@ namespace Scripting {
|
|||
|
||||
|
||||
|
||||
boost::shared_ptr< NativeScriptManager > createNativeScriptMgr();
|
||||
boost::shared_ptr< NativeScriptMgr > createNativeScriptMgr();
|
||||
} }
|
||||
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
#include "ScriptLoader.h"
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Config/XMLConfig.h>
|
||||
#include "ServerZone.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Config/XMLConfig.h>
|
||||
|
||||
#include "ScriptLoader.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
|
@ -35,14 +35,14 @@ bool Core::Scripting::ScriptLoader::unloadModule( ModuleHandle handle )
|
|||
bool success = dlclose( handle ) == 0;
|
||||
#endif
|
||||
|
||||
if( !success )
|
||||
if ( !success )
|
||||
{
|
||||
g_log.error( "Failed to unload module @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) );
|
||||
g_framework.getLogger().error( "Failed to unload module @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
g_log.debug( "Unloaded module @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) );
|
||||
g_framework.getLogger().debug( "Unloaded module @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -53,12 +53,12 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
|
|||
|
||||
if ( isModuleLoaded( f.stem().string() ) )
|
||||
{
|
||||
g_log.error( "Unable to load module '" + f.stem().string() + "' as it is already loaded" );
|
||||
g_framework.getLogger().error( "Unable to load module '" + f.stem().string() + "' as it is already loaded" );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// copy to temp dir
|
||||
fs::path cacheDir( f.parent_path() /= g_serverZone.getConfig()->getValue< std::string >( "Settings.General.Scripts.CachePath", "./cache/" ) );
|
||||
fs::path cacheDir( f.parent_path() /= g_framework.getServerZone().getConfig()->getValue< std::string >( "Settings.General.Scripts.CachePath", "./cache/" ) );
|
||||
fs::create_directories( cacheDir );
|
||||
fs::path dest( cacheDir /= f.filename().string() );
|
||||
|
||||
|
@ -66,7 +66,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
|
|||
{
|
||||
fs::copy_file( f, dest, fs::copy_option::overwrite_if_exists );
|
||||
}
|
||||
catch( const boost::filesystem::filesystem_error& err )
|
||||
catch ( const boost::filesystem::filesystem_error& err )
|
||||
{
|
||||
g_log.error( "Error copying file to cache: " + err.code().message() );
|
||||
|
||||
|
@ -80,14 +80,14 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
|
|||
ModuleHandle handle = dlopen( dest.string().c_str(), RTLD_LAZY );
|
||||
#endif
|
||||
|
||||
if( !handle )
|
||||
if ( !handle )
|
||||
{
|
||||
g_log.error( "Failed to load module from: " + path );
|
||||
g_framework.getLogger().error( "Failed to load module from: " + path );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
g_log.debug( "Loaded module '" + f.filename().string() + "' @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) );
|
||||
g_framework.getLogger().debug( "Loaded module '" + f.filename().string() + "' @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) );
|
||||
|
||||
auto info = new ScriptInfo;
|
||||
info->handle = handle;
|
||||
|
@ -102,7 +102,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
|
|||
|
||||
ScriptObject** Core::Scripting::ScriptLoader::getScripts( ModuleHandle handle )
|
||||
{
|
||||
using getScripts = ScriptObject**(*)();
|
||||
using getScripts = ScriptObject**( *)( );
|
||||
|
||||
#ifdef _WIN32
|
||||
getScripts func = reinterpret_cast< getScripts >( GetProcAddress( handle, "getScripts" ) );
|
||||
|
@ -110,11 +110,11 @@ ScriptObject** Core::Scripting::ScriptLoader::getScripts( ModuleHandle handle )
|
|||
getScripts func = reinterpret_cast< getScripts >( dlsym( handle, "getScripts" ) );
|
||||
#endif
|
||||
|
||||
if( func )
|
||||
if ( func )
|
||||
{
|
||||
auto ptr = func();
|
||||
|
||||
g_log.debug( "got ScriptObject array @ 0x" + boost::str( boost::format( "%|08X|" ) % ptr ) );
|
||||
g_framework.getLogger().debug( "got ScriptObject array @ 0x" + boost::str( boost::format( "%|08X|" ) % ptr ) );
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ bool Core::Scripting::ScriptLoader::unloadScript( Core::Scripting::ScriptInfo* i
|
|||
|
||||
bool Core::Scripting::ScriptLoader::unloadScript( ModuleHandle handle )
|
||||
{
|
||||
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
for ( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
{
|
||||
if( it->second->handle == handle )
|
||||
if ( it->second->handle == handle )
|
||||
{
|
||||
auto info = it->second;
|
||||
|
||||
if( unloadModule( handle ) )
|
||||
if ( unloadModule( handle ) )
|
||||
{
|
||||
m_scriptMap.erase( it );
|
||||
|
||||
|
@ -147,7 +147,7 @@ bool Core::Scripting::ScriptLoader::unloadScript( ModuleHandle handle )
|
|||
return true;
|
||||
}
|
||||
|
||||
g_log.error( "failed to unload module: " + info->library_name );
|
||||
g_framework.getLogger().error( "failed to unload module: " + info->library_name );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -158,9 +158,9 @@ bool Core::Scripting::ScriptLoader::unloadScript( ModuleHandle handle )
|
|||
|
||||
bool Core::Scripting::ScriptLoader::isModuleLoaded( std::string name )
|
||||
{
|
||||
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
for ( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
{
|
||||
if( boost::iequals( it->second->library_name, name ) )
|
||||
if ( boost::iequals( it->second->library_name, name ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -169,9 +169,9 @@ bool Core::Scripting::ScriptLoader::isModuleLoaded( std::string name )
|
|||
|
||||
Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::getScriptInfo( std::string name )
|
||||
{
|
||||
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
for ( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
{
|
||||
if( it->second->library_name == name )
|
||||
if ( it->second->library_name == name )
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
@ -182,9 +182,9 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::getScriptInfo( std::
|
|||
|
||||
void Core::Scripting::ScriptLoader::findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search )
|
||||
{
|
||||
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
for ( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||
{
|
||||
if( it->second->library_name.find( search ) != std::string::npos )
|
||||
if ( it->second->library_name.find( search ) != std::string::npos )
|
||||
{
|
||||
scripts.insert( it->second );
|
||||
}
|
||||
|
|
|
@ -1,56 +1,59 @@
|
|||
#include <common/Logging/Logger.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Config/XMLConfig.h>
|
||||
|
||||
#include "NativeScriptManager.h"
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/BattleNpc.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include "Event/EventHelper.h"
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Config/XMLConfig.h>
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/BattleNpc.h"
|
||||
|
||||
#include "Event/EventHandler.h"
|
||||
#include "Event/EventHelper.h"
|
||||
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "NativeScriptMgr.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Framework.h"
|
||||
|
||||
// enable the ambiguity fix for every platform to avoid #define nonsense
|
||||
#define WIN_AMBIGUITY_FIX
|
||||
#include <libraries/external/watchdog/Watchdog.h>
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::Scripting::ScriptManager::ScriptManager() :
|
||||
Core::Scripting::ScriptMgr::ScriptMgr() :
|
||||
m_firstScriptChangeNotificiation( false )
|
||||
{
|
||||
m_nativeScriptManager = createNativeScriptMgr();
|
||||
m_nativeScriptMgr = createNativeScriptMgr();
|
||||
}
|
||||
|
||||
Core::Scripting::ScriptManager::~ScriptManager()
|
||||
Core::Scripting::ScriptMgr::~ScriptMgr()
|
||||
{
|
||||
Watchdog::unwatchAll();
|
||||
}
|
||||
|
||||
void Core::Scripting::ScriptManager::update()
|
||||
void Core::Scripting::ScriptMgr::update()
|
||||
{
|
||||
m_nativeScriptManager->processLoadQueue();
|
||||
m_nativeScriptMgr->processLoadQueue();
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::init()
|
||||
bool Core::Scripting::ScriptMgr::init()
|
||||
{
|
||||
std::set< std::string > files;
|
||||
|
||||
loadDir( g_serverZone.getConfig()->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ),
|
||||
files, m_nativeScriptManager->getModuleExtension() );
|
||||
loadDir( g_framework.getServerZone().getConfig()->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ),
|
||||
files, m_nativeScriptMgr->getModuleExtension() );
|
||||
|
||||
uint32_t scriptsFound = 0;
|
||||
uint32_t scriptsLoaded = 0;
|
||||
|
@ -61,24 +64,24 @@ bool Core::Scripting::ScriptManager::init()
|
|||
|
||||
scriptsFound++;
|
||||
|
||||
if( m_nativeScriptManager->loadScript( path ) )
|
||||
if( m_nativeScriptMgr->loadScript( path ) )
|
||||
scriptsLoaded++;
|
||||
}
|
||||
|
||||
g_log.info( "ScriptManager: Loaded " + std::to_string( scriptsLoaded ) + "/" + std::to_string( scriptsFound ) + " scripts successfully" );
|
||||
g_framework.getLogger().info( "ScriptMgr: Loaded " + std::to_string( scriptsLoaded ) + "/" + std::to_string( scriptsFound ) + " scripts successfully" );
|
||||
|
||||
watchDirectories();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Core::Scripting::ScriptManager::watchDirectories()
|
||||
void Core::Scripting::ScriptMgr::watchDirectories()
|
||||
{
|
||||
auto shouldWatch = g_serverZone.getConfig()->getValue< bool >( "Settings.General.Scripts.HotSwap.Enabled", true );
|
||||
auto shouldWatch = g_framework.getServerZone().getConfig()->getValue< bool >( "Settings.General.Scripts.HotSwap.Enabled", true );
|
||||
if( !shouldWatch )
|
||||
return;
|
||||
|
||||
Watchdog::watchMany( g_serverZone.getConfig()->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ) + "*" + m_nativeScriptManager->getModuleExtension(),
|
||||
Watchdog::watchMany( g_framework.getServerZone().getConfig()->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ) + "*" + m_nativeScriptMgr->getModuleExtension(),
|
||||
[ this ]( const std::vector< ci::fs::path >& paths )
|
||||
{
|
||||
if( !m_firstScriptChangeNotificiation )
|
||||
|
@ -91,26 +94,26 @@ void Core::Scripting::ScriptManager::watchDirectories()
|
|||
|
||||
for( auto path : paths )
|
||||
{
|
||||
if( m_nativeScriptManager->isModuleLoaded( path.stem().string() ) )
|
||||
if( m_nativeScriptMgr->isModuleLoaded( path.stem().string() ) )
|
||||
{
|
||||
g_log.debug( "Reloading changed script: " + path.stem().string() );
|
||||
g_framework.getLogger().debug( "Reloading changed script: " + path.stem().string() );
|
||||
|
||||
m_nativeScriptManager->queueScriptReload( path.stem( ).string( ));
|
||||
m_nativeScriptMgr->queueScriptReload( path.stem( ).string( ));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( "Loading new script: " + path.stem().string() );
|
||||
g_framework.getLogger().debug( "Loading new script: " + path.stem().string() );
|
||||
|
||||
m_nativeScriptManager->loadScript( path.string() );
|
||||
m_nativeScriptMgr->loadScript( path.string() );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Core::Scripting::ScriptManager::loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext )
|
||||
void Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext )
|
||||
{
|
||||
|
||||
g_log.info( "ScriptEngine: loading scripts from " + dirname );
|
||||
g_framework.getLogger().info( "ScriptEngine: loading scripts from " + dirname );
|
||||
|
||||
boost::filesystem::path targetDir( dirname );
|
||||
|
||||
|
@ -126,7 +129,7 @@ void Core::Scripting::ScriptManager::loadDir( const std::string& dirname, std::s
|
|||
}
|
||||
}
|
||||
|
||||
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
|
||||
void Core::Scripting::ScriptMgr::onPlayerFirstEnterWorld( Entity::Player& player )
|
||||
{
|
||||
// try
|
||||
// {
|
||||
|
@ -139,13 +142,13 @@ void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& pl
|
|||
// }
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
||||
bool Core::Scripting::ScriptMgr::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
||||
uint32_t bnpcNameId, uint32_t modelId, std::string aiName )
|
||||
{
|
||||
return g_serverZone.registerBnpcTemplate( templateName, bnpcBaseId, bnpcNameId, modelId, aiName );
|
||||
return g_framework.getServerZone().registerBnpcTemplate( templateName, bnpcBaseId, bnpcNameId, modelId, aiName );
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
|
||||
bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
|
||||
{
|
||||
|
||||
uint16_t eventType = eventId >> 16;
|
||||
|
@ -154,60 +157,60 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac
|
|||
// aethernet/aetherytes need to be handled separately
|
||||
if( eventType == Event::EventHandler::EventHandlerType::Aetheryte )
|
||||
{
|
||||
auto aetherInfo = g_exdDataGen.get< Core::Data::Aetheryte >( eventId & 0xFFFF );
|
||||
auto aetherInfo = g_framework.getExdDataGen().get< Core::Data::Aetheryte >( eventId & 0xFFFF );
|
||||
scriptId = EVENTSCRIPT_AETHERYTE_ID;
|
||||
if( !aetherInfo->isAetheryte )
|
||||
scriptId = EVENTSCRIPT_AETHERNET_ID;
|
||||
}
|
||||
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( scriptId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( scriptId );
|
||||
if( !script )
|
||||
return false;
|
||||
script->onTalk( eventId, player, actorId );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, uint32_t eventId,
|
||||
bool Core::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId,
|
||||
uint16_t param1, uint16_t param2 )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( eventId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( eventId );
|
||||
if( !script )
|
||||
return false;
|
||||
script->onEnterZone( player, eventId, param1, param2 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||
bool Core::Scripting::ScriptMgr::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||
float x, float y, float z )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( eventId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( eventId );
|
||||
if( !script )
|
||||
return false;
|
||||
script->onWithinRange( player, eventId, param1, x, y, z );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||
bool Core::Scripting::ScriptMgr::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||
float x, float y, float z )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( eventId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( eventId );
|
||||
if( !script )
|
||||
return false;
|
||||
script->onOutsideRange( player, eventId, param1, x, y, z );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t actorId,
|
||||
bool Core::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t actorId,
|
||||
uint32_t eventId, uint8_t emoteId )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( eventId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( eventId );
|
||||
if( !script )
|
||||
return false;
|
||||
script->onEmote( actorId, eventId, emoteId, player );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onEventHandlerReturn( Entity::Player& player, uint32_t eventId,
|
||||
bool Core::Scripting::ScriptMgr::onEventHandlerReturn( Entity::Player& player, uint32_t eventId,
|
||||
uint16_t subEvent, uint16_t param1, uint16_t param2,
|
||||
uint16_t param3 )
|
||||
{
|
||||
|
@ -215,10 +218,10 @@ bool Core::Scripting::ScriptManager::onEventHandlerReturn( Entity::Player& playe
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId,
|
||||
bool Core::Scripting::ScriptMgr::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId,
|
||||
uint16_t subEvent, uint16_t param, uint32_t catalogId )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( eventId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( eventId );
|
||||
if( script )
|
||||
{
|
||||
script->onEventHandlerTradeReturn( player, eventId, subEvent, param, catalogId );
|
||||
|
@ -228,14 +231,14 @@ bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player&
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32_t eventItemId,
|
||||
bool Core::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32_t eventItemId,
|
||||
uint32_t eventId, uint32_t castTime, uint64_t targetId )
|
||||
{
|
||||
std::string eventName = "onEventItem";
|
||||
std::string objName = Event::getEventName( eventId );
|
||||
player.sendDebug( "Calling: " + objName + "." + eventName + " - " + std::to_string( eventId ) );
|
||||
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( eventId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( eventId );
|
||||
if( script )
|
||||
{
|
||||
player.eventStart( targetId, eventId, Event::EventHandler::Item, 0, 0 );
|
||||
|
@ -247,7 +250,7 @@ bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t nameId )
|
||||
bool Core::Scripting::ScriptMgr::onMobKill( Entity::Player& player, uint16_t nameId )
|
||||
{
|
||||
std::string eventName = "onBnpcKill_" + std::to_string( nameId );
|
||||
|
||||
|
@ -261,7 +264,7 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
|
|||
|
||||
uint16_t questId = activeQuests->c.questId;
|
||||
|
||||
auto script = m_nativeScriptManager->getScript< EventScript >( questId );
|
||||
auto script = m_nativeScriptMgr->getScript< EventScript >( questId );
|
||||
if( script )
|
||||
{
|
||||
std::string objName = Event::getEventName( 0x00010000 | questId );
|
||||
|
@ -275,18 +278,18 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
|
||||
bool Core::Scripting::ScriptMgr::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< ActionScript >( actionId );
|
||||
auto script = m_nativeScriptMgr->getScript< ActionScript >( actionId );
|
||||
|
||||
if( script )
|
||||
script->onCastFinish( player, *pTarget );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
||||
bool Core::Scripting::ScriptMgr::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< StatusEffectScript >( effectId );
|
||||
auto script = m_nativeScriptMgr->getScript< StatusEffectScript >( effectId );
|
||||
|
||||
if( script )
|
||||
{
|
||||
|
@ -300,9 +303,9 @@ bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, u
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect )
|
||||
bool Core::Scripting::ScriptMgr::onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< StatusEffectScript >( effect.getId() );
|
||||
auto script = m_nativeScriptMgr->getScript< StatusEffectScript >( effect.getId() );
|
||||
if( script )
|
||||
{
|
||||
if( pActor->isPlayer() )
|
||||
|
@ -315,9 +318,9 @@ bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId )
|
||||
bool Core::Scripting::ScriptMgr::onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< StatusEffectScript >( effectId );
|
||||
auto script = m_nativeScriptMgr->getScript< StatusEffectScript >( effectId );
|
||||
if( script )
|
||||
{
|
||||
if( pActor->isPlayer() )
|
||||
|
@ -330,9 +333,9 @@ bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, u
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
||||
bool Core::Scripting::ScriptMgr::onZoneInit( ZonePtr pZone )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< ZoneScript >( pZone->getTerritoryId() );
|
||||
auto script = m_nativeScriptMgr->getScript< ZoneScript >( pZone->getTerritoryId() );
|
||||
if( script )
|
||||
{
|
||||
script->onZoneInit();
|
||||
|
@ -342,9 +345,9 @@ bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onInstanceInit( InstanceContent& instance )
|
||||
bool Core::Scripting::ScriptMgr::onInstanceInit( InstanceContent& instance )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< InstanceContentScript >( instance.getInstanceContentId() );
|
||||
auto script = m_nativeScriptMgr->getScript< InstanceContentScript >( instance.getInstanceContentId() );
|
||||
if( script )
|
||||
{
|
||||
script->onInit( instance );
|
||||
|
@ -354,9 +357,9 @@ bool Core::Scripting::ScriptManager::onInstanceInit( InstanceContent& instance )
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onInstanceUpdate( InstanceContent& instance, uint32_t currTime )
|
||||
bool Core::Scripting::ScriptMgr::onInstanceUpdate( InstanceContent& instance, uint32_t currTime )
|
||||
{
|
||||
auto script = m_nativeScriptManager->getScript< InstanceContentScript >( instance.getInstanceContentId() );
|
||||
auto script = m_nativeScriptMgr->getScript< InstanceContentScript >( instance.getInstanceContentId() );
|
||||
if( script )
|
||||
{
|
||||
script->onUpdate( instance, currTime );
|
||||
|
@ -366,7 +369,7 @@ bool Core::Scripting::ScriptManager::onInstanceUpdate( InstanceContent& instance
|
|||
return false;
|
||||
}
|
||||
|
||||
Scripting::NativeScriptManager& Core::Scripting::ScriptManager::getNativeScriptHandler()
|
||||
Scripting::NativeScriptMgr& Core::Scripting::ScriptMgr::getNativeScriptHandler()
|
||||
{
|
||||
return *m_nativeScriptManager;
|
||||
return *m_nativeScriptMgr;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _SCRIPTMANAGER_H_
|
||||
#define _SCRIPTMANAGER_H_
|
||||
#ifndef _ScriptMgr_H_
|
||||
#define _ScriptMgr_H_
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <mutex>
|
||||
|
@ -13,11 +13,11 @@ namespace Core
|
|||
namespace Scripting
|
||||
{
|
||||
|
||||
class ScriptManager
|
||||
class ScriptMgr
|
||||
{
|
||||
private:
|
||||
|
||||
boost::shared_ptr< NativeScriptManager > m_nativeScriptManager;
|
||||
boost::shared_ptr< NativeScriptMgr > m_nativeScriptMgr;
|
||||
|
||||
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
|
||||
// auto fn = m_pChaiHandler->eval< std::function<const std::string( Entity::Player ) > >( "onFirstEnterWorld" );
|
||||
|
@ -25,8 +25,8 @@ namespace Core
|
|||
bool m_firstScriptChangeNotificiation;
|
||||
|
||||
public:
|
||||
ScriptManager();
|
||||
~ScriptManager();
|
||||
ScriptMgr();
|
||||
~ScriptMgr();
|
||||
|
||||
bool init();
|
||||
void reload();
|
||||
|
@ -64,7 +64,7 @@ namespace Core
|
|||
|
||||
void loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext );
|
||||
|
||||
NativeScriptManager& getNativeScriptHandler();
|
||||
NativeScriptMgr& getNativeScriptHandler();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
#include "Linkshell/LinkshellMgr.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
|
@ -35,13 +35,9 @@
|
|||
#include <thread>
|
||||
#include <common/Util/Util.h>
|
||||
|
||||
Core::Logger g_log;
|
||||
Core::DebugCommandHandler g_gameCommandMgr;
|
||||
Core::Scripting::ScriptManager g_scriptMgr;
|
||||
Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
Core::TerritoryMgr g_territoryMgr;
|
||||
Core::LinkshellMgr g_linkshellMgr;
|
||||
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
#include "Framework.h"
|
||||
|
||||
Core::Framework g_framework;
|
||||
|
||||
Core::ServerZone::ServerZone( const std::string& configPath )
|
||||
: m_configPath( configPath ),
|
||||
|
@ -73,7 +69,7 @@ bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t
|
|||
|
||||
if( it != m_bnpcTemplates.end() )
|
||||
{
|
||||
g_log.error( templateName + " already registered, skipping..." );
|
||||
g_framework.getLogger().error( templateName + " already registered, skipping..." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -95,11 +91,11 @@ Core::Entity::BattleNpcTemplatePtr Core::ServerZone::getBnpcTemplate( std::strin
|
|||
|
||||
bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||
{
|
||||
g_log.info( "Loading config " + m_configPath );
|
||||
g_framework.getLogger().info( "Loading config " + m_configPath );
|
||||
|
||||
if( !m_pConfig->loadConfig( m_configPath ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config " + m_configPath );
|
||||
g_framework.getLogger().fatal( "Error loading config " + m_configPath );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -157,15 +153,15 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
|||
}
|
||||
catch( ... )
|
||||
{
|
||||
g_log.error( "Error parsing argument: " + arg + " " + "value: " + val + "\n" );
|
||||
g_log.error( "Usage: <arg> <val> \n" );
|
||||
g_framework.getLogger().error( "Error parsing argument: " + arg + " " + "value: " + val + "\n" );
|
||||
g_framework.getLogger().error( "Usage: <arg> <val> \n" );
|
||||
}
|
||||
}
|
||||
|
||||
g_log.info( "Setting up generated EXD data" );
|
||||
if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) )
|
||||
g_framework.getLogger().info( "Setting up generated EXD data" );
|
||||
if( !g_framework.getExdDataGen().init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) )
|
||||
{
|
||||
g_log.fatal( "Error setting up generated EXD data " );
|
||||
g_framework.getLogger().fatal( "Error setting up generated EXD data " );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -180,7 +176,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
|||
info.syncThreads = m_pConfig->getValue< uint8_t >( "Settings.General.Mysql.SyncThreads", 2 );
|
||||
info.asyncThreads = m_pConfig->getValue< uint8_t >( "Settings.General.Mysql.AsyncThreads", 2 );
|
||||
|
||||
loader.addDb( g_charaDb, info );
|
||||
loader.addDb( g_framework.getCharaDb(), info );
|
||||
if( !loader.initDbs() )
|
||||
return false;
|
||||
|
||||
|
@ -193,37 +189,42 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
|||
void Core::ServerZone::run( int32_t argc, char* argv[] )
|
||||
{
|
||||
// TODO: add more error checks for the entire initialisation
|
||||
g_log.setLogPath( "log/SapphireZone_" );
|
||||
g_log.init();
|
||||
/*g_log.setLogPath( "log/SapphireZone_" );
|
||||
g_log.init();*/
|
||||
|
||||
printBanner();
|
||||
|
||||
g_framework.getLogger().setLogPath( "log/SapphireZone_" );
|
||||
g_framework.getLogger().init();
|
||||
|
||||
|
||||
|
||||
if( !loadSettings( argc, argv ) )
|
||||
{
|
||||
g_log.fatal( "Unable to load settings!" );
|
||||
g_framework.getLogger().fatal( "Unable to load settings!" );
|
||||
return;
|
||||
}
|
||||
|
||||
g_log.info( "LinkshellMgr: Caching linkshells" );
|
||||
if( !g_linkshellMgr.loadLinkshells() )
|
||||
g_framework.getLogger().info( "LinkshellMgr: Caching linkshells" );
|
||||
if( !g_framework.getLinkshellMgr().loadLinkshells() )
|
||||
{
|
||||
g_log.fatal( "Unable to load linkshells!" );
|
||||
g_framework.getLogger().fatal( "Unable to load linkshells!" );
|
||||
return;
|
||||
}
|
||||
|
||||
Network::HivePtr hive( new Network::Hive() );
|
||||
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive );
|
||||
|
||||
g_scriptMgr.init();
|
||||
g_framework.getScriptMgr().init();
|
||||
|
||||
g_log.info( "TerritoryMgr: Setting up zones" );
|
||||
g_territoryMgr.init();
|
||||
g_framework.getLogger().info( "TerritoryMgr: Setting up zones" );
|
||||
g_framework.getTerritoryMgr().init();
|
||||
|
||||
std::vector< std::thread > thread_list;
|
||||
thread_list.emplace_back( std::thread( std::bind( &Network::Hive::Run, hive.get() ) ) );
|
||||
|
||||
g_log.info( "Server listening on port: " + std::to_string( m_port ) );
|
||||
g_log.info( "Ready for connections..." );
|
||||
g_framework.getLogger().info( "Server listening on port: " + std::to_string( m_port ) );
|
||||
g_framework.getLogger().info( "Ready for connections..." );
|
||||
|
||||
mainLoop();
|
||||
|
||||
|
@ -236,12 +237,12 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
|
|||
|
||||
void Core::ServerZone::printBanner() const
|
||||
{
|
||||
g_log.info("===========================================================" );
|
||||
g_log.info( "Sapphire Server Project " );
|
||||
g_log.info( "Version: " + Version::VERSION );
|
||||
g_log.info( "Git Hash: " + Version::GIT_HASH );
|
||||
g_log.info( "Compiled: " __DATE__ " " __TIME__ );
|
||||
g_log.info( "===========================================================" );
|
||||
g_framework.getLogger().info("===========================================================" );
|
||||
g_framework.getLogger().info( "Sapphire Server Project " );
|
||||
g_framework.getLogger().info( "Version: " + Version::VERSION );
|
||||
g_framework.getLogger().info( "Git Hash: " + Version::GIT_HASH );
|
||||
g_framework.getLogger().info( "Compiled: " __DATE__ " " __TIME__ );
|
||||
g_framework.getLogger().info( "===========================================================" );
|
||||
}
|
||||
|
||||
void Core::ServerZone::mainLoop()
|
||||
|
@ -253,9 +254,9 @@ void Core::ServerZone::mainLoop()
|
|||
|
||||
auto currTime = Util::getTimeSeconds();
|
||||
|
||||
g_territoryMgr.updateTerritoryInstances( currTime );
|
||||
g_framework.getTerritoryMgr().updateTerritoryInstances( currTime );
|
||||
|
||||
g_scriptMgr.update();
|
||||
g_framework.getScriptMgr().update();
|
||||
|
||||
lock_guard< std::mutex > lock( this->m_sessionMutex );
|
||||
for( auto sessionIt : this->m_sessionMapById )
|
||||
|
@ -274,7 +275,7 @@ void Core::ServerZone::mainLoop()
|
|||
|
||||
if( currTime - m_lastDBPingTime > 3 )
|
||||
{
|
||||
g_charaDb.keepAlive();
|
||||
g_framework.getCharaDb().keepAlive();
|
||||
m_lastDBPingTime = currTime;
|
||||
}
|
||||
|
||||
|
@ -292,7 +293,7 @@ void Core::ServerZone::mainLoop()
|
|||
it->second->close();
|
||||
// if( it->second.unique() )
|
||||
{
|
||||
g_log.info("[" + std::to_string(it->second->getId() ) + "] Session removal" );
|
||||
g_framework.getLogger().info("[" + std::to_string(it->second->getId() ) + "] Session removal" );
|
||||
it = this->m_sessionMapById.erase( it );
|
||||
removeSession( pPlayer->getName() );
|
||||
continue;
|
||||
|
@ -302,7 +303,7 @@ void Core::ServerZone::mainLoop()
|
|||
// remove sessions that simply timed out
|
||||
if( diff > 20 )
|
||||
{
|
||||
g_log.info("[" + std::to_string( it->second->getId() ) + "] Session time out" );
|
||||
g_framework.getLogger().info("[" + std::to_string( it->second->getId() ) + "] Session time out" );
|
||||
|
||||
it->second->close();
|
||||
// if( it->second.unique() )
|
||||
|
@ -331,18 +332,18 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
|
|||
|
||||
if( it != m_sessionMapById.end() )
|
||||
{
|
||||
g_log.error( "[" + session_id_str + "] Error creating session" );
|
||||
g_framework.getLogger().error( "[" + session_id_str + "] Error creating session" );
|
||||
return false;
|
||||
}
|
||||
|
||||
g_log.info( "[" + session_id_str + "] Creating new session" );
|
||||
g_framework.getLogger().info( "[" + session_id_str + "] Creating new session" );
|
||||
|
||||
boost::shared_ptr<Session> newSession( new Session( sessionId ) );
|
||||
m_sessionMapById[sessionId] = newSession;
|
||||
|
||||
if( !newSession->loadPlayer() )
|
||||
{
|
||||
g_log.error( "[" + session_id_str + "] Error loading player " + session_id_str );
|
||||
g_framework.getLogger().error( "[" + session_id_str + "] Error loading player " + session_id_str );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
#include <boost/filesystem/operations.hpp>
|
||||
#include <time.h>
|
||||
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Network/PacketContainer.h>
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Session.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
extern Core::Logger g_log;
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Framework.h"
|
||||
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::Session::Session( uint32_t sessionId ) :
|
||||
m_sessionId( sessionId ),
|
||||
|
@ -145,7 +148,7 @@ void Core::Session::startReplay( const std::string& path )
|
|||
m_replayCache.push_back( std::tuple< uint64_t, std::string >(
|
||||
Util::getTimeMs() + ( std::get< 0 >( set ) - startTime ), std::get< 1 >( set ) ) );
|
||||
|
||||
g_log.info( "Registering " + std::get< 1 >( set ) + " for " + std::to_string( std::get< 0 >( set ) - startTime ) );
|
||||
g_framework.getLogger().info( "Registering " + std::get< 1 >( set ) + " for " + std::to_string( std::get< 0 >( set ) - startTime ) );
|
||||
}
|
||||
|
||||
getPlayer()->sendDebug( "Registered " + std::to_string( m_replayCache.size() ) + " sets for replay" );
|
||||
|
@ -167,7 +170,7 @@ void Core::Session::processReplay()
|
|||
{
|
||||
m_pZoneConnection->injectPacket( std::get< 1 >( set ), *getPlayer().get() );
|
||||
m_replayCache.erase( m_replayCache.begin() + at );
|
||||
//g_log.info( "Sent for " + std::to_string( std::get< 0 >( set ) ) + ", left: " + std::to_string( m_replayCache.size() ) );
|
||||
//g_framework.getLogger().info( "Sent for " + std::to_string( std::get< 0 >( set ) ) + ", left: " + std::to_string( m_replayCache.size() ) );
|
||||
}
|
||||
at++;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
#include <boost/algorithm/string.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Actor/Actor.h"
|
||||
|
||||
#include "StatusEffect.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
#include "StatusEffect.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
|
||||
|
||||
Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
|
||||
uint32_t duration, uint32_t tickRate )
|
||||
|
@ -30,7 +29,7 @@ Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr so
|
|||
, m_tickRate( tickRate )
|
||||
, m_lastTick( 0 )
|
||||
{
|
||||
auto entry = g_exdDataGen.get< Core::Data::Status >( id );
|
||||
auto entry = g_framework.getExdDataGen().get< Core::Data::Status >( id );
|
||||
m_name = entry->name;
|
||||
|
||||
std::replace( m_name.begin(), m_name.end(), ' ', '_' );
|
||||
|
@ -64,7 +63,7 @@ std::pair< uint8_t, uint32_t> Core::StatusEffect::StatusEffect::getTickEffect()
|
|||
void Core::StatusEffect::StatusEffect::onTick()
|
||||
{
|
||||
m_lastTick = Util::getTimeMs();
|
||||
g_scriptMgr.onStatusTick( m_targetActor, *this );
|
||||
g_framework.getScriptMgr().onStatusTick( m_targetActor, *this );
|
||||
}
|
||||
|
||||
uint32_t Core::StatusEffect::StatusEffect::getSrcActorId() const
|
||||
|
@ -104,14 +103,14 @@ void Core::StatusEffect::StatusEffect::applyStatus()
|
|||
//effectPacket.data().effects[4].unknown_5 = 0x80;
|
||||
//m_sourceActor->sendToInRangeSet( effectPacket, true );
|
||||
|
||||
g_log.debug( "StatusEffect applied: " + m_name );
|
||||
g_scriptMgr.onStatusReceive( m_targetActor, m_id );
|
||||
g_framework.getLogger().debug( "StatusEffect applied: " + m_name );
|
||||
g_framework.getScriptMgr().onStatusReceive( m_targetActor, m_id );
|
||||
}
|
||||
|
||||
void Core::StatusEffect::StatusEffect::removeStatus()
|
||||
{
|
||||
g_log.debug( "StatusEffect removed: " + m_name );
|
||||
g_scriptMgr.onStatusTimeOut( m_targetActor, m_id );
|
||||
g_framework.getLogger().debug( "StatusEffect removed: " + m_name );
|
||||
g_framework.getScriptMgr().onStatusTimeOut( m_targetActor, m_id );
|
||||
}
|
||||
|
||||
uint32_t Core::StatusEffect::StatusEffect::getId() const
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "InstanceContent.h"
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
@ -6,15 +5,17 @@
|
|||
#include <common/Util/UtilMath.h>
|
||||
|
||||
#include "Event/Director.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
#include "InstanceContent.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -31,7 +32,7 @@ Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceC
|
|||
m_instanceContentId( instanceContentId ),
|
||||
m_state( Created )
|
||||
{
|
||||
g_scriptMgr.onInstanceInit( *this );
|
||||
g_framework.getScriptMgr().onInstanceInit( *this );
|
||||
}
|
||||
|
||||
Core::InstanceContent::~InstanceContent()
|
||||
|
@ -51,7 +52,7 @@ Core::Data::ExdDataGenerated::InstanceContentPtr Core::InstanceContent::getInsta
|
|||
|
||||
void Core::InstanceContent::onEnterTerritory( Entity::Player& player )
|
||||
{
|
||||
g_log.debug( "InstanceContent::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|"
|
||||
g_framework.getLogger().debug( "InstanceContent::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|"
|
||||
+ std::to_string( getInstanceContentId() ) +
|
||||
+ ", Entity#" + std::to_string( player.getId() ) );
|
||||
|
||||
|
@ -67,7 +68,7 @@ void Core::InstanceContent::onEnterTerritory( Entity::Player& player )
|
|||
|
||||
void Core::InstanceContent::onLeaveTerritory( Entity::Player& player )
|
||||
{
|
||||
g_log.debug( "InstanceContent::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|"
|
||||
g_framework.getLogger().debug( "InstanceContent::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|"
|
||||
+ std::to_string( getInstanceContentId() ) +
|
||||
+ ", Entity#" + std::to_string( player.getId() ) );
|
||||
sendDirectorClear( player );
|
||||
|
@ -121,7 +122,7 @@ void Core::InstanceContent::onUpdate( uint32_t currTime )
|
|||
break;
|
||||
}
|
||||
|
||||
g_scriptMgr.onInstanceUpdate( *this, currTime );
|
||||
g_framework.getScriptMgr().onInstanceUpdate( *this, currTime );
|
||||
}
|
||||
|
||||
void Core::InstanceContent::onFinishLoading( Entity::Player& player )
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include "TerritoryMgr.h"
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
|
@ -9,9 +7,10 @@
|
|||
#include "Zone.h"
|
||||
#include "ZonePosition.h"
|
||||
#include "InstanceContent.h"
|
||||
#include "TerritoryMgr.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
Core::TerritoryMgr::TerritoryMgr() :
|
||||
m_lastInstanceId( 10000 )
|
||||
|
@ -21,11 +20,11 @@ Core::TerritoryMgr::TerritoryMgr() :
|
|||
|
||||
void Core::TerritoryMgr::loadTerritoryTypeDetailCache()
|
||||
{
|
||||
auto idList = g_exdDataGen.getTerritoryTypeIdList();
|
||||
auto idList = g_framework.getExdDataGen().getTerritoryTypeIdList();
|
||||
|
||||
for( auto id : idList )
|
||||
{
|
||||
auto teri1 = g_exdDataGen.get< Core::Data::TerritoryType >( id );
|
||||
auto teri1 = g_framework.getExdDataGen().get< Core::Data::TerritoryType >( id );
|
||||
|
||||
if( !teri1->name.empty() )
|
||||
m_territoryTypeDetailCacheMap[id] = teri1;
|
||||
|
@ -106,13 +105,13 @@ bool Core::TerritoryMgr::createDefaultTerritories()
|
|||
if( territoryInfo->name.empty() )
|
||||
continue;
|
||||
|
||||
auto pPlaceName = g_exdDataGen.get< Core::Data::PlaceName >( territoryInfo->placeName );
|
||||
auto pPlaceName = g_framework.getExdDataGen().get< Core::Data::PlaceName >( territoryInfo->placeName );
|
||||
|
||||
if( !pPlaceName || pPlaceName->name.empty() || !isDefaultTerritory( territoryId ) )
|
||||
continue;
|
||||
|
||||
uint32_t guid = getNextInstanceId();
|
||||
g_log.Log( LoggingSeverity::info, std::to_string( territoryId ) +
|
||||
g_framework.getLogger.info( std::to_string( territoryId ) +
|
||||
"\t" + std::to_string( guid ) +
|
||||
"\t" + std::to_string( territoryInfo->territoryIntendedUse ) +
|
||||
"\t" + territoryInfo->name +
|
||||
|
@ -142,12 +141,12 @@ Core::ZonePtr Core::TerritoryMgr::createTerritoryInstance( uint32_t territoryTyp
|
|||
return nullptr;
|
||||
|
||||
auto pTeri = getTerritoryDetail( territoryTypeId );
|
||||
auto pPlaceName = g_exdDataGen.get< Core::Data::PlaceName >( pTeri->placeName );
|
||||
auto pPlaceName = g_framework.getExdDataGen().get< Core::Data::PlaceName >( pTeri->placeName );
|
||||
|
||||
if( !pTeri || !pPlaceName )
|
||||
return nullptr;
|
||||
|
||||
g_log.debug( "Starting instance for territory: " + std::to_string( territoryTypeId ) + " (" + pPlaceName->name + ")" );
|
||||
g_framework.getLogger().debug( "Starting instance for territory: " + std::to_string( territoryTypeId ) + " (" + pPlaceName->name + ")" );
|
||||
|
||||
auto pZone = make_Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name );
|
||||
pZone->init();
|
||||
|
@ -160,7 +159,7 @@ Core::ZonePtr Core::TerritoryMgr::createTerritoryInstance( uint32_t territoryTyp
|
|||
|
||||
Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceContentId )
|
||||
{
|
||||
auto pInstanceContent = g_exdDataGen.get< Core::Data::InstanceContent >( instanceContentId );
|
||||
auto pInstanceContent = g_framework.getExdDataGen().get< Core::Data::InstanceContent >( instanceContentId );
|
||||
if( !pInstanceContent )
|
||||
return nullptr;
|
||||
|
||||
|
@ -172,7 +171,7 @@ Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceConten
|
|||
if( !pTeri || pInstanceContent->name.empty() )
|
||||
return nullptr;
|
||||
|
||||
g_log.debug( "Starting instance for InstanceContent id: " + std::to_string( instanceContentId ) +
|
||||
g_framework.getLogger().debug( "Starting instance for InstanceContent id: " + std::to_string( instanceContentId ) +
|
||||
" (" + pInstanceContent->name + ")" );
|
||||
|
||||
auto pZone = make_InstanceContent( pInstanceContent, getNextInstanceId(),
|
||||
|
@ -220,7 +219,7 @@ Core::ZonePtr Core::TerritoryMgr::getInstanceZonePtr( uint32_t instanceId ) cons
|
|||
|
||||
void Core::TerritoryMgr::loadTerritoryPositionMap()
|
||||
{
|
||||
auto pQR = g_charaDb.query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius FROM zonepositions;" );
|
||||
auto pQR = g_framework.getCharaDb().query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius FROM zonepositions;" );
|
||||
|
||||
while( pQR->next() )
|
||||
{
|
||||
|
@ -309,7 +308,7 @@ bool Core::TerritoryMgr::movePlayer( ZonePtr pZone, Core::Entity::PlayerPtr pPla
|
|||
{
|
||||
if( !pZone )
|
||||
{
|
||||
g_log.error( "Zone not found on this server." );
|
||||
g_framework.getLogger().error( "Zone not found on this server." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <common/Util/Util.h>
|
||||
|
@ -12,31 +13,24 @@
|
|||
#include <common/Network/PacketContainer.h>
|
||||
#include <common/Database/DatabaseDef.h>
|
||||
|
||||
#include "Zone.h"
|
||||
#include "TerritoryMgr.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Actor/Actor.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/BattleNpc.h"
|
||||
#include "Actor/EventNpc.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "Forwards.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
|
||||
#include "CellHandler.h"
|
||||
#include "Zone.h"
|
||||
#include "TerritoryMgr.h"
|
||||
#include "Framework.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
extern Core::TerritoryMgr g_territoryMgr;
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
/**
|
||||
* \brief
|
||||
|
@ -62,13 +56,13 @@ Core::Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& intern
|
|||
m_lastMobUpdate = 0;
|
||||
|
||||
m_weatherOverride = 0;
|
||||
m_territoryTypeInfo = g_exdDataGen.get< Core::Data::TerritoryType >( territoryId );
|
||||
m_territoryTypeInfo = g_framework.getExdDataGen().get< Core::Data::TerritoryType >( territoryId );
|
||||
|
||||
uint8_t weatherRateId = m_territoryTypeInfo->weatherRate > g_exdDataGen.getWeatherRateIdList().size() ?
|
||||
uint8_t weatherRateId = m_territoryTypeInfo->weatherRate > g_framework.getExdDataGen().getWeatherRateIdList().size() ?
|
||||
uint8_t{ 0 } : m_territoryTypeInfo->weatherRate;
|
||||
|
||||
uint8_t sumPc = 0;
|
||||
auto weatherRateFields = g_exdDataGen.m_WeatherRateDat.get_row( weatherRateId );
|
||||
auto weatherRateFields = g_framework.getExdDataGen().m_WeatherRateDat.get_row( weatherRateId );
|
||||
for( size_t i = 0; i < 16; )
|
||||
{
|
||||
int32_t weatherId = boost::get< int32_t >( weatherRateFields[i] );
|
||||
|
@ -92,7 +86,7 @@ bool Core::Zone::init()
|
|||
{
|
||||
memset( m_pCellCache, 0, sizeof( CellCache* ) * _sizeX );
|
||||
|
||||
if( g_scriptMgr.onZoneInit( shared_from_this() ) )
|
||||
if( g_framework.getScriptMgr().onZoneInit( shared_from_this() ) )
|
||||
{
|
||||
// all good
|
||||
}
|
||||
|
@ -152,7 +146,7 @@ Core::CellCache* Core::Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t cel
|
|||
|
||||
void Core::Zone::loadCellCache()
|
||||
{
|
||||
auto pQR = g_charaDb.query( "SELECT Id,"
|
||||
auto pQR = g_framework.getCharaDb().query( "SELECT Id,"
|
||||
"Zoneid,"
|
||||
"NameId,"
|
||||
"SizeId,"
|
||||
|
@ -298,7 +292,7 @@ void Core::Zone::pushActor( Entity::ActorPtr pActor )
|
|||
{
|
||||
auto pPlayer = pActor->getAsPlayer();
|
||||
|
||||
auto pSession = g_serverZone.getSession( pPlayer->getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( pPlayer->getId() );
|
||||
if( pSession )
|
||||
m_sessionSet.insert( pSession );
|
||||
m_playerMap[pPlayer->getId()] = pPlayer;
|
||||
|
@ -358,7 +352,7 @@ void Core::Zone::removeActor( Entity::ActorPtr pActor )
|
|||
|
||||
void Core::Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry )
|
||||
{
|
||||
if( g_territoryMgr.isPrivateTerritory( getTerritoryId() ) )
|
||||
if( g_framework.getTerritoryMgr().isPrivateTerritory( getTerritoryId() ) )
|
||||
return;
|
||||
|
||||
for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it )
|
||||
|
@ -372,7 +366,7 @@ void Core::Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t
|
|||
|
||||
if( ( distance < range ) && sourcePlayer.getId() != ( *it ).second->getId() )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( ( *it ).second->getId() );
|
||||
auto pSession = g_framework.getServerZone().getSession( ( *it ).second->getId() );
|
||||
pPacketEntry->setValAt< uint32_t >( 0x08, ( *it ).second->getId() );
|
||||
if( pSession )
|
||||
pSession->getZoneConnection()->queueOutPacket( pPacketEntry );
|
||||
|
@ -412,7 +406,7 @@ bool Core::Zone::checkWeather()
|
|||
if ( m_weatherOverride != m_currentWeather )
|
||||
{
|
||||
m_currentWeather = m_weatherOverride;
|
||||
g_log.debug( "[Zone:" + m_internalName + "] overriding weather to : " + std::to_string( m_weatherOverride ) );
|
||||
g_framework.getLogger().debug( "[Zone:" + m_internalName + "] overriding weather to : " + std::to_string( m_weatherOverride ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +416,7 @@ bool Core::Zone::checkWeather()
|
|||
if ( nextWeather != m_currentWeather )
|
||||
{
|
||||
m_currentWeather = nextWeather;
|
||||
g_log.debug( "[Zone:" + m_internalName + "] changing weather to : " + std::to_string( nextWeather ) );
|
||||
g_framework.getLogger().debug( "[Zone:" + m_internalName + "] changing weather to : " + std::to_string( nextWeather ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -681,7 +675,7 @@ void Core::Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
|
|||
return;
|
||||
|
||||
// TODO: make sure gms can overwrite this. Potentially temporary solution
|
||||
if( g_territoryMgr.isPrivateTerritory( getTerritoryId() ) )
|
||||
if( g_framework.getTerritoryMgr().isPrivateTerritory( getTerritoryId() ) )
|
||||
return;
|
||||
|
||||
Entity::ActorPtr pCurAct;
|
||||
|
@ -757,13 +751,13 @@ void Core::Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
|
|||
|
||||
void Core::Zone::onEnterTerritory( Entity::Player& player )
|
||||
{
|
||||
g_log.debug( "Zone::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryId() ) +
|
||||
g_framework.getLogger().debug( "Zone::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryId() ) +
|
||||
+ ", Entity#" + std::to_string( player.getId() ) );
|
||||
}
|
||||
|
||||
void Core::Zone::onLeaveTerritory( Entity::Player& player )
|
||||
{
|
||||
g_log.debug( "Zone::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryId() ) +
|
||||
g_framework.getLogger().debug( "Zone::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryId() ) +
|
||||
+ ", Entity#" + std::to_string( player.getId() ) );
|
||||
}
|
||||
|
||||
|
@ -791,7 +785,7 @@ void Core::Zone::registerInstanceObj( Entity::InstanceObjectPtr object )
|
|||
|
||||
m_instanceObjects[object->getId()] = object;
|
||||
|
||||
g_log.debug( "Registered instance eobj: " + std::to_string( object->getId() ) );
|
||||
g_framework.getLogger().debug( "Registered instance eobj: " + std::to_string( object->getId() ) );
|
||||
}
|
||||
|
||||
Core::Entity::InstanceObjectPtr Core::Zone::getInstanceObject( uint32_t objId )
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
#include "ServerZone.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
Core::ServerZone g_serverZone( "config/settings_zone.xml" );
|
||||
#include "Framework.h"
|
||||
|
||||
|
||||
|
||||
extern Core::Framework g_framework;
|
||||
|
||||
int main( int32_t argc, char* argv[] )
|
||||
{
|
||||
g_serverZone.run( argc, argv );
|
||||
//g_framework.init( g_serverZone );
|
||||
g_framework.getServerZone().run( argc, argv );
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue