How sezero/uhexen2 works
Purpose and Deliverables
uHexen2 is a C-based, cross-platform source port of *Hexen II* and *HexenWorld*. It produces:
• Hexen II client and dedicated-server executables.
• HexenWorld multiplayer client and server executables.
• Content/build utilities, including QuakeC compilers, map tools, patching, and server administration tools.
Primary build entry points are engine/hexen2/Makefile, engine/hexenworld/build.sh, and utils/build.sh.
Engine Product Split
The repository separates game variants rather than using one uniform executable:
• Hexen II client owns host lifecycle, local client/server integration, menus, input, effects, and rendering: engine/hexen2/host.c, engine/hexen2/cl_main.c, engine/hexen2/sv_main.c.
• Hexen II dedicated server is a smaller platform-hosted target: engine/hexen2/server/host.c, engine/hexen2/server/sys_unix.c.
• HexenWorld explicitly separates multiplayer client, server, and shared protocol/movement code: engine/hexenworld/client/cl_main.c, engine/hexenworld/server/sv_main.c, engine/hexenworld/shared/net_chan.c.
Shared Engine Core and Runtime Loop
engine/h2shared is the core substrate used by the game targets. It provides command/cvar state, filesystem access, memory management, model loading, serialization, and script execution:
• Command/configuration and host-facing state: engine/h2shared/cmd.c, engine/h2shared/cvar.c, engine/h2shared/cfgfile.c.
• Virtual game filesystem and packed assets: engine/h2shared/quakefs.c, engine/h2shared/wad.c, common/pakfile.h.
• QuakeC VM boundary: engine code loads and executes compiled game programs through engine/h2shared/pr_exec.c, engine/h2shared/pr_edict.c, engine/h2shared/progs.h.
Control flow is broadly platform initialization → host/client or server frame loop → input/network processing → simulation/QuakeC execution → render/audio output.
Simulation, Networking, and Protocol Boundaries
The server owns authoritative world state, collision, physics, client command handling, and replication:
engine/hexen2/sv_phys.c, engine/hexen2/sv_move.c, engine/hexen2/sv_user.c.
Clients encode input, receive and parse server state, interpolate/predict where applicable, then render:
engine/hexen2/cl_input.c, engine/hexen2/cl_parse.c, engine/hexenworld/client/cl_pred.c.
Networking is datagram-oriented with loopback and OS-specific transports. Hexen II networking is centered in engine/hexen2/net_main.c, engine/hexen2/net_udp.c, and engine/hexen2/protocol.h; HexenWorld adds shared channel framing and Huffman compression in engine/hexenworld/shared/net_chan.c and engine/hexenworld/shared/huffman.c.
Rendering, Media, and Platform Adapters
Rendering has OpenGL and software-renderer paths. Common model/BSP and software rasterization live in engine/h2shared/model.c, engine/h2shared/r_bsp.c, and engine/h2shared/d_surf.c; product-level render orchestration is in engine/hexen2/gl_rmain.c and engine/hexen2/r_main.c.
System boundaries are selected per platform:
• SDL video/input/system integration: engine/h2shared/vid_sdl.c, engine/h2shared/in_sdl.c, engine/h2shared/sys_sdl.c.
• Native Windows/DOS/Amiga/OS2 alternatives are co-located in engine/h2shared/vid_win.c, engine/h2shared/vid_dos.c, and target-specific sys_*.c.
• Audio combines mixer/codec layers with platform backends: engine/h2shared/snd_mix.c, engine/h2shared/snd_codec.c, engine/h2shared/snd_sdl.c.
Bundled dependencies include SDL 1.2, OpenGL/DirectX-era headers, and audio codecs (FLAC, Ogg/Vorbis, Opus, MP3, MikMod, mpg123, xmp) under oslibs/.
Game Content and Build Pipeline
Game behavior is authored in QuakeC-like .hc sources, partitioned by original game and expansions/modes:
gamecode/hc/h2/progs.src, gamecode/hc/hw/progs.src, gamecode/hc/portals/progs.src.
These compile into VM program data consumed by the engine’s pr_* subsystem. Two compiler implementations are supplied: utils/hcc/hcc.c and utils/dcc/dcc.c.
Map/content production is a separate offline pipeline: BSP compilation (utils/qbsp/qbsp.c), visibility (utils/vis/vis.c), lighting (utils/light/light.c), and asset packaging (utils/pak/pakfile.c). Map entity overrides are shipped under gamecode/mapfixes/.
Operations and Supporting Executables
h2patch/h2patch3.c applies distribution patches using the vendored xdelta3 implementation in libs/xdelta3/xdelta3.c. HexenWorld server discovery/administration is supported by a master server and query/RCON tools: hw_utils/hwmaster/master.c, hw_utils/hwmquery/hwmquery.c, and hw_utils/hwrcon/hwrcon.c.
CI currently includes a Linux build workflow at .github/workflows/build-linux.yml.
Main entry points: Makefile Build entry points · host.c Hexen II client · cmd.c Shared engine core · sv_main.c HexenWorld server
Components 20
Engine Products
- Hexen II client · Integrated local client/server game runtime.
engine/hexen2/host.c - Hexen II dedicated server
engine/hexen2/server/host.c - HexenWorld client
engine/hexenworld/client/cl_main.c - HexenWorld server
engine/hexenworld/server/sv_main.c - Hexen II simulation · Physics, movement, commands, and replication.
engine/hexen2/sv_phys.c - Hexen II networking · Loopback and UDP transports with game protocol.
engine/hexen2/net_main.c - HexenWorld protocol · Shared framing and Huffman compression.
engine/hexenworld/shared/net_chan.c
Shared Runtime
- Shared engine core · Commands, cvars, memory, files, models, and serialization.
engine/h2shared/cmd.c - Virtual filesystem · Loads game files and packed assets.
engine/h2shared/quakefs.c - QuakeC VM · Loads and executes compiled game programs.
engine/h2shared/pr_exec.c - Rendering and audio · OpenGL/software rendering plus mixer and codecs.
engine/h2shared/model.c - Platform adapters · SDL and native video, input, system, and audio backends.
engine/h2shared/vid_sdl.c
Content Pipeline
- Game QuakeC sources · Base, HexenWorld, and Portal of Praevus programs.
gamecode/hc/h2/progs.src - QuakeC compilers · Two supplied compilers produce VM programs.
utils/hcc/hcc.c - Compiled game programs
gamecode/hc/hw/progs.src - Map toolchain · BSP, visibility, lighting, and package generation.
utils/qbsp/qbsp.c
Operations
- Distribution patcher · Applies patches through vendored xdelta3.
h2patch/h2patch3.c - HexenWorld operations · Server discovery, query, and RCON support.
hw_utils/hwmaster/master.c
Other components
- Build entry points · Builds engine variants and utilities.
engine/hexen2/Makefile - Linux CI
.github/workflows/build-linux.yml
Connections 27
- Build entry points → Hexen II client: builds
- Build entry points → Hexen II dedicated server: builds
- Build entry points → HexenWorld client: builds
- Build entry points → HexenWorld server: builds
- Build entry points → QuakeC compilers: builds
- Linux CI → Build entry points: runs
- Hexen II client → Shared engine core: uses
- Hexen II dedicated server → Shared engine core: uses
- HexenWorld client → Shared engine core: uses
- HexenWorld server → Shared engine core: uses
- Shared engine core → Virtual filesystem: loads assets through
- Shared engine core → QuakeC VM: hosts
- Hexen II client → Hexen II simulation: local server loop
- Hexen II dedicated server → Hexen II simulation: runs
- Hexen II client → Hexen II networking: sends input and receives state
- Hexen II simulation → Hexen II networking: replicates state
- HexenWorld client → HexenWorld protocol: uses
- HexenWorld server → HexenWorld protocol: uses
- Hexen II client → Rendering and audio: renders and plays audio
- Rendering and audio → Platform adapters: uses backends
- Platform adapters → Hexen II client: initializes runtime
- Game QuakeC sources → QuakeC compilers: compiled by
- QuakeC compilers → Compiled game programs: produces
- Compiled game programs → QuakeC VM: executed by
- Map toolchain → Virtual filesystem: produces packaged content
- Distribution patcher → Virtual filesystem: patches distributions
- HexenWorld operations → HexenWorld server: discovers and administers