mirror of https://github.com/OpenTTD/OpenTTD
(svn r20881) -Codechange: Make Hash_Get a method.
parent
6ea5643e40
commit
4ed94825b2
|
@ -33,7 +33,7 @@
|
||||||
* If so, it returns the PathNode, else NULL */
|
* If so, it returns the PathNode, else NULL */
|
||||||
PathNode *AyStar::ClosedListIsInList(const AyStarNode *node)
|
PathNode *AyStar::ClosedListIsInList(const AyStarNode *node)
|
||||||
{
|
{
|
||||||
return (PathNode*)Hash_Get(&this->ClosedListHash, node->tile, node->direction);
|
return (PathNode*)this->ClosedListHash.Get(node->tile, node->direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This adds a node to the ClosedList
|
/* This adds a node to the ClosedList
|
||||||
|
@ -50,7 +50,7 @@ void AyStar::ClosedListAdd(const PathNode *node)
|
||||||
* If so, it returns the OpenListNode, else NULL */
|
* If so, it returns the OpenListNode, else NULL */
|
||||||
OpenListNode *AyStar::OpenListIsInList(const AyStarNode *node)
|
OpenListNode *AyStar::OpenListIsInList(const AyStarNode *node)
|
||||||
{
|
{
|
||||||
return (OpenListNode*)Hash_Get(&this->OpenListHash, node->tile, node->direction);
|
return (OpenListNode*)this->OpenListHash.Get(node->tile, node->direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gets the best node from OpenList
|
/* Gets the best node from OpenList
|
||||||
|
|
|
@ -502,9 +502,13 @@ void *Hash_Set(Hash *h, uint key1, uint key2, void *value)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Hash_Get(const Hash *h, uint key1, uint key2)
|
/**
|
||||||
|
* Gets the value associated with the given key pair, or NULL when it is not
|
||||||
|
* present.
|
||||||
|
*/
|
||||||
|
void *Hash::Get(uint key1, uint key2) const
|
||||||
{
|
{
|
||||||
HashNode *node = Hash_FindNode(h, key1, key2, NULL);
|
HashNode *node = Hash_FindNode(this, key1, key2, NULL);
|
||||||
|
|
||||||
#ifdef HASH_DEBUG
|
#ifdef HASH_DEBUG
|
||||||
debug("Found node: %p", node);
|
debug("Found node: %p", node);
|
||||||
|
|
|
@ -86,6 +86,8 @@ struct Hash {
|
||||||
* there are any Nodes in the bucket */
|
* there are any Nodes in the bucket */
|
||||||
bool *buckets_in_use;
|
bool *buckets_in_use;
|
||||||
|
|
||||||
|
void *Get(uint key1, uint key2) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current size of the hash.
|
* Gets the current size of the hash.
|
||||||
*/
|
*/
|
||||||
|
@ -108,11 +110,6 @@ void *Hash_Delete(Hash *h, uint key1, uint key2);
|
||||||
* Returns the old value if the value was replaced, NULL when it was not yet present.
|
* Returns the old value if the value was replaced, NULL when it was not yet present.
|
||||||
*/
|
*/
|
||||||
void *Hash_Set(Hash *h, uint key1, uint key2, void *value);
|
void *Hash_Set(Hash *h, uint key1, uint key2, void *value);
|
||||||
/**
|
|
||||||
* Gets the value associated with the given key pair, or NULL when it is not
|
|
||||||
* present.
|
|
||||||
*/
|
|
||||||
void *Hash_Get(const Hash *h, uint key1, uint key2);
|
|
||||||
|
|
||||||
/* Call these function to create/destroy a hash */
|
/* Call these function to create/destroy a hash */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue