Auto Updater?

BlitzPlus Forums/BlitzPlus Programming/Auto Updater?

JoeDude36(Posted 2013) [#1]
Is it possible to make a auto updater or something like it. I think I know how to make a button to click to go to a website with a download of a new version if there is a new version, but is it possible to make something that could automatically download a new version if there is a new version.

If your thinking of a server to hold the contents I would appreciate a how to like, would I use Filezilla or something


Kryzon(Posted 2013) [#2]
Yes, it is possible.
If you have a personal website (http://mygamewebsite.com), you can do it with CPanel or other file managers.

In your game folder (installed in your players' systems) you need two executables: one is the game program, the other is the auto-updater program.
What you arrange for people to "click" to play your game is a shortcut that points to the auto-updater, not the game.

When the auto-updater runs, it checks for internet connection. In case there's no internet connection, it just quits and runs the game.
If there is an internet connection however, it tries to read a file with a fixed address in your website: http://mygamewebsite.com/updates/version.txt.
What this 'version.txt' file contains is the latest version number of your game, and a list of files that were modified in this update. The auto-updater program interprets this information. If the latest version number in this online file is different than the version number in a local file in your game folder in the user's system, an update is necessary. The auto-updater program downloads the appropriate files.

An example of what this 'version.txt' file in your website may contain:
version (11_07_2013)

file (GameUpdate_11_07_2013.exe) (bin\MyGame.exe)
file (Level_2_fix_11_07_2013.b3d) (data\models\Level_2.b3d)
file (MenuClick_3_fix.ogg) (data\audio\MenuClick_3.ogg)
The first line is read and interpreted to find the latest version number. It's a simple string comparison: if the string value "11_07_2013" is different than the string value in a local version file in your game folder, you need to update.
The files to be updated are described by these file (from) (to) statements.
These files are addressed relatively. The update files in your website should be at http://mygamewebsite.com/updates/(filename)

You can format this information in any way you want, I just went with what's simpler to interpret in code.

Once the update is commited (all update files are downloaded, the obsolete files deleted and the update files renamed to take their place), the auto-updater rewrites the version number in that local file in the game folder (so next time it runs, it doesn't download the update files all over again), and executes the game. This local version will be compared to the online version next time the auto-updater is run.

This is all very simple just to illustrate. You can certainly have more sophisticated version control and updating, download an entire update package instead of separate files (much better, since you can compress it like hell so it's small to download) etc.
You can do the above with BlitzPlus and the network commands. You just need to read up on how to use them. Search the forums for threads on the subject.


JoeDude36(Posted 2013) [#3]
Thanks Kryzon