mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-07 21:38:01 -05:00
Compare commits
220 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c4a7c8c9b7 | ||
|
2aa8d4e3dc | ||
|
4e37ab860b | ||
|
2973704db4 | ||
|
8a85ee776b | ||
|
a379d5db07 | ||
|
2cc63c6a0a | ||
|
c7132546d4 | ||
|
a5e34d7081 | ||
|
7f4d582fbd | ||
|
f462520c83 | ||
|
518bf1fba2 | ||
|
b19bb4d55a | ||
|
54c72af9a0 | ||
|
da1c3956e5 | ||
|
49867a3474 | ||
|
dc43671930 | ||
|
a8cf9b79fa | ||
|
e67d3a8040 | ||
|
200479e319 | ||
|
fa1b99a28a | ||
|
f47c0c5074 | ||
|
5d107bd7f6 | ||
|
302206b4de | ||
|
bf9094db2d | ||
|
450bd46902 | ||
|
2a4c0dcb43 | ||
|
c28d1f6000 | ||
|
d7e7726f76 | ||
|
2c45942d13 | ||
|
23ece27d07 | ||
|
11d01763d6 | ||
|
404bba6142 | ||
|
efeffe9e90 | ||
|
a1b48ceeeb | ||
|
f802b4e130 | ||
|
38dd7eecad | ||
|
4798a20699 | ||
|
e7d9d9a845 | ||
|
182b0b2530 | ||
|
dc4956c077 | ||
|
9b7f384a3d | ||
|
5b97cbf3f8 | ||
|
0dde2478a7 | ||
|
35cb6636a1 | ||
|
b92e85dc14 | ||
|
955df98279 | ||
|
eb16dfcd00 | ||
|
4ce82ad63c | ||
|
446c38d8ee | ||
|
ed029bc24d | ||
|
8b85cadb77 | ||
|
9e940a6f53 | ||
|
50612d117e | ||
|
115765ad86 | ||
|
1b579b1bc3 | ||
|
68ee502c72 | ||
|
0103e4631f | ||
|
7f59d35e87 | ||
|
f4870de1a7 | ||
|
547da3fdf9 | ||
|
1fe1b30831 | ||
|
3adbe5a275 | ||
|
d938f91541 | ||
|
2eefad105e | ||
|
d94a004433 | ||
|
4ccd0a55cf | ||
|
4e9599aabf | ||
|
088d14f894 | ||
|
365b627523 | ||
|
a6107e24a2 | ||
|
3b00c1d45b | ||
|
de43e33dcd | ||
|
5d0c94e430 | ||
|
ee4301952a | ||
|
5635470b6e | ||
|
60f5c1a18f | ||
|
c61dddf0e2 | ||
|
2271f350f1 | ||
|
a8c6620c1f | ||
|
7cf9804117 | ||
|
70a1a4aba2 | ||
|
8d171a2e9e | ||
|
8dbba71944 | ||
|
41dcabf145 | ||
|
cf8969c1a6 | ||
|
10cbd47bdc | ||
|
f7af6e4480 | ||
|
76c22ffce2 | ||
|
dc282170bc | ||
|
82d38ab710 | ||
|
0fbfb860c0 | ||
|
e14f0743da | ||
|
fb20cbf81c | ||
|
101487d869 | ||
|
1cccfe352b | ||
|
dbcf7d86af | ||
|
f888d7a5d4 | ||
|
74b9f7b010 | ||
|
ba4cb85639 | ||
|
da90bbd356 | ||
|
13b07c0fe4 | ||
|
199446b09f | ||
|
37fe6b6a5c | ||
|
ea5d27a7f9 | ||
|
38d948ebdd | ||
|
9f8a933277 | ||
|
9f738da517 | ||
|
785cf8c025 | ||
|
8946c28eab | ||
|
b0f89e5842 | ||
|
0f3ee1fa79 | ||
|
c8cd6826c1 | ||
|
5afc24fd89 | ||
|
598abe095b | ||
|
d6eee273ff | ||
|
7edbe7378b | ||
|
2aeeccd492 | ||
|
2a45357d5c | ||
|
b1666ad1da | ||
|
b83bafb0f8 | ||
|
e750e3ffd9 | ||
|
d5b6c6e9c2 | ||
|
d6c1ef775e | ||
|
c05d4ea34e | ||
|
b2d9bf416d | ||
|
7aebe085b3 | ||
|
ef79504e71 | ||
|
812f7e1f91 | ||
|
f2501fdc0b | ||
|
eff80a0318 | ||
|
8ac276f3f6 | ||
|
3134ec5a37 | ||
|
0d35696940 | ||
|
b215b22018 | ||
|
a447dd29fa | ||
|
985996975b | ||
|
f235798cf6 | ||
|
0228e86980 | ||
|
01302cf061 | ||
|
6f31e8cc29 | ||
|
37d52ae8da | ||
|
481d301545 | ||
|
d3bb99e92c | ||
|
cec70e783f | ||
|
a2c8129a13 | ||
|
e13eb256bb | ||
|
aab510c917 | ||
|
820fe47473 | ||
|
0366b24bd7 | ||
|
49f0794545 | ||
|
20911d552d | ||
|
1748f9e1a5 | ||
|
a37b5fee8c | ||
|
42e2eb80b3 | ||
|
885c57bfa5 | ||
|
fa88b135f9 | ||
|
56c4eeb5cd | ||
|
0fcae6a55a | ||
|
f97f38dc31 | ||
|
95f5dca5e0 | ||
|
f2723255f5 | ||
|
11cb93f736 | ||
|
e40d688e11 | ||
|
2eeb20d1cd | ||
|
7b79504477 | ||
|
4cc7ab77d5 | ||
|
08fb6b0496 | ||
|
a871889c13 | ||
|
81bc21eacf | ||
|
aec779dae5 | ||
|
97c4a23d5e | ||
|
0c587e5e5f | ||
|
4ac38bfc66 | ||
|
34a0bd4f4f | ||
|
047e8aa125 | ||
|
b5303475d9 | ||
|
4adc9115b2 | ||
|
a4347b0b0d | ||
|
4e5c72d79a | ||
|
58f5f66dcf | ||
|
54d19dcc8a | ||
|
f05a21984a | ||
|
b071beea3f | ||
|
548c0c23bf | ||
|
6d186bc09c | ||
|
96dc2c9318 | ||
|
e4c08e1372 | ||
|
1b6824f2bd | ||
|
0eb0383051 | ||
|
222d96a923 | ||
|
07dccbf2f8 | ||
|
b24b6b1979 | ||
|
a220142e86 | ||
|
4c30bd129a | ||
|
3d3a0ca565 | ||
|
903bd5a960 | ||
|
2402d4f9c7 | ||
|
a21b410fd7 | ||
|
2b1ade2b5a | ||
|
d869de5881 | ||
|
2ce1a4e050 | ||
|
89e22329f8 | ||
|
bea601d932 | ||
|
826c1d2f2d | ||
|
0b91eeb932 | ||
|
94ca0ab79e | ||
|
f6d36b2d6e | ||
|
140eb7b7a4 | ||
|
708e759f8c | ||
|
80fa61b45c | ||
|
f436cd6caa | ||
|
4d0b0651eb | ||
|
7a639a359c | ||
|
990bfe27df | ||
|
b4194eff28 | ||
|
8ace49b715 | ||
|
b623ed49a0 | ||
|
0ffbdf5b73 | ||
|
f930c874b8 |
19
.github/workflows/ci.yaml
vendored
19
.github/workflows/ci.yaml
vendored
@ -10,6 +10,9 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-test-linux:
|
build-test-linux:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
build_arch: [x86, x64]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ubuntu:24.04
|
container: ubuntu:24.04
|
||||||
steps:
|
steps:
|
||||||
@ -35,10 +38,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: make -C build -j$(nproc) config=release_x86 all
|
run: make -C build -j$(nproc) config=release_${{ matrix.build_arch }} all
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: ${{ github.workspace }}/build/lib/Release_x86/tests
|
working-directory: ${{ github.workspace }}/build/lib/Release_${{ matrix.build_arch }}/tests
|
||||||
run: |
|
run: |
|
||||||
./ObjCommonTests
|
./ObjCommonTests
|
||||||
./ObjCompilingTests
|
./ObjCompilingTests
|
||||||
@ -48,6 +51,14 @@ jobs:
|
|||||||
./ZoneCommonTests
|
./ZoneCommonTests
|
||||||
|
|
||||||
build-test-windows:
|
build-test-windows:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
build_arch: [x86, x64]
|
||||||
|
include:
|
||||||
|
- build_arch: x86
|
||||||
|
msbuild_config: Win32
|
||||||
|
- build_arch: x64
|
||||||
|
msbuild_config: x64
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@ -66,10 +77,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: msbuild /m /p:Configuration=Release /p:Platform=Win32 build
|
run: msbuild /m /p:Configuration=Release /p:Platform=${{ matrix.msbuild_config }} build
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: ${{ github.workspace }}/build/lib/Release_x86/tests
|
working-directory: ${{ github.workspace }}/build/lib/Release_${{ matrix.build_arch }}/tests
|
||||||
run: |
|
run: |
|
||||||
$combinedExitCode = 0
|
$combinedExitCode = 0
|
||||||
./ObjCommonTests
|
./ObjCommonTests
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -16,3 +16,6 @@
|
|||||||
[submodule "thirdparty/eigen"]
|
[submodule "thirdparty/eigen"]
|
||||||
path = thirdparty/eigen
|
path = thirdparty/eigen
|
||||||
url = https://gitlab.com/libeigen/eigen.git
|
url = https://gitlab.com/libeigen/eigen.git
|
||||||
|
[submodule "thirdparty/lz4"]
|
||||||
|
path = thirdparty/lz4
|
||||||
|
url = https://github.com/lz4/lz4.git
|
||||||
|
@ -13,7 +13,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| -------------------- | --------------- | --------------- | ----------------------------------------------------------------- |
|
| -------------------- | --------------- | --------------- | ----------------------------------------------------------------- |
|
||||||
| PhysPreset | ❌ | ❌ | |
|
| PhysPreset | ❌ | ❌ | |
|
||||||
| XAnimParts | ❌ | ❌ | |
|
| XAnimParts | ❌ | ❌ | |
|
||||||
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT`, `OBJ`, `GLB/GLTF`. |
|
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT/XMODEL_BIN`, `OBJ`, `GLB/GLTF`. |
|
||||||
| Material | ❌ | ❌ | |
|
| Material | ❌ | ❌ | |
|
||||||
| MaterialTechniqueSet | ❌ | ❌ | |
|
| MaterialTechniqueSet | ❌ | ❌ | |
|
||||||
| GfxImage | ✅ | ✅ | |
|
| GfxImage | ✅ | ✅ | |
|
||||||
@ -44,7 +44,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| PhysPreset | ✅ | ✅ | |
|
| PhysPreset | ✅ | ✅ | |
|
||||||
| PhysCollmap | ❌ | ❌ | |
|
| PhysCollmap | ❌ | ❌ | |
|
||||||
| XAnimParts | ❌ | ❌ | |
|
| XAnimParts | ❌ | ❌ | |
|
||||||
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT`, `OBJ`, `GLB/GLTF`. |
|
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT/XMODEL_BIN`, `OBJ`, `GLB/GLTF`. |
|
||||||
| Material | ❌ | ❌ | |
|
| Material | ❌ | ❌ | |
|
||||||
| MaterialPixelShader | ✅ | ✅ | Shaders are compiled. Only dumps/loads shader bytecode. |
|
| MaterialPixelShader | ✅ | ✅ | Shaders are compiled. Only dumps/loads shader bytecode. |
|
||||||
| MaterialVertexShader | ✅ | ✅ | Shaders are compiled. Only dumps/loads shader bytecode. |
|
| MaterialVertexShader | ✅ | ✅ | Shaders are compiled. Only dumps/loads shader bytecode. |
|
||||||
@ -85,7 +85,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| PhysCollmap | ❌ | ❌ | |
|
| PhysCollmap | ❌ | ❌ | |
|
||||||
| XAnimParts | ❌ | ❌ | |
|
| XAnimParts | ❌ | ❌ | |
|
||||||
| XModelSurfs | ❌ | ❌ | |
|
| XModelSurfs | ❌ | ❌ | |
|
||||||
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT`, `OBJ`, `GLB/GLTF`. |
|
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT/XMODEL_BIN`, `OBJ`, `GLB/GLTF`. |
|
||||||
| Material | ❌ | ❌ | |
|
| Material | ❌ | ❌ | |
|
||||||
| MaterialPixelShader | ❌ | ❌ | |
|
| MaterialPixelShader | ❌ | ❌ | |
|
||||||
| MaterialVertexShader | ❌ | ❌ | |
|
| MaterialVertexShader | ❌ | ❌ | |
|
||||||
@ -130,7 +130,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| PhysConstraints | ❌ | ❌ | |
|
| PhysConstraints | ❌ | ❌ | |
|
||||||
| DestructibleDef | ❌ | ❌ | |
|
| DestructibleDef | ❌ | ❌ | |
|
||||||
| XAnimParts | ❌ | ❌ | |
|
| XAnimParts | ❌ | ❌ | |
|
||||||
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT`, `OBJ`, `GLB/GLTF`. |
|
| XModel | ⁉️ | ❌ | Model data can be exported to `XMODEL_EXPORT/XMODEL_BIN`, `OBJ`, `GLB/GLTF`. |
|
||||||
| Material | ❌ | ❌ | |
|
| Material | ❌ | ❌ | |
|
||||||
| MaterialTechniqueSet | ❌ | ❌ | |
|
| MaterialTechniqueSet | ❌ | ❌ | |
|
||||||
| GfxImage | ✅ | ❌ | A few special image encodings are not yet supported. |
|
| GfxImage | ✅ | ❌ | A few special image encodings are not yet supported. |
|
||||||
@ -167,7 +167,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| PhysConstraints | ✅ | ✅ | |
|
| PhysConstraints | ✅ | ✅ | |
|
||||||
| DestructibleDef | ❌ | ❌ | |
|
| DestructibleDef | ❌ | ❌ | |
|
||||||
| XAnimParts | ❌ | ❌ | |
|
| XAnimParts | ❌ | ❌ | |
|
||||||
| XModel | ✅ | ✅ | Model data can be exported to `XMODEL_EXPORT`, `OBJ`, `GLB/GLTF`. |
|
| XModel | ✅ | ✅ | Model data can be exported to `XMODEL_EXPORT/XMODEL_BIN`, `OBJ`, `GLB/GLTF`. |
|
||||||
| Material | ⁉️ | ⁉️ | Dumping/Loading is currently possible for materials in their compiled form. There is currently no material pipeline. |
|
| Material | ⁉️ | ⁉️ | Dumping/Loading is currently possible for materials in their compiled form. There is currently no material pipeline. |
|
||||||
| MaterialTechniqueSet | ⁉️ | ❌ | Only dumps compiled shaders. |
|
| MaterialTechniqueSet | ⁉️ | ❌ | Only dumps compiled shaders. |
|
||||||
| GfxImage | ✅ | ✅ | A few special image encodings are not yet supported. |
|
| GfxImage | ✅ | ✅ | A few special image encodings are not yet supported. |
|
||||||
@ -177,7 +177,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| ComWorld | ❌ | ❌ | |
|
| ComWorld | ❌ | ❌ | |
|
||||||
| GameWorldSp | ❌ | ❌ | |
|
| GameWorldSp | ❌ | ❌ | |
|
||||||
| GameWorldMp | ❌ | ❌ | |
|
| GameWorldMp | ❌ | ❌ | |
|
||||||
| MapEnts | ❌ | ❌ | |
|
| MapEnts | ✅ | ❌ | |
|
||||||
| GfxWorld | ❌ | ❌ | |
|
| GfxWorld | ❌ | ❌ | |
|
||||||
| GfxLightDef | ❌ | ❌ | |
|
| GfxLightDef | ❌ | ❌ | |
|
||||||
| Font_s | ❌ | ❌ | |
|
| Font_s | ❌ | ❌ | |
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
set PREMAKE_URL="https://github.com/premake/premake-core/releases/download/v5.0.0-beta4/premake-5.0.0-beta4-windows.zip"
|
set PREMAKE_URL="https://github.com/premake/premake-core/releases/download/v5.0.0-beta6/premake-5.0.0-beta6-windows.zip"
|
||||||
set PREMAKE_HASH="12d741d3b70445b025c03e26148e2d129801041fa5ddde61b4ac888a76017395"
|
set PREMAKE_HASH="c34a6e0b15f119f6284886298fdd8df543af87ad16f3ce5f4d0a847be2a88343"
|
||||||
|
|
||||||
@REM The following variables can be set:
|
@REM The following variables can be set:
|
||||||
@REM PREMAKE_NO_GLOBAL - Ignore premake5 executable from path
|
@REM PREMAKE_NO_GLOBAL - Ignore premake5 executable from path
|
||||||
@ -28,7 +28,7 @@ IF ERRORLEVEL 1 (
|
|||||||
)
|
)
|
||||||
|
|
||||||
echo Extracting...
|
echo Extracting...
|
||||||
%POWERSHELL_BIN% -NoProfile -NonInteractive -Command "Expand-Archive -LiteralPath build/premake.zip -DestinationPath build"
|
%POWERSHELL_BIN% -NoProfile -NonInteractive -Command "Expand-Archive -LiteralPath build/premake.zip -DestinationPath build -Force"
|
||||||
IF ERRORLEVEL 1 (
|
IF ERRORLEVEL 1 (
|
||||||
echo Extraction failed >&2
|
echo Extraction failed >&2
|
||||||
exit 2
|
exit 2
|
||||||
@ -59,8 +59,11 @@ IF "%PREMAKE_NO_GLOBAL%" EQU "" (
|
|||||||
)
|
)
|
||||||
|
|
||||||
IF EXIST build/premake5.exe (
|
IF EXIST build/premake5.exe (
|
||||||
|
build\premake5.exe --version >NUL
|
||||||
|
IF NOT ERRORLEVEL 1 (
|
||||||
set PREMAKE_BIN="build/premake5.exe"
|
set PREMAKE_BIN="build/premake5.exe"
|
||||||
goto runpremake
|
goto runpremake
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%PREMAKE_NO_PROMPT%" NEQ "" (
|
if "%PREMAKE_NO_PROMPT%" NEQ "" (
|
||||||
|
21
generate.sh
21
generate.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PREMAKE_URL='https://github.com/premake/premake-core/releases/download/v5.0.0-beta4/premake-5.0.0-beta4-linux.tar.gz'
|
PREMAKE_URL='https://github.com/premake/premake-core/releases/download/v5.0.0-beta6/premake-5.0.0-beta6-linux.tar.gz'
|
||||||
PREMAKE_HASH='4356ab7cdec6085183d68fb240089376eacdc2fb751ffbd8063d797ae43abeb3'
|
PREMAKE_HASH='fade2839ace1a2953556693e6f3d8f9b8b2897894b5a1f2ad477cdf8e9af042a'
|
||||||
|
|
||||||
# The following variables can be set:
|
# The following variables can be set:
|
||||||
# PREMAKE_NO_GLOBAL - Ignore premake5 executable from path
|
# PREMAKE_NO_GLOBAL - Ignore premake5 executable from path
|
||||||
@ -46,18 +46,23 @@ function install_premake {
|
|||||||
chmod +x build/premake5
|
chmod +x build/premake5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expect_inside_git_repository {
|
||||||
|
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
||||||
|
if [ ! -d ".git" ] && [ ! "$inside_git_repo" ]; then
|
||||||
|
echo "You must clone the OpenAssetTools repository using 'git clone'. Please read README.md." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Go to repository root
|
# Go to repository root
|
||||||
cd "$(dirname "$0")" || exit 2
|
cd "$(dirname "$0")" || exit 2
|
||||||
|
|
||||||
if [[ ! -d ".git" ]]; then
|
expect_inside_git_repository
|
||||||
echo "You must clone the OpenAssetTools repository using 'git clone'. Please read README.md." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
PREMAKE_BIN=''
|
PREMAKE_BIN=''
|
||||||
if [[ -z "$PREMAKE_NO_GLOBAL" ]] && [[ -x "$(command -v premake5)" ]]; then
|
if [[ -z "$PREMAKE_NO_GLOBAL" ]] && [[ -x "$(command -v premake5)" ]]; then
|
||||||
PREMAKE_BIN='premake5'
|
PREMAKE_BIN='premake5'
|
||||||
elif [[ -x "$(command -v build/premake5)" ]]; then
|
elif [[ -x "$(command -v build/premake5)" ]] && [[ ! -z "$(build/premake5 --version)" ]]; then
|
||||||
PREMAKE_BIN='build/premake5'
|
PREMAKE_BIN='build/premake5'
|
||||||
else
|
else
|
||||||
echo "Could not find premake5. You can either install it yourself or this script download it for you."
|
echo "Could not find premake5. You can either install it yourself or this script download it for you."
|
||||||
@ -72,4 +77,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
$PREMAKE_BIN $@ gmake2
|
$PREMAKE_BIN $@ gmake
|
||||||
|
14
premake5.lua
14
premake5.lua
@ -1,4 +1,4 @@
|
|||||||
require("premake", ">=5.0.0-beta4")
|
require("premake", ">=5.0.0-beta5")
|
||||||
|
|
||||||
include "tools/scripts/folders.lua"
|
include "tools/scripts/folders.lua"
|
||||||
include "tools/scripts/including.lua"
|
include "tools/scripts/including.lua"
|
||||||
@ -16,7 +16,7 @@ workspace "OpenAssetTools"
|
|||||||
objdir "%{wks.location}/obj"
|
objdir "%{wks.location}/obj"
|
||||||
symbols "On"
|
symbols "On"
|
||||||
systemversion "latest"
|
systemversion "latest"
|
||||||
cppdialect "C++20"
|
cppdialect "C++23"
|
||||||
largeaddressaware "on"
|
largeaddressaware "on"
|
||||||
|
|
||||||
flags {
|
flags {
|
||||||
@ -54,6 +54,10 @@ workspace "OpenAssetTools"
|
|||||||
symbols "On"
|
symbols "On"
|
||||||
filter {}
|
filter {}
|
||||||
|
|
||||||
|
filter {"system:windows", "configurations:Debug" }
|
||||||
|
buildoptions { "/bigobj" }
|
||||||
|
filter {}
|
||||||
|
|
||||||
filter "configurations:Release"
|
filter "configurations:Release"
|
||||||
defines "NDEBUG"
|
defines "NDEBUG"
|
||||||
optimize "Full"
|
optimize "Full"
|
||||||
@ -93,6 +97,7 @@ include "thirdparty/minilzo.lua"
|
|||||||
include "thirdparty/minizip.lua"
|
include "thirdparty/minizip.lua"
|
||||||
include "thirdparty/salsa20.lua"
|
include "thirdparty/salsa20.lua"
|
||||||
include "thirdparty/zlib.lua"
|
include "thirdparty/zlib.lua"
|
||||||
|
include "thirdparty/lz4.lua"
|
||||||
|
|
||||||
-- ThirdParty group: All projects that are external dependencies
|
-- ThirdParty group: All projects that are external dependencies
|
||||||
group "ThirdParty"
|
group "ThirdParty"
|
||||||
@ -105,13 +110,14 @@ group "ThirdParty"
|
|||||||
minizip:project()
|
minizip:project()
|
||||||
salsa20:project()
|
salsa20:project()
|
||||||
zlib:project()
|
zlib:project()
|
||||||
|
lz4:project()
|
||||||
group ""
|
group ""
|
||||||
|
|
||||||
-- ========================
|
-- ========================
|
||||||
-- Projects
|
-- Projects
|
||||||
-- ========================
|
-- ========================
|
||||||
include "src/Common.lua"
|
include "src/Common.lua"
|
||||||
include "src/Crypto.lua"
|
include "src/Cryptography.lua"
|
||||||
include "src/ImageConverter.lua"
|
include "src/ImageConverter.lua"
|
||||||
include "src/Linker.lua"
|
include "src/Linker.lua"
|
||||||
include "src/Parser.lua"
|
include "src/Parser.lua"
|
||||||
@ -135,7 +141,7 @@ include "tools/scripts/raw.lua"
|
|||||||
-- Components group: All projects assist or are part of a tool
|
-- Components group: All projects assist or are part of a tool
|
||||||
group "Components"
|
group "Components"
|
||||||
Common:project()
|
Common:project()
|
||||||
Crypto:project()
|
Cryptography:project()
|
||||||
Parser:project()
|
Parser:project()
|
||||||
Utils:project()
|
Utils:project()
|
||||||
ZoneCode:project()
|
ZoneCode:project()
|
||||||
|
23
scripts/build.sh
Executable file
23
scripts/build.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Go to repository root
|
||||||
|
cd "$(dirname "$0")/.." || exit 2
|
||||||
|
|
||||||
|
TARGET='all'
|
||||||
|
ARCHITECTURE='x86'
|
||||||
|
CONFIG='debug'
|
||||||
|
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
if [ "$var" == "debug" ] || [ "$var" == "release" ]; then
|
||||||
|
CONFIG="$var"
|
||||||
|
elif [ "$var" == "x86" ] || [ "$var" == "x64" ]; then
|
||||||
|
ARCHITECTURE="$var"
|
||||||
|
else
|
||||||
|
TARGET="$var"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Building config=${CONFIG} architecture=${ARCHITECTURE} target=${TARGET}"
|
||||||
|
make -C build -j$(nproc) config=${CONFIG}_${ARCHITECTURE} "${TARGET}"
|
||||||
|
|
@ -5,3 +5,5 @@ cd "$(dirname "$0")/.." || exit 2
|
|||||||
|
|
||||||
make -C build -j$(nproc) config=debug_x86 clean
|
make -C build -j$(nproc) config=debug_x86 clean
|
||||||
make -C build -j$(nproc) config=release_x86 clean
|
make -C build -j$(nproc) config=release_x86 clean
|
||||||
|
make -C build -j$(nproc) config=debug_x64 clean
|
||||||
|
make -C build -j$(nproc) config=release_x64 clean
|
||||||
|
@ -135,7 +135,7 @@ namespace IW3
|
|||||||
typedef float vec2_t[2];
|
typedef float vec2_t[2];
|
||||||
typedef float vec3_t[3];
|
typedef float vec3_t[3];
|
||||||
typedef float vec4_t[4];
|
typedef float vec4_t[4];
|
||||||
typedef tdef_align(128) unsigned int raw_uint128;
|
typedef tdef_align32(128) unsigned int raw_uint128;
|
||||||
|
|
||||||
struct XModelPiece
|
struct XModelPiece
|
||||||
{
|
{
|
||||||
@ -179,7 +179,7 @@ namespace IW3
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned char ByteVec[3];
|
typedef unsigned char ByteVec[3];
|
||||||
typedef tdef_align(4) unsigned short UShortVec[3];
|
typedef tdef_align32(4) unsigned short UShortVec[3];
|
||||||
|
|
||||||
union XAnimDynamicIndicesTrans
|
union XAnimDynamicIndicesTrans
|
||||||
{
|
{
|
||||||
@ -214,7 +214,7 @@ namespace IW3
|
|||||||
XAnimPartTransData u;
|
XAnimPartTransData u;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) short XQuat[2];
|
typedef tdef_align32(4) short XQuat[2];
|
||||||
|
|
||||||
union XAnimDynamicIndicesQuat
|
union XAnimDynamicIndicesQuat
|
||||||
{
|
{
|
||||||
@ -360,7 +360,7 @@ namespace IW3
|
|||||||
uint16_t* vertsBlend;
|
uint16_t* vertsBlend;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) uint16_t r_index16_t;
|
typedef tdef_align32(16) uint16_t r_index16_t;
|
||||||
|
|
||||||
struct XSurface
|
struct XSurface
|
||||||
{
|
{
|
||||||
@ -709,7 +709,7 @@ namespace IW3
|
|||||||
MaterialTextureDefInfo u;
|
MaterialTextureDefInfo u;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gcc_align(8) GfxDrawSurfFields
|
struct gcc_align32(8) GfxDrawSurfFields
|
||||||
{
|
{
|
||||||
uint64_t objectId : 16;
|
uint64_t objectId : 16;
|
||||||
uint64_t reflectionProbeIndex : 8;
|
uint64_t reflectionProbeIndex : 8;
|
||||||
@ -724,8 +724,8 @@ namespace IW3
|
|||||||
|
|
||||||
union GfxDrawSurf
|
union GfxDrawSurf
|
||||||
{
|
{
|
||||||
gcc_align(8) GfxDrawSurfFields fields;
|
gcc_align32(8) GfxDrawSurfFields fields;
|
||||||
gcc_align(8) uint64_t packed;
|
gcc_align32(8) uint64_t packed;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum materialSurfType_t
|
enum materialSurfType_t
|
||||||
@ -1314,9 +1314,9 @@ namespace IW3
|
|||||||
{
|
{
|
||||||
char levelCount;
|
char levelCount;
|
||||||
char flags;
|
char flags;
|
||||||
int16_t dimensions[3];
|
uint16_t dimensions[3];
|
||||||
int format;
|
int format;
|
||||||
int resourceSize;
|
unsigned int resourceSize;
|
||||||
char data[1];
|
char data[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1605,7 +1605,7 @@ namespace IW3
|
|||||||
cLeaf_t leaf;
|
cLeaf_t leaf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) cbrush_t
|
struct type_align32(16) cbrush_t
|
||||||
{
|
{
|
||||||
float mins[3];
|
float mins[3];
|
||||||
int contents;
|
int contents;
|
||||||
@ -1671,7 +1671,7 @@ namespace IW3
|
|||||||
|
|
||||||
typedef unsigned short LeafBrush;
|
typedef unsigned short LeafBrush;
|
||||||
|
|
||||||
typedef tdef_align(16) cbrush_t cbrush_array_t;
|
typedef tdef_align32(16) cbrush_t cbrush_array_t;
|
||||||
|
|
||||||
struct clipMap_t
|
struct clipMap_t
|
||||||
{
|
{
|
||||||
@ -2265,7 +2265,7 @@ namespace IW3
|
|||||||
char pad;
|
char pad;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) GfxSceneDynModel GfxSceneDynModel4;
|
typedef tdef_align32(4) GfxSceneDynModel GfxSceneDynModel4;
|
||||||
|
|
||||||
struct GfxWorld
|
struct GfxWorld
|
||||||
{
|
{
|
||||||
|
@ -155,10 +155,10 @@ namespace IW4
|
|||||||
void* data;
|
void* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) char raw_byte16;
|
typedef tdef_align32(16) char raw_byte16;
|
||||||
typedef tdef_align(16) float raw_float16;
|
typedef tdef_align32(16) float raw_float16;
|
||||||
typedef unsigned int raw_uint;
|
typedef unsigned int raw_uint;
|
||||||
typedef tdef_align(128) unsigned int raw_uint128;
|
typedef tdef_align32(128) unsigned int raw_uint128;
|
||||||
typedef unsigned char cbrushedge_t;
|
typedef unsigned char cbrushedge_t;
|
||||||
typedef unsigned short r_index_t;
|
typedef unsigned short r_index_t;
|
||||||
typedef float vec2_t[2];
|
typedef float vec2_t[2];
|
||||||
@ -289,7 +289,7 @@ namespace IW4
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned char ByteVec[3];
|
typedef unsigned char ByteVec[3];
|
||||||
typedef tdef_align(4) unsigned short UShortVec[3];
|
typedef tdef_align32(4) unsigned short UShortVec[3];
|
||||||
|
|
||||||
union XAnimDynamicFrames
|
union XAnimDynamicFrames
|
||||||
{
|
{
|
||||||
@ -303,7 +303,7 @@ namespace IW4
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) XAnimPartTransFrames
|
struct type_align32(4) XAnimPartTransFrames
|
||||||
{
|
{
|
||||||
float mins[3];
|
float mins[3];
|
||||||
float size[3];
|
float size[3];
|
||||||
@ -330,9 +330,9 @@ namespace IW4
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) short XQuat2[2];
|
typedef tdef_align32(4) short XQuat2[2];
|
||||||
|
|
||||||
struct type_align(4) XAnimDeltaPartQuatDataFrames2
|
struct type_align32(4) XAnimDeltaPartQuatDataFrames2
|
||||||
{
|
{
|
||||||
XQuat2* frames;
|
XQuat2* frames;
|
||||||
XAnimDynamicIndicesQuat2 indices;
|
XAnimDynamicIndicesQuat2 indices;
|
||||||
@ -356,7 +356,7 @@ namespace IW4
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) short XQuat[4];
|
typedef tdef_align32(4) short XQuat[4];
|
||||||
|
|
||||||
struct XAnimDeltaPartQuatDataFrames
|
struct XAnimDeltaPartQuatDataFrames
|
||||||
{
|
{
|
||||||
@ -489,7 +489,7 @@ namespace IW4
|
|||||||
XSurfaceCollisionTree* collisionTree;
|
XSurfaceCollisionTree* collisionTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) uint16_t r_index16_t;
|
typedef tdef_align32(16) uint16_t r_index16_t;
|
||||||
|
|
||||||
struct XSurface
|
struct XSurface
|
||||||
{
|
{
|
||||||
@ -843,7 +843,7 @@ namespace IW4
|
|||||||
unsigned int toolFlags;
|
unsigned int toolFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gcc_align(8) GfxDrawSurfFields
|
struct gcc_align32(8) GfxDrawSurfFields
|
||||||
{
|
{
|
||||||
uint64_t objectId : 16;
|
uint64_t objectId : 16;
|
||||||
uint64_t reflectionProbeIndex : 8;
|
uint64_t reflectionProbeIndex : 8;
|
||||||
@ -860,8 +860,8 @@ namespace IW4
|
|||||||
|
|
||||||
union GfxDrawSurf
|
union GfxDrawSurf
|
||||||
{
|
{
|
||||||
gcc_align(8) GfxDrawSurfFields fields;
|
gcc_align32(8) GfxDrawSurfFields fields;
|
||||||
gcc_align(8) uint64_t packed;
|
gcc_align32(8) uint64_t packed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The sort key is translated to a numeric value inside the material templates
|
// The sort key is translated to a numeric value inside the material templates
|
||||||
@ -993,7 +993,7 @@ namespace IW4
|
|||||||
GfxStateBits* stateBitsTable;
|
GfxStateBits* stateBitsTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) GfxImageLoadDef
|
struct type_align32(4) GfxImageLoadDef
|
||||||
{
|
{
|
||||||
char levelCount;
|
char levelCount;
|
||||||
char pad[3];
|
char pad[3];
|
||||||
@ -2918,8 +2918,8 @@ namespace IW4
|
|||||||
float linkMaxs[2];
|
float linkMaxs[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(128) cbrush_t cbrush_array_t;
|
typedef tdef_align32(128) cbrush_t cbrush_array_t;
|
||||||
typedef tdef_align(128) Bounds BoundsArray;
|
typedef tdef_align32(128) Bounds BoundsArray;
|
||||||
|
|
||||||
struct clipMap_t
|
struct clipMap_t
|
||||||
{
|
{
|
||||||
@ -3539,7 +3539,7 @@ namespace IW4
|
|||||||
Bounds bounds;
|
Bounds bounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) GfxBrushModel
|
struct type_align32(4) GfxBrushModel
|
||||||
{
|
{
|
||||||
GfxBrushModelWritable writable;
|
GfxBrushModelWritable writable;
|
||||||
Bounds bounds;
|
Bounds bounds;
|
||||||
@ -3744,8 +3744,8 @@ namespace IW4
|
|||||||
int exponent;
|
int exponent;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(128) GfxCellTree GfxCellTree128;
|
typedef tdef_align32(128) GfxCellTree GfxCellTree128;
|
||||||
typedef tdef_align(4) GfxSceneDynModel GfxSceneDynModel4;
|
typedef tdef_align32(4) GfxSceneDynModel GfxSceneDynModel4;
|
||||||
|
|
||||||
struct GfxWorld
|
struct GfxWorld
|
||||||
{
|
{
|
||||||
|
@ -221,9 +221,9 @@ namespace IW5
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) char raw_byte16;
|
typedef tdef_align32(16) char raw_byte16;
|
||||||
typedef tdef_align(16) float raw_float16;
|
typedef tdef_align32(16) float raw_float16;
|
||||||
typedef tdef_align(128) unsigned int raw_uint128;
|
typedef tdef_align32(128) unsigned int raw_uint128;
|
||||||
typedef unsigned char raw_byte;
|
typedef unsigned char raw_byte;
|
||||||
typedef unsigned int raw_uint;
|
typedef unsigned int raw_uint;
|
||||||
typedef unsigned short r_index_t;
|
typedef unsigned short r_index_t;
|
||||||
@ -338,7 +338,7 @@ namespace IW5
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned char ByteVec[3];
|
typedef unsigned char ByteVec[3];
|
||||||
typedef tdef_align(4) unsigned short UShortVec[3];
|
typedef tdef_align32(4) unsigned short UShortVec[3];
|
||||||
|
|
||||||
union XAnimDynamicFrames
|
union XAnimDynamicFrames
|
||||||
{
|
{
|
||||||
@ -352,7 +352,7 @@ namespace IW5
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) XAnimPartTransFrames
|
struct type_align32(4) XAnimPartTransFrames
|
||||||
{
|
{
|
||||||
float mins[3];
|
float mins[3];
|
||||||
float size[3];
|
float size[3];
|
||||||
@ -379,9 +379,9 @@ namespace IW5
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) short XQuat2[2];
|
typedef tdef_align32(4) short XQuat2[2];
|
||||||
|
|
||||||
struct type_align(4) XAnimDeltaPartQuatDataFrames2
|
struct type_align32(4) XAnimDeltaPartQuatDataFrames2
|
||||||
{
|
{
|
||||||
XQuat2* frames;
|
XQuat2* frames;
|
||||||
XAnimDynamicIndicesQuat2 indices;
|
XAnimDynamicIndicesQuat2 indices;
|
||||||
@ -405,7 +405,7 @@ namespace IW5
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) short XQuat[4];
|
typedef tdef_align32(4) short XQuat[4];
|
||||||
|
|
||||||
struct XAnimDeltaPartQuatDataFrames
|
struct XAnimDeltaPartQuatDataFrames
|
||||||
{
|
{
|
||||||
@ -543,7 +543,7 @@ namespace IW5
|
|||||||
uint16_t i[3];
|
uint16_t i[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) XSurfaceTri XSurfaceTri16;
|
typedef tdef_align32(16) XSurfaceTri XSurfaceTri16;
|
||||||
|
|
||||||
struct XSurface
|
struct XSurface
|
||||||
{
|
{
|
||||||
@ -653,7 +653,7 @@ namespace IW5
|
|||||||
float quantization;
|
float quantization;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gcc_align(8) GfxDrawSurfFields
|
struct gcc_align32(8) GfxDrawSurfFields
|
||||||
{
|
{
|
||||||
uint64_t unused : 1;
|
uint64_t unused : 1;
|
||||||
uint64_t primarySortKey : 6;
|
uint64_t primarySortKey : 6;
|
||||||
@ -671,8 +671,8 @@ namespace IW5
|
|||||||
|
|
||||||
union GfxDrawSurf
|
union GfxDrawSurf
|
||||||
{
|
{
|
||||||
gcc_align(8) GfxDrawSurfFields fields;
|
gcc_align32(8) GfxDrawSurfFields fields;
|
||||||
gcc_align(8) uint64_t packed;
|
gcc_align32(8) uint64_t packed;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MaterialGameFlags
|
enum MaterialGameFlags
|
||||||
@ -1127,7 +1127,7 @@ namespace IW5
|
|||||||
MaterialTechnique* techniques[54];
|
MaterialTechnique* techniques[54];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) GfxImageLoadDef
|
struct type_align32(4) GfxImageLoadDef
|
||||||
{
|
{
|
||||||
char levelCount;
|
char levelCount;
|
||||||
char pad[3];
|
char pad[3];
|
||||||
@ -1339,8 +1339,8 @@ namespace IW5
|
|||||||
unsigned char edgeCount[2][3];
|
unsigned char edgeCount[2][3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(128) cbrush_t cbrush_array_t;
|
typedef tdef_align32(128) cbrush_t cbrush_array_t;
|
||||||
typedef tdef_align(128) Bounds BoundsArray;
|
typedef tdef_align32(128) Bounds BoundsArray;
|
||||||
|
|
||||||
struct ClipInfo
|
struct ClipInfo
|
||||||
{
|
{
|
||||||
@ -2190,7 +2190,7 @@ namespace IW5
|
|||||||
Bounds bounds;
|
Bounds bounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) GfxBrushModel
|
struct type_align32(4) GfxBrushModel
|
||||||
{
|
{
|
||||||
GfxBrushModelWritable writable;
|
GfxBrushModelWritable writable;
|
||||||
Bounds bounds;
|
Bounds bounds;
|
||||||
@ -2396,7 +2396,7 @@ namespace IW5
|
|||||||
int exponent;
|
int exponent;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(128) GfxCellTree GfxCellTree128;
|
typedef tdef_align32(128) GfxCellTree GfxCellTree128;
|
||||||
|
|
||||||
struct GfxWorld
|
struct GfxWorld
|
||||||
{
|
{
|
||||||
@ -3446,7 +3446,7 @@ namespace IW5
|
|||||||
SndAliasCustom projIgnitionSound;
|
SndAliasCustom projIgnitionSound;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) AttSight AttSight4;
|
typedef tdef_align32(4) AttSight AttSight4;
|
||||||
|
|
||||||
struct WeaponAttachment
|
struct WeaponAttachment
|
||||||
{
|
{
|
||||||
|
@ -193,20 +193,20 @@ namespace T5
|
|||||||
void* data;
|
void* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) char char16;
|
typedef tdef_align32(16) char char16;
|
||||||
typedef tdef_align(32) char byte32;
|
typedef tdef_align32(32) char byte32;
|
||||||
typedef tdef_align(128) char byte128;
|
typedef tdef_align32(128) char byte128;
|
||||||
|
|
||||||
typedef tdef_align(4) char char_align4;
|
typedef tdef_align32(4) char char_align4;
|
||||||
typedef tdef_align(128) char char_align128;
|
typedef tdef_align32(128) char char_align128;
|
||||||
|
|
||||||
typedef tdef_align(16) char raw_byte16;
|
typedef tdef_align32(16) char raw_byte16;
|
||||||
typedef tdef_align(128) char raw_byte128;
|
typedef tdef_align32(128) char raw_byte128;
|
||||||
|
|
||||||
typedef tdef_align(128) float float_align128;
|
typedef tdef_align32(128) float float_align128;
|
||||||
|
|
||||||
typedef char cbrushedge_t;
|
typedef char cbrushedge_t;
|
||||||
typedef tdef_align(128) unsigned int raw_uint128;
|
typedef tdef_align32(128) unsigned int raw_uint128;
|
||||||
|
|
||||||
typedef uint16_t ScriptString;
|
typedef uint16_t ScriptString;
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ namespace T5
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned char ByteVec[3];
|
typedef unsigned char ByteVec[3];
|
||||||
typedef tdef_align(4) unsigned short UShortVec[3];
|
typedef tdef_align32(4) unsigned short UShortVec[3];
|
||||||
|
|
||||||
union XAnimDynamicFrames
|
union XAnimDynamicFrames
|
||||||
{
|
{
|
||||||
@ -385,7 +385,7 @@ namespace T5
|
|||||||
XAnimPartTransData u;
|
XAnimPartTransData u;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) short XQuat[2];
|
typedef tdef_align32(4) short XQuat[2];
|
||||||
|
|
||||||
union XAnimDynamicIndicesQuat
|
union XAnimDynamicIndicesQuat
|
||||||
{
|
{
|
||||||
@ -542,7 +542,7 @@ namespace T5
|
|||||||
uint16_t i[3];
|
uint16_t i[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) XSurfaceTri XSurfaceTri16;
|
typedef tdef_align32(16) XSurfaceTri XSurfaceTri16;
|
||||||
|
|
||||||
struct XSurface
|
struct XSurface
|
||||||
{
|
{
|
||||||
@ -627,7 +627,7 @@ namespace T5
|
|||||||
int sflags;
|
int sflags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) BrushWrapper
|
struct type_align32(16) BrushWrapper
|
||||||
{
|
{
|
||||||
vec3_t mins;
|
vec3_t mins;
|
||||||
int contents;
|
int contents;
|
||||||
@ -650,7 +650,7 @@ namespace T5
|
|||||||
vec3_t halfLengths;
|
vec3_t halfLengths;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) PhysGeomInfo PhysGeomInfo16;
|
typedef tdef_align32(16) PhysGeomInfo PhysGeomInfo16;
|
||||||
|
|
||||||
struct PhysGeomList
|
struct PhysGeomList
|
||||||
{
|
{
|
||||||
@ -713,7 +713,7 @@ namespace T5
|
|||||||
PhysConstraints* physConstraints;
|
PhysConstraints* physConstraints;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gcc_align(8) GfxDrawSurfFields
|
struct gcc_align32(8) GfxDrawSurfFields
|
||||||
{
|
{
|
||||||
uint64_t objectId : 16;
|
uint64_t objectId : 16;
|
||||||
uint64_t fade : 4;
|
uint64_t fade : 4;
|
||||||
@ -732,8 +732,8 @@ namespace T5
|
|||||||
|
|
||||||
union GfxDrawSurf
|
union GfxDrawSurf
|
||||||
{
|
{
|
||||||
gcc_align(8) GfxDrawSurfFields fields;
|
gcc_align32(8) GfxDrawSurfFields fields;
|
||||||
gcc_align(8) uint64_t packed;
|
gcc_align32(8) uint64_t packed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MaterialInfo
|
struct MaterialInfo
|
||||||
@ -1138,7 +1138,7 @@ namespace T5
|
|||||||
SND_ASSET_FLAG_PAD_LOOP_BUFFER = 0x2,
|
SND_ASSET_FLAG_PAD_LOOP_BUFFER = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(2048) char snd_align_char;
|
typedef tdef_align32(2048) char snd_align_char;
|
||||||
|
|
||||||
struct snd_asset
|
struct snd_asset
|
||||||
{
|
{
|
||||||
@ -1164,7 +1164,7 @@ namespace T5
|
|||||||
snd_asset sound;
|
snd_asset sound;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(2048) char char_align_2048;
|
typedef tdef_align32(2048) char char_align_2048;
|
||||||
|
|
||||||
struct PrimedSound
|
struct PrimedSound
|
||||||
{
|
{
|
||||||
@ -1426,7 +1426,7 @@ namespace T5
|
|||||||
cLeaf_s leaf;
|
cLeaf_s leaf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) cbrush_t
|
struct type_align32(16) cbrush_t
|
||||||
{
|
{
|
||||||
float mins[3];
|
float mins[3];
|
||||||
int contents;
|
int contents;
|
||||||
@ -1935,7 +1935,7 @@ namespace T5
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) GfxLight
|
struct type_align32(16) GfxLight
|
||||||
{
|
{
|
||||||
char type;
|
char type;
|
||||||
char canUseShadowMap;
|
char canUseShadowMap;
|
||||||
@ -2142,7 +2142,7 @@ namespace T5
|
|||||||
char rgb[56][3];
|
char rgb[56][3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) char aligned_byte_pointer;
|
typedef tdef_align32(4) char aligned_byte_pointer;
|
||||||
|
|
||||||
struct GfxLightGrid
|
struct GfxLightGrid
|
||||||
{
|
{
|
||||||
@ -2220,7 +2220,7 @@ namespace T5
|
|||||||
uint16_t dynEntId;
|
uint16_t dynEntId;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) GfxSceneDynModel GfxSceneDynModel4;
|
typedef tdef_align32(4) GfxSceneDynModel GfxSceneDynModel4;
|
||||||
|
|
||||||
struct BModelDrawInfo
|
struct BModelDrawInfo
|
||||||
{
|
{
|
||||||
@ -2283,7 +2283,7 @@ namespace T5
|
|||||||
int stream2ByteOffset;
|
int stream2ByteOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) GfxSurface
|
struct type_align32(16) GfxSurface
|
||||||
{
|
{
|
||||||
srfTriangles_t tris;
|
srfTriangles_t tris;
|
||||||
Material* material;
|
Material* material;
|
||||||
@ -2935,7 +2935,7 @@ namespace T5
|
|||||||
ITEM_TYPE_MENUMODEL = 0x27
|
ITEM_TYPE_MENUMODEL = 0x27
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(8) itemDef_s
|
struct type_align32(8) itemDef_s
|
||||||
{
|
{
|
||||||
windowDef_t window;
|
windowDef_t window;
|
||||||
int type;
|
int type;
|
||||||
@ -2949,15 +2949,15 @@ namespace T5
|
|||||||
menuDef_t* parent;
|
menuDef_t* parent;
|
||||||
rectData_s* rectExpData;
|
rectData_s* rectExpData;
|
||||||
ExpressionStatement visibleExp;
|
ExpressionStatement visibleExp;
|
||||||
gcc_align(8) uint64_t showBits;
|
gcc_align32(8) uint64_t showBits;
|
||||||
gcc_align(8) uint64_t hideBits;
|
gcc_align32(8) uint64_t hideBits;
|
||||||
ExpressionStatement forecolorAExp;
|
ExpressionStatement forecolorAExp;
|
||||||
int ui3dWindowId;
|
int ui3dWindowId;
|
||||||
GenericEventHandler* onEvent;
|
GenericEventHandler* onEvent;
|
||||||
UIAnimInfo* animInfo;
|
UIAnimInfo* animInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(8) menuDef_t
|
struct type_align32(8) menuDef_t
|
||||||
{
|
{
|
||||||
windowDef_t window;
|
windowDef_t window;
|
||||||
const char* font;
|
const char* font;
|
||||||
@ -2984,8 +2984,8 @@ namespace T5
|
|||||||
GenericEventHandler* onEvent;
|
GenericEventHandler* onEvent;
|
||||||
ItemKeyHandler* onKey;
|
ItemKeyHandler* onKey;
|
||||||
ExpressionStatement visibleExp;
|
ExpressionStatement visibleExp;
|
||||||
gcc_align(8) uint64_t showBits;
|
gcc_align32(8) uint64_t showBits;
|
||||||
gcc_align(8) uint64_t hideBits;
|
gcc_align32(8) uint64_t hideBits;
|
||||||
const char* allowedBinding;
|
const char* allowedBinding;
|
||||||
const char* soundName;
|
const char* soundName;
|
||||||
int imageTrack;
|
int imageTrack;
|
||||||
|
@ -10,17 +10,17 @@ namespace T6
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef tdef_align(16) char char16;
|
typedef tdef_align32(16) char char16;
|
||||||
typedef tdef_align(32) char byte32;
|
typedef tdef_align32(32) char byte32;
|
||||||
typedef tdef_align(128) char byte128;
|
typedef tdef_align32(128) char byte128;
|
||||||
|
|
||||||
typedef tdef_align(4) char char_align4;
|
typedef tdef_align32(4) char char_align4;
|
||||||
typedef tdef_align(128) char char_align128;
|
typedef tdef_align32(128) char char_align128;
|
||||||
|
|
||||||
typedef tdef_align(16) char raw_byte16;
|
typedef tdef_align32(16) char raw_byte16;
|
||||||
typedef tdef_align(128) char raw_byte128;
|
typedef tdef_align32(128) char raw_byte128;
|
||||||
|
|
||||||
typedef tdef_align(128) float float_align128;
|
typedef tdef_align32(128) float float_align128;
|
||||||
|
|
||||||
typedef uint16_t ScriptString;
|
typedef uint16_t ScriptString;
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ namespace T6
|
|||||||
float lightingOriginRange;
|
float lightingOriginRange;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gcc_align(8) GfxDrawSurfFields
|
struct gcc_align32(8) GfxDrawSurfFields
|
||||||
{
|
{
|
||||||
uint64_t objectId : 16;
|
uint64_t objectId : 16;
|
||||||
uint64_t customIndex : 9;
|
uint64_t customIndex : 9;
|
||||||
@ -658,8 +658,8 @@ namespace T6
|
|||||||
|
|
||||||
union GfxDrawSurf
|
union GfxDrawSurf
|
||||||
{
|
{
|
||||||
gcc_align(8) GfxDrawSurfFields fields;
|
gcc_align32(8) GfxDrawSurfFields fields;
|
||||||
gcc_align(8) uint64_t packed;
|
gcc_align32(8) uint64_t packed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The sort key is translated to a numeric value inside the material templates
|
// The sort key is translated to a numeric value inside the material templates
|
||||||
@ -702,7 +702,7 @@ namespace T6
|
|||||||
MTL_GAMEFLAG_1000 = 0x1000,
|
MTL_GAMEFLAG_1000 = 0x1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(8) MaterialInfo
|
struct type_align32(8) MaterialInfo
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
unsigned int gameFlags;
|
unsigned int gameFlags;
|
||||||
@ -735,7 +735,7 @@ namespace T6
|
|||||||
CAMERA_REGION_NONE = CAMERA_REGION_COUNT,
|
CAMERA_REGION_NONE = CAMERA_REGION_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(8) GfxStateBits GfxStateBitsTable;
|
typedef tdef_align32(8) GfxStateBits GfxStateBitsTable;
|
||||||
|
|
||||||
struct Material
|
struct Material
|
||||||
{
|
{
|
||||||
@ -960,9 +960,9 @@ namespace T6
|
|||||||
unsigned int entryCount;
|
unsigned int entryCount;
|
||||||
unsigned int dependencyCount;
|
unsigned int dependencyCount;
|
||||||
unsigned int pad32;
|
unsigned int pad32;
|
||||||
gcc_align(8) int64_t fileSize;
|
gcc_align32(8) int64_t fileSize;
|
||||||
gcc_align(8) int64_t entryOffset;
|
gcc_align32(8) int64_t entryOffset;
|
||||||
gcc_align(8) int64_t checksumOffset;
|
gcc_align32(8) int64_t checksumOffset;
|
||||||
char checksumChecksum[16];
|
char checksumChecksum[16];
|
||||||
char dependencies[512];
|
char dependencies[512];
|
||||||
char padding[1464];
|
char padding[1464];
|
||||||
@ -970,7 +970,7 @@ namespace T6
|
|||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
struct type_align(2) SndRuntimeAssetBank
|
struct type_align32(2) SndRuntimeAssetBank
|
||||||
{
|
{
|
||||||
const char* zone;
|
const char* zone;
|
||||||
const char* language;
|
const char* language;
|
||||||
@ -985,7 +985,7 @@ namespace T6
|
|||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef tdef_align(2048) char SndChar2048;
|
typedef tdef_align32(2048) char SndChar2048;
|
||||||
|
|
||||||
struct SndLoadedAssets
|
struct SndLoadedAssets
|
||||||
{
|
{
|
||||||
@ -1041,8 +1041,8 @@ namespace T6
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned short LeafBrush;
|
typedef unsigned short LeafBrush;
|
||||||
typedef tdef_align(128) cbrush_t cbrush_array_t;
|
typedef tdef_align32(128) cbrush_t cbrush_array_t;
|
||||||
typedef tdef_align(128) Bounds BoundsArray;
|
typedef tdef_align32(128) Bounds BoundsArray;
|
||||||
|
|
||||||
struct ClipInfo
|
struct ClipInfo
|
||||||
{
|
{
|
||||||
@ -1066,7 +1066,7 @@ namespace T6
|
|||||||
int* brushContents;
|
int* brushContents;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) cLeaf_s
|
struct type_align32(4) cLeaf_s
|
||||||
{
|
{
|
||||||
uint16_t firstCollAabbIndex;
|
uint16_t firstCollAabbIndex;
|
||||||
uint16_t collAabbCount;
|
uint16_t collAabbCount;
|
||||||
@ -1273,8 +1273,8 @@ namespace T6
|
|||||||
void /*ID3D11Buffer*/* indexBuffer;
|
void /*ID3D11Buffer*/* indexBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) char aligned_byte_pointer;
|
typedef tdef_align32(4) char aligned_byte_pointer;
|
||||||
typedef tdef_align(4) GfxCompressedLightGridCoeffs GfxCompressedLightGridCoeffs_align4;
|
typedef tdef_align32(4) GfxCompressedLightGridCoeffs GfxCompressedLightGridCoeffs_align4;
|
||||||
|
|
||||||
struct GfxLightGrid
|
struct GfxLightGrid
|
||||||
{
|
{
|
||||||
@ -1323,7 +1323,7 @@ namespace T6
|
|||||||
vec3_t sunFxPosition;
|
vec3_t sunFxPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) GfxDrawSurf GfxDrawSurf_align4;
|
typedef tdef_align32(4) GfxDrawSurf GfxDrawSurf_align4;
|
||||||
|
|
||||||
struct GfxWorldDpvsStatic
|
struct GfxWorldDpvsStatic
|
||||||
{
|
{
|
||||||
@ -1449,7 +1449,7 @@ namespace T6
|
|||||||
int lightingQuality;
|
int lightingQuality;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) GfxLightImage
|
struct type_align32(4) GfxLightImage
|
||||||
{
|
{
|
||||||
GfxImage* image;
|
GfxImage* image;
|
||||||
char samplerState;
|
char samplerState;
|
||||||
@ -1478,8 +1478,8 @@ namespace T6
|
|||||||
struct FontIcon
|
struct FontIcon
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
int numEntries;
|
unsigned int numEntries;
|
||||||
int numAliasEntries;
|
unsigned int numAliasEntries;
|
||||||
FontIconEntry* fontIconEntry;
|
FontIconEntry* fontIconEntry;
|
||||||
FontIconAlias* fontIconAlias;
|
FontIconAlias* fontIconAlias;
|
||||||
};
|
};
|
||||||
@ -1535,7 +1535,7 @@ namespace T6
|
|||||||
expressionRpn* rpn;
|
expressionRpn* rpn;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(8) menuDef_t
|
struct type_align32(8) menuDef_t
|
||||||
{
|
{
|
||||||
windowDef_t window;
|
windowDef_t window;
|
||||||
const char* font;
|
const char* font;
|
||||||
@ -1562,8 +1562,8 @@ namespace T6
|
|||||||
GenericEventHandler* onEvent;
|
GenericEventHandler* onEvent;
|
||||||
ItemKeyHandler* onKey;
|
ItemKeyHandler* onKey;
|
||||||
ExpressionStatement visibleExp;
|
ExpressionStatement visibleExp;
|
||||||
gcc_align(8) uint64_t showBits;
|
gcc_align32(8) uint64_t showBits;
|
||||||
gcc_align(8) uint64_t hideBits;
|
gcc_align32(8) uint64_t hideBits;
|
||||||
const char* allowedBinding;
|
const char* allowedBinding;
|
||||||
const char* soundName;
|
const char* soundName;
|
||||||
int imageTrack;
|
int imageTrack;
|
||||||
@ -1942,7 +1942,7 @@ namespace T6
|
|||||||
int columnCount;
|
int columnCount;
|
||||||
int rowCount;
|
int rowCount;
|
||||||
StringTableCell* values;
|
StringTableCell* values;
|
||||||
int16_t* cellIndex;
|
uint16_t* cellIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LbUpdateType
|
enum LbUpdateType
|
||||||
@ -2753,9 +2753,9 @@ namespace T6
|
|||||||
uint16_t i[3];
|
uint16_t i[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) XSurfaceTri XSurfaceTri16;
|
typedef tdef_align32(16) XSurfaceTri XSurfaceTri16;
|
||||||
|
|
||||||
struct type_align(16) XSurface
|
struct type_align32(16) XSurface
|
||||||
{
|
{
|
||||||
char tileMode;
|
char tileMode;
|
||||||
unsigned char vertListCount;
|
unsigned char vertListCount;
|
||||||
@ -2783,7 +2783,7 @@ namespace T6
|
|||||||
int surfFlags;
|
int surfFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) XBoneInfo
|
struct type_align32(4) XBoneInfo
|
||||||
{
|
{
|
||||||
vec3_t bounds[2];
|
vec3_t bounds[2];
|
||||||
vec3_t offset;
|
vec3_t offset;
|
||||||
@ -3058,7 +3058,7 @@ namespace T6
|
|||||||
{
|
{
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
struct type_align(4) GfxImageLoadDef
|
struct type_align32(4) GfxImageLoadDef
|
||||||
{
|
{
|
||||||
char levelCount;
|
char levelCount;
|
||||||
char flags;
|
char flags;
|
||||||
@ -3104,7 +3104,7 @@ namespace T6
|
|||||||
float returnHighpass;
|
float returnHighpass;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) float SndFloatAlign16;
|
typedef tdef_align32(16) float SndFloatAlign16;
|
||||||
|
|
||||||
struct SndDuck
|
struct SndDuck
|
||||||
{
|
{
|
||||||
@ -3206,7 +3206,7 @@ namespace T6
|
|||||||
cLeafBrushNodeData_t data;
|
cLeafBrushNodeData_t data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) cbrush_t
|
struct type_align32(16) cbrush_t
|
||||||
{
|
{
|
||||||
vec3_t mins;
|
vec3_t mins;
|
||||||
int contents;
|
int contents;
|
||||||
@ -3352,7 +3352,7 @@ namespace T6
|
|||||||
ROPE_CENTITY_CONSTRAINT = 0x3,
|
ROPE_CENTITY_CONSTRAINT = 0x3,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) constraint_t
|
struct type_align32(4) constraint_t
|
||||||
{
|
{
|
||||||
vec3_t p;
|
vec3_t p;
|
||||||
rope_constraint_e type;
|
rope_constraint_e type;
|
||||||
@ -3374,7 +3374,7 @@ namespace T6
|
|||||||
unsigned int frame_index;
|
unsigned int frame_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) rope_t
|
struct type_align32(4) rope_t
|
||||||
{
|
{
|
||||||
par_t m_particles[25];
|
par_t m_particles[25];
|
||||||
constraint_t m_constraints[30];
|
constraint_t m_constraints[30];
|
||||||
@ -3489,7 +3489,7 @@ namespace T6
|
|||||||
uint16_t infoIndex;
|
uint16_t infoIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) pathnode_dynamic_t
|
struct type_align32(4) pathnode_dynamic_t
|
||||||
{
|
{
|
||||||
SentientHandle pOwner;
|
SentientHandle pOwner;
|
||||||
int iFreeTime;
|
int iFreeTime;
|
||||||
@ -3595,7 +3595,7 @@ namespace T6
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) GfxLight
|
struct type_align32(16) GfxLight
|
||||||
{
|
{
|
||||||
char type;
|
char type;
|
||||||
char canUseShadowMap;
|
char canUseShadowMap;
|
||||||
@ -3814,7 +3814,8 @@ namespace T6
|
|||||||
uint16_t dynEntId;
|
uint16_t dynEntId;
|
||||||
};
|
};
|
||||||
|
|
||||||
union gcc_align(8) __m128
|
// Usually __m128, but that is not portable
|
||||||
|
union gcc_align32(8) custom_m128
|
||||||
{
|
{
|
||||||
float m128_f32[4];
|
float m128_f32[4];
|
||||||
uint64_t m128_u64[2];
|
uint64_t m128_u64[2];
|
||||||
@ -3827,22 +3828,15 @@ namespace T6
|
|||||||
unsigned int m128_u32[4];
|
unsigned int m128_u32[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vector3
|
|
||||||
{
|
|
||||||
__m128 x;
|
|
||||||
__m128 y;
|
|
||||||
__m128 z;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vector4
|
struct vector4
|
||||||
{
|
{
|
||||||
__m128 x;
|
custom_m128 x;
|
||||||
__m128 y;
|
custom_m128 y;
|
||||||
__m128 z;
|
custom_m128 z;
|
||||||
__m128 w;
|
custom_m128 w;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) SSkinInstance
|
struct type_align32(16) SSkinInstance
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
@ -3894,7 +3888,7 @@ namespace T6
|
|||||||
int baseIndex;
|
int baseIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) GfxSurface
|
struct type_align32(16) GfxSurface
|
||||||
{
|
{
|
||||||
srfTriangles_t tris;
|
srfTriangles_t tris;
|
||||||
Material* material;
|
Material* material;
|
||||||
@ -3919,7 +3913,7 @@ namespace T6
|
|||||||
uint16_t V2[4];
|
uint16_t V2[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) GfxStaticModelLmapVertexInfo
|
struct type_align32(4) GfxStaticModelLmapVertexInfo
|
||||||
{
|
{
|
||||||
unsigned int* lmapVertexColors;
|
unsigned int* lmapVertexColors;
|
||||||
void /*ID3D11Buffer*/* lmapVertexColorsVB;
|
void /*ID3D11Buffer*/* lmapVertexColorsVB;
|
||||||
@ -4119,7 +4113,7 @@ namespace T6
|
|||||||
void* data;
|
void* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(8) itemDef_s
|
struct type_align32(8) itemDef_s
|
||||||
{
|
{
|
||||||
windowDef_t window;
|
windowDef_t window;
|
||||||
int type;
|
int type;
|
||||||
@ -5593,7 +5587,7 @@ namespace T6
|
|||||||
LOCAL_CLIENT_COUNT = 0x1,
|
LOCAL_CLIENT_COUNT = 0x1,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) DevGraph
|
struct type_align32(4) DevGraph
|
||||||
{
|
{
|
||||||
vec2_t* knots;
|
vec2_t* knots;
|
||||||
int* knotCount;
|
int* knotCount;
|
||||||
@ -5615,7 +5609,7 @@ namespace T6
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef char ByteVec[3];
|
typedef char ByteVec[3];
|
||||||
typedef tdef_align(4) uint16_t UShortVec[3];
|
typedef tdef_align32(4) uint16_t UShortVec[3];
|
||||||
|
|
||||||
union XAnimDynamicFrames
|
union XAnimDynamicFrames
|
||||||
{
|
{
|
||||||
@ -5629,7 +5623,7 @@ namespace T6
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) XAnimPartTransFrames
|
struct type_align32(4) XAnimPartTransFrames
|
||||||
{
|
{
|
||||||
vec3_t mins;
|
vec3_t mins;
|
||||||
vec3_t size;
|
vec3_t size;
|
||||||
@ -5656,9 +5650,9 @@ namespace T6
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) int16_t XQuat2[2];
|
typedef tdef_align32(4) int16_t XQuat2[2];
|
||||||
|
|
||||||
struct type_align(4) XAnimDeltaPartQuatDataFrames2
|
struct type_align32(4) XAnimDeltaPartQuatDataFrames2
|
||||||
{
|
{
|
||||||
XQuat2* frames;
|
XQuat2* frames;
|
||||||
XAnimDynamicIndicesDeltaQuat2 indices;
|
XAnimDynamicIndicesDeltaQuat2 indices;
|
||||||
@ -5682,9 +5676,9 @@ namespace T6
|
|||||||
uint16_t _2[1];
|
uint16_t _2[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(4) int16_t XQuat[4];
|
typedef tdef_align32(4) int16_t XQuat[4];
|
||||||
|
|
||||||
struct type_align(4) XAnimDeltaPartQuatDataFrames
|
struct type_align32(4) XAnimDeltaPartQuatDataFrames
|
||||||
{
|
{
|
||||||
XQuat* frames;
|
XQuat* frames;
|
||||||
XAnimDynamicIndicesDeltaQuat indices;
|
XAnimDynamicIndicesDeltaQuat indices;
|
||||||
@ -5744,7 +5738,7 @@ namespace T6
|
|||||||
vec4_t tvec;
|
vec4_t tvec;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tdef_align(16) PhysGeomInfo PhysGeomInfo16;
|
typedef tdef_align32(16) PhysGeomInfo PhysGeomInfo16;
|
||||||
|
|
||||||
struct PhysGeomList
|
struct PhysGeomList
|
||||||
{
|
{
|
||||||
@ -6301,7 +6295,7 @@ namespace T6
|
|||||||
static_assert(sizeof(SndAliasFlags) == 8);
|
static_assert(sizeof(SndAliasFlags) == 8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct type_align(4) pathlink_s
|
struct type_align32(4) pathlink_s
|
||||||
{
|
{
|
||||||
float fDist;
|
float fDist;
|
||||||
uint16_t nodeNum;
|
uint16_t nodeNum;
|
||||||
@ -6410,7 +6404,7 @@ namespace T6
|
|||||||
unsigned int v;
|
unsigned int v;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(4) SSkinVert
|
struct type_align32(4) SSkinVert
|
||||||
{
|
{
|
||||||
half4 pos_bone;
|
half4 pos_bone;
|
||||||
PackedUnitVec normal;
|
PackedUnitVec normal;
|
||||||
@ -6501,7 +6495,7 @@ namespace T6
|
|||||||
} vector;
|
} vector;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(8) dvar_t
|
struct type_align32(8) dvar_t
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* description;
|
const char* description;
|
||||||
@ -7012,7 +7006,7 @@ namespace T6
|
|||||||
uint16_t triangleBeginIndex;
|
uint16_t triangleBeginIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_align(16) BrushWrapper
|
struct type_align32(16) BrushWrapper
|
||||||
{
|
{
|
||||||
vec3_t mins;
|
vec3_t mins;
|
||||||
int contents;
|
int contents;
|
||||||
|
@ -7,9 +7,6 @@
|
|||||||
#ifdef tdef_align
|
#ifdef tdef_align
|
||||||
#undef tdef_align
|
#undef tdef_align
|
||||||
#endif
|
#endif
|
||||||
#ifdef memb_align
|
|
||||||
#undef memb_align
|
|
||||||
#endif
|
|
||||||
#ifdef gcc_align
|
#ifdef gcc_align
|
||||||
#undef gcc_align
|
#undef gcc_align
|
||||||
#endif
|
#endif
|
||||||
@ -17,25 +14,44 @@
|
|||||||
#ifdef __zonecodegenerator
|
#ifdef __zonecodegenerator
|
||||||
#define type_align(x) alignas(x)
|
#define type_align(x) alignas(x)
|
||||||
#define tdef_align(x) alignas(x)
|
#define tdef_align(x) alignas(x)
|
||||||
#define memb_align(x) alignas(x)
|
|
||||||
#define gcc_align(x)
|
#define gcc_align(x)
|
||||||
#else
|
#else
|
||||||
#ifdef __ida
|
#ifdef __ida
|
||||||
#define type_align(x) __declspec(align(x))
|
#define type_align(x) __declspec(align(x))
|
||||||
#define tdef_align(x) __declspec(align(x))
|
#define tdef_align(x) __declspec(align(x))
|
||||||
#define memb_align(x) __declspec(align(x))
|
|
||||||
#define gcc_align(x)
|
#define gcc_align(x)
|
||||||
#else
|
#else
|
||||||
#ifdef _MSVC_LANG
|
#ifdef _MSVC_LANG
|
||||||
#define type_align(x) __declspec(align(x))
|
#define type_align(x) __declspec(align(x))
|
||||||
#define tdef_align(x) __declspec(align(x))
|
#define tdef_align(x) __declspec(align(x))
|
||||||
#define memb_align(x) __declspec(align(x))
|
|
||||||
#define gcc_align(x)
|
#define gcc_align(x)
|
||||||
#else
|
#else
|
||||||
#define type_align(x) __attribute__((__aligned__(x)))
|
#define type_align(x) __attribute__((__aligned__(x)))
|
||||||
#define tdef_align(x)
|
#define tdef_align(x)
|
||||||
#define memb_align(x) __attribute__((__aligned__(x)))
|
|
||||||
#define gcc_align(x) __attribute__((__aligned__(x)))
|
#define gcc_align(x) __attribute__((__aligned__(x)))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__zonecodegenerator) || defined(__ida)
|
||||||
|
#define type_align32(x) type_align(x)
|
||||||
|
#define tdef_align32(x) tdef_align(x)
|
||||||
|
#define gcc_align32(x) gcc_align(x)
|
||||||
|
#define type_align64(x) type_align(x)
|
||||||
|
#define tdef_align64(x) tdef_align(x)
|
||||||
|
#define gcc_align64(x) gcc_align(x)
|
||||||
|
#elif defined(ARCH_x86)
|
||||||
|
#define type_align32(x) type_align(x)
|
||||||
|
#define tdef_align32(x) tdef_align(x)
|
||||||
|
#define gcc_align32(x) gcc_align(x)
|
||||||
|
#define type_align64(x)
|
||||||
|
#define tdef_align64(x)
|
||||||
|
#define gcc_align64(x)
|
||||||
|
#elif defined(ARCH_x64)
|
||||||
|
#define type_align32(x)
|
||||||
|
#define tdef_align32(x)
|
||||||
|
#define gcc_align32(x)
|
||||||
|
#define type_align64(x) type_align(x)
|
||||||
|
#define tdef_align64(x) tdef_align(x)
|
||||||
|
#define gcc_align64(x) gcc_align(x)
|
||||||
|
#endif
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
struct ZoneHeader
|
struct ZoneHeader
|
||||||
{
|
{
|
||||||
@ -7,22 +8,12 @@ struct ZoneHeader
|
|||||||
uint32_t m_version;
|
uint32_t m_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ARCH_x64
|
|
||||||
typedef uint32_t scr_string_t;
|
|
||||||
typedef uint64_t xchunk_size_t;
|
|
||||||
typedef uint64_t xblock_size_t;
|
|
||||||
typedef uint64_t zone_pointer_t;
|
|
||||||
|
|
||||||
constexpr uint16_t SCR_STRING_MAX = UINT32_MAX;
|
|
||||||
#elif ARCH_x86
|
|
||||||
typedef uint16_t scr_string_t;
|
typedef uint16_t scr_string_t;
|
||||||
typedef uint32_t xchunk_size_t;
|
typedef uint32_t xchunk_size_t;
|
||||||
typedef uint32_t xblock_size_t;
|
typedef uint32_t xblock_size_t;
|
||||||
typedef uint32_t zone_pointer_t;
|
|
||||||
|
|
||||||
constexpr uint16_t SCR_STRING_MAX = UINT16_MAX;
|
constexpr uint16_t SCR_STRING_MAX = std::numeric_limits<scr_string_t>::max();
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int block_t;
|
typedef unsigned block_t;
|
||||||
typedef int asset_type_t;
|
typedef unsigned asset_type_t;
|
||||||
typedef unsigned int zone_priority_t;
|
typedef unsigned int zone_priority_t;
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
#include "Crypto.h"
|
|
||||||
|
|
||||||
#include "Impl/AlgorithmMD5.h"
|
|
||||||
#include "Impl/AlgorithmRSA.h"
|
|
||||||
#include "Impl/AlgorithmSHA1.h"
|
|
||||||
#include "Impl/AlgorithmSHA256.h"
|
|
||||||
#include "Impl/AlgorithmSalsa20.h"
|
|
||||||
|
|
||||||
std::unique_ptr<IHashFunction> Crypto::CreateMD5()
|
|
||||||
{
|
|
||||||
return std::make_unique<AlgorithmMD5>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<IHashFunction> Crypto::CreateSHA1()
|
|
||||||
{
|
|
||||||
return std::make_unique<AlgorithmSHA1>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<IHashFunction> Crypto::CreateSHA256()
|
|
||||||
{
|
|
||||||
return std::make_unique<AlgorithmSHA256>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<IStreamCipher> Crypto::CreateSalsa20(const uint8_t* keyBytes, const size_t keySize)
|
|
||||||
{
|
|
||||||
return std::make_unique<AlgorithmSalsa20>(keyBytes, keySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<IPublicKeyAlgorithm> Crypto::CreateRSA(const IPublicKeyAlgorithm::HashingAlgorithm hashingAlgorithm, const RSAPaddingMode paddingMode)
|
|
||||||
{
|
|
||||||
return std::make_unique<AlgorithmRSA>(hashingAlgorithm, paddingMode);
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "IHashFunction.h"
|
|
||||||
#include "IPublicKeyAlgorithm.h"
|
|
||||||
#include "IStreamCipher.h"
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class Crypto
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum class RSAPaddingMode
|
|
||||||
{
|
|
||||||
RSA_PADDING_PKS1,
|
|
||||||
RSA_PADDING_PSS,
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::unique_ptr<IHashFunction> CreateMD5();
|
|
||||||
|
|
||||||
static std::unique_ptr<IHashFunction> CreateSHA1();
|
|
||||||
static std::unique_ptr<IHashFunction> CreateSHA256();
|
|
||||||
|
|
||||||
static std::unique_ptr<IStreamCipher> CreateSalsa20(const uint8_t* keyBytes, size_t keySize);
|
|
||||||
|
|
||||||
static std::unique_ptr<IPublicKeyAlgorithm> CreateRSA(IPublicKeyAlgorithm::HashingAlgorithm hashingAlgorithm, RSAPaddingMode paddingMode);
|
|
||||||
};
|
|
@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
class IHashFunction
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IHashFunction() = default;
|
|
||||||
|
|
||||||
virtual size_t GetHashSize() = 0;
|
|
||||||
virtual void Init() = 0;
|
|
||||||
virtual void Process(const void* input, size_t inputSize) = 0;
|
|
||||||
virtual void Finish(void* hashBuffer) = 0;
|
|
||||||
};
|
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class IPublicKeyAlgorithm
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum class HashingAlgorithm
|
|
||||||
{
|
|
||||||
RSA_HASH_SHA256,
|
|
||||||
RSA_HASH_SHA512
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~IPublicKeyAlgorithm() = default;
|
|
||||||
|
|
||||||
virtual bool SetKey(const uint8_t* keyData, size_t keySize) = 0;
|
|
||||||
|
|
||||||
// If needed add a signing method
|
|
||||||
|
|
||||||
virtual bool Verify(const uint8_t* signedData, size_t signedDataSize, const uint8_t* signature, size_t signatureSize) = 0;
|
|
||||||
};
|
|
@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class IStreamCipher
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IStreamCipher() = default;
|
|
||||||
|
|
||||||
virtual void SetIV(const uint8_t* iv, size_t ivSize) = 0;
|
|
||||||
|
|
||||||
virtual void Process(const void* plainText, void* cipherText, size_t amount) = 0;
|
|
||||||
};
|
|
@ -1,64 +0,0 @@
|
|||||||
#include "AlgorithmMD5.h"
|
|
||||||
|
|
||||||
#include "CryptoLibrary.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class AlgorithmMD5::AlgorithmMD5Impl
|
|
||||||
{
|
|
||||||
hash_state m_state{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
AlgorithmMD5Impl()
|
|
||||||
{
|
|
||||||
CryptoLibrary::Init();
|
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
md5_init(&m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process(const void* input, const size_t inputSize)
|
|
||||||
{
|
|
||||||
md5_process(&m_state, static_cast<const uint8_t*>(input), inputSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finish(void* hashBuffer)
|
|
||||||
{
|
|
||||||
md5_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlgorithmMD5::AlgorithmMD5()
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmMD5Impl();
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmMD5::~AlgorithmMD5()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t AlgorithmMD5::GetHashSize()
|
|
||||||
{
|
|
||||||
return HASH_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmMD5::Init()
|
|
||||||
{
|
|
||||||
m_impl->Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmMD5::Process(const void* input, const size_t inputSize)
|
|
||||||
{
|
|
||||||
m_impl->Process(input, inputSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmMD5::Finish(void* hashBuffer)
|
|
||||||
{
|
|
||||||
m_impl->Finish(hashBuffer);
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "IHashFunction.h"
|
|
||||||
|
|
||||||
class AlgorithmMD5 : public IHashFunction
|
|
||||||
{
|
|
||||||
class AlgorithmMD5Impl;
|
|
||||||
AlgorithmMD5Impl* m_impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const int HASH_SIZE = 16;
|
|
||||||
|
|
||||||
AlgorithmMD5();
|
|
||||||
~AlgorithmMD5() override;
|
|
||||||
|
|
||||||
size_t GetHashSize() override;
|
|
||||||
|
|
||||||
void Init() override;
|
|
||||||
void Process(const void* input, size_t inputSize) override;
|
|
||||||
void Finish(void* hashBuffer) override;
|
|
||||||
};
|
|
@ -1,119 +0,0 @@
|
|||||||
#include "AlgorithmRSA.h"
|
|
||||||
|
|
||||||
#include "CryptoLibrary.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
class AlgorithmRSA::AlgorithmRSAImpl
|
|
||||||
{
|
|
||||||
rsa_key m_key{};
|
|
||||||
HashingAlgorithm m_hash;
|
|
||||||
Crypto::RSAPaddingMode m_padding;
|
|
||||||
|
|
||||||
const ltc_hash_descriptor* GetHashDescriptor() const
|
|
||||||
{
|
|
||||||
switch (m_hash)
|
|
||||||
{
|
|
||||||
case HashingAlgorithm::RSA_HASH_SHA256:
|
|
||||||
return &sha256_desc;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case HashingAlgorithm::RSA_HASH_SHA512:
|
|
||||||
return &sha512_desc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetPaddingMode() const
|
|
||||||
{
|
|
||||||
switch (m_padding)
|
|
||||||
{
|
|
||||||
case Crypto::RSAPaddingMode::RSA_PADDING_PKS1:
|
|
||||||
return LTC_PKCS_1_V1_5;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case Crypto::RSAPaddingMode::RSA_PADDING_PSS:
|
|
||||||
return LTC_PKCS_1_PSS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
AlgorithmRSAImpl(const HashingAlgorithm hash, const Crypto::RSAPaddingMode padding)
|
|
||||||
{
|
|
||||||
m_hash = hash;
|
|
||||||
m_padding = padding;
|
|
||||||
|
|
||||||
CryptoLibrary::Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
~AlgorithmRSAImpl() = default;
|
|
||||||
|
|
||||||
AlgorithmRSAImpl(AlgorithmRSAImpl& other) = default;
|
|
||||||
AlgorithmRSAImpl(AlgorithmRSAImpl&& other) = delete;
|
|
||||||
|
|
||||||
AlgorithmRSAImpl& operator=(AlgorithmRSAImpl const& other) = default;
|
|
||||||
AlgorithmRSAImpl& operator=(AlgorithmRSAImpl&& other) = delete;
|
|
||||||
|
|
||||||
bool SetKey(const uint8_t* keyData, const size_t keySize)
|
|
||||||
{
|
|
||||||
return rsa_import(keyData, keySize, &m_key) == CRYPT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Verify(const uint8_t* signedData, const size_t signedDataSize, const uint8_t* signature, const size_t signatureSize)
|
|
||||||
{
|
|
||||||
const ltc_hash_descriptor* hashDesc = GetHashDescriptor();
|
|
||||||
const int hashId = register_hash(hashDesc);
|
|
||||||
const int padding = GetPaddingMode();
|
|
||||||
|
|
||||||
int result;
|
|
||||||
rsa_verify_hash_ex(signature, signatureSize, signedData, signedDataSize, padding, hashId, 8, &result, &m_key);
|
|
||||||
|
|
||||||
return result == 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlgorithmRSA::AlgorithmRSA(const HashingAlgorithm hash, const Crypto::RSAPaddingMode padding)
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmRSAImpl(hash, padding);
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmRSA::~AlgorithmRSA()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmRSA::AlgorithmRSA(AlgorithmRSA& other)
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmRSAImpl(*other.m_impl);
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmRSA::AlgorithmRSA(AlgorithmRSA&& other) noexcept
|
|
||||||
{
|
|
||||||
m_impl = other.m_impl;
|
|
||||||
other.m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmRSA& AlgorithmRSA::operator=(AlgorithmRSA const& other)
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmRSAImpl(*other.m_impl);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmRSA& AlgorithmRSA::operator=(AlgorithmRSA&& other) noexcept
|
|
||||||
{
|
|
||||||
m_impl = other.m_impl;
|
|
||||||
other.m_impl = nullptr;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlgorithmRSA::SetKey(const uint8_t* keyData, size_t keySize)
|
|
||||||
{
|
|
||||||
return m_impl->SetKey(keyData, keySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlgorithmRSA::Verify(const uint8_t* signedData, const size_t signedDataSize, const uint8_t* signature, const size_t signatureSize)
|
|
||||||
{
|
|
||||||
return m_impl->Verify(signedData, signedDataSize, signature, signatureSize);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Crypto.h"
|
|
||||||
#include "IPublicKeyAlgorithm.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class AlgorithmRSA final : public IPublicKeyAlgorithm
|
|
||||||
{
|
|
||||||
class AlgorithmRSAImpl;
|
|
||||||
AlgorithmRSAImpl* m_impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AlgorithmRSA(HashingAlgorithm hash, Crypto::RSAPaddingMode padding);
|
|
||||||
~AlgorithmRSA() override;
|
|
||||||
|
|
||||||
AlgorithmRSA(AlgorithmRSA& other);
|
|
||||||
AlgorithmRSA(AlgorithmRSA&& other) noexcept;
|
|
||||||
|
|
||||||
AlgorithmRSA& operator=(AlgorithmRSA const& other);
|
|
||||||
AlgorithmRSA& operator=(AlgorithmRSA&& other) noexcept;
|
|
||||||
|
|
||||||
bool SetKey(const uint8_t* keyData, size_t keySize) override;
|
|
||||||
|
|
||||||
bool Verify(const uint8_t* signedData, size_t signedDataSize, const uint8_t* signature, size_t signatureSize) override;
|
|
||||||
};
|
|
@ -1,64 +0,0 @@
|
|||||||
#include "AlgorithmSHA1.h"
|
|
||||||
|
|
||||||
#include "CryptoLibrary.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class AlgorithmSHA1::AlgorithmSHA1Impl
|
|
||||||
{
|
|
||||||
hash_state m_state{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
AlgorithmSHA1Impl()
|
|
||||||
{
|
|
||||||
CryptoLibrary::Init();
|
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
sha1_init(&m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process(const void* input, const size_t inputSize)
|
|
||||||
{
|
|
||||||
sha1_process(&m_state, static_cast<const uint8_t*>(input), inputSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finish(void* hashBuffer)
|
|
||||||
{
|
|
||||||
sha1_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlgorithmSHA1::AlgorithmSHA1()
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmSHA1Impl();
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSHA1::~AlgorithmSHA1()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t AlgorithmSHA1::GetHashSize()
|
|
||||||
{
|
|
||||||
return HASH_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSHA1::Init()
|
|
||||||
{
|
|
||||||
m_impl->Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSHA1::Process(const void* input, const size_t inputSize)
|
|
||||||
{
|
|
||||||
m_impl->Process(input, inputSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSHA1::Finish(void* hashBuffer)
|
|
||||||
{
|
|
||||||
m_impl->Finish(hashBuffer);
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "IHashFunction.h"
|
|
||||||
|
|
||||||
class AlgorithmSHA1 : public IHashFunction
|
|
||||||
{
|
|
||||||
class AlgorithmSHA1Impl;
|
|
||||||
AlgorithmSHA1Impl* m_impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const int HASH_SIZE = 20;
|
|
||||||
|
|
||||||
AlgorithmSHA1();
|
|
||||||
~AlgorithmSHA1() override;
|
|
||||||
|
|
||||||
size_t GetHashSize() override;
|
|
||||||
|
|
||||||
void Init() override;
|
|
||||||
void Process(const void* input, size_t inputSize) override;
|
|
||||||
void Finish(void* hashBuffer) override;
|
|
||||||
};
|
|
@ -1,64 +0,0 @@
|
|||||||
#include "AlgorithmSHA256.h"
|
|
||||||
|
|
||||||
#include "CryptoLibrary.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class AlgorithmSHA256::Impl
|
|
||||||
{
|
|
||||||
hash_state m_state{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
Impl()
|
|
||||||
{
|
|
||||||
CryptoLibrary::Init();
|
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
sha256_init(&m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process(const void* input, const size_t inputSize)
|
|
||||||
{
|
|
||||||
sha256_process(&m_state, static_cast<const uint8_t*>(input), inputSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finish(void* hashBuffer)
|
|
||||||
{
|
|
||||||
sha256_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlgorithmSHA256::AlgorithmSHA256()
|
|
||||||
{
|
|
||||||
m_impl = new Impl();
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSHA256::~AlgorithmSHA256()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t AlgorithmSHA256::GetHashSize()
|
|
||||||
{
|
|
||||||
return HASH_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSHA256::Init()
|
|
||||||
{
|
|
||||||
m_impl->Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSHA256::Process(const void* input, const size_t inputSize)
|
|
||||||
{
|
|
||||||
m_impl->Process(input, inputSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSHA256::Finish(void* hashBuffer)
|
|
||||||
{
|
|
||||||
m_impl->Finish(hashBuffer);
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "IHashFunction.h"
|
|
||||||
|
|
||||||
class AlgorithmSHA256 : public IHashFunction
|
|
||||||
{
|
|
||||||
class Impl;
|
|
||||||
Impl* m_impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const int HASH_SIZE = 32;
|
|
||||||
|
|
||||||
AlgorithmSHA256();
|
|
||||||
~AlgorithmSHA256() override;
|
|
||||||
|
|
||||||
size_t GetHashSize() override;
|
|
||||||
|
|
||||||
void Init() override;
|
|
||||||
void Process(const void* input, size_t inputSize) override;
|
|
||||||
void Finish(void* hashBuffer) override;
|
|
||||||
};
|
|
@ -1,89 +0,0 @@
|
|||||||
#include "AlgorithmSalsa20.h"
|
|
||||||
|
|
||||||
#include "salsa20.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
class AlgorithmSalsa20::AlgorithmSalsa20Impl
|
|
||||||
{
|
|
||||||
salsa20_ctx m_context{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
AlgorithmSalsa20Impl(const uint8_t* keyBytes, const size_t keySize)
|
|
||||||
{
|
|
||||||
Salsa20_KeySetup(&m_context, keyBytes, keySize * 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
~AlgorithmSalsa20Impl() = default;
|
|
||||||
|
|
||||||
AlgorithmSalsa20Impl(AlgorithmSalsa20Impl& other) = default;
|
|
||||||
AlgorithmSalsa20Impl(AlgorithmSalsa20Impl&& other) = delete;
|
|
||||||
|
|
||||||
AlgorithmSalsa20Impl& operator=(AlgorithmSalsa20Impl const& other) = default;
|
|
||||||
AlgorithmSalsa20Impl& operator=(AlgorithmSalsa20Impl&& other) = delete;
|
|
||||||
|
|
||||||
void SetIV(const uint8_t* iv, const size_t ivSize)
|
|
||||||
{
|
|
||||||
assert(ivSize == 8);
|
|
||||||
|
|
||||||
if (ivSize != 8)
|
|
||||||
{
|
|
||||||
throw std::invalid_argument("Salsa20 IV size must be 8");
|
|
||||||
}
|
|
||||||
|
|
||||||
Salsa20_IVSetup(&m_context, iv);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process(const void* plainText, void* cipherText, const size_t amount)
|
|
||||||
{
|
|
||||||
Salsa20_Encrypt_Bytes(&m_context, static_cast<const uint8_t*>(plainText), static_cast<uint8_t*>(cipherText), amount);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlgorithmSalsa20::AlgorithmSalsa20(const uint8_t* keyBytes, const size_t keySize)
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmSalsa20Impl(keyBytes, keySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSalsa20::~AlgorithmSalsa20()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSalsa20::AlgorithmSalsa20(AlgorithmSalsa20& other)
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmSalsa20Impl(*other.m_impl);
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSalsa20::AlgorithmSalsa20(AlgorithmSalsa20&& other) noexcept
|
|
||||||
{
|
|
||||||
m_impl = other.m_impl;
|
|
||||||
other.m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSalsa20& AlgorithmSalsa20::operator=(AlgorithmSalsa20 const& other)
|
|
||||||
{
|
|
||||||
m_impl = new AlgorithmSalsa20Impl(*other.m_impl);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlgorithmSalsa20& AlgorithmSalsa20::operator=(AlgorithmSalsa20&& other) noexcept
|
|
||||||
{
|
|
||||||
m_impl = other.m_impl;
|
|
||||||
other.m_impl = nullptr;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSalsa20::SetIV(const uint8_t* iv, const size_t ivSize)
|
|
||||||
{
|
|
||||||
m_impl->SetIV(iv, ivSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlgorithmSalsa20::Process(const void* plainText, void* cipherText, const size_t amount)
|
|
||||||
{
|
|
||||||
m_impl->Process(plainText, cipherText, amount);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "IStreamCipher.h"
|
|
||||||
|
|
||||||
class AlgorithmSalsa20 final : public IStreamCipher
|
|
||||||
{
|
|
||||||
class AlgorithmSalsa20Impl;
|
|
||||||
AlgorithmSalsa20Impl* m_impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AlgorithmSalsa20(const uint8_t* keyBytes, size_t keySize);
|
|
||||||
~AlgorithmSalsa20() override;
|
|
||||||
|
|
||||||
AlgorithmSalsa20(AlgorithmSalsa20& other);
|
|
||||||
AlgorithmSalsa20(AlgorithmSalsa20&& other) noexcept;
|
|
||||||
|
|
||||||
AlgorithmSalsa20& operator=(AlgorithmSalsa20 const& other);
|
|
||||||
AlgorithmSalsa20& operator=(AlgorithmSalsa20&& other) noexcept;
|
|
||||||
|
|
||||||
void SetIV(const uint8_t* iv, size_t ivSize) override;
|
|
||||||
void Process(const void* plainText, void* cipherText, size_t amount) override;
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "Base64.h"
|
|
||||||
|
|
||||||
#define LTC_NO_PROTOTYPES
|
|
||||||
#include <tomcrypt.h>
|
|
||||||
|
|
||||||
namespace base64
|
|
||||||
{
|
|
||||||
std::string EncodeBase64(const void* inputData, const size_t inputLength)
|
|
||||||
{
|
|
||||||
const auto base64BufferSize = GetBase64EncodeOutputLength(inputLength);
|
|
||||||
|
|
||||||
std::string output(base64BufferSize, '\0');
|
|
||||||
const auto outLength = base64BufferSize + 1u;
|
|
||||||
|
|
||||||
const auto result = EncodeBase64(inputData, inputLength, output.data(), outLength);
|
|
||||||
assert(result);
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EncodeBase64(const void* inputData, const size_t inputLength, void* outputBuffer, const size_t outputBufferSize)
|
|
||||||
{
|
|
||||||
unsigned long outLength = outputBufferSize;
|
|
||||||
const auto result = base64_encode(static_cast<const unsigned char*>(inputData), inputLength, static_cast<char*>(outputBuffer), &outLength);
|
|
||||||
return result == CRYPT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t GetBase64EncodeOutputLength(const size_t inputLength)
|
|
||||||
{
|
|
||||||
return 4u * ((inputLength + 2u) / 3u);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t DecodeBase64(const void* base64Data, const size_t inputLength, void* outputBuffer, const size_t outputBufferSize)
|
|
||||||
{
|
|
||||||
unsigned long outLength = GetBase64DecodeOutputLength(inputLength);
|
|
||||||
if (outLength > outputBufferSize)
|
|
||||||
return 0u;
|
|
||||||
|
|
||||||
const auto result = base64_decode(static_cast<const char*>(base64Data), inputLength, static_cast<unsigned char*>(outputBuffer), &outLength);
|
|
||||||
assert(result == CRYPT_OK);
|
|
||||||
|
|
||||||
return static_cast<size_t>(outLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t GetBase64DecodeOutputLength(const size_t inputLength)
|
|
||||||
{
|
|
||||||
return inputLength / 4u;
|
|
||||||
}
|
|
||||||
} // namespace base64
|
|
@ -1,15 +0,0 @@
|
|||||||
#include "CryptoLibrary.h"
|
|
||||||
|
|
||||||
#include "tommath.h"
|
|
||||||
|
|
||||||
void CryptoLibrary::Init()
|
|
||||||
{
|
|
||||||
static bool initialized = false;
|
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
initialized = true;
|
|
||||||
|
|
||||||
ltc_mp = ltm_desc;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define LTC_NO_PROTOTYPES
|
|
||||||
#include "tomcrypt.h"
|
|
||||||
|
|
||||||
class CryptoLibrary
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void Init();
|
|
||||||
};
|
|
@ -1,29 +1,29 @@
|
|||||||
Crypto = {}
|
Cryptography = {}
|
||||||
|
|
||||||
function Crypto:include(includes)
|
function Cryptography:include(includes)
|
||||||
if includes:handle(self:name()) then
|
if includes:handle(self:name()) then
|
||||||
includedirs {
|
includedirs {
|
||||||
path.join(ProjectFolder(), "Crypto")
|
path.join(ProjectFolder(), "Cryptography")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Crypto:link(links)
|
function Cryptography:link(links)
|
||||||
links:add(self:name())
|
links:add(self:name())
|
||||||
links:linkto(libtomcrypt)
|
links:linkto(libtomcrypt)
|
||||||
links:linkto(libtommath)
|
links:linkto(libtommath)
|
||||||
links:linkto(salsa20)
|
links:linkto(salsa20)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Crypto:use()
|
function Cryptography:use()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Crypto:name()
|
function Cryptography:name()
|
||||||
return "Crypto"
|
return "Cryptography"
|
||||||
end
|
end
|
||||||
|
|
||||||
function Crypto:project()
|
function Cryptography:project()
|
||||||
local folder = ProjectFolder()
|
local folder = ProjectFolder()
|
||||||
local includes = Includes:create()
|
local includes = Includes:create()
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ function Crypto:project()
|
|||||||
language "C++"
|
language "C++"
|
||||||
|
|
||||||
files {
|
files {
|
||||||
path.join(folder, "Crypto/**.h"),
|
path.join(folder, "Cryptography/**.h"),
|
||||||
path.join(folder, "Crypto/**.cpp")
|
path.join(folder, "Cryptography/**.cpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
54
src/Cryptography/Algorithms/AlgorithmMd5.cpp
Normal file
54
src/Cryptography/Algorithms/AlgorithmMd5.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "AlgorithmMd5.h"
|
||||||
|
|
||||||
|
#include "Internal/CryptoLibrary.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
using namespace cryptography;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr int HASH_SIZE = 16;
|
||||||
|
|
||||||
|
class AlgorithmMd5 final : public IHashFunction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlgorithmMd5()
|
||||||
|
{
|
||||||
|
internal::CryptoLibrary::Init();
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t GetHashSize() override
|
||||||
|
{
|
||||||
|
return HASH_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init() override
|
||||||
|
{
|
||||||
|
md5_init(&m_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process(const void* input, const size_t inputSize) override
|
||||||
|
{
|
||||||
|
md5_process(&m_state, static_cast<const uint8_t*>(input), static_cast<unsigned long>(inputSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Finish(void* hashBuffer) override
|
||||||
|
{
|
||||||
|
md5_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
hash_state m_state{};
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IHashFunction> CreateMd5()
|
||||||
|
{
|
||||||
|
return std::make_unique<AlgorithmMd5>();
|
||||||
|
}
|
||||||
|
} // namespace cryptography
|
10
src/Cryptography/Algorithms/AlgorithmMd5.h
Normal file
10
src/Cryptography/Algorithms/AlgorithmMd5.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IHashFunction.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IHashFunction> CreateMd5();
|
||||||
|
}
|
84
src/Cryptography/Algorithms/AlgorithmRsa.cpp
Normal file
84
src/Cryptography/Algorithms/AlgorithmRsa.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "AlgorithmRsa.h"
|
||||||
|
|
||||||
|
#include "Internal/CryptoLibrary.h"
|
||||||
|
|
||||||
|
using namespace cryptography;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class AlgorithmRsa final : public IPublicKeyAlgorithm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlgorithmRsa(const HashingAlgorithm hash, const RsaPaddingMode padding)
|
||||||
|
{
|
||||||
|
m_hash = hash;
|
||||||
|
m_padding = padding;
|
||||||
|
|
||||||
|
internal::CryptoLibrary::Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetKey(const uint8_t* keyData, const size_t keySize) override
|
||||||
|
{
|
||||||
|
return rsa_import(keyData, static_cast<unsigned long>(keySize), &m_key) == CRYPT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Verify(const uint8_t* signedData, const size_t signedDataSize, const uint8_t* signature, const size_t signatureSize) override
|
||||||
|
{
|
||||||
|
const ltc_hash_descriptor* hashDesc = GetHashDescriptor();
|
||||||
|
const int hashId = register_hash(hashDesc);
|
||||||
|
const int padding = GetPaddingMode();
|
||||||
|
|
||||||
|
int result;
|
||||||
|
rsa_verify_hash_ex(signature,
|
||||||
|
static_cast<unsigned long>(signatureSize),
|
||||||
|
signedData,
|
||||||
|
static_cast<unsigned long>(signedDataSize),
|
||||||
|
padding,
|
||||||
|
hashId,
|
||||||
|
8,
|
||||||
|
&result,
|
||||||
|
&m_key);
|
||||||
|
|
||||||
|
return result == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] const ltc_hash_descriptor* GetHashDescriptor() const
|
||||||
|
{
|
||||||
|
switch (m_hash)
|
||||||
|
{
|
||||||
|
case HashingAlgorithm::RSA_HASH_SHA256:
|
||||||
|
return &sha256_desc;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case HashingAlgorithm::RSA_HASH_SHA512:
|
||||||
|
return &sha512_desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int GetPaddingMode() const
|
||||||
|
{
|
||||||
|
switch (m_padding)
|
||||||
|
{
|
||||||
|
case RsaPaddingMode::RSA_PADDING_PKS1:
|
||||||
|
return LTC_PKCS_1_V1_5;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case RsaPaddingMode::RSA_PADDING_PSS:
|
||||||
|
return LTC_PKCS_1_PSS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rsa_key m_key{};
|
||||||
|
HashingAlgorithm m_hash;
|
||||||
|
RsaPaddingMode m_padding;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IPublicKeyAlgorithm> CreateRsa(const HashingAlgorithm hashingAlgorithm, const RsaPaddingMode paddingMode)
|
||||||
|
{
|
||||||
|
return std::make_unique<AlgorithmRsa>(hashingAlgorithm, paddingMode);
|
||||||
|
}
|
||||||
|
} // namespace cryptography
|
17
src/Cryptography/Algorithms/AlgorithmRsa.h
Normal file
17
src/Cryptography/Algorithms/AlgorithmRsa.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IPublicKeyAlgorithm.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
enum class RsaPaddingMode : std::uint8_t
|
||||||
|
{
|
||||||
|
RSA_PADDING_PKS1,
|
||||||
|
RSA_PADDING_PSS,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<IPublicKeyAlgorithm> CreateRsa(HashingAlgorithm hashingAlgorithm, RsaPaddingMode paddingMode);
|
||||||
|
} // namespace cryptography
|
46
src/Cryptography/Algorithms/AlgorithmSalsa20.cpp
Normal file
46
src/Cryptography/Algorithms/AlgorithmSalsa20.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include "AlgorithmSalsa20.h"
|
||||||
|
|
||||||
|
#include "salsa20.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
using namespace cryptography;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class AlgorithmSalsa20 final : public IStreamCipher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlgorithmSalsa20(const uint8_t* keyBytes, const size_t keySize)
|
||||||
|
{
|
||||||
|
Salsa20_KeySetup(&m_context, keyBytes, static_cast<uint32_t>(keySize * 8uz));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetIv(const uint8_t* iv, const size_t ivSize) override
|
||||||
|
{
|
||||||
|
assert(ivSize == 8);
|
||||||
|
|
||||||
|
if (ivSize != 8)
|
||||||
|
throw std::invalid_argument("Salsa20 IV size must be 8");
|
||||||
|
|
||||||
|
Salsa20_IVSetup(&m_context, iv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process(const void* plainText, void* cipherText, const size_t amount) override
|
||||||
|
{
|
||||||
|
Salsa20_Encrypt_Bytes(&m_context, static_cast<const uint8_t*>(plainText), static_cast<uint8_t*>(cipherText), static_cast<uint32_t>(amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
salsa20_ctx m_context{};
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IStreamCipher> CreateSalsa20(const uint8_t* keyBytes, const size_t keySize)
|
||||||
|
{
|
||||||
|
return std::make_unique<AlgorithmSalsa20>(keyBytes, keySize);
|
||||||
|
}
|
||||||
|
} // namespace cryptography
|
10
src/Cryptography/Algorithms/AlgorithmSalsa20.h
Normal file
10
src/Cryptography/Algorithms/AlgorithmSalsa20.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IStreamCipher.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IStreamCipher> CreateSalsa20(const uint8_t* keyBytes, size_t keySize);
|
||||||
|
}
|
54
src/Cryptography/Algorithms/AlgorithmSha1.cpp
Normal file
54
src/Cryptography/Algorithms/AlgorithmSha1.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "AlgorithmSha1.h"
|
||||||
|
|
||||||
|
#include "Internal/CryptoLibrary.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
using namespace cryptography;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr int HASH_SIZE = 20;
|
||||||
|
|
||||||
|
class AlgorithmSha1 final : public IHashFunction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlgorithmSha1()
|
||||||
|
{
|
||||||
|
internal::CryptoLibrary::Init();
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t GetHashSize() override
|
||||||
|
{
|
||||||
|
return HASH_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init() override
|
||||||
|
{
|
||||||
|
sha1_init(&m_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process(const void* input, const size_t inputSize) override
|
||||||
|
{
|
||||||
|
sha1_process(&m_state, static_cast<const uint8_t*>(input), static_cast<unsigned long>(inputSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Finish(void* hashBuffer) override
|
||||||
|
{
|
||||||
|
sha1_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
hash_state m_state{};
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IHashFunction> CreateSha1()
|
||||||
|
{
|
||||||
|
return std::make_unique<AlgorithmSha1>();
|
||||||
|
}
|
||||||
|
} // namespace cryptography
|
10
src/Cryptography/Algorithms/AlgorithmSha1.h
Normal file
10
src/Cryptography/Algorithms/AlgorithmSha1.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IHashFunction.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IHashFunction> CreateSha1();
|
||||||
|
}
|
54
src/Cryptography/Algorithms/AlgorithmSha256.cpp
Normal file
54
src/Cryptography/Algorithms/AlgorithmSha256.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "AlgorithmSha256.h"
|
||||||
|
|
||||||
|
#include "Internal/CryptoLibrary.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
using namespace cryptography;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr int HASH_SIZE = 32;
|
||||||
|
|
||||||
|
class AlgorithmSha256 final : public IHashFunction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlgorithmSha256()
|
||||||
|
{
|
||||||
|
internal::CryptoLibrary::Init();
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t GetHashSize() override
|
||||||
|
{
|
||||||
|
return HASH_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init() override
|
||||||
|
{
|
||||||
|
sha256_init(&m_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process(const void* input, const size_t inputSize) override
|
||||||
|
{
|
||||||
|
sha256_process(&m_state, static_cast<const uint8_t*>(input), static_cast<unsigned long>(inputSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Finish(void* hashBuffer) override
|
||||||
|
{
|
||||||
|
sha256_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
hash_state m_state{};
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IHashFunction> CreateSha256()
|
||||||
|
{
|
||||||
|
return std::make_unique<AlgorithmSha256>();
|
||||||
|
}
|
||||||
|
} // namespace cryptography
|
10
src/Cryptography/Algorithms/AlgorithmSha256.h
Normal file
10
src/Cryptography/Algorithms/AlgorithmSha256.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IHashFunction.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
std::unique_ptr<IHashFunction> CreateSha256();
|
||||||
|
}
|
72
src/Cryptography/Base64.cpp
Normal file
72
src/Cryptography/Base64.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "Base64.h"
|
||||||
|
|
||||||
|
#define LTC_NO_PROTOTYPES
|
||||||
|
#include <tomcrypt.h>
|
||||||
|
|
||||||
|
namespace base64
|
||||||
|
{
|
||||||
|
std::string EncodeBase64(const void* inputData, const size_t inputLength)
|
||||||
|
{
|
||||||
|
const auto base64BufferSize = GetBase64EncodeOutputLength(inputLength);
|
||||||
|
|
||||||
|
std::string output(base64BufferSize, '\0');
|
||||||
|
const auto outLength = base64BufferSize + 1u;
|
||||||
|
|
||||||
|
const auto result = EncodeBase64(inputData, inputLength, output.data(), outLength);
|
||||||
|
assert(result);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EncodeBase64(const void* inputData, const size_t inputLength, void* outputBuffer, const size_t outputBufferSize)
|
||||||
|
{
|
||||||
|
unsigned long outLength = static_cast<unsigned long>(outputBufferSize);
|
||||||
|
const auto result =
|
||||||
|
base64_encode(static_cast<const unsigned char*>(inputData), static_cast<unsigned long>(inputLength), static_cast<char*>(outputBuffer), &outLength);
|
||||||
|
return result == CRYPT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t GetBase64EncodeOutputLength(const size_t inputLength)
|
||||||
|
{
|
||||||
|
return 4u * ((inputLength + 2u) / 3u);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t DecodeBase64(const void* base64Data, const size_t inputLength, void* outputBuffer, const size_t outputBufferSize)
|
||||||
|
{
|
||||||
|
auto outLength = static_cast<unsigned long>(GetBase64DecodeOutputLength(base64Data, inputLength));
|
||||||
|
assert(outLength <= outputBufferSize);
|
||||||
|
if (outLength > outputBufferSize)
|
||||||
|
return 0u;
|
||||||
|
|
||||||
|
const auto result =
|
||||||
|
base64_decode(static_cast<const char*>(base64Data), static_cast<unsigned long>(inputLength), static_cast<unsigned char*>(outputBuffer), &outLength);
|
||||||
|
assert(result == CRYPT_OK);
|
||||||
|
|
||||||
|
return static_cast<size_t>(outLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t GetBase64DecodeOutputLength(const void* base64Data, const size_t inputLength)
|
||||||
|
{
|
||||||
|
assert(base64Data);
|
||||||
|
assert(inputLength);
|
||||||
|
|
||||||
|
if (!base64Data || inputLength == 0u)
|
||||||
|
return 0u;
|
||||||
|
|
||||||
|
auto padding = 0u;
|
||||||
|
if (inputLength >= 1 && static_cast<const char*>(base64Data)[inputLength - 1] == '=')
|
||||||
|
{
|
||||||
|
if (inputLength >= 2 && static_cast<const char*>(base64Data)[inputLength - 2] == '=')
|
||||||
|
padding = 2u;
|
||||||
|
else
|
||||||
|
padding = 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((inputLength / 4u) * 3u) - padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t GetBase64DecodeOutputLength(const size_t inputLength)
|
||||||
|
{
|
||||||
|
return (inputLength / 4u) * 3u;
|
||||||
|
}
|
||||||
|
} // namespace base64
|
@ -8,5 +8,6 @@ namespace base64
|
|||||||
size_t GetBase64EncodeOutputLength(size_t inputLength);
|
size_t GetBase64EncodeOutputLength(size_t inputLength);
|
||||||
|
|
||||||
size_t DecodeBase64(const void* base64Data, size_t inputLength, void* outputBuffer, size_t outputBufferSize);
|
size_t DecodeBase64(const void* base64Data, size_t inputLength, void* outputBuffer, size_t outputBufferSize);
|
||||||
|
size_t GetBase64DecodeOutputLength(const void* base64Data, size_t inputLength);
|
||||||
size_t GetBase64DecodeOutputLength(size_t inputLength);
|
size_t GetBase64DecodeOutputLength(size_t inputLength);
|
||||||
} // namespace base64
|
} // namespace base64
|
7
src/Cryptography/Cryptography.h
Normal file
7
src/Cryptography/Cryptography.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Algorithms/AlgorithmMd5.h"
|
||||||
|
#include "Algorithms/AlgorithmRsa.h"
|
||||||
|
#include "Algorithms/AlgorithmSalsa20.h"
|
||||||
|
#include "Algorithms/AlgorithmSha1.h"
|
||||||
|
#include "Algorithms/AlgorithmSha256.h"
|
22
src/Cryptography/IHashFunction.h
Normal file
22
src/Cryptography/IHashFunction.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
class IHashFunction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IHashFunction() = default;
|
||||||
|
virtual ~IHashFunction() = default;
|
||||||
|
IHashFunction(const IHashFunction& other) = default;
|
||||||
|
IHashFunction(IHashFunction&& other) noexcept = default;
|
||||||
|
IHashFunction& operator=(const IHashFunction& other) = default;
|
||||||
|
IHashFunction& operator=(IHashFunction&& other) noexcept = default;
|
||||||
|
|
||||||
|
virtual size_t GetHashSize() = 0;
|
||||||
|
virtual void Init() = 0;
|
||||||
|
virtual void Process(const void* input, size_t inputSize) = 0;
|
||||||
|
virtual void Finish(void* hashBuffer) = 0;
|
||||||
|
};
|
||||||
|
} // namespace cryptography
|
30
src/Cryptography/IPublicKeyAlgorithm.h
Normal file
30
src/Cryptography/IPublicKeyAlgorithm.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
enum class HashingAlgorithm : std::uint8_t
|
||||||
|
{
|
||||||
|
RSA_HASH_SHA256,
|
||||||
|
RSA_HASH_SHA512
|
||||||
|
};
|
||||||
|
|
||||||
|
class IPublicKeyAlgorithm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IPublicKeyAlgorithm() = default;
|
||||||
|
virtual ~IPublicKeyAlgorithm() = default;
|
||||||
|
IPublicKeyAlgorithm(const IPublicKeyAlgorithm& other) = default;
|
||||||
|
IPublicKeyAlgorithm(IPublicKeyAlgorithm&& other) noexcept = default;
|
||||||
|
IPublicKeyAlgorithm& operator=(const IPublicKeyAlgorithm& other) = default;
|
||||||
|
IPublicKeyAlgorithm& operator=(IPublicKeyAlgorithm&& other) noexcept = default;
|
||||||
|
|
||||||
|
virtual bool SetKey(const uint8_t* keyData, size_t keySize) = 0;
|
||||||
|
|
||||||
|
// If needed, add a signing method
|
||||||
|
|
||||||
|
virtual bool Verify(const uint8_t* signedData, size_t signedDataSize, const uint8_t* signature, size_t signatureSize) = 0;
|
||||||
|
};
|
||||||
|
} // namespace cryptography
|
21
src/Cryptography/IStreamCipher.h
Normal file
21
src/Cryptography/IStreamCipher.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace cryptography
|
||||||
|
{
|
||||||
|
class IStreamCipher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IStreamCipher() = default;
|
||||||
|
virtual ~IStreamCipher() = default;
|
||||||
|
IStreamCipher(const IStreamCipher& other) = default;
|
||||||
|
IStreamCipher(IStreamCipher&& other) noexcept = default;
|
||||||
|
IStreamCipher& operator=(const IStreamCipher& other) = default;
|
||||||
|
IStreamCipher& operator=(IStreamCipher&& other) noexcept = default;
|
||||||
|
|
||||||
|
virtual void SetIv(const uint8_t* iv, size_t ivSize) = 0;
|
||||||
|
virtual void Process(const void* plainText, void* cipherText, size_t amount) = 0;
|
||||||
|
};
|
||||||
|
} // namespace cryptography
|
18
src/Cryptography/Internal/CryptoLibrary.cpp
Normal file
18
src/Cryptography/Internal/CryptoLibrary.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include "CryptoLibrary.h"
|
||||||
|
|
||||||
|
#include "tommath.h"
|
||||||
|
|
||||||
|
namespace cryptography::internal
|
||||||
|
{
|
||||||
|
void CryptoLibrary::Init()
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
ltc_mp = ltm_desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace cryptography::internal
|
13
src/Cryptography/Internal/CryptoLibrary.h
Normal file
13
src/Cryptography/Internal/CryptoLibrary.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define LTC_NO_PROTOTYPES
|
||||||
|
#include "tomcrypt.h"
|
||||||
|
|
||||||
|
namespace cryptography::internal
|
||||||
|
{
|
||||||
|
class CryptoLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Init();
|
||||||
|
};
|
||||||
|
} // namespace cryptography::internal
|
@ -5,6 +5,7 @@
|
|||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
|
#include "Utils/PathUtils.h"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <format>
|
#include <format>
|
||||||
@ -152,9 +153,9 @@ void LinkerArgs::PrintVersion()
|
|||||||
std::cout << std::format("OpenAssetTools Linker {}\n", GIT_VERSION);
|
std::cout << std::format("OpenAssetTools Linker {}\n", GIT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkerArgs::SetBinFolder(const char* argv0)
|
void LinkerArgs::SetBinFolder()
|
||||||
{
|
{
|
||||||
const fs::path path(argv0);
|
const fs::path path(utils::GetExecutablePath());
|
||||||
m_bin_folder = path.parent_path().string();
|
m_bin_folder = path.parent_path().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldContin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetBinFolder(argv[0]);
|
SetBinFolder();
|
||||||
|
|
||||||
m_project_specifiers_to_build = m_argument_parser.GetArguments();
|
m_project_specifiers_to_build = m_argument_parser.GetArguments();
|
||||||
if (m_project_specifiers_to_build.empty())
|
if (m_project_specifiers_to_build.empty())
|
||||||
|
@ -37,7 +37,7 @@ private:
|
|||||||
void PrintUsage() const;
|
void PrintUsage() const;
|
||||||
static void PrintVersion();
|
static void PrintVersion();
|
||||||
|
|
||||||
void SetBinFolder(const char* argv0);
|
void SetBinFolder();
|
||||||
void SetVerbose(bool isVerbose);
|
void SetVerbose(bool isVerbose);
|
||||||
|
|
||||||
ArgumentParser m_argument_parser;
|
ArgumentParser m_argument_parser;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "SearchPath/IWD.h"
|
#include "SearchPath/IWD.h"
|
||||||
#include "SearchPath/SearchPathFilesystem.h"
|
#include "SearchPath/SearchPathFilesystem.h"
|
||||||
#include "SearchPath/SearchPaths.h"
|
#include "SearchPath/SearchPaths.h"
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -55,8 +56,8 @@ namespace
|
|||||||
void CreateFromString(const std::string& templateString)
|
void CreateFromString(const std::string& templateString)
|
||||||
{
|
{
|
||||||
const auto templateStringLength = templateString.size();
|
const auto templateStringLength = templateString.size();
|
||||||
auto partStart = 0u;
|
auto partStart = 0uz;
|
||||||
for (auto i = 0u; i < templateStringLength; i++)
|
for (auto i = 0uz; i < templateStringLength; i++)
|
||||||
{
|
{
|
||||||
if (templateString[i] != '?')
|
if (templateString[i] != '?')
|
||||||
continue;
|
continue;
|
||||||
@ -215,7 +216,10 @@ namespace
|
|||||||
{
|
{
|
||||||
if (!curTemplate.CanRender(PROJECT_MASK) && curTemplate.CanRender(GAME_MASK))
|
if (!curTemplate.CanRender(PROJECT_MASK) && curTemplate.CanRender(GAME_MASK))
|
||||||
{
|
{
|
||||||
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, GameId_Names[static_cast<unsigned>(game)]);
|
std::string gameName(GameId_Names[static_cast<unsigned>(game)]);
|
||||||
|
utils::MakeStringLowerCase(gameName);
|
||||||
|
|
||||||
|
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, gameName);
|
||||||
if (AddSearchPath(addedSearchPaths, searchPaths, renderedTemplate))
|
if (AddSearchPath(addedSearchPaths, searchPaths, renderedTemplate))
|
||||||
hasSearchPath = true;
|
hasSearchPath = true;
|
||||||
}
|
}
|
||||||
@ -310,8 +314,8 @@ namespace
|
|||||||
|
|
||||||
std::unique_ptr<ILinkerPaths> ILinkerPaths::FromArgs(const LinkerArgs& args)
|
std::unique_ptr<ILinkerPaths> ILinkerPaths::FromArgs(const LinkerArgs& args)
|
||||||
{
|
{
|
||||||
std::string normalizedBinPath = fs::canonical(args.m_bin_folder).make_preferred().string();
|
std::string normalizedBinPath = fs::weakly_canonical(args.m_bin_folder).make_preferred().string();
|
||||||
std::string normalizedBasePath = fs::canonical(args.m_base_folder).make_preferred().string();
|
std::string normalizedBasePath = fs::weakly_canonical(args.m_base_folder).make_preferred().string();
|
||||||
|
|
||||||
LinkerSearchPathBuilder assetSearchPaths("asset", normalizedBinPath, normalizedBasePath);
|
LinkerSearchPathBuilder assetSearchPaths("asset", normalizedBinPath, normalizedBasePath);
|
||||||
assetSearchPaths.BuildFromArgs(args.m_asset_search_paths);
|
assetSearchPaths.BuildFromArgs(args.m_asset_search_paths);
|
||||||
|
@ -21,7 +21,7 @@ bool CsvHeaderRow::RequireIndexForHeader(const std::string& headerName, unsigned
|
|||||||
if (existingHeader == m_header_row.end())
|
if (existingHeader == m_header_row.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
out = std::distance(m_header_row.begin(), existingHeader);
|
out = static_cast<unsigned>(std::distance(m_header_row.begin(), existingHeader));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
|
|
||||||
bool Read(const CsvInputStream& inputStream);
|
bool Read(const CsvInputStream& inputStream);
|
||||||
|
|
||||||
const std::string& HeaderNameForColumn(unsigned columnIndex) const;
|
[[nodiscard]] const std::string& HeaderNameForColumn(unsigned columnIndex) const;
|
||||||
bool RequireIndexForHeader(const std::string& headerName, unsigned& out) const;
|
bool RequireIndexForHeader(const std::string& headerName, unsigned& out) const;
|
||||||
[[nodiscard]] std::optional<unsigned> GetIndexForHeader(const std::string& headerName) const;
|
[[nodiscard]] std::optional<unsigned> GetIndexForHeader(const std::string& headerName) const;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace ipak_consts
|
|||||||
static constexpr size_t IPAK_CHUNK_SIZE = 0x8000;
|
static constexpr size_t IPAK_CHUNK_SIZE = 0x8000;
|
||||||
static constexpr size_t IPAK_CHUNK_COUNT_PER_READ = 0x8;
|
static constexpr size_t IPAK_CHUNK_COUNT_PER_READ = 0x8;
|
||||||
|
|
||||||
static constexpr uint32_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
static constexpr size_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
||||||
static constexpr uint32_t IPAK_COMMAND_UNCOMPRESSED = 0;
|
static constexpr uint32_t IPAK_COMMAND_UNCOMPRESSED = 0;
|
||||||
static constexpr uint32_t IPAK_COMMAND_COMPRESSED = 1;
|
static constexpr uint32_t IPAK_COMMAND_COMPRESSED = 1;
|
||||||
static constexpr uint32_t IPAK_COMMAND_SKIP = 0xCF;
|
static constexpr uint32_t IPAK_COMMAND_SKIP = 0xCF;
|
||||||
|
@ -68,7 +68,7 @@ namespace
|
|||||||
T result;
|
T result;
|
||||||
} data{};
|
} data{};
|
||||||
|
|
||||||
const auto byteCount = utils::Align(bitCount, 8u) / 8u;
|
const auto byteCount = utils::Align(bitCount, 8uz) / 8uz;
|
||||||
assert(byteCount <= sizeof(T));
|
assert(byteCount <= sizeof(T));
|
||||||
|
|
||||||
const auto shiftCount = (8u - bitCount % 8) % 8;
|
const auto shiftCount = (8u - bitCount % 8) % 8;
|
||||||
@ -83,7 +83,7 @@ namespace
|
|||||||
|
|
||||||
while (remainingBits > 0)
|
while (remainingBits > 0)
|
||||||
{
|
{
|
||||||
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8u));
|
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8uz));
|
||||||
|
|
||||||
if (m_remaining_bits_last_byte > 0)
|
if (m_remaining_bits_last_byte > 0)
|
||||||
{
|
{
|
||||||
|
@ -42,14 +42,14 @@ uint32_t CommonStructuredDataEnum::CalculateChecksum(const uint32_t initialValue
|
|||||||
{
|
{
|
||||||
auto checksum = initialValue;
|
auto checksum = initialValue;
|
||||||
|
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(m_name.c_str()), m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(m_name.c_str()), static_cast<unsigned>(m_name.size() + 1u));
|
||||||
|
|
||||||
const auto littleEndianElementCount = endianness::ToLittleEndian(ElementCount());
|
const auto littleEndianElementCount = endianness::ToLittleEndian(ElementCount());
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(&littleEndianElementCount), sizeof(littleEndianElementCount));
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(&littleEndianElementCount), sizeof(littleEndianElementCount));
|
||||||
|
|
||||||
for (const auto& entry : m_entries)
|
for (const auto& entry : m_entries)
|
||||||
{
|
{
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(entry.m_name.c_str()), entry.m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(entry.m_name.c_str()), static_cast<unsigned>(entry.m_name.size() + 1));
|
||||||
|
|
||||||
const auto littleEndianValue = endianness::ToLittleEndian(entry.m_value);
|
const auto littleEndianValue = endianness::ToLittleEndian(entry.m_value);
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(&littleEndianValue), sizeof(littleEndianValue));
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(&littleEndianValue), sizeof(littleEndianValue));
|
||||||
|
@ -41,10 +41,10 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat
|
|||||||
{
|
{
|
||||||
auto checksum = initialValue;
|
auto checksum = initialValue;
|
||||||
|
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(m_name.c_str()), m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(m_name.c_str()), static_cast<unsigned>(m_name.size() + 1u));
|
||||||
for (const auto& property : m_properties)
|
for (const auto& property : m_properties)
|
||||||
{
|
{
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(property.m_name.c_str()), property.m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(property.m_name.c_str()), static_cast<unsigned>(property.m_name.size() + 1u));
|
||||||
|
|
||||||
const auto littleEndianOffset = endianness::ToLittleEndian(property.m_offset_in_bits);
|
const auto littleEndianOffset = endianness::ToLittleEndian(property.m_offset_in_bits);
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(&littleEndianOffset), sizeof(littleEndianOffset));
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(&littleEndianOffset), sizeof(littleEndianOffset));
|
||||||
@ -68,7 +68,7 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat
|
|||||||
if (currentType.m_info.type_index < def.m_enums.size())
|
if (currentType.m_info.type_index < def.m_enums.size())
|
||||||
{
|
{
|
||||||
const auto& _enum = *def.m_enums[currentType.m_info.type_index];
|
const auto& _enum = *def.m_enums[currentType.m_info.type_index];
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(_enum.m_name.c_str()), _enum.m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(_enum.m_name.c_str()), static_cast<unsigned>(_enum.m_name.size() + 1u));
|
||||||
currentType = CommonStructuredDataType(CommonStructuredDataTypeCategory::UNKNOWN);
|
currentType = CommonStructuredDataType(CommonStructuredDataTypeCategory::UNKNOWN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -76,7 +76,7 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat
|
|||||||
if (currentType.m_info.type_index < def.m_structs.size())
|
if (currentType.m_info.type_index < def.m_structs.size())
|
||||||
{
|
{
|
||||||
const auto& _struct = *def.m_structs[currentType.m_info.type_index];
|
const auto& _struct = *def.m_structs[currentType.m_info.type_index];
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(_struct.m_name.c_str()), _struct.m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(_struct.m_name.c_str()), static_cast<unsigned>(_struct.m_name.size() + 1u));
|
||||||
currentType = CommonStructuredDataType(CommonStructuredDataTypeCategory::UNKNOWN);
|
currentType = CommonStructuredDataType(CommonStructuredDataTypeCategory::UNKNOWN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -99,7 +99,7 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat
|
|||||||
if (enumedArray.m_enum_index < def.m_enums.size())
|
if (enumedArray.m_enum_index < def.m_enums.size())
|
||||||
{
|
{
|
||||||
const auto& _enum = *def.m_enums[enumedArray.m_enum_index];
|
const auto& _enum = *def.m_enums[enumedArray.m_enum_index];
|
||||||
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(_enum.m_name.c_str()), _enum.m_name.size() + 1);
|
checksum = crc32(checksum, reinterpret_cast<const Bytef*>(_enum.m_name.c_str()), static_cast<unsigned>(_enum.m_name.size() + 1u));
|
||||||
}
|
}
|
||||||
currentType = enumedArray.m_array_type;
|
currentType = enumedArray.m_array_type;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CommonStructuredDataTypes.h"
|
#include "CommonStructuredDataTypes.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -8,29 +8,29 @@
|
|||||||
|
|
||||||
struct CommonStructuredDataStructProperty
|
struct CommonStructuredDataStructProperty
|
||||||
{
|
{
|
||||||
std::string m_name;
|
|
||||||
CommonStructuredDataType m_type;
|
|
||||||
size_t m_offset_in_bits;
|
|
||||||
|
|
||||||
CommonStructuredDataStructProperty();
|
CommonStructuredDataStructProperty();
|
||||||
explicit CommonStructuredDataStructProperty(std::string name);
|
explicit CommonStructuredDataStructProperty(std::string name);
|
||||||
CommonStructuredDataStructProperty(std::string name, CommonStructuredDataType type, size_t offsetInBits);
|
CommonStructuredDataStructProperty(std::string name, CommonStructuredDataType type, size_t offsetInBits);
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
CommonStructuredDataType m_type;
|
||||||
|
size_t m_offset_in_bits;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CommonStructuredDataDef;
|
class CommonStructuredDataDef;
|
||||||
|
|
||||||
struct CommonStructuredDataStruct
|
struct CommonStructuredDataStruct
|
||||||
{
|
{
|
||||||
|
CommonStructuredDataStruct();
|
||||||
|
explicit CommonStructuredDataStruct(std::string name);
|
||||||
|
|
||||||
|
[[nodiscard]] uint32_t CalculateChecksum(const CommonStructuredDataDef& def, uint32_t initialValue) const;
|
||||||
|
|
||||||
|
void SortPropertiesByOffset();
|
||||||
|
void SortPropertiesByName();
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::vector<CommonStructuredDataStructProperty> m_properties;
|
std::vector<CommonStructuredDataStructProperty> m_properties;
|
||||||
size_t m_bit_offset;
|
size_t m_bit_offset;
|
||||||
size_t m_size_in_byte;
|
size_t m_size_in_byte;
|
||||||
|
|
||||||
CommonStructuredDataStruct();
|
|
||||||
explicit CommonStructuredDataStruct(std::string name);
|
|
||||||
|
|
||||||
_NODISCARD uint32_t CalculateChecksum(const CommonStructuredDataDef& def, uint32_t initialValue) const;
|
|
||||||
|
|
||||||
void SortPropertiesByOffset();
|
|
||||||
void SortPropertiesByName();
|
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
|||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
|
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
|
||||||
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8u);
|
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8uz);
|
||||||
}
|
}
|
||||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
|||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
|
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
|
||||||
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8u);
|
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8uz);
|
||||||
}
|
}
|
||||||
|
|
||||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ namespace
|
|||||||
|
|
||||||
auto* gameKvps = m_memory.Alloc<KeyValuePairs>();
|
auto* gameKvps = m_memory.Alloc<KeyValuePairs>();
|
||||||
gameKvps->name = m_memory.Dup(m_zone.m_name.c_str());
|
gameKvps->name = m_memory.Dup(m_zone.m_name.c_str());
|
||||||
gameKvps->numVariables = commonKvps.size();
|
gameKvps->numVariables = static_cast<unsigned>(commonKvps.size());
|
||||||
gameKvps->keyValuePairs = m_memory.Alloc<KeyValuePair>(commonKvps.size());
|
gameKvps->keyValuePairs = m_memory.Alloc<KeyValuePair>(commonKvps.size());
|
||||||
|
|
||||||
const auto namespaceHash = Common::Com_HashKey(m_zone.m_name.c_str(), 64);
|
const auto namespaceHash = Common::Com_HashKey(m_zone.m_name.c_str(), 64);
|
||||||
|
@ -17,7 +17,7 @@ namespace
|
|||||||
ISearchPath& searchPath,
|
ISearchPath& searchPath,
|
||||||
ZoneAssetCreationStateContainer& zoneStates)
|
ZoneAssetCreationStateContainer& zoneStates)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddAssetCreator(CreateKeyValuePairsCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
collection.AddAssetCreator(CreateKeyValuePairsCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIPakPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIPakPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIPakPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIPakPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "IPakCreator.h"
|
#include "IPakCreator.h"
|
||||||
|
|
||||||
#include "Game/T6/CommonT6.h"
|
#include "Game/T6/CommonT6.h"
|
||||||
#include "Game/T6/GameT6.h"
|
|
||||||
#include "GitVersion.h"
|
#include "GitVersion.h"
|
||||||
#include "ObjContainer/IPak/IPakTypes.h"
|
#include "ObjContainer/IPak/IPakTypes.h"
|
||||||
#include "Utils/Alignment.h"
|
#include "Utils/Alignment.h"
|
||||||
@ -23,7 +22,7 @@ namespace
|
|||||||
static constexpr char BRANDING[] = "Created with OpenAssetTools " GIT_VERSION;
|
static constexpr char BRANDING[] = "Created with OpenAssetTools " GIT_VERSION;
|
||||||
static constexpr auto SECTION_COUNT = 3; // Index + Data + Branding
|
static constexpr auto SECTION_COUNT = 3; // Index + Data + Branding
|
||||||
|
|
||||||
inline static const std::string PAD_DATA = std::string(256, '\xA7');
|
inline static const auto PAD_DATA = std::string(256, '\xA7');
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IPakWriter(std::ostream& stream, ISearchPath& searchPath, const std::vector<std::string>& images)
|
IPakWriter(std::ostream& stream, ISearchPath& searchPath, const std::vector<std::string>& images)
|
||||||
@ -70,8 +69,8 @@ namespace
|
|||||||
|
|
||||||
void Write(const void* data, const size_t dataSize)
|
void Write(const void* data, const size_t dataSize)
|
||||||
{
|
{
|
||||||
m_stream.write(static_cast<const char*>(data), dataSize);
|
m_stream.write(static_cast<const char*>(data), static_cast<std::streamsize>(dataSize));
|
||||||
m_current_offset += dataSize;
|
m_current_offset += static_cast<int64_t>(dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pad(const size_t paddingSize)
|
void Pad(const size_t paddingSize)
|
||||||
@ -100,27 +99,30 @@ namespace
|
|||||||
{
|
{
|
||||||
GoTo(0);
|
GoTo(0);
|
||||||
|
|
||||||
const IPakHeader header{ipak_consts::IPAK_MAGIC, ipak_consts::IPAK_VERSION, static_cast<uint32_t>(m_total_size), SECTION_COUNT};
|
const IPakHeader header{.magic = ipak_consts::IPAK_MAGIC,
|
||||||
|
.version = ipak_consts::IPAK_VERSION,
|
||||||
|
.size = static_cast<uint32_t>(m_total_size),
|
||||||
|
.sectionCount = SECTION_COUNT};
|
||||||
|
|
||||||
const IPakSection dataSection{
|
const IPakSection dataSection{
|
||||||
ipak_consts::IPAK_DATA_SECTION,
|
.type = ipak_consts::IPAK_DATA_SECTION,
|
||||||
static_cast<uint32_t>(m_data_section_offset),
|
.offset = static_cast<uint32_t>(m_data_section_offset),
|
||||||
static_cast<uint32_t>(m_data_section_size),
|
.size = static_cast<uint32_t>(m_data_section_size),
|
||||||
static_cast<uint32_t>(m_index_entries.size()),
|
.itemCount = static_cast<uint32_t>(m_index_entries.size()),
|
||||||
};
|
};
|
||||||
|
|
||||||
const IPakSection indexSection{
|
const IPakSection indexSection{
|
||||||
ipak_consts::IPAK_INDEX_SECTION,
|
.type = ipak_consts::IPAK_INDEX_SECTION,
|
||||||
static_cast<uint32_t>(m_index_section_offset),
|
.offset = static_cast<uint32_t>(m_index_section_offset),
|
||||||
static_cast<uint32_t>(sizeof(IPakIndexEntry) * m_index_entries.size()),
|
.size = static_cast<uint32_t>(sizeof(IPakIndexEntry) * m_index_entries.size()),
|
||||||
static_cast<uint32_t>(m_index_entries.size()),
|
.itemCount = static_cast<uint32_t>(m_index_entries.size()),
|
||||||
};
|
};
|
||||||
|
|
||||||
const IPakSection brandingSection{
|
const IPakSection brandingSection{
|
||||||
ipak_consts::IPAK_BRANDING_SECTION,
|
.type = ipak_consts::IPAK_BRANDING_SECTION,
|
||||||
static_cast<uint32_t>(m_branding_section_offset),
|
.offset = static_cast<uint32_t>(m_branding_section_offset),
|
||||||
std::extent_v<decltype(BRANDING)>,
|
.size = std::extent_v<decltype(BRANDING)>,
|
||||||
1,
|
.itemCount = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
Write(&header, sizeof(header));
|
Write(&header, sizeof(header));
|
||||||
@ -147,7 +149,7 @@ namespace
|
|||||||
|
|
||||||
imageSize = static_cast<size_t>(openFile.m_length);
|
imageSize = static_cast<size_t>(openFile.m_length);
|
||||||
auto imageData = std::make_unique<char[]>(imageSize);
|
auto imageData = std::make_unique<char[]>(imageSize);
|
||||||
openFile.m_stream->read(imageData.get(), imageSize);
|
openFile.m_stream->read(imageData.get(), static_cast<std::streamsize>(imageSize));
|
||||||
|
|
||||||
return imageData;
|
return imageData;
|
||||||
}
|
}
|
||||||
@ -177,7 +179,7 @@ namespace
|
|||||||
IPakDataBlockHeader skipBlockHeader{};
|
IPakDataBlockHeader skipBlockHeader{};
|
||||||
skipBlockHeader.countAndOffset.count = 1;
|
skipBlockHeader.countAndOffset.count = 1;
|
||||||
skipBlockHeader.commands[0].compressed = ipak_consts::IPAK_COMMAND_SKIP;
|
skipBlockHeader.commands[0].compressed = ipak_consts::IPAK_COMMAND_SKIP;
|
||||||
skipBlockHeader.commands[0].size = sizeToSkip - sizeof(IPakDataBlockHeader);
|
skipBlockHeader.commands[0].size = static_cast<uint32_t>(sizeToSkip - sizeof(IPakDataBlockHeader));
|
||||||
Write(&skipBlockHeader, sizeof(skipBlockHeader));
|
Write(&skipBlockHeader, sizeof(skipBlockHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,12 +201,12 @@ namespace
|
|||||||
m_current_block.countAndOffset.offset = static_cast<uint32_t>(m_file_offset);
|
m_current_block.countAndOffset.offset = static_cast<uint32_t>(m_file_offset);
|
||||||
|
|
||||||
// Reserve space to later write actual block header data
|
// Reserve space to later write actual block header data
|
||||||
GoTo(m_current_offset + sizeof(IPakDataBlockHeader));
|
GoTo(static_cast<int64_t>(m_current_offset + sizeof(IPakDataBlockHeader)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteChunkData(const void* data, const size_t dataSize)
|
void WriteChunkData(const void* data, const size_t dataSize)
|
||||||
{
|
{
|
||||||
auto dataOffset = 0u;
|
auto dataOffset = 0uz;
|
||||||
while (dataOffset < dataSize)
|
while (dataOffset < dataSize)
|
||||||
{
|
{
|
||||||
if (m_current_block.countAndOffset.count >= std::extent_v<decltype(IPakDataBlockHeader::commands)>)
|
if (m_current_block.countAndOffset.count >= std::extent_v<decltype(IPakDataBlockHeader::commands)>)
|
||||||
@ -216,7 +218,7 @@ namespace
|
|||||||
const auto remainingSize = dataSize - dataOffset;
|
const auto remainingSize = dataSize - dataOffset;
|
||||||
const auto remainingChunkBufferWindowSize = std::max((ipak_consts::IPAK_CHUNK_COUNT_PER_READ * ipak_consts::IPAK_CHUNK_SIZE)
|
const auto remainingChunkBufferWindowSize = std::max((ipak_consts::IPAK_CHUNK_COUNT_PER_READ * ipak_consts::IPAK_CHUNK_SIZE)
|
||||||
- static_cast<size_t>(m_current_offset - m_chunk_buffer_window_start),
|
- static_cast<size_t>(m_current_offset - m_chunk_buffer_window_start),
|
||||||
0u);
|
0uz);
|
||||||
|
|
||||||
if (remainingChunkBufferWindowSize == 0)
|
if (remainingChunkBufferWindowSize == 0)
|
||||||
{
|
{
|
||||||
@ -225,7 +227,7 @@ namespace
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto commandSize = std::min(std::min(remainingSize, ipak_consts::IPAK_COMMAND_DEFAULT_SIZE), remainingChunkBufferWindowSize);
|
const auto commandSize = std::min({remainingSize, ipak_consts::IPAK_COMMAND_DEFAULT_SIZE, remainingChunkBufferWindowSize});
|
||||||
|
|
||||||
auto writeUncompressed = true;
|
auto writeUncompressed = true;
|
||||||
if (USE_IPAK_COMPRESSION)
|
if (USE_IPAK_COMPRESSION)
|
||||||
@ -254,7 +256,7 @@ namespace
|
|||||||
Write(&static_cast<const char*>(data)[dataOffset], commandSize);
|
Write(&static_cast<const char*>(data)[dataOffset], commandSize);
|
||||||
|
|
||||||
const auto currentCommand = m_current_block.countAndOffset.count;
|
const auto currentCommand = m_current_block.countAndOffset.count;
|
||||||
m_current_block.commands[currentCommand].size = commandSize;
|
m_current_block.commands[currentCommand].size = static_cast<uint32_t>(commandSize);
|
||||||
m_current_block.commands[currentCommand].compressed = ipak_consts::IPAK_COMMAND_UNCOMPRESSED;
|
m_current_block.commands[currentCommand].compressed = ipak_consts::IPAK_COMMAND_UNCOMPRESSED;
|
||||||
m_current_block.countAndOffset.count = currentCommand + 1u;
|
m_current_block.countAndOffset.count = currentCommand + 1u;
|
||||||
}
|
}
|
||||||
@ -281,7 +283,7 @@ namespace
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const auto nameHash = T6::Common::R_HashString(imageName.c_str(), 0);
|
const auto nameHash = T6::Common::R_HashString(imageName.c_str(), 0);
|
||||||
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(imageData.get()), imageSize));
|
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(imageData.get()), static_cast<unsigned>(imageSize)));
|
||||||
|
|
||||||
StartNewFile();
|
StartNewFile();
|
||||||
const auto startOffset = m_current_block_header_offset;
|
const auto startOffset = m_current_block_header_offset;
|
||||||
@ -294,7 +296,7 @@ namespace
|
|||||||
WriteChunkData(imageData.get(), imageSize);
|
WriteChunkData(imageData.get(), imageSize);
|
||||||
const auto writtenImageSize = static_cast<size_t>(m_current_offset - startOffset);
|
const auto writtenImageSize = static_cast<size_t>(m_current_offset - startOffset);
|
||||||
|
|
||||||
indexEntry.size = writtenImageSize;
|
indexEntry.size = static_cast<uint32_t>(writtenImageSize);
|
||||||
m_index_entries.emplace_back(indexEntry);
|
m_index_entries.emplace_back(indexEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,16 +14,28 @@ namespace dds
|
|||||||
{
|
{
|
||||||
static constexpr auto DDS_MAGIC = FileUtils::MakeMagic32('D', 'D', 'S', ' ');
|
static constexpr auto DDS_MAGIC = FileUtils::MakeMagic32('D', 'D', 'S', ' ');
|
||||||
|
|
||||||
std::istream& m_stream;
|
public:
|
||||||
|
explicit DdsLoaderInternal(std::istream& stream)
|
||||||
|
: m_stream(stream),
|
||||||
|
m_texture_type(TextureType::T_2D),
|
||||||
|
m_has_mip_maps(false),
|
||||||
|
m_width(0u),
|
||||||
|
m_height(0u),
|
||||||
|
m_depth(0u),
|
||||||
|
m_format(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TextureType m_texture_type;
|
std::unique_ptr<Texture> LoadDds()
|
||||||
bool m_has_mip_maps;
|
{
|
||||||
size_t m_width;
|
if (!ReadMagic() || !ReadHeader())
|
||||||
size_t m_height;
|
return nullptr;
|
||||||
size_t m_depth;
|
|
||||||
const ImageFormat* m_format;
|
|
||||||
|
|
||||||
_NODISCARD bool ReadMagic() const
|
return ReadTextureData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] bool ReadMagic() const
|
||||||
{
|
{
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
m_stream.read(reinterpret_cast<char*>(&magic), sizeof(magic));
|
m_stream.read(reinterpret_cast<char*>(&magic), sizeof(magic));
|
||||||
@ -42,7 +54,7 @@ namespace dds
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD bool ReadDxt10Header()
|
[[nodiscard]] bool ReadDxt10Header()
|
||||||
{
|
{
|
||||||
DDS_HEADER_DXT10 headerDx10{};
|
DDS_HEADER_DXT10 headerDx10{};
|
||||||
m_stream.read(reinterpret_cast<char*>(&headerDx10), sizeof(headerDx10));
|
m_stream.read(reinterpret_cast<char*>(&headerDx10), sizeof(headerDx10));
|
||||||
@ -86,7 +98,7 @@ namespace dds
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD bool ReadPixelFormatFourCc(DDS_PIXELFORMAT& pf)
|
[[nodiscard]] bool ReadPixelFormatFourCc(DDS_PIXELFORMAT& pf)
|
||||||
{
|
{
|
||||||
switch (pf.dwFourCC)
|
switch (pf.dwFourCC)
|
||||||
{
|
{
|
||||||
@ -132,7 +144,7 @@ namespace dds
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD bool ReadPixelFormatUnsigned(DDS_PIXELFORMAT& pf)
|
[[nodiscard]] bool ReadPixelFormatUnsigned(DDS_PIXELFORMAT& pf)
|
||||||
{
|
{
|
||||||
unsigned rOffset, rSize, gOffset, gSize, bOffset, bSize, aOffset, aSize;
|
unsigned rOffset, rSize, gOffset, gSize, bOffset, bSize, aOffset, aSize;
|
||||||
|
|
||||||
@ -163,7 +175,7 @@ namespace dds
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD bool ReadPixelFormat(DDS_PIXELFORMAT& pf)
|
[[nodiscard]] bool ReadPixelFormat(DDS_PIXELFORMAT& pf)
|
||||||
{
|
{
|
||||||
if (pf.dwFlags & DDPF_FOURCC)
|
if (pf.dwFlags & DDPF_FOURCC)
|
||||||
return ReadPixelFormatFourCc(pf);
|
return ReadPixelFormatFourCc(pf);
|
||||||
@ -200,7 +212,7 @@ namespace dds
|
|||||||
return ReadPixelFormat(header.ddspf);
|
return ReadPixelFormat(header.ddspf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD std::unique_ptr<Texture> ReadTextureData() const
|
[[nodiscard]] std::unique_ptr<Texture> ReadTextureData() const
|
||||||
{
|
{
|
||||||
std::unique_ptr<Texture> result;
|
std::unique_ptr<Texture> result;
|
||||||
|
|
||||||
@ -229,7 +241,7 @@ namespace dds
|
|||||||
|
|
||||||
for (auto mipLevel = 0; mipLevel < mipMapCount; mipLevel++)
|
for (auto mipLevel = 0; mipLevel < mipMapCount; mipLevel++)
|
||||||
{
|
{
|
||||||
const auto mipSize = result->GetSizeOfMipLevel(mipLevel);
|
const auto mipSize = static_cast<std::streamsize>(result->GetSizeOfMipLevel(mipLevel));
|
||||||
|
|
||||||
for (auto face = 0; face < faceCount; face++)
|
for (auto face = 0; face < faceCount; face++)
|
||||||
{
|
{
|
||||||
@ -246,25 +258,14 @@ namespace dds
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
std::istream& m_stream;
|
||||||
explicit DdsLoaderInternal(std::istream& stream)
|
|
||||||
: m_stream(stream),
|
|
||||||
m_texture_type(TextureType::T_2D),
|
|
||||||
m_has_mip_maps(false),
|
|
||||||
m_width(0u),
|
|
||||||
m_height(0u),
|
|
||||||
m_depth(0u),
|
|
||||||
m_format(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Texture> LoadDds()
|
TextureType m_texture_type;
|
||||||
{
|
bool m_has_mip_maps;
|
||||||
if (!ReadMagic() || !ReadHeader())
|
unsigned m_width;
|
||||||
return nullptr;
|
unsigned m_height;
|
||||||
|
unsigned m_depth;
|
||||||
return ReadTextureData();
|
const ImageFormat* m_format;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Texture> LoadDds(std::istream& stream)
|
std::unique_ptr<Texture> LoadDds(std::istream& stream)
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
{
|
{
|
||||||
const auto* buffer = m_texture->GetBufferForMipLevel(mipLevel);
|
const auto* buffer = m_texture->GetBufferForMipLevel(mipLevel);
|
||||||
const auto mipLevelSize = m_texture->GetSizeOfMipLevel(mipLevel) * m_texture->GetFaceCount();
|
const auto mipLevelSize = m_texture->GetSizeOfMipLevel(mipLevel) * m_texture->GetFaceCount();
|
||||||
m_stream.write(reinterpret_cast<const char*>(buffer), mipLevelSize);
|
m_stream.write(reinterpret_cast<const char*>(buffer), static_cast<std::streamsize>(mipLevelSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public:
|
|||||||
header.dwHeight = m_texture->GetHeight();
|
header.dwHeight = m_texture->GetHeight();
|
||||||
header.dwWidth = m_texture->GetWidth();
|
header.dwWidth = m_texture->GetWidth();
|
||||||
header.dwDepth = m_texture->GetDepth();
|
header.dwDepth = m_texture->GetDepth();
|
||||||
header.dwPitchOrLinearSize = m_texture->GetFormat()->GetPitch(0, m_texture->GetWidth());
|
header.dwPitchOrLinearSize = static_cast<uint32_t>(m_texture->GetFormat()->GetPitch(0, m_texture->GetWidth()));
|
||||||
header.dwMipMapCount = m_texture->HasMipMaps() ? m_texture->GetMipMapCount() : 1;
|
header.dwMipMapCount = m_texture->HasMipMaps() ? m_texture->GetMipMapCount() : 1;
|
||||||
|
|
||||||
PopulatePixelFormat(header.ddspf);
|
PopulatePixelFormat(header.ddspf);
|
||||||
|
@ -14,7 +14,7 @@ Dx12TextureLoader::Dx12TextureLoader()
|
|||||||
|
|
||||||
const ImageFormat* Dx12TextureLoader::GetFormatForDx12Format() const
|
const ImageFormat* Dx12TextureLoader::GetFormatForDx12Format() const
|
||||||
{
|
{
|
||||||
for (auto i : ImageFormat::ALL_FORMATS)
|
for (const auto* i : ImageFormat::ALL_FORMATS)
|
||||||
{
|
{
|
||||||
if (i->GetDxgiFormat() == m_format)
|
if (i->GetDxgiFormat() == m_format)
|
||||||
return i;
|
return i;
|
||||||
@ -41,19 +41,19 @@ Dx12TextureLoader& Dx12TextureLoader::HasMipMaps(const bool hasMipMaps)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dx12TextureLoader& Dx12TextureLoader::Width(const size_t width)
|
Dx12TextureLoader& Dx12TextureLoader::Width(const unsigned width)
|
||||||
{
|
{
|
||||||
m_width = width;
|
m_width = width;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dx12TextureLoader& Dx12TextureLoader::Height(const size_t height)
|
Dx12TextureLoader& Dx12TextureLoader::Height(const unsigned height)
|
||||||
{
|
{
|
||||||
m_height = height;
|
m_height = height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dx12TextureLoader& Dx12TextureLoader::Depth(const size_t depth)
|
Dx12TextureLoader& Dx12TextureLoader::Depth(const unsigned depth)
|
||||||
{
|
{
|
||||||
m_depth = depth;
|
m_depth = depth;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include "Image/DxgiFormat.h"
|
#include "Image/DxgiFormat.h"
|
||||||
#include "Image/Texture.h"
|
#include "Image/Texture.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
#include "Utils/MemoryManager.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -16,21 +14,21 @@ public:
|
|||||||
Dx12TextureLoader& Format(oat::DXGI_FORMAT format);
|
Dx12TextureLoader& Format(oat::DXGI_FORMAT format);
|
||||||
Dx12TextureLoader& Type(TextureType textureType);
|
Dx12TextureLoader& Type(TextureType textureType);
|
||||||
Dx12TextureLoader& HasMipMaps(bool hasMipMaps);
|
Dx12TextureLoader& HasMipMaps(bool hasMipMaps);
|
||||||
Dx12TextureLoader& Width(size_t width);
|
Dx12TextureLoader& Width(unsigned width);
|
||||||
Dx12TextureLoader& Height(size_t height);
|
Dx12TextureLoader& Height(unsigned height);
|
||||||
Dx12TextureLoader& Depth(size_t depth);
|
Dx12TextureLoader& Depth(unsigned depth);
|
||||||
|
|
||||||
std::unique_ptr<Texture> LoadTexture(const void* data);
|
std::unique_ptr<Texture> LoadTexture(const void* data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_NODISCARD const ImageFormat* GetFormatForDx12Format() const;
|
[[nodiscard]] const ImageFormat* GetFormatForDx12Format() const;
|
||||||
|
|
||||||
static std::unordered_map<ImageFormatId, ImageFormatId> m_conversion_table;
|
static std::unordered_map<ImageFormatId, ImageFormatId> m_conversion_table;
|
||||||
|
|
||||||
oat::DXGI_FORMAT m_format;
|
oat::DXGI_FORMAT m_format;
|
||||||
TextureType m_type;
|
TextureType m_type;
|
||||||
bool m_has_mip_maps;
|
bool m_has_mip_maps;
|
||||||
size_t m_width;
|
unsigned m_width;
|
||||||
size_t m_height;
|
unsigned m_height;
|
||||||
size_t m_depth;
|
unsigned m_depth;
|
||||||
};
|
};
|
||||||
|
@ -41,19 +41,19 @@ Dx9TextureLoader& Dx9TextureLoader::HasMipMaps(const bool hasMipMaps)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dx9TextureLoader& Dx9TextureLoader::Width(const size_t width)
|
Dx9TextureLoader& Dx9TextureLoader::Width(const unsigned width)
|
||||||
{
|
{
|
||||||
m_width = width;
|
m_width = width;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dx9TextureLoader& Dx9TextureLoader::Height(const size_t height)
|
Dx9TextureLoader& Dx9TextureLoader::Height(const unsigned height)
|
||||||
{
|
{
|
||||||
m_height = height;
|
m_height = height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dx9TextureLoader& Dx9TextureLoader::Depth(const size_t depth)
|
Dx9TextureLoader& Dx9TextureLoader::Depth(const unsigned depth)
|
||||||
{
|
{
|
||||||
m_depth = depth;
|
m_depth = depth;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
#include "Image/D3DFormat.h"
|
#include "Image/D3DFormat.h"
|
||||||
#include "Image/Texture.h"
|
#include "Image/Texture.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
#include "Utils/MemoryManager.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
class Dx9TextureLoader
|
class Dx9TextureLoader
|
||||||
{
|
{
|
||||||
@ -16,19 +13,19 @@ public:
|
|||||||
Dx9TextureLoader& Format(oat::D3DFORMAT format);
|
Dx9TextureLoader& Format(oat::D3DFORMAT format);
|
||||||
Dx9TextureLoader& Type(TextureType textureType);
|
Dx9TextureLoader& Type(TextureType textureType);
|
||||||
Dx9TextureLoader& HasMipMaps(bool hasMipMaps);
|
Dx9TextureLoader& HasMipMaps(bool hasMipMaps);
|
||||||
Dx9TextureLoader& Width(size_t width);
|
Dx9TextureLoader& Width(unsigned width);
|
||||||
Dx9TextureLoader& Height(size_t height);
|
Dx9TextureLoader& Height(unsigned height);
|
||||||
Dx9TextureLoader& Depth(size_t depth);
|
Dx9TextureLoader& Depth(unsigned depth);
|
||||||
|
|
||||||
std::unique_ptr<Texture> LoadTexture(const void* data);
|
std::unique_ptr<Texture> LoadTexture(const void* data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_NODISCARD const ImageFormat* GetFormatForDx9Format() const;
|
[[nodiscard]] const ImageFormat* GetFormatForDx9Format() const;
|
||||||
|
|
||||||
oat::D3DFORMAT m_format;
|
oat::D3DFORMAT m_format;
|
||||||
TextureType m_type;
|
TextureType m_type;
|
||||||
bool m_has_mip_maps;
|
bool m_has_mip_maps;
|
||||||
size_t m_width;
|
unsigned m_width;
|
||||||
size_t m_height;
|
unsigned m_height;
|
||||||
size_t m_depth;
|
unsigned m_depth;
|
||||||
};
|
};
|
||||||
|
@ -48,13 +48,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual ~ImageFormat() = default;
|
virtual ~ImageFormat() = default;
|
||||||
|
|
||||||
ImageFormatId GetId() const;
|
[[nodiscard]] ImageFormatId GetId() const;
|
||||||
oat::D3DFORMAT GetD3DFormat() const;
|
[[nodiscard]] oat::D3DFORMAT GetD3DFormat() const;
|
||||||
oat::DXGI_FORMAT GetDxgiFormat() const;
|
[[nodiscard]] oat::DXGI_FORMAT GetDxgiFormat() const;
|
||||||
|
|
||||||
virtual ImageFormatType GetType() const = 0;
|
[[nodiscard]] virtual ImageFormatType GetType() const = 0;
|
||||||
virtual size_t GetPitch(unsigned mipLevel, unsigned width) const = 0;
|
[[nodiscard]] virtual size_t GetPitch(unsigned mipLevel, unsigned width) const = 0;
|
||||||
virtual size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const = 0;
|
[[nodiscard]] virtual size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const = 0;
|
||||||
|
|
||||||
static const ImageFormatUnsigned FORMAT_R8_G8_B8;
|
static const ImageFormatUnsigned FORMAT_R8_G8_B8;
|
||||||
static const ImageFormatUnsigned FORMAT_B8_G8_R8_X8;
|
static const ImageFormatUnsigned FORMAT_B8_G8_R8_X8;
|
||||||
@ -98,14 +98,14 @@ public:
|
|||||||
unsigned aOffset,
|
unsigned aOffset,
|
||||||
unsigned aSize);
|
unsigned aSize);
|
||||||
|
|
||||||
ImageFormatType GetType() const override;
|
[[nodiscard]] ImageFormatType GetType() const override;
|
||||||
size_t GetPitch(unsigned mipLevel, unsigned width) const override;
|
[[nodiscard]] size_t GetPitch(unsigned mipLevel, unsigned width) const override;
|
||||||
size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override;
|
[[nodiscard]] size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override;
|
||||||
|
|
||||||
bool HasR() const;
|
[[nodiscard]] bool HasR() const;
|
||||||
bool HasG() const;
|
[[nodiscard]] bool HasG() const;
|
||||||
bool HasB() const;
|
[[nodiscard]] bool HasB() const;
|
||||||
bool HasA() const;
|
[[nodiscard]] bool HasA() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageFormatBlockCompressed final : public ImageFormat
|
class ImageFormatBlockCompressed final : public ImageFormat
|
||||||
@ -116,7 +116,7 @@ public:
|
|||||||
|
|
||||||
ImageFormatBlockCompressed(ImageFormatId id, oat::D3DFORMAT d3dFormat, oat::DXGI_FORMAT dxgiFormat, unsigned blockSize, unsigned bitsPerBlock);
|
ImageFormatBlockCompressed(ImageFormatId id, oat::D3DFORMAT d3dFormat, oat::DXGI_FORMAT dxgiFormat, unsigned blockSize, unsigned bitsPerBlock);
|
||||||
|
|
||||||
ImageFormatType GetType() const override;
|
[[nodiscard]] ImageFormatType GetType() const override;
|
||||||
size_t GetPitch(unsigned mipLevel, unsigned width) const override;
|
[[nodiscard]] size_t GetPitch(unsigned mipLevel, unsigned width) const override;
|
||||||
size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override;
|
[[nodiscard]] size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override;
|
||||||
};
|
};
|
||||||
|
@ -110,20 +110,20 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture)
|
|||||||
currentFileSize += mipLevelSize;
|
currentFileSize += mipLevelSize;
|
||||||
|
|
||||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(IwiHeader::fileSizeForPicmip)>))
|
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(IwiHeader::fileSizeForPicmip)>))
|
||||||
header.fileSizeForPicmip[currentMipLevel] = currentFileSize;
|
header.fileSizeForPicmip[currentMipLevel] = static_cast<uint32_t>(currentFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader2D(header, *texture2D);
|
FillHeader3D(header, *texture3D);
|
||||||
}
|
}
|
||||||
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
||||||
{
|
{
|
||||||
FillHeaderCube(header, *textureCube);
|
FillHeaderCube(header, *textureCube);
|
||||||
}
|
}
|
||||||
else if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
else if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader3D(header, *texture3D);
|
FillHeader2D(header, *texture2D);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -113,20 +113,20 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture)
|
|||||||
currentFileSize += mipLevelSize;
|
currentFileSize += mipLevelSize;
|
||||||
|
|
||||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(iwi27::IwiHeader::fileSizeForPicmip)>))
|
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(iwi27::IwiHeader::fileSizeForPicmip)>))
|
||||||
header.fileSizeForPicmip[currentMipLevel] = currentFileSize;
|
header.fileSizeForPicmip[currentMipLevel] = static_cast<uint32_t>(currentFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader2D(header, *texture2D);
|
FillHeader3D(header, *texture3D);
|
||||||
}
|
}
|
||||||
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
||||||
{
|
{
|
||||||
FillHeaderCube(header, *textureCube);
|
FillHeaderCube(header, *textureCube);
|
||||||
}
|
}
|
||||||
else if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
else if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader3D(header, *texture3D);
|
FillHeader2D(header, *texture2D);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -105,20 +105,20 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture)
|
|||||||
currentFileSize += mipLevelSize;
|
currentFileSize += mipLevelSize;
|
||||||
|
|
||||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(IwiHeader::fileSizeForPicmip)>))
|
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(IwiHeader::fileSizeForPicmip)>))
|
||||||
header.fileSizeForPicmip[currentMipLevel] = currentFileSize;
|
header.fileSizeForPicmip[currentMipLevel] = static_cast<uint32_t>(currentFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader2D(header, *texture2D);
|
FillHeader3D(header, *texture3D);
|
||||||
}
|
}
|
||||||
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
||||||
{
|
{
|
||||||
FillHeaderCube(header, *textureCube);
|
FillHeaderCube(header, *textureCube);
|
||||||
}
|
}
|
||||||
else if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
else if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader3D(header, *texture3D);
|
FillHeader2D(header, *texture2D);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -105,20 +105,20 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture)
|
|||||||
currentFileSize += mipLevelSize;
|
currentFileSize += mipLevelSize;
|
||||||
|
|
||||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(IwiHeader::fileSizeForPicmip)>))
|
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(IwiHeader::fileSizeForPicmip)>))
|
||||||
header.fileSizeForPicmip[currentMipLevel] = currentFileSize;
|
header.fileSizeForPicmip[currentMipLevel] = static_cast<uint32_t>(currentFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader2D(header, *texture2D);
|
FillHeader3D(header, *texture3D);
|
||||||
}
|
}
|
||||||
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
else if (const auto* textureCube = dynamic_cast<const TextureCube*>(texture))
|
||||||
{
|
{
|
||||||
FillHeaderCube(header, *textureCube);
|
FillHeaderCube(header, *textureCube);
|
||||||
}
|
}
|
||||||
else if (const auto* texture3D = dynamic_cast<const Texture3D*>(texture))
|
else if (const auto* texture2D = dynamic_cast<const Texture2D*>(texture))
|
||||||
{
|
{
|
||||||
FillHeader3D(header, *texture3D);
|
FillHeader2D(header, *texture2D);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ function ObjLoading:project()
|
|||||||
useSourceTemplating("ObjLoading")
|
useSourceTemplating("ObjLoading")
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
Crypto:include(includes)
|
Cryptography:include(includes)
|
||||||
Utils:include(includes)
|
Utils:include(includes)
|
||||||
minilzo:include(includes)
|
minilzo:include(includes)
|
||||||
minizip:include(includes)
|
minizip:include(includes)
|
||||||
|
@ -65,8 +65,10 @@ std::unique_ptr<XAssetInfoGeneric> GenericAssetRegistration::CreateXAssetInfo()
|
|||||||
AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup)
|
AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup)
|
||||||
: ZoneAssetCreationStateContainer(zone),
|
: ZoneAssetCreationStateContainer(zone),
|
||||||
m_zone(zone),
|
m_zone(zone),
|
||||||
|
m_forced_asset_pools(ZoneAssetPools::CreateForGame(zone.m_game->GetId(), &zone, zone.m_priority)),
|
||||||
m_creators(creators),
|
m_creators(creators),
|
||||||
m_ignored_asset_lookup(ignoredAssetLookup)
|
m_ignored_asset_lookup(ignoredAssetLookup),
|
||||||
|
m_forced_load_depth(0u)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +80,14 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio
|
|||||||
const auto assetType = xAssetInfo->m_type;
|
const auto assetType = xAssetInfo->m_type;
|
||||||
const auto* pAssetName = xAssetInfo->m_name.c_str();
|
const auto* pAssetName = xAssetInfo->m_name.c_str();
|
||||||
|
|
||||||
auto* addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
XAssetInfoGeneric* addedAsset;
|
||||||
|
if (m_forced_load_depth > 0)
|
||||||
|
addedAsset = m_forced_asset_pools->AddAsset(std::move(xAssetInfo));
|
||||||
|
else
|
||||||
|
addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
||||||
|
|
||||||
if (addedAsset == nullptr)
|
if (addedAsset == nullptr)
|
||||||
std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
|
std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
|
||||||
|
|
||||||
return addedAsset;
|
return addedAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +108,16 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
|||||||
if (alreadyLoadedAsset)
|
if (alreadyLoadedAsset)
|
||||||
return alreadyLoadedAsset;
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
if (m_forced_load_depth > 0)
|
||||||
|
{
|
||||||
|
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset)
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
// If we are already force loading an asset we should not load its dependencies
|
||||||
|
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||||
|
}
|
||||||
|
|
||||||
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||||
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||||
|
|
||||||
@ -121,9 +137,9 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName)
|
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||||
{
|
{
|
||||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
const auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
if (alreadyLoadedAsset)
|
if (alreadyLoadedAsset)
|
||||||
return IndirectAssetReference(assetType, assetName);
|
return IndirectAssetReference(assetType, assetName);
|
||||||
|
|
||||||
@ -137,3 +153,44 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(a
|
|||||||
}
|
}
|
||||||
return IndirectAssetReference(assetType, assetName);
|
return IndirectAssetReference(assetType, assetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||||
|
{
|
||||||
|
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
auto result = AssetCreationResult::NoAction();
|
||||||
|
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||||
|
{
|
||||||
|
// Load default asset to zone
|
||||||
|
if (!LoadDefaultAssetDependency(assetType, std::format(",{}", assetName)))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
++m_forced_load_depth;
|
||||||
|
|
||||||
|
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||||
|
|
||||||
|
assert(m_forced_load_depth > 0);
|
||||||
|
m_forced_load_depth = std::min(m_forced_load_depth - 1u, 0u);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||||
|
|
||||||
|
if (result.HasTakenAction())
|
||||||
|
{
|
||||||
|
if (!result.HasFailed())
|
||||||
|
return result.GetAssetInfo();
|
||||||
|
|
||||||
|
std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
@ -65,12 +65,31 @@ public:
|
|||||||
|
|
||||||
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
|
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Loads an asset dependency like \c LoadDependency but guarantees that the returned asset is not a reference.
|
||||||
|
* If normally a reference would be created, the actual asset is loaded but a reference is added to the zone.
|
||||||
|
* \tparam AssetType The type of the asset
|
||||||
|
* \param assetName The name of the asset
|
||||||
|
* \return XAssetInfo of the asset that is guaranteed to not be a reference or \c nullptr
|
||||||
|
*/
|
||||||
|
template<typename AssetType> XAssetInfo<typename AssetType::Type>* ForceLoadDependency(const std::string& assetName)
|
||||||
|
{
|
||||||
|
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||||
|
|
||||||
|
return static_cast<XAssetInfo<typename AssetType::Type>*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName));
|
||||||
|
}
|
||||||
|
|
||||||
|
XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
|
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
|
||||||
|
|
||||||
Zone& m_zone;
|
Zone& m_zone;
|
||||||
|
std::unique_ptr<ZoneAssetPools> m_forced_asset_pools;
|
||||||
const AssetCreatorCollection* m_creators;
|
const AssetCreatorCollection* m_creators;
|
||||||
const IgnoredAssetLookup* m_ignored_asset_lookup;
|
const IgnoredAssetLookup* m_ignored_asset_lookup;
|
||||||
|
|
||||||
|
unsigned m_forced_load_depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "AssetCreatorCollection.h"
|
#include "AssetCreatorCollection.h"
|
||||||
|
@ -81,7 +81,7 @@ namespace
|
|||||||
const auto mipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
|
const auto mipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
|
||||||
const auto faceCount = texture->GetFaceCount();
|
const auto faceCount = texture->GetFaceCount();
|
||||||
|
|
||||||
size_t dataSize = 0;
|
auto dataSize = 0uz;
|
||||||
for (auto mipLevel = 0; mipLevel < mipCount; mipLevel++)
|
for (auto mipLevel = 0; mipLevel < mipCount; mipLevel++)
|
||||||
dataSize += texture->GetSizeOfMipLevel(mipLevel) * faceCount;
|
dataSize += texture->GetSizeOfMipLevel(mipLevel) * faceCount;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ namespace
|
|||||||
loadDef->dimensions[1] = image->height;
|
loadDef->dimensions[1] = image->height;
|
||||||
loadDef->dimensions[2] = image->depth;
|
loadDef->dimensions[2] = image->depth;
|
||||||
loadDef->format = static_cast<int>(texture->GetFormat()->GetD3DFormat());
|
loadDef->format = static_cast<int>(texture->GetFormat()->GetD3DFormat());
|
||||||
loadDef->resourceSize = dataSize;
|
loadDef->resourceSize = static_cast<unsigned>(dataSize);
|
||||||
|
|
||||||
char* currentDataBuffer = loadDef->data;
|
char* currentDataBuffer = loadDef->data;
|
||||||
for (auto mipLevel = 0; mipLevel < mipCount; mipLevel++)
|
for (auto mipLevel = 0; mipLevel < mipCount; mipLevel++)
|
||||||
|
@ -21,7 +21,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetXAnim>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetXAnim>>(memory));
|
||||||
@ -85,7 +85,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||||
@ -96,7 +96,6 @@ namespace
|
|||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||||
|
@ -83,7 +83,7 @@ namespace
|
|||||||
menu::MenuAssetZoneState& zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState& conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration) const
|
||||||
{
|
{
|
||||||
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||||
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||||
@ -125,12 +125,12 @@ namespace
|
|||||||
menu::MenuAssetZoneState& zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState& conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration) const
|
||||||
{
|
{
|
||||||
const auto menuCount = parsingResult.m_menus.size();
|
const auto menuCount = parsingResult.m_menus.size();
|
||||||
const auto functionCount = parsingResult.m_functions.size();
|
const auto functionCount = parsingResult.m_functions.size();
|
||||||
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||||
auto totalItemCount = 0u;
|
auto totalItemCount = 0uz;
|
||||||
for (const auto& menu : parsingResult.m_menus)
|
for (const auto& menu : parsingResult.m_menus)
|
||||||
totalItemCount += menu->m_items.size();
|
totalItemCount += menu->m_items.size();
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus)
|
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus) const
|
||||||
{
|
{
|
||||||
menuList.menuCount = static_cast<int>(menus.size());
|
menuList.menuCount = static_cast<int>(menus.size());
|
||||||
|
|
||||||
@ -196,7 +196,8 @@ namespace
|
|||||||
menuList.menus = nullptr;
|
menuList.menus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
std::unique_ptr<menu::ParsingResult>
|
||||||
|
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
|
||||||
{
|
{
|
||||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ MenuConversionZoneState::MenuConversionZoneState()
|
|||||||
|
|
||||||
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
||||||
{
|
{
|
||||||
auto* memory = inject.m_zone.GetMemory();
|
auto& memory = inject.m_zone.Memory();
|
||||||
|
|
||||||
m_zone = &inject.m_zone;
|
m_zone = &inject.m_zone;
|
||||||
m_supporting_data = memory->Alloc<ExpressionSupportingData>();
|
m_supporting_data = memory.Alloc<ExpressionSupportingData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
||||||
@ -43,10 +43,10 @@ size_t MenuConversionZoneState::AddStaticDvar(const std::string& dvarName)
|
|||||||
if (foundDvar != m_dvars_by_name.end())
|
if (foundDvar != m_dvars_by_name.end())
|
||||||
return foundDvar->second;
|
return foundDvar->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
auto* staticDvar = memory->Alloc<StaticDvar>();
|
auto* staticDvar = memory.Alloc<StaticDvar>();
|
||||||
|
|
||||||
staticDvar->dvarName = memory->Dup(dvarName.c_str());
|
staticDvar->dvarName = memory.Dup(dvarName.c_str());
|
||||||
staticDvar->dvar = nullptr;
|
staticDvar->dvar = nullptr;
|
||||||
|
|
||||||
const auto staticDvarIndex = m_static_dvars.size();
|
const auto staticDvarIndex = m_static_dvars.size();
|
||||||
@ -63,8 +63,8 @@ const char* MenuConversionZoneState::AddString(const std::string& str)
|
|||||||
if (foundString != m_strings_by_value.end())
|
if (foundString != m_strings_by_value.end())
|
||||||
return foundString->second;
|
return foundString->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
const auto* strDuped = memory->Dup(str.c_str());
|
const auto* strDuped = memory.Dup(str.c_str());
|
||||||
|
|
||||||
m_strings.push_back(strDuped);
|
m_strings.push_back(strDuped);
|
||||||
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
||||||
@ -79,24 +79,24 @@ void MenuConversionZoneState::AddLoadedFile(std::string loadedFileName, std::vec
|
|||||||
|
|
||||||
void MenuConversionZoneState::FinalizeSupportingData() const
|
void MenuConversionZoneState::FinalizeSupportingData() const
|
||||||
{
|
{
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
|
|
||||||
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
||||||
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
||||||
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
||||||
|
|
||||||
if (m_supporting_data->uifunctions.functions)
|
if (m_supporting_data->uifunctions.functions)
|
||||||
memory->Free(m_supporting_data->uifunctions.functions);
|
memory.Free(m_supporting_data->uifunctions.functions);
|
||||||
|
|
||||||
if (m_supporting_data->staticDvarList.staticDvars)
|
if (m_supporting_data->staticDvarList.staticDvars)
|
||||||
memory->Free(m_supporting_data->staticDvarList.staticDvars);
|
memory.Free(m_supporting_data->staticDvarList.staticDvars);
|
||||||
|
|
||||||
if (m_supporting_data->uiStrings.strings)
|
if (m_supporting_data->uiStrings.strings)
|
||||||
memory->Free(m_supporting_data->uiStrings.strings);
|
memory.Free(m_supporting_data->uiStrings.strings);
|
||||||
|
|
||||||
if (!m_functions.empty())
|
if (!m_functions.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uifunctions.functions = memory->Alloc<Statement_s*>(m_functions.size());
|
m_supporting_data->uifunctions.functions = memory.Alloc<Statement_s*>(m_functions.size());
|
||||||
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -104,7 +104,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_static_dvars.empty())
|
if (!m_static_dvars.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->staticDvarList.staticDvars = memory->Alloc<StaticDvar*>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.staticDvars = memory.Alloc<StaticDvar*>(m_static_dvars.size());
|
||||||
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -112,7 +112,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_strings.empty())
|
if (!m_strings.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uiStrings.strings = memory->Alloc<const char*>(m_strings.size());
|
m_supporting_data->uiStrings.strings = memory.Alloc<const char*>(m_strings.size());
|
||||||
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -34,7 +34,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
||||||
@ -118,7 +118,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddAssetCreator(std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone));
|
collection.AddAssetCreator(std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone));
|
collection.AddAssetCreator(std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone));
|
||||||
@ -135,8 +135,7 @@ namespace
|
|||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||||
collection.AddAssetCreator(CreateSoundCurveLoader(memory, searchPath));
|
collection.AddAssetCreator(CreateSoundCurveLoader(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapSp>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapMp>(memory));
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldMp>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldMp>(memory));
|
||||||
|
@ -43,7 +43,7 @@ namespace
|
|||||||
zs.zfree = Z_NULL;
|
zs.zfree = Z_NULL;
|
||||||
zs.opaque = Z_NULL;
|
zs.opaque = Z_NULL;
|
||||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||||
zs.avail_out = compressionBufferSize;
|
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||||
|
|
||||||
|
@ -38,38 +38,38 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StructuredDataType ConvertType(CommonStructuredDataType inputType)
|
static StructuredDataType ConvertType(const CommonStructuredDataType inputType)
|
||||||
{
|
{
|
||||||
switch (inputType.m_category)
|
switch (inputType.m_category)
|
||||||
{
|
{
|
||||||
case CommonStructuredDataTypeCategory::INT:
|
case CommonStructuredDataTypeCategory::INT:
|
||||||
return {DATA_INT, {0}};
|
return {.type = DATA_INT, .u = {}};
|
||||||
case CommonStructuredDataTypeCategory::BYTE:
|
case CommonStructuredDataTypeCategory::BYTE:
|
||||||
return {DATA_BYTE, {0}};
|
return {.type = DATA_BYTE, .u = {}};
|
||||||
case CommonStructuredDataTypeCategory::BOOL:
|
case CommonStructuredDataTypeCategory::BOOL:
|
||||||
return {DATA_BOOL, {0}};
|
return {.type = DATA_BOOL, .u = {}};
|
||||||
case CommonStructuredDataTypeCategory::FLOAT:
|
case CommonStructuredDataTypeCategory::FLOAT:
|
||||||
return {DATA_FLOAT, {0}};
|
return {.type = DATA_FLOAT, .u = {}};
|
||||||
case CommonStructuredDataTypeCategory::SHORT:
|
case CommonStructuredDataTypeCategory::SHORT:
|
||||||
return {DATA_SHORT, {0}};
|
return {.type = DATA_SHORT, .u = {}};
|
||||||
case CommonStructuredDataTypeCategory::STRING:
|
case CommonStructuredDataTypeCategory::STRING:
|
||||||
return {DATA_STRING, {inputType.m_info.string_length}};
|
return {.type = DATA_STRING, .u = {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||||
case CommonStructuredDataTypeCategory::ENUM:
|
case CommonStructuredDataTypeCategory::ENUM:
|
||||||
return {DATA_ENUM, {inputType.m_info.type_index}};
|
return {.type = DATA_ENUM, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::STRUCT:
|
case CommonStructuredDataTypeCategory::STRUCT:
|
||||||
return {DATA_STRUCT, {inputType.m_info.type_index}};
|
return {.type = DATA_STRUCT, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
||||||
return {DATA_INDEXED_ARRAY, {inputType.m_info.type_index}};
|
return {.type = DATA_INDEXED_ARRAY, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||||
return {DATA_ENUM_ARRAY, {inputType.m_info.type_index}};
|
return {.type = DATA_ENUM_ARRAY, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
return {DATA_INT, {0}};
|
return {.type = DATA_INT, .u = {0}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertEnum(CommonStructuredDataEnum& inputEnum, StructuredDataEnum& outputEnum)
|
void ConvertEnum(CommonStructuredDataEnum& inputEnum, StructuredDataEnum& outputEnum) const
|
||||||
{
|
{
|
||||||
outputEnum.entryCount = static_cast<int>(inputEnum.m_entries.size());
|
outputEnum.entryCount = static_cast<int>(inputEnum.m_entries.size());
|
||||||
if (inputEnum.m_reserved_entry_count <= 0)
|
if (inputEnum.m_reserved_entry_count <= 0)
|
||||||
@ -94,10 +94,10 @@ namespace
|
|||||||
outputEnum.entries = nullptr;
|
outputEnum.entries = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertStruct(CommonStructuredDataStruct& inputStruct, StructuredDataStruct& outputStruct)
|
void ConvertStruct(CommonStructuredDataStruct& inputStruct, StructuredDataStruct& outputStruct) const
|
||||||
{
|
{
|
||||||
outputStruct.size = static_cast<int>(inputStruct.m_size_in_byte);
|
outputStruct.size = static_cast<int>(inputStruct.m_size_in_byte);
|
||||||
outputStruct.bitOffset = inputStruct.m_bit_offset;
|
outputStruct.bitOffset = static_cast<unsigned>(inputStruct.m_bit_offset);
|
||||||
|
|
||||||
outputStruct.propertyCount = static_cast<int>(inputStruct.m_properties.size());
|
outputStruct.propertyCount = static_cast<int>(inputStruct.m_properties.size());
|
||||||
inputStruct.SortPropertiesByName();
|
inputStruct.SortPropertiesByName();
|
||||||
@ -115,34 +115,34 @@ namespace
|
|||||||
if (outputProperty.type.type != DATA_BOOL)
|
if (outputProperty.type.type != DATA_BOOL)
|
||||||
{
|
{
|
||||||
assert(inputProperty.m_offset_in_bits % 8 == 0);
|
assert(inputProperty.m_offset_in_bits % 8 == 0);
|
||||||
outputProperty.offset = inputProperty.m_offset_in_bits / 8;
|
outputProperty.offset = static_cast<unsigned>(inputProperty.m_offset_in_bits / 8uz);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
outputProperty.offset = inputProperty.m_offset_in_bits;
|
outputProperty.offset = static_cast<unsigned>(inputProperty.m_offset_in_bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
outputStruct.properties = nullptr;
|
outputStruct.properties = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertIndexedArray(const CommonStructuredDataIndexedArray& inputIndexedArray, StructuredDataIndexedArray& outputIndexedArray)
|
static void ConvertIndexedArray(const CommonStructuredDataIndexedArray& inputIndexedArray, StructuredDataIndexedArray& outputIndexedArray)
|
||||||
{
|
{
|
||||||
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
||||||
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
||||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8u) / 8u;
|
outputIndexedArray.elementSize = static_cast<unsigned>(utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
||||||
{
|
{
|
||||||
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
||||||
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
||||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8u) / 8u;
|
outputEnumedArray.elementSize = static_cast<unsigned>(utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
||||||
{
|
{
|
||||||
outputDef.version = inputDef.m_version;
|
outputDef.version = inputDef.m_version;
|
||||||
outputDef.formatChecksum = inputDef.m_checksum;
|
outputDef.formatChecksum = static_cast<unsigned>(inputDef.m_checksum);
|
||||||
|
|
||||||
outputDef.enumCount = static_cast<int>(inputDef.m_enums.size());
|
outputDef.enumCount = static_cast<int>(inputDef.m_enums.size());
|
||||||
if (!inputDef.m_enums.empty())
|
if (!inputDef.m_enums.empty())
|
||||||
@ -185,7 +185,7 @@ namespace
|
|||||||
outputDef.enumedArrays = nullptr;
|
outputDef.enumedArrays = nullptr;
|
||||||
|
|
||||||
outputDef.rootType = ConvertType(inputDef.m_root_type);
|
outputDef.rootType = ConvertType(inputDef.m_root_type);
|
||||||
outputDef.size = inputDef.m_size_in_byte;
|
outputDef.size = static_cast<unsigned>(inputDef.m_size_in_byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
StructuredDataDefSet* ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& commonDefs)
|
StructuredDataDefSet* ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& commonDefs)
|
||||||
@ -193,7 +193,7 @@ namespace
|
|||||||
auto* set = m_memory.Alloc<StructuredDataDefSet>();
|
auto* set = m_memory.Alloc<StructuredDataDefSet>();
|
||||||
set->name = m_memory.Dup(assetName.c_str());
|
set->name = m_memory.Dup(assetName.c_str());
|
||||||
|
|
||||||
set->defCount = commonDefs.size();
|
set->defCount = static_cast<unsigned>(commonDefs.size());
|
||||||
set->defs = m_memory.Alloc<StructuredDataDef>(commonDefs.size());
|
set->defs = m_memory.Alloc<StructuredDataDef>(commonDefs.size());
|
||||||
|
|
||||||
for (auto defIndex = 0u; defIndex < commonDefs.size(); defIndex++)
|
for (auto defIndex = 0u; defIndex < commonDefs.size(); defIndex++)
|
||||||
|
@ -31,14 +31,14 @@ namespace
|
|||||||
class LoadedTechnique
|
class LoadedTechnique
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MaterialTechnique* m_technique;
|
|
||||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
|
||||||
|
|
||||||
LoadedTechnique(MaterialTechnique* technique, std::vector<XAssetInfoGeneric*> dependencies)
|
LoadedTechnique(MaterialTechnique* technique, std::vector<XAssetInfoGeneric*> dependencies)
|
||||||
: m_technique(technique),
|
: m_technique(technique),
|
||||||
m_dependencies(std::move(dependencies))
|
m_dependencies(std::move(dependencies))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaterialTechnique* m_technique;
|
||||||
|
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TechniqueZoneLoadingState final : public IZoneAssetCreationState
|
class TechniqueZoneLoadingState final : public IZoneAssetCreationState
|
||||||
@ -46,8 +46,7 @@ namespace
|
|||||||
public:
|
public:
|
||||||
typedef const float (*literal_t)[4];
|
typedef const float (*literal_t)[4];
|
||||||
|
|
||||||
public:
|
[[nodiscard]] const LoadedTechnique* FindLoadedTechnique(const std::string& techniqueName) const
|
||||||
_NODISCARD const LoadedTechnique* FindLoadedTechnique(const std::string& techniqueName) const
|
|
||||||
{
|
{
|
||||||
const auto loadedTechnique = m_loaded_techniques.find(techniqueName);
|
const auto loadedTechnique = m_loaded_techniques.find(techniqueName);
|
||||||
if (loadedTechnique != m_loaded_techniques.end())
|
if (loadedTechnique != m_loaded_techniques.end())
|
||||||
@ -86,8 +85,6 @@ namespace
|
|||||||
|
|
||||||
class ShaderInfoFromFileSystemCacheState final : public IZoneAssetCreationState
|
class ShaderInfoFromFileSystemCacheState final : public IZoneAssetCreationState
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, std::unique_ptr<d3d9::ShaderInfo>> m_cached_shader_info;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] const d3d9::ShaderInfo* LoadShaderInfoFromDisk(ISearchPath& searchPath, const std::string& fileName)
|
[[nodiscard]] const d3d9::ShaderInfo* LoadShaderInfoFromDisk(ISearchPath& searchPath, const std::string& fileName)
|
||||||
{
|
{
|
||||||
@ -108,9 +105,9 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto shaderData = std::make_unique<char[]>(shaderSize);
|
const auto shaderData = std::make_unique<char[]>(shaderSize);
|
||||||
file.m_stream->read(shaderData.get(), shaderSize);
|
file.m_stream->read(shaderData.get(), static_cast<std::streamsize>(shaderSize));
|
||||||
|
|
||||||
auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(reinterpret_cast<const uint32_t*>(shaderData.get()), shaderSize);
|
auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(shaderData.get(), shaderSize);
|
||||||
if (!shaderInfo)
|
if (!shaderInfo)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -118,6 +115,9 @@ namespace
|
|||||||
m_cached_shader_info.emplace(std::make_pair(fileName, std::move(shaderInfo)));
|
m_cached_shader_info.emplace(std::make_pair(fileName, std::move(shaderInfo)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<std::string, std::unique_ptr<d3d9::ShaderInfo>> m_cached_shader_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TechniqueCreator final : public techset::ITechniqueDefinitionAcceptor
|
class TechniqueCreator final : public techset::ITechniqueDefinitionAcceptor
|
||||||
@ -126,10 +126,13 @@ namespace
|
|||||||
class PassShaderArgument
|
class PassShaderArgument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MaterialShaderArgument m_arg;
|
explicit PassShaderArgument(const MaterialShaderArgument arg)
|
||||||
MaterialUpdateFrequency m_update_frequency;
|
: m_arg(arg),
|
||||||
|
m_update_frequency(GetUpdateFrequencyForArg(arg))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static MaterialUpdateFrequency GetUpdateFrequencyForArg(MaterialShaderArgument arg)
|
static MaterialUpdateFrequency GetUpdateFrequencyForArg(const MaterialShaderArgument arg)
|
||||||
{
|
{
|
||||||
switch (arg.type)
|
switch (arg.type)
|
||||||
{
|
{
|
||||||
@ -160,15 +163,22 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit PassShaderArgument(const MaterialShaderArgument arg)
|
MaterialShaderArgument m_arg;
|
||||||
: m_arg(arg),
|
MaterialUpdateFrequency m_update_frequency;
|
||||||
m_update_frequency(GetUpdateFrequencyForArg(arg))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pass
|
struct Pass
|
||||||
{
|
{
|
||||||
|
Pass()
|
||||||
|
: m_vertex_shader(nullptr),
|
||||||
|
m_vertex_shader_info(nullptr),
|
||||||
|
m_pixel_shader(nullptr),
|
||||||
|
m_pixel_shader_info(nullptr),
|
||||||
|
m_vertex_decl{},
|
||||||
|
m_vertex_decl_asset(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
XAssetInfo<MaterialVertexShader>* m_vertex_shader;
|
XAssetInfo<MaterialVertexShader>* m_vertex_shader;
|
||||||
const d3d9::ShaderInfo* m_vertex_shader_info;
|
const d3d9::ShaderInfo* m_vertex_shader_info;
|
||||||
std::unique_ptr<d3d9::ShaderInfo> m_vertex_shader_info_unq;
|
std::unique_ptr<d3d9::ShaderInfo> m_vertex_shader_info_unq;
|
||||||
@ -184,21 +194,8 @@ namespace
|
|||||||
MaterialVertexDeclaration m_vertex_decl;
|
MaterialVertexDeclaration m_vertex_decl;
|
||||||
XAssetInfo<MaterialVertexDeclaration>* m_vertex_decl_asset;
|
XAssetInfo<MaterialVertexDeclaration>* m_vertex_decl_asset;
|
||||||
std::vector<PassShaderArgument> m_arguments;
|
std::vector<PassShaderArgument> m_arguments;
|
||||||
|
|
||||||
Pass()
|
|
||||||
: m_vertex_shader(nullptr),
|
|
||||||
m_vertex_shader_info(nullptr),
|
|
||||||
m_pixel_shader(nullptr),
|
|
||||||
m_pixel_shader_info(nullptr),
|
|
||||||
m_vertex_decl{},
|
|
||||||
m_vertex_decl_asset(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Pass> m_passes;
|
|
||||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
|
||||||
|
|
||||||
TechniqueCreator(
|
TechniqueCreator(
|
||||||
const std::string& techniqueName, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, ITechsetCreator* techsetCreator)
|
const std::string& techniqueName, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, ITechsetCreator* techsetCreator)
|
||||||
: m_technique_name(techniqueName),
|
: m_technique_name(techniqueName),
|
||||||
@ -217,10 +214,11 @@ namespace
|
|||||||
m_passes.emplace_back();
|
m_passes.emplace_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
static unsigned RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
||||||
{
|
{
|
||||||
const auto valuesPerRegister =
|
const auto valuesPerRegister =
|
||||||
constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
|
constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
|
||||||
|
|
||||||
return utils::Align(constant.m_type_columns * constant.m_type_rows, valuesPerRegister) / valuesPerRegister;
|
return utils::Align(constant.m_type_columns * constant.m_type_rows, valuesPerRegister) / valuesPerRegister;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +241,7 @@ namespace
|
|||||||
if (shaderType == techset::ShaderSelector::VERTEX_SHADER && isSamplerArgument)
|
if (shaderType == techset::ShaderSelector::VERTEX_SHADER && isSamplerArgument)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MaterialShaderArgument argument{};
|
MaterialShaderArgument argument;
|
||||||
argument.dest = static_cast<uint16_t>(shaderArgument.m_register_index + registerOffset);
|
argument.dest = static_cast<uint16_t>(shaderArgument.m_register_index + registerOffset);
|
||||||
|
|
||||||
unsigned arrayCount;
|
unsigned arrayCount;
|
||||||
@ -258,7 +256,7 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
argument.type = MTL_ARG_CODE_PIXEL_SAMPLER;
|
argument.type = MTL_ARG_CODE_PIXEL_SAMPLER;
|
||||||
argument.u.codeSampler = samplerSource->source + elementOffset;
|
argument.u.codeSampler = samplerSource->source + static_cast<unsigned>(elementOffset);
|
||||||
|
|
||||||
arrayCount = static_cast<unsigned>(samplerSource->arrayCount);
|
arrayCount = static_cast<unsigned>(samplerSource->arrayCount);
|
||||||
}
|
}
|
||||||
@ -304,13 +302,12 @@ namespace
|
|||||||
{
|
{
|
||||||
if (!AutoCreateShaderArgument(techset::ShaderSelector::VERTEX_SHADER, argument, elementIndex, registerIndex))
|
if (!AutoCreateShaderArgument(techset::ShaderSelector::VERTEX_SHADER, argument, elementIndex, registerIndex))
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::string elementIndexStr;
|
||||||
ss << "Unassigned vertex shader \"" << pass.m_vertex_shader->m_name << "\" arg: " << argument.m_name;
|
|
||||||
|
|
||||||
if (argument.m_type_elements > 1)
|
if (argument.m_type_elements > 1)
|
||||||
ss << '[' << elementIndex << ']';
|
elementIndexStr = std::format("[{}]", elementIndex);
|
||||||
|
|
||||||
errorMessage = ss.str();
|
errorMessage =
|
||||||
|
std::format("Unassigned vertex shader \"{}\" arg: {}{}", pass.m_vertex_shader->m_name, argument.m_name, elementIndexStr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -572,11 +569,11 @@ namespace
|
|||||||
return foundSource;
|
return foundSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
static bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
||||||
const techset::ShaderArgument& argument,
|
const techset::ShaderArgument& argument,
|
||||||
size_t& constantIndex,
|
size_t& constantIndex,
|
||||||
size_t& registerOffset,
|
size_t& registerOffset,
|
||||||
std::string& errorMessage) const
|
std::string& errorMessage)
|
||||||
{
|
{
|
||||||
const auto matchingShaderConstant = std::ranges::find_if(shaderInfo.m_constants,
|
const auto matchingShaderConstant = std::ranges::find_if(shaderInfo.m_constants,
|
||||||
[argument](const d3d9::ShaderConstant& constant)
|
[argument](const d3d9::ShaderConstant& constant)
|
||||||
@ -854,14 +851,14 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader,
|
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader,
|
||||||
techset::ShaderArgument shaderArgument,
|
const techset::ShaderArgument shaderArgument,
|
||||||
techset::ShaderArgumentLiteralSource source,
|
const techset::ShaderArgumentLiteralSource source,
|
||||||
std::string& errorMessage) override
|
std::string& errorMessage) override
|
||||||
{
|
{
|
||||||
assert(!m_passes.empty());
|
assert(!m_passes.empty());
|
||||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||||
|
|
||||||
MaterialShaderArgument argument{};
|
MaterialShaderArgument argument;
|
||||||
const d3d9::ShaderInfo* shaderInfo;
|
const d3d9::ShaderInfo* shaderInfo;
|
||||||
|
|
||||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||||
@ -913,14 +910,14 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader,
|
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader,
|
||||||
techset::ShaderArgument shaderArgument,
|
const techset::ShaderArgument shaderArgument,
|
||||||
const techset::ShaderArgumentMaterialSource source,
|
const techset::ShaderArgumentMaterialSource source,
|
||||||
std::string& errorMessage) override
|
std::string& errorMessage) override
|
||||||
{
|
{
|
||||||
assert(!m_passes.empty());
|
assert(!m_passes.empty());
|
||||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||||
|
|
||||||
MaterialShaderArgument argument{};
|
MaterialShaderArgument argument;
|
||||||
const d3d9::ShaderInfo* shaderInfo;
|
const d3d9::ShaderInfo* shaderInfo;
|
||||||
|
|
||||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||||
@ -1016,6 +1013,8 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Pass> m_passes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string& m_technique_name;
|
const std::string& m_technique_name;
|
||||||
ISearchPath& m_search_path;
|
ISearchPath& m_search_path;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "JsonMaterialLoader.h"
|
#include "JsonMaterialLoader.h"
|
||||||
|
|
||||||
|
#include "Base64.h"
|
||||||
#include "Game/IW5/CommonIW5.h"
|
#include "Game/IW5/CommonIW5.h"
|
||||||
#include "Game/IW5/Material/JsonMaterial.h"
|
#include "Game/IW5/Material/JsonMaterial.h"
|
||||||
#include "Impl/Base64.h"
|
|
||||||
|
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -83,7 +83,7 @@ namespace
|
|||||||
menu::MenuAssetZoneState& zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState& conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration) const
|
||||||
{
|
{
|
||||||
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||||
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||||
@ -125,14 +125,14 @@ namespace
|
|||||||
menu::MenuAssetZoneState& zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState& conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration) const
|
||||||
{
|
{
|
||||||
const auto menuCount = parsingResult.m_menus.size();
|
const auto menuCount = parsingResult.m_menus.size();
|
||||||
const auto functionCount = parsingResult.m_functions.size();
|
const auto functionCount = parsingResult.m_functions.size();
|
||||||
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||||
auto totalItemCount = 0u;
|
auto totalItemCount = 0u;
|
||||||
for (const auto& menu : parsingResult.m_menus)
|
for (const auto& menu : parsingResult.m_menus)
|
||||||
totalItemCount += menu->m_items.size();
|
totalItemCount += static_cast<unsigned>(menu->m_items.size());
|
||||||
|
|
||||||
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
||||||
fileName,
|
fileName,
|
||||||
@ -152,7 +152,7 @@ namespace
|
|||||||
// Convert all menus and add them as assets
|
// Convert all menus and add them as assets
|
||||||
for (auto& commonMenu : parsingResult.m_menus)
|
for (auto& commonMenu : parsingResult.m_menus)
|
||||||
{
|
{
|
||||||
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
const auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
||||||
|
|
||||||
auto* menuAsset = m_memory.Alloc<menuDef_t>();
|
auto* menuAsset = m_memory.Alloc<menuDef_t>();
|
||||||
AssetRegistration<AssetMenu> menuRegistration(commonMenu->m_name, menuAsset);
|
AssetRegistration<AssetMenu> menuRegistration(commonMenu->m_name, menuAsset);
|
||||||
@ -182,7 +182,7 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus)
|
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus) const
|
||||||
{
|
{
|
||||||
menuList.menuCount = static_cast<int>(menus.size());
|
menuList.menuCount = static_cast<int>(menus.size());
|
||||||
|
|
||||||
@ -196,7 +196,8 @@ namespace
|
|||||||
menuList.menus = nullptr;
|
menuList.menus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
std::unique_ptr<menu::ParsingResult>
|
||||||
|
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
|
||||||
{
|
{
|
||||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path);
|
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path);
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ MenuConversionZoneState::MenuConversionZoneState()
|
|||||||
|
|
||||||
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
||||||
{
|
{
|
||||||
auto* memory = inject.m_zone.GetMemory();
|
auto& memory = inject.m_zone.Memory();
|
||||||
|
|
||||||
m_zone = &inject.m_zone;
|
m_zone = &inject.m_zone;
|
||||||
m_supporting_data = memory->Alloc<ExpressionSupportingData>();
|
m_supporting_data = memory.Alloc<ExpressionSupportingData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
||||||
@ -43,10 +43,10 @@ size_t MenuConversionZoneState::AddStaticDvar(const std::string& dvarName)
|
|||||||
if (foundDvar != m_dvars_by_name.end())
|
if (foundDvar != m_dvars_by_name.end())
|
||||||
return foundDvar->second;
|
return foundDvar->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
auto* staticDvar = memory->Alloc<StaticDvar>();
|
auto* staticDvar = memory.Alloc<StaticDvar>();
|
||||||
|
|
||||||
staticDvar->dvarName = memory->Dup(dvarName.c_str());
|
staticDvar->dvarName = memory.Dup(dvarName.c_str());
|
||||||
staticDvar->dvar = nullptr;
|
staticDvar->dvar = nullptr;
|
||||||
|
|
||||||
const auto staticDvarIndex = m_static_dvars.size();
|
const auto staticDvarIndex = m_static_dvars.size();
|
||||||
@ -63,8 +63,8 @@ const char* MenuConversionZoneState::AddString(const std::string& str)
|
|||||||
if (foundString != m_strings_by_value.end())
|
if (foundString != m_strings_by_value.end())
|
||||||
return foundString->second;
|
return foundString->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
const auto* strDuped = memory->Dup(str.c_str());
|
const auto* strDuped = memory.Dup(str.c_str());
|
||||||
|
|
||||||
m_strings.push_back(strDuped);
|
m_strings.push_back(strDuped);
|
||||||
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
||||||
@ -79,24 +79,24 @@ void MenuConversionZoneState::AddLoadedFile(std::string loadedFileName, std::vec
|
|||||||
|
|
||||||
void MenuConversionZoneState::FinalizeSupportingData() const
|
void MenuConversionZoneState::FinalizeSupportingData() const
|
||||||
{
|
{
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
|
|
||||||
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
||||||
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
||||||
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
||||||
|
|
||||||
if (m_supporting_data->uifunctions.functions)
|
if (m_supporting_data->uifunctions.functions)
|
||||||
memory->Free(m_supporting_data->uifunctions.functions);
|
memory.Free(m_supporting_data->uifunctions.functions);
|
||||||
|
|
||||||
if (m_supporting_data->staticDvarList.staticDvars)
|
if (m_supporting_data->staticDvarList.staticDvars)
|
||||||
memory->Free(m_supporting_data->staticDvarList.staticDvars);
|
memory.Free(m_supporting_data->staticDvarList.staticDvars);
|
||||||
|
|
||||||
if (m_supporting_data->uiStrings.strings)
|
if (m_supporting_data->uiStrings.strings)
|
||||||
memory->Free(m_supporting_data->uiStrings.strings);
|
memory.Free(m_supporting_data->uiStrings.strings);
|
||||||
|
|
||||||
if (!m_functions.empty())
|
if (!m_functions.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uifunctions.functions = memory->Alloc<Statement_s*>(m_functions.size());
|
m_supporting_data->uifunctions.functions = memory.Alloc<Statement_s*>(m_functions.size());
|
||||||
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -104,7 +104,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_static_dvars.empty())
|
if (!m_static_dvars.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->staticDvarList.staticDvars = memory->Alloc<StaticDvar*>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.staticDvars = memory.Alloc<StaticDvar*>(m_static_dvars.size());
|
||||||
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -112,7 +112,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_strings.empty())
|
if (!m_strings.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uiStrings.strings = memory->Alloc<const char*>(m_strings.size());
|
m_supporting_data->uiStrings.strings = memory.Alloc<const char*>(m_strings.size());
|
||||||
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -29,7 +29,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
||||||
@ -119,7 +119,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
||||||
|
@ -44,7 +44,7 @@ namespace
|
|||||||
zs.zfree = Z_NULL;
|
zs.zfree = Z_NULL;
|
||||||
zs.opaque = Z_NULL;
|
zs.opaque = Z_NULL;
|
||||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||||
zs.avail_out = compressionBufferSize;
|
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace
|
|||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + (scriptFile->compressedLen + scriptFile->bytecodeLen) > file.m_length)
|
if (offset + static_cast<size_t>(scriptFile->compressedLen + scriptFile->bytecodeLen) > static_cast<size_t>(file.m_length))
|
||||||
{
|
{
|
||||||
std::cerr << std::format("Error: Specified length in {} GSC BIN structure exceeds the actual file size\n", assetName);
|
std::cerr << std::format("Error: Specified length in {} GSC BIN structure exceeds the actual file size\n", assetName);
|
||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
|
@ -232,7 +232,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_weapon.weapCompleteDef.animOverrides = animOverrides;
|
m_weapon.weapCompleteDef.animOverrides = animOverrides;
|
||||||
m_weapon.weapCompleteDef.numAnimOverrides = valueArray.size();
|
m_weapon.weapCompleteDef.numAnimOverrides = static_cast<unsigned>(valueArray.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_weapon.weapCompleteDef.soundOverrides = soundOverrides;
|
m_weapon.weapCompleteDef.soundOverrides = soundOverrides;
|
||||||
m_weapon.weapCompleteDef.numSoundOverrides = valueArray.size();
|
m_weapon.weapCompleteDef.numSoundOverrides = static_cast<unsigned>(valueArray.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_weapon.weapCompleteDef.fxOverrides = fxOverrides;
|
m_weapon.weapCompleteDef.fxOverrides = fxOverrides;
|
||||||
m_weapon.weapCompleteDef.numFxOverrides = valueArray.size();
|
m_weapon.weapCompleteDef.numFxOverrides = static_cast<unsigned>(valueArray.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_weapon.weapCompleteDef.reloadOverrides = reloadOverrides;
|
m_weapon.weapCompleteDef.reloadOverrides = reloadOverrides;
|
||||||
m_weapon.weapCompleteDef.numReloadStateTimerOverrides = valueArray.size();
|
m_weapon.weapCompleteDef.numReloadStateTimerOverrides = static_cast<unsigned>(valueArray.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ namespace
|
|||||||
|
|
||||||
m_weapon.weapCompleteDef.notetrackOverrides = m_memory.Alloc<NoteTrackToSoundEntry>(overrideVector.size());
|
m_weapon.weapCompleteDef.notetrackOverrides = m_memory.Alloc<NoteTrackToSoundEntry>(overrideVector.size());
|
||||||
memcpy(m_weapon.weapCompleteDef.notetrackOverrides, overrideVector.data(), sizeof(NoteTrackToSoundEntry) * overrideVector.size());
|
memcpy(m_weapon.weapCompleteDef.notetrackOverrides, overrideVector.data(), sizeof(NoteTrackToSoundEntry) * overrideVector.size());
|
||||||
m_weapon.weapCompleteDef.numNotetrackOverrides = overrideVector.size();
|
m_weapon.weapCompleteDef.numNotetrackOverrides = static_cast<unsigned>(overrideVector.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -437,7 +437,7 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseAnim(const std::string& value, const char*& animName)
|
void ParseAnim(const std::string& value, const char*& animName) const
|
||||||
{
|
{
|
||||||
if (value == "none")
|
if (value == "none")
|
||||||
{
|
{
|
||||||
@ -449,7 +449,7 @@ namespace
|
|||||||
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetXAnim>(value));
|
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetXAnim>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseSoundAlias(const std::string& value, SndAliasCustom& soundAlias)
|
void ParseSoundAlias(const std::string& value, SndAliasCustom& soundAlias) const
|
||||||
{
|
{
|
||||||
if (value == "none")
|
if (value == "none")
|
||||||
{
|
{
|
||||||
@ -462,7 +462,7 @@ namespace
|
|||||||
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetSound>(value));
|
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetSound>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParseFxEffectDef(const std::string& value, FxEffectDef*& fx)
|
bool ParseFxEffectDef(const std::string& value, FxEffectDef*& fx) const
|
||||||
{
|
{
|
||||||
if (value == "none")
|
if (value == "none")
|
||||||
{
|
{
|
||||||
@ -542,7 +542,7 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseScriptString(const std::string& value, ScriptString& out)
|
void ParseScriptString(const std::string& value, ScriptString& out) const
|
||||||
{
|
{
|
||||||
out = m_zone_script_strings.AddOrGetScriptString(value);
|
out = m_zone_script_strings.AddOrGetScriptString(value);
|
||||||
m_registration.AddScriptString(out);
|
m_registration.AddScriptString(out);
|
||||||
@ -863,7 +863,7 @@ InfoStringLoaderWeapon::InfoStringLoaderWeapon(MemoryManager& memory, ISearchPat
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const
|
||||||
{
|
{
|
||||||
auto* weaponFullDef = m_memory.Alloc<WeaponFullDef>();
|
auto* weaponFullDef = m_memory.Alloc<WeaponFullDef>();
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace IW5
|
|||||||
public:
|
public:
|
||||||
InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||||
|
|
||||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MemoryManager& m_memory;
|
MemoryManager& m_memory;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user