mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57: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 <Actor/Player.h>
|
||||||
#include <Action/Action.h>
|
#include <Action/Action.h>
|
||||||
|
|
||||||
class ActionSprint3 :
|
class ActionSprint3 : public Sapphire::ScriptAPI::ActionScript
|
||||||
public Sapphire::ScriptAPI::ActionScript
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActionSprint3() :
|
ActionSprint3() :
|
||||||
|
|
|
@ -47,12 +47,12 @@ public:
|
||||||
auto ls = linkshellMgr().createLinkshell( result.resultString, player );
|
auto ls = linkshellMgr().createLinkshell( result.resultString, player );
|
||||||
if( !ls )
|
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 );
|
linkshellMgr().finishLinkshellCreation( result.resultString, 0x15a, player );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 } );
|
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 }, true );
|
||||||
linkshellMgr().finishLinkshellCreation( result.resultString, 0, player );
|
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 );
|
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 );
|
auto pEvent = bootstrapSceneEvent( player, eventId, 0 );
|
||||||
if( !pEvent )
|
if( !pEvent )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if( resetCallback )
|
||||||
pEvent->setEventReturnCallback( nullptr );
|
pEvent->setEventReturnCallback( nullptr );
|
||||||
|
|
||||||
auto resumeEvent = makeZonePacket< FFXIVIpcResumeEventScene2 >( player.getId() );
|
auto resumeEvent = makeZonePacket< FFXIVIpcResumeEventScene2 >( player.getId() );
|
||||||
resumeEvent->data().handlerId = eventId;
|
resumeEvent->data().handlerId = eventId;
|
||||||
resumeEvent->data().sceneId = static_cast< uint8_t >( scene );
|
resumeEvent->data().sceneId = static_cast< uint8_t >( scene );
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Sapphire::World::Manager
|
||||||
Event::EventHandler::SceneReturnCallback eventReturnCallback = nullptr );
|
Event::EventHandler::SceneReturnCallback eventReturnCallback = nullptr );
|
||||||
|
|
||||||
/*! resume a subevent */
|
/*! 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 */
|
/*! play a subevent */
|
||||||
void playScene( Entity::Player& player, uint32_t eventId, uint32_t scene, uint32_t flags,
|
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 )
|
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;
|
uint64_t linkshellId = 1;
|
||||||
|
|
||||||
if( !m_linkshellIdMap.empty() )
|
if( !m_linkshellIdMap.empty() )
|
||||||
|
@ -169,6 +165,10 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
||||||
if( lsIt != m_linkshellNameMap.end() )
|
if( lsIt != m_linkshellNameMap.end() )
|
||||||
return nullptr;
|
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();
|
uint64_t masterId = player.getCharacterId();
|
||||||
|
|
||||||
// TODO: remove this messy set
|
// TODO: remove this messy set
|
||||||
|
@ -187,7 +187,6 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
||||||
// TODO: handle player pkt
|
// TODO: handle player pkt
|
||||||
|
|
||||||
// prepare binary data for SQL
|
// prepare binary data for SQL
|
||||||
|
|
||||||
std::vector< uint64_t > members( 128, 0 );
|
std::vector< uint64_t > members( 128, 0 );
|
||||||
std::vector< uint64_t > leaders( 128, 0 );
|
std::vector< uint64_t > leaders( 128, 0 );
|
||||||
std::vector< uint64_t > invites( 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 ) );
|
std::vector< uint8_t > invVec( sizeof( invites ) );
|
||||||
memcpy( invVec.data(), invites.data(), sizeof( invites ) );
|
memcpy( invVec.data(), invites.data(), sizeof( invites ) );
|
||||||
|
|
||||||
// TODO: insert in SQL
|
|
||||||
|
|
||||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||||
|
|
||||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_LINKSHELL_INS );
|
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_LINKSHELL_INS );
|
||||||
stmt->setUInt64( 1, linkshellId );
|
stmt->setUInt64( 1, linkshellId );
|
||||||
stmt->setUInt64( 2, masterId );
|
stmt->setUInt64( 2, masterId );
|
||||||
|
@ -220,11 +216,12 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell(
|
||||||
|
|
||||||
return lsPtr;
|
return lsPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::LinkshellMgr::finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player )
|
void Sapphire::World::Manager::LinkshellMgr::finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player )
|
||||||
{
|
{
|
||||||
auto& server = Common::Service< World::WorldServer >::ref();
|
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 );
|
server.queueForPlayer( player.getCharacterId(), linkshellResult );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -233,20 +230,18 @@ const std::vector< Sapphire::LinkshellPtr > Sapphire::World::Manager::LinkshellM
|
||||||
{
|
{
|
||||||
std::vector< Sapphire::LinkshellPtr > lsVec;
|
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& memberList = value->getMemberIdList();
|
||||||
auto& inviteList = value->getInviteIdList();
|
auto& inviteList = value->getInviteIdList();
|
||||||
|
|
||||||
// find player id in LS member list
|
// find player id in LS member or invite list
|
||||||
if( memberList.count( player.getCharacterId() ) || inviteList.count( player.getCharacterId() ) )
|
if( memberList.count( player.getCharacterId() ) ||
|
||||||
|
inviteList.count( player.getCharacterId() ) )
|
||||||
{
|
{
|
||||||
lsVec.emplace_back( value );
|
lsVec.emplace_back( value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return lsVec;
|
return lsVec;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue