1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 00:27:44 +00:00

exitInstance moved to playerMgr

This commit is contained in:
Mordred 2025-01-02 09:48:51 +01:00
parent 168cfb1a36
commit 78b800e36e
9 changed files with 26 additions and 26 deletions

View file

@ -26,7 +26,7 @@ public:
eventMgr().playScene( player, eventId, 1, 0, [this, eobj]( Entity::Player& player, const Event::SceneResult& result ) eventMgr().playScene( player, eventId, 1, 0, [this, eobj]( Entity::Player& player, const Event::SceneResult& result )
{ {
if( result.getResult( 0 ) != 1 ) if( result.getResult( 0 ) != 1 )
player.exitInstance(); playerMgr().onExitInstance( player );
} ); } );
} }
}; };

View file

@ -823,7 +823,7 @@ private:
quest.setSeq( Seq6 ); quest.setSeq( Seq6 );
eventMgr().sendEventNotice( player, getId(), 4, 0 ); eventMgr().sendEventNotice( player, getId(), 4, 0 );
playerMgr().sendUrgent( player, "QuestBattle Unimplemented, skipping..." ); playerMgr().sendUrgent( player, "QuestBattle Unimplemented, skipping..." );
player.exitInstance(); playerMgr().onExitInstance( player );
travelToPoprange( player, Poprange3, false ); travelToPoprange( player, Poprange3, false );
} }

View file

@ -397,18 +397,6 @@ bool Player::isAutoattackOn() const
return m_bAutoattack; return m_bAutoattack;
} }
bool Player::exitInstance()
{
auto& warpMgr = Common::Service< WarpMgr >::ref();
resetHp();
resetMp();
warpMgr.requestMoveTerritory( *this, WarpType::WARP_TYPE_CONTENT_END_RETURN, getPrevTerritoryId(), getPrevPos(), getPrevRot() );
return true;
}
uint32_t Player::getPlayTime() const uint32_t Player::getPlayTime() const
{ {
return m_playTime; return m_playTime;

View file

@ -294,9 +294,6 @@ namespace Sapphire::Entity
/*! return current online status depending on current state / activity */ /*! return current online status depending on current state / activity */
Common::OnlineStatus getOnlineStatus() const; Common::OnlineStatus getOnlineStatus() const;
/*! returns the player to their position before zoning into an instance */
bool exitInstance();
/*! gets the players territoryTypeId */ /*! gets the players territoryTypeId */
uint32_t getPrevTerritoryTypeId() const; uint32_t getPrevTerritoryTypeId() const;

View file

@ -923,7 +923,7 @@ void DebugCommandMgr::instance( char* data, Entity::Player& player, std::shared_
} }
else if( subCommand == "return" || subCommand == "ret" ) else if( subCommand == "return" || subCommand == "ret" )
{ {
player.exitInstance(); playerMgr().onExitInstance( player );
} }
else if( subCommand == "stringendomode" || subCommand == "sm" ) else if( subCommand == "stringendomode" || subCommand == "sm" )
{ {
@ -1165,7 +1165,7 @@ void DebugCommandMgr::questBattle( char* data, Entity::Player& player, std::shar
} }
else if( subCommand == "return" || subCommand == "ret" ) else if( subCommand == "return" || subCommand == "ret" )
{ {
player.exitInstance(); playerMgr().onExitInstance( player );
} }
else if( subCommand == "set" ) else if( subCommand == "set" )
{ {

View file

@ -9,6 +9,7 @@
#include <Manager/TerritoryMgr.h> #include <Manager/TerritoryMgr.h>
#include <Manager/HousingMgr.h> #include <Manager/HousingMgr.h>
#include <Manager/QuestMgr.h> #include <Manager/QuestMgr.h>
#include <Manager/WarpMgr.h>
#include <Script/ScriptMgr.h> #include <Script/ScriptMgr.h>
#include <Common.h> #include <Common.h>
@ -527,5 +528,17 @@ void PlayerMgr::onUpdateHuntingLog( Entity::Player& player, uint8_t id )
Network::Util::Packet::sendHuntingLog( player ); Network::Util::Packet::sendHuntingLog( player );
} }
void PlayerMgr::onExitInstance( Entity::Player& player )
{
auto& warpMgr = Common::Service< WarpMgr >::ref();
player.resetHp();
player.resetMp();
warpMgr.requestMoveTerritory( player, Common::WarpType::WARP_TYPE_CONTENT_END_RETURN,
player.getPrevTerritoryId(), player.getPrevPos(), player.getPrevRot() );
}

View file

@ -40,6 +40,8 @@ namespace Sapphire::World::Manager
void onUpdateHuntingLog( Sapphire::Entity::Player& player, uint8_t id ); void onUpdateHuntingLog( Sapphire::Entity::Player& player, uint8_t id );
void onExitInstance( Sapphire::Entity::Player& player );
//////////// Helpers //////////// Helpers
static void sendServerNotice( Sapphire::Entity::Player& player, const std::string& message ); static void sendServerNotice( Sapphire::Entity::Player& player, const std::string& message );

View file

@ -94,7 +94,7 @@ void Sapphire::InstanceContent::onPlayerZoneIn( Entity::Player& player )
if( isTerminationReady() ) // wtf if( isTerminationReady() ) // wtf
{ {
Logger::warn( "Entity#{0} Appear for a terminated instance!", player.getId() ); Logger::warn( "Entity#{0} Appear for a terminated instance!", player.getId() );
player.exitInstance(); playerMgr().onExitInstance( player );
return; return;
} }
@ -202,7 +202,7 @@ void Sapphire::InstanceContent::onUpdate( uint64_t tickCount )
return; return;
auto player = it->second; auto player = it->second;
player->exitInstance(); playerMgr().onExitInstance( *player );
return; return;
} }
} }
@ -235,7 +235,7 @@ void Sapphire::InstanceContent::onEventHandlerOrder( Entity::Player& player, uin
{ {
case 0: // Leave content case 0: // Leave content
{ {
player.exitInstance(); playerMgr().onExitInstance( player );
break; break;
} }
case 1: // Force leave ( afk timer ) case 1: // Force leave ( afk timer )
@ -458,7 +458,7 @@ void Sapphire::InstanceContent::onBeforePlayerZoneIn( Sapphire::Entity::Player&
{ {
// remove any players from the instance who aren't bound on zone in // remove any players from the instance who aren't bound on zone in
if( !isPlayerBound( player.getId() ) ) if( !isPlayerBound( player.getId() ) )
player.exitInstance(); playerMgr().onExitInstance( player );
// if a player has already spawned once inside this instance, don't move them if they happen to zone in again // if a player has already spawned once inside this instance, don't move them if they happen to zone in again
if( !hasPlayerPreviouslySpawned( player ) ) if( !hasPlayerPreviouslySpawned( player ) )
@ -605,7 +605,7 @@ void Sapphire::InstanceContent::unbindPlayer( uint32_t playerId )
auto it = m_playerMap.find( playerId ); auto it = m_playerMap.find( playerId );
if( it != m_playerMap.end() ) if( it != m_playerMap.end() )
it->second->exitInstance(); playerMgr().onExitInstance( *it->second );
} }
void Sapphire::InstanceContent::clearDirector( Entity::Player& player ) void Sapphire::InstanceContent::clearDirector( Entity::Player& player )

View file

@ -158,7 +158,7 @@ void Sapphire::QuestBattle::onUpdate( uint64_t tickCount )
if( ( static_cast< int64_t >( tickCount ) - static_cast< int64_t >( m_instanceFailTime ) ) > 6000 ) if( ( static_cast< int64_t >( tickCount ) - static_cast< int64_t >( m_instanceFailTime ) ) > 6000 )
{ {
m_pPlayer->exitInstance(); playerMgr().onExitInstance( *m_pPlayer );
m_pPlayer.reset(); m_pPlayer.reset();
} }
break; break;
@ -322,7 +322,7 @@ void Sapphire::QuestBattle::success()
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
scriptMgr.onDutyComplete( *this, *m_pPlayer ); scriptMgr.onDutyComplete( *this, *m_pPlayer );
player.exitInstance(); playerMgr().onExitInstance( player );
} ); } );
} ); } );