mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Renaming of linkshells implemented
This commit is contained in:
parent
72db0a026c
commit
8eeba39edb
14 changed files with 111 additions and 7 deletions
|
@ -329,6 +329,10 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
|
||||||
"UPDATE infolinkshell SET CharacterIdList = ?, LinkshellName = ?, LeaderIdList = ?, InviteIdList = ?, MasterCharacterId = ? WHERE LinkshellId = ?;",
|
"UPDATE infolinkshell SET CharacterIdList = ?, LinkshellName = ?, LeaderIdList = ?, InviteIdList = ?, MasterCharacterId = ? WHERE LinkshellId = ?;",
|
||||||
CONNECTION_BOTH );
|
CONNECTION_BOTH );
|
||||||
|
|
||||||
|
prepareStatement( LINKSHELL_DEL,
|
||||||
|
"DELETE FROM infolinkshell WHERE LinkshellId = ?;",
|
||||||
|
CONNECTION_BOTH );
|
||||||
|
|
||||||
/*prepareStatement( LAND_INS,
|
/*prepareStatement( LAND_INS,
|
||||||
"INSERT INTO land ( LandSetId ) VALUES ( ? );",
|
"INSERT INTO land ( LandSetId ) VALUES ( ? );",
|
||||||
CONNECTION_BOTH );
|
CONNECTION_BOTH );
|
||||||
|
|
|
@ -108,6 +108,7 @@ namespace Sapphire::Db
|
||||||
LINKSHELL_SEL_ALL,
|
LINKSHELL_SEL_ALL,
|
||||||
LINKSHELL_INS,
|
LINKSHELL_INS,
|
||||||
LINKSHELL_UP,
|
LINKSHELL_UP,
|
||||||
|
LINKSHELL_DEL,
|
||||||
|
|
||||||
|
|
||||||
MAX_STATEMENTS
|
MAX_STATEMENTS
|
||||||
|
|
|
@ -48,12 +48,12 @@ public:
|
||||||
if( !ls )
|
if( !ls )
|
||||||
{
|
{
|
||||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0x15a }, false );
|
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0x15a }, false );
|
||||||
linkshellMgr().finishLinkshellCreation( result.resultString, 0x15a, player );
|
linkshellMgr().finishLinkshellAction( result.resultString, 0x15a, player, 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 }, true );
|
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 }, true );
|
||||||
linkshellMgr().finishLinkshellCreation( result.resultString, 0, player );
|
linkshellMgr().finishLinkshellAction( result.resultString, 0, player, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -64,7 +64,22 @@ public:
|
||||||
// rename linkshell
|
// rename linkshell
|
||||||
void Scene00003( Entity::Player& player )
|
void Scene00003( Entity::Player& player )
|
||||||
{
|
{
|
||||||
eventMgr().playScene( player, getId(), 3, HIDE_HOTBAR );
|
auto callback = [ this ]( Entity::Player& player, const Event::SceneResult& result )
|
||||||
|
{
|
||||||
|
auto ls = linkshellMgr().renameLinkshell( result.intResult, result.resultString, player );
|
||||||
|
if( !ls )
|
||||||
|
{
|
||||||
|
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0x15a }, false );
|
||||||
|
linkshellMgr().finishLinkshellAction( result.resultString, 0x15a, player, 3 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventMgr().resumeScene( player, result.eventId, result.sceneId, { 0 }, true );
|
||||||
|
linkshellMgr().finishLinkshellAction( result.resultString, 0, player, 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
eventMgr().playScene( player, getId(), 3, HIDE_HOTBAR, callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove linkshell
|
// remove linkshell
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Sapphire::Event
|
||||||
uint8_t numOfResults;
|
uint8_t numOfResults;
|
||||||
std::vector< uint32_t > results;
|
std::vector< uint32_t > results;
|
||||||
std::string resultString;
|
std::string resultString;
|
||||||
|
uint64_t intResult;
|
||||||
|
|
||||||
uint32_t getResult( uint32_t index ) const;
|
uint32_t getResult( uint32_t index ) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -103,5 +103,10 @@ void Sapphire::Linkshell::setMasterId( uint64_t masterId )
|
||||||
m_masterCharacterId = masterId;
|
m_masterCharacterId = masterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::Linkshell::setName( std::string name )
|
||||||
|
{
|
||||||
|
m_name = std::move( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace Sapphire
|
||||||
uint64_t getId() const;
|
uint64_t getId() const;
|
||||||
|
|
||||||
const std::string& getName() const;
|
const std::string& getName() const;
|
||||||
|
void setName( std::string name );
|
||||||
|
|
||||||
uint64_t getMasterId() const;
|
uint64_t getMasterId() const;
|
||||||
|
|
||||||
|
|
|
@ -348,6 +348,42 @@ void EventMgr::handleReturnStringEventScene( Entity::Player& player, uint32_t ev
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventMgr::handleReturnIntAndStringEventScene( Entity::Player& player, uint32_t eventId, uint16_t sceneId, const std::string& resultString, uint64_t resultInt )
|
||||||
|
{
|
||||||
|
std::string eventName = getEventName( eventId );
|
||||||
|
|
||||||
|
PlayerMgr::sendDebug( player, "eventId: {0} ({0:08X}) scene: {1}, string: {2}, resultInt: {3}", eventId, sceneId, resultString, resultInt );
|
||||||
|
|
||||||
|
auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
||||||
|
auto pEvent = player.getEvent( eventId );
|
||||||
|
|
||||||
|
if( pEvent )
|
||||||
|
{
|
||||||
|
pEvent->setPlayedScene( false );
|
||||||
|
// try to retrieve a stored callback
|
||||||
|
// if there is one, proceed to call it
|
||||||
|
Event::SceneResult result;
|
||||||
|
result.actorId = pEvent->getActorId();
|
||||||
|
result.eventId = eventId;
|
||||||
|
result.sceneId = sceneId;
|
||||||
|
result.resultString = resultString;
|
||||||
|
result.intResult = resultInt;
|
||||||
|
|
||||||
|
auto eventCallback = pEvent->getEventReturnCallback();
|
||||||
|
if( eventCallback )
|
||||||
|
{
|
||||||
|
eventCallback( player, result );
|
||||||
|
}
|
||||||
|
|
||||||
|
// we might have a scene chain callback instead so check for that too
|
||||||
|
else if( auto chainCallback = pEvent->getSceneChainCallback() )
|
||||||
|
chainCallback( player );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventMgr::checkEvent( Sapphire::Entity::Player &player, uint32_t eventId )
|
void EventMgr::checkEvent( Sapphire::Entity::Player &player, uint32_t eventId )
|
||||||
{
|
{
|
||||||
auto pEvent = player.getEvent( eventId );
|
auto pEvent = player.getEvent( eventId );
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Sapphire::World::Manager
|
||||||
uint8_t numOfResults, const std::vector< uint32_t >& results );
|
uint8_t numOfResults, const std::vector< uint32_t >& results );
|
||||||
|
|
||||||
void handleReturnStringEventScene( Entity::Player& player, uint32_t eventId, uint16_t sceneId, const std::string& resultString );
|
void handleReturnStringEventScene( Entity::Player& player, uint32_t eventId, uint16_t sceneId, const std::string& resultString );
|
||||||
|
void handleReturnIntAndStringEventScene( Entity::Player& player, uint32_t eventId, uint16_t sceneId, const std::string& resultString, uint64_t resultInt );
|
||||||
|
|
||||||
|
|
||||||
void checkEvent( Entity::Player& player, uint32_t eventId );
|
void checkEvent( Entity::Player& player, uint32_t eventId );
|
||||||
|
|
|
@ -218,11 +218,11 @@ 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::finishLinkshellAction( const std::string& name, uint32_t result, Entity::Player& player, uint8_t action )
|
||||||
{
|
{
|
||||||
auto& server = Common::Service< World::WorldServer >::ref();
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
|
|
||||||
auto linkshellResult = makeLinkshellResult( player, 0, 0, 1, result, 0, name, "" );
|
auto linkshellResult = makeLinkshellResult( player, 0, 0, action, result, 0, name, "" );
|
||||||
server.queueForPlayer( player.getCharacterId(), linkshellResult );
|
server.queueForPlayer( player.getCharacterId(), linkshellResult );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -482,3 +482,25 @@ void LinkshellMgr::changeMaster( Sapphire::Entity::Player &sourcePlayer, Sapphir
|
||||||
|
|
||||||
server.queueForPlayer( sourcePlayer.getCharacterId(), linkshellResult1 );
|
server.queueForPlayer( sourcePlayer.getCharacterId(), linkshellResult1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LinkshellMgr::renameLinkshell( uint64_t linkshellId, const std::string &name, Sapphire::Entity::Player &player )
|
||||||
|
{
|
||||||
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
|
|
||||||
|
auto lsPtr = getLinkshellById( linkshellId );
|
||||||
|
|
||||||
|
if( !lsPtr )
|
||||||
|
{
|
||||||
|
Logger::warn( "Failed to rename linkshell - linkshell not found!" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// can't rename to an already existing name
|
||||||
|
if( getLinkshellByName( name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
lsPtr->setName( name );
|
||||||
|
writeLinkshell( lsPtr->getId() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -36,7 +36,9 @@ namespace Sapphire::World::Manager
|
||||||
// create new linkshell entry and insert into db
|
// create new linkshell entry and insert into db
|
||||||
LinkshellPtr createLinkshell( const std::string& name, Entity::Player& player );
|
LinkshellPtr createLinkshell( const std::string& name, Entity::Player& player );
|
||||||
|
|
||||||
void finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player );
|
bool renameLinkshell( uint64_t linkshellId, const std::string& name, Entity::Player& player );
|
||||||
|
|
||||||
|
void finishLinkshellAction( const std::string& name, uint32_t result, Entity::Player& player, uint8_t action );
|
||||||
|
|
||||||
void invitePlayer( Entity::Player& sourcePlayer, Entity::Player& invitedPlayer, uint64_t linkshellId );
|
void invitePlayer( Entity::Player& sourcePlayer, Entity::Player& invitedPlayer, uint64_t linkshellId );
|
||||||
void kickPlayer( Entity::Player& sourcePlayer, Entity::Player& kickedPlayer, uint64_t linkshellId );
|
void kickPlayer( Entity::Player& sourcePlayer, Entity::Player& kickedPlayer, uint64_t linkshellId );
|
||||||
|
|
|
@ -118,6 +118,8 @@ Sapphire::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pH
|
||||||
setZoneHandler( YieldEventSceneString16, "YieldEventSceneString16", &GameConnection::yieldEventString );
|
setZoneHandler( YieldEventSceneString16, "YieldEventSceneString16", &GameConnection::yieldEventString );
|
||||||
setZoneHandler( YieldEventSceneString32, "YieldEventSceneString32", &GameConnection::yieldEventString );
|
setZoneHandler( YieldEventSceneString32, "YieldEventSceneString32", &GameConnection::yieldEventString );
|
||||||
|
|
||||||
|
setZoneHandler( YieldEventSceneIntAndString, "YieldEventSceneIntAndString", &GameConnection::yieldEventSceneIntAndString );
|
||||||
|
|
||||||
setZoneHandler( RequestPenalties, "RequestPenalties", &GameConnection::cfRequestPenalties );
|
setZoneHandler( RequestPenalties, "RequestPenalties", &GameConnection::cfRequestPenalties );
|
||||||
setZoneHandler( FindContent, "FindContent", &GameConnection::findContent );
|
setZoneHandler( FindContent, "FindContent", &GameConnection::findContent );
|
||||||
setZoneHandler( Find5Contents, "Find5Contents", &GameConnection::find5Contents );
|
setZoneHandler( Find5Contents, "Find5Contents", &GameConnection::find5Contents );
|
||||||
|
|
|
@ -166,6 +166,7 @@ namespace Sapphire::Network
|
||||||
DECLARE_HANDLER( startUiEvent );
|
DECLARE_HANDLER( startUiEvent );
|
||||||
|
|
||||||
DECLARE_HANDLER( yieldEventString );
|
DECLARE_HANDLER( yieldEventString );
|
||||||
|
DECLARE_HANDLER( yieldEventSceneIntAndString );
|
||||||
|
|
||||||
DECLARE_HANDLER( logoutHandler );
|
DECLARE_HANDLER( logoutHandler );
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,19 @@ void Sapphire::Network::GameConnection::yieldEventString( const Packets::FFXIVAR
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::Network::GameConnection::yieldEventSceneIntAndString( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||||
|
{
|
||||||
|
auto &server = Common::Service< World::WorldServer >::ref();
|
||||||
|
auto &eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
||||||
|
|
||||||
|
std::string inString;
|
||||||
|
const auto packet = ZoneChannelPacket< FFXIVIpcYieldEventSceneIntAndString >( inPacket );
|
||||||
|
auto& data = packet.data();
|
||||||
|
inString = std::string( data.str );
|
||||||
|
|
||||||
|
eventMgr.handleReturnIntAndStringEventScene( player, data.handlerId, data.sceneId, inString, data.integer );
|
||||||
|
}
|
||||||
|
|
||||||
void Sapphire::Network::GameConnection::startUiEvent( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
void Sapphire::Network::GameConnection::startUiEvent( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||||
Entity::Player& player )
|
Entity::Player& player )
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,7 +119,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
||||||
}
|
}
|
||||||
case PacketCommand::COMPANION:
|
case PacketCommand::COMPANION:
|
||||||
{
|
{
|
||||||
player.setCompanion( static_cast< uint16_t >( param1 ));
|
player.setCompanion( static_cast< uint16_t >( param1 ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketCommand::REQUEST_STATUS_RESET: // Remove status (clicking it off)
|
case PacketCommand::REQUEST_STATUS_RESET: // Remove status (clicking it off)
|
||||||
|
|
Loading…
Add table
Reference in a new issue