Rocket Analytics
Parsing Rocket League replay files
What is it?
RocketAnalytics is a C++ library for parsing Rocket League replay files.
Why I built it
While I was working with the College Carball Association (CCA), in order to verify that 2 teams played their match and that there was no dispute in who won, we required teams to submit a screeenshot of their post-game screen as evidence. Additionally, our casters enjoyed talking about were player statistics.In order to compile a set of player and team statistics, a group of people would go through every submitted post-game image and manually enter the data into a spreadsheet. Obviously, this suuuuuucked. So, I wanted to automate it.
But, why a C++ library? Why not something like Python or Golang? Why not something higher level but still good at file processing? Well, at the time I was still a college student — 22, maybe 23 years old. I had a softspot for C++ as a language. I really enjoyed how much control over memory you had, and I enjoyed the puzzle of building software abstractions that utilized this power. I also had a mild ambition to use this library to analyse hundreds of thousands of replay files to build automated player feedback on how to improve their gameplay. I had the opinion at the time that I would need to performance of a C++ library to accomplish my goal. I never started working on that idea.
What it does
When I wrote this parser, replay files were broken up into 10 main sections: header, levels, keyframes, netstream, tick information, replicated packages, object table, name table, class index map, and the class net cache. I won't go deep into details, but each section, except for the netstream, are essentially just groups of integers and length-prefixed strings. The parser read through the entire given file, building in-memory objects of each value it comes across.
The replay format isn't officially documented, so none of this would likely exist without the hard work of those who posted their reverse-engineering findings on theold Rocket League forums. Their comments were critical to me getting my footing in understanding the layout of a replay file. Unfortunately, I believe the forum no longer exists, and I'm not sure where I put my download the forum pages.
Using the library is pretty simple: give the parser a file path, and you get back the parsed file. To validate correctness, I included the ability to serialize the replay object to JSON to compare the values to those in the original file manually in an hex editor. Below is some example code on how you would use the library that I took from my README.
#include "../include/RocketAnalytics.hpp"
#include <iostream>
#include <string>
int main() {
std::string filename = "rocketleague.replay";
auto replay = rocketanalytics::ReplayFile(filename);
std::cout << replay.serialize_to_json() << std::endl;
return 0;
}
What's next
Nothing. There is more that I could work on—the netstream decoding was never implemented—but I am no longer interested in this project. It will forever stay archived as the little C++ library powering the simple stat aggregator CLI tool I made while working with the College Carball Association.