Cheating on My Colony for Fun and Profit? pt.1 - Finishing your Buildings

Hey G33ks,So I play the game called My Colony.
I do love it, however, I have the tendency to get in some resource problems.
Due to this, I have decided to see if I could cheat.
However, because I couldn't find any guides online, I have decided to do my own research.
I do, however, not use this cheated save as my main.
I backed up the original before proceeding.
This part is focusing on Finishing buildings, not on getting more resources, people or making the United Earth (who still owes me tax money) or my colony like me more. Again, I do not endorse cheating!In case you're wondering why I did this?
Just for fun, and to show you that having a game that can switch between offline and online mode with the click of a button is a bad idea unless you have a decent protection build in. 

Reading Parts list

Because this is a multi-part research, here are the links to all parts:

Getting the Save

Of course, it all started with fetching the save.
In my case, this was rather simple as I played on PC (with Chrome/Vivaldi).
All I had to do was go to the main menu , hit More Options -> Game Data -> Backup Game File and then select the world . (yes, my world is called Hentaii!, don't ask).
I saved the world as hentaii-.mcz

Learning how the save works

So I hoped that the save worked like pretty much every way of saving I've seen so far:
Just a little XML file with all the data.
I generally don't like XML, but for editing saves, it would be a lot easier :)Unfortunately, this was not the case.
Fortunately, it wasn't very difficult to figure out how it works.
Because I want to save space (and resources), I decided not to show the save-file here, instead, I dropped it in this Gist (proceeding at own risk!).If you had the guts to view it, then you may have figured it out already.
But for those who don't: the save file is encoded in Base64!
Running the file through a base64decoder showed me that it was simply JSON, but encoded with Base64.
Base64 does offer a bit of compression, but except for that, I didn't really see a reason to use it.
I think using Gzip would be a better choice? (or maybe both together? I don't know, I'm not really into that stuff)
Anyways, now that we have the JSON we need, I could continue! 

Editting the save

Because I've worked with JSON in the past, and PHP is my favourite language, I decided to make a little script in PHP.
It consists 2 parts, which are slapped together in the same file:

  • The uploady thingy

  • The edittor

First, I had to figure out how the structure of the save-file was.
However, I couldn't use my favourite online JSON parser...
So I had to go in blindly with lots of trial & error.It took me nearly no time to figure out that the JSON-array was formed like this (not the full, just a stripped down version with - nearly - all info about an unfinished building and some formatting):

"def":"Gold Synthesis Lab",
"name":"Gold Synthesis Lab #5591",
Now that I had this information, I could get started with the first editing part! 

Finishing all buildings

Because I had to wait for a tonne of buildings to complete, I decided to tackle that first.
So, I created my PHP script, added an upload form, parsed the JSON in a nice array and checked if it displayed all my buildings.Now I had finished the basis, I could try to make the game think my buildings are complete!
This was the part I actually got confused.
Looking at the JSON in the save-file it said "isUnderConstruction":true, so I thought: it's as simple as flipping that to false and it would be complete right?
So, I headed over to main menu again, hit More Options -> Game Data , restored the save-file,
And...I was disappointed...
At first, I thought the save didn't get saved properly (it was hard to check lol), but after looking at the SHA256-hashes, I figured that wasn't the problem.
After a little while, I noticed something:
The constructionCounter, constructionPercentage, constructionProgress and the constructionTotal weren't the same as a finished building.
So, I had to edit those as well!With that done, I could test it again, to see if it worked!
Card image cap


What could be wrong then?
Well, after a little bit of troubleshooting, I realised that the JSON didn't get updated in the way that I wanted it.
And after some more troubleshooting, I figured out that the script didn't exactly loop through all the buildings... odd...Then, it struck me... a big facepalm moment.
Instead of looping through all the buildings, I actually looped through the regular save file stuff (like the world name, world creation date etc.)...
Why didn't I realise it earlier lol...Well, I patched it up, and count worked properly this time, JSON looked great as well.
Let's give it another shot.Again, I headed over to main menu , hit More Options -> Game Data , restored the save-file,
Card image cap


Guess I have to head over to the drawing board then...
A long time of thinking, I noticed something was off, just before the buildings-section of the save was finished, there where lines filled with this junk:

Yea, that should definitely not be there lol...
After a crap tonne of troubleshooting, I finally realised something:
It wasn't an issue with my code, it was an issue with contamination due to all the failed attempts I've made xDSo what I did was copy the backup, run that through the script (which I've added a few lines to, just for consistency, take the output, put that in the save file, import the save file in the game again,
Card image cap


Yes, I know I need more solar panels :-D
Unfortunately, it didn't work on the pavements, but ah well :-) 
I hope you guys like this little research thingy if you do, feel free to build upon it!
I hope the game dev notices this, and implement a potential fix because this makes it really easy to create a big commonwealth in no time.
I put pretty much a whole day in just this part.
I will continue on the resources themselves, but until then, don't break the game too much <3[g33kout]


Leave a comment

Please login to leave comment!