mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
added cbt;
This commit is contained in:
parent
cf2d6108e1
commit
34fc49f153
2 changed files with 55 additions and 0 deletions
|
@ -84,6 +84,7 @@ DebugCommandMgr::DebugCommandMgr()
|
||||||
registerCommand( "cf", &DebugCommandMgr::contentFinder, "Content-Finder", 1 );
|
registerCommand( "cf", &DebugCommandMgr::contentFinder, "Content-Finder", 1 );
|
||||||
registerCommand( "ew", &DebugCommandMgr::easyWarp, "Easy warping", 1 );
|
registerCommand( "ew", &DebugCommandMgr::easyWarp, "Easy warping", 1 );
|
||||||
registerCommand( "reload", &DebugCommandMgr::hotReload, "Reloads a resource", 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
|
// 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 )
|
void DebugCommandMgr::easyWarp( char* data, Sapphire::Entity::Player& player, std::shared_ptr< DebugCommand > command )
|
||||||
{
|
{
|
||||||
std::string subCommand;
|
std::string subCommand;
|
||||||
|
|
|
@ -61,6 +61,8 @@ namespace Sapphire::World::Manager
|
||||||
|
|
||||||
void contentFinder( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command );
|
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 easyWarp( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command );
|
||||||
|
|
||||||
void hotReload( char* data, Sapphire::Entity::Player& player, std::shared_ptr< DebugCommand > command );
|
void hotReload( char* data, Sapphire::Entity::Player& player, std::shared_ptr< DebugCommand > command );
|
||||||
|
|
Loading…
Add table
Reference in a new issue