GameInfo.txt file describes to the SDK tools and Source Engine which content is needed for a particular MOD or game. It is how the tools and engine know to load Half-Life 2, Counter-Strike, or Half-Life 2: Deathmatch content when they are running in the MOD's game directory. It also is a marker that the tools use to find your game directory.
Note: Only a programmer setting up a MOD project right at the very beginning ever need edit this file. In most cases, you won't need to edit it, but if you want your game to be based on content other than Half-Life 2, then you'll need to modify it. Once this file is setup for your MOD, it should be shipped with the MOD's content. The same
gameinfo.txt file should sit in the game directory of all developers working on the mod.
Basic GameInfo.txt usage
The main relevant thing in the
GameInfo.txt file is the
SteamAppId variable. If you look inside GameInfo.txt, you'll see a section that looks something like this:
SteamAppId 220 // This will mount all the GCFs we need (240=CS:S, 220=HL2).
SteamAppId value specifies which game content (Steam .GCF files) is accessible to the game for this
SteamAppId values for the core Source games are:
|Half-Life 2: Deathmatch||320|
Advanced GameInfo.txt topics
This section describes various components of
GameInfo.txt in greater detail
GameInfo.txt files should contain a line like this:
This is a special case that tools use so they can load special content that is used by the tools, but is not used by the games. For example, the Hammer Editor uses a special material to draw the red translucent highlight on displacements when they are selected, and this is how it knows where to find that material.
SearchPaths section of the
GameInfo.txt file describes where the content is to be found, either on your hard drive or inside Steam cache files. To understand this part, we must take a detour into how programmers using the Source engine access the game's files. All files that a programmer accesses in code must exist under a path ID. A path ID describes one or more locations on your hard drive or inside virtual Steam file systems.
As an example, most of your game's resources like scripts, sounds, model files, and materials are accessed under the
"Game" path ID. A programmer might say, "open a file called
scripts\weapon_m4a1.txt inside the
'Game' path ID". If you were running a mod in
C:\MyMod\Blasters, and you used
SteamAppId 240 which would load in the Counter-Strike: Source content, then it would look for the file in these locations:
<Steam install directory>\Steam\SteamApps\username\Counter-Strike Source\cstrike\scripts\weapon_m4a1.txt
<inside the virtual Steam file system>\cstrike\scripts\weapon_m4a1.txt
Using path IDs to describe where the files are saves the programmer and artist from having to worry about all these different directories. They can use names relative to the game directory (like
materials\brick\brickwall001a.vmt) and the engine and tools will find the full path to the file wherever it exists, as long as
GameInfo.txt describes what the
"Game" path ID means.
GameInfo.txt file, there is a section called
"SearchPaths", which describes the path IDs. Most mods will never need to modify the way these are setup from the way they are created when you run Create a Mod from the SDK launcher.
The first part of each line is the name of the path ID, and the second part is where to look for files when this path ID is used. A simple example, which is illustrative, but you would never use (because it uses absolute paths including drive letters, which you can never assume exist on a user's machine) is this:
If a programmer were to write code that asked for scripts\weapon_m4a1.txt and specify "TestPathID" as the path ID in code, then the engine would look for the file in these locations:
Since the Source games access most of their content in the
"Game" path ID, they do some things for you automatically if you have a path ID called
"Game". For each entry with a path ID of
- It adds a
"GameBin"path ID, in
- It adds another
"Game"path in front of it with
_<language>at the end. For example:
c:\hl2\cstrikewould get a
c:\hl2\cstrike_frenchpath added to it if you were running on a French-localized machine.
For the first
"Game" search path:
- It adds a search path called
"MOD"under the same folder.
- It adds a search path called
SearchPaths that would be used in most MODs are like this:
Game |gameinfo_path|. Game hl2
Normally, a path specifier (the part on the right side) is relative to the base directory --The directory where
hl2.exe is found. If
|gameinfo_path| precedes the path, then it is relative to the directory where
GameInfo.txt file instead. For example, if the
GameInfo.txt file were in
C:\MyMod\Blasters, and it had a path like
|gameinfo_path|SomeTestDirectory, then the path ID you were creating would refer to:
For Counter-Strike: Source, the
GameInfo.txt file has a
SearchPaths section that looks like the one above. If your Counter-Strike directory were:
C:\Program Files\Valve\Steam\SteamApps\username\Counter-Strike Source
then it would be saying to look in these two directories:
C:\Program Files\Valve\Steam\SteamApps\username\Counter-Strike Source\cstrike
because GameInfo.txt exists here.
C:\Program Files\Valve\Steam\SteamApps\username\Counter-Strike Source\hl2
which only exists inside a virtual Steam file system.