Updated format
This commit is contained in:
parent
c8729f5bd6
commit
1a572258f4
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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<uint16>();
|
||||
|
||||
// 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<uint16>();
|
||||
input.remove( "ResultRefineMinimum" );
|
||||
input.remove("ResultRefineMinimum");
|
||||
}
|
||||
if( input["ResultRefineMaximum"].IsDefined() ) {
|
||||
if (input["ResultRefineMaximum"].IsDefined()) {
|
||||
refine_level_max = input["ResultRefineMaximum"].as<uint16>();
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user