Page 1 of 1

How to go about making a updater

Posted: Fri Nov 08, 2013 10:48 pm
by Oster200
So I want to make a auto updater that checks to see if the program or game needs to be updated. I have thought of different ways of doing this like having one file that has the version in it and when the server reads it, it will than know to remove/add files to the client.
The other way was just having the server read all the "important files" and if one is missing or needs updating that it would.

I don't know how to do this though because libcurl or curl can transfer data using many different methods like http for example. if i use http to connect to a part of my website how do i get it to check all this etc?

To give you a better idea it should be like updating a game on ps3 or xbox360.

Re: How to go about making a updater

Posted: Fri Nov 08, 2013 11:24 pm
by The_Glitch
If your using Windows just google update library or something along that nature, you will find a ton of them. Some are really independent they don't even need msvc. Again assuming your using windows.

Re: How to go about making a updater

Posted: Sat Nov 09, 2013 5:24 am
by Oster200
Well i really only found one which was Win sparkle but that should work. What other ones did you see that were free?

Re: How to go about making a updater

Posted: Sun Nov 10, 2013 1:18 am
by Oster200
Yeah i cant get winsparkle to work so...I dont know what else.
Because if i made one some how i would have to tell the updater to place these files were they need to go and i dont know how to do that
any other library you know of

Re: How to go about making a updater

Posted: Sun Nov 10, 2013 9:01 am
by hendu
Perhaps this should go in the beginner help side ;)

You need to code that. It's not particularly difficult, your idea of version numbers would work. Store a similar file on the server, compare each version, download all new files.

The only gotcha is that Windows, that weird and restricted OS, doesn't let you overwrite a file while it's in use. So your updater needs to be a separate exe so that it can update your main exe.

Re: How to go about making a updater

Posted: Sun Nov 10, 2013 5:13 pm
by Oster200
hendu wrote:Perhaps this should go in the beginner help side ;)

You need to code that. It's not particularly difficult, your idea of version numbers would work. Store a similar file on the server, compare each version, download all new files.

The only gotcha is that Windows, that weird and restricted OS, doesn't let you overwrite a file while it's in use. So your updater needs to be a separate exe so that it can update your main exe.
Yeah i wasn't sure how advanced this would be so i just put it here. Yeah i was thinking i don't know if this would work or not but could i just make the updater exe the start of the game. You would run that first which would open up the updater it would check than open the game exe and close itself?

The other thing was i would like it to update files not necessarily the whole application so this is kinda a long way but if it finds it is out of date download a file that tells where all these files should be placed? for example i could have it read first line which would be file name store that. read second line which would be destination store that than find that file and put it where it tells it. if there is more than one file it would move on the the 3rd file store that file name where it stored the first since the first is placed already. and i think you get the point.

Problem with this though is that i haven't really ever worked with destination stuff in a application where you have to move a file. i can only think of using environment labels but would rather not do that. But i was thinking since the root directory for the game would be the same as there's the exe should be in the same place so all the files could be downloaded in a folder in the game directory and than moved correct? or is there a better way of doing this?

EDIT: I was trying to use libcurl to download a zip file using http for example http://www.example.com/test.zip and i just cant figure it out. I guess how my application is looking its only going to be for windows so no need for it to be cross platform. Any way to download a zip from url?

Re: How to go about making a updater

Posted: Mon Nov 11, 2013 11:52 am
by CuteAlien
As Hendu mentioned, it's easiest to work with a separate exe (there are some ugly tricks to work around that, but don't go there).

We use some update.txt file which contains information about the last update and we send that to the server when requesting a new update. The server then uses that information to decide which files to send. Don't know if that's the best way to do it.

For finding destination paths you have basically 2 choices. If it's only about data then you can use some standard paths like AppData which Windows supports (there is a function in the Windows API to find the users AppData folder). Although I must admit I don't like that too much as user, because Windows does set AppData once on Installation and won't let a user move it later which is a real pain if you put it on a small sdd disk which is slowly filled up by applications. So please only use that if it's just small amounts of data (new configurations etc). There are other user-data folders like for Pictures and Documents and Games, I have not worked yet with those from an application, but they would have the advantage that users can move those folders around. The other solution, which is used much by games, is to save your application path in some registry key on installation. You need that anyway for the de-installer. I would recommend doing that, but it certainly needs an installer (I recommend NSIS - it is horrible and has a script language from hell - but still better than all the alternatives).

If you don't get along with curl too much, we also got along better with: http://pocoproject.org

Re: How to go about making a updater

Posted: Tue Nov 12, 2013 9:43 am
by roxaz
the way i did it is make updater client do heavy lifting. server just contains file hashes, sizes and modification times. client decides which files are out of date and should be obtained. then on the server side its plain http server, nothing more. i even put together delta updating using xdelta. its not that complicated at all.

Re: How to go about making a updater

Posted: Tue Nov 12, 2013 9:56 am
by CuteAlien
@roxaz: How does your client figure out when there are new files on the server?

Re: How to go about making a updater

Posted: Tue Nov 12, 2013 11:32 am
by AReichl
There is a game made with Irrlicht: "SpaceCombat"
http://spacecombatgame.sourceforge.net/
It has an integrated updater and the sources are available.
I know it's some work, but maybe you can find something in there.

Re: How to go about making a updater

Posted: Fri Nov 15, 2013 1:47 pm
by roxaz
CuteAlien wrote:@roxaz: How does your client figure out when there are new files on the server?
its simple: server hosts update.manifest with file hashes, sizes and modification times. client downloads update.manifest, iterates all files, calculates file hash if needed, if it does not match hash in update manifest - file needs updating. in case of delta updates i have a "chain" of deltas on server too. basically if calculated file hash on client machine is in chain of deltas - it downloads following delta updates for a file. for example delta chain like:
0 ABC
1 BCE
2 CEF
3 EFG
where number is "revision" and letters are hypothetical hash. suppose file hash on client side is BCE then it will fetch deltas for revision 2 and and 3 and apply them in that order.

Re: How to go about making a updater

Posted: Fri Nov 15, 2013 6:37 pm
by CuteAlien
Thanks for the info, also a nice way to solve this.

Re: How to go about making a updater

Posted: Sat Nov 16, 2013 9:57 am
by hendu
I haven't used deltas so far in my apps, but instead of storing so many deltas, I would simply use zsync. One file on the server, the client figures out which parts have changed.

Re: How to go about making a updater

Posted: Mon Nov 18, 2013 4:24 am
by Oster200
Okay so i did not leave this conversation at all, I just have been busy. NSIS actually looks very nice and i started to just goof around with it and it works well. I could use this to temporally make and updater for the game because i was looking for something quick and easy. The reason why i dint chose libcurl is because as i said i wanted something quick and easy so i tried a couple things and it did not work so i think i will go back and read some of the command on how to download file using http. So far my tests have not worked best i have gotten is get the web page which is a example.