summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoraK-FDF <horak-fdf@web.de>2024-06-21 08:33:33 +0200
committerHoraK-FDF <horak-fdf@web.de>2024-07-02 01:15:17 +0200
commit62df54c6bb78456a9eccd641eb8596b7ba228d7f (patch)
tree3cac89f19d8893bf5001ce26e8ca4826597dfac7
parent035aa9fd51c77100ef0a94f985a2aeafeba5a976 (diff)
downloadtmwa-62df54c6bb78456a9eccd641eb8596b7ba228d7f.tar.gz
tmwa-62df54c6bb78456a9eccd641eb8596b7ba228d7f.tar.bz2
tmwa-62df54c6bb78456a9eccd641eb8596b7ba228d7f.tar.xz
tmwa-62df54c6bb78456a9eccd641eb8596b7ba228d7f.zip
map hash better const declaration and comment
-rw-r--r--src/map/map.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 5822370..6d24f59 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -1245,10 +1245,11 @@ int map_setipport(MapName name, IP4Address ip, int port)
*------------------------------------------
*/
int map_create_hash(char* str, int len) {
- const int PRIME_CONST = 67;
+ const int k = 67;
+ const int m = 3067;
int hash = 0;
for (int i = 0; i < len; i++) {
- hash += (str[i] * (int)pow(PRIME_CONST, i)) % 3067;
+ hash += (str[i] * (int)pow(k, i)) % m;
}
return hash;
}
@@ -1279,7 +1280,7 @@ bool map_readmap(map_local *m, size_t num, MapName fn)
m->npc_num = 0;
m->users = 0;
- char str[15+1] = { "\0" };
+ char str[15+1] = { "\0" }; // VString<15> is used for map names
std::copy(fn.begin(), fn.end(), str);
str[fn.size()] = '\0';
int len = strlen(str);