🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Patcher

Started by
3 comments, last by Shaarigan 4 years, 7 months ago

My question is a basic one: how do patchers work?

My understanding so far is that the EXE is only the patcher / launcher. When it's run, it checks the files against a website or server to see if they match (I will be using libcurl). If they don't, it updates them. Then, when you hit Play, it runs the actual game DLL which plays the game.

First, is this the correct idea?

Second, in Windows (I use Leadwerks and Visual Studio Express), what's the command to launch the DLL?

Finally, how do you update the launcher itself? Does that game do that once the launcher quits? Or does the updater launch another updater DLL? I guess it doesn't matter which but what's the "right" way to do it?

Thanks!

Advertisement

Generally there are two executables - the patcher and the game. The patcher executable is the one you launch to run the game. The patcher can then update the other executable and use CreateProcess() or ShellExecute() to launch it.

Updating the patcher is a little more complicated, because you can't modify the exe of a program that is currently running. I'd go for a process something like:

- The patcher does a version check. If it's out of date it downloads an updater executable. The patcher then launches the updater and exits.

- The updater waits for the patcher to fully exit, and then updates the patcher.

- The updater can then launch the new patcher and exit.

- Optionally the new patcher can get rid of old updaters.

You'll also need to watch out for cases like launching the patcher while the game is running, or the user trying to run the game directly.

In addition make sure you check that all your API calls succeed - the update process needs to be robust in case of things like the disk being full, or the user lacking appropriate permissions.

Thanks for the thorough response! Sounds like there's still a lot to learn (about how to monitor if a program is running and permissions). Games like Starcraft make it look easy.

Starcraft has had a single executeable you needed to download to patch the game in the old days. Nowdays anything is handled by the Blizzard Launcher that is some kind similar to Steam.

There is an algorythm (I cant remember yet) that is supposed to compress a file based on the difference to another file. Only the difference is stored and so patches can be small. It then extracts the correct version of the file back to disk.

Files are nowdays tested by their hash code of MD5 or SHA256 to check for similarity. So you know what version the file is and how many versions this is away from the newest one and can perform incremental patching this way

This topic is closed to new replies.

Advertisement