Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:WAD2 (Quake)

From ReverseEngineering.wiki
Format
Developer id Software
Versions WAD2 (Quake); WAD3 is Half-Life, not covered
Magic 57 41 44 32 ("WAD2") at offset 0
Extensions .wad
Endianness little
On this wiki Facts · Code · Notes · Topics

Texture and picture archive of Software:Quake (`gfx.wad`, and texture WADs used by map compilers): magic "WAD2", lump count, directory offset, then 32-byte directory entries with a type byte, a compression byte (always 0 in practice) and a 16-byte name. Different from the Doom engine's IWAD/PWAD.

Identification

WAD2 at offset 0, then int32 lump count and int32 directory offset. The header has the same three fields as the Doom WAD (Format:WAD (Doom engine)) but the directory entries are different (32 bytes instead of 16), so a Doom WAD reader misparses it.

Structure

  • Header (12 bytes): identification, numlumps, infotableofs.
  • Directory entries (32 bytes): filepos, disksize, size (uncompressed), type, compression, two pad bytes, 16-byte name.
  • Lump types: 0x40 palette, 0x41 "qtex", 0x42 picture (qpic_t: int32 width, height, then pixels), 0x43 sound, 0x44 mip texture (miptex_t as in Format:BSP (Quake)). Type 1 is a label.

The engine's own gfx.wad holds the HUD pictures and the console character set (conchars). Map compilers read texture WADs of type-0x44 lumps and copy the used textures into the BSP's texture lump, so the game itself never loads a texture WAD.

Pitfalls

  • The engine lower-cases and NUL-pads lump names to 16 bytes when loading (W_CleanupName), so lookups are case-insensitive although pak lookups are not.
  • compression 1 (LZSS) is defined in the header but the engine does not decompress anything; every lump of LibreQuake's gfx.wad has compression 0.

Evidence & references

  • id Software Quake source, WinQuake/wad.h (wadinfo_t, lumpinfo_t, TYP_*, CMP_*), wad.c (W_LoadWadFile, W_CleanupName) at commit bf4ac42.
  • Runtime test: LibreQuake v0.09-beta gfx.wad (in pak0.pak): 149 lumps, 148 of type 0x42 and 1 of type 0x44, all with compression 0.