Closed jd28 closed 8 months ago
Yes, this is expected behavior, documented somewhat in nwscript.nss entry for HashString():
// Returns the 32bit integer hash of sString
// This hash is stable and will always have the same value for same input string, regardless of platform.
// The hash algorithm is the same as the one used internally for strings in case statements, so you can do:
// switch (HashString(sString))
// {
// case "AAA": HandleAAA(); break;
// case "BBB": HandleBBB(); break;
// }
// NOTE: The exact algorithm used is XXH32(sString) ^ XXH32(""). This means that HashString("") is 0.
int HashString(string sString);
Actual relevant impl at https://github.com/niv/neverwinter.nim/blob/master/neverwinter/nwscript/native/scriptcompfinalcode.cpp#L969
Specifics
If needed, describe the bug
This compiles. I understand how the string cases are implemented, but I don't think this is intended behavior?