Updated format

This commit is contained in:
Atemo 2024-01-26 15:39:45 +01:00
parent c8729f5bd6
commit 1a572258f4
3 changed files with 24 additions and 23 deletions

View File

@ -23572,23 +23572,23 @@ void clif_parse_laphine_upgrade( int fd, map_session_data* sd ){
int total_rate = 0; int total_rate = 0;
// Get the total rate (sum of the rate) // 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 if (it.second == 0) // Level removed on import
continue; continue;
total_rate += it.second; total_rate += it.second;
} }
if (total_rate > 0) { if (total_rate > 0) {
int chance = rnd_value( 1, total_rate ); int chance = rnd_value(1, total_rate);
int sum_rate = 0; int sum_rate = 0;
for ( const auto& it : upgrade->resultRefine ) { for (const auto& it : upgrade->resultRefine) {
if (it.second == 0) if (it.second == 0)
continue; continue;
sum_rate += it.second; sum_rate += it.second;
if (chance <= sum_rate) { if (chance <= sum_rate) {
item->refine = cap_value( it.first, 0, MAX_REFINE ); item->refine = cap_value(it.first, 0, MAX_REFINE);
break; break;
} }
} }

View File

@ -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"]; const auto& refineNode = node["ResultRefine"];
for (const auto& refineit : refineNode) { for (const auto& refineit : refineNode) {
@ -1802,16 +1802,17 @@ uint64 LaphineUpgradeDatabase::parseBodyNode( const ryml::NodeRef& node ){
if (!this->asUInt16Rate(refineit, "Level", level, MAX_REFINE)) if (!this->asUInt16Rate(refineit, "Level", level, MAX_REFINE))
return 0; 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; uint16 rate;
if (!this->asUInt16Rate( refineit, "Rate", rate )) { if (!this->asUInt16Rate(refineit, "Rate", rate)) {
return 0; return 0;
} }
entry->resultRefine[level] = rate; entry->resultRefine[level] = rate;
} else { }
else {
if (!refine_exists) { if (!refine_exists) {
entry->resultRefine[level] = 1; entry->resultRefine[level] = 1;
} }

View File

@ -522,17 +522,17 @@ static bool upgrade_item_group_db( std::string file, const uint32 source_version
return true; 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; size_t entries = 0;
for( auto input : inNode["Body"] ){ for (auto input : inNode["Body"]) {
if( source_version < 2 ){ if (source_version < 2) {
if( input["ResultRefine"].IsDefined() ){ if (input["ResultRefine"].IsDefined()) {
// Convert ResultRefine to a ResultRefine array // Convert ResultRefine to a ResultRefine array
uint16 refine_level = input["ResultRefine"].as<uint16>(); uint16 refine_level = input["ResultRefine"].as<uint16>();
// Remove the existing Refine entry // Remove the existing Refine entry
input.remove( "ResultRefine" ); input.remove("ResultRefine");
// Add the ResultRefine array // Add the ResultRefine array
auto RatesNode = input["ResultRefine"]; 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 // 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; uint16 refine_level_min = 0, refine_level_max = MAX_REFINE;
// Save data and remove the existing ResultRefineMinimum/ResultRefineMaximum entry // Save data and remove the existing ResultRefineMinimum/ResultRefineMaximum entry
if( input["ResultRefineMinimum"].IsDefined() ) { if (input["ResultRefineMinimum"].IsDefined()) {
refine_level_min = input["ResultRefineMinimum"].as<uint16>(); refine_level_min = input["ResultRefineMinimum"].as<uint16>();
input.remove( "ResultRefineMinimum" ); input.remove("ResultRefineMinimum");
} }
if( input["ResultRefineMaximum"].IsDefined() ) { if (input["ResultRefineMaximum"].IsDefined()) {
refine_level_max = input["ResultRefineMaximum"].as<uint16>(); refine_level_max = input["ResultRefineMaximum"].as<uint16>();
input.remove( "ResultRefineMaximum" ); input.remove("ResultRefineMaximum");
} }
// Remove existing ResultRefine entry (shouldn't happen) // Remove existing ResultRefine entry (shouldn't happen)
if( input["ResultRefine"].IsDefined() ) if (input["ResultRefine"].IsDefined())
input.remove( "ResultRefine" ); input.remove("ResultRefine");
// Add the ResultRefine array // Add the ResultRefine array
auto RatesNode = input["ResultRefine"]; 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]; auto RateNode = RatesNode[j];
RateNode["Level"] = i; RateNode["Level"] = i;
@ -574,7 +574,7 @@ static bool upgrade_laphine_upgrade( std::string file, const uint32 source_versi
entries++; 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; return true;
} }