1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

Various smaller cleanups

This commit is contained in:
Mordred 2022-01-15 22:48:27 +01:00
parent 3f6f31b848
commit 79981909de
25 changed files with 112 additions and 118 deletions

View file

@ -653,8 +653,8 @@ namespace Component::Excel::Ps3
struct Aetheryte
{
AetheryteTextStruct Text;
uint32_t EventHandler;
uint32_t PopRange[4];
int32_t EventHandler;
uint16_t TelepoName;
uint16_t TransferName;
uint16_t TerritoryType;

View file

@ -506,7 +506,13 @@ namespace Sapphire::Common
Return = 1,
Teleport = 4,
GearSets = 6,
MateriaMelding = 11,
AdvancedMateriaMelding = 12,
MateriaAssimilating = 13,
Dye = 14,
Glamour = 15,
HuntingLog = 21,
Desynth = 95
};
enum ContainerType : uint16_t

View file

@ -64,7 +64,7 @@ namespace Sapphire::Network::ActorControl
SpawnEffect = 0x25,
ToggleInvisible = 0x26,
ToggleActionUnlock = 0x29,
SetSystemActionUnlocked = 0x29,
UpdateUiExp = 0x2B,
SetFallDamage = 0x2D,

View file

@ -45,6 +45,8 @@ namespace Sapphire::Network::Packets
RegionInfo = 0x0069,
MoveTerritory = 0x006A,
MoveInstance = 0x006B,
SetPSNId = 0x0073,
SetBillingTime = 0x0075,
@ -387,7 +389,6 @@ namespace Sapphire::Network::Packets
NpcSpawn = 0x00B3, // updated 5.21 hotfix
InventoryActionAck = 0x01B2, // updated 5.21 hotfix
UpdateInventorySlot = 0x0213, // updated 5.21 hotfix
PrepareZoning = 0x00B6, // updated 5.21 hotfix
};
}

View file

@ -1664,6 +1664,17 @@ namespace Sapphire::Network::Packets::WorldPackets::Server
char worldName[32];
};
struct FFXIVIpcMoveInstance : FFXIVIpcBasePacket< MoveInstance >
{
uint64_t characterId;
uint32_t entityId;
uint16_t worldId;
uint16_t worldId1;
uint64_t unknown1;
uint64_t unknown2;
//TODO... TO BE MAPPED
};
/**
*
*/
@ -1690,23 +1701,6 @@ namespace Sapphire::Network::Packets::WorldPackets::Server
struct DailyQuest dailyQuestArray[6];
};
/**
* Structural representation of the packet sent by the server
* prepare zoning, showing screenmessage
*/
struct FFXIVIpcPrepareZoning : FFXIVIpcBasePacket< PrepareZoning >
{
uint32_t logMessage;
uint16_t targetZone;
uint16_t animation;
uint8_t param4;
uint8_t hideChar;
uint8_t fadeOut;
uint8_t param7;
uint8_t fadeOutTime;
uint8_t unknown; // this changes whether or not the destination zone's name displays during the loading screen. Seems to always be 9 (=hidden) when going to an instance and certain zones, 0 otherwise.
uint16_t padding;
};
/**
* Structural representation of the packet sent by the server

View file

@ -139,7 +139,7 @@ float Util::trunc( float value, uint8_t digitsToRemain )
if( digitsToRemain == 0 )
return std::floor( value );
float factor = std::pow( 10, digitsToRemain );
auto factor = static_cast< float >( std::pow( 10.f, digitsToRemain ) );
return std::floor( value * factor ) / factor;
}

View file

@ -101,7 +101,7 @@ public:
else
{
eventMgr().sendEventNotice( player, eventId, 0, 1, 1, 0 );
player.learnAction( Common::UnlockEntry::Teleport );
player.setSystemActionUnlocked( Common::UnlockEntry::Teleport );
}
},
[]( Entity::Player& player, uint32_t eventId, uint64_t additional )

View file

@ -201,7 +201,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00051( quest, player );
};

View file

@ -79,7 +79,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00051( quest, player );
},
nullptr, quest.getId() );

View file

@ -82,7 +82,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00051( quest, player );
},
nullptr, quest.getId() );

View file

@ -91,7 +91,7 @@ private:
if( !pQuest )
return;
pQuest->setSeq( SEQ_FINISH );
player.prepareZoning( player.getTerritoryTypeId(), true, 1, 0 );
//player.prepareZoning( player.getTerritoryTypeId(), true, 1, 0 );
player.changePosition( 9, 40, 14, 2 );
}
} );

View file

@ -58,7 +58,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00002( player );
},
nullptr, getId() );

View file

@ -72,7 +72,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00002( player );
},
nullptr, getId() );

View file

@ -90,7 +90,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00001( quest, player );
},
nullptr, getId() );

View file

@ -90,7 +90,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00001( player );
},
nullptr, getId() );

View file

@ -90,7 +90,7 @@ public:
{
eventMgr().sendEventNotice( player, 0x050002, 0, 1, 0, 0 );
player.registerAetheryte( 2 );
player.learnAction( Common::UnlockEntry::Return );
player.setSystemActionUnlocked( Common::UnlockEntry::Return );
Scene00001( player );
},
nullptr, getId() );

View file

@ -205,7 +205,7 @@ private:
if( result.getResult( 0 ) == 1 )
{
player.learnAction( Sapphire::Common::UnlockEntry::HuntingLog );
player.setSystemActionUnlocked( Sapphire::Common::UnlockEntry::HuntingLog );
player.finishQuest( getId(), result.getResult( 1 ) );
}
}

View file

@ -240,7 +240,7 @@ bool Action::Action::update()
player->setLastActionTick( tickCount );
uint32_t delayMs = 100 - lastTickMs;
castTime = ( m_castTimeMs + delayMs ); //subtract 500ms before the client begin to request actions while casting
castTime = ( m_castTimeMs + delayMs );
m_castTimeRestMs = static_cast< uint64_t >( m_castTimeMs ) - std::difftime( static_cast< time_t >( tickCount ), static_cast< time_t >( m_startTime ) );
}
@ -253,7 +253,7 @@ bool Action::Action::update()
if( m_pTarget == nullptr && m_targetId != 0 )
{
// try to search for the target actor
for( auto actor : m_pSource->getInRangeActors( true ) )
for( const auto& actor : m_pSource->getInRangeActors( true ) )
{
if( actor->getId() == m_targetId )
{
@ -263,15 +263,12 @@ bool Action::Action::update()
}
}
if( m_pTarget != nullptr )
if( m_pTarget != nullptr && !m_pTarget->isAlive() )
{
if( !m_pTarget->isAlive() )
{
// interrupt the cast if target died
setInterrupted( Common::ActionInterruptType::RegularInterrupt );
interrupt();
return true;
}
// interrupt the cast if target died
setInterrupted( Common::ActionInterruptType::RegularInterrupt );
interrupt();
return true;
}
return false;

View file

@ -317,16 +317,6 @@ void Sapphire::Entity::Player::removeOnlineStatus( const std::vector< Common::On
Service< World::Manager::PlayerMgr >::ref().onOnlineStatusChanged( *this, false );
}
void Sapphire::Entity::Player::prepareZoning( uint16_t targetZone, bool fadeOut, uint8_t fadeOutTime, uint16_t animation )
{
auto preparePacket = makeZonePacket< FFXIVIpcPrepareZoning >( getId() );
preparePacket->data().targetZone = targetZone;
preparePacket->data().fadeOutTime = fadeOutTime;
preparePacket->data().animation = animation;
preparePacket->data().fadeOut = static_cast< uint8_t >( fadeOut ? 1 : 0 );
queuePacket( preparePacket );
}
void Sapphire::Entity::Player::calculateStats()
{
uint8_t tribe = getLookAt( Common::CharaLook::Tribe );
@ -456,19 +446,22 @@ void Sapphire::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
// TODO: this should be simplified and a type created in server_common/common.h.
if( type == 1 ) // teleport
{
prepareZoning( data.TerritoryType, true, 1, 0 ); // TODO: Really?
//prepareZoning( data.TerritoryType, true, 1, 0 ); // TODO: Really?
sendToInRangeSet( makeActorControl( getId(), WarpStart, Common::WarpType::WARP_TYPE_TELEPO ), true );
sendToInRangeSet( makeActorControl( getId(), ActorDespawnEffect, 0x04 ) );
setZoningType( Common::ZoneingType::Teleport );
}
else if( type == 2 ) // aethernet
{
prepareZoning( data.TerritoryType, true, 1, 112 );
//prepareZoning( data.TerritoryType, true, 1, 112 );
sendToInRangeSet( makeActorControl( getId(), WarpStart, Common::WarpType::WARP_TYPE_TELEPO ), true );
sendToInRangeSet( makeActorControl( getId(), ActorDespawnEffect, 0x04 ) );
setZoningType( Common::ZoneingType::Teleport );
}
else if( type == 3 ) // return
{
prepareZoning( data.TerritoryType, true, 1, 111 );
//prepareZoning( data.TerritoryType, true, 1, 111 );
sendToInRangeSet( makeActorControl( getId(), WarpStart, Common::WarpType::WARP_TYPE_HOME_POINT ), true );
sendToInRangeSet( makeActorControl( getId(), ActorDespawnEffect, 0x03 ) );
setZoningType( Common::ZoneingType::Return );
}
@ -479,7 +472,6 @@ void Sapphire::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
void Sapphire::Entity::Player::forceZoneing( uint32_t zoneId )
{
m_queuedZoneing = std::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f );
//performZoning( zoneId, Common::ZoneingType::None, getPos() );
}
void Sapphire::Entity::Player::returnToHomepoint()
@ -507,18 +499,6 @@ void Sapphire::Entity::Player::setZone( uint32_t zoneId )
}
}
bool Sapphire::Entity::Player::setInstance( uint32_t instanceContentId )
{
m_onEnterEventDone = false;
auto& teriMgr = Common::Service< TerritoryMgr >::ref();
auto instance = teriMgr.getTerritoryByGuId( instanceContentId );
if( !instance )
return false;
return setInstance( instance );
}
bool Sapphire::Entity::Player::setInstance( const TerritoryPtr& instance )
{
m_onEnterEventDone = false;
@ -752,7 +732,7 @@ void Sapphire::Entity::Player::changePosition( float x, float y, float z, float
m_queuedZoneing = std::make_shared< QueuedZoning >( getTerritoryTypeId(), pos, Util::getTimeMs(), o );
}
void Sapphire::Entity::Player::learnAction( Common::UnlockEntry unlockId )
void Sapphire::Entity::Player::setSystemActionUnlocked( Common::UnlockEntry unlockId )
{
uint16_t index;
uint8_t value;
@ -761,7 +741,7 @@ void Sapphire::Entity::Player::learnAction( Common::UnlockEntry unlockId )
m_unlocks[ index ] |= value;
queuePacket( makeActorControlSelf( getId(), ToggleActionUnlock, unlock, 1 ) );
queuePacket( makeActorControlSelf( getId(), SetSystemActionUnlocked, unlock, 1 ) );
}
void Sapphire::Entity::Player::learnSong( uint8_t songId, uint32_t itemId )
@ -1700,11 +1680,9 @@ void Sapphire::Entity::Player::sendTitleList()
queuePacket( titleListPacket );
}
void
Sapphire::Entity::Player::sendZoneInPackets( uint32_t param1, uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0,
bool shouldSetStatus = false )
void Sapphire::Entity::Player::sendZoneInPackets( uint32_t param1, bool shouldSetStatus = false )
{
auto zoneInPacket = makeActorControlSelf( getId(), Appear, param1, param2, param3, param4 );
auto zoneInPacket = makeActorControlSelf( getId(), Appear, param1, 0, 0, 0 );
auto SetStatusPacket = makeActorControl( getId(), SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
if( !getGmInvis() )
@ -1728,7 +1706,7 @@ void Sapphire::Entity::Player::finishZoning()
break;
case ZoneingType::Teleport:
sendZoneInPackets( 0x01, 0, 0, 110 );
sendZoneInPackets( 0x01 );
break;
case ZoneingType::Return:
@ -1739,10 +1717,10 @@ void Sapphire::Entity::Player::finishZoning()
resetHp();
resetMp();
setStatus( Common::ActorStatus::Idle );
sendZoneInPackets( 0x01, 0x01, 0, 111, true );
sendZoneInPackets( 0x01, true );
}
else
sendZoneInPackets( 0x01, 0x00, 0, 111 );
sendZoneInPackets( 0x01 );
}
break;

View file

@ -305,9 +305,6 @@ namespace Sapphire::Entity
/*! sets the players zone, initiating a zoning process */
void setZone( uint32_t zoneId );
/*! sets the players instance & initiates zoning process */
bool setInstance( uint32_t instanceContentId );
/*! sets the players instance & initiates zoning process */
bool setInstance( const TerritoryPtr& instance );
@ -378,9 +375,6 @@ namespace Sapphire::Entity
void setDyeingInfo( uint32_t itemToDyeContainer, uint32_t itemToDyeSlot, uint32_t dyeBagContainer, uint32_t dyeBagSlot );
void dyeItemFromDyeingInfo();
/*! prepares zoning / fades out the screen */
void prepareZoning( uint16_t targetZone, bool fadeOut, uint8_t fadeOutTime = 0, uint16_t animation = 0 );
/*! get player's title list (available titles) */
TitleList& getTitleList();
@ -465,7 +459,7 @@ namespace Sapphire::Entity
void updateHowtosSeen( uint32_t howToId );
/*! learn an action / update the unlock bitmask. */
void learnAction( Common::UnlockEntry unlockId );
void setSystemActionUnlocked( Common::UnlockEntry unlockId );
/*! learn a song / update the unlock bitmask. */
void learnSong( uint8_t songId, uint32_t itemId );
@ -598,7 +592,7 @@ namespace Sapphire::Entity
/*! return true if the player is marked for zoning */
bool isMarkedForZoning() const;
void sendZoneInPackets( uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4, bool pSetStatus );
void sendZoneInPackets( uint32_t param1, bool pSetStatus );
void finishZoning();

View file

@ -472,6 +472,47 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player&
pSession->getZoneConnection()->queueOutPacket( actorControl );
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6, &playerId);
Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
player.queuePacket( noticePacket );
Network::Packets::Server::ActorControlSelfPacket controlPacket( player, opcode,
param1, param2, param3, param4, param5, param6, playerId );
player.queuePacket( controlPacket );*/
}
else if( subCommand == "actrls" )
{
// temporary research packet
uint32_t opcode;
uint32_t param1;
uint32_t param2;
uint32_t param3;
uint32_t param4;
uint32_t param5;
uint32_t param6;
uint32_t playerId;
sscanf( params.c_str(), "%x %x %x %x %x %x %x %x", &opcode, &playerId, &param1,
&param2, &param3, &param4, &param5, &param6 );
PlayerMgr::sendServerNotice( player, "Injecting ACTOR_CONTROL {0}", opcode );
auto actorControl = makeZonePacket< FFXIVIpcActorControlSelf >( playerId, playerId );
actorControl->data().category = static_cast< uint16_t >( opcode );
actorControl->data().param1 = param1;
actorControl->data().param2 = param2;
actorControl->data().param3 = param3;
actorControl->data().param4 = param4;
actorControl->data().param5 = param5;
actorControl->data().param6 = param6;
pSession->getZoneConnection()->queueOutPacket( actorControl );
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6, &playerId);
Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
@ -488,7 +529,7 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player&
uint32_t id;
sscanf( params.c_str(), "%d", &id );
player.learnAction( static_cast< Common::UnlockEntry >( id ) );
player.setSystemActionUnlocked( static_cast< Common::UnlockEntry >( id ) );
}
else if ( subCommand == "effect")
{

View file

@ -73,7 +73,7 @@ std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId )
case Event::EventHandler::EventHandlerType::Aetheryte:
{
auto aetherInfo = exdData.getRow< Component::Excel::Aetheryte >( eventId & 0xFFFF );
if( !aetherInfo->data().Telepo )
if( aetherInfo->data().Telepo )
return "Aetheryte";
return "Aethernet";
}

View file

@ -86,6 +86,7 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR
auto& server = Common::Service< World::WorldServer >::ref();
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
auto& exdData = Common::Service< Data::ExdData >::ref();
const auto packet = ZoneChannelPacket< FFXIVIpcGmCommand >( inPacket );
const auto commandId = packet.data().Id;
@ -508,8 +509,6 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR
bool doTeleport = false;
uint16_t teleport;
auto& exdData = Common::Service< Data::ExdData >::ref();
auto idList = exdData.getIdList< Component::Excel::Aetheryte >();
for( auto i : idList )
@ -517,19 +516,15 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR
auto data = exdData.getRow< Component::Excel::Aetheryte >( i );
if( !data )
{
continue;
if( data->data().TerritoryType == param1 && data->data().Telepo )
{
doTeleport = true;
teleport = static_cast< uint16_t >( i );
break;
}
if( data->data().TerritoryType == param1 )
{
//if( data->data().Telepo )
{
doTeleport = true;
teleport = static_cast< uint16_t >( i );
break;
}
}
}
if( doTeleport )
{
@ -646,7 +641,7 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX
targetPlayer->resetHp();
targetPlayer->resetMp();
targetPlayer->setStatus( Common::ActorStatus::Idle );
targetPlayer->sendZoneInPackets( 0x01, 0x01, 0, 113, true );
targetPlayer->sendZoneInPackets( 0x01, true );
targetPlayer->sendToInRangeSet( makeActorControlSelf( player.getId(), Appear, 0x01, 0x01, 0, 113 ), true );
@ -658,7 +653,6 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX
}
case GmCommand::Jump:
{
player.prepareZoning( targetPlayer->getTerritoryTypeId(), true, 1, 0 );
if( pPlayerTerri->getAsInstanceContent() )
{
player.exitInstance();
@ -671,11 +665,11 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX
{
// Not sure if GMs actually get bound to an instance they jump to on retail. It's mostly here to avoid a crash for now
pInstanceContent->bindPlayer( player.getId() );
player.setInstance( pInstanceContent );
}
player.setInstance( targetPlayer->getTerritoryId() );
}
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z, targetActor->getRot() );
player.sendZoneInPackets( 0x00, 0x00, 0, 0, false );
player.sendZoneInPackets( 0x00, false );
PlayerMgr::sendServerNotice( player, "Jumping to {0}", targetPlayer->getName() );
break;
}
@ -687,17 +681,16 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX
PlayerMgr::sendUrgent( player, "You are unable to call a player while bound to a battle instance." );
return;
}
targetPlayer->prepareZoning( player.getTerritoryTypeId(), true, 1, 0 );
if( pTargetActorTerri->getAsInstanceContent() )
{
targetPlayer->exitInstance();
}
if( targetPlayer->getTerritoryId() != player.getTerritoryId() )
{
targetPlayer->setInstance( player.getTerritoryId() );
targetPlayer->setInstance( pTargetActorTerri->getAsInstanceContent() );
}
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() );
targetPlayer->sendZoneInPackets( 0x00, 0x00, 0, 0, false );
targetPlayer->sendZoneInPackets( 0x00, false );
PlayerMgr::sendServerNotice( player, "Calling {0}", targetPlayer->getName() );
break;
}

View file

@ -340,7 +340,8 @@ void Sapphire::Network::GameConnection::zoneJumpHandler( const Packets::FFXIVARR
pPopRange->header.transform.rotation.z,
rotation );
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), WarpStart, 0x03, player.getId(), 0x01, targetZone ) );
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), WarpStart,
Common::WarpType::WARP_TYPE_EXIT_RANGE, player.getId(), 0x01, targetZone ) );
auto moveTerritoryPacket = makeZonePacket< FFXIVIpcMoveTerritory >( player.getId() );
moveTerritoryPacket->data().index = -1;

View file

@ -148,17 +148,6 @@ void Sapphire::World::WorldServer::run( int32_t argc, char* argv[] )
}
Common::Service< Data::ExdData >::set( pExdData );
auto idList = pExdData->getIdList< Component::Excel::Aetheryte >();
for( auto id : idList )
{
auto aetherInfo = pExdData->getRow< Component::Excel::Aetheryte >( id );
Logger::info( "id: {0} bool: {1}, padd: {2}", id, aetherInfo->data().Telepo, aetherInfo->data().padding1 );
}
auto pDb = std::make_shared< Db::DbWorkerPool< Db::ZoneDbConnection > >();
Sapphire::Db::DbLoader loader;
loader.addDb( *pDb, m_config.global.database );