Skip to content

Commit

Permalink
Merge pull request #272 from Laupetin/feature/iwi-converter
Browse files Browse the repository at this point in the history
feat: iwi converter tool
  • Loading branch information
Laupetin authored Sep 27, 2024
2 parents fabefc8 + d2fa1f4 commit a8fefbc
Show file tree
Hide file tree
Showing 139 changed files with 2,828 additions and 2,457 deletions.
4 changes: 4 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ group ""
-- ========================
include "src/Common.lua"
include "src/Crypto.lua"
include "src/ImageConverter.lua"
include "src/Linker.lua"
include "src/Parser.lua"
include "src/RawTemplater.lua"
Expand All @@ -125,6 +126,7 @@ include "src/ZoneLoading.lua"
include "src/ZoneWriting.lua"
include "src/ZoneCommon.lua"
include "src/ObjCommon.lua"
include "src/ObjImage.lua"
include "src/ObjLoading.lua"
include "src/ObjWriting.lua"
include "tools/scripts/raw.lua"
Expand All @@ -141,6 +143,7 @@ group "Components"
ZoneLoading:project()
ZoneWriting:project()
ObjCommon:project()
ObjImage:project()
ObjLoading:project()
ObjWriting:project()
group ""
Expand All @@ -155,6 +158,7 @@ group ""
group "Tools"
Linker:project()
Unlinker:project()
ImageConverter:project()
group ""

group "Raw"
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW3/IW3.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "IW3_Assets.h"

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW3/IW3_Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,6 @@ namespace IW3
// void/*IDirect3DTexture9*/* map;
// void/*IDirect3DVolumeTexture9*/* volmap;
// void/*IDirect3DCubeTexture9*/* cubemap;
Texture* texture;
GfxImageLoadDef* loadDef;
};

Expand Down
2 changes: 2 additions & 0 deletions src/Common/Game/IW4/CommonIW4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "Utils/Pack.h"

#include <cctype>

using namespace IW4;

int Common::StringTable_HashString(const char* str)
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW4/IW4.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "IW4_Assets.h"

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW4/IW4_Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,6 @@ namespace IW4
// IDirect3DTexture9* map;
// IDirect3DVolumeTexture9* volmap;
// IDirect3DCubeTexture9* cubemap;
Texture* texture;
GfxImageLoadDef* loadDef;
};

Expand Down
2 changes: 2 additions & 0 deletions src/Common/Game/IW5/CommonIW5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "Utils/Pack.h"

#include <cctype>

using namespace IW5;

int Common::StringTable_HashString(const char* str)
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW5/IW5.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "IW5_Assets.h"

Expand Down
3 changes: 0 additions & 3 deletions src/Common/Game/IW5/IW5_Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,6 @@ namespace IW5
// IDirect3DTexture9* map;
// IDirect3DVolumeTexture9* volmap;
// IDirect3DCubeTexture9* cubemap;
#ifndef __ida
Texture* texture;
#endif
GfxImageLoadDef* loadDef;
};

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/T5/T5.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "T5_Assets.h"

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/T5/T5_Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,6 @@ namespace T5
// IDirect3DTexture9* map;
// IDirect3DVolumeTexture9* volmap;
// IDirect3DCubeTexture9* cubemap;
Texture* texture;
GfxImageLoadDef* loadDef;
};

Expand Down
54 changes: 0 additions & 54 deletions src/Common/Game/T6/CommonT6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,8 @@

#include "Utils/Pack.h"

#include <cctype>

using namespace T6;

int Common::Com_HashKey(const char* str, const int maxLen)
{
if (str == nullptr)
return 0;

int hash = 0;
for (int i = 0; i < maxLen; i++)
{
if (str[i] == '\0')
break;

hash += str[i] * (0x77 + i);
}

return hash ^ ((hash ^ (hash >> 10)) >> 10);
}

int Common::Com_HashString(const char* str)
{
if (!str)
return 0;

auto result = 0x1505;
auto offset = 0;
while (str[offset])
{
const auto c = tolower(str[offset++]);
result = c + 33 * result;
}

return result;
}

int Common::Com_HashString(const char* str, const int len)
{
if (!str)
return 0;

int result = 0x1505;
int offset = 0;
while (str[offset])
{
if (len > 0 && offset >= len)
break;

const int c = tolower(str[offset++]);
result = c + 33 * result;
}

return result;
}

PackedTexCoords Common::Vec2PackTexCoords(const float (&in)[2])
{
return PackedTexCoords{pack32::Vec2PackTexCoordsUV(in)};
Expand Down
56 changes: 53 additions & 3 deletions src/Common/Game/T6/CommonT6.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,64 @@

#include "T6.h"

#include <cctype>

namespace T6
{
class Common
{
public:
static int Com_HashKey(const char* str, int maxLen);
static int Com_HashString(const char* str);
static int Com_HashString(const char* str, int len);
static constexpr int Com_HashKey(const char* str, const int maxLen)
{
if (str == nullptr)
return 0;

int hash = 0;
for (int i = 0; i < maxLen; i++)
{
if (str[i] == '\0')
break;

hash += str[i] * (0x77 + i);
}

return hash ^ ((hash ^ (hash >> 10)) >> 10);
}

static constexpr int Com_HashString(const char* str)
{
if (!str)
return 0;

auto result = 0x1505;
auto offset = 0;
while (str[offset])
{
const auto c = tolower(str[offset++]);
result = c + 33 * result;
}

return result;
}

static constexpr int Com_HashString(const char* str, const int len)
{
if (!str)
return 0;

int result = 0x1505;
int offset = 0;
while (str[offset])
{
if (len > 0 && offset >= len)
break;

const int c = tolower(str[offset++]);
result = c + 33 * result;
}

return result;
}

static constexpr uint32_t R_HashString(const char* str, uint32_t hash)
{
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/T6/T6.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d11.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "T6_Assets.h"

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/T6/T6_Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ namespace T6
union GfxTexture
{
void /*ID3D11ShaderResourceView*/* basemap;
Texture* texture;
GfxImageLoadDef* loadDef;
};

Expand Down
127 changes: 0 additions & 127 deletions src/Common/Image/Texture.h

This file was deleted.

Loading

0 comments on commit a8fefbc

Please sign in to comment.