diff options
author | HoraK-FDF <horak-fdf@web.de> | 2024-06-20 11:40:01 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-30 21:05:10 +0200 |
commit | 69e85064403904ba6bece8532b29cc4fc60e722d (patch) | |
tree | e72d4174caab76c5f4153e6f7112de87a0bd8f8a /src/map/map.cpp | |
parent | 4f80aafa3940abf4050290e6c8b63c45716e0db0 (diff) | |
download | tmwa-69e85064403904ba6bece8532b29cc4fc60e722d.tar.gz tmwa-69e85064403904ba6bece8532b29cc4fc60e722d.tar.bz2 tmwa-69e85064403904ba6bece8532b29cc4fc60e722d.tar.xz tmwa-69e85064403904ba6bece8532b29cc4fc60e722d.zip |
map hash
as it was not possible to store a string variable with the current
format of the athena.txt I though a hash could help to identify the maps
since this one can be stored as a permanent char bound variable in
athena.txt
Diffstat (limited to 'src/map/map.cpp')
-rw-r--r-- | src/map/map.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index ff69a56..f8e8bea 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1241,6 +1241,20 @@ int map_setipport(MapName name, IP4Address ip, int port) } /*========================================== + * creates a hash of a map name + *------------------------------------------ + */ +int map_create_hash(XString str) { + const int k = 67; + const int m = 3067; + int hash = 0; + for (int i = 0; i < str.size(); i++) { + hash += (str[i] * (int)pow(k, i)) % m; + } + return hash; +} + +/*========================================== * マップ1枚読み込み *------------------------------------------ */ @@ -1265,6 +1279,9 @@ bool map_readmap(map_local *m, size_t num, MapName fn) m->npc_num = 0; m->users = 0; + + m->hash = map_create_hash(fn); + really_memzero_this(&m->flag); if (battle_config.pk_mode) m->flag.set(MapFlag::PVP, 1); |