summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pathfinder/npf/aystar.cpp4
-rw-r--r--src/pathfinder/npf/queue.cpp23
-rw-r--r--src/pathfinder/npf/queue.h13
3 files changed, 17 insertions, 23 deletions
diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp
index 3a1a5c057..fe2af5156 100644
--- a/src/pathfinder/npf/aystar.cpp
+++ b/src/pathfinder/npf/aystar.cpp
@@ -285,8 +285,8 @@ void AyStar::AddStartNode(AyStarNode *start_node, uint g)
void AyStar::Init(Hash_HashProc hash, uint num_buckets)
{
/* Allocated the Hash for the OpenList and ClosedList */
- init_Hash(&this->OpenListHash, hash, num_buckets);
- init_Hash(&this->ClosedListHash, hash, num_buckets);
+ this->OpenListHash.Init(hash, num_buckets);
+ this->ClosedListHash.Init(hash, num_buckets);
/* Set up our sorting queue
* BinaryHeap allocates a block of 1024 nodes
diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp
index 5b0e9a0ec..3075ebf73 100644
--- a/src/pathfinder/npf/queue.cpp
+++ b/src/pathfinder/npf/queue.cpp
@@ -243,24 +243,27 @@ void BinaryHeap::Init(uint max_size)
* Hash
*/
-void init_Hash(Hash *h, Hash_HashProc *hash, uint num_buckets)
+/**
+ * Builds a new hash in an existing struct. Make sure that hash() always
+ * returns a hash less than num_buckets! Call delete_hash after use
+ */
+void Hash::Init(Hash_HashProc *hash, uint num_buckets)
{
/* Allocate space for the Hash, the buckets and the bucket flags */
uint i;
- assert(h != NULL);
#ifdef HASH_DEBUG
- debug("Allocated hash: %p", h);
+ debug("Allocated hash: %p", this);
#endif
- h->hash = hash;
- h->size = 0;
- h->num_buckets = num_buckets;
- h->buckets = (HashNode*)MallocT<byte>(num_buckets * (sizeof(*h->buckets) + sizeof(*h->buckets_in_use)));
+ this->hash = hash;
+ this->size = 0;
+ this->num_buckets = num_buckets;
+ this->buckets = (HashNode*)MallocT<byte>(num_buckets * (sizeof(*this->buckets) + sizeof(*this->buckets_in_use)));
#ifdef HASH_DEBUG
- debug("Buckets = %p", h->buckets);
+ debug("Buckets = %p", this->buckets);
#endif
- h->buckets_in_use = (bool*)(h->buckets + num_buckets);
- for (i = 0; i < num_buckets; i++) h->buckets_in_use[i] = false;
+ this->buckets_in_use = (bool*)(this->buckets + num_buckets);
+ for (i = 0; i < num_buckets; i++) this->buckets_in_use[i] = false;
}
/**
diff --git a/src/pathfinder/npf/queue.h b/src/pathfinder/npf/queue.h
index 6059c54b1..69c1602df 100644
--- a/src/pathfinder/npf/queue.h
+++ b/src/pathfinder/npf/queue.h
@@ -86,6 +86,8 @@ struct Hash {
* there are any Nodes in the bucket */
bool *buckets_in_use;
+ void Init(Hash_HashProc *hash, uint num_buckets);
+
void *Get(uint key1, uint key2) const;
void *Set(uint key1, uint key2, void *value);
@@ -103,15 +105,4 @@ struct Hash {
}
};
-/* Call these function to manipulate a hash */
-
-
-/* Call these function to create/destroy a hash */
-
-/**
- * Builds a new hash in an existing struct. Make sure that hash() always
- * returns a hash less than num_buckets! Call delete_hash after use
- */
-void init_Hash(Hash *h, Hash_HashProc *hash, uint num_buckets);
-
#endif /* QUEUE_H */