[StringTable] Use the game's hashing function

This commit is contained in:
momo5502 2017-06-30 00:35:04 +02:00
parent b85810b0ab
commit dd1308a7f9
5 changed files with 5 additions and 18 deletions

View File

@ -91,8 +91,6 @@ namespace Components
// Don't create stat backup
Utils::Hook::Nop(0x402CE6, 2);
}
Stats::~Stats()

View File

@ -4,20 +4,6 @@ namespace Components
{
std::unordered_map<std::string, Game::StringTable*> StringTable::StringTableMap;
int StringTable::Hash(const char* data)
{
int hash = 0;
while (*data != 0)
{
hash = tolower(*data) + (31 * hash);
++data;
}
return hash;
}
Game::StringTable* StringTable::LoadObject(std::string filename)
{
Utils::Memory::Allocator* allocator = Utils::Memory::GetAllocator();
@ -53,7 +39,7 @@ namespace Components
std::string value = parsedTable.getElementAt(i, j);
Game::StringTableCell* cell = &table->values[i * table->columnCount + j];
cell->hash = StringTable::Hash(value.data());
cell->hash = Game::StringTable_HashString(value.data());
cell->string = allocator->duplicateString(value);
//if (!cell->string) cell->string = ""; // We have to assume it allocated successfully
}

View File

@ -11,7 +11,6 @@ namespace Components
private:
static std::unordered_map<std::string, Game::StringTable*> StringTableMap;
static int Hash(const char* data);
static Game::StringTable* LoadObject(std::string filename);
};
}

View File

@ -260,6 +260,7 @@ namespace Game
Steam_JoinLobby_t Steam_JoinLobby = Steam_JoinLobby_t(0x49CF70);
StringTable_Lookup_t StringTable_Lookup = StringTable_Lookup_t(0x42F0E0);
StringTable_HashString_t StringTable_HashString = StringTable_HashString_t(0x475EB0);
SV_AddTestClient_t SV_AddTestClient = SV_AddTestClient_t(0x48AD30);
SV_GameClientNum_Score_t SV_GameClientNum_Score = SV_GameClientNum_Score_t(0x469AC0);

View File

@ -622,6 +622,9 @@ namespace Game
typedef const char*(__cdecl * StringTable_Lookup_t)(StringTable *table, const int comparisonColumn, const char *value, const int valueColumn);
extern StringTable_Lookup_t StringTable_Lookup;
typedef int(__cdecl * StringTable_HashString_t)(const char* string);
extern StringTable_HashString_t StringTable_HashString;
typedef gentity_t*(__cdecl* SV_AddTestClient_t)();
extern SV_AddTestClient_t SV_AddTestClient;