Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Gamemap Atlas

Show players where the real-world places that show up in a game actually are, by marking them on a real map with a rough outline of the region the game covers. First prototype: the Caribbean setting of Assassin's Creed IV: Black Flag (remake).

This deliberately does not try to overlay the actual game map image on the real world. Game maps are stylized, compressed re-imaginings of real geography (Black Flag's whole Caribbean fits in a few dozen km, not the ~1000+ km it spans in reality), so a pixel-accurate overlay would always look distorted no matter how carefully it's calibrated — and it would mean redistributing someone else's map image, which is a copyright headache. Instead: real places get their real boundaries, and a loose rectangle gives a sense of "this is roughly the area the game depicts" without claiming precision it can't have.

Two modes

The same page behaves differently depending on how it's served, decided by a GET /api/ping probe at startup:

Viewer (deployed / static server) Editor (local node server.js)
Browse games, search, view landmarks yes yes
Add/rename/delete games, edit boundary, mark landmarks, change theme hidden yes
Find enclosing areas (proxied through the server) hidden yes

That split is deliberate: GitHub Pages is static hosting with no backend, so editing controls would only fail there. Authoring happens locally and gets committed as JSON.

Running it

node server.js        # or: npm run dev

Then open http://localhost:8000.

To see what a visitor sees, run the same server with no write API:

node server.js --static   # or: npm run prod

That serves http://localhost:8001 with every /api/* route switched off, so the startup probe 404s and the page falls into viewer mode exactly as it does on GitHub Pages. Both can run at once — :8000 to author, :8001 to look.

Editing

Region boundary — check "Edit boundary edges", then drag anywhere along a side of the rectangle. North/south edges only move latitude, east/west only longitude, so each side adjusts independently.

Landmarks — search a place, click a result to highlight it, then "Mark as landmark". Each result is tagged outline (a real OSM boundary) or box (no boundary exists; a bounding rectangle stands in).

The ✎ button on a landmark opens a form for every stored field — real name, in-game name, wiki URL, description. Descriptions in particular are never filled in automatically, since Nominatim knows nothing about game wikis. Edits apply as you type; Save game file persists them.

For a box result, find enclosing areas looks up the areas containing that point and offers them as alternatives, smallest first, each labelled with its kind. This exists because plenty of cities have no boundary of their own in OSM — Nassau is only a point, while the island it sits on (New Providence) has the outline you actually want.

Both administrative areas and islands are offered, because the same name often covers two very different shapes: New Providence exists as an island and as an administrative district whose boundary runs out to sea and is 23× larger. For a pirate-era map it's the island you want, so the kind is shown on every option.

Picking an enclosing area borrows only its shape — the landmark keeps the name you searched for. Marking Nassau via New Providence still saves a landmark called "Nassau"; otherwise it would be indistinguishable from having just searched for the bigger place. The mark button spells out which name it'll use.

It deliberately doesn't auto-pick the smallest. A city node usually sits on a town hall or harbour, so the tightest enclosing area is often far too small — Havana's is Prado, a single neighbourhood, with the province you want two levels out. Ordering is by actual bounding-box area rather than admin_level, since levels aren't comparable across countries (an island district is 8 in the Bahamas, a province is 4 in Cuba) and islands have no level at all.

Theme — each game carries a primary and secondary colour. Primary drives the region rectangle and UI accents, secondary the landmark shapes. Pick a preset or use the colour inputs. (Search highlights stay white regardless, so a transient search result is never mistaken for a saved landmark.)

Nothing is written to disk until you click Save game file, which writes via a temp-file-then-rename swap so an interrupted save can't leave a half-written or empty file.

On geometry precision — search results are fetched pre-simplified (polygon_threshold=0.001, ~100 m), since a result list is 15 shapes at once and only one is ever kept; unsimplified, a 15-result search runs to 165 KB instead of 19 KB.

Selecting a result then re-fetches that one place unsimplified and trims it to a point budget (MAX_BOUNDARY_POINTS, 1500) rather than a fixed tolerance. The highlight draws from the coarse preview immediately so the click feels instant, then redraws when the exact shape lands — so what's on screen before you mark is what gets saved.

A flat tolerance is wrong in both directions — it leaves a huge coastline enormous while flattening a small place into a triangle when you zoom in. A budget only bites on the shapes that need it:

raw saved
Ambergris Caye 23,469 pts / 568 KB 1,469 pts / 36 KB
New Providence 5,065 pts 1,121 pts
Cuba 198 pts untouched
Castillo de la Real Fuerza 193 pts untouched
Grand Cayman 72 pts untouched

Simplification is Douglas–Peucker with the tolerance doubled until the budget is met, run iteratively so a 20k-point coastline can't overflow the stack. Saved files also keep each landmark's geometry on a single line, since indenting it puts every coordinate number on its own row and triples the file size.

Data layout

data/games/index.json          # list of {id, name} — what the game picker reads
data/games/<id>.json           # one file per game

A game file:

{
  "id": "ac-black-flag",
  "name": "Assassin's Creed IV: Black Flag",
  "theme": { "primary": "#d8a537", "secondary": "#2a9d9c" },
  "bounds": [[south, west], [north, east]],
  "landmarks": [
    {
      "name": "Guantánamo Bay",        // the real place — what the map shows
      "gameName": "Cumberland Bay",    // what the game calls it, if different
      "kind": "site",                  // omitted for regions; "site" draws a dot
      "wikiUrl": "…",                  // the game wiki's article
      "osm": "R7160727",
      "boundary": { /* GeoJSON */ },
      "description": "…"
    }
  ]
}

The id is the filename, and it is derived from the name — so renaming a game renames data/games/<id>.json and its data/candidates/<id>.json alongside it, and rewrites the index entry. If the new name would collide with a different game's id, the rename is refused and the old id is kept rather than overwriting that game.

Generating candidates from the wiki

node tools/wiki-candidates.js writes the game's locations to data/candidates/<game-id>.json, which the editor shows as a Checklist above the search box. It adds nothing to the map — every row hands off to the search panel, and you pick the shape there.

Each row gives the in-game name, any alternate the game also uses, what the place is really called, a wiki link, and search:

Cumberland Bay
real life: Guantánamo Bay       wiki  search

Fort Lully
a.k.a. Navassa
real life: Navassa Island       wiki  search

Alternates matter because a page title isn't always the in-game name: Charlotte (fort) carries a wiki disambiguator, and a place renamed during the story is titled by its later name — the base game calls Fort Lully Navassa and Fort Matías Punta Guarico. The lead paragraph bolds every alternate, so those get collected.

search fills the search box with the real-world name and runs it — so the region filter, the enclosing-area drill-up, and the outline/box badges all apply as usual.

Both names are stored: name is the real place (Guantánamo Bay), gameName what the game calls it (Cumberland Bay). gameName is what ticks the checklist row off (✓).

On screen the game's name leads, with the real one underneath — in the landmark list, in the map tooltip, and as the popup's heading, with Real life: Guantánamo Bay below it. A visitor arrives knowing the game's name for a place and wants to find out where it is; showing them the answer first and making them work out which entry it belongs to is backwards. The list sorts by the displayed name for the same reason.

Regions and sites

The checklist has two tabs. Sites — Havana's cathedral and Castillo de la Real Fuerza, Nassau's Queen's Staircase — come from the wiki's Landmarks in <city> categories and are saved with kind: "site", which drops a pin rather than drawing an outline. They do have OSM footprints (all five checked had one), but a 60 m building is sub-pixel at the zoom this map opens at, so the shape is stored and the dot is what you see. The ✎ form has a Show as a point toggle for anything searched directly.

Locations the wiki gives no real-world name for stay in the list, labelled as such under the name. They're a mix of invented places (Isle-du-Fey), in-game buildings (Nassau bureau, Old Avery), and real places nobody has tagged (New Providence, The Blue Hole) — only a person can tell those apart.

The tool does no geocoding. An earlier version matched every place against Nominatim and shipped the geometry, but each match still had to be eyeballed — a name-similar hit inside the right region (Fort Charles matching "Fort Charles Road") looks exactly like a correct one in a list — so the shapes were never trusted. Searching by hand covers the same ground with the map in view, and the file dropped from 263 KB to 13 KB.

Pages come from two sources, because each misses what the other catches:

  • The game navbox's Locations group (Template:ACIV, Template:FC) — hand-curated, and reaches wherever the game goes. It's the only thing that finds Conttoyor and Chinchorro (filed under Locations in Mexico) or Príncipe (an island off Africa — the game's second map). Any hand-written list of Caribbean categories misses whatever lies outside the region you thought to list.

    Entries in that group that are followed by {{c|…}} are headings for the places inside them, not places — Cayman Islands only groups Cayman Sound and Grand Cayman — so they're detected from that structure and dropped. They have to be dropped after both sources are merged, since the category tree pulls names like Cuba and Jamaica in independently.

  • The category tree (Category:Caribbean and friends) — the navbox only names top-level places, so on its own it drops the buildings inside them: Havana's Castillo de la Real Fuerza and cathedral, Nassau's Queen's Staircase.

Two more signals then filter and enrich them, neither of which is in the category tree:

  • Appearances section — which games a location is in. A bullet tagged {{Mo}}/{{Mdat}} means the place is only mentioned there, never visitable (Barbados, Trinidad, Spanish Town), so it's dropped. This is only required of category hits, since categories carry no game: a navbox hit is already the game's own list, and demanding an Appearances section from it dropped stub pages like Isla Faro that cite the game under References instead.
  • {{WP-REAL}} — the place exists in reality. Bare means the real name matches the page title; with an argument it differs — and it usually does. Cumberland Bay is really Guantánamo Bay, Fort Lully is Navassa Island, Ambergris Key is Ambergris Caye. That mapping is hand-curated by wiki editors and is the part you could never reconstruct by guessing.

For Black Flag this yields 87 visitable locations — 73 regions and 14 sites — 50 of which carry a real-world name.

A note on names and language

By default Nominatim localises names to the browser's Accept-Language, which would mean whoever marked a landmark froze its name in their language for every later visitor — a landmark marked on a Chinese browser would stay "拿骚" for English readers, since the saved file stores the string literally and never re-localises.

Requests therefore pin accept-language=en (PLACE_LANGUAGE in js/config.js), so saved names are English no matter who authored them. Change that constant to target a different language.

Landmarks also store an osm reference (e.g. "R7160727"), which leaves the door open to re-resolving names into other languages, or refreshing geometry, without searching again. Use the ✎ button in the landmark list to override a name by hand.

About Fandom content

Fandom/Wikia article text defaults to the CC BY-SA license: you can quote and paraphrase it, but you must give attribution and share alike — don't copy large blocks verbatim and pass them off as original. Keep descriptions short and rewritten in your own words; the wikiUrl link covers attribution.

Deploying to GitHub Pages

  1. Create a new GitHub repo (e.g. gamemap-atlas) and push this directory to it.
  2. Repo Settings → Pages → Source: main branch, root /.
  3. After a few minutes it'll be live at https://<your-username>.github.io/gamemap-atlas/.

server.js is dev tooling and simply goes unused there. To later move to a custom domain on Cloudflare Pages, point a Cloudflare Pages project at this directory — no code changes needed.

Project structure

index.html          # sidebar + map shell
css/style.css       # layout; theme colours arrive as CSS variables
js/main.js          # entry point: mode detection, wiring, startup
js/config.js        # constants — palettes, language, simplification threshold
js/state.js         # shared mutable state + the cross-module event bus
js/mapView.js       # Leaflet map, boundary rectangle, edge dragging, landmarks
js/geo.js           # Nominatim/Overpass calls and GeoJSON helpers
js/games.js         # game index, switching, loading
js/search.js        # search UI and enclosing-area picker
js/editor.js        # editor-only panel: theme, add/save/delete
js/candidates.js    # editor-only: review and accept generated candidates
js/util.js          # escapeHtml, el
server.js           # local-only dev server: static files + write API
check.js            # syntax/JSON check for every source file
tools/              # offline generators, run by hand
data/games/         # game index and per-game files
data/candidates/    # generated proposals, reviewed in the editor

Browser modules are plain ES modules loaded natively (<script type="module">) — no bundler, no build step. Editing a file and reloading is the whole loop.

state.js holds shared state and a small DOM-event bus so modules don't have to import each other: games.js announces a load, editor.js listens, and neither needs a reference to the other.

Run npm run check before committing. It syntax-checks every file and validates the game JSON. Note it copies browser modules to .mjs first — node --check silently exits 0 on a .js file containing import, so checking them directly validates nothing.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages