Unlocking chapters in your mod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
Line 1: Line 1:
[[Category:Level Design]] [[Category:Tutorials]] [[Category:Programming]]
[[Category:Level Design]] [[Category:Tutorials]] [[Category:Programming]]


=Valve Approach=
everyone likes caramelldansen
This approach shows the ''best'' way to update chapters in your mod.
download
 
== Updating ==
In <code>gameinterface.cpp</code>, modify <code>void UpdateChapterRestrictions( const char* mapname )</code> and the array <code>static TITLECOMMENT gTitleComments[]</code> to conform to your maps' naming format.
 
Each TITLECOMMENT in gTitleComments contains a <code>char* pBSPName</code> (the map name or part of a map name) and a <code>char* pTitleName</code> (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 <code>{"e2m4", "#Doom_Chapter2_Title"}</code> to the array (with a trailing comma if it's not last, of course). Replace "e2m4" with simply "e2" and <i>all</i> 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 <code>{"e2m9", "#Doom_Chapter3_Title"}</code> must come <i>before</i> <code>{"e2", "#Doom_Chapter2_Title"}</code> 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 <code>hl2.exe -game "C:\Steam\SteamApps\SourceMods\MyMod"</code>.
 
But UpdateChapterRestrictions assumes "-game" to be just "mymod"(Mod name in lowercase), so <code>char chapterNumberPrefix[64]</code> ends up as <code>#C:\Steam\SteamApps\SourceMods\MyMod_chapter</code>, rather than <code>#mymod_chapter</code> 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

Revision as of 09:40, 21 November 2008


everyone likes caramelldansen