2018-11-22 01:17:19 +11:00
|
|
|
#include "PlayerMgr.h"
|
|
|
|
|
|
|
|
#include <Exd/ExdDataGenerated.h>
|
|
|
|
|
2018-12-01 00:27:16 +11:00
|
|
|
#include <Manager/TerritoryMgr.h>
|
|
|
|
#include <Territory/ZonePosition.h>
|
2019-07-21 22:33:33 +10:00
|
|
|
#include <Territory/Territory.h>
|
2018-11-22 01:17:19 +11:00
|
|
|
|
2018-12-01 00:27:16 +11:00
|
|
|
#include <Manager/HousingMgr.h>
|
2018-11-22 01:17:19 +11:00
|
|
|
|
|
|
|
#include <Actor/Player.h>
|
2020-03-01 01:00:57 +11:00
|
|
|
#include <Service.h>
|
2018-11-22 01:17:19 +11:00
|
|
|
|
2018-12-01 00:27:16 +11:00
|
|
|
using namespace Sapphire::World::Manager;
|
2018-11-22 01:17:19 +11:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Sapphire::Entity::Player& player, uint32_t landId, uint16_t param )
|
2018-11-22 01:17:19 +11:00
|
|
|
{
|
|
|
|
// check if we have one in the db first
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& terriMgr = Common::Service< TerritoryMgr >::ref();
|
2018-11-22 01:17:19 +11:00
|
|
|
|
2019-07-21 22:33:33 +10:00
|
|
|
Sapphire::TerritoryPtr destinationZone;
|
2018-11-22 01:17:19 +11:00
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
auto terriPos = terriMgr.getTerritoryPosition( landId );
|
2018-11-22 01:17:19 +11:00
|
|
|
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() ) )
|
2018-11-22 01:17:19 +11:00
|
|
|
{
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& housingMgr = Common::Service< HousingMgr >::ref();
|
|
|
|
auto landSetId = housingMgr.toLandSetId( terriPos->getTargetZoneId(), param );
|
2018-11-22 01:17:19 +11:00
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
auto housingZone = housingMgr.getHousingZoneByLandSetId( landSetId );
|
2018-11-22 01:17:19 +11:00
|
|
|
|
|
|
|
if( !housingZone )
|
|
|
|
return;
|
|
|
|
|
|
|
|
destinationZone = housingZone;
|
|
|
|
}
|
2020-03-01 01:00:57 +11:00
|
|
|
else if( terriMgr.isInstanceContentTerritory( terriPos->getTargetZoneId() ) )
|
2018-11-22 01:17:19 +11:00
|
|
|
{
|
|
|
|
// 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() );
|
2018-11-22 01:17:19 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// todo: lookup land.exd and see if it's in there if its not in our db
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !destinationZone )
|
2019-03-17 13:50:01 +11:00
|
|
|
{
|
|
|
|
player.sendDebug( "Unable to find applicable territory for Warp#{0}. "
|
|
|
|
"Check that it exists inside zonepositions table.",
|
|
|
|
landId );
|
2018-11-22 01:17:19 +11:00
|
|
|
return;
|
2019-03-17 13:50:01 +11:00
|
|
|
}
|
2018-11-22 01:17:19 +11:00
|
|
|
|
|
|
|
player.setPos( terriPos->getTargetPosition() );
|
|
|
|
player.setRot( terriPos->getTargetRotation() );
|
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
terriMgr.movePlayer( destinationZone, player.getAsPlayer() );
|
2018-12-22 22:25:03 +01:00
|
|
|
}
|