|
Rehti MMORPG
1.0.0
Rehti MMORPG is a free and open source MMORPG game.
|
#include "rapidjson/document.h"#include "rapidjson/prettywriter.h"#include <exception>#include <filesystem>#include <stdlib.h>#include "RehtiUtils.hpp"#include "Utils.hpp"

Go to the source code of this file.
Functions | |
| static const std::vector< std::vector< std::string > > | fetchAreaMap () |
| Fetches the area map from the JSON file. Throws an exception if the file corrupted. More... | |
| static void | loadHeightAndTextureMap (const std::vector< std::vector< std::string >> &areaMap, std::vector< std::vector< int >> &heightMap, std::vector< std::vector< int >> &textureMap) |
| Loads a height map and map's texture map into given parameters. Loads them together to avoid reading the same image file twice. More... | |
| static void | insertObjectTileMap (std::vector< std::vector< std::string >> &objectBlockMap, std::vector< std::vector< std::string >> &objectTileMap, unsigned areaY, unsigned areaX, unsigned currentAreaRowIndex, unsigned currentAreaColumnIndex) |
| Inserts the object tile map to the map. More... | |
| static void | changeBlockDirection (std::vector< std::vector< std::string >> &objectTileMap, unsigned rotation) |
| When object tile map is rotated, its direction needs to be rotated as well. More... | |
| static const std::vector< std::vector< std::string > > | createObjectBlockMap (const std::vector< std::vector< std::string >> &areaMap, GameObjects gameObjects, const std::vector< std::vector< int >> &heightMap) |
| Generate the object block map. The map defines how the objects block the tiles around itself. More... | |
| static const std::vector< std::vector< unsigned > > | generateAccessMap (const std::vector< std::vector< int >> &heightMap, const std::vector< std::vector< std::string >> &objectBlockMap) |
| Generates access map from height map & object block map. Access map defines how tiles can or cannot be accessed from it's neighbours. More... | |
Variables | |
| const std::string | OBJECT_TILE_MAP_CENTER = "X" |
| const std::string | OBJECT_TILE_MAP_NORTH_BLOCK = "N" |
| const std::string | OBJECT_TILE_MAP_EAST_BLOCK = "E" |
| const std::string | OBJECT_TILE_MAP_SOUTH_BLOCK = "S" |
| const std::string | OBJECT_TILE_MAP_WEST_BLOCK = "W" |
| const std::string | OBJECT_TILE_MAP_FULL_BLOCK = "B" |
| const std::string | OBJECT_TILE_MAP_NO_BLOCK = " " |
| const unsigned | NON_OBJECT_ID = 255 * 255 |
|
static |
When object tile map is rotated, its direction needs to be rotated as well.
For example, if the object is rotated 90 degrees clockwise, the south block becomes west block and so on.
| objectTileMap | The object tile map to be rotated. |
| rotation | The rotation of the object. 0-4 (North, East, South, West) |

|
static |
Generate the object block map. The map defines how the objects block the tiles around itself.
ALSO, stores objects with their locations to generated/objects.json. This is used by the game server to spawn the objects on start.
| areaMap | Matrix of all the area names. |
| gameObjects | A GameObjects object containing all the object definitions. |
| heightMap | A matrix representing the height of the map. |

|
static |
Fetches the area map from the JSON file. Throws an exception if the file corrupted.
|
static |
Generates access map from height map & object block map. Access map defines how tiles can or cannot be accessed from it's neighbours.
Access map is defined as a matrix where each cell contains 4-bit value. 1st bit is the rightmost bit
If bit = 1, the tile is accessible from that direction. Otherwise not.
Access map is constructed from the object block map and the height map as follows:
North is blocked if, the tile is on the top row, height difference with the north tile is > 1 or the tile has a north block (N). East is blocked if, the tile is on the rightmost column, height difference with the east tile is > 1 or the tile has a east block (E). South is blocked if, the tile is on the bottom row, height difference with the south tile is > 1 or the tile has a south block (S). West is blocked if, the tile is on the leftmost column, height difference with the west tile is > 1 or the tile has a west block (W).
| heightMap | A matrix representing the height map. |
| objectBlockMap | A matrix representing the object block map. |

|
static |
Inserts the object tile map to the map.
| objectBlockMap | The object block map to be modified. |
| objectTileMap | The object tile map to be inserted. |
| areaY | The y-coordinate of the area in the area map. |
| areaX | The x-coordinate of the area in the area map. |
| currentAreaRowIndex | The y-coordinate of the area in the area map. |
| currentAreaColumnIndex | The x-coordinate of the area in the area map. |

|
static |
Loads a height map and map's texture map into given parameters. Loads them together to avoid reading the same image file twice.
Height map is formed by:
Map's texture map is formed by:
| areaMap | Matrix of all the area names |
| heightMap | Empty height matrix to be filled |
| textureMap | Empty texture map to be filled |

| const unsigned NON_OBJECT_ID = 255 * 255 |
| const std::string OBJECT_TILE_MAP_CENTER = "X" |
| const std::string OBJECT_TILE_MAP_EAST_BLOCK = "E" |
| const std::string OBJECT_TILE_MAP_FULL_BLOCK = "B" |
| const std::string OBJECT_TILE_MAP_NO_BLOCK = " " |
| const std::string OBJECT_TILE_MAP_NORTH_BLOCK = "N" |
| const std::string OBJECT_TILE_MAP_SOUTH_BLOCK = "S" |
| const std::string OBJECT_TILE_MAP_WEST_BLOCK = "W" |