Converted Improvised Song Database to YAML (#4481)

* Split database into pre-renewal and renewal.
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Aleos
2019-12-19 18:06:37 -05:00
committed by GitHub
parent beec1c2766
commit 77045ef287
9 changed files with 250 additions and 74 deletions

View File

@@ -71,6 +71,7 @@ static bool guild_read_guildskill_tree_db( char* split[], int columns, int curre
static size_t pet_read_db( const char* file );
static bool skill_parse_row_magicmushroomdb(char* split[], int column, int current);
static bool skill_parse_row_abradb(char* split[], int columns, int current);
static bool skill_parse_row_improvisedb(char* split[], int columns, int current);
// Constants for conversion
std::unordered_map<uint16, std::string> aegis_itemnames;
@@ -155,11 +156,11 @@ void finalizeBody(void) {
}
template<typename Func>
bool process( const std::string& type, uint32 version, const std::vector<std::string>& paths, const std::string& name, Func lambda ){
bool process( const std::string& type, uint32 version, const std::vector<std::string>& paths, const std::string& name, Func lambda, const std::string& rename = "" ){
for( const std::string& path : paths ){
const std::string name_ext = name + ".txt";
const std::string from = path + "/" + name_ext;
const std::string to = path + "/" + name + ".yml";
const std::string to = path + "/" + (rename.size() > 0 ? rename : name) + ".yml";
if( fileExists( from ) ){
if( !askConfirmation( "Found the file \"%s\", which requires migration to yml.\nDo you want to convert it now? (Y/N)\n", from.c_str() ) ){
@@ -181,7 +182,7 @@ bool process( const std::string& type, uint32 version, const std::vector<std::st
return false;
}
prepareHeader(out, type, version, name);
prepareHeader(out, type, version, (rename.size() > 0 ? rename : name));
prepareBody();
if( !lambda( path, name_ext ) ){
@@ -195,7 +196,7 @@ bool process( const std::string& type, uint32 version, const std::vector<std::st
out << "\n";
out.close();
// TODO: do you want to delete/rename?
// TODO: do you want to delete?
}
}
@@ -248,6 +249,12 @@ int do_init( int argc, char** argv ){
return 0;
}
if (!process("IMPROVISED_SONG_DB", 1, root_paths, "skill_improvise_db", [](const std::string& path, const std::string& name_ext) -> bool {
return sv_readdb(path.c_str(), name_ext.c_str(), ',', 2, 2, -1, &skill_parse_row_improvisedb, false);
}, "improvise_db")) {
return 0;
}
// TODO: add implementations ;-)
return 0;
@@ -714,7 +721,7 @@ static bool skill_parse_row_abradb(char* split[], int columns, int current)
std::string *skill_name = util::umap_find(aegis_skillnames, skill_id);
if (skill_name == nullptr) {
ShowError("Skill name for Abra skill ID &hu is not known.\n", skill_id);
ShowError("Skill name for Abra skill ID %hu is not known.\n", skill_id);
return false;
}
@@ -746,3 +753,21 @@ static bool skill_parse_row_abradb(char* split[], int columns, int current)
return true;
}
static bool skill_parse_row_improvisedb(char* split[], int columns, int current)
{
uint16 skill_id = atoi(split[0]);
std::string *skill_name = util::umap_find(aegis_skillnames, skill_id);
if (skill_name == nullptr) {
ShowError("Skill name for Improvised Song skill ID %hu is not known.\n", skill_id);
return false;
}
body << YAML::BeginMap;
body << YAML::Key << "Skill" << YAML::Value << *skill_name;
body << YAML::Key << "Probability" << YAML::Value << atoi(split[1]) / 10;
body << YAML::EndMap;
return true;
}