make --restrict-room floor-specific

This commit is contained in:
Martin Michelsen
2026-02-15 10:50:16 -08:00
parent 1e459edfc4
commit 68b495b4b4
+17 -6
View File
@@ -3191,8 +3191,8 @@ Action a_optimize_materialized_map(
and parameters). Event count always takes precedence; that is, a map\n\ and parameters). Event count always takes precedence; that is, a map\n\
with fewer events is always considered better than any map with more\n\ with fewer events is always considered better than any map with more\n\
events, regardless of the enemy counts.\n\ events, regardless of the enemy counts.\n\
--restrict-room=ROOM-ID: Ignore all enemies outside of this room (may be\n\ --restrict-room=FLOOR:ROOM-ID: Ignore all enemies outside of this room\n\
given multiple times).\n\ (may be given multiple times).\n\
--threads=NUM-THREADS: Limits parallelism; by default, uses one thread\n\ --threads=NUM-THREADS: Limits parallelism; by default, uses one thread\n\
per CPU core.\n\ per CPU core.\n\
--debug: Enables debug logging.\n\ --debug: Enables debug logging.\n\
@@ -3214,12 +3214,20 @@ Action a_optimize_materialized_map(
minimize_types.emplace(std::stoul(arg, nullptr, 0), std::make_pair(0xFF, 0)); minimize_types.emplace(std::stoul(arg, nullptr, 0), std::make_pair(0xFF, 0));
} else if (tokens.size() == 3) { } else if (tokens.size() == 3) {
minimize_types.emplace(std::stoul(tokens[0], nullptr, 0), std::make_pair(std::stoul(tokens[1], nullptr, 0), std::stoul(tokens[2], nullptr, 0))); minimize_types.emplace(std::stoul(tokens[0], nullptr, 0), std::make_pair(std::stoul(tokens[1], nullptr, 0), std::stoul(tokens[2], nullptr, 0)));
} else {
throw std::runtime_error("invalid vlaue for --minimize");
} }
} }
std::unordered_set<uint16_t> room_ids; std::unordered_set<uint32_t> floor_room_ids; // (floor << 16) | room_id
for (const auto& arg : args.get_multi<std::string>("restrict-room")) { for (const auto& arg : args.get_multi<std::string>("restrict-room")) {
room_ids.emplace(std::stoul(arg, nullptr, 0)); auto tokens = phosg::split(arg, ':');
if (tokens.size() != 2) {
throw std::runtime_error("invalid vlaue for --restrict-room");
}
uint8_t floor = std::stoul(tokens[0], nullptr, 0);
uint16_t room_id = std::stoul(tokens[1], nullptr, 0);
floor_room_ids.emplace((floor << 16) | room_id);
} }
size_t num_threads = args.get<size_t>("threads", 0); size_t num_threads = args.get<size_t>("threads", 0);
@@ -3230,8 +3238,11 @@ Action a_optimize_materialized_map(
auto materialized = map_file->materialize_random_sections(seed); auto materialized = map_file->materialize_random_sections(seed);
auto is_minimize_target = [&](const MapFile::EnemySetEntry& ene) -> bool { auto is_minimize_target = [&](const MapFile::EnemySetEntry& ene) -> bool {
if (!room_ids.empty() && !room_ids.count(ene.room)) { if (!floor_room_ids.empty()) {
return false; uint32_t floor_room_id_key = (ene.floor << 8) | ene.room;
if (!floor_room_ids.count(floor_room_id_key)) {
return false;
}
} }
if (minimize_types.empty()) { if (minimize_types.empty()) {
return true; return true;