From: Holger Schemel Date: Wed, 21 Feb 2024 19:19:49 +0000 (+0100) Subject: added functions for integer hash keys X-Git-Tag: 4.4.0.0-test-1~323 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=69e00ce68d7e6acf3325adcee8b4a8828fb421d5;p=rocksndiamonds.git added functions for integer hash keys --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 5fb6ecfc..e34ed89a 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -2311,11 +2311,23 @@ unsigned int get_hash_from_string(void *key) return hash; } +unsigned int get_hash_from_integer(void *key) +{ + unsigned int hash = PTR_TO_UINT(key); + + return hash; +} + int hash_key_strings_are_equal(void *key1, void *key2) { return (strEqual((char *)key1, (char *)key2)); } +int hash_key_integers_are_equal(void *key1, void *key2) +{ + return (key1 == key2); +} + SetupFileHash *newSetupFileHash(void) { SetupFileHash *new_hash = diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 99167ea1..c7c65cdf 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -372,7 +372,9 @@ char *getSetupValue(int, void *); char *getSetupLine(struct TokenInfo *, char *, int); unsigned int get_hash_from_string(void *); +unsigned int get_hash_from_integer(void *); int hash_key_strings_are_equal(void *, void *); +int hash_key_integers_are_equal(void *, void *); int GetZipFileTreeType(char *); char *ExtractZipFileIntoDirectory(char *, char *, int); diff --git a/src/libgame/types.h b/src/libgame/types.h index 0c935a21..6ea71aeb 100644 --- a/src/libgame/types.h +++ b/src/libgame/types.h @@ -66,6 +66,12 @@ typedef unsigned char byte; #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) +#define PTR_TO_INT(p) ((int) (long) (p)) +#define PTR_TO_UINT(p) ((unsigned int) (unsigned long) (p)) + +#define INT_TO_PTR(i) ((void *) (long) (i)) +#define UINT_TO_PTR(u) ((void *) (unsigned long) (u)) + struct ListNode {