Thursday, 30 October 2014

External launchers in C#

Hey guys, back from vacation, time to discuss external launchers in C#.

As mentioned previously, an external launcher is what you would typically think of when somebody refers to a "launcher". It is a separate EXE, usually used to check the game's version and login if necessary. Common examples of this are EVE Online and Minecraft (previously World of Warcraft, RIFT and many other MMOs before the introduction of multi-game launchers like Glyph and Battle.net)

I'm not going to be delving into the code regarding checking versions or logging in, but in terms of making it function as a launcher. There is only 1 line of code needed:

System.Diagnostics.Process.Start(pathToFile);

This line of code will run any file given to it using whatever the default method is for that particular filetype.

It can be used for EXE files, which is all we really need right now.
This is the line of code you need to make the launcher actually LAUNCH your game.

Now in terms of checking versions, I'm not going to talk about the code behind it, but there are a few common ways of doing it:

verNo Check - A simple check that connects to the server and downloads a version number from it, then compares it to the one shown on the game. If they match, no updates are needed, if the server shows higher, time to patch, if the game shows higher, you either fuqed up your code, or the user fuqed up your game.

File Check - This one is considerably more complex, but also much more reliable. This checks the actual content of the game's files, to ensure that they match completely. With a check like this, you can avoid your users editing game files in order to cheat.

As for logging in, that's as simple as checking the user and password with ones stored on a remote server, although as with any secure login system, I strongly suggest you encrypt or better yet Hash (irreversible encryption) the password BEFORE SENDING.

Simply store a hashed version of the password on the server, instead of a plaintext one.

No comments:

Post a Comment