Skip to content
Bogdan Gligorijević edited this page Sep 7, 2022 · 4 revisions

Warcraft loads its game files from a set of MPQ archives (before v1.30) or the CASC archive (v1.30+ of the game). These are basically ZIP files with all of the game's textures, models, and other data inside. Which files get looked up in which MPQs or CASC roots differs from file to file and version to version, until 1.32 finally made a sane and consistent hierarchy for all of them.

An aliases file FileAliases.json, located in the war3.w3mod root of the game but possibly also found through the same hierarchy, contains mappings of filepaths. This is done to prevent file duplication. The local files root is the game flavour's root directory unless the game is run with the -datadir argument, in which case that folder is used instead.

	function open_file(path)
                // Try paths until the file is found and return it
                // Note that is just a file separator used after subroots,
                // It is not much different than / for path separation
                // Imagine file_exists(specific-path) is a part of every if
		IF LOCAL_FILES: <local_files_root>/<path>
		ELSEIF HD+TEEN: <map>/_hd.w3mod/_teen.w3mod/<path>
		ELSEIF HD: <map>/_hd.w3mod:<path>
		ELSEIF: <map>/<path>
		ELSEIF HD: war3.w3mod:_hd.w3mod:_tilesets/<tileset>.w3mod:<path>
		ELSEIF HD: war3.w3mod:_hd.w3mod:_locales/<locale>.w3mod:<path>
		ELSEIF HD+TEEN: war3.w3mod:_hd.w3mod:_teen.w3mod:<path>
		ELSEIF HD: war3.w3mod:_hd.w3mod:<path>
		ELSEIF: war3.w3mod:_tilesets/<tileset>.w3mod:<path>
		ELSEIF: war3.w3mod:_locales/<locale>.w3mod:"<path>
		ELSEIF TEEN: war3.w3mod:_teen.w3mod:<path>
		ELSEIF: war3.w3mod:<path>
		ELSEIF: war3.w3mod:_deprecated.w3mod:<path>
		ELSEIF /*try opening by alias*/open_file(get_alias_for(path))
		ELSE: error, not found
	endfunction

The order of less commonly used subroots like teen, tileset, and locale ones is not 100% tested, but they are all loaded before the path with none of them.

The tileset checks in the hierarchy are only possible once you partially load war3map.w3e because that is when the tileset is defined. Not very troublesome for CASC, but for MPQs it means you have to open and close the correct tileset MPQ every time you switch maps.

For an implementation and any potential updates, check Hierarchy.ixx

PS: The order of MPQs for older patches is (loosely) described in Extracting game files (MPQ and CASC)

Clone this wiki locally