Skip to content

Commit a8501de

Browse files
committed
ProcessJson: Move all flags in a single parameter
Make it possible to configure the "keys" output of "GetKeys"
1 parent 9cc7445 commit a8501de

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/game_interpreter.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5402,13 +5402,12 @@ bool Game_Interpreter::CommandEasyRpgProcessJson(lcf::rpg::EventCommand const& c
54025402
return true;
54035403
}
54045404

5405-
int extract_data_from_string = com.parameters[10];
5406-
bool pretty_print = com.parameters[11] == 1;
5405+
int flags = com.parameters[10];
5406+
bool pretty_print = (flags & 4) == 4;
54075407

5408-
if (extract_data_from_string == 1) { // as string
5408+
if ((flags & 1) == 1) { // parse command codes
54095409
json_path = Game_Strings::Extract(json_path, false);
5410-
}
5411-
if (extract_data_from_string == 2) { // as hex
5410+
} else if ((flags & 2) == 2) { // parse command codes, numbers as hex
54125411
json_path = Game_Strings::Extract(json_path, true);
54135412
}
54145413

@@ -5456,13 +5455,17 @@ bool Game_Interpreter::CommandEasyRpgProcessJson(lcf::rpg::EventCommand const& c
54565455
break;
54575456
}
54585457
case 3: { // GetKeys operation
5458+
bool create_keys_obj = (flags & 8) == 8;
54595459
auto keys = Json_Helper::GetKeys(*json_data, json_path);
54605460
std::string keys_str;
54615461
for (size_t i = 0; i < keys.size(); ++i) {
54625462
if (i > 0) keys_str += ",";
54635463
keys_str += "\"" + (keys)[i] + "\"";
54645464
}
5465-
std::string json_str = "{ \"keys\": [" + keys_str + "] }";
5465+
std::string json_str = "[" + keys_str + "]";
5466+
if (create_keys_obj) {
5467+
json_str = fmt::format(R"({ \"keys\": {} })", json_str);
5468+
}
54665469
set_var_value(target_var_type, target_var_id, json_str);
54675470
break;
54685471
}

0 commit comments

Comments
 (0)