1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 15:17:46 +00:00

Merge branch 'bs-stuff' of https://github.com/hkAlice/Sapphire into bs-stuff-rebase2

This commit is contained in:
Tahir 2024-06-25 03:15:15 +01:00
commit e794df50ba
4 changed files with 77 additions and 3 deletions

View file

@ -19,6 +19,7 @@
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket.h"
#include "Network/PacketWrappers/ActorControlSelfPacket.h"
#include "Network/CommonActorControl.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/PlayerSetupPacket.h"
#include "Network/PacketWrappers/PlayerSpawnPacket.h"
@ -83,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
@ -854,6 +856,7 @@ void DebugCommandMgr::script( char* data, Entity::Player& player, std::shared_pt
void DebugCommandMgr::instance( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command )
{
auto& server = Common::Service< World::WorldServer >::ref();
auto& terriMgr = Common::Service< TerritoryMgr >::ref();
auto pCurrentZone = terriMgr.getTerritoryByGuId( player.getTerritoryId() );
@ -1114,6 +1117,14 @@ void DebugCommandMgr::instance( char* data, Entity::Player& player, std::shared_
if( auto instance = pCurrentZone->getAsInstanceContent() )
instance->setCurrentBGM( bgmId );
}
else if( subCommand == "dir_update" ) {
uint32_t dirType;
uint32_t param;
sscanf( params.c_str(), "%x %d", &dirType, &param );
if( auto instance = pCurrentZone->getAsInstanceContent() )
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), Network::ActorControl::DirectorUpdate, instance->getDirectorId(),
dirType, param ) );
}
else
{
PlayerMgr::sendDebug( player, "Unknown sub command." );
@ -1441,6 +1452,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;

View file

@ -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 );

View file

@ -661,7 +661,7 @@ void Sapphire::InstanceContent::setCurrentBGM( uint16_t bgmIndex )
auto player = playerIt.second;
server.queueForPlayer( player->getCharacterId(),
makeActorControlSelf( player->getId(), DirectorUpdate, getDirectorId(),
DirectorEventId::BattleGroundMusic, bgmIndex ) );
DirectorEventId::BGM, bgmIndex ) );
}
}
@ -669,7 +669,7 @@ void Sapphire::InstanceContent::setPlayerBGM( Sapphire::Entity::Player& player,
{
auto& server = Common::Service< World::WorldServer >::ref();
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), DirectorUpdate, getDirectorId(),
DirectorEventId::BattleGroundMusic, bgmId ) );
DirectorEventId::BGM, bgmId ) );
}
uint16_t Sapphire::InstanceContent::getCurrentBGM() const

View file

@ -37,6 +37,7 @@ namespace Sapphire
0x4000000E - INSTANCE_CONTENT_ORDER_SYSTEM_Unknown - no args - some timer set */
enum DirectorEventId : uint32_t
{
// 2.3
DEBUG_TimeSync = 0xC0000001,
DutyCommence = 0x40000001,
DutyComplete = 0x40000002,
@ -44,7 +45,7 @@ namespace Sapphire
SetDutyTime = 0x40000004,
LoadingScreen = 0x40000005,
Forward = 0x40000006,
BattleGroundMusic = 0x40000007,
//BattleGroundMusic = 0x40000007,
InvalidateTodoList = 0x40000008,
VoteState = 0x40000009,
VoteStart = 0x4000000A,
@ -53,6 +54,14 @@ namespace Sapphire
FirstTimeNotify = 0x4000000D,
TreasureVoteRefresh = 0x4000000E,
SetSharedGroupId = 0x4000000F,
// 3.3x onwards
Sync = 0x80000000,
BGM = 0x80000001,
SyncDutyTimer = 0x80000003,
// some vote stuff here
StartEventCutscene = 0x80000008,
EndEventCutscene = 0x80000009,
StartQTE = 0x8000000A
};
enum EventHandlerOrderId : uint32_t