Game Development Community

Live Update

by Chris Labombard · in Torque Game Engine · 10/27/2005 (7:40 am) · 14 replies

I esarched GG but couldnt find an answer to this.

How do you do a live update ? I want to poll my web server for the latest version number of the game. If the version numbers dont match, I want the game to request the latest update patch and patch itself.

I can handle all of this except the actual updating.

What does the server send? A patch exe? How does TGE run it ? Would I then have to restart, or juist exec all the scripts that were changed ?

I'm not really up to snuff on how updates work.

About the author

I have been a professional game programmer for over 5 years now. I've worked on virtually every platform, dozens of games and released a few of my own games, including 2 iPhone titles and a title waiting release on Big Fish Games.


#1
10/27/2005 (9:02 am)
Final Fantasy XI Online does it by running an exe that checks the version number and gets the proper files if neccessary. Then it will call a DLL with the actual game in it.

AFAIK You cant update the exe you are just running to update itself. So you would have to write an application that checks for updates and then calls your updated game exe.
#2
10/27/2005 (9:10 am)
No no no... I just want to update the scripts. I dont care about the exe. If the time comes that the exe needs to be updated I will just force an update that pops a message boc telling the player to go get it.

There's got to be a way to execute an exe, silently, from script.

To exec the scripts I will just always include a function called reSync() that execs them all :)
#3
10/27/2005 (9:20 am)
If you're not worried about updating the exe, I'd just include the update code in your engine and expose a ConsoleFunction to trigger it.
#4
10/27/2005 (9:27 am)
the update code in your engine

Is this sometihng that's already there ? or something I have to write ? I have no idea how to write something like that.
#5
10/27/2005 (10:04 am)
That's something you'd have to write. I'd imagine all of the pieces are there. You should be able to use the HTTPObject and the .zip support to download and unzip any updates.
#6
10/27/2005 (10:07 am)
I wanted to run a patch exe. I have a patch maker.

Connection and what not arent difficult. I would have to muck around to figure out how to actually get it to silently download, open and overwrite

I suppose I could just unzip new files and overwrite the old ones. I'll have to investigate the zip support. Any ideas where I should start looking in the source ?
#7
10/27/2005 (10:44 am)
Chris, I silently download files in my app. I based it on the resource www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4926

I have a webserver that servers the files, it contains a file with the current version numner. The application downloads the file and checks the version number, if different then it downloads the patch. (I added a version to my script eg: $Script::Version = 1; )

Applying the patch required code changes to bypass the resource manager. Note, if you add new files, you will either have to restart your app, or call setModPaths($userMods); via script again. I would suggest restarting.
#8
10/27/2005 (10:56 am)
Simon - thank you.

That helps a lot. Just one thing left now.

How did you make the patch execute ? Was it an executable or just files that you overwrote the old ones with ? I don't suppose you have the code that actually executes the patch that you can share? (I can handle hte rest)

EDIT:

Never mind, I will just get my amazing web guy Tom Bushby to have the php checkForUpdate script return the web address and game location of each file that needs to be updated and download them all individually.
#9
10/27/2005 (11:17 am)
Just food for thought...

If you wanted to have a little more control over your update process you could do this:

Create a serverUpdate.cs script file on your server. This file would contain a $LatestGameVersion global variable that specifies the latest version of your game. It would also contain a UpdateGame() function which takes the users version number as a parameter.

This function would then compare the users version to the latest version, and take any necessary action. For instance, if the user is running 1.03 they may only need to download 2 or 3 scripts to update to the latest 1.04 version. If they are running 1.00 they may need to download a bunch of scripts, models, and images. Or if they were running a beta version of the game, you could display a "Your version of is too old to update, please download the latest version from our website." messagebox.

Each time you release a new version of your game, you simply add the necesary logic into this file to update clients to the latest version, as well as updating the $LatestGameVersion variable.

So when clients want to update, they simply downloads serverUpdate.cs from your server, exec() it in script, and then simply call "UpdateGame($ClientVersionNumber);" which handles the entire update process. This way you can totally control the update process, since all update logic is stored in the serverUpdate.cs file located on your server.
#10
10/27/2005 (11:23 am)
Robert - right sorta.

Using $Pref::version in the prefs.cs file will make sure the version is always stored. Then instead of passing parameters, you just use the globally accessible version number.

Im going to call checkForUpdate.php and pass it the current Version number. If it's not the current one the script will return all the files that need to be downloaded.

I will record them all and then download them all and replace them sileintly.

This will all happen while hte player is watching hte GarageGames and SpunkyGames splash screens :)

It will also be done before all the normal scripts are executed... That way I dont have to restart or anyhting, the files will be replaced before they're exececuted and all is forgiven :)
#11
10/27/2005 (11:42 am)
What would the MIME type of a dso file be ?

EDIT:

application/force-download ?
#12
10/27/2005 (12:25 pm)
@Chris

I may be wrong, but from what I recall it would be application/octet-stream


Yes I am right.. a quick search on google returns this page at w3schools.com

EDIT: actually I may be wrong, because I read your post too fast- I thought you asked the mime type of an EXE. Forgive me!

You could probably use application/octet-stream anyways though, however I would still wait until GG corrects me.
#13
10/27/2005 (12:38 pm)
Someone else told me that application/force-download works :)

Thanks Thomas.
#14
10/27/2005 (12:58 pm)
Application/force-download could work too.
:)