Skip to content
ethanejohnsonsPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

webq3

Quake III Arena in the browser, for playing with friends and family. It's built on ioquake3 compiled to WebAssembly, and supports multiplayer and QVM mods. Whoever hosts the site supplies the game data, so no id Software files are included here.

How it works

  • Engine: engine/ioq3 is the upstream ioquake3 submodule, and engine/patches/ holds webq3's changes to it. The main one is vm_wasm.c, which compiles QVM bytecode (cgame, ui, mods) into WebAssembly at load time instead of interpreting it.
  • Multiplayer: the browser engine's UDP traffic goes over a WebSocket to a gateway (server/src/gateway.ts), which relays it to native ioq3ded servers.
  • Content: server/src/content.ts scans a game directory and writes a manifest. The launcher (web/) downloads the pk3s a room needs and caches them in the browser.

Game data

Put your own files in content/, which git ignores:

content/
  mods.yaml              mods players can pick
  baseq3/pak0.pk3 ...    retail data plus any map packs
  <mod>/*.pk3            one directory per mod

content/mods.yaml:

mods:
  - id: baseq3
    name: Quake III Arena
    fs_game: baseq3
  - id: alternatefire
    name: Alternate Fire
    gametypes: [ffa, tdm, ctf]

Running it with Docker

cp .env.example .env    # then set Q3_CONTENT to your Quake III Arena folder, and ROOMS
docker compose up -d --build

The site is on port 80. Opening it with no parameters joins the first room in ROOMS, and ?connect=<room id> joins another. Mods come from deploy/mods.yaml; each ROOMS entry runs one dedicated server (id=mod:map[:gametype[:bots]]).

Browsers only cache the game files on HTTPS pages (or localhost). Over plain HTTP on the LAN, the ~500 MB of pk3s download again on every visit. For family outside your network, set SITE_ADDRESS to a domain that points at your home connection and forward ports 80 and 443, or put the site behind a Cloudflare Tunnel.

Development

You need Node 24+, CMake, Ninja and a C compiler. engine/build.sh installs its own Emscripten SDK into engine/.emsdk.

git submodule update --init
engine/build.sh all                   # wasm client + native ioq3ded
npm --prefix server ci && npm --prefix web ci
npm --prefix server run build-content  # writes content/_dist
npm --prefix server start              # gateway on :8080
npm --prefix web run dev               # launcher on :5173

Start a dedicated server for the gateway's default target:

engine/build/server/Release/ioq3ded +set dedicated 1 +set net_ip 127.0.0.1 \
  +set fs_basepath "$PWD/content" +set sv_pure 1 +map q3dm17

Then open http://localhost:5173/?connect=default&name=You. Useful query parameters: mod, map (without connect this starts a local game), and args for extra engine arguments (+ must be written as %2b).

Changing the engine

engine/work is a git worktree of the submodule on a webq3 branch, with the patches committed:

git -C engine/ioq3 worktree add -b webq3 ../work HEAD
git -C engine/work am ../patches/*.patch

Commit changes there, build with IOQ3_SRC=engine/work engine/build.sh, and run engine/export-patches.sh to regenerate engine/patches/.

Benchmarking QVM performance

vm_timing 1 plus the vmtiming command report the time spent running QVM code. vm_cgame 1 selects the interpreter and vm_cgame 2 the WebAssembly compiler:

?args=%2bset vm_timing 1 %2bset nextdemo vmtiming %2btimedemo 1 %2bdemo four

License

GPL-2.0, the same as ioquake3. See COPYING.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages