Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
server/src/world/Utils.hpp File Reference
#include "Coordinates.hpp"
#include "RehtiReader.hpp"
#include <memory>
#include <vector>
Include dependency graph for server/src/world/Utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Node
 

Enumerations

enum  Direction {
  NORTH , NORTH_EAST , EAST , SOUTH_EAST ,
  SOUTH , SOUTH_WEST , WEST , NORTH_WEST
}
 

Functions

bool isValidCell (const std::vector< std::vector< uint8_t >> &map, std::pair< int, int > cell, Direction dir)
 Check if cell is valid and accessible from given direction. More...
 
unsigned int euclideanDistance (std::pair< int, int > start, std::pair< int, int > end)
 Calculate the euclidean distance between two points. More...
 
std::vector< std::pair< int, int > > astar (const std::vector< std::vector< uint8_t >> &map, std::pair< int, int > start, std::pair< int, int > end)
 A-star algorithm made to work with the access map format. Allows diagonal movement and has a heuristic of euclidean distance. More...
 

Enumeration Type Documentation

◆ Direction

enum Direction
Enumerator
NORTH 
NORTH_EAST 
EAST 
SOUTH_EAST 
SOUTH 
SOUTH_WEST 
WEST 
NORTH_WEST 

Function Documentation

◆ astar()

std::vector<std::pair<int, int> > astar ( const std::vector< std::vector< uint8_t >> &  map,
std::pair< int, int >  start,
std::pair< int, int >  end 
)

A-star algorithm made to work with the access map format. Allows diagonal movement and has a heuristic of euclidean distance.

Parameters
map
start
end
Returns
Returns a vector containing the path from start to finish. Start is not included in the path, but end is.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ euclideanDistance()

unsigned int euclideanDistance ( std::pair< int, int >  start,
std::pair< int, int >  end 
)

Calculate the euclidean distance between two points.

Parameters
startpair (x, y)
endpair (x, y)
Returns
Euclidean distance in tiles
Here is the caller graph for this function:

◆ isValidCell()

bool isValidCell ( const std::vector< std::vector< uint8_t >> &  map,
std::pair< int, int >  cell,
Direction  dir 
)

Check if cell is valid and accessible from given direction.

Parameters
mapThe access map of the map.
cellThe cell to check.
dirThe direction from which the cell is accessed.
Returns
true if the cell is valid, false otherwise.
Here is the caller graph for this function: