Post feature RSS A special gift from AvP2 Team Fortress - part 2

Continuing with our launcher & update module, the second part brings the finished product. And yes, there is also a third part in the works.

Posted by on

  1. A special gift from AvP2 Team Fortress
  2. A special gift from AvP2 Team Fortress - part 2
  3. A special gift from AvP2 Team Fortress - part 3
I know, the original deal was that you'll get the mod launcher 4 - 5 days later. But it is Christmas, so here we go:


The archive you just downloaded contains both the compiled launcher and the NSIS script. This way you can make any alterations you want and personalize the launcher further.

If your mod is for a game that has a rich modding community, it is likely that other mods also use this launcher. This however might cause issues, because each mod would end up overwritting the same .ini file (assuming all launchers are placed in the same folder).

To counter that, the launcher is designed so that a launcher renamed to "Jailbreak.exe" will try to open the .ini file called "Jailbreak.ini". This way all launchers end up having sepparate ini files.

This means that before distributing the mod, make sure that the launcher.exe file and the launcher.ini file are renamed appropriately.

In this second part, we'll disect the NSIS script and try to identify the pieces of code responsable for the following:
  1. version checking
  2. fetching the update/patch
  3. executing the installer
  4. starting up the game
Open up the launcher.nsi file into a text editor; you'll find it in the "src/" subfolder of the archive. Keep the text editor handy 'cause we'll ALT-TAB to it a lot.
Now, until you do open up the .nsi file, a couple of words about what the launcher does (available also in the archive, in the readme.txt file):
  1. It performes a version check. If an update is found, then
  2. The user is notified that an update will be downloaded and installed
  3. When pressing "Play", it'll launch the game

(1) Version checking (Function CheckVersions)

This step can be further broken down as follow:
  • the .ini file is opened, and the value for the "url" key in section "[version]" is being read. The URL must point to a remote_version.ini file.
  • the remote .ini file is downloaded to the TEMP folder.
  • both launcher's .ini file and the copy of the remote_version.ini file (retrieved in the TEMP folder) are then checked for differences between the major, minor and micro version numbers.
  • if all are equal, no action is performed.
  • if the micro version numbers are different, then the "Optional update" pop-up is displayed
  • if the major or minor version numbers are different, then the "Mandatory update" pop-up is displayed

(2) Downloading of the update (Function DoUpdate)

Here are the details regarding this action:
  • the "[update]" section is located in the .ini file. Two values are read from here, "url" and "localFile".
    It is needed that the file at that given url is an executable (you can set however any file extension if the web server does not allow .exe file), and the "localFile" is properly named (having an .exe extension).
  • the HTTP client will then connect to the "url" and will download the remote file to the same folder as the launcher. The local copy will be named according to the value of "localFile".
  • the copy of the installer (or self extract archive) is then executed.
    You'll notice we are calling ExecWait here: the reason is that we want the launcher to suspend it's execution until the patch is executed.

(3) Launching the mod (Function OnPageExit)

This step consists in reading the "commandline" value from the "[launcher]" section. A simple "Exec" call is then performed with that command line.

This concludes the second part of the article. In our next (and final) part, we'll cover some best practices on using the launcher and we'll prepare some example files.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.