From 8a5d497c21aee4fc36671fd9678eca4619b97afb Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 31 Jan 2018 11:43:22 +0100 Subject: [PATCH 1/6] zone, api: Removed old EXD reader --- src/common/Exd/ExdDataGenerated.cpp | 27 +++++- src/common/Exd/ExdDataGenerated.h | 22 ++++- src/servers/sapphire_api/PlayerMinimal.cpp | 28 +++--- src/servers/sapphire_api/main.cpp | 19 ++-- .../sapphire_zone/Action/ActionCast.cpp | 6 +- .../sapphire_zone/Action/ActionCollision.cpp | 10 +- .../sapphire_zone/Action/ActionCollision.h | 3 +- .../sapphire_zone/Action/ActionTeleport.cpp | 6 +- .../sapphire_zone/Action/EventAction.cpp | 6 +- src/servers/sapphire_zone/Actor/Actor.cpp | 9 +- src/servers/sapphire_zone/Actor/BattleNpc.cpp | 6 +- src/servers/sapphire_zone/Actor/Player.cpp | 93 +++++++++---------- .../sapphire_zone/Actor/PlayerQuest.cpp | 28 +++--- src/servers/sapphire_zone/Actor/PlayerSql.cpp | 6 +- .../DebugCommand/DebugCommandHandler.cpp | 6 +- .../sapphire_zone/Event/EventHelper.cpp | 8 +- .../sapphire_zone/Inventory/Inventory.cpp | 26 +++--- src/servers/sapphire_zone/Inventory/Item.cpp | 14 +-- src/servers/sapphire_zone/Math/CalcBattle.cpp | 13 ++- src/servers/sapphire_zone/Math/CalcStats.cpp | 30 +++--- .../Network/Handlers/ActionHandler.cpp | 12 +-- .../Network/Handlers/EventHandlers.cpp | 10 +- .../Network/Handlers/SkillHandler.cpp | 10 +- .../sapphire_zone/Script/ScriptManager.cpp | 6 +- src/servers/sapphire_zone/ServerZone.cpp | 18 ---- .../StatusEffect/StatusEffect.cpp | 8 +- src/servers/sapphire_zone/Zone/Zone.cpp | 27 +++++- src/tools/exd_struct_gen/ex.json | 25 +++++ 28 files changed, 269 insertions(+), 213 deletions(-) diff --git a/src/common/Exd/ExdDataGenerated.cpp b/src/common/Exd/ExdDataGenerated.cpp index 9f00fd42..84904506 100644 --- a/src/common/Exd/ExdDataGenerated.cpp +++ b/src/common/Exd/ExdDataGenerated.cpp @@ -735,7 +735,9 @@ name = exdData->getField< std::string >( row, 0 ); abbreviation = exdData->getField< std::string >( row, 1 ); classJobCategory = exdData->getField< uint8_t >( row, 3 ); + expArrayIndex = exdData->getField< int8_t >( row, 4 ); modifierHitPoints = exdData->getField< uint16_t >( row, 9 ); + modifierManaPoints = exdData->getField< uint16_t >( row, 10 ); modifierStrength = exdData->getField< uint16_t >( row, 11 ); modifierVitality = exdData->getField< uint16_t >( row, 12 ); modifierDexterity = exdData->getField< uint16_t >( row, 13 ); @@ -2376,11 +2378,12 @@ id = exdData->getField< std::string >( row, 5 ); sizeFactor = exdData->getField< uint16_t >( row, 6 ); offsetX = exdData->getField< int16_t >( row, 7 ); - offsetY = exdData->getField< int16_t >( row, 8 ); + discoveryIndex = exdData->getField< int16_t >( row, 8 ); placeNameRegion = exdData->getField< uint16_t >( row, 9 ); placeName = exdData->getField< uint16_t >( row, 10 ); placeNameSub = exdData->getField< uint16_t >( row, 11 ); territoryType = exdData->getField< uint16_t >( row, 14 ); + discoveryArrayByte = exdData->getField< bool >( row, 15 ); } Core::Data::MapMarker::MapMarker( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ) @@ -2571,6 +2574,12 @@ icon = exdData->getField< uint32_t >( row, 4 ); } + Core::Data::Opening::Opening( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ) + { + auto row = exdData->m_OpeningDat.get_row( row_id ); + name = exdData->getField< std::string >( row, 0 ); + } + Core::Data::Orchestrion::Orchestrion( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ) { auto row = exdData->m_OrchestrionDat.get_row( row_id ); @@ -4096,6 +4105,7 @@ bool Core::Data::ExdDataGenerated::init( const std::string& path ) m_NpcEquipDat = setupDatAccess( "NpcEquip", xiv::exd::Language::none ); m_OmenDat = setupDatAccess( "Omen", xiv::exd::Language::none ); m_OnlineStatusDat = setupDatAccess( "OnlineStatus", xiv::exd::Language::en ); + m_OpeningDat = setupDatAccess( "Opening", xiv::exd::Language::none ); m_OrchestrionDat = setupDatAccess( "Orchestrion", xiv::exd::Language::en ); m_OrchestrionPathDat = setupDatAccess( "OrchestrionPath", xiv::exd::Language::none ); m_ParamGrowDat = setupDatAccess( "ParamGrow", xiv::exd::Language::none ); @@ -7555,6 +7565,21 @@ boost::shared_ptr< Core::Data::OnlineStatus > } return nullptr; } +boost::shared_ptr< Core::Data::Opening > + Core::Data::ExdDataGenerated::getOpening( uint32_t OpeningId ) +{ + try + { + auto row = m_OpeningDat.get_row( OpeningId ); + auto info = boost::make_shared< Opening >( OpeningId, this ); + return info; + } + catch( ... ) + { + return nullptr; + } + return nullptr; +} boost::shared_ptr< Core::Data::Orchestrion > Core::Data::ExdDataGenerated::getOrchestrion( uint32_t OrchestrionId ) { diff --git a/src/common/Exd/ExdDataGenerated.h b/src/common/Exd/ExdDataGenerated.h index 49386231..2192626e 100644 --- a/src/common/Exd/ExdDataGenerated.h +++ b/src/common/Exd/ExdDataGenerated.h @@ -242,6 +242,7 @@ struct MountAction; struct NpcEquip; struct Omen; struct OnlineStatus; +struct Opening; struct Orchestrion; struct OrchestrionPath; struct ParamGrow; @@ -936,7 +937,9 @@ struct ClassJob std::string name; std::string abbreviation; uint8_t classJobCategory; + int8_t expArrayIndex; uint16_t modifierHitPoints; + uint16_t modifierManaPoints; uint16_t modifierStrength; uint16_t modifierVitality; uint16_t modifierDexterity; @@ -2421,11 +2424,12 @@ struct Map std::string id; uint16_t sizeFactor; int16_t offsetX; - int16_t offsetY; + int16_t discoveryIndex; uint16_t placeNameRegion; uint16_t placeName; uint16_t placeNameSub; uint16_t territoryType; + bool discoveryArrayByte; Map( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ); }; @@ -2604,6 +2608,13 @@ struct OnlineStatus OnlineStatus( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ); }; +struct Opening +{ + std::string name; + + Opening( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ); +}; + struct Orchestrion { std::string name; @@ -3607,6 +3618,7 @@ struct WorldDCGroupType xiv::exd::Exd m_NpcEquipDat; xiv::exd::Exd m_OmenDat; xiv::exd::Exd m_OnlineStatusDat; + xiv::exd::Exd m_OpeningDat; xiv::exd::Exd m_OrchestrionDat; xiv::exd::Exd m_OrchestrionPathDat; xiv::exd::Exd m_ParamGrowDat; @@ -3906,6 +3918,7 @@ struct WorldDCGroupType boost::shared_ptr< NpcEquip > getNpcEquip( uint32_t NpcEquipId ); boost::shared_ptr< Omen > getOmen( uint32_t OmenId ); boost::shared_ptr< OnlineStatus > getOnlineStatus( uint32_t OnlineStatusId ); + boost::shared_ptr< Opening > getOpening( uint32_t OpeningId ); boost::shared_ptr< Orchestrion > getOrchestrion( uint32_t OrchestrionId ); boost::shared_ptr< OrchestrionPath > getOrchestrionPath( uint32_t OrchestrionPathId ); boost::shared_ptr< ParamGrow > getParamGrow( uint32_t ParamGrowId ); @@ -4205,6 +4218,7 @@ struct WorldDCGroupType std::set< uint32_t > m_NpcEquipIdList; std::set< uint32_t > m_OmenIdList; std::set< uint32_t > m_OnlineStatusIdList; + std::set< uint32_t > m_OpeningIdList; std::set< uint32_t > m_OrchestrionIdList; std::set< uint32_t > m_OrchestrionPathIdList; std::set< uint32_t > m_ParamGrowIdList; @@ -5629,6 +5643,12 @@ const std::set< uint32_t >& getOnlineStatusIdList() loadIdList( m_OnlineStatusDat, m_OnlineStatusIdList ); return m_OnlineStatusIdList; } +const std::set< uint32_t >& getOpeningIdList() +{ + if( m_OpeningIdList.size() == 0 ) + loadIdList( m_OpeningDat, m_OpeningIdList ); + return m_OpeningIdList; +} const std::set< uint32_t >& getOrchestrionIdList() { if( m_OrchestrionIdList.size() == 0 ) diff --git a/src/servers/sapphire_api/PlayerMinimal.cpp b/src/servers/sapphire_api/PlayerMinimal.cpp index 3cf47acb..15deb2d4 100644 --- a/src/servers/sapphire_api/PlayerMinimal.cpp +++ b/src/servers/sapphire_api/PlayerMinimal.cpp @@ -2,11 +2,11 @@ #include #include -#include +#include #include -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; namespace Core { @@ -220,7 +220,7 @@ namespace Core { // CharacterId, ClassIdx, Exp, Lvl auto stmtClass = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_CLASS_INS ); stmtClass->setInt( 1, m_id ); - stmtClass->setInt( 2, g_exdData.m_classJobInfoMap[m_class].exp_idx ); + stmtClass->setInt( 2, g_exdDataGen.getClassJob( m_class )->expArrayIndex ); stmtClass->setInt( 3, 0 ); stmtClass->setInt( 4, 1 ); g_charaDb.directExecute( stmtClass ); @@ -292,14 +292,14 @@ namespace Core { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// SETUP EQUIPMENT / STARTING GEAR - auto classJobInfo = g_exdData.m_classJobInfoMap[m_class]; - uint32_t weaponId = classJobInfo.start_weapon_id; + auto classJobInfo = g_exdDataGen.getClassJob( m_class ); + uint32_t weaponId = classJobInfo->itemStartingWeapon; uint64_t uniqueId = getNextUId64(); uint8_t race = customize[CharaLook::Race]; uint8_t gender = customize[CharaLook::Gender]; - auto raceInfo = g_exdData.getRaceInfo( race ); + auto raceInfo = g_exdDataGen.getRace( race ); uint32_t body; uint32_t hands; @@ -312,17 +312,17 @@ namespace Core { if( gender == 0 ) { - body = raceInfo->male_body; - hands = raceInfo->male_hands; - legs = raceInfo->male_legs; - feet = raceInfo->male_feet; + body = raceInfo->rSEMBody; + hands = raceInfo->rSEMHands; + legs = raceInfo->rSEMLegs; + feet = raceInfo->rSEMFeet; } else { - body = raceInfo->female_body; - hands = raceInfo->female_hands; - legs = raceInfo->female_legs; - feet = raceInfo->female_feet; + body = raceInfo->rSEFBody; + hands = raceInfo->rSEFHands; + legs = raceInfo->rSEFLegs; + feet = raceInfo->rSEFFeet; } insertDbGlobalItem( weaponId, uniqueId ); diff --git a/src/servers/sapphire_api/main.cpp b/src/servers/sapphire_api/main.cpp index 9093ee8d..1a6fe25f 100644 --- a/src/servers/sapphire_api/main.cpp +++ b/src/servers/sapphire_api/main.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -35,7 +35,7 @@ Core::Logger g_log; Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb; -Core::Data::ExdData g_exdData; +Core::Data::ExdDataGenerated g_exdDataGen; Core::Network::SapphireAPI g_sapphireAPI; using namespace std; @@ -139,10 +139,10 @@ bool loadSettings( int32_t argc, char* argv[] ) } } - g_log.info( "Setting up EXD data" ); - if( !g_exdData.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) + g_log.info( "Setting up generated EXD data" ); + if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) { - g_log.fatal( "Error setting up EXD data " ); + g_log.fatal( "Error setting up generated EXD data " ); return false; } @@ -241,10 +241,10 @@ std::string buildHttpResponse( uint16_t rCode, const std::string& content = "", void getZoneName( shared_ptr response, shared_ptr request ) { string number = request->path_match[1]; - auto it = g_exdData.m_zoneInfoMap.find( atoi( number.c_str() ) ); + auto info = g_exdDataGen.getTerritoryType( atoi( number.c_str() ) ); std::string responseStr = "Not found!"; - if( it != g_exdData.m_zoneInfoMap.end() ) - responseStr = it->second.zone_name + ", " + it->second.zone_str; + if( info ) + responseStr = info->name + ", " + info->bg; *response << buildHttpResponse( 200, responseStr ); } @@ -751,9 +751,6 @@ int main( int argc, char* argv[] ) if( !loadSettings( argc, argv ) ) throw std::exception(); - g_exdData.loadZoneInfo(); - g_exdData.loadClassJobInfo(); - server.config.port = stoi( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) ); g_log.info( "Starting API server at port " + m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) + "..." ); diff --git a/src/servers/sapphire_zone/Action/ActionCast.cpp b/src/servers/sapphire_zone/Action/ActionCast.cpp index b9289b30..2e4f8f29 100644 --- a/src/servers/sapphire_zone/Action/ActionCast.cpp +++ b/src/servers/sapphire_zone/Action/ActionCast.cpp @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket143.h" @@ -17,7 +17,7 @@ using namespace Core::Network; using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Logger g_log; extern Core::Scripting::ScriptManager g_scriptMgr; @@ -31,7 +31,7 @@ Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr m_startTime = 0; m_id = actionId; m_handleActionType = HandleActionType::Spell; - m_castTime = g_exdData.getActionInfo( actionId )->cast_time; // TODO: Add security checks. + m_castTime = g_exdDataGen.getAction( actionId )->cast100ms; // TODO: Add security checks. m_pSource = pActor; m_pTarget = pTarget; m_bInterrupt = false; diff --git a/src/servers/sapphire_zone/Action/ActionCollision.cpp b/src/servers/sapphire_zone/Action/ActionCollision.cpp index 8a42d3c1..f2d0b68f 100644 --- a/src/servers/sapphire_zone/Action/ActionCollision.cpp +++ b/src/servers/sapphire_zone/Action/ActionCollision.cpp @@ -53,12 +53,12 @@ bool ActionCollision::isActorApplicable( ActorPtr actorPtr, TargetFilter targetF std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange, - boost::shared_ptr< Core::Data::ActionInfo > actionInfo, + boost::shared_ptr< Core::Data::Action > actionInfo, TargetFilter targetFilter ) { std::set< ActorPtr > actorsCollided; - switch( static_cast< ActionCollisionType >( actionInfo->aoe_type ) ) + switch( static_cast< ActionCollisionType >( actionInfo->castType ) ) { case ActionCollisionType::None: case ActionCollisionType::SingleTarget: @@ -75,7 +75,7 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI continue; // Test our collision from actor with the area generated by the action from the AoE data - if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width ) ) + if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->effectRange ) ) { // Add it to the actors collided with the area actorsCollided.insert( pActor ); @@ -92,7 +92,7 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI if ( !isActorApplicable( pActor, targetFilter ) ) continue; - if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) ) + if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->effectRange ) ) actorsCollided.insert( pActor ); } break; @@ -106,7 +106,7 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI if ( !isActorApplicable( pActor, targetFilter ) ) continue; - if ( boxCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width, actionInfo->aoe_range ) ) + if ( boxCollision( pActor->getPos(), aoePosition, actionInfo->xAxisModifier, actionInfo->effectRange ) ) { // todo: does this actually work? diff --git a/src/servers/sapphire_zone/Action/ActionCollision.h b/src/servers/sapphire_zone/Action/ActionCollision.h index f70f6f7a..ba2deb1e 100644 --- a/src/servers/sapphire_zone/Action/ActionCollision.h +++ b/src/servers/sapphire_zone/Action/ActionCollision.h @@ -2,6 +2,7 @@ #define _ACTIONCOLLISION_H #include +#include #include "Actor/Actor.h" #include "Action.h" @@ -25,7 +26,7 @@ namespace Entity { static bool isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter ); static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange, - boost::shared_ptr< Data::ActionInfo > actionInfo, + boost::shared_ptr< Data::Action > actionInfo, TargetFilter targetFilter ); private: diff --git a/src/servers/sapphire_zone/Action/ActionTeleport.cpp b/src/servers/sapphire_zone/Action/ActionTeleport.cpp index bb53e522..313ec6ee 100644 --- a/src/servers/sapphire_zone/Action/ActionTeleport.cpp +++ b/src/servers/sapphire_zone/Action/ActionTeleport.cpp @@ -1,7 +1,7 @@ #include "ActionTeleport.h" #include -#include +#include #include #include "Network/PacketWrappers/ActorControlPacket142.h" @@ -13,7 +13,7 @@ using namespace Core::Network; using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Logger g_log; Core::Action::ActionTeleport::ActionTeleport() @@ -26,7 +26,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t m_startTime = 0; m_id = 5; m_handleActionType = HandleActionType::Teleport; - m_castTime = g_exdData.getActionInfo(5)->cast_time; // TODO: Add security checks. + m_castTime = g_exdDataGen.getAction( 5 )->cast100ms; // TODO: Add security checks. m_pSource = pActor; m_bInterrupt = false; m_targetAetheryte = targetZone; diff --git a/src/servers/sapphire_zone/Action/EventAction.cpp b/src/servers/sapphire_zone/Action/EventAction.cpp index 869fa089..3370a635 100644 --- a/src/servers/sapphire_zone/Action/EventAction.cpp +++ b/src/servers/sapphire_zone/Action/EventAction.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "EventAction.h" #include "Network/PacketWrappers/ActorControlPacket142.h" @@ -9,7 +9,7 @@ #include "Event/EventHandler.h" extern Core::Logger g_log; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; using namespace Core::Network; @@ -28,7 +28,7 @@ Core::Action::EventAction::EventAction( Entity::ActorPtr pActor, uint32_t eventI m_handleActionType = HandleActionType::Event; m_eventId = eventId; m_id = action; - m_castTime = g_exdData.m_EventActionInfoMap[action].castTime; // TODO: Add security checks. + m_castTime = g_exdDataGen.getEventAction( action )->castTime; // TODO: Add security checks. m_onActionFinishClb = finishRef; m_onActionInterruptClb = interruptRef; m_pSource = pActor; diff --git a/src/servers/sapphire_zone/Actor/Actor.cpp b/src/servers/sapphire_zone/Actor/Actor.cpp index 88aa1c04..3342a6e0 100644 --- a/src/servers/sapphire_zone/Actor/Actor.cpp +++ b/src/servers/sapphire_zone/Actor/Actor.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "Forwards.h" @@ -24,7 +25,7 @@ #include "Player.h" extern Core::ServerZone g_serverZone; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; using namespace Core::Network::Packets; @@ -682,7 +683,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u getAsPlayer()->sendDebug( "Handle script skill type: " + std::to_string( type ) ); } - auto actionInfoPtr = g_exdData.getActionInfo( actionId ); + auto actionInfoPtr = g_exdDataGen.getAction( actionId ); // Todo: Effect packet generator. 90% of this is basically setting params and it's basically unreadable. // Prepare packet. This is seemingly common for all packets in the action handler. @@ -708,7 +709,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalDamage; effectPacket.data().effects[0].unknown_3 = 7; - if( !actionInfoPtr->is_aoe ) + if( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 || actionInfoPtr->castType != 1 ) { // If action on this specific target is valid... if ( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) ) @@ -764,7 +765,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u effectPacket.data().effects[0].effectType = ActionEffectType::Heal; effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalHeal; - if( !actionInfoPtr->is_aoe ) + if( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 || actionInfoPtr->castType != 1 ) { if( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Allies ) ) break; diff --git a/src/servers/sapphire_zone/Actor/BattleNpc.cpp b/src/servers/sapphire_zone/Actor/BattleNpc.cpp index 46ab6a8b..81732922 100644 --- a/src/servers/sapphire_zone/Actor/BattleNpc.cpp +++ b/src/servers/sapphire_zone/Actor/BattleNpc.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -21,7 +21,7 @@ using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; extern Core::Logger g_log; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; uint32_t Core::Entity::BattleNpc::m_nextID = 1149241694; @@ -422,7 +422,7 @@ void Core::Entity::BattleNpc::onDeath() auto levelDiff = static_cast< int32_t >( this->m_level ) - level; auto cappedLevelDiff = Math::Util::clamp( levelDiff, 1, 6 ); - auto expNeeded = g_exdData.m_paramGrowthInfoMap[m_level + cappedLevelDiff - 1].needed_exp; + auto expNeeded = g_exdDataGen.getParamGrow( m_level + cappedLevelDiff - 1 )->expToNext; int32_t exp = 0; // todo: arbitrary numbers pulled out of my ass diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index fa8c1d3b..c4ab4497 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "Session.h" @@ -44,7 +44,7 @@ extern Core::Logger g_log; extern Core::ServerZone g_serverZone; extern Core::TerritoryMgr g_territoryMgr; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Scripting::ScriptManager g_scriptMgr; using namespace Core::Common; @@ -211,36 +211,27 @@ void Core::Entity::Player::calculateStats() uint8_t level = getLevel(); uint8_t job = static_cast< uint8_t >( getClass() ); - auto classInfoIt = g_exdData.m_classJobInfoMap.find( job ); - auto tribeInfoIt = g_exdData.m_tribeInfoMap.find( tribe ); - auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( level ); - - if( tribeInfoIt == g_exdData.m_tribeInfoMap.end() || - classInfoIt == g_exdData.m_classJobInfoMap.end() || - paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() ) - return; - - auto tribeInfo = tribeInfoIt->second; - auto classInfo = classInfoIt->second; - auto paramGrowthInfo = paramGrowthInfoIt->second; + auto classInfo = g_exdDataGen.getClassJob( job ); + auto tribeInfo = g_exdDataGen.getTribe( tribe ); + auto paramGrowthInfo = g_exdDataGen.getParamGrow( level ); // TODO: put formula somewhere else... float base = Math::CalcStats::calculateBaseStat( getAsPlayer() ); - m_baseStats.str = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_str ) / 100 ) + tribeInfo.mod_str ); - m_baseStats.dex = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_dex ) / 100 ) + tribeInfo.mod_dex ); - m_baseStats.vit = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_vit ) / 100 ) + tribeInfo.mod_vit ); - m_baseStats.inte = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_int ) / 100 ) + tribeInfo.mod_int ); - m_baseStats.mnd = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_mnd ) / 100 ) + tribeInfo.mod_mnd ); - m_baseStats.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_pie ) / 100 ) + tribeInfo.mod_pie ); + m_baseStats.str = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierStrength ) / 100 ) + tribeInfo->sTR ); + m_baseStats.dex = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierDexterity ) / 100 ) + tribeInfo->dEX ); + m_baseStats.vit = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierVitality ) / 100 ) + tribeInfo->vIT ); + m_baseStats.inte = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierIntelligence ) / 100 ) + tribeInfo->iNT ); + m_baseStats.mnd = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierMind ) / 100 ) + tribeInfo->mND ); + m_baseStats.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierPiety ) / 100 ) + tribeInfo->pIE ); - m_baseStats.skillSpeed = paramGrowthInfo.base_secondary; - m_baseStats.spellSpeed = paramGrowthInfo.base_secondary; - m_baseStats.accuracy = paramGrowthInfo.base_secondary; - m_baseStats.critHitRate = paramGrowthInfo.base_secondary; - m_baseStats.attackPotMagic = paramGrowthInfo.base_secondary; - m_baseStats.healingPotMagic = paramGrowthInfo.base_secondary; - m_baseStats.tenacity = paramGrowthInfo.base_secondary; + m_baseStats.skillSpeed = paramGrowthInfo->baseSpeed; + m_baseStats.spellSpeed = paramGrowthInfo->baseSpeed; + m_baseStats.accuracy = paramGrowthInfo->baseSpeed; + m_baseStats.critHitRate = paramGrowthInfo->baseSpeed; + m_baseStats.attackPotMagic = paramGrowthInfo->baseSpeed; + m_baseStats.healingPotMagic = paramGrowthInfo->baseSpeed; + m_baseStats.tenacity = paramGrowthInfo->baseSpeed; m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() ); @@ -300,7 +291,7 @@ void Core::Entity::Player::sendStats() void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type ) { - auto data = g_exdData.getAetheryteInfo( aetheryteId ); + auto data = g_exdDataGen.getAetheryte( aetheryteId ); if( data == nullptr ) { @@ -309,7 +300,7 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type ) setStateFlag( PlayerStateFlag::BetweenAreas ); - auto z_pos = g_territoryMgr.getTerritoryPosition( data->levelId ); + auto z_pos = g_territoryMgr.getTerritoryPosition( data->territory ); Common::FFXIVARR_POSITION3 pos; pos.x = 0; @@ -323,30 +314,30 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type ) rot = z_pos->getTargetRotation(); } - sendDebug( "Teleport: " + data->placename + " " + data->placename_aethernet + - "(" + std::to_string( data->levelId ) + ")" ); + sendDebug( "Teleport: " + g_exdDataGen.getPlaceName( data->placeName )->name + " " + g_exdDataGen.getPlaceName( data->aethernetName )->name + + "(" + std::to_string( data->territory ) + ")" ); // TODO: this should be simplified and a type created in server_common/common.h. if( type == 1 ) // teleport { - prepareZoning( data->target_zone, true, 1, 112 ); + prepareZoning( data->territory, true, 1, 112 ); // TODO: Really? sendToInRangeSet( ActorControlPacket142( getId(), ActorDespawnEffect, 0x04 ) ); setZoningType( Common::ZoneingType::Teleport ); } else if( type == 2 ) // aethernet { - prepareZoning( data->target_zone, true, 1, 112 ); + prepareZoning( data->territory, true, 1, 112 ); sendToInRangeSet( ActorControlPacket142( getId(), ActorDespawnEffect, 0x04 ) ); setZoningType( Common::ZoneingType::Teleport ); } else if( type == 3 ) // return { - prepareZoning( data->target_zone, true, 1, 111 ); + prepareZoning( data->territory, true, 1, 111 ); sendToInRangeSet( ActorControlPacket142( getId(), ActorDespawnEffect, 0x03 ) ); setZoningType( Common::ZoneingType::Return ); } - m_queuedZoneing = boost::make_shared< QueuedZoning >( data->target_zone, pos, Util::getTimeMs(), rot ); + m_queuedZoneing = boost::make_shared< QueuedZoning >( data->territory, pos, Util::getTimeMs(), rot ); } @@ -502,11 +493,11 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id ) int32_t offset = 4; - auto info = g_exdData.m_zoneInfoMap[getCurrentZone()->getTerritoryId()]; - if( info.is_two_byte ) - offset = 4 + 2 * info.discovery_index; + auto info = g_exdDataGen.getMap( g_exdDataGen.getTerritoryType( getCurrentZone()->getTerritoryId() )->map ); + if( info->discoveryArrayByte ) + offset = 4 + 2 * info->discoveryIndex; else - offset = 324 + 4 * info.discovery_index; + offset = 324 + 4 * info->discoveryIndex; int32_t index = offset + sub_id / 8; uint8_t bitIndex = sub_id % 8; @@ -517,7 +508,7 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id ) uint16_t level = getLevel(); - uint32_t exp = ( g_exdData.m_paramGrowthInfoMap[level].needed_exp * 5 / 100 ); + uint32_t exp = ( g_exdDataGen.getParamGrow(level)->expToNext * 5 / 100 ); gainExp( exp ); @@ -594,9 +585,9 @@ void Core::Entity::Player::gainExp( uint32_t amount ) uint16_t level = getLevel(); - uint32_t neededExpToLevel = g_exdData.m_paramGrowthInfoMap[level].needed_exp; + uint32_t neededExpToLevel = g_exdDataGen.getParamGrow( level )->expToNext; - uint32_t neededExpToLevelplus1 = g_exdData.m_paramGrowthInfoMap[level + 1].needed_exp; + uint32_t neededExpToLevelplus1 = g_exdDataGen.getParamGrow( level + 1 )->expToNext; queuePacket( ActorControlPacket143( getId(), GainExpMsg, static_cast< uint8_t >( getClass() ), amount ) ); @@ -696,25 +687,25 @@ void Core::Entity::Player::sendStatusUpdate( bool toSelf ) uint8_t Core::Entity::Player::getLevel() const { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast< uint8_t >( getClass() ) )->expArrayIndex; return static_cast< uint8_t >( m_classArray[classJobIndex] ); } uint8_t Core::Entity::Player::getLevelForClass( Common::ClassJob pClass ) const { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( pClass )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast< uint8_t >( pClass ) )->expArrayIndex; return static_cast< uint8_t >( m_classArray[classJobIndex] ); } uint32_t Core::Entity::Player::getExp() const { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast< uint8_t >( getClass() ) )->expArrayIndex; return m_expArray[classJobIndex]; } void Core::Entity::Player::setExp( uint32_t amount ) { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast< uint8_t >( getClass() ) )->expArrayIndex; m_expArray[classJobIndex] = amount; } @@ -754,13 +745,13 @@ void Core::Entity::Player::setClassJob( Common::ClassJob classJob ) void Core::Entity::Player::setLevel( uint8_t level ) { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( static_cast< uint8_t >( getClass() ) )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast< uint8_t >( getClass() ) )->expArrayIndex; m_classArray[classJobIndex] = level; } void Core::Entity::Player::setLevelForClass( uint8_t level, Common::ClassJob classjob ) { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( classjob )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast< uint8_t >( classjob ) )->expArrayIndex; if( m_classArray[classJobIndex] == 0 ) insertDbClass( classJobIndex ); @@ -910,11 +901,11 @@ const uint8_t* Core::Entity::Player::getStateFlags() const bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases { - auto actionInfoPtr = g_exdData.getActionInfo( actionId ); - if( actionInfoPtr->is_instant ) + auto actionInfoPtr = g_exdDataGen.getAction( actionId ); + if( actionInfoPtr->preservesCombo ) return false; - return actionInfoPtr->cast_time != 0; + return actionInfoPtr->cast100ms != 0; } diff --git a/src/servers/sapphire_zone/Actor/PlayerQuest.cpp b/src/servers/sapphire_zone/Actor/PlayerQuest.cpp index 3a4c144d..88c1e82a 100644 --- a/src/servers/sapphire_zone/Actor/PlayerQuest.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerQuest.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include "Network/GameConnection.h" @@ -12,7 +12,7 @@ #include "Inventory/Inventory.h" #include "Player.h" -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; using namespace Core::Network::Packets; @@ -1015,24 +1015,24 @@ void Core::Entity::Player::removeQuestsCompleted( uint32_t questId ) bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optionalChoice ) { uint32_t playerLevel = getLevel(); - auto questInfo = g_exdData.getQuestInfo( questId ); + auto questInfo = g_exdDataGen.getQuest( questId ); if( !questInfo ) return false; - auto paramGrowth = g_exdData.m_paramGrowthInfoMap[questInfo->quest_level]; + auto paramGrowth = g_exdDataGen.getParamGrow( questInfo->classJobLevel0 ); // TODO: use the correct formula, this one is wrong - uint32_t exp = ( questInfo->reward_exp_factor * paramGrowth.quest_exp_mod * ( 45 + 5 * questInfo->quest_level) ) / 100; - exp = exp + ( questInfo->reward_exp_factor / 100 ) * 10000; + uint32_t exp = ( questInfo->expFactor * paramGrowth->questExpModifier * ( 45 + 5 * questInfo->classJobLevel0 ) ) / 100; + exp = exp + ( questInfo->expFactor / 100 ) * 10000; - exp = questInfo->reward_exp_factor; + exp = questInfo->expFactor; - auto rewardItemCount = questInfo->reward_item.size(); - uint16_t optionalItemCount = questInfo->reward_item_optional.size() > 0 ? 1 : 0; + auto rewardItemCount = questInfo->itemReward0.size(); + uint16_t optionalItemCount = questInfo->itemReward1.size(); - uint32_t gilReward = questInfo->reward_gil; + uint32_t gilReward = questInfo->gilReward; // TODO: check if there is room in inventory, else return false; if( exp > 0 ) @@ -1040,18 +1040,18 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional if( rewardItemCount > 0 ) { - for( uint32_t i = 0; i < questInfo->reward_item.size(); i++ ) + for( uint32_t i = 0; i < questInfo->itemReward0.size(); i++ ) { // TODO: add the correct amount of items instead of 1 - addItem( -1, questInfo->reward_item.at( i ), questInfo->reward_item_count.at( i ) ); + addItem( -1, questInfo->itemReward0.at( i ), questInfo->itemReward1.at( i ) ); } } if( optionalItemCount > 0 ) { - auto itemId = questInfo->reward_item_optional.at( optionalChoice ); + auto itemId = questInfo->itemReward1.at( optionalChoice ); // TODO: add the correct amount of items instead of 1 - addItem( -1, itemId, questInfo->reward_item_optional_count.at( optionalChoice ) ); + addItem( -1, itemId, questInfo->itemCountReward1.at( optionalChoice ) ); } if( gilReward > 0 ) diff --git a/src/servers/sapphire_zone/Actor/PlayerSql.cpp b/src/servers/sapphire_zone/Actor/PlayerSql.cpp index 044dd5ea..fbf2f60c 100644 --- a/src/servers/sapphire_zone/Actor/PlayerSql.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerSql.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ extern Core::Logger g_log; extern Core::ServerZone g_serverZone; extern Core::TerritoryMgr g_territoryMgr; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; @@ -433,7 +433,7 @@ void Core::Entity::Player::updateSql() void Core::Entity::Player::updateDbClass() const { - uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx; + uint8_t classJobIndex = g_exdDataGen.getClassJob( static_cast( getClass() ) )->expArrayIndex; //Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ? auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_UP ); diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 2902dc13..ee20b4a5 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include "DebugCommand.h" @@ -40,7 +40,7 @@ #include "Zone/TerritoryMgr.h" extern Core::Scripting::ScriptManager g_scriptMgr; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Logger g_log; extern Core::ServerZone g_serverZone; extern Core::TerritoryMgr g_territoryMgr; @@ -480,7 +480,7 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost: if( ( subCommand == "pos" ) ) { - int16_t map_id = g_exdData.m_zoneInfoMap[player.getCurrentZone()->getTerritoryId()].map_id; + int16_t map_id = g_exdDataGen.getTerritoryType( player.getCurrentZone()->getTerritoryId() )->map; player.sendNotice( "Pos:\n" + std::to_string( player.getPos().x ) + "\n" + diff --git a/src/servers/sapphire_zone/Event/EventHelper.cpp b/src/servers/sapphire_zone/Event/EventHelper.cpp index a043de75..018474d2 100644 --- a/src/servers/sapphire_zone/Event/EventHelper.cpp +++ b/src/servers/sapphire_zone/Event/EventHelper.cpp @@ -1,10 +1,8 @@ #include "EventHelper.h" #include "EventHandler.h" #include -#include #include -extern Core::Data::ExdData g_exdData; extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; @@ -41,7 +39,7 @@ std::string Core::Event::getEventName( uint32_t eventId ) } case Event::EventHandler::EventHandlerType::Opening: { - auto openingInfo = g_exdData.getOpeningInfo( eventId ); + auto openingInfo = g_exdDataGen.getOpening( eventId ); if( openingInfo ) return openingInfo->name; return unknown + "Opening"; @@ -67,9 +65,9 @@ std::string Core::Event::getEventName( uint32_t eventId ) uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId ) { - auto levelInfo = g_exdData.getLevelInfo( eventActorId ); + auto levelInfo = g_exdDataGen.getLevel( eventActorId ); if( levelInfo ) - return levelInfo->actor_id; + return levelInfo->objectKey; return 0; } diff --git a/src/servers/sapphire_zone/Inventory/Inventory.cpp b/src/servers/sapphire_zone/Inventory/Inventory.cpp index 7d2275a4..7ace94d7 100644 --- a/src/servers/sapphire_zone/Inventory/Inventory.cpp +++ b/src/servers/sapphire_zone/Inventory/Inventory.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -21,7 +21,7 @@ extern Core::Logger g_log; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; using namespace Core::Network; @@ -135,11 +135,11 @@ Core::ItemPtr Core::Inventory::getItemAt( uint16_t containerId, uint8_t slotId ) Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity ) { - auto itemInfo = g_exdData.getItemInfo( catalogId ); + auto itemInfo = g_exdDataGen.getItem( catalogId ); uint8_t itemAmount = quantity; - if( itemInfo->stack_size == 1 ) + if( itemInfo->stackSize == 1 ) itemAmount = 1; if( !itemInfo ) @@ -153,8 +153,8 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity pItem->setStackSize( itemAmount ); pItem->setUId( getNextUId() ); - pItem->setModelIds( itemInfo->model_primary, itemInfo->model_secondary ); - pItem->setCategory( static_cast< ItemUICategory >( itemInfo->ui_category ) ); + pItem->setModelIds( itemInfo->modelMain, itemInfo->modelSub ); + pItem->setCategory( static_cast< ItemUICategory >( itemInfo->itemUICategory ) ); g_charaDb.execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " + std::to_string( m_pOwner->getId() ) + ", " + @@ -473,10 +473,10 @@ bool Core::Inventory::isObtainable( uint32_t catalogId, uint8_t quantity ) int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint8_t quantity ) { - auto itemInfo = g_exdData.getItemInfo( catalogId ); + auto itemInfo = g_exdDataGen.getItem( catalogId ); // if item data doesn't exist or it's a blank field - if( !itemInfo || itemInfo->item_level == 0 ) + if( !itemInfo || itemInfo->levelItem == 0 ) { return -1; } @@ -656,13 +656,13 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId ) try { - auto itemInfo = g_exdData.getItemInfo( itemRes->getUInt( 1 ) ); + auto itemInfo = g_exdDataGen.getItem( itemRes->getUInt( 1 ) ); bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false; ItemPtr pItem( new Item( uId, - itemInfo->id, - itemInfo->model_primary, - itemInfo->model_secondary, - static_cast< ItemUICategory >( itemInfo->ui_category ), + itemRes->getUInt( 1 ), + itemInfo->modelMain, + itemInfo->modelSub, + static_cast< ItemUICategory >( itemInfo->itemUICategory ), isHq ) ); pItem->setStackSize( itemRes->getUInt( 2 ) ); diff --git a/src/servers/sapphire_zone/Inventory/Item.cpp b/src/servers/sapphire_zone/Inventory/Item.cpp index e77c4ca4..01f7639c 100644 --- a/src/servers/sapphire_zone/Inventory/Item.cpp +++ b/src/servers/sapphire_zone/Inventory/Item.cpp @@ -1,8 +1,8 @@ #include -#include +#include #include "Item.h" -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; Core::Item::Item() { @@ -24,13 +24,13 @@ Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t mo m_model2( model2 ), m_isHq( isHq ) { - auto itemInfo = g_exdData.getItemInfo( catalogId ); - m_delayMs = itemInfo->delayMs; - m_physicalDmg = itemInfo->physical_damage; - m_magicalDmg = itemInfo->magical_damage; + auto itemInfo = g_exdDataGen.getItem( catalogId ); + m_delayMs = itemInfo->delayms; + m_physicalDmg = itemInfo->damagePhys; + m_magicalDmg = itemInfo->damageMag; m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg; m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000; - m_itemLevel = itemInfo->item_level; + m_itemLevel = itemInfo->levelItem; } Core::Item::~Item() diff --git a/src/servers/sapphire_zone/Math/CalcBattle.cpp b/src/servers/sapphire_zone/Math/CalcBattle.cpp index 12f93936..89a522cd 100644 --- a/src/servers/sapphire_zone/Math/CalcBattle.cpp +++ b/src/servers/sapphire_zone/Math/CalcBattle.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include "Actor/Actor.h" #include "Actor/Player.h" @@ -10,7 +10,7 @@ using namespace Core::Math; using namespace Core::Entity; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; /* Class used for battle-related formulas and calculations. @@ -30,14 +30,13 @@ extern Core::Data::ExdData g_exdData; uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency ) { - auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) ); - auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() ); + auto classInfo = g_exdDataGen.getClassJob( static_cast< uint8_t >( pPlayer->getClass() ) ); + auto paramGrowthInfo = g_exdDataGen.getParamGrow( pPlayer->getLevel() ); - if ( classInfoIt == g_exdData.m_classJobInfoMap.end() || - paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end()) + if ( !classInfo || !paramGrowthInfo ) return 0; - auto jobModVal = classInfoIt->second; + //auto jobModVal = classInfoIt->second; // consider 3% variation return potency / 10; diff --git a/src/servers/sapphire_zone/Math/CalcStats.cpp b/src/servers/sapphire_zone/Math/CalcStats.cpp index 2e390887..63bf66ea 100644 --- a/src/servers/sapphire_zone/Math/CalcStats.cpp +++ b/src/servers/sapphire_zone/Math/CalcStats.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include "Actor/Actor.h" #include "Actor/Player.h" @@ -11,7 +11,7 @@ using namespace Core::Math; using namespace Core::Entity; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; /* Class used for battle-related formulas and calculations. @@ -61,19 +61,18 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer ) // Is there any way to pull reliable BaseHP without having to manually use a pet for every level, and using the values from a table? // More info here: https://docs.google.com/spreadsheets/d/1de06KGT0cNRUvyiXNmjNgcNvzBCCQku7jte5QxEQRbs/edit?usp=sharing - auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) ); - auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() ); + auto classInfo = g_exdDataGen.getClassJob( static_cast< uint8_t >( pPlayer->getClass() ) ); + auto paramGrowthInfo = g_exdDataGen.getParamGrow( pPlayer->getLevel() ); - if ( classInfoIt == g_exdData.m_classJobInfoMap.end() || - paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() ) + if ( !classInfo || !paramGrowthInfo ) return 0; uint8_t level = pPlayer->getLevel(); float baseStat = calculateBaseStat( pPlayer ); uint16_t vitStat = pPlayer->getStats().vit; - uint16_t hpMod = paramGrowthInfoIt->second.hp_mod; - uint16_t jobModHp = classInfoIt->second.mod_hp; + uint16_t hpMod = paramGrowthInfo->hpModifier; + uint16_t jobModHp = classInfo->modifierHitPoints; float approxBaseHp = 0.0f; // Read above // These values are not precise. @@ -83,7 +82,7 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer ) else if ( level >= 50 ) approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) ); else - approxBaseHp = paramGrowthInfoIt->second.mp_const * 0.7667f; + approxBaseHp = paramGrowthInfo->mpModifier * 0.7667f; uint16_t result = static_cast< uint16_t >( floor( jobModHp * ( approxBaseHp / 100.0f ) ) + floor( hpMod / 100.0f * ( vitStat - baseStat ) ) ); @@ -95,18 +94,17 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer ) uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer ) { - auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) ); - auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() ); + auto classInfo = g_exdDataGen.getClassJob( static_cast< uint8_t >( pPlayer->getClass() ) ); + auto paramGrowthInfo = g_exdDataGen.getParamGrow( pPlayer->getLevel() ); - if ( classInfoIt == g_exdData.m_classJobInfoMap.end() || - paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() ) + if ( !classInfo || !paramGrowthInfo ) return 0; float baseStat = calculateBaseStat( pPlayer ); uint16_t piety = pPlayer->getStats().pie; - uint16_t pietyScalar = paramGrowthInfoIt->second.mp_mod; - uint16_t jobModMp = classInfoIt->second.mod_mpcpgp; - uint16_t baseMp = paramGrowthInfoIt->second.mp_const; + uint16_t pietyScalar = paramGrowthInfo->mpModifier; + uint16_t jobModMp = classInfo->modifierManaPoints; + uint16_t baseMp = paramGrowthInfo->mpModifier; uint16_t result = static_cast< uint16_t >( floor( floor( piety - baseStat ) * ( pietyScalar / 100 ) + baseMp ) * jobModMp / 100 ); diff --git a/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp index 90c9140a..c8bbc0f9 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include @@ -36,7 +36,7 @@ extern Core::Logger g_log; extern Core::ServerZone g_serverZone; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::DebugCommandHandler g_gameCommandMgr; using namespace Core::Common; @@ -200,15 +200,15 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in case 0xCA: // Teleport { // TODO: only register this action if enough gil is in possession - auto targetAetheryte = g_exdData.getAetheryteInfo( param11 ); + auto targetAetheryte = g_exdDataGen.getAetheryte( param11 ); if( targetAetheryte ) { - auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[player.getZoneId()].aetheryte_index ); + auto fromAetheryte = g_exdDataGen.getAetheryte( g_exdDataGen.getTerritoryType( player.getZoneId() )->aetheryte ); // calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets - auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) + - pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 ); + auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->aetherstreamX - targetAetheryte->aetherstreamX, 2 ) + + pow( fromAetheryte->aetherstreamY - targetAetheryte->aetherstreamY, 2 ) ) / 2 ) + 100 ); // cap at 999 gil cost = cost > uint16_t{999} ? uint16_t{999} : cost; diff --git a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp index e36c9717..9417a87f 100644 --- a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -21,7 +21,7 @@ #include "Forwards.h" #include "Event/EventHelper.h" -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Scripting::ScriptManager g_scriptMgr; using namespace Core::Common; @@ -52,9 +52,9 @@ void Core::Network::GameConnection::eventHandlerTalk( const Packets::GamePacket& if( !g_scriptMgr.onTalk( player, actorId, eventId ) && eventType == Event::EventHandler::EventHandlerType::Quest ) { - auto questInfo = g_exdData.getQuestInfo( eventId ); + auto questInfo = g_exdDataGen.getQuest( eventId ); if ( questInfo ) - player.sendUrgent( "Quest not implemented: " + questInfo->name + " (" + questInfo->name_intern + ")" ); + player.sendUrgent( "Quest not implemented: " + questInfo->name + " (" + questInfo->id + ")" ); } player.checkEvent( eventId ); @@ -87,7 +87,7 @@ void Core::Network::GameConnection::eventHandlerEmote( const Packets::GamePacket if( !g_scriptMgr.onEmote( player, actorId, eventId, static_cast< uint8_t >( emoteId ) ) && eventType == Event::EventHandler::EventHandlerType::Quest ) { - auto questInfo = g_exdData.getQuestInfo( eventId ); + auto questInfo = g_exdDataGen.getQuest( eventId ); if( questInfo ) player.sendUrgent( "Quest not implemented: " + questInfo->name ); } diff --git a/src/servers/sapphire_zone/Network/Handlers/SkillHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/SkillHandler.cpp index 38b339c7..1240bf8c 100644 --- a/src/servers/sapphire_zone/Network/Handlers/SkillHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/SkillHandler.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ extern Core::Scripting::ScriptManager g_scriptMgr; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Logger g_log; using namespace Core::Common; @@ -60,7 +60,7 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action ); player.sendDebug( "---------------------------------------" ); player.sendDebug( "ActionHandler ( " + actionIdStr + " | " + - g_exdData.getActionInfo( action )->name + + g_exdDataGen.getAction( action )->name + " | " + std::to_string( targetId ) + " )" ); player.queuePacket( ActorControlPacket142( player.getId(), ActorControlType::ActionStart, 0x01, action ) ); @@ -100,11 +100,11 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP } else if( action < 3000000 ) // item action { - auto info = g_exdData.getEventItemInfo( action ); + auto info = g_exdDataGen.getEventItem( action ); if( info ) { g_log.debug( info->name ); - g_scriptMgr.onEventItem( player, action, info->eventId, info->castTime, targetId ); + g_scriptMgr.onEventItem( player, action, info->quest, info->castTime, targetId ); } } else if( action > 3000000 ) // unknown diff --git a/src/servers/sapphire_zone/Script/ScriptManager.cpp b/src/servers/sapphire_zone/Script/ScriptManager.cpp index 40eddee6..2467fa07 100644 --- a/src/servers/sapphire_zone/Script/ScriptManager.cpp +++ b/src/servers/sapphire_zone/Script/ScriptManager.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include "NativeScriptManager.h" @@ -26,7 +26,7 @@ #include extern Core::Logger g_log; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::ServerZone g_serverZone; Core::Scripting::ScriptManager::ScriptManager() : @@ -154,7 +154,7 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac // aethernet/aetherytes need to be handled separately if( eventType == Event::EventHandler::EventHandlerType::Aetheryte ) { - auto aetherInfo = g_exdData.getAetheryteInfo( eventId & 0xFFFF ); + auto aetherInfo = g_exdDataGen.getAetheryte( eventId & 0xFFFF ); scriptId = EVENTSCRIPT_AETHERYTE_ID; if( !aetherInfo->isAetheryte ) scriptId = EVENTSCRIPT_AETHERNET_ID; diff --git a/src/servers/sapphire_zone/ServerZone.cpp b/src/servers/sapphire_zone/ServerZone.cpp index 712fa37d..322e2b83 100644 --- a/src/servers/sapphire_zone/ServerZone.cpp +++ b/src/servers/sapphire_zone/ServerZone.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -39,7 +38,6 @@ Core::Logger g_log; Core::DebugCommandHandler g_gameCommandMgr; Core::Scripting::ScriptManager g_scriptMgr; -Core::Data::ExdData g_exdData; Core::Data::ExdDataGenerated g_exdDataGen; Core::TerritoryMgr g_territoryMgr; Core::LinkshellMgr g_linkshellMgr; @@ -164,13 +162,6 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) } } - g_log.info( "Setting up EXD data" ); - if( !g_exdData.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) - { - g_log.fatal( "Error setting up EXD data " ); - return false; - } - g_log.info( "Setting up generated EXD data" ); if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) { @@ -213,15 +204,6 @@ void Core::ServerZone::run( int32_t argc, char* argv[] ) return; } - g_exdData.loadZoneInfo(); - g_exdData.loadClassJobInfo(); - g_exdData.loadParamGrowInfo(); - g_exdData.loadEventActionInfo(); - g_exdData.loadActionInfo(); - g_exdData.loadStatusEffectInfo(); - g_exdData.loadAetheryteInfo(); - g_exdData.loadTribeInfo(); - g_log.info( "LinkshellMgr: Caching linkshells" ); if( !g_linkshellMgr.loadLinkshells() ) { diff --git a/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp b/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp index 1a4063f8..7d986249 100644 --- a/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp +++ b/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -13,7 +13,7 @@ #include "Script/ScriptManager.h" extern Core::Logger g_log; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; using namespace Core::Common; using namespace Core::Network::Packets; @@ -31,8 +31,8 @@ Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr so , m_tickRate( tickRate ) , m_lastTick( 0 ) { - auto& entry = g_exdData.m_statusEffectInfoMap[id]; - m_name = entry.name; + auto entry = g_exdDataGen.getStatus( id ); + m_name = entry->name; std::replace( m_name.begin(), m_name.end(), ' ', '_' ); std::replace( m_name.begin(), m_name.end(), ':', '_' ); diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index c2141e68..3f0338d7 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ extern Core::Logger g_log; extern Core::ServerZone g_serverZone; -extern Core::Data::ExdData g_exdData; +extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Scripting::ScriptManager g_scriptMgr; namespace Core { @@ -207,7 +207,7 @@ void Zone::loadCellCache() uint8_t Zone::getNextWeather() { - auto zoneInfo = g_exdData.m_zoneInfoMap[getTerritoryId()]; + auto zoneInfo = g_exdDataGen.getTerritoryType( getTerritoryId() ); uint32_t unixTime = static_cast< uint32_t >( Util::getTimeSeconds() ); // Get Eorzea hour for weather start @@ -225,7 +225,26 @@ uint8_t Zone::getNextWeather() auto rate = static_cast< uint8_t >( step2 % 0x64 ); - for( auto entry : zoneInfo.weather_rate_map ) + auto weatherRate = g_exdDataGen.getWeatherRate( zoneInfo->weatherRate ); + auto weatherRateFields = g_exdDataGen.m_WeatherRateDat.get_row( zoneInfo->weatherRate ); + + std::map< uint8_t, int32_t> weatherRateMap; + + uint8_t sumPc = 0; + for( size_t i = 0; i < 16; ) + { + int32_t weatherId = boost::get( weatherRateFields[i] ); + + if( weatherId == 0 ) + break; + + sumPc += boost::get( weatherRateFields[i + 1] ); + weatherRateMap[sumPc] = weatherId; + + i += 2; + } + + for( auto entry : weatherRateMap ) { uint8_t sRate = entry.first; auto weatherId = static_cast< uint8_t >( entry.second ); diff --git a/src/tools/exd_struct_gen/ex.json b/src/tools/exd_struct_gen/ex.json index b199c795..5b4ab455 100644 --- a/src/tools/exd_struct_gen/ex.json +++ b/src/tools/exd_struct_gen/ex.json @@ -1666,10 +1666,18 @@ "target": "ClassJobCategory" } }, + { + "index": 4, + "name": "ExpArrayIndex" + }, { "index": 9, "name": "Modifier{HitPoints}" }, + { + "index": 10, + "name": "Modifier{ManaPoints}" + }, { "index": 11, "name": "Modifier{Strength}" @@ -6244,6 +6252,10 @@ "target": "PlaceName" } }, + { + "index": 8, + "name": "DiscoveryIndex" + }, { "index": 14, "name": "TerritoryType", @@ -6251,6 +6263,10 @@ "type": "link", "target": "TerritoryType" } + }, + { + "index": 15, + "name": "DiscoveryArrayByte" } ] }, @@ -6845,6 +6861,15 @@ } ] }, + { + "sheet": "Opening", + "defaultColumn": "Name", + "definitions": [ + { + "name": "Name" + } + ] + }, { "sheet": "Orchestrion", "definitions": [ From 6793cccaa0e32d4621a965414922fb9d8146b7c8 Mon Sep 17 00:00:00 2001 From: goaaats <16760685+goaaats@users.noreply.github.com> Date: Wed, 31 Jan 2018 11:58:29 +0100 Subject: [PATCH 2/6] Style --- src/servers/sapphire_zone/Actor/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index c4ab4497..7cc33dd9 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -508,7 +508,7 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id ) uint16_t level = getLevel(); - uint32_t exp = ( g_exdDataGen.getParamGrow(level)->expToNext * 5 / 100 ); + uint32_t exp = ( g_exdDataGen.getParamGrow( level )->expToNext * 5 / 100 ); gainExp( exp ); From c460283ca6541cfea7d1471906074a10881418c0 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 1 Feb 2018 14:50:51 +0100 Subject: [PATCH 3/6] Fix for weather crash --- src/common/Exd/ExdDataGenerated.cpp | 7 ++++++- src/common/Exd/ExdDataGenerated.h | 4 +++- src/servers/sapphire_zone/Zone/Zone.cpp | 8 +++++--- src/tools/exd_struct_gen/ex.json | 14 +++++++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/common/Exd/ExdDataGenerated.cpp b/src/common/Exd/ExdDataGenerated.cpp index 84904506..9c401e72 100644 --- a/src/common/Exd/ExdDataGenerated.cpp +++ b/src/common/Exd/ExdDataGenerated.cpp @@ -2378,10 +2378,11 @@ id = exdData->getField< std::string >( row, 5 ); sizeFactor = exdData->getField< uint16_t >( row, 6 ); offsetX = exdData->getField< int16_t >( row, 7 ); - discoveryIndex = exdData->getField< int16_t >( row, 8 ); + offsetY = exdData->getField< int16_t >( row, 8 ); placeNameRegion = exdData->getField< uint16_t >( row, 9 ); placeName = exdData->getField< uint16_t >( row, 10 ); placeNameSub = exdData->getField< uint16_t >( row, 11 ); + discoveryIndex = exdData->getField< int16_t >( row, 12 ); territoryType = exdData->getField< uint16_t >( row, 14 ); discoveryArrayByte = exdData->getField< bool >( row, 15 ); } @@ -3711,6 +3712,10 @@ defaultTalkNPCWin = exdData->getField< uint32_t >( row, 22 ); defaultTalkDraw = exdData->getField< uint32_t >( row, 23 ); defaultTalkPCWin = exdData->getField< uint32_t >( row, 24 ); + itemPossibleReward.push_back( exdData->getField< uint32_t >( row, 26 ) ); + itemPossibleReward.push_back( exdData->getField< uint32_t >( row, 27 ) ); + itemPossibleReward.push_back( exdData->getField< uint32_t >( row, 28 ) ); + itemPossibleReward.push_back( exdData->getField< uint32_t >( row, 29 ) ); } Core::Data::TripleTriadCard::TripleTriadCard( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ) diff --git a/src/common/Exd/ExdDataGenerated.h b/src/common/Exd/ExdDataGenerated.h index 2192626e..f86c73c7 100644 --- a/src/common/Exd/ExdDataGenerated.h +++ b/src/common/Exd/ExdDataGenerated.h @@ -2424,10 +2424,11 @@ struct Map std::string id; uint16_t sizeFactor; int16_t offsetX; - int16_t discoveryIndex; + int16_t offsetY; uint16_t placeNameRegion; uint16_t placeName; uint16_t placeNameSub; + int16_t discoveryIndex; uint16_t territoryType; bool discoveryArrayByte; @@ -3215,6 +3216,7 @@ struct TripleTriad uint32_t defaultTalkNPCWin; uint32_t defaultTalkDraw; uint32_t defaultTalkPCWin; + std::vector< uint32_t > itemPossibleReward; TripleTriad( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ); }; diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index 3f0338d7..92642861 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -225,8 +225,10 @@ uint8_t Zone::getNextWeather() auto rate = static_cast< uint8_t >( step2 % 0x64 ); - auto weatherRate = g_exdDataGen.getWeatherRate( zoneInfo->weatherRate ); - auto weatherRateFields = g_exdDataGen.m_WeatherRateDat.get_row( zoneInfo->weatherRate ); + uint8_t weatherRateNum = zoneInfo->weatherRate > g_exdDataGen.getWeatherRateIdList().size() ? 0 : zoneInfo->weatherRate; + + auto weatherRate = g_exdDataGen.getWeatherRate( weatherRateNum ); + auto weatherRateFields = g_exdDataGen.m_WeatherRateDat.get_row( weatherRateNum ); std::map< uint8_t, int32_t> weatherRateMap; @@ -238,7 +240,7 @@ uint8_t Zone::getNextWeather() if( weatherId == 0 ) break; - sumPc += boost::get( weatherRateFields[i + 1] ); + sumPc += boost::get( weatherRateFields[i + 1] ); weatherRateMap[sumPc] = weatherId; i += 2; diff --git a/src/tools/exd_struct_gen/ex.json b/src/tools/exd_struct_gen/ex.json index 5b4ab455..51b01c68 100644 --- a/src/tools/exd_struct_gen/ex.json +++ b/src/tools/exd_struct_gen/ex.json @@ -6253,7 +6253,7 @@ } }, { - "index": 8, + "index": 12, "name": "DiscoveryIndex" }, { @@ -9114,6 +9114,18 @@ "type": "link", "target": "DefaultTalk" } + }, + { + "index": 26, + "type": "repeat", + "count": 4, + "definition": { + "name": "Item{PossibleReward}", + "converter": { + "type": "link", + "target": "Item" + } + } } ] }, From 4f22c20fa89754ca4f90e10817d711f50bf31434 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 1 Feb 2018 16:28:03 +0100 Subject: [PATCH 4/6] Style --- src/servers/sapphire_zone/Zone/Zone.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index 92642861..83b06bca 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -235,12 +235,12 @@ uint8_t Zone::getNextWeather() uint8_t sumPc = 0; for( size_t i = 0; i < 16; ) { - int32_t weatherId = boost::get( weatherRateFields[i] ); + int32_t weatherId = boost::get< int32_t >( weatherRateFields[i] ); if( weatherId == 0 ) break; - sumPc += boost::get( weatherRateFields[i + 1] ); + sumPc += boost::get< uint8_t >( weatherRateFields[i + 1] ); weatherRateMap[sumPc] = weatherId; i += 2; From ed9a140ccc3fdf33e38479d6abbd7879ba02e18a Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 1 Feb 2018 16:28:14 +0100 Subject: [PATCH 5/6] Fix cast time --- src/servers/sapphire_zone/Action/ActionCast.cpp | 2 +- src/servers/sapphire_zone/Action/ActionTeleport.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/servers/sapphire_zone/Action/ActionCast.cpp b/src/servers/sapphire_zone/Action/ActionCast.cpp index 2e4f8f29..8e275898 100644 --- a/src/servers/sapphire_zone/Action/ActionCast.cpp +++ b/src/servers/sapphire_zone/Action/ActionCast.cpp @@ -31,7 +31,7 @@ Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr m_startTime = 0; m_id = actionId; m_handleActionType = HandleActionType::Spell; - m_castTime = g_exdDataGen.getAction( actionId )->cast100ms; // TODO: Add security checks. + m_castTime = g_exdDataGen.getAction( actionId )->cast100ms * 100; // TODO: Add security checks. m_pSource = pActor; m_pTarget = pTarget; m_bInterrupt = false; diff --git a/src/servers/sapphire_zone/Action/ActionTeleport.cpp b/src/servers/sapphire_zone/Action/ActionTeleport.cpp index 313ec6ee..09824332 100644 --- a/src/servers/sapphire_zone/Action/ActionTeleport.cpp +++ b/src/servers/sapphire_zone/Action/ActionTeleport.cpp @@ -26,7 +26,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t m_startTime = 0; m_id = 5; m_handleActionType = HandleActionType::Teleport; - m_castTime = g_exdDataGen.getAction( 5 )->cast100ms; // TODO: Add security checks. + m_castTime = g_exdDataGen.getAction( 5 )->cast100ms * 5; // TODO: Add security checks. m_pSource = pActor; m_bInterrupt = false; m_targetAetheryte = targetZone; From 2adfdbc47de3dfb7b90f210d66724365beba9db6 Mon Sep 17 00:00:00 2001 From: Mordred <30826167+SapphireMordred@users.noreply.github.com> Date: Thu, 1 Feb 2018 17:47:55 +0100 Subject: [PATCH 6/6] Update ActionTeleport.cpp --- src/servers/sapphire_zone/Action/ActionTeleport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/Action/ActionTeleport.cpp b/src/servers/sapphire_zone/Action/ActionTeleport.cpp index 09824332..7ba3d7b7 100644 --- a/src/servers/sapphire_zone/Action/ActionTeleport.cpp +++ b/src/servers/sapphire_zone/Action/ActionTeleport.cpp @@ -26,7 +26,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t m_startTime = 0; m_id = 5; m_handleActionType = HandleActionType::Teleport; - m_castTime = g_exdDataGen.getAction( 5 )->cast100ms * 5; // TODO: Add security checks. + m_castTime = g_exdDataGen.getAction( 5 )->cast100ms * 100; // TODO: Add security checks. m_pSource = pActor; m_bInterrupt = false; m_targetAetheryte = targetZone;