Fixed SQL db loading (#6843)

This commit is contained in:
Lemongrass3110 2022-04-17 22:31:57 +02:00 committed by GitHub
parent 1a7a26bc39
commit aae930198d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 20 deletions

View File

@ -2913,8 +2913,37 @@ static bool itemdb_read_sqldb_sub(std::vector<std::string> str) {
jobs["Summoner"] << (std::stoi(str[index]) ? "true" : "false"); jobs["Summoner"] << (std::stoi(str[index]) ? "true" : "false");
#endif #endif
rootNode["Classes"] = classes; if( !jobs.has_children() ){
rootNode["Jobs"] = jobs; rootNode.remove_child( jobs );
}
if( !classes.has_children() ){
rootNode.remove_child( classes );
}
if( !locations.has_children() ){
rootNode.remove_child( locations );
}
if( !flags.has_children() ){
rootNode.remove_child( flags );
}
if( !delay.has_children() ){
rootNode.remove_child( delay );
}
if( !stack.has_children() ){
rootNode.remove_child( stack );
}
if( !nouse.has_children() ){
rootNode.remove_child( nouse );
}
if( !trade.has_children() ){
rootNode.remove_child( trade );
}
return item_db.parseBodyNode(rootNode) > 0; return item_db.parseBodyNode(rootNode) > 0;
} }

View File

@ -5018,15 +5018,10 @@ static bool mob_read_sqldb_sub(std::vector<std::string> str) {
node["Race"] << str[index]; node["Race"] << str[index];
ryml::NodeRef raceGroupsNode = node["RaceGroups"]; ryml::NodeRef raceGroupsNode = node["RaceGroups"];
bool groupheader = false; raceGroupsNode |= ryml::MAP;
for (uint16 i = 1; i < RC2_MAX; i++) { for (uint16 i = 1; i < RC2_MAX; i++) {
if (!str[i + index].empty()) { if (!str[i + index].empty()) {
if (!groupheader) {
raceGroupsNode |= ryml::MAP;
groupheader = true;
}
raceGroupsNode[c4::to_csubstr(script_get_constant_str("RC2_", i) + 4)] << (std::stoi(str[i + index]) ? "true" : "false"); raceGroupsNode[c4::to_csubstr(script_get_constant_str("RC2_", i) + 4)] << (std::stoi(str[i + index]) ? "true" : "false");
} }
} }
@ -5109,14 +5104,9 @@ static bool mob_read_sqldb_sub(std::vector<std::string> str) {
modes["SkillImmune"] << (std::stoi(str[index]) ? "true" : "false"); modes["SkillImmune"] << (std::stoi(str[index]) ? "true" : "false");
ryml::NodeRef mvpDropsNode = node["MvpDrops"]; ryml::NodeRef mvpDropsNode = node["MvpDrops"];
bool mvpheader = false; mvpDropsNode |= ryml::SEQ;
for (uint8 i = 0; i < MAX_MVP_DROP; i++) { for (uint8 i = 0; i < MAX_MVP_DROP; i++) {
if (!mvpheader) {
mvpDropsNode |= ryml::SEQ;
mvpheader = true;
}
if (!str[++index].empty()) { if (!str[++index].empty()) {
ryml::NodeRef entry = mvpDropsNode[i]; ryml::NodeRef entry = mvpDropsNode[i];
entry |= ryml::MAP; entry |= ryml::MAP;
@ -5133,14 +5123,9 @@ static bool mob_read_sqldb_sub(std::vector<std::string> str) {
} }
ryml::NodeRef dropsNode = node["Drops"]; ryml::NodeRef dropsNode = node["Drops"];
bool dropheader = false; dropsNode |= ryml::SEQ;
for (uint8 i = 0; i < MAX_MOB_DROP; i++) { for (uint8 i = 0; i < MAX_MOB_DROP; i++) {
if (!dropheader) {
dropsNode |= ryml::SEQ;
dropheader = true;
}
if (!str[++index].empty()) { if (!str[++index].empty()) {
ryml::NodeRef entry = dropsNode[i]; ryml::NodeRef entry = dropsNode[i];
entry |= ryml::MAP; entry |= ryml::MAP;
@ -5165,6 +5150,18 @@ static bool mob_read_sqldb_sub(std::vector<std::string> str) {
node["MagicResistance"] << std::stoi(str[index]); node["MagicResistance"] << std::stoi(str[index]);
#endif #endif
if( !modes.has_children() ){
node.remove_child( modes );
}
if( !mvpDropsNode.has_children() ){
node.remove_child( mvpDropsNode );
}
if( !dropsNode.has_children() ){
node.remove_child( dropsNode );
}
return mob_db.parseBodyNode(node) > 0; return mob_db.parseBodyNode(node) > 0;
} }