mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 00:27:44 +00:00
Fix create linkshell event with existing name
This commit is contained in:
parent
0c6a0b0323
commit
fed653ed62
5 changed files with 22 additions and 26 deletions
|
@ -2,8 +2,7 @@
|
|||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionSprint3 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
class ActionSprint3 : public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionSprint3() :
|
||||
|
|
|
@ -47,12 +47,12 @@ public:
|
|||
auto ls = linkshellMgr().createLinkshell( result.resultString, player );
|
||||
if( !ls )
|
||||
{
|
||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0x15a } );
|
||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0x15a }, false );
|
||||
linkshellMgr().finishLinkshellCreation( result.resultString, 0x15a, player );
|
||||
}
|
||||
else
|
||||
{
|
||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 } );
|
||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 }, true );
|
||||
linkshellMgr().finishLinkshellCreation( result.resultString, 0, player );
|
||||
}
|
||||
|
||||
|
|
|
@ -542,13 +542,15 @@ void EventMgr::playScene( Entity::Player& player, uint32_t eventId, uint32_t sce
|
|||
sendEventPlay( player, eventId, scene, flags );
|
||||
}
|
||||
|
||||
void EventMgr::resumeScene( Entity::Player& player, uint32_t eventId, uint32_t scene, std::vector< uint32_t > values )
|
||||
void EventMgr::resumeScene( Entity::Player& player, uint32_t eventId, uint32_t scene, std::vector< uint32_t > values, bool resetCallback )
|
||||
{
|
||||
auto pEvent = bootstrapSceneEvent( player, eventId, 0 );
|
||||
if( !pEvent )
|
||||
return;
|
||||
|
||||
pEvent->setEventReturnCallback( nullptr );
|
||||
if( resetCallback )
|
||||
pEvent->setEventReturnCallback( nullptr );
|
||||
|
||||
auto resumeEvent = makeZonePacket< FFXIVIpcResumeEventScene2 >( player.getId() );
|
||||
resumeEvent->data().handlerId = eventId;
|
||||
resumeEvent->data().sceneId = static_cast< uint8_t >( scene );
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Sapphire::World::Manager
|
|||
Event::EventHandler::SceneReturnCallback eventReturnCallback = nullptr );
|
||||
|
||||
/*! resume a subevent */
|
||||
void resumeScene( Entity::Player& player, uint32_t eventId, uint32_t scene, std::vector< uint32_t > values );
|
||||
void resumeScene( Entity::Player& player, uint32_t eventId, uint32_t scene, std::vector< uint32_t > values, bool resetCallback );
|
||||
|
||||
/*! play a subevent */
|
||||
void playScene( Entity::Player& player, uint32_t eventId, uint32_t scene, uint32_t flags,
|
||||
|
|
|
@ -152,10 +152,6 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellById(
|
|||
|
||||
Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell( const std::string& name, Entity::Player& player )
|
||||
{
|
||||
auto& chatChannelMgr = Common::Service< Manager::ChatChannelMgr >::ref();
|
||||
auto chatChannelId = chatChannelMgr.createChatChannel( Common::ChatChannelType::LinkshellChat );
|
||||
chatChannelMgr.addPlayerToChannel( chatChannelId, player );
|
||||
|
||||
uint64_t linkshellId = 1;
|
||||
|
||||
if( !m_linkshellIdMap.empty() )
|
||||
|
@ -169,6 +165,10 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
|||
if( lsIt != m_linkshellNameMap.end() )
|
||||
return nullptr;
|
||||
|
||||
auto& chatChannelMgr = Common::Service< Manager::ChatChannelMgr >::ref();
|
||||
auto chatChannelId = chatChannelMgr.createChatChannel( Common::ChatChannelType::LinkshellChat );
|
||||
chatChannelMgr.addPlayerToChannel( chatChannelId, player );
|
||||
|
||||
uint64_t masterId = player.getCharacterId();
|
||||
|
||||
// TODO: remove this messy set
|
||||
|
@ -187,7 +187,6 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
|||
// TODO: handle player pkt
|
||||
|
||||
// prepare binary data for SQL
|
||||
|
||||
std::vector< uint64_t > members( 128, 0 );
|
||||
std::vector< uint64_t > leaders( 128, 0 );
|
||||
std::vector< uint64_t > invites( 128, 0 );
|
||||
|
@ -204,10 +203,7 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
|||
std::vector< uint8_t > invVec( sizeof( invites ) );
|
||||
memcpy( invVec.data(), invites.data(), sizeof( invites ) );
|
||||
|
||||
// TODO: insert in SQL
|
||||
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_LINKSHELL_INS );
|
||||
stmt->setUInt64( 1, linkshellId );
|
||||
stmt->setUInt64( 2, masterId );
|
||||
|
@ -220,11 +216,12 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
|||
|
||||
return lsPtr;
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::LinkshellMgr::finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player )
|
||||
{
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
|
||||
auto linkshellResult = makeLinkshellResult( player, 0, 0, 1, 0, 0, name, "" );
|
||||
auto linkshellResult = makeLinkshellResult( player, 0, 0, 1, result, 0, name, "" );
|
||||
server.queueForPlayer( player.getCharacterId(), linkshellResult );
|
||||
|
||||
}
|
||||
|
@ -233,18 +230,16 @@ const std::vector< Sapphire::LinkshellPtr > Sapphire::World::Manager::LinkshellM
|
|||
{
|
||||
std::vector< Sapphire::LinkshellPtr > lsVec;
|
||||
|
||||
if( !m_linkshellIdMap.empty() )
|
||||
for( const auto &[ key, value ] : m_linkshellIdMap )
|
||||
{
|
||||
for( const auto &[ key, value ] : m_linkshellIdMap )
|
||||
{
|
||||
auto& memberList = value->getMemberIdList();
|
||||
auto& inviteList = value->getInviteIdList();
|
||||
auto& memberList = value->getMemberIdList();
|
||||
auto& inviteList = value->getInviteIdList();
|
||||
|
||||
// find player id in LS member list
|
||||
if( memberList.count( player.getCharacterId() ) || inviteList.count( player.getCharacterId() ) )
|
||||
{
|
||||
lsVec.emplace_back( value );
|
||||
}
|
||||
// find player id in LS member or invite list
|
||||
if( memberList.count( player.getCharacterId() ) ||
|
||||
inviteList.count( player.getCharacterId() ) )
|
||||
{
|
||||
lsVec.emplace_back( value );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue