2018-11-22 01:17:19 +11:00
|
|
|
#include "PlayerMgr.h"
|
|
|
|
|
|
|
|
#include <Framework.h>
|
|
|
|
#include <Exd/ExdDataGenerated.h>
|
|
|
|
|
2018-12-01 00:27:16 +11:00
|
|
|
#include <Manager/TerritoryMgr.h>
|
|
|
|
#include <Territory/ZonePosition.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>
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
extern Sapphire::Framework g_fw;
|
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
|
2018-12-01 00:27:16 +11:00
|
|
|
auto terriMgr = g_fw.get< TerritoryMgr >();
|
2018-11-22 01:17:19 +11:00
|
|
|
if( !terriMgr )
|
|
|
|
return;
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::ZonePtr destinationZone;
|
2018-11-22 01:17:19 +11:00
|
|
|
|
|
|
|
auto terriPos = terriMgr->getTerritoryPosition( landId );
|
|
|
|
if( terriPos )
|
|
|
|
{
|
|
|
|
// check if its a housing zone, zoning is different here
|
2018-11-22 12:27:35 +11:00
|
|
|
if( terriMgr->isHousingTerritory( terriPos->getTargetZoneId() ) )
|
2018-11-22 01:17:19 +11:00
|
|
|
{
|
2018-12-01 00:27:16 +11:00
|
|
|
auto housingMgr = g_fw.get< HousingMgr >();
|
2018-11-22 01:17:19 +11:00
|
|
|
auto landSetId = housingMgr->toLandSetId( terriPos->getTargetZoneId(), param );
|
|
|
|
|
|
|
|
auto housingZone = housingMgr->getHousingZoneByLandSetId( landSetId );
|
|
|
|
|
|
|
|
if( !housingZone )
|
|
|
|
return;
|
|
|
|
|
|
|
|
destinationZone = housingZone;
|
|
|
|
}
|
|
|
|
else if( terriMgr->isInstanceContentTerritory( terriPos->getTargetZoneId() ) )
|
|
|
|
{
|
|
|
|
// todo: instance dungeon handling
|
|
|
|
// will need to use setInstance so old pos gets set
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// normal zones
|
|
|
|
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 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
player.setPos( terriPos->getTargetPosition() );
|
|
|
|
player.setRot( terriPos->getTargetRotation() );
|
|
|
|
|
|
|
|
if( terriMgr->movePlayer( destinationZone, player.getAsPlayer() ) )
|
|
|
|
player.sendZonePackets();
|
|
|
|
}
|