Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
server/src/world/Utils.cpp File Reference
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include "Utils.hpp"
Include dependency graph for server/src/world/Utils.cpp:

Classes

struct  nodeCompare
 

Functions

bool isValidCell (const std::vector< std::vector< uint8_t >> &map, std::pair< int, int > coords, 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...
 

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: