mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 07:03:40 +01:00
Merge pull request #1884 from GriffinRichards/mapjson-err
Fix mapjson misreporting errors when processing map_groups.json
This commit is contained in:
commit
1497719f8c
@ -75,6 +75,9 @@ string json_to_string(const Json &data, const string &field = "", bool silent =
|
|||||||
case Json::Type::BOOL:
|
case Json::Type::BOOL:
|
||||||
output = value.bool_value() ? "TRUE" : "FALSE";
|
output = value.bool_value() ? "TRUE" : "FALSE";
|
||||||
break;
|
break;
|
||||||
|
case Json::Type::NUL:
|
||||||
|
output = "";
|
||||||
|
break;
|
||||||
default:{
|
default:{
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field";
|
string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field";
|
||||||
@ -459,23 +462,24 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
|
|||||||
for (auto &group : groups_data["group_order"].array_items()) {
|
for (auto &group : groups_data["group_order"].array_items()) {
|
||||||
string groupName = json_to_string(group);
|
string groupName = json_to_string(group);
|
||||||
text << "// " << groupName << "\n";
|
text << "// " << groupName << "\n";
|
||||||
vector<Json> map_ids;
|
vector<string> map_ids;
|
||||||
size_t max_length = 0;
|
size_t max_length = 0;
|
||||||
|
|
||||||
for (auto &map_name : groups_data[groupName].array_items()) {
|
for (auto &map_name : groups_data[groupName].array_items()) {
|
||||||
string header_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json";
|
string map_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json";
|
||||||
string err_str;
|
string err_str;
|
||||||
Json map_data = Json::parse(read_text_file(header_filepath), err_str);
|
Json map_data = Json::parse(read_text_file(map_filepath), err_str);
|
||||||
map_ids.push_back(map_data["id"]);
|
if (map_data == Json())
|
||||||
string id = json_to_string(map_data, "id");
|
FATAL_ERROR("%s: %s\n", map_filepath.c_str(), err_str.c_str());
|
||||||
|
string id = json_to_string(map_data, "id", true);
|
||||||
|
map_ids.push_back(id);
|
||||||
if (id.length() > max_length)
|
if (id.length() > max_length)
|
||||||
max_length = id.length();
|
max_length = id.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
int map_id_num = 0;
|
int map_id_num = 0;
|
||||||
for (Json map_id : map_ids) {
|
for (string map_id : map_ids) {
|
||||||
string id = json_to_string(map_id);
|
text << "#define " << map_id << string((max_length - map_id.length() + 1), ' ')
|
||||||
text << "#define " << id << string((max_length - id.length() + 1), ' ')
|
|
||||||
<< "(" << map_id_num++ << " | (" << group_num << " << 8))\n";
|
<< "(" << map_id_num++ << " | (" << group_num << " << 8))\n";
|
||||||
}
|
}
|
||||||
text << "\n";
|
text << "\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user