Evan's Blog

A story from modding the video game Planet Coaster

Back in 2020, when I was 16, I was working to reverse-engineer Cobra, the game engine developed by Frontier Developments for Planet Coaster, Planet Zoo, Elite Dangerous, etc. I was a big fan of the game Planet Coaster, and my dream was to mod the game to remove the annoying arbitrary limits in the roller coaster designer.

The goal was to fully understand the OVL file format it used to store all the game content so we could extract it and inject modified content. This progressed really well, and by the summer of 2020 we could modify database values, inject new textures, and even load custom Lua scripts to change game behaviour. I was developing some mod loading tools in parallel with the OpenNaja team, and I eventually ported their ACSE Mod Loader to Planet Coaster to allow really easy mod loading.

Showing off the game’s boot screen, with the ACSE logo

The custom Lua scripting was a very painful process. Like many game engines, Cobra used C++ for most of the core implementation, with the ability to script game logic in Lua. For some ungodly reason, it used a custom version of Lua, meaning a modified version of Luadec was needed. Thankfully this had already been built by people way more experienced than me. The output from this was often extremely garbled and required significant modification to compile and work properly once injected into the game.

There were some pretty big issues with this as we couldn’t read any log outputs or attach a debugger. This made debugging and understanding why these decompiled Lua scripts were crashing really difficult and tedious. The only real choice was to write some questionable Lua, patch it into the game, and boot it up to see an inevitable crash. Everyone who was friends with me on Steam at the time will attest I was rebooting the game 100+ times a day and spamming them with notifications!

I spent weeks digging around in the Lua APIs looking for something I could use to get some form of logging. Writing to stdout? Blocked. Writing to a file? Blocked. Sending network requests to my server? Blocked.

But I realised, clearly the game was making some network requests, I could see telemetry calls back to Frontier’s servers for analytics and logging! There must be some kind of whitelist somewhere. After searching the executable’s strings in a hex editor I found a string entry for something along the lines of api.pc.frontier.co.uk. I immediately changed this to my server domain. I booted it up, but, alas, the dreaded Denuvo Anti-Tamper detected the change and stopped the game from launching.

I would love to say I did some research into how Denuvo Anti-Tamper worked, but I will confess I just blindly tried a bunch of stuff. In the process, I found my favourite bodge:

As long as the string was the same length, it would pass the anti-tamper checks!

I modified the binary to have localhost/some-string-of-same-length in there instead and spun up a quick Python Flask server running on that endpoint. I booted the game up and saw all of the game logs coming through into my terminal!

I had successfully bodged together a way of getting logging, structured logging no less, out of Planet Coaster’s Lua scripts. I was also able to write my own logs and have my local server filter for them. This massively sped up my ability to modify the game and create mods such as NoTrackLimits V3 - Realism Overhaul (26k+ downloads). Other people eventually used these tools to create mods of their own.

An aside and an apology

The logging format had a structure along the lines of {COMPONENT: {"CONTENT HERE"}} with the component being text like PARK_MANAGER or ROLLERCOASTERS. My custom one was ARSE. Why? Because I was 16 years old.

When I released V1 of the NoTrackLimits mod, I accidentally left a couple of logs in there. This meant one day in 2020 the Frontier Developments observability system was hit with possibly thousands of messages tagged ARSE. I sincerely apologise for this, but I really hope it was noticed and made someone chuckle.

Proof?

Unfortunately, I didn’t develop a good habit of using version control until about a year after this. A couple of years later, my desktop had issues leading to it being wiped and much of the source code relevant to this story was lost 💔.

Credit where credit is due

A lot of the reverse engineering behind this was driven by the OpenNaja team and a good friend and mentor who I don’t think would want to be named. A particular shout-out to my modding partner in crime, Distantz, who is still carrying the Planet Coaster modding torch long after I moved on. I worked out a fair amount independently, but my main practical contribution was porting tools to Planet Coaster and figuring out how to actually build and distribute mods to people!

#Modding #Reverse-Engineering #Gamedev