mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-04 09:47:46 +00:00
More cleanup and a session removal bug fixed
This commit is contained in:
parent
775b1e5641
commit
c5c8199bd2
3 changed files with 52 additions and 80 deletions
6
deps/datReader/Exd/Structs.h
vendored
6
deps/datReader/Exd/Structs.h
vendored
|
@ -344,6 +344,7 @@ namespace Component::Excel
|
|||
int8_t SelectRange;
|
||||
int8_t SelectCorpse;
|
||||
int8_t AttackType;
|
||||
|
||||
uint8_t SelectMyPet : 1;
|
||||
uint8_t SelectGround : 1;
|
||||
uint8_t SelectENpc : 1;
|
||||
|
@ -352,6 +353,7 @@ namespace Component::Excel
|
|||
uint8_t SelectAlliance : 1;
|
||||
uint8_t SelectParty : 1;
|
||||
uint8_t SelectMyself : 1;
|
||||
|
||||
uint8_t PvPOnly : 1;
|
||||
uint8_t InvalidMove : 1;
|
||||
uint8_t Silence : 1;
|
||||
|
@ -360,6 +362,7 @@ namespace Component::Excel
|
|||
uint8_t CheckDir : 1;
|
||||
uint8_t Lay : 1;
|
||||
uint8_t SelectPartyPet : 1;
|
||||
|
||||
uint8_t IsTargetLine : 1;
|
||||
uint8_t HideCastBar : 1;
|
||||
uint8_t ForceVFX : 1;
|
||||
|
@ -368,7 +371,8 @@ namespace Component::Excel
|
|||
uint8_t LogCast : 1;
|
||||
uint8_t IsMove : 1;
|
||||
uint8_t IsAvoid : 1;
|
||||
int8_t padding0[1];
|
||||
|
||||
int8_t padding0;
|
||||
};
|
||||
|
||||
/* 75653 */
|
||||
|
|
|
@ -66,8 +66,7 @@ using namespace Sapphire::Network::Packets::WorldPackets;
|
|||
using namespace Sapphire::Network::ActorControl;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
void Sapphire::Network::GameConnection::setProfileHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::setProfileHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcSetSearchInfo >( inPacket );
|
||||
|
||||
|
@ -100,8 +99,7 @@ void Sapphire::Network::GameConnection::setProfileHandler( const Packets::FFXIVA
|
|||
static_cast< uint8_t >( player.getOnlineStatus() ) ), true );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getProfileHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::getProfileHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
auto searchInfoPacket = makeZonePacket< FFXIVIpcGetProfileResult >( player.getId() );
|
||||
searchInfoPacket->data().OnlineStatus = player.getOnlineStatusMask() | player.getOnlineStatusCustomMask();
|
||||
|
@ -110,20 +108,15 @@ void Sapphire::Network::GameConnection::getProfileHandler( const Packets::FFXIVA
|
|||
queueOutPacket( searchInfoPacket );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getSearchCommentHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::getSearchCommentHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
|
||||
auto targetId = *reinterpret_cast< const uint32_t* >( &inPacket.data[ 0x10 ] );
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
auto pSession = server.getSession( targetId );
|
||||
auto pPlayer = server.getPlayer( targetId );
|
||||
|
||||
Logger::debug( "getSearchCommentHandler: {0}", targetId );
|
||||
|
||||
if( pSession )
|
||||
{
|
||||
auto pPlayer = pSession->getPlayer();
|
||||
|
||||
if( pPlayer )
|
||||
{
|
||||
if( pPlayer->isActingAsGm() || pPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() )
|
||||
|
@ -135,24 +128,18 @@ void Sapphire::Network::GameConnection::getSearchCommentHandler( const Packets::
|
|||
strcpy( searchInfoPacket->data().searchComment, pPlayer->getSearchMessage() );
|
||||
server.queueForPlayer( player.getCharacterId(), searchInfoPacket );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::reqExamineFcInfo( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::reqExamineFcInfo( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
|
||||
auto targetId = *reinterpret_cast< const uint32_t* >( &inPacket.data[ 0x18 ] );
|
||||
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
auto pSession = server.getSession( targetId );
|
||||
auto pPlayer = server.getPlayer( targetId );
|
||||
|
||||
Logger::debug( "reqExamineFcInfo: {0}", targetId );
|
||||
|
||||
if( pSession )
|
||||
{
|
||||
auto pPlayer = pSession->getPlayer();
|
||||
|
||||
if( pPlayer )
|
||||
{
|
||||
if( pPlayer->isActingAsGm() || pPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() )
|
||||
|
@ -165,7 +152,7 @@ void Sapphire::Network::GameConnection::reqExamineFcInfo( const Packets::FFXIVAR
|
|||
|
||||
server.queueForPlayer( player.getCharacterId(), examineFcInfoPacket );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::joinChatChannelHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
|
@ -209,8 +196,7 @@ void Sapphire::Network::GameConnection::joinChatChannelHandler( const Packets::F
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
// if the player is marked for zoning we no longer want to update his pos
|
||||
if( player.isMarkedForZoning() )
|
||||
|
@ -229,7 +215,7 @@ void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PAC
|
|||
player.setRot( data.dir );
|
||||
player.setPos( { data.pos.x, data.pos.y, data.pos.z } );
|
||||
|
||||
if( ( player.getCurrentAction() != nullptr ) && bPosChanged )
|
||||
if( player.getCurrentAction() && bPosChanged )
|
||||
player.getCurrentAction()->setInterrupted( Common::ActionInterruptType::RegularInterrupt );
|
||||
|
||||
auto clientAnimationType = data.flag;
|
||||
|
@ -300,8 +286,7 @@ void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PAC
|
|||
player.sendToInRangeSet( movePacket );
|
||||
}
|
||||
|
||||
void
|
||||
Sapphire::Network::GameConnection::configHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::configHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcConfig >( inPacket );
|
||||
|
||||
|
@ -326,7 +311,7 @@ void Sapphire::Network::GameConnection::zoneJumpHandler( const Packets::FFXIVARR
|
|||
|
||||
Common::FFXIVARR_POSITION3 targetPos{};
|
||||
Common::FFXIVARR_POSITION3 targetRot{};
|
||||
uint32_t targetZone;
|
||||
uint32_t targetZone{128};
|
||||
float rotation = 0.0f;
|
||||
|
||||
if( pExitRange )
|
||||
|
@ -378,8 +363,7 @@ void Sapphire::Network::GameConnection::zoneJumpHandler( const Packets::FFXIVARR
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Network::GameConnection::newDiscoveryHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::newDiscoveryHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
auto& teriMgr = Common::Service< TerritoryMgr >::ref();
|
||||
|
@ -413,8 +397,7 @@ void Sapphire::Network::GameConnection::loginHandler( const Packets::FFXIVARR_PA
|
|||
teriMgr.joinWorld( player );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::syncHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::syncHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcPingHandler >( inPacket );
|
||||
|
@ -429,8 +412,7 @@ void Sapphire::Network::GameConnection::syncHandler( const Packets::FFXIVARR_PAC
|
|||
pSession->setLastPing( Common::Util::getTimeSeconds() );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::setLanguageHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::setLanguageHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
if( player.isLogin() )
|
||||
{
|
||||
|
@ -470,8 +452,7 @@ void Sapphire::Network::GameConnection::setLanguageHandler( const Packets::FFXIV
|
|||
pCurrentZone->updateActorPosition( player );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::pcSearchHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::pcSearchHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcPcSearch >( inPacket );
|
||||
auto& data = packet.data();
|
||||
|
@ -492,7 +473,7 @@ void Sapphire::Network::GameConnection::pcSearchHandler( const Packets::FFXIVARR
|
|||
// store result in player - we don't map out query keys to data yet
|
||||
std::vector< uint32_t > entityIdVec;
|
||||
|
||||
for( const auto pSession : queryPlayers )
|
||||
for( const auto& pSession : queryPlayers )
|
||||
{
|
||||
if( !pSession )
|
||||
continue;
|
||||
|
@ -571,8 +552,7 @@ void Sapphire::Network::GameConnection::chatHandler( const Packets::FFXIVARR_PAC
|
|||
// currently we wait for the session to just time out after logout, this can be a problem is the user tries to
|
||||
// log right back in.
|
||||
// Also the packet needs to be converted to an ipc structure
|
||||
void Sapphire::Network::GameConnection::logoutHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::logoutHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
auto logoutPacket = makeZonePacket< FFXIVIpcEnableLogout >( player.getId() );
|
||||
logoutPacket->data().content = 0x02;
|
||||
|
@ -583,8 +563,7 @@ void Sapphire::Network::GameConnection::logoutHandler( const Packets::FFXIVARR_P
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Network::GameConnection::tellHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::tellHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcChatTo >( inPacket );
|
||||
auto& data = packet.data();
|
||||
|
@ -647,8 +626,7 @@ void Sapphire::Network::GameConnection::tellHandler( const Packets::FFXIVARR_PAC
|
|||
pSession->getChatConnection()->queueOutPacket( tellPacket );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::chatToChannelHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::chatToChannelHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ChatChannelPacket< Client::FFXIVIpcChatToChannel >( inPacket );
|
||||
auto& data = packet.data();
|
||||
|
@ -660,8 +638,7 @@ void Sapphire::Network::GameConnection::chatToChannelHandler( const Packets::FFX
|
|||
chatChannelMgr.sendMessageToChannel( data.channelID, player, message );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::catalogSearch( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::catalogSearch( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
auto& marketMgr = Common::Service< MarketMgr >::ref();
|
||||
|
||||
|
@ -679,8 +656,7 @@ void Sapphire::Network::GameConnection::catalogSearch( const Packets::FFXIVARR_P
|
|||
);
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::marketBoardRequestItemInfo( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::marketBoardRequestItemInfo( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcMarketBoardRequestItemListingInfo >( inPacket );
|
||||
|
||||
|
@ -689,8 +665,7 @@ void Sapphire::Network::GameConnection::marketBoardRequestItemInfo( const Packet
|
|||
marketMgr.requestItemListingInfo( player, packet.data().catalogId, packet.data().requestId );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::marketBoardRequestItemListings( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::marketBoardRequestItemListings( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcMarketBoardRequestItemListings >( inPacket );
|
||||
|
||||
|
@ -699,14 +674,12 @@ void Sapphire::Network::GameConnection::marketBoardRequestItemListings( const Pa
|
|||
marketMgr.requestItemListings( player, packet.data().itemCatalogId );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getFcStatus( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::getFcStatus( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getFcProfile( const Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::getFcProfile( const Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGetFcProfile >( inPacket );
|
||||
|
||||
|
@ -742,9 +715,7 @@ void Sapphire::Network::GameConnection::getFcProfile( const Sapphire::Network::P
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getRequestItemListHandler(
|
||||
const Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
void Sapphire::Network::GameConnection::getRequestItemListHandler( const Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -148,9 +148,6 @@ void Sapphire::World::WorldServer::run( int32_t argc, char* argv[] )
|
|||
}
|
||||
Common::Service< Data::ExdData >::set( pExdData );
|
||||
|
||||
// auto aetherInfo = pExdData->getRow< Component::Excel::ClassJob >( 2 );
|
||||
// auto aetherInfo1 = pExdData->getRow< Component::Excel::ClassJob >( 3 );
|
||||
|
||||
auto pDb = std::make_shared< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
Sapphire::Db::DbLoader loader;
|
||||
loader.addDb( *pDb, m_config.global.database );
|
||||
|
@ -341,7 +338,7 @@ void Sapphire::World::WorldServer::updateSessions( uint32_t currTime )
|
|||
auto diff = difftime( currTime, session->getLastDataTime() );
|
||||
auto& player = *session->getPlayer();
|
||||
|
||||
// remove session of players marked for removel ( logoff / kick )
|
||||
// remove session of players marked for removal ( logoff / kick )
|
||||
if( ( player.isMarkedForRemoval() && diff > 5 ) || diff > 20 )
|
||||
{
|
||||
Logger::info( "[{0}] Session removal", session->getId() );
|
||||
|
@ -354,13 +351,9 @@ void Sapphire::World::WorldServer::updateSessions( uint32_t currTime )
|
|||
{
|
||||
auto removalId = sessionRemovalQueue.front();
|
||||
sessionRemovalQueue.pop();
|
||||
auto session = getSession( removalId );
|
||||
if( session )
|
||||
{
|
||||
m_sessionMapById.erase( removalId );
|
||||
if( auto session = getSession( removalId ) )
|
||||
removeSession( *session->getPlayer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Sapphire::World::WorldServer::createSession( uint32_t sessionId )
|
||||
|
@ -441,6 +434,10 @@ Sapphire::World::SessionPtr Sapphire::World::WorldServer::getSession( const std:
|
|||
|
||||
void Sapphire::World::WorldServer::removeSession( const Entity::Player& player )
|
||||
{
|
||||
auto session = getSession( player.getCharacterId() );
|
||||
if( session )
|
||||
m_sessionMapById.erase( session->getId() );
|
||||
|
||||
m_sessionMapByName.erase( player.getName() );
|
||||
m_sessionMapByCharacterId.erase( player.getCharacterId() );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue