diff --git a/src/world/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index ba9901f7..5420eb79 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -84,6 +84,7 @@ DebugCommandMgr::DebugCommandMgr() registerCommand( "cf", &DebugCommandMgr::contentFinder, "Content-Finder", 1 ); registerCommand( "ew", &DebugCommandMgr::easyWarp, "Easy warping", 1 ); registerCommand( "reload", &DebugCommandMgr::hotReload, "Reloads a resource", 1 ); + registerCommand( "cbt", &DebugCommandMgr::cbt, "Create, bind and teleport to an instance", 1 ); } // clear all loaded commands @@ -1441,6 +1442,58 @@ void DebugCommandMgr::contentFinder( char *data, Sapphire::Entity::Player &playe } +void DebugCommandMgr::cbt( char* data, Sapphire::Entity::Player& player, std::shared_ptr< DebugCommand > command ) +{ + std::string subCommand; + std::string params = ""; + + // check if the command has parameters + std::string tmpCommand = std::string( data + command->getName().length() + 1 ); + + std::size_t pos = tmpCommand.find_first_of( ' ' ); + + if( pos != std::string::npos ) + // command has parameters, grab the first part + subCommand = tmpCommand.substr( 0, pos ); + else + // no subcommand given + subCommand = tmpCommand; + + if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) + params = std::string( data + command->getName().length() + 1 + pos + 1 ); + + auto& terriMgr = Common::Service< TerritoryMgr >::ref(); + auto& warpMgr = Common::Service< WarpMgr >::ref(); + + uint32_t contentFinderConditionId; + sscanf( params.c_str(), "%d", &contentFinderConditionId ); + + auto instance = terriMgr.createInstanceContent( contentFinderConditionId ); + if( instance ) + PlayerMgr::sendDebug( player, "Created instance with id#{0} -> {1}", instance->getGuId(), instance->getName() ); + else + return PlayerMgr::sendDebug( player, "Failed to create instance with id#{0}", contentFinderConditionId ); + + + auto terri = terriMgr.getTerritoryByGuId( instance->getGuId() ); + if( terri ) + { + auto pInstanceContent = terri->getAsInstanceContent(); + if( !pInstanceContent ) + { + PlayerMgr::sendDebug( player, "Instance id#{} is not an InstanceContent territory.", pInstanceContent->getGuId() ); + return; + } + + pInstanceContent->bindPlayer( player.getId() ); + PlayerMgr::sendDebug( player, + "Now bound to instance with id: " + std::to_string( pInstanceContent->getGuId() ) + + " -> " + pInstanceContent->getName() ); + + warpMgr.requestMoveTerritory( player, Common::WarpType::WARP_TYPE_INSTANCE_CONTENT, instance->getGuId(), { 0.f, 0.f, 0.f }, 0.f ); + } +} + void DebugCommandMgr::easyWarp( char* data, Sapphire::Entity::Player& player, std::shared_ptr< DebugCommand > command ) { std::string subCommand; diff --git a/src/world/Manager/DebugCommandMgr.h b/src/world/Manager/DebugCommandMgr.h index 084b99b6..b8e39c64 100644 --- a/src/world/Manager/DebugCommandMgr.h +++ b/src/world/Manager/DebugCommandMgr.h @@ -61,6 +61,8 @@ namespace Sapphire::World::Manager void contentFinder( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); + void cbt( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); + void easyWarp( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); void hotReload( char* data, Sapphire::Entity::Player& player, std::shared_ptr< DebugCommand > command );