fix area_norm for Episode 4

This commit is contained in:
Martin Michelsen
2023-11-07 22:51:44 -08:00
parent c9a61afa62
commit 7d0438f149
+6 -4
View File
@@ -60,7 +60,7 @@ uint8_t ItemCreator::normalize_area_number(uint8_t area) const {
if (!this->restrictions || (this->restrictions->box_drop_area == 0) || (area < 0x10) || (area > 0x11)) { if (!this->restrictions || (this->restrictions->box_drop_area == 0) || (area < 0x10) || (area > 0x11)) {
switch (this->episode) { switch (this->episode) {
case Episode::EP1: case Episode::EP1:
if (area >= 15) { if (area >= 0x0F) {
throw runtime_error("invalid Episode 1 area number"); throw runtime_error("invalid Episode 1 area number");
} }
switch (area) { switch (area) {
@@ -102,7 +102,9 @@ uint8_t ItemCreator::normalize_area_number(uint8_t area) const {
return area; return area;
} }
case Episode::EP4: case Episode::EP4:
// TODO: Figure out remaps for Episode 4 (if there are any) if (area >= 0x24 && area < 0x2D) {
return area - 0x22;
}
return area; return area;
default: default:
throw logic_error("invalid episode number"); throw logic_error("invalid episode number");
@@ -115,13 +117,13 @@ uint8_t ItemCreator::normalize_area_number(uint8_t area) const {
ItemData ItemCreator::on_box_item_drop(uint16_t entity_id, uint8_t area) { ItemData ItemCreator::on_box_item_drop(uint16_t entity_id, uint8_t area) {
return this->destroyed_boxes.emplace(entity_id).second return this->destroyed_boxes.emplace(entity_id).second
? this->on_box_item_drop_with_norm_area(normalize_area_number(area) - 1) ? this->on_box_item_drop_with_norm_area(this->normalize_area_number(area) - 1)
: ItemData(); : ItemData();
} }
ItemData ItemCreator::on_monster_item_drop(uint16_t entity_id, uint32_t enemy_type, uint8_t area) { ItemData ItemCreator::on_monster_item_drop(uint16_t entity_id, uint32_t enemy_type, uint8_t area) {
return this->destroyed_monsters.emplace(entity_id).second return this->destroyed_monsters.emplace(entity_id).second
? this->on_monster_item_drop_with_norm_area(enemy_type, normalize_area_number(area) - 1) ? this->on_monster_item_drop_with_norm_area(enemy_type, this->normalize_area_number(area) - 1)
: ItemData(); : ItemData();
} }