Skip to content

GoldSrc mount: register source files as ResourceType.Binary - #11686

Open
ecclesialatina01 wants to merge 3 commits into
Facepunch:masterfrom
ecclesialatina01:goldsrc-raw-bytes
Open

GoldSrc mount: register source files as ResourceType.Binary#11686
ecclesialatina01 wants to merge 3 commits into
Facepunch:masterfrom
ecclesialatina01:goldsrc-raw-bytes

Conversation

@ecclesialatina01

@ecclesialatina01 ecclesialatina01 commented Aug 20, 2026

Copy link
Copy Markdown

Summary

A mounted GoldSrc game currently exposes only what the mount converts: WAD textures and materials, MDL models, WAV sounds. There's no way to get at the source files.

This registers every scanned file as the engine's unused ResourceType.Binary, so a game can read the raw bytes. Player files (configs, saves, demos, logs, sprays) are excluded.

This isn't a map loader, and a map loader doesn't replace it, because loading a map and exposing its bytes are separate registrations. The Quake mount has a full map loader and registers no raw files. The same registration would fit there too, since Quake keeps its entities in the same BSP lump and its game logic in progs.dat, which has no converted form either.

Motivation & Context

The converted resources don't keep everything the source files contain. A BSP's entity lump, where Half-Life keeps its monsters, scripted sequences and target wiring, has no converted form at all, because the scan only handles .wad, .mdl and .wav. An MDL's attachments and events don't survive model conversion; the parser reads them but the model builder never uses them. Sprites, skyboxes, HUD sprite manifests, sentences.txt, skill.cfg and the soundtrack aren't registered at all.

Reading them directly is a whitelist no-no, so the mount is the only route to a mounted game's bytes.

I'm using this in a Half-Life recreation where the entity lump is used for the map's monsters and triggers, skill.cfg for damage tables, sentences.txt for scripted speech, and the skies and HUD come from gfx/env/ and sprites/*.txt. With this addition the whole game runs off the mount.

Implementation Details

Uses the existing MountContext.Add with ResourceType.Binary. Paths don't clash because the engine appends an extension to converted resources, so a converted model registers as models/x.mdl.vmdl while the raw file stays models/x.mdl.

lazy loading: File.ReadAllBytes runs only when someone actually asks for the resource, through the same ResourceLoader caching every other mount type uses.

Checklist

  • Code follows existing style and conventions
  • No unnecessary formatting or unrelated changes
  • Public APIs are documented (if applicable)
  • Unit tests added where applicable and all passing
  • I'm okay with this PR being rejected or requested to change 🙂

ecclesialatina01 and others added 3 commits August 20, 2026 15:07
Registers every scanned file as Binary alongside the existing conversions,
excluding the player's own files (configs, saves, demos, logs, sprays).
skill.cfg is re-allowed by name since it's retail game data. Adds a
BinaryResource case to the mounting integration tests covering path
preservation and byte round-trip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant