Updating methods

As I said before, there are many methods that can be used for updating. I am going to explain a few, but if you don't like any of the ones mentioned, you can always try and come up with your own or search for a new way. You can also combine many of these methods together.

Hash-checking file-by-file

This is my favorite method by far, and the one I use in my engine, though it can become quite slow when theres many files. You have to have an update server that has the latest version of every file that needs to be kept up to date (which should be most of the client files, not including the files containing settings). When the server loads, a MD5 hash is made of every file, then every file is compressed. When the client checks for updates, it sends the MD5 hash of every file it has to the server. The server then compares it to the hashes it made of the newest files. If any hashes are different, it will send the compressed version of the file. The client then decompresses the file and saves it over the old one.

Pros: It couldn't get any easier for the developer - just copy over the files the client needs, and run the server. It is also very easy for the users, since all files they need are automatically downloaded. Quite an easy system to develop, too. It also helps prevent against the client editing their files.

Cons: The only real flaws I have found with this system are that, for starters, compressing each file individually isn't anywhere near as powerful as packing a whole archive. Along with that, the client has to send a MD5 hash of every file, which can add up to quite a bit of uploading from the client. Finally, there is a chance that a new file's hash will be the same as the old files, but the chance is very unlikely - there is only a 16^10 chance of that happening (very rate).

Variation: You can add a "global version" that is first checked. If the client and server global version are the same, then the MD5 hashes are no checked.

Version lists

This system can work exactly like the hash checking system, but instead of hash checks, you store versions. You have a global version, along with a version for each file. The client and server then first compare global versions - if that is different, then the server updates the files.

Pros: It is very easy for the user since it is all automatic and only the files they need are downloaded. Checking for updates is very fast, and if there is no update, very few packets have to be exchanged.

Cons: It can be quite a hassle for the developers, since they have to keep track of every file that needs to be updated. You could just keep track of the change dates of the files, but sometimes that won't tell you what you need to know.

Variation: Instead of updating file-by-file, you can send an archive and extract it, containing only the files that need to be updated. Though, this would require that you loop through the versions in order, instead of just going to the latest version.