Game Development Community

dev|Pro Game Development Curriculum

Auto-Update Resource Fixes and Enhancements

by Robert Fritzen · 08/08/2011 (4:28 pm) · 13 comments

So, as you all know, there was a resource made available a while back that allowed developers to patch non .exe updates for their projects using a simple TCPObject overlay to download and replace content based on an MD5 file check.

This resource I found had problems with it's stream object, especially when it came to downloading two files at once, when one file had a smaller size and was "overcome" by a larger file and then ignored by the downloader object. This caused a deadlock in the download process and would miss any additional files after this problem. To address, I had to make some updates to fix this.

Thanks go out to Tom Bushby for the original resource that got the ball rolling here.

Now Requirements:
* Updated TCPObject to handle binary transfers (see this)
* File MD5 Calculator for C++ (either use this or my resource (if you are using xxz568))
* Web Capable Server with PHP installed

Now, the fixes. First of all, I handle my patcher in a significantly different route than the original one. My route specifies it as a separate directory of the game itself, instead of migrating in with the client or server scripts. Also, I've made a major amount of changes to the original resource (you might say it doesn't look anything like it), these are mostly enhancement and bug fixes that I've made to the code to get it to function correctly.

So, in the top directory of the game (where tools is), create a "patcher" folder, and load in the contents of the patcher folder of this zipped archive to it.

Then, on your web server, load the contents of the phpcode folder from that above zip archive on your server somewhere, be sure to note the directory scheme on it. change the gvars in the php files to match the needed details on directory schemes, ect.

Sample:
/home/
   /mygame/
      /patches/
         /game/
            *all game files needed to have updates and suchz0r
         *php files from resource

Now let's tell your game to load the patcher module, in the head folder, open main.cs change the following gvars
$dirCount = 3;
$userDirs = "tools;patcher;" @ $defaultGame;

Now, at this point, we just need to tell the client to initiate a download check, however you need to set the server settings. Go through the serverSettings.cs file and set the variables as necessary.

Lastly, when ready to perform an update check: call this: updateClientDownload();

Final Notes:

You should no longer have any issues downloading multiple files at once with the large file overcoming problem. Also, you can now define a $developerMode variable to help in your development process. This variable if set to true will disable the patcher system so you don't need to upload your changes every single time you make one. I put my $developerMode in main.cs at the top for easy access, you can do the same if you want.

You may also notice there are some missing variable/object stuff in the console, this is what I used for my "GUI" in the auto-update process. If you make one, see there to make adjustments.

Good luck!

#1
08/08/2011 (5:03 pm)
A very interesting resource. Thank you for the information and the example of how to control file transfer stuff useing the TCPobject.
#2
08/09/2011 (9:34 am)
This seems very useful, thanks! Only issue I see is how one might update their game .exe? Which is something that will probably need to be done for most games. Maybe use an update.exe which only performs this stuff on the game files?
#3
08/09/2011 (1:36 pm)
I haven't quite figured that one out yet, but I'll let you know if I can get something like that working.
#4
08/09/2011 (2:09 pm)
It would be worth figuring out, it's got to be possible using another small exe that can access the game.exe. I've seen a few games that use that method. I'll try to mess around with it once I get some free time. Great resource though. I'm sure a lot of people can use a system like this :)
#5
08/09/2011 (3:11 pm)
I worked around it for our game by downloading the replacement game.exe as game.exe_patch, I added a function to the game engine to spawned a seperate process on windows (need to make sure this is a seperate process group or it will be killed when the game.exe shuts down) and then quit the game.


The launched patch.exe (compiled python script) just tries to delete the game.exe looping if it hits an error with locked file (i.e. game hasn't stopped yet), then renames the file and starts the game back up.

I can post the code if it's any help
#6
08/10/2011 (6:12 pm)
Might help, only issue (might not be) is the python part. would it work for people w/o python installed?
#7
08/18/2011 (4:09 am)
Hey there Robert,

I am working to implement this - but the TCPObject requirement link seems to indicate that the TCPObject changes do not work in T3D 1.1... Can you point me to the TPCOBject changes that need to be made to get this working in T3d 1.1 final?

Thanks!
#8
08/27/2011 (10:06 am)
The TCPObject resource above should work fine.

You will just need to change instances of "ResourceManager" to match the new pointer "gResourceManager".

Also, it was mentioned that T3D uses DefineEngineMethod instead of ConsoleMethod.

Just do your research, it shouldn't be too hard to implement.
#9
08/29/2011 (5:27 am)
A bit late but a heads up, the MD5 resource listed doesn't work in T3D, but we(I and two others) did rerelease the resoucre in an updated form about a month ago...
www.garagegames.com/community/resources/view/21062

Edit... Actually this does NOT work with T3D 1.1 as is, none of the refenced resources other than the one directly above works in 1.1 , and I highly doubt beta 3, though I will be trying that later today. The primary issue is that T3D of today is barely even related to TGEA, or the other products. While once upon a time this was not true, the developments of the last year have evolved the software so that is uses few of the old methods any more.
#10
09/05/2011 (6:51 pm)
Interesting. I'd just go the Crypto++ or OpenSSL route in that case then.
#11
07/08/2013 (5:33 pm)
Hello Robert,

Do you happen to still have the updated TCPObject resource? The link for it is quite dead :( I was hoping to add auto updating to my game project, but it seems that file is nowhere to be found!
#12
08/10/2013 (5:45 pm)
Unfortunately I no longer have the exact list of changes to the TCPObject class made by that resource directly, however, I did make a copy of the TCPObject class that contains only allowance for Binary transfers (what was needed by the resource). You can grab those two files here and here. Good luck!
#13
08/20/2013 (9:03 pm)
I've managed to get it to compile after a bit of hacking up of the code to work with the current TGB build. It runs and reads the patch list, but doesn't seem to be doing anything after that :/ I'm not sure if I have the formatting of the patch list 100% correct as well. Do you remember what the appropriate formatting is for the file path on the server versus the local? It could be something else, too. I'll try mucking with it a bit more when I get a chance :)