From 1e459edfc450966191f4cece97b1cdae6f3f9ac6 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 15 Feb 2026 08:31:30 -0800 Subject: [PATCH] add --restrict-room in random enemy optimizer --- src/Main.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Main.cc b/src/Main.cc index 6aef6780..b26c3066 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -3191,6 +3191,8 @@ Action a_optimize_materialized_map( 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\ events, regardless of the enemy counts.\n\ + --restrict-room=ROOM-ID: Ignore all enemies outside of this room (may be\n\ + given multiple times).\n\ --threads=NUM-THREADS: Limits parallelism; by default, uses one thread\n\ per CPU core.\n\ --debug: Enables debug logging.\n\ @@ -3209,12 +3211,17 @@ Action a_optimize_materialized_map( for (const auto& arg : args.get_multi("minimize")) { auto tokens = phosg::split(arg, ':'); if (tokens.size() == 1) { - minimize_types.emplace(std::stoul(arg, nullptr, 16), std::make_pair(0xFF, 0)); + minimize_types.emplace(std::stoul(arg, nullptr, 0), std::make_pair(0xFF, 0)); } else if (tokens.size() == 3) { - minimize_types.emplace(std::stoul(tokens[0], nullptr, 16), std::make_pair(std::stoul(tokens[1], nullptr, 16), std::stoul(tokens[2], nullptr, 16))); + minimize_types.emplace(std::stoul(tokens[0], nullptr, 0), std::make_pair(std::stoul(tokens[1], nullptr, 0), std::stoul(tokens[2], nullptr, 0))); } } + std::unordered_set room_ids; + for (const auto& arg : args.get_multi("restrict-room")) { + room_ids.emplace(std::stoul(arg, nullptr, 0)); + } + size_t num_threads = args.get("threads", 0); bool pessimize = args.get("pessimize"); mutex output_lock; @@ -3223,6 +3230,9 @@ Action a_optimize_materialized_map( auto materialized = map_file->materialize_random_sections(seed); auto is_minimize_target = [&](const MapFile::EnemySetEntry& ene) -> bool { + if (!room_ids.empty() && !room_ids.count(ene.room)) { + return false; + } if (minimize_types.empty()) { return true; }