Unlocking chapters in your mod
Valve Approach
This approach shows the best way to update chapters in your mod. download
Updating
In gameinterface.cpp
, modify void UpdateChapterRestrictions( const char* mapname )
and the array static TITLECOMMENT gTitleComments[]
to conform to your maps' naming format.
Each TITLECOMMENT in gTitleComments contains a char* pBSPName
(the map name or part of a map name) and a char* pTitleName
(the chapter that map or set of maps is part of). If you want the map e2m4 to be part of Chapter 2 of the mod Doom, add {"e2m4", "#Doom_Chapter2_Title"}
to the array (with a trailing comma if it's not last, of course). Replace "e2m4" with simply "e2" and all maps starting with "e2" will be part of Chapter 2.
Note the comment right above gTitleComments, which reads "This list gets searched for the first partial match, so some are out of order". Meaning, if e2m9 is part of Chapter 3 and the rest of the "e2" maps are in Chapter 2, then {"e2m9", "#Doom_Chapter3_Title"}
must come before {"e2", "#Doom_Chapter2_Title"}
in the array.
Necessary Fixes
UpdateChapterRestrictions has an inherent flaw which only comes to light when Steam runs a Source mod. Steam puts the mod's entire path in the command line; the mod MyMod might be run with hl2.exe -game "C:\Steam\SteamApps\SourceMods\MyMod"
.
But UpdateChapterRestrictions assumes "-game" to be just "mymod"(Mod name in lowercase), so char chapterNumberPrefix[64]
ends up as #C:\Steam\SteamApps\SourceMods\MyMod_chapter
, rather than #mymod_chapter
as it should be.
You can solve this problem in one of two ways. The first and easiest is to dispense with the "-game" parameter and simply hardcode "#mymod_chapter" as the chapterNumberPrefix. The second, which may be copied and pasted across mods, is to lop off the parent folders one by one, perhaps with strtok, until only the mod folder is left.
rockband