diff --git a/src/common/Common.h b/src/common/Common.h index fe8636fd..6bfdd5ab 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -1312,18 +1312,6 @@ namespace Sapphire::Common GetGil = 9, // p1: gil EmptyCoffer = 11, // seems like no param }; - - struct EventSaveData - { - uint32_t eventId; - uint16_t scene; - uint16_t unknown1; - uint32_t params[11]; - uint64_t unknown2; - uint8_t unknown3[4]; - uint64_t unknown4; - }; - } #endif diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index 541ad6d0..7bce247e 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -194,14 +194,7 @@ namespace Sapphire::Network::Packets EventPlay128 = 0x026E, // updated 5.58 EventPlay255 = 0x039E, // updated 5.58 - EventYield = 0x0123, // updated 5.58 - //EventYield4 = 0x0000, - //EventYield8 = 0x0000, - //EventYield16 = 0x0000, - //EventYield32 = 0x0000, - //EventYield64 = 0x0000, - //EventYield128 = 0x0000, - //EventYield255 = 0x0000, + EventContinue = 0x0123, // updated 5.58 EventStart = 0x01CC, // updated 5.58 EventFinish = 0x0180, // updated 5.58 @@ -401,7 +394,7 @@ namespace Sapphire::Network::Packets ReturnEventHandler = 0x0333, // updated 5.58 TradeReturnEventHandler = 0x0179, // updated 5.58 TradeReturnEventHandler2 = 0x02E1, // updated 5.58 - SaveDataEventHandler = 0x03D7, // updated 5.58 + EventYield16Handler = 0x03D7, // updated 5.58 LinkshellEventHandler = 0x016B, // updated 4.5 LinkshellEventHandler1 = 0x016C, // updated 4.5 diff --git a/src/common/Network/PacketDef/Zone/ClientZoneDef.h b/src/common/Network/PacketDef/Zone/ClientZoneDef.h index 772f6a1c..903abf90 100644 --- a/src/common/Network/PacketDef/Zone/ClientZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ClientZoneDef.h @@ -446,10 +446,22 @@ struct FFXIVIpcHousingEditInterior : uint16_t slot[10]; }; -struct FFXIVIpcSaveDataEventHandler : - FFXIVIpcBasePacket< SaveDataEventHandler > +struct FFXIVIpcEventYieldHandler : + FFXIVIpcBasePacket< EventYieldHandler > { - Common::EventSaveData data; + uint32_t eventId; + uint16_t scene; + uint16_t padding; + uint64_t unknown; +}; + +struct FFXIVIpcEventYield16Handler : + FFXIVIpcBasePacket< EventYield16Handler > +{ + uint32_t eventId; + uint16_t scene; + uint16_t padding; + uint32_t params[16]; }; struct FFXIVIpcCFCommenceHandler : diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 9d09a47b..c0899b1e 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -2253,7 +2253,7 @@ namespace Sapphire::Network::Packets::Server uint8_t padding[3]; }; - struct FFXIVIpcEventYield : FFXIVIpcBasePacket< EventYield > + struct FFXIVIpcEventContinue : FFXIVIpcBasePacket< EventContinue > { uint32_t eventId; uint16_t scene; diff --git a/src/scripts/quest/subquest/gridania/SubCts999.cpp b/src/scripts/quest/subquest/gridania/SubCts999.cpp index 44585736..84826b5f 100644 --- a/src/scripts/quest/subquest/gridania/SubCts999.cpp +++ b/src/scripts/quest/subquest/gridania/SubCts999.cpp @@ -508,22 +508,22 @@ public: onProgress( player, param1, param2, 4, 0 ); } - void onSaveData( Sapphire::Entity::Player& player, const Common::EventSaveData& data ) override + void onEventYield( Sapphire::Entity::Player& player, uint16_t scene, std::vector< uint32_t > param ) override { - if( data.scene == 69 ) + if( scene == 69 ) { - player.setQuestUI8AH( getId(), data.params[0] ); - player.setQuestUI8AL( getId(), data.params[1] ); - player.setQuestUI8BH( getId(), data.params[2] ); - player.setQuestUI8BL( getId(), data.params[3] ); - player.setQuestUI8CH( getId(), data.params[4] ); - player.setQuestUI8CL( getId(), data.params[5] ); - player.setQuestUI8DH( getId(), data.params[6] ); - player.setQuestUI8DL( getId(), data.params[7] ); + player.setQuestUI8AH( getId(), param[0] ); + player.setQuestUI8AL( getId(), param[1] ); + player.setQuestUI8BH( getId(), param[2] ); + player.setQuestUI8BL( getId(), param[3] ); + player.setQuestUI8CH( getId(), param[4] ); + player.setQuestUI8CL( getId(), param[5] ); + player.setQuestUI8DH( getId(), param[6] ); + player.setQuestUI8DL( getId(), param[7] ); // retail does not save these two values here, we borrow them since they are unused. - player.setQuestUI8FH( getId(), data.params[8] ); - player.setQuestUI8FL( getId(), data.params[9] ); + player.setQuestUI8FH( getId(), param[8] ); + player.setQuestUI8FL( getId(), param[9] ); player.sendDebug( "Ceremony settings saved." ); } } diff --git a/src/world/Network/GameConnection.cpp b/src/world/Network/GameConnection.cpp index 9f45b926..fc0c6028 100644 --- a/src/world/Network/GameConnection.cpp +++ b/src/world/Network/GameConnection.cpp @@ -106,7 +106,8 @@ Sapphire::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pH setZoneHandler( ClientZoneIpcType::TradeReturnEventHandler, "TradeReturnEventHandler", &GameConnection::eventHandlerReturn ); setZoneHandler( ClientZoneIpcType::TradeReturnEventHandler2, "TradeReturnEventHandler2", &GameConnection::eventHandlerReturn ); - setZoneHandler( ClientZoneIpcType::SaveDataEventHandler, "SaveDataEventHandler", &GameConnection::saveDataEventHandler ); + setZoneHandler( ClientZoneIpcType::EventYieldHandler, "EventYieldHandler", &GameConnection::eventYieldHandler ); + setZoneHandler( ClientZoneIpcType::EventYield16Handler, "EventYield16Handler", &GameConnection::eventYieldHandler ); setZoneHandler( ClientZoneIpcType::ShopEventHandler, "ShopEventHandler", &GameConnection::eventHandlerShop ); diff --git a/src/world/Network/GameConnection.h b/src/world/Network/GameConnection.h index 76013146..a01f0749 100644 --- a/src/world/Network/GameConnection.h +++ b/src/world/Network/GameConnection.h @@ -209,7 +209,7 @@ namespace Sapphire::Network DECLARE_HANDLER( disbandPartyHandler ); - DECLARE_HANDLER( saveDataEventHandler ); + DECLARE_HANDLER( eventYieldHandler ); }; } diff --git a/src/world/Network/Handlers/EventHandlers.cpp b/src/world/Network/Handlers/EventHandlers.cpp index 19c9b3d0..744e6575 100644 --- a/src/world/Network/Handlers/EventHandlers.cpp +++ b/src/world/Network/Handlers/EventHandlers.cpp @@ -303,24 +303,39 @@ void Sapphire::Network::GameConnection::eventHandlerShop( const Packets::FFXIVAR scriptMgr.onTalk( player, player.getId(), eventId ); } -void Sapphire::Network::GameConnection::saveDataEventHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) +void Sapphire::Network::GameConnection::eventYieldHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) { auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref(); - const auto packet = ZoneChannelPacket< Client::FFXIVIpcSaveDataEventHandler >( inPacket ); + auto opcode = *reinterpret_cast< const uint16_t* >( &inPacket.data[ 2 ] ); + auto eventId = *reinterpret_cast< const uint32_t* >( &inPacket.data[ 0x10 + 0 ] ); + auto scene = *reinterpret_cast< const uint16_t* >( &inPacket.data[ 0x10 + 4 ] ); + auto pParam = reinterpret_cast< const uint32_t* >( &inPacket.data[ 0x10 + 8 ] ); + + std::vector< uint32_t > param; - const auto eventId = packet.data().data.eventId; + switch( opcode ) + { + case EventYield16Handler: + { + for( int i = 0; i < 16; i++ ) + { + param.push_back( pParam[ i ] ); + } + break; + } + } - std::string eventName = "onSaveData"; + std::string eventName = "onEventYield"; std::string objName = eventMgr.getEventName( eventId ); - player.sendDebug( "Calling: {0}.{1} - {2} scene: {3}", objName, eventName, eventId, packet.data().data.scene ); + player.sendDebug( "Calling: {0}.{1} - {2} scene: {3}", objName, eventName, eventId, scene ); - scriptMgr.onSaveData( player, packet.data().data ); + scriptMgr.onEventYield( player, eventId, scene, param ); - auto response = makeZonePacket< FFXIVIpcEventYield >( player.getId() ); + auto response = makeZonePacket< FFXIVIpcEventContinue >( player.getId() ); response->data().eventId = eventId; - response->data().scene = packet.data().data.scene; + response->data().scene = scene; player.queuePacket( response ); } diff --git a/src/world/Script/NativeScriptApi.cpp b/src/world/Script/NativeScriptApi.cpp index 4c04f36e..70e32151 100644 --- a/src/world/Script/NativeScriptApi.cpp +++ b/src/world/Script/NativeScriptApi.cpp @@ -150,7 +150,7 @@ namespace Sapphire::ScriptAPI { } - void EventScript::onSaveData( Sapphire::Entity::Player& player, const Common::EventSaveData& data ) + void EventScript::onEventYield( Sapphire::Entity::Player& player, uint16_t scene, std::vector< uint32_t > param ) { } diff --git a/src/world/Script/NativeScriptApi.h b/src/world/Script/NativeScriptApi.h index e01bd15c..072da949 100644 --- a/src/world/Script/NativeScriptApi.h +++ b/src/world/Script/NativeScriptApi.h @@ -175,7 +175,7 @@ namespace Sapphire::ScriptAPI virtual void onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ); - virtual void onSaveData( Sapphire::Entity::Player& player, const Common::EventSaveData& data ); + virtual void onEventYield( Sapphire::Entity::Player& player, uint16_t scene, std::vector< uint32_t > param ); }; /*! diff --git a/src/world/Script/ScriptMgr.cpp b/src/world/Script/ScriptMgr.cpp index d7e9cb2e..6e1e3595 100644 --- a/src/world/Script/ScriptMgr.cpp +++ b/src/world/Script/ScriptMgr.cpp @@ -588,12 +588,12 @@ bool Sapphire::Scripting::ScriptMgr::onDutyComplete( Sapphire::QuestBattlePtr in return false; } -bool Sapphire::Scripting::ScriptMgr::onSaveData( Sapphire::Entity::Player& player, const Sapphire::Common::EventSaveData& data ) +bool Sapphire::Scripting::ScriptMgr::onEventYield( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t scene, std::vector< uint32_t > param ) { - auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( data.eventId ); + auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId ); if( script ) { - script->onSaveData( player, data ); + script->onEventYield( player, scene, param ); return true; } diff --git a/src/world/Script/ScriptMgr.h b/src/world/Script/ScriptMgr.h index 08066519..776d1357 100644 --- a/src/world/Script/ScriptMgr.h +++ b/src/world/Script/ScriptMgr.h @@ -120,7 +120,7 @@ namespace Sapphire::Scripting bool onDutyComplete( QuestBattlePtr instance, Entity::Player& player ); - bool onSaveData( Entity::Player& player, const Common::EventSaveData& data ); + bool onEventYield( Entity::Player& player, uint32_t eventId, uint16_t scene, std::vector< uint32_t > param ); bool onPublicContentInit( PublicContentPtr instance );