mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Fix mapjson misreporting errors when processing map_groups.json
This commit is contained in:
parent
8d67bebd51
commit
8e5347b450
@ -75,6 +75,9 @@ string json_to_string(const Json &data, const string &field = "", bool silent =
|
||||
case Json::Type::BOOL:
|
||||
output = value.bool_value() ? "TRUE" : "FALSE";
|
||||
break;
|
||||
case Json::Type::NUL:
|
||||
output = "";
|
||||
break;
|
||||
default:{
|
||||
if (!silent) {
|
||||
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()) {
|
||||
string groupName = json_to_string(group);
|
||||
text << "// " << groupName << "\n";
|
||||
vector<Json> map_ids;
|
||||
vector<string> map_ids;
|
||||
size_t max_length = 0;
|
||||
|
||||
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;
|
||||
Json map_data = Json::parse(read_text_file(header_filepath), err_str);
|
||||
map_ids.push_back(map_data["id"]);
|
||||
string id = json_to_string(map_data, "id");
|
||||
Json map_data = Json::parse(read_text_file(map_filepath), err_str);
|
||||
if (map_data == Json())
|
||||
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)
|
||||
max_length = id.length();
|
||||
}
|
||||
|
||||
int map_id_num = 0;
|
||||
for (Json map_id : map_ids) {
|
||||
string id = json_to_string(map_id);
|
||||
text << "#define " << id << string((max_length - id.length() + 1), ' ')
|
||||
for (string map_id : map_ids) {
|
||||
text << "#define " << map_id << string((max_length - map_id.length() + 1), ' ')
|
||||
<< "(" << map_id_num++ << " | (" << group_num << " << 8))\n";
|
||||
}
|
||||
text << "\n";
|
||||
|
Loading…
Reference in New Issue
Block a user