1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-24 13:47:46 +00:00
sapphire/src/world/Manager/PlayerMgr.cpp

70 lines
1.9 KiB
C++
Raw Normal View History

#include "PlayerMgr.h"
#include <Exd/ExdDataGenerated.h>
#include <Manager/TerritoryMgr.h>
#include <Territory/ZonePosition.h>
2019-07-21 22:33:33 +10:00
#include <Territory/Territory.h>
#include <Manager/HousingMgr.h>
#include <Actor/Player.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
using namespace Sapphire::World::Manager;
void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Sapphire::Entity::Player& player, uint32_t landId, uint16_t param )
{
// check if we have one in the db first
2020-03-01 01:00:57 +11:00
auto& terriMgr = Common::Service< TerritoryMgr >::ref();
2019-07-21 22:33:33 +10:00
Sapphire::TerritoryPtr destinationZone;
2020-03-01 01:00:57 +11:00
auto terriPos = terriMgr.getTerritoryPosition( landId );
if( terriPos )
{
// check if its a housing zone, zoning is different here
2020-03-01 01:00:57 +11:00
if( terriMgr.isHousingTerritory( terriPos->getTargetZoneId() ) )
{
2020-03-01 01:00:57 +11:00
auto& housingMgr = Common::Service< HousingMgr >::ref();
auto landSetId = housingMgr.toLandSetId( terriPos->getTargetZoneId(), param );
2020-03-01 01:00:57 +11:00
auto housingZone = housingMgr.getHousingZoneByLandSetId( landSetId );
if( !housingZone )
return;
destinationZone = housingZone;
}
2020-03-01 01:00:57 +11:00
else if( terriMgr.isInstanceContentTerritory( terriPos->getTargetZoneId() ) )
{
// todo: instance dungeon handling
// will need to use setInstance so old pos gets set
return;
}
else
{
// normal zones
2020-03-01 01:00:57 +11:00
destinationZone = terriMgr.getZoneByTerritoryTypeId( terriPos->getTargetZoneId() );
}
}
else
{
// todo: lookup land.exd and see if it's in there if its not in our db
return;
}
if( !destinationZone )
{
player.sendDebug( "Unable to find applicable territory for Warp#{0}. "
"Check that it exists inside zonepositions table.",
landId );
return;
}
player.setPos( terriPos->getTargetPosition() );
player.setRot( terriPos->getTargetRotation() );
2020-03-01 01:00:57 +11:00
terriMgr.movePlayer( destinationZone, player.getAsPlayer() );
}