From 93eaf3207eea73c89a3d5047965d43b1bd6ea9ee Mon Sep 17 00:00:00 2001 From: Aleos Date: Wed, 28 Oct 2020 12:45:52 -0400 Subject: [PATCH] Resolves SQL header output on suffix files (#5497) * Resolves an issue where the wrong header was being printed to the SQL files that contain a suffix to them. Thanks to @Atemo! --- doc/yaml/sql/item_db_equip.sql | 3 +++ doc/yaml/sql/item_db_etc.sql | 3 +++ doc/yaml/sql/item_db_re_equip.sql | 3 +++ doc/yaml/sql/item_db_re_etc.sql | 3 +++ doc/yaml/sql/item_db_re_usable.sql | 3 +++ doc/yaml/sql/item_db_usable.sql | 3 +++ src/tool/yaml2sql.cpp | 9 +++++---- 7 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 doc/yaml/sql/item_db_equip.sql create mode 100644 doc/yaml/sql/item_db_etc.sql create mode 100644 doc/yaml/sql/item_db_re_equip.sql create mode 100644 doc/yaml/sql/item_db_re_etc.sql create mode 100644 doc/yaml/sql/item_db_re_usable.sql create mode 100644 doc/yaml/sql/item_db_usable.sql diff --git a/doc/yaml/sql/item_db_equip.sql b/doc/yaml/sql/item_db_equip.sql new file mode 100644 index 0000000000..9f02662b66 --- /dev/null +++ b/doc/yaml/sql/item_db_equip.sql @@ -0,0 +1,3 @@ +# +# Table data for table `item_db` +# diff --git a/doc/yaml/sql/item_db_etc.sql b/doc/yaml/sql/item_db_etc.sql new file mode 100644 index 0000000000..9f02662b66 --- /dev/null +++ b/doc/yaml/sql/item_db_etc.sql @@ -0,0 +1,3 @@ +# +# Table data for table `item_db` +# diff --git a/doc/yaml/sql/item_db_re_equip.sql b/doc/yaml/sql/item_db_re_equip.sql new file mode 100644 index 0000000000..c5916d98e5 --- /dev/null +++ b/doc/yaml/sql/item_db_re_equip.sql @@ -0,0 +1,3 @@ +# +# Table data for table `item_db_re` +# diff --git a/doc/yaml/sql/item_db_re_etc.sql b/doc/yaml/sql/item_db_re_etc.sql new file mode 100644 index 0000000000..c5916d98e5 --- /dev/null +++ b/doc/yaml/sql/item_db_re_etc.sql @@ -0,0 +1,3 @@ +# +# Table data for table `item_db_re` +# diff --git a/doc/yaml/sql/item_db_re_usable.sql b/doc/yaml/sql/item_db_re_usable.sql new file mode 100644 index 0000000000..c5916d98e5 --- /dev/null +++ b/doc/yaml/sql/item_db_re_usable.sql @@ -0,0 +1,3 @@ +# +# Table data for table `item_db_re` +# diff --git a/doc/yaml/sql/item_db_usable.sql b/doc/yaml/sql/item_db_usable.sql new file mode 100644 index 0000000000..9f02662b66 --- /dev/null +++ b/doc/yaml/sql/item_db_usable.sql @@ -0,0 +1,3 @@ +# +# Table data for table `item_db` +# diff --git a/src/tool/yaml2sql.cpp b/src/tool/yaml2sql.cpp index 62686cd258..3a2440a513 100644 --- a/src/tool/yaml2sql.cpp +++ b/src/tool/yaml2sql.cpp @@ -78,10 +78,11 @@ void prepareHeader(std::ofstream &file, const std::string& name) { } template -bool process( const std::string& type, uint32 version, const std::vector& paths, const std::string& name, const std::string& to, const std::string& table, Func lambda ){ +bool process( const std::string& type, uint32 version, const std::vector& paths, const std::string& name, const std::string& to_table, const std::string& table, Func lambda ){ for( const std::string& path : paths ){ const std::string name_ext = name + ".yml"; const std::string from = path + name_ext; + const std::string to = "sql-files/" + to_table + ".sql"; if( fileExists( from ) ){ if( !askConfirmation( "Found the file \"%s\", which can be converted to sql.\nDo you want to convert it now? (Y/N)\n", from.c_str() ) ){ @@ -114,7 +115,7 @@ bool process( const std::string& type, uint32 version, const std::vector bool { + if (!process("ITEM_DB", 1, { path_db_mode }, "item_db_" + suffix, item_table_name + "_" + suffix, item_table_name, [](const std::string& path, const std::string& name_ext, const std::string& table) -> bool { return item_db_yaml2sql(path + name_ext, table); })) { return 0; } } - if (!process("ITEM_DB", 1, { path_db_import }, "item_db", "sql-files/" + item_import_table_name + ".sql", item_import_table_name, [](const std::string& path, const std::string& name_ext, const std::string& table) -> bool { + if (!process("ITEM_DB", 1, { path_db_import }, "item_db", item_import_table_name, item_import_table_name, [](const std::string& path, const std::string& name_ext, const std::string& table) -> bool { return item_db_yaml2sql(path + name_ext, table); })) { return 0;