mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-06 18:57:45 +00:00
Some more packet cleanup.
This commit is contained in:
parent
ca002dadd1
commit
fb7be5053a
6 changed files with 65 additions and 80 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
|
||||
#include <Network/CommonActorControl.h>
|
||||
#include <Network/GameConnection.h>
|
||||
#include <Network/Util/PacketUtil.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <cstring>
|
||||
|
@ -434,8 +435,7 @@ bool HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint
|
|||
// TODO: actually use permissions here for FC houses
|
||||
if( !hasPermission( player, *pLand, 0 ) )
|
||||
{
|
||||
auto msgPkt = makeActorControlSelf( player.getId(), ActorControl::LogMsg, 3304, 0 );
|
||||
server.queueForPlayer( player.getCharacterId(), msgPkt );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::LogMsg, 3304 );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -443,8 +443,7 @@ bool HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint
|
|||
// TODO: additionally check for yard items
|
||||
if( pLand->getHouse() )
|
||||
{
|
||||
auto msgPkt = makeActorControlSelf( player.getId(), ActorControl::LogMsg, 3315, 0 );
|
||||
server.queueForPlayer( player.getCharacterId(), msgPkt );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::LogMsg, 3315 );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -460,11 +459,8 @@ bool HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint
|
|||
|
||||
sendLandFlagsSlot( player, Common::LandFlagsSlot::Private );
|
||||
|
||||
auto screenMsgPkt2 = makeActorControlSelf( player.getId(), ActorControl::LogMsg, 3351, 0x1AA,
|
||||
pLand->getLandIdent().wardNum + 1, plot + 1 );
|
||||
server.queueForPlayer( player.getCharacterId(), screenMsgPkt2 );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::LogMsg, 3351, 0x1AA, pLand->getLandIdent().wardNum + 1, plot + 1 );
|
||||
zone.sendLandUpdate( plot );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -708,9 +704,7 @@ void HousingMgr::buildPresetEstate( Entity::Player& player, HousingZone& zone, u
|
|||
pLand->setLandType( Common::LandType::Private );
|
||||
zone.sendLandUpdate( plotNum );
|
||||
|
||||
auto pSuccessBuildingPacket = makeActorControl( player.getId(), ActorControl::BuildPresetResponse, plotNum );
|
||||
|
||||
server.queueForPlayer( player.getCharacterId(), pSuccessBuildingPacket );
|
||||
Network::Util::Packet::sendActorControl( player, ActorControl::BuildPresetResponse, plotNum );
|
||||
|
||||
pLand->updateLandDb();
|
||||
|
||||
|
@ -1065,7 +1059,7 @@ void HousingMgr::reqPlaceHousingItem( Entity::Player& player, uint16_t landId, u
|
|||
status = placeInteriorItem( player, item );
|
||||
|
||||
if( status )
|
||||
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), 0x3f3 ) );
|
||||
Network::Util::Packet::sendActorControlSelf( player, 0x3f3 );
|
||||
else
|
||||
PlayerMgr::sendUrgent( player, "An internal error occurred when placing the item." );
|
||||
}
|
||||
|
@ -1343,7 +1337,7 @@ bool HousingMgr::moveInternalItem( Entity::Player& player, Common::LandIdent ide
|
|||
// send confirmation to player
|
||||
uint32_t param1 = static_cast< uint32_t >( ( ident.landId << 16 ) | containerId );
|
||||
|
||||
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), ActorControl::HousingItemMoveConfirm, param1, slotIdx ) );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::HousingItemMoveConfirm, param1, slotIdx );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1377,7 +1371,7 @@ bool HousingMgr::moveExternalItem( Entity::Player& player, Common::LandIdent ide
|
|||
terri.updateYardObjectPos( player, slot, static_cast< uint16_t >( ident.landId ), *item );
|
||||
|
||||
uint32_t param1 = static_cast< uint32_t >( ( ident.landId << 16 ) | Common::InventoryType::HousingExteriorPlacedItems );
|
||||
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), ActorControl::HousingItemMoveConfirm, param1, slot ) );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::HousingItemMoveConfirm, param1, slot ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1614,9 +1608,7 @@ void HousingMgr::reqEstateExteriorRemodel( Entity::Player& player, uint16_t plot
|
|||
|
||||
invMgr.sendInventoryContainer( player, it->second );
|
||||
|
||||
auto pkt = makeActorControlSelf( player.getId(), Network::ActorControl::ShowEstateExternalAppearanceUI, plot );
|
||||
server.queueForPlayer( player.getCharacterId(), pkt );
|
||||
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::ShowEstateExternalAppearanceUI, plot );
|
||||
}
|
||||
|
||||
void HousingMgr::reqEstateInteriorRemodel( Entity::Player& player )
|
||||
|
@ -1653,8 +1645,7 @@ void HousingMgr::reqEstateInteriorRemodel( Entity::Player& player )
|
|||
|
||||
invMgr.sendInventoryContainer( player, it->second );
|
||||
|
||||
auto pkt = makeActorControlSelf( player.getId(), Network::ActorControl::ShowEstateInternalAppearanceUI );
|
||||
server.queueForPlayer( player.getCharacterId(), pkt );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::ShowEstateInternalAppearanceUI );
|
||||
}
|
||||
|
||||
bool HousingMgr::hasPermission( Entity::Player& player, Sapphire::Land& land, uint32_t permission )
|
||||
|
@ -1697,8 +1688,7 @@ void HousingMgr::removeHouse( Entity::Player& player, uint16_t plot )
|
|||
// TODO: actually use permissions here for FC houses
|
||||
if( !hasPermission( player, *pLand, 0 ) )
|
||||
{
|
||||
auto msgPkt = makeActorControlSelf( player.getId(), ActorControl::LogMsg, 3305, 0 );
|
||||
server.queueForPlayer( player.getCharacterId(), msgPkt );
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::LogMsg, 3305 );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -307,10 +307,15 @@ void PlayerMgr::onUpdate( Entity::Player& player, uint64_t tickCount )
|
|||
if( !player.isAlive() )
|
||||
return;
|
||||
|
||||
auto mainWeap = player.getItemAt( Common::GearSet0, Common::GearSetSlot::MainHand );
|
||||
if( mainWeap && !player.checkAction() && ( player.getTargetId() && player.getStance() == Common::Stance::Active && player.isAutoattackOn() ) )
|
||||
{
|
||||
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need...
|
||||
checkAutoAttack( player, tickCount );
|
||||
}
|
||||
|
||||
void PlayerMgr::checkAutoAttack( Entity::Player& player, uint64_t tickCount ) const
|
||||
{
|
||||
auto mainWeap = player.getItemAt( Common::GearSet0, Common::MainHand );
|
||||
if( !mainWeap || !player.isAutoattackOn() || player.checkAction() || !player.getTargetId() || player.getStance() != Common::Active )
|
||||
return;
|
||||
|
||||
for( const auto& actor : player.getInRangeActors() )
|
||||
{
|
||||
if( actor->getId() != player.getTargetId() || !actor->getAsChara()->isAlive() )
|
||||
|
@ -326,16 +331,14 @@ void PlayerMgr::onUpdate( Entity::Player& player, uint64_t tickCount )
|
|||
if( classJob == Common::ClassJob::Machinist || classJob == Common::ClassJob::Bard || classJob == Common::ClassJob::Archer )
|
||||
range = 25.f + chara->getRadius() + player.getRadius() * 0.5f;
|
||||
|
||||
if( Common::Util::distance( player.getPos(), actor->getPos() ) <= range )
|
||||
{
|
||||
if( ( tickCount - player.getLastAttack() ) > mainWeap->getDelay() )
|
||||
if( ( Common::Util::distance( player.getPos(), actor->getPos() ) <= range ) &&
|
||||
( ( tickCount - player.getLastAttack() ) > mainWeap->getDelay() ) )
|
||||
{
|
||||
player.setLastAttack( tickCount );
|
||||
player.autoAttack( actor->getAsChara() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ namespace Sapphire::World::Manager
|
|||
std::map< uint32_t, Entity::PlayerPtr > m_playerMapById;
|
||||
std::map< uint64_t, Entity::PlayerPtr > m_playerMapByCharacterId;
|
||||
std::map< std::string, Entity::PlayerPtr > m_playerMapByName;
|
||||
|
||||
void checkAutoAttack( Entity::Player& player, uint64_t tickCount ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <Network/CommonActorControl.h>
|
||||
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
|
||||
#include <Network/PacketWrappers/ActorControlPacket.h>
|
||||
#include <Network/Util/PacketUtil.h>
|
||||
|
||||
#include <Manager/PlayerMgr.h>
|
||||
#include <Manager/MapMgr.h>
|
||||
|
@ -90,10 +91,8 @@ void WarpMgr::requestWarp( Entity::Player& player, Common::WarpType warpType, Co
|
|||
{
|
||||
m_entityIdToWarpInfoMap[ player.getId() ] = { 0, warpType, targetPos, targetRot };
|
||||
|
||||
server().queueForPlayers( player.getInRangePlayerIds( true ),
|
||||
makeActorControlSelf( player.getId(), WarpStart, warpType, warpType, 0, player.getTerritoryTypeId(), 1 ) );
|
||||
server().queueForPlayers( player.getInRangePlayerIds(),
|
||||
makeActorControl( player.getId(), ActorDespawnEffect, warpType, player.getTerritoryTypeId() ) );
|
||||
Network::Util::Packet::sendActorControlSelf( player.getInRangePlayerIds( true ), player, WarpStart, warpType, warpType, 0, player.getTerritoryTypeId(), 1 );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, ActorDespawnEffect, warpType, player.getTerritoryTypeId() );
|
||||
|
||||
auto& taskMgr = Common::Service< TaskMgr >::ref();
|
||||
taskMgr.queueTask( makeWarpTask( player, warpType, targetPos, targetRot, 1000 ) );
|
||||
|
@ -127,14 +126,11 @@ void WarpMgr::finishWarp( Entity::Player& player )
|
|||
|
||||
auto warpFinishAnim = warpType - 1;
|
||||
|
||||
auto zoneInPacket = makeActorControlSelf( player.getId(), Appear, warpFinishAnim, raiseAnim, 0, 0 );
|
||||
auto setStatusPacket = makeActorControl( player.getId(), SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
|
||||
|
||||
if( !player.getGmInvis() )
|
||||
server().queueForPlayers( player.getInRangePlayerIds(), zoneInPacket );
|
||||
Network::Util::Packet::sendActorControlSelf( player.getInRangePlayerIds(), player, Appear, warpFinishAnim, raiseAnim );
|
||||
|
||||
server().queueForPlayer( player.getCharacterId(), zoneInPacket );
|
||||
server().queueForPlayers( player.getInRangePlayerIds( true ), setStatusPacket );
|
||||
Network::Util::Packet::sendActorControlSelf( player, Appear, warpFinishAnim, raiseAnim );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player, SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
|
||||
|
||||
player.removeCondition( PlayerCondition::BetweenAreas );
|
||||
|
||||
|
|
|
@ -103,9 +103,7 @@ void Sapphire::Network::GameConnection::getSearchCommentHandler( const Packets::
|
|||
|
||||
Logger::debug( "getSearchCommentHandler: {0}", targetId );
|
||||
|
||||
if( pPlayer )
|
||||
{
|
||||
if( pPlayer->isActingAsGm() || pPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() )
|
||||
if( !pPlayer || pPlayer->isActingAsGm() || pPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() )
|
||||
return;
|
||||
|
||||
// retail sends the requester's id as both (isForSelf)
|
||||
|
@ -113,7 +111,7 @@ void Sapphire::Network::GameConnection::getSearchCommentHandler( const Packets::
|
|||
searchInfoPacket->data().TargetEntityID = targetId;
|
||||
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 )
|
||||
|
@ -313,14 +311,14 @@ void Sapphire::Network::GameConnection::newDiscoveryHandler( const Packets::FFXI
|
|||
|
||||
PlayerMgr::sendDebug( player, "Discovery ref pos id#{0}", layoutId );
|
||||
|
||||
if( pRefInfo )
|
||||
{
|
||||
if( !pRefInfo )
|
||||
return;
|
||||
|
||||
auto discoveryPacket = makeZonePacket< FFXIVIpcDiscoveryReply >( player.getId() );
|
||||
discoveryPacket->data().mapId = tInfo->data().Map;
|
||||
discoveryPacket->data().mapPartId = pRefInfo->data.discoveryIndex;
|
||||
server().queueForPlayer( player.getCharacterId(), discoveryPacket );
|
||||
player.discover( tInfo->data().Map, pRefInfo->data.discoveryIndex );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -363,9 +361,7 @@ void Sapphire::Network::GameConnection::setLanguageHandler( const Packets::FFXIV
|
|||
|
||||
// if this is a login event
|
||||
if( player.isLogin() )
|
||||
{
|
||||
playerMgr().sendLoginMessage( player );
|
||||
}
|
||||
|
||||
// spawn the player for himself
|
||||
player.spawn( player.getAsPlayer() );
|
||||
|
@ -619,9 +615,7 @@ void Sapphire::Network::GameConnection::gearSetEquip( const Packets::FFXIVARR_PA
|
|||
player.sendGearInventory();
|
||||
|
||||
if( packet.data().contextId < 0xFE )
|
||||
{
|
||||
server().queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), Network::ActorControl::GearSetEquipMsg, packet.data().contextId ) );
|
||||
}
|
||||
Network::Util::Packet::sendActorControlSelf( player, GearSetEquipMsg, packet.data().contextId );
|
||||
|
||||
auto invTransFinPacket = makeZonePacket< FFXIVIpcItemOperationBatch >( player.getId() );
|
||||
invTransFinPacket->data().contextId = contextId;
|
||||
|
|
Loading…
Add table
Reference in a new issue