Tile paths are stable across rebuilds but their contents are not: moving a map's `place` makes tiles/<id>/6/17/33.webp different imagery at the same URL. Combined with the immutable week-long cache added earlier, a browser that had seen an older build blended the two and drew duplicated, offset terrain -- visible as a second copy of Lighthouse. Each map now carries a `version` in world.json, hashed from its geometry, zoom range and source file stamp, and appended to every tile URL as ?v=. Re-tiled maps get fresh URLs; identical rebuilds keep the same version so nothing is re-fetched needlessly. Also corrects the runbook's base-layer table, which still listed the pre-correction layers for Woods, Reserve, Interchange and Streets. Verified: 733 tiles across seven map views, all carrying ?v=, zero broken, and the focused map topmost in every case. Co-Authored-By: Claude Opus 5 <[email protected]>
189 lines
6.1 KiB
Markdown
189 lines
6.1 KiB
Markdown
# Adding a map
|
||
|
||
Point the config at a PSD, name the layers holding the map art, say where it
|
||
goes on the world map, build. No application code changes.
|
||
|
||
Budget ~10 minutes plus render time (roughly 3 minutes per GB of PSD).
|
||
|
||
---
|
||
|
||
## 0. Once per machine
|
||
|
||
```bash
|
||
python -m pip install -r tools/requirements.txt
|
||
```
|
||
|
||
Put the PSD under `sources/<id>/`. That directory is gitignored — source art
|
||
lives on the shared drive, never in the repo.
|
||
|
||
---
|
||
|
||
## 1. Find the layers holding the map art
|
||
|
||
```bash
|
||
python tools/psd_tree.py sources/woods/woods.psd --depth 2
|
||
```
|
||
|
||
**There is no naming convention.** Every re3mr map does this differently, so
|
||
you have to look each time:
|
||
|
||
| Map | Base layers |
|
||
| --- | --- |
|
||
| Customs, Customs Dorms | `LOCATION` |
|
||
| Woods | `re3mr.com/Map&Art/Map&OverlayArt/{RawMapLayer,WaterDetail}` |
|
||
| Lighthouse | `Day` (there is also a hidden `Night`) |
|
||
| Shoreline | `Baselayer` |
|
||
| Shoreline Resort | `BGCOLOR PATTERN`, `BASEMAP+2DLAYERS` |
|
||
| Interchange | `3DRENDER` |
|
||
| Reserve | `Day copy` |
|
||
| Streets | `Map - 3D map portion…` |
|
||
|
||
Note the shapes this takes: several maps need **more than one** top-level
|
||
layer, and some bury the art **inside wrapper groups** (use a slash path —
|
||
Woods is three deep).
|
||
|
||
Watch for layers that are really just plates. Interchange's `Background` and
|
||
Reserve's `Color Fill 1` are solid white; Woods' `MapBlackout` and Streets'
|
||
`Layer 1` are solid black. Including them hides the terrain underneath, so
|
||
leave them out.
|
||
|
||
Also note any `shape` layers — psd-tools renders stroke-only vector shapes as
|
||
solid fills, so they may need `excludeLayers`.
|
||
|
||
---
|
||
|
||
## 2. Add it to `maps.json`
|
||
|
||
```json
|
||
{
|
||
"id": "woods",
|
||
"name": "Woods",
|
||
"psd": "sources/woods/woods.psd",
|
||
"baseLayers": ["re3mr.com/Map&Art/Map&OverlayArt/RawMapLayer"],
|
||
"excludeLayers": [],
|
||
"crop": null,
|
||
"place": { "cx": 814, "cy": 672, "w": 380 }
|
||
}
|
||
```
|
||
|
||
| Field | Meaning |
|
||
| --- | --- |
|
||
| `baseLayers` | slash-paths from the document root; everything else is hidden |
|
||
| `excludeLayers` | layer names to hide anywhere inside the kept set |
|
||
| `crop` | `[x0, y0, x1, y1]` in PSD pixels, or `null` for the full canvas |
|
||
| `place` | where it sits on the world map — see step 4 |
|
||
| `pxPerMeter` | optional, from the map's scale bar; recorded for later use |
|
||
|
||
---
|
||
|
||
## 3. Render the base layer and look at it
|
||
|
||
```bash
|
||
python tools/export_base.py woods
|
||
```
|
||
|
||
Open `build/woods/base.png` and check for:
|
||
|
||
- **large flat areas of solid colour** — a shape layer is filling. Add its name
|
||
to `excludeLayers`. (Customs needs `"Map Borders"`; without it the whole
|
||
playable area renders white.)
|
||
- **leftover markers, legends or titles** — wrong `baseLayers`.
|
||
- **missing terrain** — you kept the overlay group but not the art beneath it.
|
||
- **dead canvas around the art** — that sets your `crop`.
|
||
|
||
A failed map no longer aborts the batch; check the summary at the end.
|
||
|
||
---
|
||
|
||
## 4. Position it on the world map
|
||
|
||
The base of the canvas is `sources/overall/overall.jpeg`, rotated by
|
||
`world.rotate` (35°) so north is up. `place` is in **rotated overall-map
|
||
pixels** — the north-up image you actually look at.
|
||
|
||
```bash
|
||
python tools/place_preview.py
|
||
```
|
||
|
||
That writes `build/place-preview.png`: the rotated base with a 100 px grid and
|
||
every current `place` box drawn on it. Read the coordinates for your zone
|
||
straight off the grid, set `cx`/`cy`/`w`, re-run. The loop takes seconds
|
||
because nothing is tiled.
|
||
|
||
`w` is the map's width in overall-map pixels; height follows from the source
|
||
aspect ratio. Positions are deliberately approximate — the game's individual
|
||
maps are not drawn to match the satellite view exactly, so aim for "clearly the
|
||
right place", not pixel alignment.
|
||
|
||
Because placements are approximate, map rectangles **do** overlap where the
|
||
real locations don't. That is handled in the viewer rather than by chasing
|
||
perfect boxes: the map whose centre you are viewing is always lifted to the
|
||
top, so an overlapping neighbour can never hide it.
|
||
|
||
### Changing the tilt
|
||
|
||
`place` coordinates live in the rotated frame, so editing `world.rotate` by
|
||
hand would move every map. Use the helper instead — it converts all placements
|
||
through the old and new angles so geography is preserved:
|
||
|
||
```bash
|
||
python tools/retilt.py 35
|
||
```
|
||
|
||
---
|
||
|
||
## 5. Build and verify
|
||
|
||
```bash
|
||
python tools/build.py woods
|
||
```
|
||
|
||
```bash
|
||
python tools/preview.py 4
|
||
```
|
||
|
||
`build/world-preview.png` composites everything at its world position. Then:
|
||
|
||
```bash
|
||
pwsh server/run.ps1
|
||
```
|
||
|
||
---
|
||
|
||
## Useful variations
|
||
|
||
```bash
|
||
python tools/build.py # base + every map
|
||
python tools/build.py overall # just retile the base map
|
||
python tools/build.py --tiles-only # re-tile after a place/crop change
|
||
python tools/build.py --force-export # re-render even if base.png is current
|
||
```
|
||
|
||
`build.py` skips the PSD render when `base.png` is newer than the PSD, so
|
||
iterating on `place` and `crop` is seconds, not minutes.
|
||
|
||
Retiling a map changes its `version` in `world.json`, which is appended to its
|
||
tile URLs as `?v=`. That is what stops a browser mixing a previous build's
|
||
tiles with the new ones — you do not need to hard-reload after a rebuild.
|
||
|
||
---
|
||
|
||
## How placement works
|
||
|
||
World pixels are overall-map pixels × `world.overallScale` (64), chosen so the
|
||
detail maps land near their native resolution — Customs works out to almost
|
||
exactly its 7832 px source width.
|
||
|
||
Tile grids have to stay integral: a map's tile-index offset must be a whole
|
||
number of tiles at every zoom, which only holds when its origin is a multiple
|
||
of `tileSize · 2^maxZoom`. That is 131 072 world pixels — far too coarse to
|
||
position anything. So rather than *moving* a map onto the grid, the tiler
|
||
**pads** it: the raster is padded up-and-left to the nearest cell boundary and
|
||
only tiles containing real content are ever visited. Exact placement, integral
|
||
grid, and the padding costs nothing.
|
||
|
||
Each map is also only tiled down to its **native level** — the deepest zoom at
|
||
which we are still downscaling its source. Past that the browser upscales,
|
||
which looks the same as upscaling during the build but without storing tiles.
|
||
`minZoom` likewise stops a map loading while it would be a speck on screen.
|