equal
deleted
inserted
replaced
17 */ |
17 */ |
18 |
18 |
19 #include "stdafx.h" |
19 #include "stdafx.h" |
20 #include "openttd.h" |
20 #include "openttd.h" |
21 #include "aystar.h" |
21 #include "aystar.h" |
|
22 #include "helpers.hpp" |
22 |
23 |
23 int _aystar_stats_open_size; |
24 int _aystar_stats_open_size; |
24 int _aystar_stats_closed_size; |
25 int _aystar_stats_closed_size; |
25 |
26 |
26 // This looks in the Hash if a node exists in ClosedList |
27 // This looks in the Hash if a node exists in ClosedList |
33 // This adds a node to the ClosedList |
34 // This adds a node to the ClosedList |
34 // It makes a copy of the data |
35 // It makes a copy of the data |
35 static void AyStarMain_ClosedList_Add(AyStar *aystar, const PathNode *node) |
36 static void AyStarMain_ClosedList_Add(AyStar *aystar, const PathNode *node) |
36 { |
37 { |
37 // Add a node to the ClosedList |
38 // Add a node to the ClosedList |
38 PathNode *new_node = malloc(sizeof(*new_node)); |
39 PathNode *new_node; |
|
40 MallocT(&new_node, 1); |
39 *new_node = *node; |
41 *new_node = *node; |
40 Hash_Set(&aystar->ClosedListHash, node->node.tile, node->node.direction, new_node); |
42 Hash_Set(&aystar->ClosedListHash, node->node.tile, node->node.direction, new_node); |
41 } |
43 } |
42 |
44 |
43 // Checks if a node is in the OpenList |
45 // Checks if a node is in the OpenList |
64 // Adds a node to the OpenList |
66 // Adds a node to the OpenList |
65 // It makes a copy of node, and puts the pointer of parent in the struct |
67 // It makes a copy of node, and puts the pointer of parent in the struct |
66 static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, const AyStarNode *node, int f, int g) |
68 static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, const AyStarNode *node, int f, int g) |
67 { |
69 { |
68 // Add a new Node to the OpenList |
70 // Add a new Node to the OpenList |
69 OpenListNode *new_node = malloc(sizeof(*new_node)); |
71 OpenListNode *new_node; |
|
72 MallocT(&new_node, 1); |
70 new_node->g = g; |
73 new_node->g = g; |
71 new_node->path.parent = parent; |
74 new_node->path.parent = parent; |
72 new_node->path.node = *node; |
75 new_node->path.node = *node; |
73 Hash_Set(&aystar->OpenListHash, node->tile, node->direction, new_node); |
76 Hash_Set(&aystar->OpenListHash, node->tile, node->direction, new_node); |
74 |
77 |