A check-in, with no code this time: a look back over the forty-seven episodes so far, from a C++ server and a raylib client to quests, a load test with Pyroscope and analytics in ClickHouse. We go over how the game fits together today, play it, and look at the tools around it, the dashboards and CI, and the practices from the industry we've put in place. Then the plan: more of the features you'd expect in an MMORPG, more worlds and graphics, a trading system, all the players simulated by bots, and more on security. This is episode 48 of a series about building an MMORPG from scratch in C++, with the focus on the engineering around the game.
Transcript
Intro
0:00 Hello and welcome back to episode forty-eight, which is going to be a bit different, as we're not going to write any code. Instead, I want to talk to you directly about where the project is after forty-seven episodes, and where I want to take it next. Let's begin with a quick look at all the episodes so far.
0:17 We've made forty-seven episodes so far, from the plan and a C++ server in the first one, to the game's analytics in ClickHouse in the last one. And this one, the forty-eighth, is a pause to take stock before we carry on with the game.
0:32 On the website of the series you can find more information about the project. The code for the project is open source on GitHub, tagged at each step of each episode so that you can follow along.
So far
0:44 All right, let's get started, going back over what we've built, episode by episode. We started with the plan and a C++ server, then a client drawn with raylib, and players who see each other move, through protobuf and Asio. From the fourth episode on, Prometheus has collected the server's metrics, and Grafana has drawn them. Then came accounts in MySQL, with passwords hashed with Argon2id, a login server with tokens in Redis, and animated characters. We profiled the tick with perf and Tracy, and measured TCP against UDP under packet loss. Monsters came next, and combat, a website in Laravel, a Redis cache that writes behind to MySQL, so that a crash doesn't cost the players their progress, and TLS. The island grew from a seed, with trees and frustum culling, and the database got migrations. Then the game went online on a VPS, with interest management to send each player less, and Consul to find the worlds, which got lands, with portals between them. Chat and NPCs came after that, with a storyteller that runs a language model. Items and content became data, and we went looking for bugs with sanitisers, fuzzers and integration tests. Alerts went out as emails, to a mail server in Docker. The players got skills and music, and the world got bloom and cel shading. The logs went into Loki, a deploy stopped throwing the players out, and a push to main deployed the game on its own. Then dungeons, and a bag you can drag items around in, with loot from the monsters, then water, low-poly people, and quests. And in the last two episodes, we put the server under load, with flame graphs from Pyroscope, and kept what the players do in ClickHouse, for the game's analytics.
The game today
2:29 So, let's go over how the game fits together today, from one end to the other. The client draws the world with raylib and sends what the player does, while the servers decide what happens. It logs in through our login server, over TLS, against the accounts in MySQL. Then it plays on one of the worlds, which register with Consul, so that the login server can list them. Each world keeps its players in Redis, and the saver writes them behind to MySQL. Our bots play the game over the network as a client would, which is how we put the servers under load. And what the players do goes through a Redis stream into ClickHouse.
3:05 The client opens on the worlds that are up, with how many players each has, and arthur logs in to Ember, where sixty bots are playing. Each player is a low-poly person, with their own skin and hair, and their level, name and health over them. The bag holds the potions arthur carries, and the character screen has arthur's level, health and experience, next to a preview of the character in the gear arthur wears. The camera turns around arthur, over the island, with skeletons wandering around the middle, and a few NPCs, such as the guard, who gives out quests.
Around the game
3:40 Around the game, we have a lot of the tools you'd find around a service in production. With three hundred bots on the server, its dashboard has the players online and the ticks a second, along with how long each tick takes. What the servers log goes into Loki, next to the metrics, and Pyroscope keeps a flame graph of where the worlds spend their CPU, all the time.
4:01 The game has a dashboard of its own, from ClickHouse, with the kills a minute by monster. It shows the quests the players take against the ones they finish, and the items that come into the game against the ones that are used.
4:14 And on GitHub, each push to main, and each pull request, runs our CI. Next to the build and the tests, clang-tidy, the sanitisers and the fuzzers look for the bugs the tests don't catch. And from main, the API docs and the coverage report are published to GitHub Pages.
Where we are
4:31 Looking back over these episodes, we've put in place a lot of the practices I've come across in the industry and in my own projects. The code has tests, which CI runs on each push to main, with sanitisers and fuzzers next to them. The servers, the bots and the tools around them build and run in Docker, along with the tests, and the database changes through migrations. A push to main can deploy the game, with the players handed over to the new version. We can see what the servers are doing through their metrics and logs, and the alerts tell us when a world falls behind or crashes. Load tests tell us roughly how many players a world can take, while the analytics show what the players do. So, I think we're in a good position to keep working on the project, as our development process is set up in a healthy way.
What's next
5:17 As for what's next, the plan is to keep adding the features you'd expect in a game like this. There's going to be more content, with more worlds to explore, and more graphics features, and we're going to bring in new data structures as the game needs them. Further down the line, I want to build a trading system. I hope it's going to be fairly interesting, as items have to change hands between two players safely, even when something fails halfway through. We're going to simulate all the players, with bots that play the game the way people would. That way, we can see how each feature does with a lot of players in the world. And soon, we're going to cover more of the security aspects of running a game like this. As before, we're going to document each step of the way, in the code, with its tags, and in these videos.
Playing it
6:42 Let me know in the comments what you'd like to see next. And if you want to follow along with the series, subscribe to the channel. I hope you find this useful, and thanks for watching.