Map Module

A separate map module is responsible for delivering different map data of the world. Internally it can use many different map producers, that have some internal source data for the maps. The internal data is never exposed directly to the game server or clients. This way it is possible to change the way maps are generated later, or add new map producing algorithms, without affecting anything outside the map server.

A rough outline of some parts of a map server and of the map format can be seen in this map system diagram.

Generating Items From The Map

The map module provides terrain data. We might also implement item layers, that specify very frequent static items such as trees, stones, and plants that exist in the landscape. However, it will not be used for storing normal game entities.

If an entity generated from the terrain is modified, it is turned into a real entity for the rest of its life, and the map module is notified that it shouldn't be generated any more. Thus, if you cut down a tree, or just carve a figure in it with a knife, it turns into an entity that is stored in the database instead of the map data. Large changes such as forest fires are trickier, but could be implemented with some effect layer system inside the map server.

Modifying maps

Maps can be modified dynamically too. So the map server also has an interface for adding an local layer of soil of a certain terrain/ground type and thickness to a certain place. Parts of the landscape can also be carved out, by specifying a negative layer with some depth, or with both thickness and height over sea level. The first one can be used to dig away soil from the top of the terrain, the latter can be used for creating tunnels and caves in the ground too.

Future Map Servers

The change from a map module used by STAGE to a separate Map Server should be simple. When we start scaling up to support many users we can run many map servers for one world, to distribute the load of clients downloading map data. One server is the Master, and all changes to the map have to be sent to it, from where it propagates to the other servers. The Game Server would probably use the Master Map Server.

Output Maps

The map module produces output maps, that are gives to the game server and the client. Anything given to the client has to be approved by the game server first.

The output maps have a height layer, a terrain type layer, and a water height layer. The game server may also need some other layers, perhaps weather, mana concentration, item layers, etc. The client might also need some additional layers, such as vegetation and forest layers. When the need for some of these layers arise they are defined and code is added to produce them for the output maps. To start with, however, terrain height, type and perhaps water height should be enough.

The layers in the output map are 2D meshes that cover the whole area that the map was requested for, and have the map data (such as height or terrain type) stored in the vertexes (in the source maps inside the map server, OTOH, it is possible to have layers that only cover a part of the game world. But they are all combined to produce the all-covering layers of the output format).

Different Polygon Surfaces

Polygons (preferably triangles, as that makes the processing much easier), in a mesh making up a layer in a map, can be of three different types: flat, smooth, or fractal. The flat polygons are just that, a flat surface stretched between the corners of the polygon. Smooth polygons use the normal of each corner point to calculate a surface that lacks any sharp edges between polygons. Fractal polygons use perlin noise to create a fractal surface, that is a combination of random variation at different scale levels. The fractal polygons store as parameters the amplitude (and fractal dimension?) of changes at different scales.

Smooth and fractal polygons can be rendered at any desired level of detail by the client. The server can render them on a level of detail that is enough to get proper collision detection with the ground.