Put * on the "uglier but more obvious" side of variable names.

This commit is contained in:
2024-05-24 01:12:48 +02:00
parent 91ec7cc507
commit d0c5119d52
2 changed files with 14 additions and 14 deletions

View File

@@ -23,7 +23,7 @@ Node::Node(int x, int y)
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->parent = parent;
@@ -145,7 +145,7 @@ bool MultilevelAStarEx::get_unit(const Vector2i &cell) const
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;
@@ -176,7 +176,7 @@ bool MultilevelAStarEx::can_move(const Node* current, int x, int y) const
return false;
}
TypedArray<Vector2i> MultilevelAStarEx::generate_path(const Node* current) const
TypedArray<Vector2i> MultilevelAStarEx::generate_path(const Node *current) const
{
TypedArray<Vector2i> arr;
@@ -207,12 +207,12 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, c
open.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);
open.push_back(closest);
auto process = [this, &open, &closed, &to2, &closest](Node* current, int x, int y, int distance) {
Node* node = &NODES(x, y);
auto process = [this, &open, &closed, &to2, &closest](Node *current, int x, int y, int distance) {
Node *node = &NODES(x, y);
if (node->state == Node::UNUSED)
{
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)
{
// find closest to destination
Node* current = open[0];
for (Node* n : open)
Node *current = open[0];
for (Node *n : open)
{
if (n->total_cost() < current->total_cost())
{
@@ -333,11 +333,11 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, c
cleanup:
// release the nodes
for (Node* node : open)
for (Node *node : open)
{
node->state = Node::UNUSED;
}
for (Node* node : closed)
for (Node *node : closed)
{
node->state = Node::UNUSED;
}

View File

@@ -23,14 +23,14 @@ private:
NodeState state;
int x, y;
Node* parent;
Node *parent;
int distanceFromStart;
int distanceToEnd;
int distanceToEndForClosest;
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;
public:
@@ -59,8 +59,8 @@ private:
Vector2i _trans;
int _width, _height;
bool can_move(const Node* current, int x, int y) const;
TypedArray<Vector2i> generate_path(const Node* current) const;
bool can_move(const Node *current, int x, int y) const;
TypedArray<Vector2i> generate_path(const Node *current) const;
protected:
static void _bind_methods();