diff options
-rw-r--r-- | src/map/map.cpp | 11 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index 6d24f59..f8e8bea 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1244,11 +1244,11 @@ int map_setipport(MapName name, IP4Address ip, int port) * creates a hash of a map name *------------------------------------------ */ -int map_create_hash(char* str, int len) { +int map_create_hash(XString str) { const int k = 67; const int m = 3067; int hash = 0; - for (int i = 0; i < len; i++) { + for (int i = 0; i < str.size(); i++) { hash += (str[i] * (int)pow(k, i)) % m; } return hash; @@ -1280,12 +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" }; // VString<15> is used for map names - std::copy(fn.begin(), fn.end(), str); - str[fn.size()] = '\0'; - int len = strlen(str); - - m->hash = map_create_hash(str, len); + m->hash = map_create_hash(fn); really_memzero_this(&m->flag); if (battle_config.pk_mode) diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 7f63408..74a70b3 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -5543,7 +5543,7 @@ static void builtin_getmapnamefromhash(ScriptState *st) { int hash = conv_num(st, &AARG(0)); - MapName mapname = stringish<MapName>(ZString(""_s)); + MapName mapname; for (auto& mit : maps_db) { map_local *ml = static_cast<map_local *>(mit.second.get()); |