diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index 865fbd6d8..7ad7bf3e1 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -32,6 +32,7 @@ EQEmuLogSys Log; void ExportSpells(SharedDatabase *db); void ExportSkillCaps(SharedDatabase *db); void ExportBaseData(SharedDatabase *db); +void ExportDBStrings(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientExport); @@ -62,6 +63,7 @@ int main(int argc, char **argv) { ExportSpells(&database); ExportSkillCaps(&database); ExportBaseData(&database); + ExportDBStrings(&database); Log.CloseFileLogs(); @@ -200,3 +202,37 @@ void ExportBaseData(SharedDatabase *db) { fclose(f); } +void ExportDBStrings(SharedDatabase *db) { + Log.Out(Logs::General, Logs::Status, "Exporting DB Strings..."); + + FILE *f = fopen("export/dbstr_us.txt", "w"); + if(!f) { + Log.Out(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping."); + return; + } + + fprintf(f, "Major^Minor^String(New)\n"); + const std::string query = "SELECT * FROM db_str ORDER BY id, type"; + auto results = db->QueryDatabase(query); + if(results.Success()) { + for(auto row = results.begin(); row != results.end(); ++row) { + std::string line; + unsigned int fields = results.ColumnCount(); + for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) { + if(rowIndex != 0) + line.push_back('^'); + + if(row[rowIndex] != nullptr) { + line += row[rowIndex]; + } + } + + fprintf(f, "%s\n", line.c_str()); + } + } + else { + } + + fclose(f); +} + diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 3a2f4154f..72ae6fd5d 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -30,6 +30,7 @@ EQEmuLogSys Log; void ImportSpells(SharedDatabase *db); void ImportSkillCaps(SharedDatabase *db); void ImportBaseData(SharedDatabase *db); +void ImportDBStrings(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientImport); @@ -59,6 +60,7 @@ int main(int argc, char **argv) { ImportSpells(&database); ImportSkillCaps(&database); ImportBaseData(&database); + ImportDBStrings(&database); Log.CloseFileLogs(); @@ -202,7 +204,6 @@ void ImportSkillCaps(SharedDatabase *db) { continue; } - int class_id, skill_id, level, cap; class_id = atoi(split[0].c_str()); skill_id = atoi(split[1].c_str()); @@ -262,3 +263,56 @@ void ImportBaseData(SharedDatabase *db) { fclose(f); } + +void ImportDBStrings(SharedDatabase *db) { + Log.Out(Logs::General, Logs::Status, "Importing DB Strings..."); + + FILE *f = fopen("import/dbstr_us.txt", "r"); + if(!f) { + Log.Out(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping."); + return; + } + + std::string delete_sql = "DELETE FROM db_str"; + db->QueryDatabase(delete_sql); + + char buffer[2048]; + bool first = true; + while(fgets(buffer, 2048, f)) { + if(first) { + first = false; + continue; + } + + for(int i = 0; i < 2048; ++i) { + if(buffer[i] == '\n') { + buffer[i] = 0; + break; + } + } + + auto split = SplitString(buffer, '^'); + + if(split.size() < 2) { + continue; + } + + std::string sql; + int id, type; + std::string value; + + id = atoi(split[0].c_str()); + type = atoi(split[1].c_str()); + + if(split.size() >= 3) { + value = ::EscapeString(split[2]); + } + + sql = StringFormat("INSERT INTO db_str(id, type, value) VALUES(%u, %u, '%s')", + id, type, value.c_str()); + + db->QueryDatabase(sql); + } + + fclose(f); +} diff --git a/utils/sql/git/required/2015_05_23_dbstr_us.sql b/utils/sql/git/required/2015_05_23_dbstr_us.sql new file mode 100644 index 000000000..d4e789b83 --- /dev/null +++ b/utils/sql/git/required/2015_05_23_dbstr_us.sql @@ -0,0 +1,6 @@ +CREATE TABLE `db_str` ( + `id` INT(10) NOT NULL, + `type` INT(10) NOT NULL, + `value` TEXT NOT NULL, + PRIMARY KEY (`id`, `type`) +);;