- This project delivers a Windows-friendly BeamMP map rotation tool so server hosts can swap maps quickly without manual zip juggling.
Deliver a single self-contained batch file (map_selector.bat) that automates map rotation, server restarts, and mod hygiene without dependencies on extra scripts or data files. This file now lives at the repo root; launch it (double-click or run via cmd) to start the selector. The batch file extracts its embedded PowerShell payload to a temporary file at runtime, cleans it up on exit, and handles everything else automatically.
-
Single Artifact
- All logic must reside inside
map_selector.bat(embedded PowerShell/VBScript payloads are allowed if generated at runtime and cleaned up afterward). - The batch file must operate correctly when launched from any directory by deriving the BeamMP root relative to its own path.
- All logic must reside inside
-
Map Zip Discovery & Classification
- On startup, scan both
Resources\Clientandmap_filesfor*.zip. - Inspect each archive for entries matching
levels/<folder>/info.json. - Zips that contain at least one such entry are map zips; all others are general mods.
- Map zips found in
Resources\Clientare moved tomap_files(reserveResources\Clientfor active map + general mods only). - General mod zips (or archives that failed inspection) are kept/moved to
Resources\Clientso players can correct issues manually.
- On startup, scan both
-
Dynamic Menu Structure
- Build an in-memory structure
[zip file -> [map folders]]from the inspection results. - First-level menu lists map zip files (plus a
randomoption and a dedicated Stock maps entry); navigation via arrow keys, PageUp/PageDown, Home/End, Enter to select. - When a zip contains multiple map folders, show a second-level menu to choose the desired folder; if there is exactly one folder, auto-select it.
- Menus should clearly display the current selection and total counts.
- Build an in-memory structure
-
Random Selection Quality
- Selecting
randomfirst picks a random zip, then a random map within that zip. - Use a cryptographically strong RNG (
System.Security.Cryptography.RNGCryptoServiceProvideror equivalent) to avoid deterministic sequences.
- Selecting
-
Map Activation Workflow
- When a specific zip/map pair is chosen:
- Move any other map zips out of
Resources\Clientintomap_files. - Move the chosen zip into
Resources\Client. - Backup
ServerConfig.tomltoconfig_backups/ServerConfig.<timestamp>.bak. - Update (or insert) the line
Map = "/levels/<map>/info.json"using UTF-8 encoding. - Stop all running
BeamMP-Server.exeprocesses. - Start a fresh
BeamMP-Server.exewith working directory set to the repo root.
- Move any other map zips out of
- When a specific zip/map pair is chosen:
-
Session Persistence
- After starting the server, print the active zip and map.
- Return to the main menu automatically so players can switch maps repeatedly without restarting
map_selector.bat. - Provide an explicit exit option (e.g.,
Escor menu item) that shuts down the selector without killing the server.
-
Error Handling & Messaging
- If no map zips exist in either directory, display guidance to drop map zips into
map_filesorResources\Clientand re-scan on demand. - Warn (but continue running) when
BeamMP-Server.exeorServerConfig.tomlis missing, when zip inspection fails, or when process control requires elevation. - Mirror every critical action (scans, selections, config edits, server restarts, failures) to both the console and an append-only
map_selector.login the repo root so post-mortem debugging is possible even when the console session disappears.
- If no map zips exist in either directory, display guidance to drop map zips into
-
Networking Awareness (Optional Enhancements)
- After launching the server, optionally display the detected LAN IP + port to simplify office LAN matches.
- Future improvements may include automatic detection of dedicated ethernet dongle IPs.
- Portability: Works on Windows 10/11 without requiring extra PowerShell modules.
- Performance: Initial scanning and menu rendering should complete within a few seconds even with dozens of zips.
- Maintainability: Code should be commented only where behavior is non-obvious; keep everything ASCII for compatibility.
- Safety: Never delete mods; only move between
map_filesandResources\Client. Always create config backups before edits.
- Write selector activity to
map_selector.log(adjacent tomap_selector.bat) in addition to console output so that we can reconstruct actions after non-interactive runs or sudden console exits. The file automatically trims itself to roughly 512 KB so it never grows unbounded. - Log the discovered map count, chosen zip/map, config backup path, server stop/start status, and any warnings/errors with timestamps.
- Ensure the log is created/updated entirely by the self-contained batch/PowerShell bundle—no external scripts or modules.
- Provide a simple environment flag (e.g.,
MAP_SELECTOR_DEBUG=1) that skips deleting the temporary embedded PowerShell file, enabling deeper troubleshooting when required.
- Run
map_selector.batfrom the repo root (double-click or via Command Prompt). It auto-discovers the repo path and launches its embedded PowerShell selector logic. - On launch it scans
Resources\Clientandmap_files, rehomes map zips, and builds two-level menus (zip → map).randomuses a cryptographically strong RNG. - Selecting a map moves only other map zips back to
map_files, leaves general mods where they belong inResources\Client, places the active map zip beside them, backs upServerConfig.tomlintoconfig_backups/, edits the config, restartsBeamMP-Server.exe, and prints the active pairing while keeping the selector running for future swaps. - The CLI offers
RescanandExitentries plus Esc shortcuts; if no maps are found it prompts you to add zips and re-scan.
You can run the selector without the interactive menu—handy when diagnosing issues from a non-interactive console:
map_selector.bat --help
map_selector.bat --zip Clickbait_LiquidJumpingV1.0.zip --map WaterJumping2
map_selector.bat --random
map_selector.bat --stock italy
--zip <zipfile>: select the given zip automatically (case-insensitive).--map <folder>: specify which map folder inside the zip to use (required if the zip has multiple maps; optional otherwise).--random: pick a random zip and random map (stock levels are excluded; use--stockfor those).--stock <name>: activate a built-in BeamNG map (gridmap_v2, italy, etc.; check the Stock Maps Menu section below or themap_selector.batsource for the latest names).--help: print the usage summary.
In non-interactive mode the selector still moves zips, updates the config, restarts the server, prints the selection, and exits when finished.
- The interactive main menu now includes Stock maps (built-in BeamNG levels). Selecting it opens a submenu listing curated stock maps (e.g., Gridmap v2, Johnson Valley, Italy, Jungle Rock Island, Utah) along with their
/levels/<map>/info.jsonpaths so you can activate official maps without keeping the zips locally. - Stock activations respect the same workflow: other custom map zips are parked back in
map_files, general mods stay inResources\Client,ServerConfig.tomlis backed up and updated with the stockMappath, and the BeamMP server is restarted automatically. - Random selection only considers discovered map zips, so stock levels never appear in the Random menu entry—trigger them explicitly via the Stock Maps menu or the
--stockCLI flag. - Non-interactive stock runs use
--stock <name>(matching is case-insensitive). If you supply an unknown name, the selector prints the list of valid identifiers and exits with an error.
- Set the environment variable
MAP_SELECTOR_DEBUG=1before launching the batch file when you want to preserve the extracted PowerShell script for inspection. The batch wrapper will leave the temp file in%TEMP%and log the exact path. - Review
map_selector.logafter any crash or unexpected exit to see the recorded actions (scan results, moves, warnings, server restarts, etc.).
- Should the selector optionally sync chosen maps to the second office PC automatically?
- Do we want to expose presets (e.g., “best of 5 random maps”) for tournament play?
- Should the selector track historical usage to avoid repeating the same map until all others are used?
These can be addressed in follow-up iterations once the baseline batch selector is in place.