Login | Register

Patches and extensions

November 6, 2006, 19:46 by Calle
[loading]
-->
It is not very often that game gets finished and that it is really neccesary with a patch, but as the question gets asked a lot I will explain for one way to achieve this.

The thing with Game Maker files is that once it is compilated, it is compilated and since we don't know the file structure of the generated .exe file we won't be able to change anything in it. Therefore our new code, our patch, must be saved externally out of the game and that we must have left place for it already from the beginning.

This place that we must create for later code could be place within already used objects or it could be dedicated obejcts which from the beginning is left empty of all code but reads the code of the external source. First thing we will have to decide is how we will save that external code, a normal text file would do fine.

If I would do this, personally I would choose a textfile, but I would encrypt it. Encryption is very important if one plans to implement full code into the file, otherwise users could easily cheat by changing the code within the patch.

When you have chosen your way of saving (either it is the registry, file or some kind of binary encrypted stuff) you just need to read it into the game. You'll have to do this at start up, at each start up because of, as stated before, the fact that the .exe files can't be manipulated.

There is a very simple function for this, which I would recommend you to use:
execute_file(fname);

Before you can do this, of course, you need to decrypt the code and maybe split the patch in several files, one for each object and event (unless you have written your patch-code in such a way that it automatically check which event from which it is called and from there decides what code to execute, but it'd probably be easier to split it up).

So, now that you have the files split up in files like: create1.patch, step4.patch etc. your program/game will just need a tiny code that says that if step4.patch (for an example) exists, then execute that file in that event.

Now if I need to explain something further (maybe add a little code?), then please tell me so...

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games