From 1a572258f4d839fb52eebfe9faf79ba3dd37c9ca Mon Sep 17 00:00:00 2001 From: Atemo Date: Fri, 26 Jan 2024 15:39:45 +0100 Subject: [PATCH] Updated format --- src/map/clif.cpp | 8 ++++---- src/map/itemdb.cpp | 11 ++++++----- src/tool/yamlupgrade.cpp | 28 ++++++++++++++-------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 0874e830bb..f0b4217e18 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -23572,23 +23572,23 @@ void clif_parse_laphine_upgrade( int fd, map_session_data* sd ){ int total_rate = 0; // Get the total rate (sum of the rate) - for ( const auto& it : upgrade->resultRefine ) { + for (const auto& it : upgrade->resultRefine) { if (it.second == 0) // Level removed on import continue; total_rate += it.second; } if (total_rate > 0) { - int chance = rnd_value( 1, total_rate ); + int chance = rnd_value(1, total_rate); int sum_rate = 0; - for ( const auto& it : upgrade->resultRefine ) { + for (const auto& it : upgrade->resultRefine) { if (it.second == 0) continue; sum_rate += it.second; if (chance <= sum_rate) { - item->refine = cap_value( it.first, 0, MAX_REFINE ); + item->refine = cap_value(it.first, 0, MAX_REFINE); break; } } diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 91e9a308b1..5d53a93434 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -1793,7 +1793,7 @@ uint64 LaphineUpgradeDatabase::parseBodyNode( const ryml::NodeRef& node ){ } } - if (this->nodeExists( node, "ResultRefine" )) { + if (this->nodeExists(node, "ResultRefine")) { const auto& refineNode = node["ResultRefine"]; for (const auto& refineit : refineNode) { @@ -1802,16 +1802,17 @@ uint64 LaphineUpgradeDatabase::parseBodyNode( const ryml::NodeRef& node ){ if (!this->asUInt16Rate(refineit, "Level", level, MAX_REFINE)) return 0; - bool refine_exists = util::umap_find( entry->resultRefine, level ) != nullptr; + bool refine_exists = util::umap_find(entry->resultRefine, level) != nullptr; - if (this->nodeExists( refineit, "Rate" )) { + if (this->nodeExists(refineit, "Rate")) { uint16 rate; - if (!this->asUInt16Rate( refineit, "Rate", rate )) { + if (!this->asUInt16Rate(refineit, "Rate", rate)) { return 0; } entry->resultRefine[level] = rate; - } else { + } + else { if (!refine_exists) { entry->resultRefine[level] = 1; } diff --git a/src/tool/yamlupgrade.cpp b/src/tool/yamlupgrade.cpp index 74758c5ca9..bb3f15e66d 100644 --- a/src/tool/yamlupgrade.cpp +++ b/src/tool/yamlupgrade.cpp @@ -522,17 +522,17 @@ static bool upgrade_item_group_db( std::string file, const uint32 source_version return true; } -static bool upgrade_laphine_upgrade( std::string file, const uint32 source_version ){ +static bool upgrade_laphine_upgrade(std::string file, const uint32 source_version) { size_t entries = 0; - for( auto input : inNode["Body"] ){ - if( source_version < 2 ){ - if( input["ResultRefine"].IsDefined() ){ + for (auto input : inNode["Body"]) { + if (source_version < 2) { + if (input["ResultRefine"].IsDefined()) { // Convert ResultRefine to a ResultRefine array uint16 refine_level = input["ResultRefine"].as(); // Remove the existing Refine entry - input.remove( "ResultRefine" ); + input.remove("ResultRefine"); // Add the ResultRefine array auto RatesNode = input["ResultRefine"]; @@ -542,27 +542,27 @@ static bool upgrade_laphine_upgrade( std::string file, const uint32 source_versi } // Convert the values between ResultRefineMinimum and ResultRefineMaximum to a ResultRefine array - if( input["ResultRefineMinimum"].IsDefined() || input["ResultRefineMaximum"].IsDefined() ){ + if (input["ResultRefineMinimum"].IsDefined() || input["ResultRefineMaximum"].IsDefined()) { uint16 refine_level_min = 0, refine_level_max = MAX_REFINE; // Save data and remove the existing ResultRefineMinimum/ResultRefineMaximum entry - if( input["ResultRefineMinimum"].IsDefined() ) { + if (input["ResultRefineMinimum"].IsDefined()) { refine_level_min = input["ResultRefineMinimum"].as(); - input.remove( "ResultRefineMinimum" ); + input.remove("ResultRefineMinimum"); } - if( input["ResultRefineMaximum"].IsDefined() ) { + if (input["ResultRefineMaximum"].IsDefined()) { refine_level_max = input["ResultRefineMaximum"].as(); - input.remove( "ResultRefineMaximum" ); + input.remove("ResultRefineMaximum"); } // Remove existing ResultRefine entry (shouldn't happen) - if( input["ResultRefine"].IsDefined() ) - input.remove( "ResultRefine" ); + if (input["ResultRefine"].IsDefined()) + input.remove("ResultRefine"); // Add the ResultRefine array auto RatesNode = input["ResultRefine"]; - for( int i = refine_level_min, j = 0; i <= refine_level_max; i++, j++ ){ + for (int i = refine_level_min, j = 0; i <= refine_level_max; i++, j++) { auto RateNode = RatesNode[j]; RateNode["Level"] = i; @@ -574,7 +574,7 @@ static bool upgrade_laphine_upgrade( std::string file, const uint32 source_versi entries++; } - ShowStatus( "Done converting/upgrading '" CL_WHITE "%zu" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str() ); + ShowStatus("Done converting/upgrading '" CL_WHITE "%zu" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str()); return true; }