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

Some refactoring and TODO tags

This commit is contained in:
Mordred 2017-10-01 18:38:58 +02:00
parent 0474a6f9ce
commit 69a7076e36
4 changed files with 62 additions and 63 deletions

View file

@ -54,6 +54,7 @@ Core::Entity::BattleNpc::BattleNpc( uint32_t modelId, uint32_t nameid, const Com
m_type = ActorType::BattleNpc; m_type = ActorType::BattleNpc;
m_mode = MODE_IDLE; m_mode = MODE_IDLE;
m_targetId = INVALID_GAME_OBJECT_ID;
m_maxHp = 150; m_maxHp = 150;
m_maxMp = 100; m_maxMp = 100;

View file

@ -113,7 +113,6 @@ uint32_t CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
return result; return result;
} }
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency ) uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
{ {
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() ); auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );

View file

@ -192,7 +192,7 @@ void Core::Entity::Player::prepareZoning( uint16_t targetZone, bool fadeOut, uin
preparePacket.data().targetZone = targetZone; preparePacket.data().targetZone = targetZone;
preparePacket.data().fadeOutTime = fadeOutTime; preparePacket.data().fadeOutTime = fadeOutTime;
preparePacket.data().animation = animation; preparePacket.data().animation = animation;
preparePacket.data().fadeOut = fadeOut == true ? 1 : 0; preparePacket.data().fadeOut = static_cast< uint8_t >( fadeOut ? 1 : 0 );
queuePacket( preparePacket ); queuePacket( preparePacket );
} }
@ -398,7 +398,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
if( isLogin() ) if( isLogin() )
{ {
GamePacketNew< FFXIVIpcCFAvailableContents, ServerZoneIpcType > contentFinderList( getId() ); GamePacketNew< FFXIVIpcCFAvailableContents, ServerZoneIpcType > contentFinderList( getId() );
for( auto i = 0; i < 72; i++ ) for( auto i = 0; i < sizeof( contentFinderList.data().contents ); i++ )
{ {
// unlock all contents for now // unlock all contents for now
contentFinderList.data().contents[i] = 0xFF; contentFinderList.data().contents[i] = 0xFF;
@ -632,7 +632,9 @@ void Core::Entity::Player::gainExp( uint32_t amount )
if( ( currentExp + amount ) >= neededExpToLevel ) if( ( currentExp + amount ) >= neededExpToLevel )
{ {
// levelup // levelup
amount = ( currentExp + amount - neededExpToLevel ) > neededExpToLevelplus1 ? neededExpToLevelplus1 - 1 : ( currentExp + amount - neededExpToLevel ); amount = ( currentExp + amount - neededExpToLevel ) > neededExpToLevelplus1 ?
neededExpToLevelplus1 - 1 :
( currentExp + amount - neededExpToLevel );
setExp( amount ); setExp( amount );
gainLevel(); gainLevel();
queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) ); queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) );
@ -791,50 +793,6 @@ void Core::Entity::Player::setLevelForClass( uint8_t level, Core::Common::ClassJ
setSyncFlag( PlayerSyncFlags::ExpLevel ); setSyncFlag( PlayerSyncFlags::ExpLevel );
} }
void Core::Entity::Player::eventActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,
ActionCallback interruptCallback,
uint64_t additional )
{
Action::ActionPtr pEventAction( new Action::EventAction( shared_from_this(), eventId, action,
finishCallback, interruptCallback, additional ) );
setCurrentAction( pEventAction );
auto pEvent = getEvent( eventId );
if( !pEvent && getEventCount() )
{
// We're trying to play a nested event, need to start it first.
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
pEvent = getEvent( eventId );
}
else if( !pEvent )
{
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
return;
}
if( pEvent )
pEvent->setPlayedScene( true );
pEventAction->onStart();
}
void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,
ActionCallback interruptCallback,
uint64_t additional )
{
Action::ActionPtr pEventItemAction( new Action::EventItemAction( shared_from_this(), eventId, action,
finishCallback, interruptCallback, additional ) );
setCurrentAction( pEventItemAction );
pEventItemAction->onStart();
}
void Core::Entity::Player::sendModel() void Core::Entity::Player::sendModel()
{ {
ModelEquipPacket modelEquip( getAsPlayer() ); ModelEquipPacket modelEquip( getAsPlayer() );
@ -1086,21 +1044,16 @@ void Core::Entity::Player::update( int64_t currTime )
m_lastUpdate = currTime; m_lastUpdate = currTime;
// @TODO needs to happen in a if check. Don't want autoattacking while an action is being performed.
if( !checkAction() ) if( !checkAction() )
{ {
if( m_targetId ) if( m_targetId && m_currentStance == Entity::Actor::Stance::Active && isAutoattackOn() )
{ {
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand ); auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need...
for( auto actor : m_inRangeActors ) for( auto actor : m_inRangeActors )
{ {
if( isAutoattackOn() && if( actor->getId() == m_targetId && actor->isAlive() && mainWeap )
actor->getId() == m_targetId &&
actor->isAlive() &&
mainWeap &&
m_currentStance == Entity::Actor::Stance::Active
)
{ {
// default autoattack range // default autoattack range
// TODO make this dependant on bnpc size // TODO make this dependant on bnpc size
@ -1644,9 +1597,7 @@ uint32_t Core::Entity::Player::getCFPenaltyMinutes() const
// check if penalty timestamp already passed current time // check if penalty timestamp already passed current time
if (currentTimestamp > endTimestamp) if (currentTimestamp > endTimestamp)
{
return 0; return 0;
}
auto deltaTime = endTimestamp - currentTimestamp; auto deltaTime = endTimestamp - currentTimestamp;
return static_cast< uint32_t > ( ceil( static_cast< float > (deltaTime) / 60 ) ); return static_cast< uint32_t > ( ceil( static_cast< float > (deltaTime) / 60 ) );

View file

@ -18,6 +18,10 @@
#include "src/servers/Server_Zone/Network/PacketWrappers/EventPlayPacket.h" #include "src/servers/Server_Zone/Network/PacketWrappers/EventPlayPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h" #include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h"
#include "src/servers/Server_Zone/Action/EventAction.h"
#include "src/servers/Server_Zone/Action/EventItemAction.h"
#include "src/servers/Server_Zone/Event/Event.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "src/servers/Server_Zone/Event/Event.h"
#include "Server_Zone/ServerZone.h" #include "Server_Zone/ServerZone.h"
@ -230,6 +234,50 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
} }
} }
void Core::Entity::Player::eventActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,
ActionCallback interruptCallback,
uint64_t additional )
{
Action::ActionPtr pEventAction( new Action::EventAction( shared_from_this(), eventId, action,
finishCallback, interruptCallback, additional ) );
setCurrentAction( pEventAction );
auto pEvent = getEvent( eventId );
if( !pEvent && getEventCount() )
{
// We're trying to play a nested event, need to start it first.
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
pEvent = getEvent( eventId );
}
else if( !pEvent )
{
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
return;
}
if( pEvent )
pEvent->setPlayedScene( true );
pEventAction->onStart();
}
void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,
ActionCallback interruptCallback,
uint64_t additional )
{
Action::ActionPtr pEventItemAction( new Action::EventItemAction( shared_from_this(), eventId, action,
finishCallback, interruptCallback, additional ) );
setCurrentAction( pEventItemAction );
pEventItemAction->onStart();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Core::Entity::Player::onLogin() void Core::Entity::Player::onLogin()