Using the updater
From VbGORE Visual Basic Online RPG Engine
Contents |
[edit] What it does
The updater does just like it says, it updates files. A common misconception is that it will do this fully automatically for you, or that it will even update vbGORE itself. Well sorry to say, its neither of those, but it is still very easy to use.
The updater has two components. Just like the game, these components are a server and a client. The server holds the latest version of all the files and uploads it to the clients that request the download. The files then are copied from the server to the client.
[edit] Adding files
The first step to updating is to add files to be updated. All the update server (UpdateServer.exe) needs to run is the exe itself along with the \UpdateFiles\ directory. In this directory, you will see a single demo file if you have not changed anything that is basically a small read-me (in newer versions, it will link you to this page). In this directory is where you want to put all the files you want updated.
Directory structure is read and preserved. The \UpdateFiles\ directory serves as the root directory of the client. That means if you, for example, had MyFile.txt in \UpdateFiles\ directory directly, it will download to the same directory the UpdateClient is in.
Server: \UpdateFiles\MyFile.txt Client: \MyFile.txt Server: \UpdateFiles\Grh\100.png Client: \Grh\100.png Server: \UpdateFiles\Data\NPCChat\english.txt Client: \Data\NPCChat\english.txt
As you can see, you basically just want to copy over your copy of the client and all of its files into this directory, then delete those that you do not want to keep up to date.
[edit] How it all works
[edit] Compressed folder
When you run the server, you will notice a new folder pop up named \_Compressed\. What this folder holds is a compressed version of a file, along with the MD5 hash of the original file, not the compressed! This .md5 file is used for only one thing. When the server is run, instead of re-compressing every single file, the MD5 hashes of the versions in the \_Compressed\ folder are compared to the MD5 hashes of those in the \UpdateFiles\ folder. If the hash is the same, the file does not need to be updated in the \_Compressed\ directory, which saves a lot of time. This allows you to reboot the update server very quickly if it crashes, or only compress the files you change when you add new ones.
The files in the \_Compressed\ folder are the actual ones that get sent to the client.
[edit] Compression
Two types of compression are used in the updater - LZMA and MAC. MAC, or Monkey Audio Compression, is used on .wav format files while LZMA is used on every other file. The update server and client will both just decide which one to use according to the file's suffix. If you have a graphic file and rename it to .wav, it will try to use MAC on it, but will fail and no compression will be made. Likewise, if you have a .wav file and rename it to .bmp, it will use LZMA.
The compression is made at runtime on the update server and all of the compressed files are stored in the \_Compressed\ directory. The files are only compressed if the MD5 hash in the \_Compressed\ directory is not equal to the MD5 hash of the same file in the \UpdateFiles\ directory, or the .MD5 file can not be found.
The list of the server's files and information on those files, stored in the server as variable ServerFileList(), is also compressed. More on this is explained in the next section.
[edit] Event structure
The first thing to happen is the update server is loaded. During this time, the following events take place:
- All the files in the \UpdateFiles\ are found and their path stored
- A list of "short file paths" (the path of the file the \UpdateFiles\ directory) is created
- A list of the size of all the files is created
- A MD5 hash for each file is created
- A string is created that gets stored in the array ServerFileList() which contains the "short path", file size and MD5 hash (in that order) of every single file, and is then turned into a byte array and compressed with LZMA
- A loop is made that checks if any of the files in \_Compressed\ are not equal to or missing those in \UpdateFiles\ and makes the compressed version if needed
- The server opens up the socket and is ready for connections
Now the server has most all the important information it needs in RAM. The ServerFileList() contains all the information it needs to send to the client disincluding the files themselves.
When a client connects to the server:
- Server recognizes the connection, accepts it and sends the ServerFileList() array
- Client decrypts the ServerFileList() array and compares the information in that to the files it has - if any file is has different information or is missing, a request is made to the server to download the file
- Server receives a file download request (given the "short file path") and sends the client the file
- Once the client finishes downloading the file, it decompresses it and deletes the compressed version
- Once the client goes through every file and confirms them all being valid, it disconnects from the server




