|
@@ -10,6 +10,7 @@ static bool upgrade_item_db(std::string file, const uint32 source_version);
|
|
|
static bool upgrade_job_stats(std::string file, const uint32 source_version);
|
|
|
static bool upgrade_status_db(std::string file, const uint32 source_version);
|
|
|
static bool upgrade_map_drops_db(std::string file, const uint32 source_version);
|
|
|
+static bool upgrade_enchantgrade_db( std::string file, const uint32 source_version );
|
|
|
|
|
|
template<typename Func>
|
|
|
bool process(const std::string &type, uint32 version, const std::vector<std::string> &paths, const std::string &name, Func lambda) {
|
|
@@ -129,7 +130,7 @@ bool YamlUpgradeTool::initialize( int argc, char* argv[] ){
|
|
|
if (!process("STATUS_DB", 3, root_paths, "status", [](const std::string& path, const std::string& name_ext, uint32 source_version) -> bool {
|
|
|
return upgrade_status_db(path + name_ext, source_version);
|
|
|
})) {
|
|
|
- return 0;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
if (!process("MAP_DROP_DB", 2, root_paths, "map_drops", [](const std::string& path, const std::string& name_ext, uint32 source_version) -> bool {
|
|
@@ -138,6 +139,12 @@ bool YamlUpgradeTool::initialize( int argc, char* argv[] ){
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ if( !process( "ENCHANTGRADE_DB", 3, root_paths, "enchantgrade", []( const std::string& path, const std::string& name_ext, uint32 source_version ) -> bool {
|
|
|
+ return upgrade_enchantgrade_db( path + name_ext, source_version );
|
|
|
+ } ) ){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -366,6 +373,60 @@ static bool upgrade_map_drops_db(std::string file, const uint32 source_version)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+static bool upgrade_enchantgrade_db( std::string file, const uint32 source_version ){
|
|
|
+ size_t entries = 0;
|
|
|
+
|
|
|
+ for( auto input : inNode["Body"] ){
|
|
|
+ // If under version 3
|
|
|
+ if( source_version < 3 ){
|
|
|
+ if( input["Levels"].IsDefined() ){
|
|
|
+ for( auto levelNode : input["Levels"] ){
|
|
|
+ if( levelNode["Grades"].IsDefined() ){
|
|
|
+ for( auto gradeNode : levelNode["Grades"] ){
|
|
|
+ // Convert Refine + Chance to a Chances array
|
|
|
+ if( gradeNode["Refine"].IsDefined() && !gradeNode["Chance"].IsDefined() ){
|
|
|
+ ShowError( "Cannot upgrade automatically, because Refine is specified, but Chance is missing" );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if( gradeNode["Chance"].IsDefined() && !gradeNode["Refine"].IsDefined() ){
|
|
|
+ ShowError( "Cannot upgrade automatically, because Chance is specified, but Refine is missing" );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ uint16 refine = gradeNode["Refine"].as<uint16>();
|
|
|
+ uint16 chance = gradeNode["Chance"].as<uint16>();
|
|
|
+
|
|
|
+ auto chancesNode = gradeNode["Chances"];
|
|
|
+
|
|
|
+ for( int i = refine, j = 0; i <= MAX_REFINE; i++, j++ ){
|
|
|
+ auto chanceNode = chancesNode[j];
|
|
|
+
|
|
|
+ chanceNode["Refine"] = i;
|
|
|
+ chanceNode["Chance"] = chance;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Remove the existing Refine entry
|
|
|
+ gradeNode.remove( "Refine" );
|
|
|
+
|
|
|
+ // Remove the existing Chance entry
|
|
|
+ gradeNode.remove( "Chance" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ body << input;
|
|
|
+ entries++;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShowStatus( "Done converting/upgrading '" CL_WHITE "%zu" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str() );
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int main( int argc, char *argv[] ){
|
|
|
return main_core<YamlUpgradeTool>( argc, argv );
|
|
|
}
|