mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 22:17:45 +00:00
Simplified handling of state flags
This commit is contained in:
parent
6d6c71d6af
commit
add84d6516
8 changed files with 17 additions and 42 deletions
|
@ -58,7 +58,6 @@ void Core::Action::ActionCast::onStart()
|
|||
|
||||
m_pSource->sendToInRangeSet( castPacket, true );
|
||||
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,6 @@ void Core::Action::ActionCast::onFinish()
|
|||
pPlayer->sendDebug( "onFinish()" );
|
||||
|
||||
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
pPlayer->sendStateFlags();
|
||||
|
||||
/*auto control = ActorControlPacket143( m_pTarget->getId(), ActorControlType::Unk7,
|
||||
0x219, m_id, m_id, m_id, m_id );
|
||||
|
@ -87,7 +85,6 @@ void Core::Action::ActionCast::onInterrupt()
|
|||
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
||||
0x219, 1, m_id, 0 );
|
||||
|
|
|
@ -60,7 +60,6 @@ void Core::Action::ActionMount::onStart()
|
|||
|
||||
m_pSource->sendToInRangeSet( castPacket, true );
|
||||
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
}
|
||||
|
||||
|
@ -73,7 +72,6 @@ void Core::Action::ActionMount::onFinish()
|
|||
pPlayer->sendDebug( "ActionMount::onFinish()" );
|
||||
|
||||
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
pPlayer->sendStateFlags();
|
||||
|
||||
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
|
||||
effectPacket.data().targetId = pPlayer->getId();
|
||||
|
@ -100,7 +98,6 @@ void Core::Action::ActionMount::onInterrupt()
|
|||
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
||||
0x219, 1, m_id, 0 );
|
||||
|
|
|
@ -54,7 +54,6 @@ void Core::Action::ActionTeleport::onStart()
|
|||
|
||||
m_pSource->sendToInRangeSet( castPacket, true );
|
||||
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
}
|
||||
|
||||
|
@ -75,7 +74,6 @@ void Core::Action::ActionTeleport::onFinish()
|
|||
pPlayer->removeCurrency( Inventory::CurrencyType::Gil, m_cost );
|
||||
|
||||
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
pPlayer->sendStateFlags();
|
||||
|
||||
// TODO: not sure if this ever gets sent
|
||||
//auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::TeleportDone );
|
||||
|
@ -105,7 +103,6 @@ void Core::Action::ActionTeleport::onInterrupt()
|
|||
return;
|
||||
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
||||
0x219, 0x04, m_id, 0 );
|
||||
|
|
|
@ -54,7 +54,6 @@ void Core::Action::EventAction::onStart()
|
|||
{
|
||||
m_pSource->sendToInRangeSet( control, true );
|
||||
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::SomeFlag );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
}
|
||||
else
|
||||
m_pSource->sendToInRangeSet( control );
|
||||
|
@ -84,7 +83,6 @@ void Core::Action::EventAction::onFinish()
|
|||
if( m_pSource->isPlayer() )
|
||||
{
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::SomeFlag );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
m_pSource->sendToInRangeSet( control, true );
|
||||
}
|
||||
else
|
||||
|
@ -114,7 +112,6 @@ void Core::Action::EventAction::onInterrupt()
|
|||
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::NoCombat );
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
m_pSource->sendToInRangeSet( control );
|
||||
m_pSource->sendToInRangeSet( control1 );
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ void Core::Action::EventItemAction::onStart()
|
|||
|
||||
m_pSource->sendToInRangeSet( castPacket, true );
|
||||
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,6 @@ void Core::Action::EventItemAction::onFinish()
|
|||
effectPacket.data().effectTarget = static_cast< uint32_t >( m_additional );
|
||||
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
m_pSource->sendToInRangeSet( effectPacket, true );
|
||||
|
||||
if( m_onActionFinishClb )
|
||||
|
@ -104,7 +102,6 @@ void Core::Action::EventItemAction::onInterrupt()
|
|||
if( m_pSource->isPlayer() )
|
||||
{
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
m_pSource->getAsPlayer()->sendStateFlags();
|
||||
m_pSource->sendToInRangeSet( control, true );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -308,7 +308,6 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
|||
}
|
||||
|
||||
setStateFlag( PlayerStateFlag::BetweenAreas );
|
||||
sendStateFlags();
|
||||
|
||||
auto z_pos = g_zoneMgr.getZonePosition( data->levelId );
|
||||
|
||||
|
@ -402,7 +401,6 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
|
|||
// set flags, will be reset automatically by zoning ( only on client side though )
|
||||
pPlayer->setStateFlag( PlayerStateFlag::BetweenAreas );
|
||||
pPlayer->setStateFlag( PlayerStateFlag::BetweenAreas1 );
|
||||
pPlayer->sendStateFlags();
|
||||
|
||||
pPlayer->sendStats();
|
||||
|
||||
|
@ -580,7 +578,6 @@ void Core::Entity::Player::setNewAdventurer( bool state )
|
|||
//{
|
||||
// setStateFlag( PlayerStateFlag::NewAdventurer );
|
||||
//}
|
||||
sendStateFlags();
|
||||
m_bNewAdventurer = state;
|
||||
}
|
||||
|
||||
|
@ -972,6 +969,7 @@ bool Core::Entity::Player::hasStateFlag( Common::PlayerStateFlag flag ) const
|
|||
|
||||
void Core::Entity::Player::setStateFlag( Common::PlayerStateFlag flag )
|
||||
{
|
||||
auto prevOnlineStatus = getOnlineStatus();
|
||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||
|
||||
uint16_t index;
|
||||
|
@ -979,6 +977,13 @@ void Core::Entity::Player::setStateFlag( Common::PlayerStateFlag flag )
|
|||
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
||||
|
||||
m_stateFlags[index] |= value;
|
||||
sendStateFlags();
|
||||
|
||||
auto newOnlineStatus = getOnlineStatus();
|
||||
|
||||
if( prevOnlineStatus != newOnlineStatus )
|
||||
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( getOnlineStatus() ) ), true );
|
||||
|
||||
}
|
||||
|
||||
|
@ -986,13 +991,7 @@ void Core::Entity::Player::setStateFlags( std::vector< Common::PlayerStateFlag >
|
|||
{
|
||||
for( const auto& flag : flags )
|
||||
{
|
||||
int iFlag = static_cast< uint32_t >( flag );
|
||||
|
||||
uint16_t index;
|
||||
uint8_t value;
|
||||
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
||||
|
||||
m_stateFlags[index] |= value;
|
||||
setStateFlag( flag );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1006,6 +1005,8 @@ void Core::Entity::Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
|||
if( !hasStateFlag( flag ) )
|
||||
return;
|
||||
|
||||
auto prevOnlineStatus = getOnlineStatus();
|
||||
|
||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||
|
||||
uint16_t index;
|
||||
|
@ -1013,7 +1014,13 @@ void Core::Entity::Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
|||
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
||||
|
||||
m_stateFlags[index] ^= value;
|
||||
sendStateFlags();
|
||||
|
||||
auto newOnlineStatus = getOnlineStatus();
|
||||
|
||||
if( prevOnlineStatus != newOnlineStatus )
|
||||
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( getOnlineStatus() ) ), true );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::update( int64_t currTime )
|
||||
|
|
|
@ -83,7 +83,6 @@ void Core::Entity::Player::eventStart( uint64_t actorId, uint32_t eventId,
|
|||
addEvent( newEvent );
|
||||
|
||||
setStateFlag( PlayerStateFlag::Occupied2 );
|
||||
sendStateFlags();
|
||||
|
||||
EventStartPacket eventStart( getId(), actorId, eventId, eventType, eventParam1, eventParam2 );
|
||||
|
||||
|
@ -114,11 +113,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
uint32_t eventParam3, Event::EventHandler::SceneReturnCallback eventCallback )
|
||||
{
|
||||
if( flags & 0x02 )
|
||||
{
|
||||
setStateFlag( PlayerStateFlag::WatchingCutscene );
|
||||
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( getOnlineStatus() ) ), true );
|
||||
}
|
||||
|
||||
auto pEvent = getEvent( eventId );
|
||||
if( !pEvent && getEventCount() )
|
||||
|
@ -146,11 +141,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
uint32_t eventParam3, uint32_t eventParam4, Event::EventHandler::SceneReturnCallback eventCallback )
|
||||
{
|
||||
if( flags & 0x02 )
|
||||
{
|
||||
setStateFlag( PlayerStateFlag::WatchingCutscene );
|
||||
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( getOnlineStatus() ) ), true );
|
||||
}
|
||||
|
||||
auto pEvent = getEvent( eventId );
|
||||
if( !pEvent && getEventCount() )
|
||||
|
@ -219,19 +210,12 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
|
|||
}
|
||||
|
||||
if( hasStateFlag( PlayerStateFlag::WatchingCutscene ) )
|
||||
{
|
||||
unsetStateFlag( PlayerStateFlag::WatchingCutscene );
|
||||
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( getOnlineStatus() ) ), true );
|
||||
}
|
||||
|
||||
removeEvent( pEvent->getId() );
|
||||
|
||||
if( freePlayer == 1 )
|
||||
{
|
||||
unsetStateFlag( PlayerStateFlag::Occupied2 );
|
||||
sendStateFlags();
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Entity::Player::eventActionStart( uint32_t eventId,
|
||||
|
|
|
@ -196,7 +196,6 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
|
|||
|
||||
player.unsetStateFlag( PlayerStateFlag::BetweenAreas );
|
||||
player.unsetStateFlag( PlayerStateFlag::BetweenAreas1 );
|
||||
player.sendStateFlags();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue