Extended item_group_db.yml (#6173)
* Added Index field The structure now allows to define the same item with different data * Updated the tool yamlupgrade for version upgrade
This commit is contained in:
@@ -11,6 +11,7 @@ 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 );
|
||||
static bool upgrade_item_group_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) {
|
||||
@@ -144,6 +145,11 @@ bool YamlUpgradeTool::initialize( int argc, char* argv[] ){
|
||||
} ) ){
|
||||
return false;
|
||||
}
|
||||
if( !process( "ITEM_GROUP_DB", 3, root_paths, "item_group_db", []( const std::string& path, const std::string& name_ext, uint32 source_version ) -> bool {
|
||||
return upgrade_item_group_db( path + name_ext, source_version );
|
||||
} ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -426,6 +432,90 @@ static bool upgrade_enchantgrade_db( std::string file, const uint32 source_versi
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool upgrade_item_group_db( std::string file, const uint32 source_version ){
|
||||
size_t entries = 0;
|
||||
|
||||
for( const auto input : inNode["Body"] ){
|
||||
// If under version 3
|
||||
if( source_version < 3 ){
|
||||
body << YAML::BeginMap;
|
||||
body << YAML::Key << "Group" << YAML::Value << input["Group"];
|
||||
|
||||
if( input["SubGroups"].IsDefined() ){
|
||||
body << YAML::Key << "SubGroups";
|
||||
body << YAML::BeginSeq;
|
||||
|
||||
for (const auto &it : input["SubGroups"]) {
|
||||
body << YAML::BeginMap;
|
||||
if( it["SubGroup"].IsDefined() ){
|
||||
body << YAML::Key << "SubGroup" << YAML::Value << it["SubGroup"];
|
||||
}
|
||||
|
||||
if( it["List"].IsDefined() )
|
||||
body << YAML::Key << "List";{
|
||||
body << YAML::BeginSeq;
|
||||
|
||||
uint32 index = 0;
|
||||
|
||||
for( auto ListNode : it["List"] ){
|
||||
if( !ListNode["Item"].IsDefined() ){
|
||||
ShowError( "Cannot upgrade automatically, Item is missing" );
|
||||
return false;
|
||||
}
|
||||
body << YAML::BeginMap;
|
||||
|
||||
body << YAML::Key << "Index" << YAML::Value << index;
|
||||
body << YAML::Key << "Item" << YAML::Value << ListNode["Item"];
|
||||
|
||||
if( ListNode["Rate"].IsDefined() )
|
||||
body << YAML::Key << "Rate" << YAML::Value << ListNode["Rate"];
|
||||
if( ListNode["Amount"].IsDefined() )
|
||||
body << YAML::Key << "Amount" << YAML::Value << ListNode["Amount"];
|
||||
if( ListNode["Duration"].IsDefined() )
|
||||
body << YAML::Key << "Duration" << YAML::Value << ListNode["Duration"];
|
||||
if( ListNode["Announced"].IsDefined() )
|
||||
body << YAML::Key << "Announced" << YAML::Value << ListNode["Announced"];
|
||||
if( ListNode["UniqueId"].IsDefined() )
|
||||
body << YAML::Key << "UniqueId" << YAML::Value << ListNode["UniqueId"];
|
||||
if( ListNode["Stacked"].IsDefined() )
|
||||
body << YAML::Key << "Stacked" << YAML::Value << ListNode["Stacked"];
|
||||
if( ListNode["Named"].IsDefined() )
|
||||
body << YAML::Key << "Named" << YAML::Value << ListNode["Named"];
|
||||
if( ListNode["Bound"].IsDefined() )
|
||||
body << YAML::Key << "Bound" << YAML::Value << ListNode["Bound"];
|
||||
if( ListNode["RandomOptionGroup"].IsDefined() )
|
||||
body << YAML::Key << "RandomOptionGroup" << YAML::Value << ListNode["RandomOptionGroup"];
|
||||
if( ListNode["RefineMinimum"].IsDefined() )
|
||||
body << YAML::Key << "RefineMinimum" << YAML::Value << ListNode["RefineMinimum"];
|
||||
if( ListNode["RefineMaximum"].IsDefined() )
|
||||
body << YAML::Key << "RefineMaximum" << YAML::Value << ListNode["RefineMaximum"];
|
||||
if( ListNode["Clear"].IsDefined() )
|
||||
body << YAML::Key << "Clear" << YAML::Value << ListNode["Clear"];
|
||||
|
||||
index++;
|
||||
body << YAML::EndMap;
|
||||
}
|
||||
|
||||
body << YAML::EndSeq;
|
||||
}
|
||||
if( it["Clear"].IsDefined() )
|
||||
body << YAML::Key << "Clear" << YAML::Value << it["Clear"];
|
||||
|
||||
body << YAML::EndMap;
|
||||
}
|
||||
body << YAML::EndSeq;
|
||||
}
|
||||
body << YAML::EndMap;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
Reference in New Issue
Block a user