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.

Disclaimer
This post is intended for educational use only.
I am in no way or shape responsible for any damages done!
Please make sure you made adequate preperations before proceeding.

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):

{
	"builings":[
		{
			"acceptsWorkers":6,
			"availableHomes":0,
			"bedsAvailable":0,
			"colGenCounter":0,
			"colGenMax":0,
			"colGenPercentage":0,
			"constructionCounter":13000,
			"constructionPercentage":0.99540581929556,
			"constructionProgress":{
				"Ore":0,
				"Steel":0,
				"Gold":0,
				"Microchip":60
			},
			"constructionQueue":null,
			"constructionTotal":13060,
			"consumptionCounter":0,
			"dX":12,
			"dY":45,
			"def":"Gold Synthesis Lab",
			"generateAmount":1,
			"generateCounter":0,
			"generatePercentage":0,
			"generateTime":1000,
			"generates":"Atmosphere",
			"howManyWorking":0,
			"id":5591,
			"isUnderConstruction":true,
			"jobsAvailable":0,
			"lowPowerMode":false,
			"name":"Gold Synthesis Lab #5591",
			"noConsumptionMode":false,
			"occupiesTiles":null,
			"openForEntertainment":false,
			"openForTourism":false,
			"owner":0,
			"patients":{},
			"patrons":{},
			"tourists":{},
			"requiresWorkers":true,
			"residents":{},
			"smeltCounter":0,
			"someoneWorking":false,
			"workerCheckCounter":0,
			"workers":{},
			"x":12,
			"y":45,
			"deactivated":false,
			"miniDef":null,
			"openForMedical":false
		}
	]
}

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!
And…

NOPE!?

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,
And…

ARE YOU KIDDING ME!?

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:

{"isUnderConstruction":0,"constructionCounter":0,"constructionPercentage":0,"constructionProgress":null,"constructionTotal":0}

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 xD

So 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,
And….

VICTORY!

Yes, I know I need more solar panels 😀
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 G33k Out!

Comments ( 5 )

  1. Ryan Cavitt (Kira)
    This does not work. No matter what encoding I use, the base64 decoder will not decode the file.
  2. Scott DeWitz
    How do you add the code to the game plz tell me
    • FinlayDaG33k
      It has been said multiple times in the guide: Go to the main menu hit More Options and then Game Data. It should say "Restore a game file (*.mcz)", if so, click that and load the save file you've editted
  3. Scott DeWitz
    How do you add it

Leave a reply