Add implementation for stringtable assetloader iw4

This commit is contained in:
Jan
2022-01-02 01:34:42 +01:00
parent 8e2b9f4a62
commit 87c2e58c4b
6 changed files with 88 additions and 5 deletions

View File

@ -4,6 +4,22 @@
using namespace IW4;
int Common::StringTable_HashString(const char* str)
{
if (!str)
return 0;
auto result = 0;
auto offset = 0;
while (str[offset])
{
const auto c = tolower(str[offset++]);
result = c + 31 * result;
}
return result;
}
PackedTexCoords Common::Vec2PackTexCoords(const vec2_t* in)
{
return PackedTexCoords{Pack32::Vec2PackTexCoords(reinterpret_cast<const float*>(in))};

View File

@ -198,6 +198,8 @@ namespace IW4
class Common
{
public:
static int StringTable_HashString(const char* str);
static PackedTexCoords Vec2PackTexCoords(const vec2_t* in);
static PackedUnitVec Vec3PackUnitVec(const vec3_t* in);
static GfxColor Vec4PackGfxColor(const vec4_t* in);