How to go about making a updater

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Oster200
Posts: 60
Joined: Sun May 06, 2012 6:13 pm

How to go about making a updater

Post 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.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: How to go about making a updater

Post 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.
Oster200
Posts: 60
Joined: Sun May 06, 2012 6:13 pm

Re: How to go about making a updater

Post 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?
Oster200
Posts: 60
Joined: Sun May 06, 2012 6:13 pm

Re: How to go about making a updater

Post 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
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: How to go about making a updater

Post 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.
Oster200
Posts: 60
Joined: Sun May 06, 2012 6:13 pm

Re: How to go about making a updater

Post 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?
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to go about making a updater

Post 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
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Re: How to go about making a updater

Post 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.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to go about making a updater

Post by CuteAlien »

@roxaz: How does your client figure out when there are new files on the server?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: How to go about making a updater

Post 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.
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Re: How to go about making a updater

Post 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.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to go about making a updater

Post by CuteAlien »

Thanks for the info, also a nice way to solve this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: How to go about making a updater

Post 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.
Oster200
Posts: 60
Joined: Sun May 06, 2012 6:13 pm

Re: How to go about making a updater

Post 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.
Post Reply