1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

Move warping to land points to a generic handler

This commit is contained in:
NotAdam 2018-11-22 01:17:19 +11:00
parent 7dbab22aed
commit 065a5b35a0
5 changed files with 83 additions and 29 deletions

View file

@ -2,10 +2,8 @@
#include <Actor/Player.h>
#include <Exd/ExdDataGenerated.h>
#include <Zone/TerritoryMgr.h>
#include <Zone/HousingMgr.h>
#include <Zone/ZonePosition.h>
#include <Framework.h>
#include <Manager/PlayerMgr.h>
using namespace Core;
@ -29,37 +27,13 @@ public:
player.eventFinish( 1310721, 0 );
player.eventFinish( getId(), 1 );
// todo: this is shit, move to housingmgr? handle moving players in and out of it there?
auto exdData = getFramework()->get< Core::Data::ExdDataGenerated >();
auto warp = exdData->get< Core::Data::Warp >( getId() );
if( !warp )
return;
auto level = exdData->get< Core::Data::Level >( warp->level );
if( !level )
{
// fetch from cache
auto teriMgr = getFramework()->get< Core::TerritoryMgr >();
auto pos = teriMgr->getTerritoryPosition( warp->level );
if( !pos )
return;
// lookup instance
auto housingMgr = getFramework()->get< Core::HousingMgr >();
auto landSetId = housingMgr->toLandSetId( 341, result.param3 );
auto hZone = housingMgr->getHousingZoneByLandSetId( landSetId );
if( !hZone )
return;
player.setPos( pos->getTargetPosition() );
player.setRot( pos->getTargetRotation() );
player.setInstance( hZone );
}
auto playerMgr = getFramework()->get< Sapphire::World::Manager::PlayerMgr >();
playerMgr->movePlayerToLandDestination( player, warp->level, result.param3 );
}
else
{

View file

@ -12,6 +12,7 @@ file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Event/*.c*
Inventory/*.c*
Linkshell/*.c*
Manager/*.c*
Math/*.c*
Network/*.c*
Network/Handlers/*.c*

View file

@ -0,0 +1,66 @@
#include "PlayerMgr.h"
#include <Framework.h>
#include <Exd/ExdDataGenerated.h>
#include <Zone/TerritoryMgr.h>
#include <Zone/ZonePosition.h>
#include <Zone/HousingMgr.h>
#include <Actor/Player.h>
extern Core::Framework g_fw;
void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Core::Entity::Player& player, uint32_t landId, uint16_t param )
{
// check if we have one in the db first
auto terriMgr = g_fw.get< Core::TerritoryMgr >();
if( !terriMgr )
return;
Core::ZonePtr destinationZone;
auto terriPos = terriMgr->getTerritoryPosition( landId );
if( terriPos )
{
// check if its a housing zone, zoning is different here
if( terriMgr->isHousingTerritory( terriPos->getTargetZoneId() ) && param != 0 )
{
auto housingMgr = g_fw.get< Core::HousingMgr >();
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();
}

View file

@ -0,0 +1,10 @@
#include "ForwardsZone.h"
namespace Sapphire::World::Manager
{
class PlayerMgr
{
public:
void movePlayerToLandDestination( Core::Entity::Player& player, uint32_t landId, uint16_t param = 0 );
};
}

View file

@ -11,6 +11,7 @@
#include "Zone/TerritoryMgr.h"
#include "Zone/HousingMgr.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Manager/PlayerMgr.h"
#include <Config/ConfigMgr.h>
@ -30,6 +31,7 @@ bool setupFramework()
auto pTeriMgr = std::make_shared< TerritoryMgr >();
auto pDebugCom = std::make_shared< DebugCommandHandler >();
auto pConfig = std::make_shared< ConfigMgr >();
auto pPlayerMgr = std::make_shared< Sapphire::World::Manager::PlayerMgr >();
pLogger->setLogPath( "log/SapphireZone" );
pLogger->init();
@ -44,6 +46,7 @@ bool setupFramework()
g_fw.set< TerritoryMgr >( pTeriMgr );
g_fw.set< DebugCommandHandler >( pDebugCom );
g_fw.set< ConfigMgr >( pConfig );
g_fw.set< Sapphire::World::Manager::PlayerMgr >( pPlayerMgr );
// actuall catch errors here...
return true;