- A special gift from AvP2 Team Fortress
- A special gift from AvP2 Team Fortress - part 2
- A special gift from AvP2 Team Fortress - part 3
DOWNLOAD THE MOD LAUNCHER HERE!
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:
- version checking
- fetching the update/patch
- executing the installer
- starting up the game
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):
- It performes a version check. If an update is found, then
- The user is notified that an update will be downloaded and installed
- 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)
- 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.