refactor: Unify string hashing
> moved to util/utils.h
This commit is contained in:
+12
-16
@@ -5,6 +5,7 @@
|
||||
#include "util/sigscan.h"
|
||||
#include "util/detour.h"
|
||||
#include "util/libutils.h"
|
||||
#include "util/utils.h"
|
||||
#include "avs/core.h"
|
||||
#include <cstring>
|
||||
|
||||
@@ -698,11 +699,6 @@ static struct offset_t
|
||||
intptr_t DAT_song_id;
|
||||
bool is_lstr_wchar;
|
||||
memutils::VProtectGuard *guard;
|
||||
|
||||
static constexpr unsigned int by_ext(const char *ext, int h = 0)
|
||||
{
|
||||
return !ext[h] ? 5381 : (by_ext(ext, h + 1) * 33) ^ ext[h];
|
||||
}
|
||||
} offset_;
|
||||
snd_bank *snd_bank::cache_ = nullptr;
|
||||
size_t snd_bank::cachesz_ = 0;
|
||||
@@ -909,34 +905,34 @@ void init(HINSTANCE hmodule, const char *model, const char *ext)
|
||||
offset_.DAT_song_id = 0x67c;
|
||||
offset_.is_lstr_wchar = true;
|
||||
}
|
||||
switch (offset_t::by_ext(ext))
|
||||
switch (to_hash(ext))
|
||||
{
|
||||
case offset_t::by_ext("2018091900"):
|
||||
case to_hash("2018091900"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x1170b0;
|
||||
break;
|
||||
case offset_t::by_ext("2019090200"):
|
||||
case offset_t::by_ext("2019100700"):
|
||||
case to_hash("2019090200"):
|
||||
case to_hash("2019100700"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x37a540;
|
||||
break;
|
||||
case offset_t::by_ext("2020092900"):
|
||||
case to_hash("2020092900"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x5ac460;
|
||||
break;
|
||||
case offset_t::by_ext("2021083000"):
|
||||
case to_hash("2021083000"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x766bc0;
|
||||
break;
|
||||
case offset_t::by_ext("2021091500"):
|
||||
case to_hash("2021091500"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x766c60;
|
||||
break;
|
||||
case offset_t::by_ext("2022082400"):
|
||||
case to_hash("2022082400"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x46e160;
|
||||
break;
|
||||
case offset_t::by_ext("2023090500"):
|
||||
case to_hash("2023090500"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0xafd780;
|
||||
break;
|
||||
case offset_t::by_ext("2024082600"):
|
||||
case to_hash("2024082600"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x8eae40;
|
||||
break;
|
||||
case offset_t::by_ext("2025082500"):
|
||||
case to_hash("2025082500"):
|
||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x969fb0;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user