Put * on the "uglier but more obvious" side of variable names.
This commit is contained in:
@@ -23,7 +23,7 @@ Node::Node(int x, int y)
|
|||||||
this->state = UNUSED;
|
this->state = UNUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::init(Node* parent, int distanceFromStart, const Vector2i &end)
|
void Node::init(Node *parent, int distanceFromStart, const Vector2i &end)
|
||||||
{
|
{
|
||||||
this->state = OPEN;
|
this->state = OPEN;
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
@@ -145,7 +145,7 @@ bool MultilevelAStarEx::get_unit(const Vector2i &cell) const
|
|||||||
return UNITS(cell2.x, cell2.y);
|
return UNITS(cell2.x, cell2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultilevelAStarEx::can_move(const Node* current, int x, int y) const
|
bool MultilevelAStarEx::can_move(const Node *current, int x, int y) const
|
||||||
{
|
{
|
||||||
if (UNITS(x, y)) return false;
|
if (UNITS(x, y)) return false;
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ bool MultilevelAStarEx::can_move(const Node* current, int x, int y) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedArray<Vector2i> MultilevelAStarEx::generate_path(const Node* current) const
|
TypedArray<Vector2i> MultilevelAStarEx::generate_path(const Node *current) const
|
||||||
{
|
{
|
||||||
TypedArray<Vector2i> arr;
|
TypedArray<Vector2i> arr;
|
||||||
|
|
||||||
@@ -207,12 +207,12 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, c
|
|||||||
open.reserve(_width * _height);
|
open.reserve(_width * _height);
|
||||||
closed.reserve(_width * _height);
|
closed.reserve(_width * _height);
|
||||||
|
|
||||||
Node* closest = &NODES(from2.x, from2.y);
|
Node *closest = &NODES(from2.x, from2.y);
|
||||||
closest->init(nullptr, 0, to2);
|
closest->init(nullptr, 0, to2);
|
||||||
open.push_back(closest);
|
open.push_back(closest);
|
||||||
|
|
||||||
auto process = [this, &open, &closed, &to2, &closest](Node* current, int x, int y, int distance) {
|
auto process = [this, &open, &closed, &to2, &closest](Node *current, int x, int y, int distance) {
|
||||||
Node* node = &NODES(x, y);
|
Node *node = &NODES(x, y);
|
||||||
if (node->state == Node::UNUSED)
|
if (node->state == Node::UNUSED)
|
||||||
{
|
{
|
||||||
node->init(current, current->distanceFromStart + distance, to2);
|
node->init(current, current->distanceFromStart + distance, to2);
|
||||||
@@ -244,8 +244,8 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, c
|
|||||||
while (open.size() > 0)
|
while (open.size() > 0)
|
||||||
{
|
{
|
||||||
// find closest to destination
|
// find closest to destination
|
||||||
Node* current = open[0];
|
Node *current = open[0];
|
||||||
for (Node* n : open)
|
for (Node *n : open)
|
||||||
{
|
{
|
||||||
if (n->total_cost() < current->total_cost())
|
if (n->total_cost() < current->total_cost())
|
||||||
{
|
{
|
||||||
@@ -333,11 +333,11 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, c
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
// release the nodes
|
// release the nodes
|
||||||
for (Node* node : open)
|
for (Node *node : open)
|
||||||
{
|
{
|
||||||
node->state = Node::UNUSED;
|
node->state = Node::UNUSED;
|
||||||
}
|
}
|
||||||
for (Node* node : closed)
|
for (Node *node : closed)
|
||||||
{
|
{
|
||||||
node->state = Node::UNUSED;
|
node->state = Node::UNUSED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ private:
|
|||||||
NodeState state;
|
NodeState state;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
Node* parent;
|
Node *parent;
|
||||||
int distanceFromStart;
|
int distanceFromStart;
|
||||||
int distanceToEnd;
|
int distanceToEnd;
|
||||||
|
|
||||||
int distanceToEndForClosest;
|
int distanceToEndForClosest;
|
||||||
|
|
||||||
Node(int x, int y);
|
Node(int x, int y);
|
||||||
void init(Node* parent, int distanceFromStart, const Vector2i &end);
|
void init(Node *parent, int distanceFromStart, const Vector2i &end);
|
||||||
int total_cost() const;
|
int total_cost() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -59,8 +59,8 @@ private:
|
|||||||
Vector2i _trans;
|
Vector2i _trans;
|
||||||
int _width, _height;
|
int _width, _height;
|
||||||
|
|
||||||
bool can_move(const Node* current, int x, int y) const;
|
bool can_move(const Node *current, int x, int y) const;
|
||||||
TypedArray<Vector2i> generate_path(const Node* current) const;
|
TypedArray<Vector2i> generate_path(const Node *current) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|||||||
Reference in New Issue
Block a user