I have one month to make an MMO: Day 16

Yuan Gao (Meseta)
Meseta’s MMO experiment
4 min readSep 11, 2019

Oops! Yesterday I took some unscheduled time off to go watch a movie with the wife, which has thrown my planned hours off completely. I’m about half a day behind where I had planned to be. Fortunately it’s the end of the sprint, so I decided to work on Day 16’s tasks on my day off between sprints and present it to you like nothing happened.

These times are an amalgam of stuff I did yesterday and today that counts towards “Day 16”, I’ll just have less of a day off today.

Full chunk unloading and warp

The MMO’s world is designed to be very very large, and is split into different areas. The single largest area is simply named “world”, and contains all of the areas I’ve screenshotted so far. Every settlement and every outdoor environment should in theory all exist at some coordinate in this “world” area. (The “world” is actually split into separate tmx projects, but the uploader code will re-assemble this world together and upload the chunks as if it were a single tmx project)

However, there are also other areas that are reachable by the player but aren’t attached to this “world” area. The prime example for this are the inside of buildings and caves. These areas exist in isolation, and have no geometric relationship to “world”. To accomplish moving from one area to another, the “warping” mechanism is used. When a player “warps” both the player client, and the player node in the server dump their current set of chunks, and request completely new ones from the new area.

Inside game client, there is an object called obj_chunkman which is the chunk manager. It’s responsible for working out what chunks a player needs and spawning in obj_chunk objects that are responsible for holding the chunk data and keeping track of instances on those chunks (things like signposts and non-entities). To achieve a warp from one area to another, a full chunk unload has to happen, which involves:

  1. Destroy all entities that aren’t the player (npcs, mobs, and other player characters).
  2. Destroy obj_chunkman, which will cause all obj_chunk it controls to be automatically destroyed. Each obj_chunk in turn automatically also removes all instances and layers on it.
  3. Create a new obj_chunkman. Once the new obj_chunkman is spawned, it automatically goes and loads all new chunks for the new area.

This delegation of responsibilities keeps the chunk management very clean.

The results can be seen in this Gif. As the player warps into a new area, you can see the world flicker briefly to black before the next area loads. You can also see the NPC entity’s placeholder icon show up briefly before it too loads NPC data from the server and figures out which sprite it should be using.

The same happens coming out of that area back into the world — the chunks have to load, and the NPCs also have to load in their properties. Some kind of loading screen or transition is needed here to hide this world loading flicker.

New indoor areas

A couple of new indoor areas have been added, as can be seen in the Gif above, and the one below.

Indoor areas are built no differently from outdoor areas. they have very much the same set of tile layers.

With all the framework in place, it is now extremely easy to create new areas. It’s simply a case of putting together a new project in Tiled, adding a warp object and setting its to point at the correct coordinates in other areas, and hitting “upload” in Tiled from the menu to send all the updates to the database.

Day 16 Task Summary

As sprint 4 draws to a close, I’m pleased to have cleaned up the world unloading and warping, as now I don’t have to worry about weird errors or memory leaks when moving between areas.

Since I overran by half a day due to taking some unscheduled social time off, I’ll be doing the Sprint 5 planning today too, and immediately starting on the next sprint tomorrow. It’s sure to be a busy time.

--

--

Yuan Gao (Meseta)
Meseta’s MMO experiment

🤖 Build robots, code in python. Former Electrical Engineer 👨‍💻 Programmer, Chief Technology Officer 🏆 Forbes 30 Under 30 in Enterprise Technology