How does Starcraft 2 load its metadata?

Lets say you are playing Starcraft 2 melee map. The game loads the map.
Melee maps have the following dependencies:

  • Liberty (Mod)
  • Liberty Multi (Mod)

I think the game engine will load the data from Liberty (Mod) first, then from Liberty Multi (Mod). For data that exists in both dependencies, the engine will use the one from
Liberty Multi (Mod). Is this correct?

Liberty Multi (Mod) is updated with each patch of Starcraft 2.
Does the game engine load just the latest version of Liberty Multi (Mod)?
Does the game engine load all the versions and overwrite duplicate data with the latest version?


You are very close to understanding how the system works. My answer won’t necessarily be how Starcraft works – but most moddable games work like this; and Starcraft is either very similar or the same.

Firstly the mod system would have some form of a header file for each mod. This would list any ‘base’ dependencies: in the instance of “Liberty Multi” it would list “Liberty” as the only base mod. This is basically used to build a chain of names and nothing more, so what you are looking for at the end of the day is:

  • My Cool Map (more on this later)
  • Liberty Multi
  • Liberty

When you need to load an asset you would search the mods top-down. Starcraft would therefore look in Liberty Multi for assets and then Liberty. MPQ (Blizzard’s zip-like files) are actually quite good at this as you can very quickly determine if a file is not present. If the file is not present look through any additional base mods. Something like the following pseudo-code:

routine findAsset(string assetName):
  let mods = "Joes Mod", "Liberty Multi", "Liberty"
  each mod in mods
    if modFileExists(mod, assetName):
      return loadAsset(mod, assetName)
  raise error "Asset not found" -- Or return a default asset for the asset type

You could even pre-build a table that contains the resolved file table for all the mods that are loaded – again investigate on how MPQ would make this possible.

Some systems let you skip the asset discovery and load an asset directly from a specific mod – this helps when, for example, a mod wants to call a script from the base mod that it has a new implementation/override of.

Starcraft overwrites assets when a patch is released. The engine is unaware of previous versions; except a routine which is used to upgrade (or translate-on-the-fly) previous save games and replays. If you remove something from the game you must leave the tombstones in your assets so that you don’t get missing textures etc. for replays.

Finally remember that, in Starcraft specifically, a map is actually the first mod in the chain; and it is due to this that maps like DoTA were possible in Warcraft 3 (which is the code-base for Starcraft 2).

Source : Link , Question Author : chobok , Answer Author : Jonathan Dickinson

Leave a Comment