fix invalid tool class on v3/v4
This commit is contained in:
+19
-8
@@ -632,8 +632,26 @@ void ItemCreator::generate_common_tool_variances(uint32_t area_norm, ItemData& i
|
|||||||
if (this->is_v3() && (tool_class == 0x1A)) {
|
if (this->is_v3() && (tool_class == 0x1A)) {
|
||||||
tool_class = 0x73;
|
tool_class = 0x73;
|
||||||
}
|
}
|
||||||
|
this->log.info("Generating tool with class %02hhX", tool_class);
|
||||||
|
|
||||||
|
// Note: This block was originally a separate function called
|
||||||
|
// generate_common_tool_type
|
||||||
|
{
|
||||||
|
// It appears that when Sega deleted Hit Material in v3, they never deleted
|
||||||
|
// it from the ItemPT entries, so sometimes ItemCreator tries to generate
|
||||||
|
// it. The original implementation just generates no item when that happens,
|
||||||
|
// so we do the same here.
|
||||||
|
try {
|
||||||
|
auto data = this->item_parameter_table->find_tool_by_id(tool_class);
|
||||||
|
item.data1[0] = 0x03;
|
||||||
|
item.data1[1] = data.first;
|
||||||
|
item.data1[2] = data.second;
|
||||||
|
} catch (const out_of_range&) {
|
||||||
|
this->log.info("Tool class is missing; skipping item generation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->generate_common_tool_type(tool_class, item);
|
|
||||||
if (item.data1[1] == 0x02) { // Tech disk
|
if (item.data1[1] == 0x02) { // Tech disk
|
||||||
item.data1[4] = this->get_rand_from_weighted_tables_2d_vertical(this->pt->technique_index_prob_table(), area_norm);
|
item.data1[4] = this->get_rand_from_weighted_tables_2d_vertical(this->pt->technique_index_prob_table(), area_norm);
|
||||||
item.data1[2] = this->generate_tech_disk_level(item.data1[4], area_norm);
|
item.data1[2] = this->generate_tech_disk_level(item.data1[4], area_norm);
|
||||||
@@ -652,13 +670,6 @@ uint8_t ItemCreator::generate_tech_disk_level(uint32_t tech_num, uint32_t area_n
|
|||||||
return range.min;
|
return range.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemCreator::generate_common_tool_type(uint8_t id, ItemData& item) const {
|
|
||||||
auto data = this->item_parameter_table->find_tool_by_id(id);
|
|
||||||
item.data1[0] = 0x03;
|
|
||||||
item.data1[1] = data.first;
|
|
||||||
item.data1[2] = data.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemCreator::generate_common_mag_variances(ItemData& item) const {
|
void ItemCreator::generate_common_mag_variances(ItemData& item) const {
|
||||||
if (item.data1[0] == 0x02) {
|
if (item.data1[0] == 0x02) {
|
||||||
item.data1[1] = 0x00;
|
item.data1[1] = 0x00;
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ private:
|
|||||||
void generate_common_armor_or_shield_type_and_variances(char area_norm, ItemData& item);
|
void generate_common_armor_or_shield_type_and_variances(char area_norm, ItemData& item);
|
||||||
void generate_common_tool_variances(uint32_t area_norm, ItemData& item);
|
void generate_common_tool_variances(uint32_t area_norm, ItemData& item);
|
||||||
uint8_t generate_tech_disk_level(uint32_t tech_num, uint32_t area_norm);
|
uint8_t generate_tech_disk_level(uint32_t tech_num, uint32_t area_norm);
|
||||||
void generate_common_tool_type(uint8_t tool_class, ItemData& item) const;
|
|
||||||
void generate_common_mag_variances(ItemData& item) const;
|
void generate_common_mag_variances(ItemData& item) const;
|
||||||
void generate_common_weapon_variances(uint8_t area_norm, ItemData& item);
|
void generate_common_weapon_variances(uint8_t area_norm, ItemData& item);
|
||||||
void generate_common_weapon_grind(ItemData& item, uint8_t offset_within_subtype_range);
|
void generate_common_weapon_grind(ItemData& item, uint8_t offset_within_subtype_range);
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ pair<uint8_t, uint8_t> ItemParameterTable::find_tool_by_id_t(uint32_t tool_table
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw runtime_error(string_printf("invalid tool class %08" PRIX32, item_id));
|
throw out_of_range(string_printf("invalid tool class %08" PRIX32, item_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<uint8_t, uint8_t> ItemParameterTable::find_tool_by_id(uint32_t item_id) const {
|
pair<uint8_t, uint8_t> ItemParameterTable::find_tool_by_id(uint32_t item_id) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user