MPQ (File Format)

From HIVE
Jump to navigation Jump to search

The MPQ format is used to package and compress many files into a file system similiar to a ZIP file. MPQ stands for Mo'PaQ, which in turn comes from the name of the format's creator, Mike O'Brien. Mike O'Brien was a game designer working for Blizzard Entertainment, and Blizzard Entertainment continues to use the format.

MPQs used in Blizzard's games generally contain a game's data files, including graphics, sounds, and level data. The format's capabilities include compression, encryption, file segmentation, extensible file metadata, cryptographic signature and the ability to store multiple versions of the same file for internationalization and platform-specific differences. MPQ archives can use a variety of compression algorithms which may also be combined[1]

StarCraft II Usage

In StarCraft II, most of the stored files are stored in renamed MPQs. For example, Liberty.SC2Assets is actually an MPQ under a different name. todo:explain what is in each of the SC2 MPQs

MPQ Editing

MPQs can be edited with a number of freely available programs. See MPQ Exporting for more details.

File indexing

In order to meet the requirements of speed generally demanded by a computer game, files are indexed in a hash table using a quick, low-collision hashing algorithm. The index of a specific file within the hash table is the hash of the uppercased filename modulo the size of the hash table, allowing for quick verification of a file's existence within the archive. If multiple files within the archive have the same hash, colliding entries will

Encryption

Both the block table (which contains information on where the file data is located in the archive) and the hash table used for file indexing are encrypted when stored. The encryption process which is used by default uses a known algorithm.

Revisions

The file header reserves space to contain format version data. Warcraft III ignores format version data of .mpq complient files it loads and assumes all are version 1.

Version 1 was used before World of Warcraft. Version 2 added an extended header to the format which contained data for an extended block table to allow for larger archive sizes.

Archive metadata

MPQ archives do not have specific structures to store metadata beyond what is absolutely necessary to access archived files. Instead, the convention is to use regular files whose filename is enclosed by parentheses.

Below are known metadata files.

(listfile): Contains a list of the archive's files, one filename per line. May or may not be exhaustive. (signature): Contains the weak cryptographic signature of the archive. This type of signature is deprecated. (attributes): Contains extended file metadata. Currently known attributes are file creation date, CRC32 checksum and MD5 checksum.

Compression

In modern MPQ archives, each segment (or sector) of a file can be compressed using a combination of compression algorithms. A header byte is prepended to every compressed sector to indicate which compressions were used. The order in which those compressors are applied is hardcoded.

The following algorithms are currently in use by Blizzard games:

PKZIP (licensed from PKWARE). The first compression algorithm available. Huffman tree compression combined with ADPCM 4:1 compression (both introduced in StarCraft). Latter algorithm is lossy and only suitable for raw PCM input data. zlib (introduced in Warcraft III). bzip2 (introduced in World of Warcraft). LZMA (introduced in StarCraft II). Since there was only one compression algorithm available when MPQs were first deployed in Diablo, those archives used a different archive file metadata flag to indicate compression and did not use a compression header byte.

Warcraft III cinematics

Cutscene cinematics with the MPQ extension are included with Warcraft III and, despite the file extension, are not actual MPQ files. Rather they are AVI files compressed with Blizzard's renamed MPEG-4 codec, BLZ0 (which actually is DivX). These files are playable in ordinary media players, provided the proper codecs are installed. Blizzard probably used the MPQ extension on those files to hide them from players, who could have spoiled the game by seeing them out of the gameplay. Nonetheless, World of Warcraft cinematics use the AVI extension.

DBC (WDBC) files are collections of data records used in World of Warcraft's client-side database. They are found within the MPQ files in the game. .DBC files organize the client-side information necessary to run the game correctly.[citation needed]

Usage in gaming

Blizzard has utilized the MPQ file format for archiving game files in a number of their games, including:

Diablo Diablo: Hellfire developed by Synergistic Software Lords of Magic developed by Sierra Entertainment Diablo II Diablo II: Lord of Destruction StarCraft StarCraft: Brood War WarCraft II: Battle.net Edition Warcraft III: Reign of Chaos Warcraft III: The Frozen Throne World of Warcraft World of Warcraft: The Burning Crusade World of Warcraft: Wrath of the Lich King World of Warcraft: Cataclysm StarCraft II: Wings of Liberty

References

1: http://en.wikipedia.org/wiki/MPQ