Dev Blog

Pure Geometry, Infinite Arenas: Custom Maps with TrenchBroom

In most multiplayer shooters, the map pool stays fixed. Adding a new level means months of modeling, texturing, and lightmap baking before shipping a multi-gigabyte update. On mobile, community mapping basically does not exist because builds are locked behind app store reviews and oversized asset packs.

In the late 90s, anyone could open a level editor, block out some brushes, drop a few spawn points, and play a match on their own layout an hour later.

Because Wirefrag ships on Android first (with our desktop build coming as a secondary platform), we wanted that modding workflow to work directly on phones. You should be able to build an arena in TrenchBroom on a laptop, send the plain-text .map file to your Android phone, and play it seconds later without waiting on Play Store updates or giant downloads.


The Pure Geometry Rule

Many arena shooters rely on mechanical gadgets to move players vertically: jump pads with fixed flight paths, slow elevators, and teleporters that warp you across the map.

Wirefrag bans all three.

Every arena is built strictly out of static geometric blocks:

  • No Jump Pads: High platforms are reached with movement: bunnyhopping off angled ramps, blast jumping with the Cannon, or chaining wall kicks between pillars.
  • No Elevators: Vertical routes use stair switchbacks and wall-kick ledges that reward momentum.
  • No Teleporters: Sound and sightlines stay continuous, so enemies cannot appear behind you without footsteps or line-of-sight cues.

Keeping levels to static brushes also keeps the engine simple. There are no moving platforms or scripted triggers to sync over mobile networks or compile at load time.


From Raw Text to Playable Arenas

TrenchBroom saves levels as plain text where each solid block is defined by intersecting planes.

When you load a custom map in Wirefrag, the engine builds everything on the fly:

  1. It reads the plane definitions and computes their 3D intersections to form solid convex blocks.
  2. It generates static collision shapes for movement and wall kicks.
  3. It builds glowing neon wireframe outlines along every structural edge.

Because there are no bitmap textures to decompress into mobile VRAM and no lighting passes to bake, an arena with hundreds of brushes builds in roughly a tenth of a second on a modern Android phone. That keeps storage footprints small, load times near instant, and battery heat down. Our desktop build uses the exact same runtime loader, so maps run identically on PC as well.

Drawing Seams Where Blocks Intersect

In TrenchBroom, mappers overlap blocks all the time: running pillars through floors, sinking angled ramps into walls, or crossing trim brushes. Normally, overlapping brushes only draw wireframes along their outer corners, hiding the seam where two blocks meet.

During map compilation, Wirefrag checks overlapping brush bounds and clips penetrating faces against each other in 3D space. Any new edge where two blocks intersect gets added straight to the wireframe mesh, giving overlapping geometry clean glowing seams with no extra shader cost on mobile GPUs. On higher-tier desktop GPUs, an optional linear-depth edge pass adds crisp outer silhouettes while cutting off before your first-person weapon viewmodel.

Fallback Spawns for Fast Prototyping

If you are sketching a quick movement room in TrenchBroom and forget to place spawn entities, the importer logs a warning and generates fallback floor spawns automatically so you can still test the geometry right away. Once you add real deathmatch spawn points, the engine scales the map’s player limit between 2 and 16 players to match.


Sandboxing User Maps and Verifying Hashes

Loading user-created files from Discord or the web carries real security risks if a parser blindly trusts whatever is inside the file. Every imported map goes through a content agreement prompt and a strict validator before any game node is created.

Hard Size and Geometry Limits

To prevent malformed or hostile files from exhausting phone memory, incoming .map files are capped at 8 MB uncompressed. The validator also caps entity, brush, and face counts and rejects coordinates outside sensible world bounds. Anything that breaks those limits gets rejected before parsing finishes.

Blocking Script Injection and Scrubbing Paths

In TrenchBroom, entities use classnames to mark objects like player spawns or reverb audio zones. If an engine lets arbitrary names resolve into scripts, an attacker could reference engine classes or shell commands.

Our validator restricts entities to an explicit whitelist of known gameplay types and blocks reflection classnames, script extensions, and executable strings. Before writing the file to disk, it also strips local editor keys like workstation wad paths and TrenchBroom definition paths so mappers do not accidentally leak their computer’s folder structure when sharing files.

Isolated Storage and Multiplayer Hash Checks (sv_pure)

Imported maps are never saved under their original filenames, blocking directory traversal tricks. Instead, the game computes a cryptographic SHA-256 hash of the sanitized text and writes the map inside an isolated app sandbox folder named after that hash.

That same SHA-256 hash protects multiplayer matches on both peer-to-peer lobbies and our dedicated Linux servers:

  • Hosts advertise the active map’s 64-character SHA-256 digest in lobby metadata.
  • Built-in arenas are checked against precomputed signatures, and custom arenas are verified byte-for-byte on disk during the join handshake before any player spawns.
  • If your local copy of a custom map has been altered or is older than the host’s edit, your client discards the stale file and downloads the verified version from the host.

Teaching Bots to Play New Layouts

Pre-made arenas ship with pre-baked bot navigation, whereas community maps have to work the moment you load them.

Right after building the collision geometry, the loader starts a background navigation bake:

  1. It scans static colliders across floors, 1-meter stair step-ups, and ramps up to 50 degrees on a coarse grid tuned for mobile CPUs, avoiding frame hitches and thermal spikes.
  2. It caches the baked navigation mesh in memory for the rest of your session, so rematches on the same map skip the bake on both Android and desktop.
  3. Bots score spawn and patrol points using height weighting, recent-visit history, and crowding checks, so they climb toward high ground, flank around corridors, and break stalemates on layouts they have never seen.

Automatic P2P Streaming and All Five Modes

Passing files around in group chats before every match kills momentum on mobile.

When a host starts a lobby on a custom arena, any joining player on Android (or desktop) who does not already have that exact SHA-256 build automatically pulls the Zstd-compressed map in small chunks straight from the host. Because a typical .map file shrinks down to a few dozen kilobytes compressed, transfers finish in seconds even over mobile data. The client checks the decompressed hash against the host’s digest, runs the local validator, saves it into the sandbox, and joins the match.

Custom arenas also work across all five game modes: Free For All, one-hit Instagib railgun duels, Blast rocket combat, Joust blade-and-dash, and Bounce mortar bank shots. In Singleplayer Challenge matches, Wirefrag tracks your Wirefrag Combat Rating (WCR) and Map Mastery grades per custom map and mode, so any community arena works as a portable solo challenge on your phone as well as on desktop.


Importing Maps on Android (and Desktop)

Android’s scoped-storage restrictions make browsing folders painful. If you download a .map file from Discord or a browser into your phone’s Downloads folder, games cannot read arbitrary directories without explicit user permission.

We customized an in-game touch file browser specifically for Android with Quick Jump buttons straight to the app’s sandbox folder and external storage, plus a guided permission prompt when Android blocks folder access. Tap a .map file, and the game validates it in memory and copies it into the sandbox with no PC cable required.

On desktop, where most mappers author layouts in TrenchBroom, you can use the same in-game browser or drop .map files straight into the local custom maps folder while iterating, then host a lobby and stream your latest edit straight to friends on phones.


Why This Pipeline Works for Mobile

  • Tiny files: Most custom maps weigh a few hundred kilobytes uncompressed and even less over the wire, so sharing and streaming them on phones takes seconds.
  • Instant testing: Build a layout in TrenchBroom on a laptop, verify it on desktop, and immediately run full 5-mode matches with bots or friends on Android.
  • One file everywhere: The exact same .map text file runs identically across Android, Linux, Windows, and macOS.

In our next post, we will look at combat design: our instant five-weapon loadout, zero-latency projectile prediction, and how our four-layer bot AI thinks.