add check for invalid defensive item type

This commit is contained in:
Martin Michelsen
2026-05-04 10:30:48 -07:00
parent d384cf4f11
commit b8e7d81a22
2 changed files with 7 additions and 4 deletions
+2 -1
View File
@@ -940,10 +940,11 @@ public:
case 3:
return this->unit_sale_divisor;
}
throw runtime_error("invalid defensive item type");
case 2:
return this->mag_sale_divisor;
default:
throw logic_error("item type does not have a sale divisor");
throw runtime_error("item type does not have a sale divisor");
}
}
+5 -3
View File
@@ -2393,9 +2393,11 @@ Action a_convert_item_parameter_table(
auto data = std::make_shared<string>(read_input_data(args));
auto pmt = ItemParameterTable::from_binary(data, get_cli_version(args, Version::BB_V4));
auto json = pmt->json();
uint32_t hex_option = args.get<bool>("hex") ? phosg::JSON::SerializeOption::HEX_INTEGERS : 0;
string json_data = json.serialize(
phosg::JSON::SerializeOption::FORMAT | hex_option | phosg::JSON::SerializeOption::SORT_DICT_KEYS);
uint32_t serialize_options = phosg::JSON::SerializeOption::FORMAT | phosg::JSON::SerializeOption::SORT_DICT_KEYS;
if (args.get<bool>("hex")) {
serialize_options |= phosg::JSON::SerializeOption::HEX_INTEGERS;
}
string json_data = json.serialize(serialize_options);
write_output_data(args, json_data.data(), json_data.size(), nullptr);
});