mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
Merge pull request #433 from NotAdam/housing
Add playermgr, add generic handler for teleporting to warp destinations
This commit is contained in:
commit
950e15c25c
6 changed files with 85 additions and 30 deletions
|
@ -218,7 +218,8 @@ INSERT INTO `zonepositions` (`id`, `target_zone_id`, `pos_x`, `pos_y`, `pos_z`,
|
|||
(1359650, 153, -226.643, 21.23, 351.76, -0.74, 2),
|
||||
(3965709, 147, 22.9166, 48.309, -26.801, -2.406, 2),
|
||||
(3965584, 146, -320.39, 8.262, 406.08, -1.455, 2),
|
||||
(5668783, 144, -0.3458, 1.0425, -5.786, 0.0603, 2);
|
||||
(5668783, 144, -0.3458, 1.0425, -5.786, 0.0603, 2),
|
||||
(4656744, 341, 29.4298, -11.0766, -211.529, -0.5092, 2);
|
||||
/*!40000 ALTER TABLE `zonepositions` ENABLE KEYS */;
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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*
|
||||
|
|
66
src/servers/sapphire_zone/Manager/PlayerMgr.cpp
Normal file
66
src/servers/sapphire_zone/Manager/PlayerMgr.cpp
Normal 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();
|
||||
}
|
10
src/servers/sapphire_zone/Manager/PlayerMgr.h
Normal file
10
src/servers/sapphire_zone/Manager/PlayerMgr.h
Normal 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 );
|
||||
};
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue