Mostly Harmless
Package map
The package map is a collection of packages that need to be available on all clients in network games or during demo playback. The package map is commonly referred to as "ServerPackages", although the ServerPackages list doesn't contain all packages that are added to the package map.
Adding to the package map
The package map generally contains packages from two sources. One source is the level package currently being played. That package and all packages it requires (mostly textures, sounds and meshes, but also classes) are automatically added to the package map, because the level would otherwise not be playable. The second source in Unreal Engine 1 and 2 is the ServerPackages list in the [Engine.GameEngine]
of the main configuration file. All contained packages and the packages they depend on are added to the package map as well.
There's one exception, packages marked as serverside-only will not be added to the package map, because they are not supposed to reach the client. As a result, packages the client requires must never depend on a serverside-only package.
Packages in the package map are usually downloaded to the client's cache folder, if the client doesn't already have the package. If, however, a package is not marked as allowed to download (which all packages are, unless the package flags are explicitly changed), the client will not be able to connect to the server unless the package is already installed.
Dynamically adding to the package map
Starting with later Unreal Engine 2, packages no longer need to be added explicitly through the ServerPackages list.
In UT2004, packages can be added at map startup via AddToPackageMap(). This function can only be called while the GameInfo's bScriptInitialized property is False
, i.e. before the GameInfo's SetInitialState() function runs. That means, mutators and server actors should call it in their [Pre/Post]BeginPlay() events. Mutators automatically do that if their bAddToServerPackages property is set to True
. For some reason AddToPackageMap() does not have any effect on demo recording, so to get proper demo files, the packages still need to be added to the ServerPackages.
In Unreal Engine 3 all loaded packages on the server that are not marked as serverside-only are added to the package map. This even happens at runtime, potentially causing mid-game package downloads when the server calls DynamicLoadObject().