diff --git a/src/lobby/GameConnection.cpp b/src/lobby/GameConnection.cpp index 39bd2fb9..8d6d479a 100644 --- a/src/lobby/GameConnection.cpp +++ b/src/lobby/GameConnection.cpp @@ -402,25 +402,25 @@ void Sapphire::Network::GameConnection::handleGamePacket( Packets::FFXIVARR_PACK // todo: validate client version based on sha1 or gamever/bootver sendServiceAccountList( packet, tmpId ); } - break; + break; case ReqCharList: { getCharList( packet, tmpId ); } - break; + break; case ReqEnterWorld: { enterWorld( packet, tmpId ); } - break; + break; case ReqCharCreate: { createOrModifyChar( packet, tmpId ); } - break; + break; } diff --git a/src/lobby/ServerLobby.cpp b/src/lobby/ServerLobby.cpp index b8fa0a9e..9d243624 100644 --- a/src/lobby/ServerLobby.cpp +++ b/src/lobby/ServerLobby.cpp @@ -34,8 +34,6 @@ namespace Sapphire m_pConfig = std::make_shared< ConfigMgr >(); } - ServerLobby::~ServerLobby( void ) = default; - LobbySessionPtr ServerLobby::getSession( char* sessionId ) { return g_restConnector.getSession( sessionId ); diff --git a/src/lobby/ServerLobby.h b/src/lobby/ServerLobby.h index 8e101bfb..99e091ef 100644 --- a/src/lobby/ServerLobby.h +++ b/src/lobby/ServerLobby.h @@ -34,7 +34,7 @@ namespace Sapphire public: ServerLobby( const std::string& configPath ); - ~ServerLobby( void ); + ~ServerLobby( void ) = default; void run( int32_t argc, char* argv[] ); diff --git a/src/tools/quest_parser/main.cpp b/src/tools/quest_parser/main.cpp index 39bafa69..79aea813 100644 --- a/src/tools/quest_parser/main.cpp +++ b/src/tools/quest_parser/main.cpp @@ -25,22 +25,22 @@ namespace fs = std::experimental::filesystem; using namespace Sapphire; const std::string onTalkStr( - " void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n" - " {\n" - " auto actor = Event::mapEventActorToRealActor( actorId );\n" - " }\n\n" + " void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n" + " {\n" + " auto actor = Event::mapEventActorToRealActor( actorId );\n" + " }\n\n" ); const std::string onWithinRangeStr( - " void onWithinRange( uint32_t eventId, Entity::Player& player, uint64_t eRangeId, float x, float y, float z ) override\n" - " {\n" - " }\n\n" + " void onWithinRange( uint32_t eventId, Entity::Player& player, uint64_t eRangeId, float x, float y, float z ) override\n" + " {\n" + " }\n\n" ); const std::string onEmoteStr( - " void onEmote( uint32_t eventId, Entity::Player& player, uint64_t actorId, uint32_t emoteId ) override\n" - " {\n" - " }\n\n" + " void onEmote( uint32_t eventId, Entity::Player& player, uint64_t actorId, uint32_t emoteId ) override\n" + " {\n" + " }\n\n" ); std::string titleCase( const std::string& str ) @@ -67,8 +67,7 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st std::string header( "// This is an automatically generated C++ script template\n" "// Content needs to be added by hand to make it function\n" - "// In order for this script to be loaded, change its extension to .cpp\n" - "// and move it to the correct folder in /scripts/native/\n" + "// In order for this script to be loaded, move it to the correct folder in /scripts/\n" "\n" "#include \n\n" ); @@ -77,13 +76,13 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st std::string className( pQuestData->id.substr( 0, splitPos ) ); //className = "Quest" + className; std::string sceneStr( - " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n" ); + " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n" ); std::string seqStr; seqStr.reserve( 0xFFF ); - seqStr += ( " // Steps in this quest ( 0 is before accepting, \n // 1 is first, 255 means ready for turning it in\n" ); - std::string questVarStr( " // Quest vars / flags used\n" ); + seqStr += ( " // Steps in this quest ( 0 is before accepting, \n // 1 is first, 255 means ready for turning it in\n" ); + std::string questVarStr( " // Quest vars / flags used\n" ); - seqStr += " enum Sequence : uint8_t\n {\n"; + seqStr += " enum Sequence : uint8_t\n {\n"; for( auto& entry : additionalList ) { if( entry.find( "OnScene" ) != std::string::npos ) @@ -95,29 +94,29 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st sceneId = numOff != std::string::npos ? sceneId.substr( numOff ) : "0"; sceneStr += std::string( - " void " + + " void " + sceneName + "( Entity::Player& player )\n" - " {\n" - " player.eventPlay( this->getId(), " + + " {\n" + " player.playScene( getId(), " + sceneId + ", 0,\n" - " [&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )\n" - " {\n" - " });\n" - " }\n\n" + " [ & ]( Entity::Player& player, const Event::SceneResult& result )\n" + " {\n" + " });\n" + " }\n\n" ); } else if( entry.find( "Flag" ) != std::string::npos || entry.find( "QuestUI" ) != std::string::npos ) { - questVarStr += " // " + entry + "\n"; + questVarStr += " // " + entry + "\n"; } else if( entry.find( "SEQ" ) != std::string::npos ) { if( entry.find( "SEQ_FINISH" ) != std::string::npos ) { - seqStr += " SeqFinish = 255,\n"; + seqStr += " SeqFinish = 255,\n"; } else if( entry.find( "SEQ_OFFER" ) != std::string::npos ) { @@ -131,46 +130,46 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st }), seqName.end()); std::string seqId = entry.substr( 4 ); - seqStr += " " + seqName + " = " + seqId + ",\n"; + seqStr += " " + seqName + " = " + seqId + ",\n"; } } } - seqStr += " };\n"; + seqStr += " };\n"; std::string rewards; rewards.reserve( 0xFFF ); - rewards += " // Quest rewards \n"; - rewards += ( pQuestData->expFactor != 0 ) ? " static constexpr auto RewardExpFactor = " + + rewards += " // Quest rewards \n"; + rewards += ( pQuestData->expFactor != 0 ) ? " static constexpr auto RewardExpFactor = " + std::to_string( pQuestData->expFactor ) + ";\n" : ""; - rewards += ( pQuestData->gilReward != 0 ) ? " static constexpr auto RewardGil = " + + rewards += ( pQuestData->gilReward != 0 ) ? " static constexpr auto RewardGil = " + std::to_string( pQuestData->gilReward ) + ";\n" : ""; - rewards += ( pQuestData->emoteReward != 0 ) ? " static constexpr auto RewardEmote = " + + rewards += ( pQuestData->emoteReward != 0 ) ? " static constexpr auto RewardEmote = " + std::to_string( pQuestData->emoteReward ) + ";\n" : ""; - rewards += ( pQuestData->actionReward != 0 ) ? " static constexpr auto RewardAction = " + + rewards += ( pQuestData->actionReward != 0 ) ? " static constexpr auto RewardAction = " + std::to_string( pQuestData->actionReward ) + ";\n" : ""; - rewards += ( pQuestData->generalActionReward[ 0 ] != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + + rewards += ( pQuestData->generalActionReward[ 0 ] != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + std::to_string( pQuestData->generalActionReward[ 0 ] ) + ";\n" : ""; - rewards += ( pQuestData->generalActionReward[ 1 ] != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + + rewards += ( pQuestData->generalActionReward[ 1 ] != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + std::to_string( pQuestData->generalActionReward[ 1 ] ) + ";\n" : ""; - rewards += ( pQuestData->gCSeals != 0 ) ? " static constexpr auto RewardGCSeals = " + + rewards += ( pQuestData->gCSeals != 0 ) ? " static constexpr auto RewardGCSeals = " + std::to_string( pQuestData->gCSeals ) + ";\n" : ""; - rewards += ( pQuestData->otherReward != 0 ) ? " static constexpr auto RewardOther = " + + rewards += ( pQuestData->otherReward != 0 ) ? " static constexpr auto RewardOther = " + std::to_string( pQuestData->otherReward ) + ";\n" : ""; - rewards += ( pQuestData->reputationReward != 0 ) ? " static constexpr auto RewardReputation = " + + rewards += ( pQuestData->reputationReward != 0 ) ? " static constexpr auto RewardReputation = " + std::to_string( pQuestData->reputationReward ) + ";\n" : ""; - rewards += ( pQuestData->tomestoneReward != 0 ) ? " static constexpr auto RewardTomeType = " + + rewards += ( pQuestData->tomestoneReward != 0 ) ? " static constexpr auto RewardTomeType = " + std::to_string( pQuestData->tomestoneReward ) + ";\n" : ""; - rewards += ( pQuestData->tomestoneCountReward != 0 ) ? " static constexpr auto RewardTomeCount = " + + rewards += ( pQuestData->tomestoneCountReward != 0 ) ? " static constexpr auto RewardTomeCount = " + std::to_string( pQuestData->tomestoneCountReward ) + ";\n" : ""; - rewards += ( pQuestData->instanceContentUnlock != 0 ) ? " static constexpr auto InstancedContentUnlock = " + + rewards += ( pQuestData->instanceContentUnlock != 0 ) ? " static constexpr auto InstancedContentUnlock = " + std::to_string( pQuestData->instanceContentUnlock ) + ";\n" : ""; if( !pQuestData->itemReward0.empty() ) { - rewards += " static constexpr auto RewardItem[] = { "; + rewards += " static constexpr auto RewardItem = { "; for( size_t ca = 0; ca < pQuestData->itemReward0.size(); ca++ ) { rewards += std::to_string( pQuestData->itemReward0.at( ca ) ); @@ -184,7 +183,7 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st if( !pQuestData->itemReward0.empty() ) { - rewards += " static constexpr auto RewardItemCount[] = { "; + rewards += " static constexpr auto RewardItemCount = { "; for( size_t ca = 0; ca < pQuestData->itemCountReward0.size(); ca++ ) { rewards += std::to_string( pQuestData->itemCountReward0.at( ca ) ); @@ -198,7 +197,7 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st if( !pQuestData->itemReward1.empty() ) { - rewards += " static constexpr auto RewardItemOptional[] = { "; + rewards += " static constexpr auto RewardItemOptional = { "; for( size_t ca = 0; ca < pQuestData->itemReward1.size(); ca++ ) { rewards += std::to_string( pQuestData->itemReward1.at( ca ) ); @@ -212,7 +211,7 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st if( !pQuestData->itemCountReward1.empty() ) { - rewards += " static constexpr auto RewardItemOptionalCount[] = { "; + rewards += " static constexpr auto RewardItemOptionalCount = { "; for( size_t ca = 0; ca < pQuestData->itemCountReward1.size(); ca++ ) { rewards += std::to_string( pQuestData->itemCountReward1.at( ca ) ); @@ -227,9 +226,13 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st bool hasERange = false; bool hasEmote = false; bool hasEnemies = false; + bool hasActions = false; std::vector< uint32_t > enemy_ids; + std::vector< std::string > action_names; + std::vector< uint32_t > action_ids; std::vector< std::string > script_entities; - std::string sentities = " // Entities found in the script data of the quest\n"; + std::string sentities = " // Entities found in the script data of the quest\n"; + std::vector< std::string > enemy_strings; for( size_t ca = 0; ca < pQuestData->scriptInstruction.size(); ca++ ) { @@ -245,8 +248,21 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st { hasEnemies = true; enemy_ids.push_back( pQuestData->scriptArg.at( ca ) ); + enemy_strings.push_back( pQuestData->scriptInstruction.at( ca ) ); } + if( ( ( pQuestData->scriptInstruction.at( ca ).find( "ACTION0" ) != std::string::npos ) || + ( pQuestData->scriptInstruction.at( ca ).find( "ACTION1" ) != std::string::npos ) || + ( pQuestData->scriptInstruction.at( ca ).find( "ACTION2" ) != std::string::npos ) ) && + pQuestData->scriptInstruction.at( ca ).find( "_ACTION" ) == std::string::npos && + pQuestData->scriptInstruction.at( ca ).find( "EVENT" ) == std::string::npos ) + { + hasActions = true; + action_ids.push_back( pQuestData->scriptArg.at( ca ) ); + action_names.push_back( pQuestData->scriptInstruction.at( ca ) ); + } + + if( !pQuestData->scriptInstruction.at( ca ).empty() ) script_entities.push_back( pQuestData->scriptInstruction.at( ca ) + " = " + std::to_string( pQuestData->scriptArg.at( ca ) ) ); @@ -260,7 +276,7 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st return c == '_'; }), name.end()); - sentities += " static constexpr auto " + name + ";\n"; + sentities += " static constexpr auto " + name + ";\n"; } std::string additional = "// Quest Script: " + pQuestData->id + "\n"; @@ -269,9 +285,10 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st additional += "// Start NPC: " + std::to_string( pQuestData->eNpcResidentStart ) + "\n"; additional += "// End NPC: " + std::to_string( pQuestData->eNpcResidentEnd ) + "\n\n"; + std::string actionEntry; std::string scriptEntry; scriptEntry.reserve( 0xFFFF ); - scriptEntry += " //////////////////////////////////////////////////////////////////////\n // Event Handlers\n"; + scriptEntry += " //////////////////////////////////////////////////////////////////////\n // Event Handlers\n"; scriptEntry += onTalkStr; @@ -285,34 +302,59 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st scriptEntry += onEmoteStr; } - for( auto enemy : enemy_ids ) - { + + if( !enemy_ids.empty() ) scriptEntry += std::string( - " void onMobKill_" + std::to_string( enemy ) + "( Entity::Player& player )\n" - " {\n" - " }\n\n" - ); + " void onBNpcKill( uint32_t npcId, Entity::Player& player )\n" + " {\n" + " switch( npcId )\n" + " {\n" ); + + for( auto enemy : enemy_strings ) + { + scriptEntry += " case " + enemy + ": { break; }\n"; } + if( !enemy_ids.empty() ) + scriptEntry += std::string( " }\n" + " }\n" ); + + if( !action_ids.empty() ) + actionEntry += std::string( + " void onEObjHit( uint32_t npcId, Entity::Player& player, uin32_t actionId )\n" + " {\n" + " switch( actionId )\n" + " {\n" ); + + for( auto action : action_names ) + { + actionEntry += " case " + action + ": { break; }\n"; + } + + if( !action_ids.empty() ) + actionEntry += std::string( " }\n" + " }\n" ); std::string constructor; constructor += std::string( - " private:\n" - " // Basic quest information \n" ); + " private:\n" + " // Basic quest information \n" ); constructor += questVarStr + "\n"; constructor += seqStr + "\n"; constructor += rewards + "\n"; constructor += sentities + "\n"; - constructor += " public:\n"; - constructor += " " + className + "() : EventScript" + "( " + std::to_string( questId ) + " ){}; \n"; - constructor += " ~" + className + "(){}; \n"; + constructor += " public:\n"; + constructor += " " + className + "() : Sapphire::ScriptAPI::EventScript" + "( " + std::to_string( questId ) + " ){}; \n"; + constructor += " ~" + className + "() = default; \n"; std::string classString( - "class " + className + " : public EventScript\n" + "class " + className + " : public Sapphire::ScriptAPI::EventScript\n" "{\n" + constructor + "\n" + scriptEntry + - " private:\n" + + "\n" + + actionEntry + + " private:\n" + sceneStr + "};\n\nEXPOSE_SCRIPT( " + className + " );" ); @@ -332,7 +374,9 @@ int main( int argc, char** argv ) bool unluac = false; // std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" ); //std::string datLocation( "C:/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn/game/sqpack" ); - std::string datLocation( "C:/SquareEnix/FINAL FANTASY XIV - A Realm Reborn/game/sqpack" ); + //std::string datLocation( "C:/SquareEnix/FINAL FANTASY XIV - A Realm Reborn/game/sqpack" ); + + std::string datLocation( "/home/mordred/sqpack" ); if( argc > 1 ) datLocation = std::string( argv[ 1 ] ); if( argc > 2 ) diff --git a/src/world/Territory/CellHandler.h b/src/world/Territory/CellHandler.h index 7a0f6c86..03f5fc71 100644 --- a/src/world/Territory/CellHandler.h +++ b/src/world/Territory/CellHandler.h @@ -18,8 +18,6 @@ #define GetRelatCoord( Coord, CellCoord ) ((_maxX-Coord)-CellCoord*_cellSize) namespace Sapphire { -class Zone; - template< class T > class CellHandler { diff --git a/src/world/Territory/Zone.h b/src/world/Territory/Zone.h index d17ce563..6cc085bd 100644 --- a/src/world/Territory/Zone.h +++ b/src/world/Territory/Zone.h @@ -48,6 +48,7 @@ namespace Sapphire Common::Weather m_currentWeather; Common::Weather m_weatherOverride; + std::map< uint8_t, int32_t > m_weatherRateMap; int64_t m_lastMobUpdate; @@ -55,8 +56,6 @@ namespace Sapphire std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo; - std::map< uint8_t, int32_t > m_weatherRateMap; - uint32_t m_nextEObjId; uint32_t m_nextActorId; FrameworkPtr m_pFw;