Game Patcher?

All I want is to program a simple launcher that will allow players to launch the game and change settings. This launcher will also function as a game patcher.

For this, all I want is for the game to be able to download a new, updated .jar file.

Is there an established way for doing this? Also, how can I track the completion of the download to make a status bar?

Thanks a bunch,

Nathan

No, there is no established way, but take a look at
http://downloads.puppygames.net/SetupDroidAssault.exe
http://downloads.puppygames.net/DroidAssault_MacOSX.zip
http://downloads.puppygames.net/DroidAssault.tar.gz
and see how they work. (Code’s not obfuscated, just decompile installer.jar which also contains the tools used to build the deployment jars and index files)

Cas :slight_smile:

Much appreciated.

I am wondering about that for a while now for my current project. I want to easily distribute the game to friends. I have the server+bandwith but not the tools. Is there really no established way?
It’s about time somebody wrote something. Maybe I will provide mine if I can come up with something useful.

What I would do is ask the server how many bytes are in the patch. Then as you download the new JAR, calcualte how many bytes you are downloading, and make a proportional prgoress bar out of that

Each version will require a version.txt file or something similar which contains the version number.

The patcher downloads the current version.txt from the server and compares the version numbers.

If they are different (or the client-side version is corrupt (not a number) or missing) then it downloads the new game files.

To download the files from the internet, you use create a URL and use url.openStream() as the input stream, and the output stream is just a file.

Then, you need to use ProcessBuilder.

You set the directory to the folder that the game jar is in.
You set the application to “java”, the commands to “-jar Game.jar”
Then you execute the processbuilder (which launches the game) and exit the launcher.

(if you use the err/out streams then you may need to handle those from the launcher)

Some people write that JAR as an applet and add it to the frame.

One should use GetDown for patching n stuff. Things that can be tricky are: to have write access in the folder, because its usually in a protected area. Also if you just have one jar you couldn’t replace the self jar while its running n stuff.

I personally dont use it YET, is simply because of server cost - you would have to have stable server with enough traffic bandwidth and so on.

I’ve been working on making my own GameUpdater libraries and I started with C# because it looked easier to me. I just finished and am now going to make one in Java (mainly because C# apparently isn’t easily multi-platform, if it wasn’t I would just use the C# one). The source may help you if you’d like to make your own. I’ll update this post with my Java one when I finish that, but for now I will just have my C# one posted.

EDIT: I finally finished the Java version. I stayed up way later than I normally do because I forgot to add 1 to Calendar’s month lol. I’ll add a README to the repository tomorrow because I’m too tired right now. This is a library, by the way, so if you want to use this as your library, go ahead. Do you think it should go into tools or something? I would be amazed if this was good enough for that (though it is incredibly basic). It requires Java 7 as Java 7 added really helpful file functions. That shouldn’t be too much of a problem however. If you use it as a library, be sure to use it in a separate JAR than your game JAR, so that it can update your game JAR. It can’t update itself (I assume that would cause an error but I never tried that). It wouldn’t be too troubling to have (for an example I’m using my game PixelZombies as the title) PixelZombiesLauncher.JAR and PixelZombies.JAR. Likely you could put PixelZombies.JAR in a folder so that noobs don’t see it and click on it (though that wouldn’t be the end of the world if they did). I’ll say most of this in the README I make tomorrow but it will be in more depth, so stay tuned for that.

Both READMEs are now high quality. I’m pretty proud of the libraries, I think they could be used for game launchers pretty easily. If you’d like to get information on either one of my two libraries, click on the link and the README is quite massive for both.

EDIT: As I saw your (StonePickaxes) post request a progress bar, I am implementing a progress bar, although it’s just via the console. To make it work nicely, you could write a batch script that users click on so that they can see the progress on the cmd screen. It’s done on the Java version now I believe and I will now work to put it in the C# version.

EDIT2: I have now finished adding the printing of progress. I think I’ll make a topic for these two libraries in a few hours, since I see them as good enough to do so.

I’ve used getdown in the past, it’s not perfect, but it does save me writing my own. It seems to work quite well for the little I’ve done with it.

Endolf