mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-16 07:29:30 +00:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13abd4e546 | |||
| 92c6b115f3 | |||
| 2b87e0e53a | |||
| b04b4583f4 | |||
| 18d650a422 | |||
| 55e36db265 | |||
| 379878bd6d | |||
| ac39241ff9 | |||
| 5044df11b8 | |||
| b34da98139 | |||
| 17c7d5bdfc | |||
| 63110be15a | |||
| ce23dab0cd | |||
| dfb95484ea | |||
| 5be00dd712 | |||
| 23a2c38935 | |||
| edd937f4c7 | |||
| e1900cd342 | |||
| 313c7390ca | |||
| ab1a3a19e1 | |||
| 4fa1d8e2c5 | |||
| b060e25ee2 | |||
| 326b7086c9 | |||
| 485ecd1341 | |||
| 175002a9e4 | |||
| 93032262c3 | |||
| fd9d1af477 | |||
| 866455567d | |||
| 26b4f4ce4a | |||
| 5b1bcf6638 | |||
| 766e6439aa | |||
| bca0786cff | |||
| a1f32b5963 | |||
| 21c20c80e5 | |||
| 1692a5526c | |||
| f9d69fc91e | |||
| 7dbbdc480e | |||
| 9e593e83ee | |||
| b49428bafd | |||
| ae2c93fc32 | |||
| a1cadde802 | |||
| 69b06d94a2 | |||
| 514aefa371 | |||
| f07e180b53 | |||
| 13b7df3ae3 | |||
| ab2d8cdb0a | |||
| a7e36fc965 |
@@ -0,0 +1,48 @@
|
||||
---
|
||||
Language: Cpp
|
||||
Standard: Latest
|
||||
|
||||
# Long, hand-wrapped declarations (vtable typedefs, D3D signatures) are kept as
|
||||
# written rather than reflowed to a column.
|
||||
ColumnLimit: 0
|
||||
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
AccessModifierOffset: -4
|
||||
NamespaceIndentation: All
|
||||
IndentCaseLabels: true
|
||||
PointerAlignment: Left
|
||||
MaxEmptyLinesToKeep: 2
|
||||
Cpp11BracedListStyle: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
FixNamespaceComments: false
|
||||
|
||||
# Include order is load-bearing in the Windows headers; never reorder.
|
||||
SortIncludes: Never
|
||||
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
AfterControlStatement: Never
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterStruct: false
|
||||
AfterEnum: false
|
||||
AfterUnion: false
|
||||
AfterNamespace: false
|
||||
AfterExternBlock: false
|
||||
BeforeElse: true
|
||||
BeforeCatch: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
@@ -0,0 +1,38 @@
|
||||
# Build output and artifacts
|
||||
build/
|
||||
bin/
|
||||
Debug/
|
||||
Release/
|
||||
MinSizeRel/
|
||||
RelWithDebInfo/
|
||||
win32/
|
||||
install/
|
||||
|
||||
# CMake generated directories
|
||||
*.dir/
|
||||
CMakeFiles/
|
||||
_deps/
|
||||
|
||||
# vcpkg vendored dependencies
|
||||
vcpkg_installed/
|
||||
|
||||
# Visual Studio files
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
*.vcxproj.user
|
||||
*.sln
|
||||
*.slnx
|
||||
*.sdf
|
||||
*.suo
|
||||
*.user
|
||||
*.aps
|
||||
|
||||
# CMake cache/generated
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
ALL_BUILD*
|
||||
ZERO_CHECK*
|
||||
INSTALL*
|
||||
|
||||
# Version resource (generated)
|
||||
version.rc
|
||||
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="uMod" buildProperties="" description="" id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207" name="Debug" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207.1198697062" name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.msvc.toolchain.dll.debug.819029430" name="org.eclipse.cdt.msvc.toolchain.dll.debug" superClass="org.eclipse.cdt.msvc.toolchain.dll.debug">
|
||||
<targetPlatform id="org.eclipse.cdt.msvc.targetPlatform.dll.debug.988168225" superClass="org.eclipse.cdt.msvc.targetPlatform.dll.debug"/>
|
||||
<builder buildPath="${workspace_loc:/uMod/Debug}" id="org.eclipse.cdt.msvc.builder.611532519" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="CDT Internal Builder" superClass="org.eclipse.cdt.msvc.builder"/>
|
||||
<tool id="org.eclipse.cdt.msvc.cl.dll.debug.971252395" name="C/C++ Compiler (cl)" superClass="org.eclipse.cdt.msvc.cl.dll.debug">
|
||||
<option id="org.eclipse.cdt.msvc.cl.option.includes.1468714055" name="Include Path (/I)" superClass="org.eclipse.cdt.msvc.cl.option.includes" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include""/>
|
||||
<listOptionValue builtIn="false" value=""D:\Programme\wxWidgets-2.9.2\include""/>
|
||||
<listOptionValue builtIn="false" value=""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include""/>
|
||||
</option>
|
||||
<inputType id="org.eclipse.cdt.msvc.cl.inputType.370712665" superClass="org.eclipse.cdt.msvc.cl.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.msvc.rc.dll.debug.1079503691" name="Resource Compiler (rc)" superClass="org.eclipse.cdt.msvc.rc.dll.debug">
|
||||
<inputType id="org.eclipse.cdt.msvc.rc.inputType.1577630195" superClass="org.eclipse.cdt.msvc.rc.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.msvc.link.dll.debug.617161498" name="Linker (link)" superClass="org.eclipse.cdt.msvc.link.dll.debug">
|
||||
<inputType id="org.eclipse.cdt.msvc.link.inputType.1391138218" superClass="org.eclipse.cdt.msvc.link.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.msvc.lib.1963448406" name="Library Manager (lib)" superClass="org.eclipse.cdt.msvc.lib"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="uMod.null.2056766171" name="uMod"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="1">
|
||||
<resource resourceType="PROJECT" workspacePath="/uMod"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207;org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207.1198697062;org.eclipse.cdt.msvc.cl.dll.debug.971252395;org.eclipse.cdt.msvc.cl.inputType.370712665">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.msw.build.clScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
|
||||
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
|
||||
<path value=""/>
|
||||
</doc-comment-owner>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -0,0 +1,7 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
@@ -1,81 +0,0 @@
|
||||
* text=auto !eol
|
||||
/.cproject -text
|
||||
/.project -text
|
||||
.settings/org.eclipse.cdt.codan.core.prefs -text
|
||||
/README.txt -text
|
||||
uMod_DX9/makefile.gcc -text
|
||||
uMod_DX9/makefile.vc -text
|
||||
uMod_DX9/uMod_ArrayHandler.cpp -text
|
||||
uMod_DX9/uMod_ArrayHandler.h -text
|
||||
uMod_DX9/uMod_DX9_dll.cpp -text
|
||||
uMod_DX9/uMod_DX9_dll.h -text
|
||||
uMod_DX9/uMod_DX9_dll_DIRECT_INJECTION.def -text
|
||||
uMod_DX9/uMod_DX9_dll_HOOK_INJECTION.def -text
|
||||
uMod_DX9/uMod_DX9_dll_NO_INJECTION.def -text
|
||||
uMod_DX9/uMod_Defines.h -text
|
||||
uMod_DX9/uMod_IDirect3D9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3D9.h -text
|
||||
uMod_DX9/uMod_IDirect3D9Ex.cpp -text
|
||||
uMod_DX9/uMod_IDirect3D9Ex.h -text
|
||||
uMod_DX9/uMod_IDirect3DCubeTexture9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DCubeTexture9.h -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9.h -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9Ex.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9Ex.h -text
|
||||
uMod_DX9/uMod_IDirect3DTexture9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DTexture9.h -text
|
||||
uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DVolumeTexture9.h -text
|
||||
uMod_DX9/uMod_Main.h -text
|
||||
uMod_DX9/uMod_TextureClient.cpp -text
|
||||
uMod_DX9/uMod_TextureClient.h -text
|
||||
uMod_DX9/uMod_TextureFunction.cpp -text
|
||||
uMod_DX9/uMod_TextureFunction.h -text
|
||||
uMod_DX9/uMod_TextureServer.cpp -text
|
||||
uMod_DX9/uMod_TextureServer.h -text
|
||||
/uMod_Error.h -text
|
||||
uMod_GUI/bin/README_Deutsch.txt -text
|
||||
uMod_GUI/bin/README_English.txt -text
|
||||
uMod_GUI/bin/README_French.txt -text
|
||||
uMod_GUI/bin/languages/Example_uMod_LanguagePack_English.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePackU_Deutsch.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePackU_French.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePackU_Russian.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePack_Italian.txt -text
|
||||
uMod_GUI/config.gcc -text
|
||||
uMod_GUI/config.vc -text
|
||||
uMod_GUI/makefile.gcc -text
|
||||
uMod_GUI/makefile.vc -text
|
||||
uMod_GUI/uMod.ico -text
|
||||
uMod_GUI/uMod.rc -text
|
||||
uMod_GUI/uMod_AddTexture.cpp -text
|
||||
uMod_GUI/uMod_AddTexture.h -text
|
||||
uMod_GUI/uMod_Client.cpp -text
|
||||
uMod_GUI/uMod_Client.h -text
|
||||
uMod_GUI/uMod_DirectInjection.cpp -text
|
||||
uMod_GUI/uMod_DirectInjection.h -text
|
||||
uMod_GUI/uMod_Event.cpp -text
|
||||
uMod_GUI/uMod_Event.h -text
|
||||
uMod_GUI/uMod_File.cpp -text
|
||||
uMod_GUI/uMod_File.h -text
|
||||
uMod_GUI/uMod_GUI.cpp -text
|
||||
uMod_GUI/uMod_GUI.h -text
|
||||
uMod_GUI/uMod_GameInfo.cpp -text
|
||||
uMod_GUI/uMod_GameInfo.h -text
|
||||
uMod_GUI/uMod_GamePage.cpp -text
|
||||
uMod_GUI/uMod_GamePage.h -text
|
||||
uMod_GUI/uMod_Language.cpp -text
|
||||
uMod_GUI/uMod_Language.h -text
|
||||
uMod_GUI/uMod_Main.h -text
|
||||
uMod_GUI/uMod_Sender.cpp -text
|
||||
uMod_GUI/uMod_Sender.h -text
|
||||
uMod_GUI/uMod_Server.cpp -text
|
||||
uMod_GUI/uMod_Server.h -text
|
||||
uMod_GUI/uMod_Settings.cpp -text
|
||||
uMod_GUI/uMod_Settings.h -text
|
||||
uMod_GUI/unzip.cpp -text
|
||||
uMod_GUI/unzip.h -text
|
||||
uMod_GUI/zip.cpp -text
|
||||
uMod_GUI/zip.h -text
|
||||
/uMod_GlobalDefines.h -text
|
||||
@@ -0,0 +1,74 @@
|
||||
name: gMod CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
targetplatform: [x86]
|
||||
|
||||
runs-on: windows-2025-vs2026
|
||||
|
||||
env:
|
||||
Configuration: Release
|
||||
Actions_Allow_Unsecure_Commands: true
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild.exe
|
||||
uses: microsoft/setup-msbuild@v1.3.1
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
.\vcpkg\bootstrap-vcpkg.bat
|
||||
|
||||
- name: Set VCPKG_ROOT
|
||||
run: |
|
||||
echo "VCPKG_ROOT=$(Get-Location)\vcpkg" >> $env:GITHUB_ENV
|
||||
shell: powershell
|
||||
|
||||
- name: Build CMake Files with vcpkg toolchain
|
||||
run: cmake --preset=vcpkg
|
||||
env:
|
||||
VCPKG_ROOT: ${{ env.VCPKG_ROOT }}
|
||||
|
||||
- name: Build binaries
|
||||
run: cmake --build build --config Release
|
||||
|
||||
- name: Retrieve version
|
||||
id: set_version
|
||||
run: |
|
||||
$fileVersionInfo = (Get-Item -Path .\bin\Release\gMod.dll).VersionInfo.FileVersion
|
||||
if ([string]::IsNullOrEmpty($fileVersionInfo)) {
|
||||
Write-Host "The DLL file version information could not be retrieved."
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "FileVersionInfo: $fileVersionInfo"
|
||||
echo "::set-output name=version::$fileVersionInfo"
|
||||
}
|
||||
shell: pwsh
|
||||
|
||||
- name: Publish release
|
||||
uses: Xotl/cool-github-releases@v1.1.8
|
||||
with:
|
||||
mode: update
|
||||
tag_name: v${{ steps.set_version.outputs.version }}
|
||||
release_name: gMod v${{ steps.set_version.outputs.version }}
|
||||
assets: .\bin\Release\gMod.dll;.\bin\Release\TpfConvert.exe;.\bin\Release\d3dx9_43.dll
|
||||
github_token: ${{ env.GITHUB_TOKEN }}
|
||||
replace_assets: true
|
||||
body_mrkdwn: ${{ env.Changelog }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,50 @@
|
||||
name: gMod CI Pipeline
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
targetplatform: [x86]
|
||||
|
||||
runs-on: windows-2025-vs2026
|
||||
|
||||
env:
|
||||
Configuration: Release
|
||||
Actions_Allow_Unsecure_Commands: true
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild.exe
|
||||
uses: microsoft/setup-msbuild@v1.3.1
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
.\vcpkg\bootstrap-vcpkg.bat
|
||||
|
||||
- name: Set VCPKG_ROOT
|
||||
run: |
|
||||
echo "VCPKG_ROOT=$(Get-Location)\vcpkg" >> $env:GITHUB_ENV
|
||||
shell: powershell
|
||||
|
||||
- name: Build CMake Files with vcpkg toolchain
|
||||
run: cmake --preset=vcpkg
|
||||
env:
|
||||
VCPKG_ROOT: ${{ env.VCPKG_ROOT }}
|
||||
|
||||
- name: Build binaries
|
||||
run: cmake --build build --config Release
|
||||
@@ -0,0 +1,40 @@
|
||||
name: gMod Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
# Pinned to the version the tree was formatted with so CI and local agree.
|
||||
- name: Install clang-format
|
||||
run: pipx install clang-format==22.1.5
|
||||
|
||||
- name: Apply clang-format
|
||||
run: clang-format -i header/*.h source/*.cpp modules/*.ixx TpfConvert/src/*.ixx
|
||||
|
||||
# Push / same-repo PRs: commit the fixes back. Fork PRs can't be pushed to,
|
||||
# so fail the check instead and let the contributor format.
|
||||
- name: Commit fixes
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "ci: apply clang-format"
|
||||
- name: Verify formatting (fork PRs)
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
|
||||
run: git diff --exit-code
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
# IDE
|
||||
*.vs
|
||||
*.user
|
||||
*.settings
|
||||
*.vscode
|
||||
*.project
|
||||
*.cproject
|
||||
*.vcproj
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
**/CMakeFiles/**
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
*.sln
|
||||
*.rc
|
||||
/*.dir
|
||||
|
||||
# Build directories
|
||||
Release
|
||||
Debug
|
||||
bin/
|
||||
*/Debug
|
||||
*/Release
|
||||
*/bin
|
||||
*/obj
|
||||
vcpkg
|
||||
vcpkg_installed
|
||||
|
||||
# Bloated Windows Databases
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.suo
|
||||
*.exp
|
||||
*.db
|
||||
*.pdb
|
||||
*.idb
|
||||
*.ilk
|
||||
*.opendb
|
||||
*.log
|
||||
*.lastbuildstate
|
||||
|
||||
# Compiled files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
*.exe
|
||||
*.wxs
|
||||
*.wixobj
|
||||
*.msi
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
*.idb
|
||||
*.pdb
|
||||
*.opendb
|
||||
*.wixpdb
|
||||
|
||||
**/RelWithDebInfo/
|
||||
**/Debug/
|
||||
/bin
|
||||
/win32
|
||||
/out
|
||||
/build
|
||||
/_deps
|
||||
|
||||
.idea
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>uMod 1</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/uMod/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,66 +0,0 @@
|
||||
#Sun Mar 11 21:51:23 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false}
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue.params={}
|
||||
org.eclipse.cdt.codan.checkers.noreturn=Error
|
||||
org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")}
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
@@ -0,0 +1,96 @@
|
||||
# gMod
|
||||
|
||||
A 32-bit Windows DLL that hooks Direct3D 9 to load texture mods for Guild Wars. Continuation of uMod. Integrated with [GW Launcher](https://github.com/gwdevhub/gwlauncher) and [Daybreak](https://github.com/gwdevhub/Daybreak).
|
||||
|
||||
## Project structure
|
||||
|
||||
- `header/` — header files (D3D9Hooks, D3D9State, Defines, Error, Main, Utils)
|
||||
- `source/` — implementation files (D3D9Hooks.cpp, dll_main.cpp, Error.cpp)
|
||||
- `modules/` — C++23 module files (ModfileLoader, ModfileLoader_TpfReader, TextureClient, TextureFunction)
|
||||
- `TpfConvert/` — standalone utility to fix broken .tpf files
|
||||
- `cmake/` — CMake helper scripts
|
||||
- `build/` — CMake build tree (generated, ignored)
|
||||
- `bin/` — compiled output (generated, ignored)
|
||||
|
||||
## Build
|
||||
|
||||
Requires Visual Studio 2022, CMake 3.29+, and vcpkg — all via the VS 2022 Developer PowerShell.
|
||||
|
||||
```
|
||||
cmake --preset=vcpkg
|
||||
cmake --open build
|
||||
# then compile inside Visual Studio, or:
|
||||
cmake --build build --config Release
|
||||
```
|
||||
|
||||
- Target: 32-bit only (`-A Win32` / `CMAKE_GENERATOR_PLATFORM=win32`)
|
||||
- Standard: C++23
|
||||
- Output: `bin/` (gMod.dll, TpfConvert.exe)
|
||||
- Version: set in `CMakeLists.txt` (`VERSION_MAJOR/MINOR/PATCH/TWEAK`)
|
||||
|
||||
> **Cannot be built or run in this agent environment** (Linux, no MSVC, no 32-bit
|
||||
> D3D9, no Guild Wars to inject into). Don't burn turns attempting `cmake`/builds
|
||||
> here — validate changes by reading and matching existing patterns, and lean on
|
||||
> Windows CI (`ci.yaml`) for the real build. When an actual compile/test is needed,
|
||||
> ask the user to do it in Visual Studio rather than trying locally.
|
||||
|
||||
## Key dependencies (via vcpkg)
|
||||
|
||||
- `minhook` — D3D9 function hooking
|
||||
- `libzippp` / `libzip` / `zlib` — reading .tpf/.zip mod files
|
||||
- `directxtex` — texture format conversion
|
||||
- `Microsoft.GSL` — Guidelines Support Library
|
||||
|
||||
## How it works
|
||||
|
||||
1. `dll_main.cpp` — DLL entry point, hooks d3d9.dll via MinHook
|
||||
2. `D3D9Hooks.cpp` — intercepts `Direct3DCreate9` and IDirect3DDevice9 methods
|
||||
3. `ModfileLoader` — reads `modlist.txt`, loads .tpf/.zip mod archives
|
||||
4. `TextureClient` / `TextureFunction` — matches and replaces textures by hash at runtime
|
||||
|
||||
### Hooking model (read before touching D3D9 code)
|
||||
|
||||
gMod uses **MinHook vtable hooks**, not proxy/subclass wrappers (the old uMod model
|
||||
was replaced — see `git log` "Replace D3D9 proxy wrappers with vtable hooks"). The
|
||||
game keeps the **real** `IDirect3D9` / `IDirect3DDevice9` / texture objects byte-for-byte
|
||||
untouched; gMod patches only the individual vtable slots it cares about (CreateDevice,
|
||||
CreateTexture/Volume/Cube, UpdateTexture, BeginScene, Set/GetTexture, Release).
|
||||
|
||||
- Per-texture side-state lives **out of band** in `header/D3D9State.h` (`TexState`,
|
||||
keyed by the real texture pointer), so reverting the hooks fully detaches gMod.
|
||||
- `RemoveAllD3D9Hooks()` must leave the host process pristine — preserve that invariant.
|
||||
- A vtable is shared by all instances of a class, so each slot is hooked once; texture
|
||||
Release slots are hooked lazily on first instance. Don't double-hook.
|
||||
|
||||
## Conventions
|
||||
|
||||
- **Formatting is CI-enforced** by clang-format `22.1.5` (`.clang-format`, applied by
|
||||
`lint.yaml` on push to `dev`). Don't hand-reformat or "tidy" whole files — it just
|
||||
churns the diff. Notable rules: `ColumnLimit: 0` (never reflow long D3D signatures /
|
||||
vtable typedefs), `SortIncludes: Never` (include order is load-bearing in Windows
|
||||
headers — never reorder), 4-space indent, braces on their own line after functions.
|
||||
- **C++23 named modules** (`modules/*.ixx`). Editing a module *interface* triggers wide
|
||||
rebuilds; prefer changing implementation over interface when possible.
|
||||
- **Public exported API is a fixed surface** — four `extern "C" __declspec(dllexport)`
|
||||
functions in `dll_main.cpp`: `SetDevice`, `AddFile`, `RemoveFile`, `GetFiles`. These
|
||||
are consumed by GW Launcher and Daybreak; do **not** change their names, signatures,
|
||||
or calling convention (`__cdecl`) without coordinating downstream.
|
||||
- **Commits**: short imperative summaries, lowercase, no trailing period
|
||||
(e.g. "Keep loaded_files in load order so GetFiles returns priority order").
|
||||
- **Branching**: `dev` is the integration branch; PRs target `master`. CI builds on
|
||||
push to `dev` and on PRs to `master`.
|
||||
|
||||
### Where things live (by size / how often they change)
|
||||
|
||||
- `modules/TextureClient.ixx` (~670 lines) — texture match/replace bookkeeping, hot
|
||||
- `source/D3D9Hooks.cpp` (~580) — the vtable detours and install/remove
|
||||
- `modules/TextureFunction.ixx` (~380) — texture creation/conversion helpers
|
||||
- `source/dll_main.cpp` (~345) — entry point + exported C API
|
||||
- `modules/ModfileLoader*.ixx` — .tpf/.zip parsing
|
||||
- `header/Defines.h` — shared structs/constants (`TextureFileStruct`, `HashTuple`, etc.)
|
||||
|
||||
## Notes
|
||||
|
||||
- Must be injected before d3d9.dll loads, or renamed to d3d9.dll in the GW folder
|
||||
- Reshade > 5.0.1 causes glitches; recommend 5.0.1 or 4.9.1
|
||||
- `modlist.txt` contains full paths to .tpf/.zip mod files, one per line
|
||||
@@ -0,0 +1,73 @@
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
|
||||
set(CMAKE_GENERATOR_PLATFORM win32)
|
||||
|
||||
project(gMod)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
if(NOT(CMAKE_SIZEOF_VOID_P EQUAL 4))
|
||||
message(FATAL_ERROR "You are configuring a non 32-bit build, this is not supported. Run cmake with `-A Win32`")
|
||||
endif()
|
||||
|
||||
set(VERSION_MAJOR 1)
|
||||
set(VERSION_MINOR 9)
|
||||
set(VERSION_PATCH 0)
|
||||
set(VERSION_TWEAK 2)
|
||||
|
||||
set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
|
||||
add_compile_options(/MP /permissive-)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
find_package(libzippp CONFIG REQUIRED)
|
||||
find_package(minhook CONFIG REQUIRED)
|
||||
find_package(Microsoft.GSL CONFIG REQUIRED)
|
||||
include(dxtk)
|
||||
|
||||
add_library(gMod SHARED)
|
||||
|
||||
file(GLOB SOURCES
|
||||
"header/*.h"
|
||||
"source/*.cpp"
|
||||
"modules/*.ixx"
|
||||
${VERSION_RC}
|
||||
)
|
||||
|
||||
target_include_directories(gMod PRIVATE
|
||||
"header"
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
)
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
|
||||
target_sources(gMod PRIVATE ${SOURCES})
|
||||
target_compile_options(gMod PRIVATE /W4 /WX)
|
||||
|
||||
target_link_libraries(gMod PRIVATE
|
||||
dxguid
|
||||
libzippp::libzippp
|
||||
psapi
|
||||
minhook::minhook
|
||||
directxtex
|
||||
Microsoft.GSL::GSL
|
||||
)
|
||||
target_link_options(gMod PRIVATE
|
||||
"$<$<CONFIG:DEBUG>:/NODEFAULTLIB:LIBCMT>"
|
||||
"/LARGEADDRESSAWARE"
|
||||
)
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
|
||||
target_sources(gMod PRIVATE ${SOURCES})
|
||||
target_compile_definitions(gMod PRIVATE
|
||||
"NOMINMAX"
|
||||
"_WIN32_WINNT=_WIN32_WINNT_WIN7"
|
||||
"WIN32_LEAN_AND_MEAN"
|
||||
"VC_EXTRALEAN"
|
||||
DIRECT_INJECTION
|
||||
LOG_MESSAGE
|
||||
)
|
||||
|
||||
add_subdirectory(TpfConvert)
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "vcpkg",
|
||||
"generator": "Visual Studio 18 2026",
|
||||
"architecture": "Win32",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/triplets",
|
||||
"VCPKG_TARGET_TRIPLET": "x86-windows-mixed",
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "x86-Debug",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
},
|
||||
{
|
||||
"name": "x86-Release",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"configurationType": "Release",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,44 @@
|
||||
***gMod***
|
||||
|
||||
Continuation of the uMod project to improve performance and stability. Integrated with [Guild Wars Launcher](https://github.com/gwdevhub/gwlauncher) and [Daybreak](https://github.com/gwdevhub/Daybreak).
|
||||
|
||||
*Usage is primarily intended with GW Launcher or Daybreak, but it can be used without.*
|
||||
|
||||
**Usage with manual gMod.dll injection:**
|
||||
- Create a file called modlist.txt in either the Guild Wars (Gw.exe) folder, or the gMod.dll folder.
|
||||
- Inject gMod.dll before d3d9.dll is loaded.
|
||||
|
||||
**Usage without dll injection:**
|
||||
- Create a file called modlist.txt in the Guild Wars (Gw.exe) folder.
|
||||
- Place gMod.dll in the Guild Wars folder
|
||||
- Rename gMod.dll to d3d9.dll
|
||||
- Launch Guild Wars
|
||||
|
||||
**Format of the modlist.txt file:**
|
||||
|
||||
Each line in the modlist.txt is the full path to a mod you want to load (eg. `D:\uMod\Borderless Cartography Made Easy 2015 1.3.tpf`)
|
||||
gMod will load all these files on startup
|
||||
|
||||
**Disclaimer about [Reshade](https://github.com/crosire/reshade)**
|
||||
|
||||
Reshade in versions > 5.0.1 is known to cause glitches with TexMod, uMod and also gMod.
|
||||
If you would like to use Reshade in combination with gMod, we recommend running version [5.0.1](https://github.com/crosire/reshade/releases/tag/v5.0.1) or [4.9.1](https://github.com/crosire/reshade/releases/tag/v4.9.1).
|
||||
|
||||
**Build from source**
|
||||
|
||||
Requirements:
|
||||
- Visual Studio 2022
|
||||
- CMake 3.29+, integrated into the Developer Powershell for VS 2022
|
||||
- vcpkg, integrated into the Developer Powershell for VS 2022
|
||||
|
||||
Compile:
|
||||
- cmake --preset=vcpkg
|
||||
- cmake --open build
|
||||
- compile
|
||||
|
||||
**TpfConvert**
|
||||
Small utility to convert old .tpf files with invalid images into .zip files with working images.
|
||||
Usage:
|
||||
- Put TpfConvert.exe and d3dx9.dll in the folder where you have your old, broken texmods with invalid images.
|
||||
- Run TpfConvert.exe, all *.tpf and *.zip files are processed. The originals are saved into a newly created backup folder.
|
||||
- Done.
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
The licence is set for each file separately.
|
||||
|
||||
|
||||
1) How to compile the GUI:
|
||||
|
||||
1.1) You need:
|
||||
- wxWidgets 2.9. (an earlier version won't work, cause I use wxString functions only available in 2.9., I use atm 2.9.2)
|
||||
|
||||
In the package a makefile for the gcc (makefile.gcc) and a makefile for the MS Visual C Compiler (makefile.vc) is included, but you can generate your own makefile for the compiler of your choice.
|
||||
|
||||
Compiling wxWidgets:
|
||||
- Compile it with BUILD=release otherwise the executable will be very large.
|
||||
- The vc compiler somehow generates a smaller executable.
|
||||
- Set the linkage to static (in the config.gcc or config.vc) before you compile the wxWidgets, to ensure, that also on other PC's your executable will run.
|
||||
|
||||
If you use my makefiles, you have to change the WX_DIR Variable to your wxWidgets directory. This Variable is nearly at the beginning of the makefiles.
|
||||
note: I have set the linkage to static in the corresponding config.* files, if you have not compiled you wxWidgets with static linkage the compiler will fail, when linking the GUI.
|
||||
|
||||
1.2) Using gcc:
|
||||
change in the uMod_GUI Directory and type:
|
||||
mingw32-make -f makefile.gcc BUILD=release
|
||||
(note: with the options -j 4 you compile simultaneously with 4 threads)
|
||||
|
||||
1.3) Using vc:
|
||||
change in the uMod_GUI Directory and type:
|
||||
nmake -f makefile.vc BUILD=release
|
||||
(note: you need to use the special MS Visual prompt)
|
||||
|
||||
|
||||
2) How to compile the dll:
|
||||
|
||||
2.1) You need:
|
||||
- The DirectX SDK (I use June 2010)
|
||||
- MS Visual C Compiler (I use the free Express 2010 version)
|
||||
- maybe the Microsoft Windows SDK
|
||||
|
||||
There exist two makefiles, one for the mingw32-make.exe (makefile.gcc) which call the vc compiler and one for the nmake.exe (makefile.vc) which also calls the vc compiler. I have created the makefile.gcc only to use the -j 4 option of the gnu make.
|
||||
|
||||
You have to compile the 3 dll's separately (one for each injection method). The dll will be copied after successful compilation in the uMod_GUI/bin directory.
|
||||
|
||||
If you want to use the logging mode of the dll you have to parse LOG_MESSAGE=1
|
||||
|
||||
|
||||
2.2) Using gcc (BUT you need the vc compiler!):
|
||||
change in the uMod_DX9 Directory and type:
|
||||
mingw32-make -f makefile.gcc
|
||||
mingw32-make -f makefile.gcc DI=1
|
||||
mingw32-make -f makefile.gcc NI=1
|
||||
(note: you need to use the special MS Visual prompt)
|
||||
(note: with the options -j 4 you compile simultaneously with 4 threads)
|
||||
|
||||
|
||||
2.3) Using vc:
|
||||
change in the uMod_DX9 Directory and type:
|
||||
nmake -f makefile.vc
|
||||
nmake -f makefile.vc DI=1
|
||||
nmake -f makefile.vc NI=1
|
||||
(note: you need to use the special MS Visual prompt)
|
||||
@@ -0,0 +1,39 @@
|
||||
add_executable(TpfConvert)
|
||||
|
||||
# Find all .ixx files in the TpfConvert folder
|
||||
file(GLOB TPF_SOURCES "src/*.ixx")
|
||||
|
||||
# Add the .ixx files to the TpfConvert target
|
||||
target_sources(TpfConvert PRIVATE ${TPF_SOURCES})
|
||||
|
||||
set_target_properties(TpfConvert PROPERTIES
|
||||
CXX_STANDARD 23
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
|
||||
target_compile_definitions(TpfConvert PRIVATE
|
||||
"NOMINMAX"
|
||||
"_WIN32_WINNT=_WIN32_WINNT_WIN7"
|
||||
"WIN32_LEAN_AND_MEAN"
|
||||
"VC_EXTRALEAN"
|
||||
)
|
||||
|
||||
if(DEFINED ENV{VCPKG_ROOT})
|
||||
message(STATUS "VCPKG_ROOT: $ENV{VCPKG_ROOT}")
|
||||
else()
|
||||
message(STATUS "VCPKG_ROOT is not set")
|
||||
endif()
|
||||
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
else()
|
||||
message(STATUS "CMAKE_TOOLCHAIN_FILE is not set")
|
||||
endif()
|
||||
|
||||
find_package(dxsdk-d3dx CONFIG REQUIRED)
|
||||
|
||||
target_link_libraries(TpfConvert PRIVATE
|
||||
libzippp::libzippp
|
||||
Microsoft::D3DX9
|
||||
d3d9
|
||||
)
|
||||
@@ -0,0 +1,179 @@
|
||||
export module ModfileLoader;
|
||||
|
||||
import std;
|
||||
import <libzippp.h>;
|
||||
import ModfileLoader.TpfReader;
|
||||
|
||||
export using HashType = uint64_t;
|
||||
|
||||
export struct TexEntry {
|
||||
std::vector<uint8_t> data{};
|
||||
HashType crc_hash = 0; // hash value
|
||||
std::string ext{};
|
||||
};
|
||||
|
||||
namespace {
|
||||
HashType GetCrcFromFilename(const std::string& filename)
|
||||
{
|
||||
const static std::regex re(R"(0[xX][0-9a-fA-F]{4,16})", std::regex::optimize);
|
||||
std::smatch match;
|
||||
if (!std::regex_search(filename, match, re)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t crc64_hash = 0;
|
||||
const auto number_str = match.str();
|
||||
try {
|
||||
crc64_hash = std::stoull(number_str, nullptr, 16);
|
||||
}
|
||||
catch (const std::invalid_argument&) {
|
||||
std::print(stderr, "Failed to parse {} as a hash\n", filename);
|
||||
return 0;
|
||||
}
|
||||
catch (const std::out_of_range&) {
|
||||
std::print(stderr, "Out of range while parsing {} as a hash\n", filename);
|
||||
return 0;
|
||||
}
|
||||
return crc64_hash;
|
||||
}
|
||||
}
|
||||
|
||||
export class ModfileLoader {
|
||||
std::filesystem::path file_name;
|
||||
const std::string TPF_PASSWORD{
|
||||
0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, static_cast<char>(0xA6), static_cast<char>(0xBD),
|
||||
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
|
||||
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
|
||||
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
|
||||
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
|
||||
0x46, 0x6F};
|
||||
|
||||
public:
|
||||
ModfileLoader(const std::filesystem::path& fileName);
|
||||
|
||||
std::vector<TexEntry> GetContents() const;
|
||||
|
||||
private:
|
||||
std::vector<TexEntry> GetTpfContents() const;
|
||||
|
||||
std::vector<TexEntry> GetFileContents() const;
|
||||
|
||||
static void LoadEntries(libzippp::ZipArchive& archive, std::vector<TexEntry>& entries);
|
||||
};
|
||||
|
||||
ModfileLoader::ModfileLoader(const std::filesystem::path& fileName)
|
||||
{
|
||||
file_name = std::filesystem::absolute(fileName);
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetContents() const
|
||||
{
|
||||
try {
|
||||
return file_name.wstring().ends_with(L".tpf") ? GetTpfContents() : GetFileContents();
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
std::print(stderr, "Failed to open mod file: {}\n", file_name.string().c_str());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetTpfContents() const
|
||||
{
|
||||
std::vector<TexEntry> entries;
|
||||
auto tpf_reader = TpfReader(file_name);
|
||||
const auto buffer = tpf_reader.ReadToEnd();
|
||||
const auto zip_archive = libzippp::ZipArchive::fromBuffer(buffer.data(), buffer.size(), false, TPF_PASSWORD);
|
||||
if (!zip_archive) {
|
||||
std::print(stderr, "Failed to open tpf file: {} - {} uint8_ts!\n", file_name.string(), buffer.size());
|
||||
return {};
|
||||
}
|
||||
zip_archive->setErrorHandlerCallback(
|
||||
[](const std::string& message, const std::string& strerror, int zip_error_code, int system_error_code) -> void {
|
||||
std::print(stderr, "GetTpfContents: {} {} {} {}\n", message, strerror, zip_error_code, system_error_code);
|
||||
});
|
||||
zip_archive->open();
|
||||
LoadEntries(*zip_archive, entries);
|
||||
zip_archive->close();
|
||||
libzippp::ZipArchive::free(zip_archive);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetFileContents() const
|
||||
{
|
||||
std::vector<TexEntry> entries;
|
||||
|
||||
libzippp::ZipArchive zip_archive(file_name.string());
|
||||
zip_archive.open();
|
||||
LoadEntries(zip_archive, entries);
|
||||
zip_archive.close();
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
void ParseSimpleArchive(const libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
for (const auto& entry : archive.getEntries()) {
|
||||
if (!entry.isFile())
|
||||
continue;
|
||||
const auto entry_name = entry.getName();
|
||||
const auto crc_hash = GetCrcFromFilename(entry_name);
|
||||
if (!crc_hash)
|
||||
continue;
|
||||
const auto data_ptr = static_cast<uint8_t*>(entry.readAsBinary());
|
||||
const auto size = entry.getSize();
|
||||
std::vector vec(data_ptr, data_ptr + size);
|
||||
std::filesystem::path tex_name(entry_name);
|
||||
entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string());
|
||||
delete[] data_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ParseTexmodArchive(std::vector<std::string>& lines, libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
for (const auto& line : lines) {
|
||||
// 0xC57D73F7|GW.EXE_0xC57D73F7.tga\r\n
|
||||
// match[1] | match[2]
|
||||
const static auto address_file_regex = std::regex(R"(^[\\/.]*([^|]+)\|([^\r\n]+))", std::regex::optimize);
|
||||
std::smatch match;
|
||||
if (!std::regex_search(line, match, address_file_regex))
|
||||
continue;
|
||||
const auto address_string = match[1].str();
|
||||
const auto file_path = match[2].str();
|
||||
|
||||
const auto crc_hash = GetCrcFromFilename(address_string);
|
||||
if (!crc_hash)
|
||||
continue;
|
||||
|
||||
const auto entry = archive.getEntry(file_path);
|
||||
if (entry.isNull() || !entry.isFile())
|
||||
continue;
|
||||
|
||||
const auto data_ptr = static_cast<uint8_t*>(entry.readAsBinary());
|
||||
const auto size = static_cast<size_t>(entry.getSize());
|
||||
std::vector vec(data_ptr, data_ptr + size);
|
||||
const auto tex_name = std::filesystem::path(entry.getName());
|
||||
entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string());
|
||||
delete[] data_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ModfileLoader::LoadEntries(libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
const auto def_file = archive.getEntry("texmod.def");
|
||||
if (def_file.isNull() || !def_file.isFile()) {
|
||||
ParseSimpleArchive(archive, entries);
|
||||
}
|
||||
else {
|
||||
const auto def = def_file.readAsText();
|
||||
std::istringstream iss(def);
|
||||
std::vector<std::string> lines;
|
||||
std::string line;
|
||||
|
||||
while (std::getline(iss, line)) {
|
||||
lines.push_back(line);
|
||||
}
|
||||
|
||||
ParseTexmodArchive(lines, archive, entries);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
export module ModfileLoader.TpfReader;
|
||||
|
||||
import std;
|
||||
|
||||
export class TpfReader {
|
||||
public:
|
||||
TpfReader(const std::filesystem::path& path)
|
||||
{
|
||||
file_stream = std::ifstream(path, std::ios::binary);
|
||||
if (!file_stream.seekg(0, std::ios::end).good() || !file_stream.seekg(0, std::ios::beg).good()) {
|
||||
throw std::invalid_argument("Provided stream needs to have SEEK set to True");
|
||||
}
|
||||
}
|
||||
|
||||
~TpfReader()
|
||||
{
|
||||
file_stream.close();
|
||||
}
|
||||
|
||||
std::vector<char> ReadToEnd()
|
||||
{
|
||||
file_stream.seekg(0, std::ios::end);
|
||||
line_length = file_stream.tellg();
|
||||
file_stream.seekg(0, std::ios::beg); // Go to the beginning of the stream
|
||||
|
||||
std::vector<char> data(line_length);
|
||||
file_stream.read(data.data(), line_length);
|
||||
for (auto i = 0; i < data.size(); i++) {
|
||||
data[i] = XOR(data[i], i);
|
||||
}
|
||||
|
||||
for (int i = data.size() - 1; i > 0 && data[i] != 0; i--) {
|
||||
data[i] = 0;
|
||||
}
|
||||
|
||||
// in the other zip libraries, these had to be cut off, with libzip we need to zero them out
|
||||
// cutting them off makes the archive invalid
|
||||
// data.resize(last_zero);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ifstream file_stream;
|
||||
long line_length = 0;
|
||||
|
||||
[[nodiscard]] char XOR(const char b, const long position) const
|
||||
{
|
||||
if (position >= (line_length / 4) * 4) {
|
||||
return b ^ TPF_XOREven;
|
||||
}
|
||||
|
||||
return position % 2 == 0 ? b ^ TPF_XOREven : b ^ TPF_XOROdd;
|
||||
}
|
||||
|
||||
static constexpr char TPF_XOROdd = 0x3F;
|
||||
static constexpr char TPF_XOREven = static_cast<char>(0xA4);
|
||||
};
|
||||
@@ -0,0 +1,152 @@
|
||||
#include <corecrt_wstdio.h>
|
||||
#include <Windows.h>
|
||||
#include <d3dx9.h>
|
||||
#include <d3d9.h>
|
||||
|
||||
import std;
|
||||
import ModfileLoader;
|
||||
import <libzippp.h>;
|
||||
|
||||
struct TexEntry;
|
||||
|
||||
namespace {
|
||||
IDirect3D9* pD3D = nullptr;
|
||||
IDirect3DDevice9* pDevice = nullptr;
|
||||
|
||||
bool InitializeDirect3D()
|
||||
{
|
||||
pD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if (pD3D == nullptr) {
|
||||
std::print(stderr, "Failed to create Direct3D9 object\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
D3DPRESENT_PARAMETERS d3dpp = {};
|
||||
d3dpp.Windowed = TRUE;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.hDeviceWindow = GetDesktopWindow();
|
||||
|
||||
if (FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(),
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice))) {
|
||||
std::print(stderr, "Failed to create Direct3D9 device\n");
|
||||
pD3D->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CleanupDirect3D()
|
||||
{
|
||||
if (pDevice) pDevice->Release();
|
||||
if (pD3D) pD3D->Release();
|
||||
}
|
||||
|
||||
std::pair<std::string, std::vector<uint8_t>> SaveAsDDS(const TexEntry& entry)
|
||||
{
|
||||
IDirect3DTexture9* pTexture = nullptr;
|
||||
ID3DXBuffer* pBuffer = nullptr;
|
||||
|
||||
HRESULT hr = D3DXCreateTextureFromFileInMemoryEx(pDevice,
|
||||
entry.data.data(), entry.data.size(),
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0,
|
||||
D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_NONE,
|
||||
D3DX_FILTER_NONE, 0, NULL, NULL, &pTexture);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
std::print(stderr, "Failed to create texture from memory\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
hr = D3DXSaveTextureToFileInMemory(&pBuffer, D3DXIFF_DDS, pTexture, NULL);
|
||||
if (FAILED(hr)) {
|
||||
std::print(stderr, "Failed to save texture to DDS memory buffer\n");
|
||||
pTexture->Release();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string dds_filename = std::format("0x{:x}.dds", entry.crc_hash);
|
||||
std::vector<uint8_t> dds_data(pBuffer->GetBufferSize());
|
||||
std::memcpy(dds_data.data(), pBuffer->GetBufferPointer(), pBuffer->GetBufferSize());
|
||||
|
||||
pTexture->Release();
|
||||
pBuffer->Release();
|
||||
|
||||
return {dds_filename, dds_data};
|
||||
}
|
||||
|
||||
std::filesystem::path GetExecutablePath()
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, buffer, MAX_PATH);
|
||||
return std::filesystem::path(buffer).parent_path();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const std::filesystem::path path = argc > 1 ? argv[1] : GetExecutablePath();
|
||||
const auto backup_path = path / "backup";
|
||||
|
||||
if (!InitializeDirect3D()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!std::filesystem::exists(backup_path)) {
|
||||
std::filesystem::create_directory(backup_path);
|
||||
}
|
||||
|
||||
for (const auto& modfile : std::filesystem::directory_iterator(path)) {
|
||||
if (modfile.is_regular_file() && (modfile.path().extension() == ".tpf" || modfile.path().extension() == ".zip")) {
|
||||
const auto mod_path = modfile.path();
|
||||
const auto backup_file = backup_path / mod_path.filename();
|
||||
|
||||
if (std::filesystem::exists(backup_file)) {
|
||||
std::print("Skipping previous TpfConvert output: {}\n", mod_path.filename().string());
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
std::print("Processing: {}\n", mod_path.filename().string());
|
||||
std::error_code ec;
|
||||
std::filesystem::rename(mod_path, backup_file, ec);
|
||||
}
|
||||
|
||||
const auto zip_filename = path / (mod_path.stem().string() + ".zip");
|
||||
if (std::filesystem::exists(zip_filename)) {
|
||||
std::filesystem::remove(zip_filename);
|
||||
}
|
||||
|
||||
ModfileLoader loader(backup_file);
|
||||
std::vector<std::pair<std::string, std::vector<uint8_t>>> data_entries;
|
||||
const auto entries = loader.GetContents();
|
||||
|
||||
libzippp::ZipArchive zip_archive(zip_filename.string());
|
||||
zip_archive.open(libzippp::ZipArchive::Write);
|
||||
|
||||
for (const auto& entry : entries) {
|
||||
auto [dds_filename, dds_data] = SaveAsDDS(entry);
|
||||
if (!dds_filename.empty()) {
|
||||
data_entries.emplace_back(dds_filename, std::move(dds_data));
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [filename, data] : data_entries) {
|
||||
const auto success = zip_archive.addData(filename, data.data(), data.size());
|
||||
if (!success) {
|
||||
std::print(stderr, "Failed to add data to ZIP: {}\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
zip_archive.close();
|
||||
std::print("Saved to ZIP: {}\n", zip_filename.string());
|
||||
}
|
||||
}
|
||||
|
||||
CleanupDirect3D();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
include_guard()
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
DirectXTex
|
||||
GIT_REPOSITORY https://github.com/microsoft/DirectXTex
|
||||
GIT_TAG oct2023)
|
||||
FetchContent_GetProperties(directxtex)
|
||||
if (directxtex_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
FetchContent_Populate(directxtex)
|
||||
|
||||
add_library(directxtex)
|
||||
file(GLOB SOURCES
|
||||
"${directxtex_SOURCE_DIR}/DDSTextureLoader/DDSTextureLoader9.h"
|
||||
"${directxtex_SOURCE_DIR}/DDSTextureLoader/DDSTextureLoader9.cpp"
|
||||
"${directxtex_SOURCE_DIR}/WICTextureLoader/WICTextureLoader9.h"
|
||||
"${directxtex_SOURCE_DIR}/WICTextureLoader/WICTextureLoader9.cpp"
|
||||
"${directxtex_SOURCE_DIR}/DirectXTex/*.h"
|
||||
"${directxtex_SOURCE_DIR}/DirectXTex/*.cpp"
|
||||
)
|
||||
list(REMOVE_ITEM SOURCES
|
||||
"${directxtex_SOURCE_DIR}/DirectXTex/BCDirectCompute.cpp"
|
||||
)
|
||||
source_group(TREE ${directxtex_SOURCE_DIR} FILES ${SOURCES})
|
||||
target_sources(directxtex PRIVATE ${SOURCES})
|
||||
target_include_directories(directxtex PUBLIC "${directxtex_SOURCE_DIR}")
|
||||
|
||||
set_target_properties(directxtex PROPERTIES FOLDER "Dependencies/")
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
void InstallD3D9Hooks(IDirect3D9* d3d9, bool is_ex);
|
||||
|
||||
void RemoveAllD3D9Hooks();
|
||||
|
||||
// Delete every per-device TextureClient, releasing its replacement textures. Only safe
|
||||
// on a real FreeLibrary (device still alive), not during process termination.
|
||||
void DestroyAllTextureClients();
|
||||
|
||||
bool RegisterExistingDevice(IDirect3DDevice9* device);
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
#include "Defines.h"
|
||||
|
||||
// Per-texture side-state, keyed by the real texture pointer (see D3D9Hooks.h).
|
||||
// Held out-of-band so reverting the vtable hooks fully detaches gMod.
|
||||
|
||||
enum class TexType {
|
||||
Tex2D,
|
||||
Volume,
|
||||
Cube,
|
||||
};
|
||||
|
||||
// State for one texture: an "original" the game created, or a "fake" we loaded
|
||||
// from a mod to stand in for one.
|
||||
struct TexState {
|
||||
IDirect3DBaseTexture9* real = nullptr;
|
||||
// An original points at the fake bound in its place (or nullptr); a fake
|
||||
// points back at the original it replaces.
|
||||
TexState* partner = nullptr;
|
||||
IDirect3DDevice9* device = nullptr;
|
||||
TextureFileStruct* reference = nullptr; // the modfile backing a fake
|
||||
HashTuple hash = {};
|
||||
TexType type = TexType::Tex2D;
|
||||
bool isFake = false;
|
||||
};
|
||||
|
||||
// Content hash (CRC32 + optional CRC64) of an original texture. Defined in
|
||||
// D3D9Hooks.cpp.
|
||||
HashTuple GetTextureHash(const TexState* state);
|
||||
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
// using HashType = DWORD32;
|
||||
using HashType = DWORD64;
|
||||
|
||||
struct HashTuple {
|
||||
HashType crc32;
|
||||
HashType crc64;
|
||||
|
||||
bool operator==(const HashTuple& other) const noexcept
|
||||
{
|
||||
return (other.crc32 == crc32) || (other.crc64 == crc64);
|
||||
}
|
||||
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return crc32 != 0 || crc64 != 0;
|
||||
}
|
||||
|
||||
explicit operator HashType() const noexcept
|
||||
{
|
||||
return crc32 ? crc32 : crc64;
|
||||
}
|
||||
};
|
||||
|
||||
struct TexEntry {
|
||||
std::vector<BYTE> data{};
|
||||
HashType crc_hash = 0; // hash value
|
||||
std::string ext{};
|
||||
};
|
||||
|
||||
struct TextureFileStruct {
|
||||
std::vector<BYTE> data{};
|
||||
HashType crc_hash = 0; // hash value
|
||||
};
|
||||
|
||||
inline void Message([[maybe_unused]] const char* format, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
//[[maybe_unused]] const auto success = SetConsoleTextAttribute(hConsole, 0); // white
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void Info([[maybe_unused]] const char* format, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
//[[maybe_unused]] const auto success = SetConsoleTextAttribute(hConsole, 0); // white
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void Warning([[maybe_unused]] const char* format, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
const HANDLE hConsole = GetStdHandle(STD_ERROR_HANDLE);
|
||||
[[maybe_unused]] const auto success = SetConsoleTextAttribute(hConsole, 6); // yellow
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
// define return values, a value less than zero indicates an error
|
||||
#define RETURN_OK 0
|
||||
#define RETURN_EXISTS -70
|
||||
|
||||
#define RETURN_FATAL_ERROR -1
|
||||
#define RETURN_NO_MEMORY -2
|
||||
#define RETURN_BAD_ARGUMENT -3
|
||||
|
||||
#define RETURN_NO_IDirect3DDevice9 -10
|
||||
|
||||
#define RETURN_TEXTURE_NOT_LOADED -20
|
||||
#define RETURN_TEXTURE_NOT_SAVED -21
|
||||
#define RETURN_TEXTURE_NOT_FOUND -22
|
||||
#define RETURN_TEXTURE_ALLREADY_ADDED -23
|
||||
#define RETURN_TEXTURE_NOT_SWITCHED -24
|
||||
|
||||
#define RETURN_LockRect_FAILED -30
|
||||
#define RETURN_UnlockRect_FAILED -31
|
||||
#define RETURN_GetLevelDesc_FAILED -32
|
||||
|
||||
|
||||
#define RETURN_NO_MUTEX -40
|
||||
#define RETURN_MUTEX_LOCK -41
|
||||
#define RETURN_MUTEX_UNLOCK -42
|
||||
|
||||
#define RETURN_UPDATE_ALLREADY_ADDED -50
|
||||
#define RETURN_FILE_NOT_LOADED -51
|
||||
|
||||
#define RETURN_PIPE_NOT_OPENED 60
|
||||
|
||||
|
||||
// define error states
|
||||
#define uMod_ERROR_FATAL 1u
|
||||
#define uMod_ERROR_MUTEX 1u << 1
|
||||
#define uMod_ERROR_PIPE 1u << 2
|
||||
#define uMod_ERROR_MEMORY 1u << 3
|
||||
#define uMod_ERROR_TEXTURE 1u << 4
|
||||
#define uMod_ERROR_MULTIPLE_IDirect3D9 1u << 5
|
||||
#define uMod_ERROR_MULTIPLE_IDirect3DDevice9 1u << 6
|
||||
#define uMod_ERROR_UPDATE 1u << 7
|
||||
#define uMod_ERROR_SERVER 1u << 8
|
||||
|
||||
__declspec(noreturn) void FatalAssert(
|
||||
const char* expr,
|
||||
const char* file,
|
||||
unsigned int line,
|
||||
const char* function);
|
||||
|
||||
#define ASSERT(expr) ((void)(!!(expr) || (FatalAssert(#expr, __FILE__, (unsigned)__LINE__, __FUNCTION__), 0)))
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <future>
|
||||
#include <map>
|
||||
#include <ranges>
|
||||
#include "Utils.h"
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "Defines.h"
|
||||
#include "Error.h"
|
||||
|
||||
#include "D3D9State.h"
|
||||
|
||||
#pragma warning(disable : 4477)
|
||||
|
||||
extern unsigned int gl_ErrorState;
|
||||
extern HINSTANCE gl_hThisInstance;
|
||||
inline std::filesystem::path gmod_dll_path;
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace utils {
|
||||
template <typename T>
|
||||
void erase_first(std::vector<T>& vec, const T& elem)
|
||||
{
|
||||
const auto found = std::ranges::find(vec, elem);
|
||||
if (found != std::ranges::end(vec)) {
|
||||
vec.erase(found);
|
||||
}
|
||||
}
|
||||
|
||||
inline std::wstring utf8_to_wstring(const std::string& utf8str)
|
||||
{
|
||||
if (utf8str.empty()) return {};
|
||||
|
||||
// Calculate the number of wide characters needed for the conversion
|
||||
const int count = MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(), -1, nullptr, 0);
|
||||
if (count == 0) throw std::runtime_error("Failed to convert UTF-8 to UTF-16");
|
||||
|
||||
std::wstring wstr(count, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(), -1, wstr.data(), count);
|
||||
|
||||
return wstr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
module;
|
||||
|
||||
#include "Main.h"
|
||||
#include "Defines.h"
|
||||
|
||||
export module ModfileLoader;
|
||||
|
||||
import std;
|
||||
import <libzippp.h>;
|
||||
import ModfileLoader.TpfReader;
|
||||
import TextureFunction;
|
||||
|
||||
namespace {
|
||||
bool use_64_bit_crc = false;
|
||||
|
||||
HashType GetCrcFromFilename(const std::string& filename)
|
||||
{
|
||||
const static std::regex re(R"(0[xX][0-9a-fA-F]{4,16})", std::regex::optimize);
|
||||
std::smatch match;
|
||||
if (!std::regex_search(filename, match, re)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t crc64_hash = 0;
|
||||
const auto number_str = match.str();
|
||||
try {
|
||||
crc64_hash = std::stoull(number_str, nullptr, 16);
|
||||
}
|
||||
catch (const std::invalid_argument&) {
|
||||
Warning("Failed to parse %s as a hash\n", filename.c_str());
|
||||
return 0;
|
||||
}
|
||||
catch (const std::out_of_range&) {
|
||||
Warning("Out of range while parsing %s as a hash\n", filename.c_str());
|
||||
return 0;
|
||||
}
|
||||
use_64_bit_crc = use_64_bit_crc || crc64_hash > 0xFFFFFFFF;
|
||||
return crc64_hash;
|
||||
}
|
||||
}
|
||||
|
||||
namespace HashCheck {
|
||||
export bool Use64BitCrc()
|
||||
{
|
||||
return use_64_bit_crc;
|
||||
}
|
||||
}
|
||||
|
||||
export class ModfileLoader {
|
||||
std::filesystem::path file_name;
|
||||
const std::string TPF_PASSWORD{
|
||||
0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, static_cast<char>(0xA6), static_cast<char>(0xBD),
|
||||
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
|
||||
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
|
||||
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
|
||||
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
|
||||
0x46, 0x6F};
|
||||
|
||||
public:
|
||||
ModfileLoader(const std::filesystem::path& fileName);
|
||||
|
||||
std::vector<TexEntry> GetContents() const;
|
||||
|
||||
private:
|
||||
std::vector<TexEntry> GetTpfContents() const;
|
||||
|
||||
std::vector<TexEntry> GetFileContents() const;
|
||||
|
||||
static void LoadEntries(libzippp::ZipArchive& archive, std::vector<TexEntry>& entries);
|
||||
};
|
||||
|
||||
ModfileLoader::ModfileLoader(const std::filesystem::path& fileName)
|
||||
{
|
||||
file_name = std::filesystem::absolute(fileName);
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetContents() const
|
||||
{
|
||||
try {
|
||||
return file_name.wstring().ends_with(L".tpf") ? GetTpfContents() : GetFileContents();
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
Warning("Failed to open mod file: %s\n", file_name.c_str());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetTpfContents() const
|
||||
{
|
||||
std::vector<TexEntry> entries;
|
||||
auto tpf_reader = TpfReader(file_name);
|
||||
const auto buffer = tpf_reader.ReadToEnd();
|
||||
const auto zip_archive = libzippp::ZipArchive::fromBuffer(buffer.data(), buffer.size(), false, TPF_PASSWORD);
|
||||
if (!zip_archive) {
|
||||
Warning("Failed to open tpf file: %s - %u bytes!", file_name.c_str(), buffer.size());
|
||||
return {};
|
||||
}
|
||||
zip_archive->setErrorHandlerCallback(
|
||||
[](const std::string& message, const std::string& strerror, int zip_error_code, int system_error_code) -> void {
|
||||
Message("GetTpfContents: %s %s %d %d\n", message.c_str(), strerror.c_str(), zip_error_code, system_error_code);
|
||||
});
|
||||
zip_archive->open();
|
||||
LoadEntries(*zip_archive, entries);
|
||||
zip_archive->close();
|
||||
libzippp::ZipArchive::free(zip_archive);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetFileContents() const
|
||||
{
|
||||
std::vector<TexEntry> entries;
|
||||
|
||||
libzippp::ZipArchive zip_archive(file_name.string());
|
||||
zip_archive.open();
|
||||
LoadEntries(zip_archive, entries);
|
||||
zip_archive.close();
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
void ParseSimpleArchive(const libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
for (const auto& entry : archive.getEntries()) {
|
||||
if (!entry.isFile())
|
||||
continue;
|
||||
const auto entry_name = entry.getName();
|
||||
const auto crc_hash = GetCrcFromFilename(entry.getName());
|
||||
if (!crc_hash) {
|
||||
Warning("Entry with name %s could not be parsed", entry_name.c_str());
|
||||
continue;
|
||||
}
|
||||
const auto data_ptr = static_cast<BYTE*>(entry.readAsBinary());
|
||||
const auto size = entry.getSize();
|
||||
std::vector vec(data_ptr, data_ptr + size);
|
||||
std::filesystem::path tex_name(entry.getName());
|
||||
entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string());
|
||||
delete[] data_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ParseTexmodArchive(std::vector<std::string>& lines, libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
for (const auto& line : lines) {
|
||||
// 0xC57D73F7|GW.EXE_0xC57D73F7.tga\r\n
|
||||
// match[1] | match[2]
|
||||
const static auto address_file_regex = std::regex(R"(^[\\/.]*([^|]+)\|([^\r\n]+))", std::regex::optimize);
|
||||
std::smatch match;
|
||||
if (!std::regex_search(line, match, address_file_regex)) {
|
||||
Warning("Failed to parse texmod.def archive line: %s - %s", line.c_str(), line.c_str());
|
||||
continue;
|
||||
}
|
||||
const auto address_string = match[1].str();
|
||||
const auto file_path = match[2].str();
|
||||
|
||||
const auto crc_hash = GetCrcFromFilename(address_string);
|
||||
if (!crc_hash)
|
||||
continue;
|
||||
|
||||
const auto entry = archive.getEntry(file_path);
|
||||
if (entry.isNull() || !entry.isFile())
|
||||
continue;
|
||||
|
||||
const auto data_ptr = static_cast<BYTE*>(entry.readAsBinary());
|
||||
const auto size = static_cast<size_t>(entry.getSize());
|
||||
std::vector vec(data_ptr, data_ptr + size);
|
||||
const auto tex_name = std::filesystem::path(entry.getName());
|
||||
entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string());
|
||||
delete[] data_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ModfileLoader::LoadEntries(libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
const auto def_file = archive.getEntry("texmod.def");
|
||||
if (def_file.isNull() || !def_file.isFile()) {
|
||||
ParseSimpleArchive(archive, entries);
|
||||
}
|
||||
else {
|
||||
const auto def = def_file.readAsText();
|
||||
std::istringstream iss(def);
|
||||
std::vector<std::string> lines;
|
||||
std::string line;
|
||||
|
||||
while (std::getline(iss, line)) {
|
||||
lines.push_back(line);
|
||||
}
|
||||
|
||||
ParseTexmodArchive(lines, archive, entries);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
export module ModfileLoader.TpfReader;
|
||||
|
||||
import std;
|
||||
|
||||
export class TpfReader {
|
||||
public:
|
||||
TpfReader(const std::filesystem::path& path)
|
||||
{
|
||||
file_stream = std::ifstream(path, std::ios::binary);
|
||||
if (!file_stream.seekg(0, std::ios::end).good() || !file_stream.seekg(0, std::ios::beg).good()) {
|
||||
throw std::invalid_argument("Provided stream needs to have SEEK set to True");
|
||||
}
|
||||
}
|
||||
|
||||
~TpfReader()
|
||||
{
|
||||
file_stream.close();
|
||||
}
|
||||
|
||||
std::vector<char> ReadToEnd()
|
||||
{
|
||||
file_stream.seekg(0, std::ios::end);
|
||||
line_length = file_stream.tellg();
|
||||
file_stream.seekg(0, std::ios::beg); // Go to the beginning of the stream
|
||||
|
||||
std::vector<char> data(static_cast<long>(line_length));
|
||||
file_stream.read(data.data(), line_length);
|
||||
for (auto i = 0u; i < data.size(); i++) {
|
||||
data[i] = XOR(data[i], i);
|
||||
}
|
||||
|
||||
for (auto i = data.size() - 1; i > 0 && data[i] != 0; i--) {
|
||||
data[i] = 0;
|
||||
}
|
||||
|
||||
// in the other zip libraries, these had to be cut off, with libzip we need to zero them out
|
||||
// cutting them off makes the archive invalid
|
||||
// data.resize(last_zero);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ifstream file_stream;
|
||||
std::streamoff line_length = 0;
|
||||
|
||||
[[nodiscard]] char XOR(const char b, const long position) const
|
||||
{
|
||||
if (position >= (line_length / 4) * 4) {
|
||||
return b ^ TPF_XOREven;
|
||||
}
|
||||
|
||||
return position % 2 == 0 ? b ^ TPF_XOREven : b ^ TPF_XOROdd;
|
||||
}
|
||||
|
||||
static constexpr char TPF_XOROdd = 0x3F;
|
||||
static constexpr char TPF_XOREven = static_cast<char>(0xA4);
|
||||
};
|
||||
@@ -0,0 +1,671 @@
|
||||
module;
|
||||
|
||||
#include "Main.h"
|
||||
#include "Error.h"
|
||||
#include "D3D9State.h"
|
||||
#include <DDSTextureLoader/DDSTextureLoader9.h>
|
||||
#include <DirectXTex/DirectXTex.h>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
export module TextureClient;
|
||||
import TextureFunction;
|
||||
import ModfileLoader;
|
||||
|
||||
export std::vector<std::pair<std::string, std::string>> modlists_contents;
|
||||
|
||||
struct PendingOp {
|
||||
enum class Kind {
|
||||
Add,
|
||||
Remove
|
||||
};
|
||||
Kind kind;
|
||||
HashType hash;
|
||||
std::vector<BYTE> data;
|
||||
};
|
||||
|
||||
// Couples a value with the mutex guarding it; the value is only reachable while
|
||||
// the lock is held.
|
||||
template <class T>
|
||||
class Guarded {
|
||||
std::mutex mutex;
|
||||
T value;
|
||||
|
||||
public:
|
||||
template <class Fn>
|
||||
auto with(Fn&& fn)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
return fn(value);
|
||||
}
|
||||
};
|
||||
|
||||
// Owned by each d3d9 device (see D3D9Hooks.cpp). Holds per-texture side-state
|
||||
// and does the modding; the On*() methods are the vtable-hook entry points.
|
||||
export class TextureClient {
|
||||
public:
|
||||
TextureClient(IDirect3DDevice9* device);
|
||||
~TextureClient();
|
||||
|
||||
// Called from the hooked vtable slots:
|
||||
TexState* OnCreateTexture(IDirect3DBaseTexture9* texture, TexType type);
|
||||
void OnBeginScene();
|
||||
// The fake replacement when `texture` is a modded original, else `texture`.
|
||||
IDirect3DBaseTexture9* ResolveBinding(IDirect3DBaseTexture9* texture);
|
||||
// For GetTexture: the original behind one of our fakes, or nullptr.
|
||||
IDirect3DBaseTexture9* ResolveOriginalFromFake(IDirect3DBaseTexture9* texture);
|
||||
void OnUpdateTexture(IDirect3DBaseTexture9* source, IDirect3DBaseTexture9* destination);
|
||||
void OnReleaseTexture(IDirect3DBaseTexture9* texture); // called once the real refcount hit zero
|
||||
|
||||
void Initialize();
|
||||
|
||||
void EnqueueAdd(HashType hash, std::vector<BYTE> data);
|
||||
void EnqueueRemove(HashType hash);
|
||||
|
||||
static int AddFile(const std::filesystem::path& path);
|
||||
static int RemoveFile(const std::filesystem::path& path);
|
||||
static std::vector<std::filesystem::path> GetFiles();
|
||||
|
||||
// The texture Release hook has only a texture pointer, so it finds its client here.
|
||||
static TextureClient* CurrentClient();
|
||||
|
||||
private:
|
||||
IDirect3DDevice9* D3D9Device;
|
||||
|
||||
// Side-state keyed by real texture pointer: the game's textures vs. our fakes.
|
||||
std::recursive_mutex registry_mutex;
|
||||
std::unordered_map<IDirect3DBaseTexture9*, TexState*> originals;
|
||||
std::unordered_map<IDirect3DBaseTexture9*, TexState*> fakes;
|
||||
|
||||
// Hashed one creation later, once the game has filled it with data.
|
||||
IDirect3DBaseTexture9* last_created[3] = {};
|
||||
|
||||
bool loading_fake = false; // set while LoadTexture() drives CreateTexture internally
|
||||
bool shutting_down = false; // set in ~TextureClient so the Release hook stops touching us
|
||||
bool should_update = false;
|
||||
|
||||
int AddTexture(IDirect3DBaseTexture9* texture); // hash a freshly filled original + look up its mod
|
||||
int LookUpToMod(TexState* state); // switch in a fake if a mod matches the hash
|
||||
int LoadTexture(TextureFileStruct* file_in_memory, IDirect3DBaseTexture9** ppTexture, TexState** ppState);
|
||||
|
||||
static void Switch(TexState* original, TexState* fake);
|
||||
static void Unswitch(TexState* original);
|
||||
void UnswitchAndRelease(TexState* original); // unswitch + release our fake
|
||||
|
||||
int MergeUpdate();
|
||||
|
||||
int LockMutex();
|
||||
int UnlockMutex();
|
||||
HANDLE hMutex;
|
||||
|
||||
Guarded<std::vector<PendingOp>> pending_ops;
|
||||
void ProcessPendingOps();
|
||||
void RemoveModdedTexture(HashType hash);
|
||||
|
||||
std::unordered_map<HashType, gsl::owner<TextureFileStruct*>> modded_textures; // hash -> mod file in memory
|
||||
|
||||
static void LoadStartupModlists();
|
||||
|
||||
// Enqueue an Add per distinct non-zero hash, free the structs, return the hashes
|
||||
// in load order; accumulates moved bytes into loaded_bytes when given.
|
||||
static std::vector<HashType> IngestModfile(std::vector<gsl::owner<TextureFileStruct*>>& texture_file_structs, uint64_t* loaded_bytes = nullptr);
|
||||
|
||||
// Kept in load order, which is priority order: on a hash collision the
|
||||
// earlier file wins (see ProcessPendingOps).
|
||||
struct LoadedFile {
|
||||
std::filesystem::path path;
|
||||
std::vector<HashType> hashes;
|
||||
};
|
||||
|
||||
static inline std::mutex global_mutex;
|
||||
static inline TextureClient* current_client = nullptr;
|
||||
// A vector, not a map: tens of mods at most, and their order is meaningful.
|
||||
static inline std::vector<LoadedFile> loaded_files;
|
||||
|
||||
// Caller holds global_mutex; path must already be absolute.
|
||||
static std::vector<LoadedFile>::iterator FindLoadedFile(const std::filesystem::path& absolute_path)
|
||||
{
|
||||
return std::ranges::find(loaded_files, absolute_path, &LoadedFile::path);
|
||||
}
|
||||
};
|
||||
|
||||
TextureClient* TextureClient::CurrentClient()
|
||||
{
|
||||
std::lock_guard lk(global_mutex);
|
||||
return current_client;
|
||||
}
|
||||
|
||||
TextureClient::TextureClient(IDirect3DDevice9* device)
|
||||
{
|
||||
Message("TextureClient::TextureClient(): %p\n", this);
|
||||
D3D9Device = device;
|
||||
|
||||
hMutex = CreateMutex(nullptr, false, nullptr);
|
||||
|
||||
std::lock_guard lk(global_mutex);
|
||||
ASSERT(current_client == nullptr); // gMod assumes a single d3d9 device per process
|
||||
current_client = this;
|
||||
}
|
||||
|
||||
TextureClient::~TextureClient()
|
||||
{
|
||||
Message("TextureClient::~TextureClient(): %p\n", this);
|
||||
{
|
||||
std::lock_guard lk(global_mutex);
|
||||
if (current_client == this) current_client = nullptr;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard lk(registry_mutex);
|
||||
shutting_down = true; // the texture Release hook now no-ops for our textures
|
||||
|
||||
// Release replacements we still own (still partnered) so they aren't leaked when
|
||||
// torn down with the device alive (FreeLibrary). Orphaned fakes were already
|
||||
// released; a device-release teardown leaves the maps empty, so this is a no-op.
|
||||
for (const auto fake : fakes | std::views::values) {
|
||||
if (fake->partner != nullptr) {
|
||||
fake->partner->partner = nullptr; // detach the original's back-pointer
|
||||
if (fake->real) fake->real->Release();
|
||||
}
|
||||
delete fake;
|
||||
}
|
||||
fakes.clear();
|
||||
for (const auto state : originals | std::views::values) {
|
||||
delete state;
|
||||
}
|
||||
originals.clear();
|
||||
}
|
||||
|
||||
if (hMutex != nullptr) {
|
||||
CloseHandle(hMutex);
|
||||
}
|
||||
for (const auto texture_file_struct : modded_textures | std::views::values) {
|
||||
delete texture_file_struct;
|
||||
}
|
||||
modded_textures.clear();
|
||||
}
|
||||
|
||||
void TextureClient::Switch(TexState* original, TexState* fake)
|
||||
{
|
||||
original->partner = fake;
|
||||
fake->partner = original;
|
||||
}
|
||||
|
||||
void TextureClient::Unswitch(TexState* original)
|
||||
{
|
||||
if (original->partner != nullptr) {
|
||||
original->partner->partner = nullptr;
|
||||
original->partner = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TextureClient::UnswitchAndRelease(TexState* original)
|
||||
{
|
||||
TexState* fake = original->partner;
|
||||
if (fake == nullptr) return;
|
||||
Unswitch(original); // detach before releasing so the fake's Release hook won't touch `original`
|
||||
if (fake->real) fake->real->Release(); // re-enters OnReleaseTexture(fake), which frees its state
|
||||
}
|
||||
|
||||
TexState* TextureClient::OnCreateTexture(IDirect3DBaseTexture9* texture, TexType type)
|
||||
{
|
||||
std::lock_guard lk(registry_mutex);
|
||||
|
||||
const auto state = new TexState();
|
||||
state->real = texture;
|
||||
state->device = D3D9Device;
|
||||
state->type = type;
|
||||
|
||||
if (loading_fake) {
|
||||
// A replacement we're creating: track as a fake, skip the originals bookkeeping.
|
||||
state->isFake = true;
|
||||
fakes.emplace(texture, state);
|
||||
return state;
|
||||
}
|
||||
|
||||
originals.emplace(texture, state);
|
||||
|
||||
// The previous texture of this type is now filled, so hash it.
|
||||
if (const auto last = last_created[static_cast<int>(type)]) {
|
||||
AddTexture(last);
|
||||
}
|
||||
last_created[static_cast<int>(type)] = texture;
|
||||
return state;
|
||||
}
|
||||
|
||||
int TextureClient::AddTexture(IDirect3DBaseTexture9* texture)
|
||||
{
|
||||
const auto it = originals.find(texture);
|
||||
if (it == originals.end()) return RETURN_OK;
|
||||
const auto state = it->second;
|
||||
|
||||
// No longer pending.
|
||||
if (last_created[static_cast<int>(state->type)] == texture) {
|
||||
last_created[static_cast<int>(state->type)] = nullptr;
|
||||
}
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
state->hash = GetTextureHash(state);
|
||||
if (!state->hash) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
return LookUpToMod(state); // check if this texture should be modded
|
||||
}
|
||||
|
||||
int TextureClient::LookUpToMod(TexState* state)
|
||||
{
|
||||
Message("TextureClient::LookUpToMod( %p): hash: %#lX\n", state->real, state->hash);
|
||||
if (state->partner != nullptr)
|
||||
return RETURN_OK; // already switched
|
||||
|
||||
auto found = modded_textures.find(state->hash.crc32);
|
||||
if (found == modded_textures.end())
|
||||
if (found = modded_textures.find(state->hash.crc64), !state->hash.crc64 || found == modded_textures.end())
|
||||
return RETURN_OK;
|
||||
|
||||
const auto textureFileStruct = found->second;
|
||||
|
||||
IDirect3DBaseTexture9* fake_texture = nullptr;
|
||||
TexState* fake_state = nullptr;
|
||||
if (const int ret = LoadTexture(textureFileStruct, &fake_texture, &fake_state); ret != RETURN_OK)
|
||||
return ret;
|
||||
|
||||
Switch(state, fake_state);
|
||||
fake_state->reference = textureFileStruct;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
int TextureClient::LoadTexture(TextureFileStruct* file_in_memory, IDirect3DBaseTexture9** ppTexture, TexState** ppState)
|
||||
{
|
||||
Message("LoadTexture( %p, %#lX): %p\n", file_in_memory, file_in_memory->crc_hash, this);
|
||||
*ppTexture = nullptr;
|
||||
*ppState = nullptr;
|
||||
|
||||
// CreateDDSTextureFromMemoryEx calls the hooked CreateTexture; loading_fake
|
||||
// makes that hook register the result as a fake, not a game original.
|
||||
IDirect3DTexture9* texture = nullptr;
|
||||
loading_fake = true;
|
||||
const auto ret = DirectX::CreateDDSTextureFromMemoryEx(
|
||||
D3D9Device,
|
||||
file_in_memory->data.data(),
|
||||
file_in_memory->data.size(),
|
||||
0, D3DPOOL_MANAGED, false,
|
||||
&texture);
|
||||
loading_fake = false;
|
||||
|
||||
if (ret != D3D_OK || texture == nullptr) {
|
||||
Warning("LoadDDSTexture (%p, %#lX): FAILED ret: \n", file_in_memory->data.data(), file_in_memory->crc_hash, ret);
|
||||
return RETURN_TEXTURE_NOT_LOADED;
|
||||
}
|
||||
|
||||
const auto fake = static_cast<IDirect3DBaseTexture9*>(texture);
|
||||
const auto state_it = fakes.find(fake);
|
||||
ASSERT(state_it != fakes.end()); // must have been registered by the CreateTexture hook
|
||||
*ppTexture = fake;
|
||||
*ppState = state_it->second;
|
||||
|
||||
Message("LoadTexture (%p, %#lX): DONE\n", fake, file_in_memory->crc_hash);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
IDirect3DBaseTexture9* TextureClient::ResolveBinding(IDirect3DBaseTexture9* texture)
|
||||
{
|
||||
if (texture == nullptr) return nullptr;
|
||||
std::lock_guard lk(registry_mutex);
|
||||
const auto it = originals.find(texture);
|
||||
if (it != originals.end() && it->second->partner != nullptr) {
|
||||
return it->second->partner->real; // bind the fake in place of the original
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
IDirect3DBaseTexture9* TextureClient::ResolveOriginalFromFake(IDirect3DBaseTexture9* texture)
|
||||
{
|
||||
if (texture == nullptr) return nullptr;
|
||||
std::lock_guard lk(registry_mutex);
|
||||
const auto it = fakes.find(texture);
|
||||
if (it != fakes.end() && it->second->partner != nullptr) {
|
||||
return it->second->partner->real;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TextureClient::OnBeginScene()
|
||||
{
|
||||
{
|
||||
std::lock_guard lk(registry_mutex);
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
if (last_created[type] != nullptr) {
|
||||
AddTexture(last_created[type]); // hashes + clears the slot
|
||||
}
|
||||
}
|
||||
}
|
||||
MergeUpdate();
|
||||
}
|
||||
|
||||
void TextureClient::OnUpdateTexture(IDirect3DBaseTexture9* source, IDirect3DBaseTexture9* destination)
|
||||
{
|
||||
// The copy already happened; re-hash both textures and re-run the mod lookup.
|
||||
std::lock_guard lk(registry_mutex);
|
||||
|
||||
auto refresh = [this](IDirect3DBaseTexture9* texture) {
|
||||
const auto it = originals.find(texture);
|
||||
if (it == originals.end()) return;
|
||||
const auto state = it->second;
|
||||
const auto hash = GetTextureHash(state);
|
||||
if (hash == state->hash) return; // unchanged
|
||||
state->hash = hash;
|
||||
if (state->partner != nullptr) UnswitchAndRelease(state);
|
||||
if (hash) LookUpToMod(state);
|
||||
};
|
||||
refresh(source);
|
||||
refresh(destination);
|
||||
}
|
||||
|
||||
void TextureClient::OnReleaseTexture(IDirect3DBaseTexture9* texture)
|
||||
{
|
||||
std::lock_guard lk(registry_mutex);
|
||||
if (shutting_down) return; // ~TextureClient is tearing everything down itself
|
||||
|
||||
// A fake of ours being released (either by us during cleanup, or transitively).
|
||||
if (const auto fit = fakes.find(texture); fit != fakes.end()) {
|
||||
const auto state = fit->second;
|
||||
if (state->partner != nullptr) state->partner->partner = nullptr;
|
||||
fakes.erase(fit);
|
||||
delete state;
|
||||
return;
|
||||
}
|
||||
|
||||
// A game texture (original) reaching zero references.
|
||||
if (const auto oit = originals.find(texture); oit != originals.end()) {
|
||||
const auto state = oit->second;
|
||||
if (last_created[static_cast<int>(state->type)] == texture) {
|
||||
last_created[static_cast<int>(state->type)] = nullptr;
|
||||
}
|
||||
originals.erase(oit);
|
||||
UnswitchAndRelease(state); // release the fake we held for it, if any
|
||||
delete state;
|
||||
}
|
||||
}
|
||||
|
||||
int TextureClient::MergeUpdate()
|
||||
{
|
||||
const bool has_pending = pending_ops.with([](auto& ops) { return !ops.empty(); });
|
||||
if (!should_update && !has_pending) return RETURN_OK;
|
||||
if (const int ret = LockMutex()) {
|
||||
gl_ErrorState |= uMod_ERROR_TEXTURE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Message("MergeUpdate(): %p\n", this);
|
||||
|
||||
ProcessPendingOps();
|
||||
|
||||
{
|
||||
std::lock_guard lk(registry_mutex);
|
||||
for (const auto state : originals | std::views::values) {
|
||||
if (state->partner == nullptr && state->hash) {
|
||||
LookUpToMod(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
should_update = false;
|
||||
return UnlockMutex();
|
||||
}
|
||||
|
||||
void TextureClient::EnqueueAdd(HashType hash, std::vector<BYTE> data)
|
||||
{
|
||||
if (!hash) return;
|
||||
pending_ops.with([&](auto& ops) { ops.push_back(PendingOp{PendingOp::Kind::Add, hash, std::move(data)}); });
|
||||
}
|
||||
|
||||
void TextureClient::EnqueueRemove(HashType hash)
|
||||
{
|
||||
if (!hash) return;
|
||||
pending_ops.with([&](auto& ops) { ops.push_back(PendingOp{PendingOp::Kind::Remove, hash, {}}); });
|
||||
}
|
||||
|
||||
void TextureClient::ProcessPendingOps()
|
||||
{
|
||||
std::vector<PendingOp> ops;
|
||||
pending_ops.with([&](auto& pending) { ops.swap(pending); });
|
||||
for (auto& op : ops) {
|
||||
if (op.kind == PendingOp::Kind::Add) {
|
||||
if (modded_textures.contains(op.hash)) continue;
|
||||
const auto texture_file_struct = new TextureFileStruct();
|
||||
texture_file_struct->crc_hash = op.hash;
|
||||
texture_file_struct->data = std::move(op.data);
|
||||
modded_textures.emplace(op.hash, texture_file_struct);
|
||||
should_update = true;
|
||||
}
|
||||
else {
|
||||
RemoveModdedTexture(op.hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextureClient::RemoveModdedTexture(HashType hash)
|
||||
{
|
||||
const auto it = modded_textures.find(hash);
|
||||
if (it == modded_textures.end()) return;
|
||||
const auto texture_file_struct = it->second;
|
||||
|
||||
{
|
||||
std::lock_guard lk(registry_mutex);
|
||||
for (const auto original : originals | std::views::values) {
|
||||
const auto fake = original->partner;
|
||||
if (fake != nullptr && fake->reference == texture_file_struct) {
|
||||
UnswitchAndRelease(original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modded_textures.erase(it);
|
||||
delete texture_file_struct;
|
||||
}
|
||||
|
||||
int TextureClient::LockMutex()
|
||||
{
|
||||
if ((gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX))) {
|
||||
return RETURN_NO_MUTEX;
|
||||
}
|
||||
if (WAIT_OBJECT_0 != WaitForSingleObject(hMutex, 100)) {
|
||||
return RETURN_MUTEX_LOCK; // waiting 100ms, to wait infinite pass INFINITE
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
int TextureClient::UnlockMutex()
|
||||
{
|
||||
if (ReleaseMutex(hMutex) == 0) {
|
||||
return RETURN_MUTEX_UNLOCK;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
gsl::owner<TextureFileStruct*> MakeTextureFileStruct(TexEntry& entry, const bool compress)
|
||||
{
|
||||
const auto texture_file_struct = new TextureFileStruct();
|
||||
texture_file_struct->crc_hash = entry.crc_hash;
|
||||
const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress);
|
||||
texture_file_struct->data.assign(static_cast<BYTE*>(dds_blob.GetBufferPointer()), static_cast<BYTE*>(dds_blob.GetBufferPointer()) + dds_blob.GetBufferSize());
|
||||
return texture_file_struct;
|
||||
}
|
||||
|
||||
std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem::path& modfile, const bool compress)
|
||||
{
|
||||
const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
if (FAILED(hr)) return {};
|
||||
const auto modfile_str = modfile.string();
|
||||
Message("Initialize: loading file %s... ", modfile_str.c_str());
|
||||
auto file_loader = ModfileLoader(modfile);
|
||||
auto entries = file_loader.GetContents();
|
||||
if (entries.empty()) {
|
||||
Message("No entries found.\n");
|
||||
CoUninitialize();
|
||||
return {};
|
||||
}
|
||||
Message("%zu textures... ", entries.size());
|
||||
std::vector<gsl::owner<TextureFileStruct*>> texture_file_structs;
|
||||
texture_file_structs.reserve(entries.size());
|
||||
unsigned file_bytes_loaded = 0;
|
||||
for (auto& tpf_entry : entries) {
|
||||
const auto texture_file_struct = MakeTextureFileStruct(tpf_entry, compress);
|
||||
texture_file_structs.push_back(texture_file_struct);
|
||||
file_bytes_loaded += static_cast<unsigned>(texture_file_structs.back()->data.size());
|
||||
}
|
||||
entries.clear();
|
||||
Message("%d bytes loaded.\n", file_bytes_loaded);
|
||||
CoUninitialize();
|
||||
return texture_file_structs;
|
||||
}
|
||||
|
||||
std::vector<HashType> TextureClient::IngestModfile(std::vector<gsl::owner<TextureFileStruct*>>& texture_file_structs, uint64_t* loaded_bytes)
|
||||
{
|
||||
std::vector<HashType> hashes;
|
||||
for (auto* texture_file_struct : texture_file_structs) {
|
||||
const auto hash = texture_file_struct->crc_hash;
|
||||
if (hash && std::ranges::find(hashes, hash) == hashes.end()) {
|
||||
hashes.push_back(hash);
|
||||
if (loaded_bytes) *loaded_bytes += texture_file_struct->data.size();
|
||||
if (current_client) {
|
||||
current_client->EnqueueAdd(hash, std::move(texture_file_struct->data));
|
||||
}
|
||||
}
|
||||
delete texture_file_struct;
|
||||
}
|
||||
texture_file_structs.clear();
|
||||
return hashes;
|
||||
}
|
||||
|
||||
std::vector<std::filesystem::path> TextureClient::GetFiles()
|
||||
{
|
||||
std::lock_guard lk(global_mutex);
|
||||
std::vector<std::filesystem::path> result;
|
||||
result.reserve(loaded_files.size());
|
||||
for (const auto& loaded_file : loaded_files) {
|
||||
result.push_back(loaded_file.path);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int TextureClient::RemoveFile(const std::filesystem::path& path)
|
||||
{
|
||||
const auto absolute_path = std::filesystem::absolute(path);
|
||||
std::lock_guard lk(global_mutex);
|
||||
const auto it = FindLoadedFile(absolute_path);
|
||||
if (it == loaded_files.end()) return RETURN_FILE_NOT_LOADED;
|
||||
if (current_client) {
|
||||
for (const auto hash : it->hashes) {
|
||||
current_client->EnqueueRemove(hash);
|
||||
}
|
||||
}
|
||||
loaded_files.erase(it);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
int TextureClient::AddFile(const std::filesystem::path& path)
|
||||
{
|
||||
const auto absolute_path = std::filesystem::absolute(path);
|
||||
{
|
||||
std::lock_guard lk(global_mutex);
|
||||
if (FindLoadedFile(absolute_path) != loaded_files.end()) return RETURN_EXISTS;
|
||||
}
|
||||
if (!std::filesystem::exists(absolute_path)) return RETURN_FILE_NOT_LOADED;
|
||||
|
||||
const auto file_size = std::filesystem::file_size(absolute_path);
|
||||
auto texture_file_structs = ProcessModfile(absolute_path, file_size > 400'000'000);
|
||||
if (texture_file_structs.empty()) return RETURN_FILE_NOT_LOADED;
|
||||
|
||||
std::lock_guard lk(global_mutex);
|
||||
// Re-check under lock; another thread may have loaded the same path concurrently.
|
||||
if (FindLoadedFile(absolute_path) != loaded_files.end()) {
|
||||
for (auto* texture_file_struct : texture_file_structs)
|
||||
delete texture_file_struct;
|
||||
return RETURN_EXISTS;
|
||||
}
|
||||
|
||||
auto hashes = IngestModfile(texture_file_structs);
|
||||
if (hashes.empty()) return RETURN_TEXTURE_NOT_LOADED;
|
||||
loaded_files.push_back({absolute_path, std::move(hashes)});
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void TextureClient::LoadStartupModlists()
|
||||
{
|
||||
std::locale::global(std::locale(""));
|
||||
std::vector<std::filesystem::path> modfiles;
|
||||
for (const auto& content : modlists_contents | std::views::values) {
|
||||
std::istringstream iss(content);
|
||||
std::string line;
|
||||
while (std::getline(iss, line)) {
|
||||
if (line.starts_with("//") || line.starts_with("#") || line.empty()) {
|
||||
continue;
|
||||
}
|
||||
// Remove newline character
|
||||
line.erase(std::ranges::remove(line, '\r').begin(), line.end());
|
||||
line.erase(std::ranges::remove(line, '\n').begin(), line.end());
|
||||
if (line.empty()) continue;
|
||||
|
||||
auto modfile = std::filesystem::absolute(std::filesystem::path(utils::utf8_to_wstring(line)));
|
||||
if (!std::ranges::contains(modfiles, modfile)) {
|
||||
modfiles.push_back(std::move(modfile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto total_size = 0ull;
|
||||
for (const auto& modfile : modfiles) {
|
||||
if (std::filesystem::exists(modfile)) total_size += std::filesystem::file_size(modfile);
|
||||
}
|
||||
const bool compress = total_size > 400'000'000;
|
||||
|
||||
std::vector<std::future<std::vector<gsl::owner<TextureFileStruct*>>>> futures;
|
||||
futures.reserve(modfiles.size());
|
||||
for (const auto& modfile : modfiles) {
|
||||
futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, compress));
|
||||
}
|
||||
auto loaded_size = 0ull;
|
||||
for (size_t i = 0; i < modfiles.size(); ++i) {
|
||||
auto texture_file_structs = futures[i].get();
|
||||
|
||||
std::lock_guard lk(global_mutex);
|
||||
if (FindLoadedFile(modfiles[i]) != loaded_files.end()) {
|
||||
for (const auto* texture_file_struct : texture_file_structs)
|
||||
delete texture_file_struct;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto hashes = IngestModfile(texture_file_structs, &loaded_size);
|
||||
if (!hashes.empty()) {
|
||||
loaded_files.push_back({modfiles[i], std::move(hashes)});
|
||||
}
|
||||
}
|
||||
Info("LoadStartupModlists: %llu bytes (%llu MB)\n", loaded_size, loaded_size / 1024 / 1024);
|
||||
}
|
||||
|
||||
void TextureClient::Initialize()
|
||||
{
|
||||
const auto t1 = std::chrono::high_resolution_clock::now();
|
||||
Info("Initialize: begin\n");
|
||||
|
||||
// AddFile() before the device existed recorded files but couldn't enqueue them
|
||||
// (no client yet); enqueue them now.
|
||||
for (const auto& path : GetFiles()) {
|
||||
if (!std::filesystem::exists(path)) continue;
|
||||
const auto file_size = std::filesystem::file_size(path);
|
||||
auto texture_file_structs = ProcessModfile(path, file_size > 400'000'000);
|
||||
IngestModfile(texture_file_structs);
|
||||
}
|
||||
|
||||
LoadStartupModlists();
|
||||
|
||||
const auto t2 = std::chrono::high_resolution_clock::now();
|
||||
const auto ms = duration_cast<std::chrono::milliseconds>(t2 - t1);
|
||||
Info("Initialize: end, took %d ms\n", ms);
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
module;
|
||||
|
||||
#include "Main.h"
|
||||
#include <d3d9types.h>
|
||||
#include <DirectXTex/DirectXTex.h>
|
||||
|
||||
export module TextureFunction;
|
||||
|
||||
// clang-format off
|
||||
constexpr auto crctab64 = std::to_array({
|
||||
0x0000000000000000ULL, 0x7ad870c830358979ULL, 0xf5b0e190606b12f2ULL,
|
||||
0x8f689158505e9b8bULL, 0xc038e5739841b68fULL, 0xbae095bba8743ff6ULL,
|
||||
0x358804e3f82aa47dULL, 0x4f50742bc81f2d04ULL, 0xab28ecb46814fe75ULL,
|
||||
0xd1f09c7c5821770cULL, 0x5e980d24087fec87ULL, 0x24407dec384a65feULL,
|
||||
0x6b1009c7f05548faULL, 0x11c8790fc060c183ULL, 0x9ea0e857903e5a08ULL,
|
||||
0xe478989fa00bd371ULL, 0x7d08ff3b88be6f81ULL, 0x07d08ff3b88be6f8ULL,
|
||||
0x88b81eabe8d57d73ULL, 0xf2606e63d8e0f40aULL, 0xbd301a4810ffd90eULL,
|
||||
0xc7e86a8020ca5077ULL, 0x4880fbd87094cbfcULL, 0x32588b1040a14285ULL,
|
||||
0xd620138fe0aa91f4ULL, 0xacf86347d09f188dULL, 0x2390f21f80c18306ULL,
|
||||
0x594882d7b0f40a7fULL, 0x1618f6fc78eb277bULL, 0x6cc0863448deae02ULL,
|
||||
0xe3a8176c18803589ULL, 0x997067a428b5bcf0ULL, 0xfa11fe77117cdf02ULL,
|
||||
0x80c98ebf2149567bULL, 0x0fa11fe77117cdf0ULL, 0x75796f2f41224489ULL,
|
||||
0x3a291b04893d698dULL, 0x40f16bccb908e0f4ULL, 0xcf99fa94e9567b7fULL,
|
||||
0xb5418a5cd963f206ULL, 0x513912c379682177ULL, 0x2be1620b495da80eULL,
|
||||
0xa489f35319033385ULL, 0xde51839b2936bafcULL, 0x9101f7b0e12997f8ULL,
|
||||
0xebd98778d11c1e81ULL, 0x64b116208142850aULL, 0x1e6966e8b1770c73ULL,
|
||||
0x8719014c99c2b083ULL, 0xfdc17184a9f739faULL, 0x72a9e0dcf9a9a271ULL,
|
||||
0x08719014c99c2b08ULL, 0x4721e43f0183060cULL, 0x3df994f731b68f75ULL,
|
||||
0xb29105af61e814feULL, 0xc849756751dd9d87ULL, 0x2c31edf8f1d64ef6ULL,
|
||||
0x56e99d30c1e3c78fULL, 0xd9810c6891bd5c04ULL, 0xa3597ca0a188d57dULL,
|
||||
0xec09088b6997f879ULL, 0x96d1784359a27100ULL, 0x19b9e91b09fcea8bULL,
|
||||
0x636199d339c963f2ULL, 0xdf7adabd7a6e2d6fULL, 0xa5a2aa754a5ba416ULL,
|
||||
0x2aca3b2d1a053f9dULL, 0x50124be52a30b6e4ULL, 0x1f423fcee22f9be0ULL,
|
||||
0x659a4f06d21a1299ULL, 0xeaf2de5e82448912ULL, 0x902aae96b271006bULL,
|
||||
0x74523609127ad31aULL, 0x0e8a46c1224f5a63ULL, 0x81e2d7997211c1e8ULL,
|
||||
0xfb3aa75142244891ULL, 0xb46ad37a8a3b6595ULL, 0xceb2a3b2ba0eececULL,
|
||||
0x41da32eaea507767ULL, 0x3b024222da65fe1eULL, 0xa2722586f2d042eeULL,
|
||||
0xd8aa554ec2e5cb97ULL, 0x57c2c41692bb501cULL, 0x2d1ab4dea28ed965ULL,
|
||||
0x624ac0f56a91f461ULL, 0x1892b03d5aa47d18ULL, 0x97fa21650afae693ULL,
|
||||
0xed2251ad3acf6feaULL, 0x095ac9329ac4bc9bULL, 0x7382b9faaaf135e2ULL,
|
||||
0xfcea28a2faafae69ULL, 0x8632586aca9a2710ULL, 0xc9622c4102850a14ULL,
|
||||
0xb3ba5c8932b0836dULL, 0x3cd2cdd162ee18e6ULL, 0x460abd1952db919fULL,
|
||||
0x256b24ca6b12f26dULL, 0x5fb354025b277b14ULL, 0xd0dbc55a0b79e09fULL,
|
||||
0xaa03b5923b4c69e6ULL, 0xe553c1b9f35344e2ULL, 0x9f8bb171c366cd9bULL,
|
||||
0x10e3202993385610ULL, 0x6a3b50e1a30ddf69ULL, 0x8e43c87e03060c18ULL,
|
||||
0xf49bb8b633338561ULL, 0x7bf329ee636d1eeaULL, 0x012b592653589793ULL,
|
||||
0x4e7b2d0d9b47ba97ULL, 0x34a35dc5ab7233eeULL, 0xbbcbcc9dfb2ca865ULL,
|
||||
0xc113bc55cb19211cULL, 0x5863dbf1e3ac9decULL, 0x22bbab39d3991495ULL,
|
||||
0xadd33a6183c78f1eULL, 0xd70b4aa9b3f20667ULL, 0x985b3e827bed2b63ULL,
|
||||
0xe2834e4a4bd8a21aULL, 0x6debdf121b863991ULL, 0x1733afda2bb3b0e8ULL,
|
||||
0xf34b37458bb86399ULL, 0x8993478dbb8deae0ULL, 0x06fbd6d5ebd3716bULL,
|
||||
0x7c23a61ddbe6f812ULL, 0x3373d23613f9d516ULL, 0x49aba2fe23cc5c6fULL,
|
||||
0xc6c333a67392c7e4ULL, 0xbc1b436e43a74e9dULL, 0x95ac9329ac4bc9b5ULL,
|
||||
0xef74e3e19c7e40ccULL, 0x601c72b9cc20db47ULL, 0x1ac40271fc15523eULL,
|
||||
0x5594765a340a7f3aULL, 0x2f4c0692043ff643ULL, 0xa02497ca54616dc8ULL,
|
||||
0xdafce7026454e4b1ULL, 0x3e847f9dc45f37c0ULL, 0x445c0f55f46abeb9ULL,
|
||||
0xcb349e0da4342532ULL, 0xb1eceec59401ac4bULL, 0xfebc9aee5c1e814fULL,
|
||||
0x8464ea266c2b0836ULL, 0x0b0c7b7e3c7593bdULL, 0x71d40bb60c401ac4ULL,
|
||||
0xe8a46c1224f5a634ULL, 0x927c1cda14c02f4dULL, 0x1d148d82449eb4c6ULL,
|
||||
0x67ccfd4a74ab3dbfULL, 0x289c8961bcb410bbULL, 0x5244f9a98c8199c2ULL,
|
||||
0xdd2c68f1dcdf0249ULL, 0xa7f41839ecea8b30ULL, 0x438c80a64ce15841ULL,
|
||||
0x3954f06e7cd4d138ULL, 0xb63c61362c8a4ab3ULL, 0xcce411fe1cbfc3caULL,
|
||||
0x83b465d5d4a0eeceULL, 0xf96c151de49567b7ULL, 0x76048445b4cbfc3cULL,
|
||||
0x0cdcf48d84fe7545ULL, 0x6fbd6d5ebd3716b7ULL, 0x15651d968d029fceULL,
|
||||
0x9a0d8ccedd5c0445ULL, 0xe0d5fc06ed698d3cULL, 0xaf85882d2576a038ULL,
|
||||
0xd55df8e515432941ULL, 0x5a3569bd451db2caULL, 0x20ed197575283bb3ULL,
|
||||
0xc49581ead523e8c2ULL, 0xbe4df122e51661bbULL, 0x3125607ab548fa30ULL,
|
||||
0x4bfd10b2857d7349ULL, 0x04ad64994d625e4dULL, 0x7e7514517d57d734ULL,
|
||||
0xf11d85092d094cbfULL, 0x8bc5f5c11d3cc5c6ULL, 0x12b5926535897936ULL,
|
||||
0x686de2ad05bcf04fULL, 0xe70573f555e26bc4ULL, 0x9ddd033d65d7e2bdULL,
|
||||
0xd28d7716adc8cfb9ULL, 0xa85507de9dfd46c0ULL, 0x273d9686cda3dd4bULL,
|
||||
0x5de5e64efd965432ULL, 0xb99d7ed15d9d8743ULL, 0xc3450e196da80e3aULL,
|
||||
0x4c2d9f413df695b1ULL, 0x36f5ef890dc31cc8ULL, 0x79a59ba2c5dc31ccULL,
|
||||
0x037deb6af5e9b8b5ULL, 0x8c157a32a5b7233eULL, 0xf6cd0afa9582aa47ULL,
|
||||
0x4ad64994d625e4daULL, 0x300e395ce6106da3ULL, 0xbf66a804b64ef628ULL,
|
||||
0xc5bed8cc867b7f51ULL, 0x8aeeace74e645255ULL, 0xf036dc2f7e51db2cULL,
|
||||
0x7f5e4d772e0f40a7ULL, 0x05863dbf1e3ac9deULL, 0xe1fea520be311aafULL,
|
||||
0x9b26d5e88e0493d6ULL, 0x144e44b0de5a085dULL, 0x6e963478ee6f8124ULL,
|
||||
0x21c640532670ac20ULL, 0x5b1e309b16452559ULL, 0xd476a1c3461bbed2ULL,
|
||||
0xaeaed10b762e37abULL, 0x37deb6af5e9b8b5bULL, 0x4d06c6676eae0222ULL,
|
||||
0xc26e573f3ef099a9ULL, 0xb8b627f70ec510d0ULL, 0xf7e653dcc6da3dd4ULL,
|
||||
0x8d3e2314f6efb4adULL, 0x0256b24ca6b12f26ULL, 0x788ec2849684a65fULL,
|
||||
0x9cf65a1b368f752eULL, 0xe62e2ad306bafc57ULL, 0x6946bb8b56e467dcULL,
|
||||
0x139ecb4366d1eea5ULL, 0x5ccebf68aecec3a1ULL, 0x2616cfa09efb4ad8ULL,
|
||||
0xa97e5ef8cea5d153ULL, 0xd3a62e30fe90582aULL, 0xb0c7b7e3c7593bd8ULL,
|
||||
0xca1fc72bf76cb2a1ULL, 0x45775673a732292aULL, 0x3faf26bb9707a053ULL,
|
||||
0x70ff52905f188d57ULL, 0x0a2722586f2d042eULL, 0x854fb3003f739fa5ULL,
|
||||
0xff97c3c80f4616dcULL, 0x1bef5b57af4dc5adULL, 0x61372b9f9f784cd4ULL,
|
||||
0xee5fbac7cf26d75fULL, 0x9487ca0fff135e26ULL, 0xdbd7be24370c7322ULL,
|
||||
0xa10fceec0739fa5bULL, 0x2e675fb4576761d0ULL, 0x54bf2f7c6752e8a9ULL,
|
||||
0xcdcf48d84fe75459ULL, 0xb71738107fd2dd20ULL, 0x387fa9482f8c46abULL,
|
||||
0x42a7d9801fb9cfd2ULL, 0x0df7adabd7a6e2d6ULL, 0x772fdd63e7936bafULL,
|
||||
0xf8474c3bb7cdf024ULL, 0x829f3cf387f8795dULL, 0x66e7a46c27f3aa2cULL,
|
||||
0x1c3fd4a417c62355ULL, 0x935745fc4798b8deULL, 0xe98f353477ad31a7ULL,
|
||||
0xa6df411fbfb21ca3ULL, 0xdc0731d78f8795daULL, 0x536fa08fdfd90e51ULL,
|
||||
0x29b7d047efec8728ULL
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
export namespace TextureFunction {
|
||||
|
||||
uint64_t get_crc64(const char* data, unsigned int length)
|
||||
{
|
||||
uint64_t crc = 0xFFFFFFFFFFFFFFFFULL;
|
||||
|
||||
while (length--) {
|
||||
crc = crctab64[(crc ^ *data++) & 0xFF] ^ (crc >> 8);
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
uint32_t get_crc32(const char* data_ptr, const unsigned int length)
|
||||
{
|
||||
constexpr static auto crc32_poly = 0xEDB88320u;
|
||||
constexpr static auto ul_crc_in = 0xffffffff;
|
||||
unsigned int crc = ul_crc_in;
|
||||
for (unsigned int idx = 0u; idx < length; idx++) {
|
||||
unsigned int data = *data_ptr++;
|
||||
for (unsigned int bit = 0u; bit < 8u; bit++, data >>= 1) {
|
||||
crc = crc >> 1 ^ ((crc ^ data) & 1 ? crc32_poly : 0);
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
int GetBitsFromFormat(D3DFORMAT format)
|
||||
{
|
||||
switch (format) // switch trough the formats to calculate the size of the raw data
|
||||
{
|
||||
case D3DFMT_A1: // 1-bit monochrome.
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
case D3DFMT_R3G3B2: // 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
|
||||
case D3DFMT_A8: // 8-bit alpha only.
|
||||
case D3DFMT_A8P8: // 8-bit color indexed with 8 bits of alpha.
|
||||
case D3DFMT_P8: // 8-bit color indexed.
|
||||
case D3DFMT_L8: // 8-bit luminance only.
|
||||
case D3DFMT_A4L4: // 8-bit using 4 bits each for alpha and luminance.
|
||||
case D3DFMT_FORCE_DWORD:
|
||||
case D3DFMT_S8_LOCKABLE: // A lockable 8-bit stencil buffer.
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
case D3DFMT_D16_LOCKABLE: // 16-bit z-buffer bit depth.
|
||||
case D3DFMT_D15S1: // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
|
||||
case D3DFMT_L6V5U5: // 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
|
||||
case D3DFMT_V8U8: // 16-bit bump-map format using 8 bits each for u and v data.
|
||||
case D3DFMT_CxV8U8: // 16-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 - U2 - V2).
|
||||
case D3DFMT_R5G6B5: // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
|
||||
case D3DFMT_X1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color.
|
||||
case D3DFMT_A1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
|
||||
case D3DFMT_A4R4G4B4: // 16-bit ARGB pixel format with 4 bits for each channel.
|
||||
case D3DFMT_A8R3G3B2: // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
|
||||
case D3DFMT_X4R4G4B4: // 16-bit RGB pixel format using 4 bits for each color.
|
||||
case D3DFMT_L16: // 16-bit luminance only.
|
||||
case D3DFMT_R16F: // 16-bit float format using 16 bits for the red channel.
|
||||
case D3DFMT_A8L8: // 16-bit using 8 bits each for alpha and luminance.
|
||||
case D3DFMT_D16: // 16-bit z-buffer bit depth.
|
||||
case D3DFMT_INDEX16: // 16-bit index buffer bit depth.
|
||||
case D3DFMT_G8R8_G8B8: // ??
|
||||
case D3DFMT_R8G8_B8G8: // ??
|
||||
case D3DFMT_UYVY: // ??
|
||||
case D3DFMT_YUY2: // ??
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
|
||||
case D3DFMT_R8G8B8: // 24-bit RGB pixel format with 8 bits per channel.
|
||||
{
|
||||
return 24;
|
||||
}
|
||||
|
||||
case D3DFMT_R32F: // 32-bit float format using 32 bits for the red channel.
|
||||
case D3DFMT_X8L8V8U8: // 32-bit bump-map format with luminance using 8 bits for each channel.
|
||||
case D3DFMT_A2W10V10U10: // 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.
|
||||
case D3DFMT_Q8W8V8U8: // 32-bit bump-map format using 8 bits for each channel.
|
||||
case D3DFMT_V16U16: // 32-bit bump-map format using 16 bits for each channel.
|
||||
case D3DFMT_A8R8G8B8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8R8G8B8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_A2B10G10R10: // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
|
||||
case D3DFMT_A8B8G8R8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8B8G8R8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_G16R16: // 32-bit pixel format using 16 bits each for green and red.
|
||||
case D3DFMT_G16R16F: // 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
|
||||
case D3DFMT_A2R10G10B10: // 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
|
||||
case D3DFMT_D32: // 32-bit z-buffer bit depth.
|
||||
case D3DFMT_D24S8: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
|
||||
case D3DFMT_D24X8: // 32-bit z-buffer bit depth using 24 bits for the depth channel.
|
||||
case D3DFMT_D24X4S4: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
|
||||
case D3DFMT_D32F_LOCKABLE: // A lockable format where the depth value is represented as a standard IEEE floating-point number.
|
||||
case D3DFMT_D24FS8: // A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
|
||||
case D3DFMT_D32_LOCKABLE: // A lockable 32-bit depth buffer.
|
||||
case D3DFMT_INDEX32: // 32-bit index buffer bit depth.
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
case D3DFMT_G32R32F: // 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
|
||||
case D3DFMT_Q16W16V16U16: // 64-bit bump-map format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16: // 64-bit pixel format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16F: // 64-bit float format using 16 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
case D3DFMT_A32B32G32R32F: // 128-bit float format using 32 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
case D3DFMT_DXT2:
|
||||
case D3DFMT_DXT3:
|
||||
case D3DFMT_DXT4:
|
||||
case D3DFMT_DXT5: {
|
||||
return 8;
|
||||
}
|
||||
case D3DFMT_DXT1: {
|
||||
return 4;
|
||||
}
|
||||
default: // compressed formats
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DirectX::ScratchImage ImageConvertToBGRA(DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8A8_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC1_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC2_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC3_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC4_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC5_UNORM) {
|
||||
return std::move(image);
|
||||
}
|
||||
DirectX::ScratchImage bgra_image;
|
||||
const HRESULT hr = DirectX::Convert(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
DirectX::TEX_FILTER_DEFAULT,
|
||||
DirectX::TEX_THRESHOLD_DEFAULT,
|
||||
bgra_image);
|
||||
if (FAILED(hr)) {
|
||||
Warning("ImageConvertToBGRA (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
bgra_image = std::move(image);
|
||||
}
|
||||
image.Release();
|
||||
return bgra_image;
|
||||
}
|
||||
|
||||
DirectX::ScratchImage ImageGenerateMipMaps(DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
if (entry.ext == ".dds") {
|
||||
return std::move(image);
|
||||
}
|
||||
DirectX::ScratchImage mipmapped_image;
|
||||
const auto hr = DirectX::GenerateMipMaps(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DirectX::TEX_FILTER_DEFAULT,
|
||||
0,
|
||||
mipmapped_image);
|
||||
if (FAILED(hr)) {
|
||||
Warning("GenerateMipMaps (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
mipmapped_image = std::move(image);
|
||||
}
|
||||
image.Release();
|
||||
return mipmapped_image;
|
||||
}
|
||||
|
||||
DirectX::ScratchImage ImageCompress(DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
if (image.GetMetadata().format == DXGI_FORMAT_BC1_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC2_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC3_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC4_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC5_UNORM) {
|
||||
return std::move(image);
|
||||
}
|
||||
DirectX::ScratchImage compressed_image;
|
||||
const auto hr = DirectX::Compress(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DXGI_FORMAT_BC3_UNORM,
|
||||
DirectX::TEX_COMPRESS_DEFAULT,
|
||||
DirectX::TEX_THRESHOLD_DEFAULT,
|
||||
compressed_image);
|
||||
if (FAILED(hr)) {
|
||||
Warning("ImageCompress (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
compressed_image = std::move(image);
|
||||
}
|
||||
image.Release();
|
||||
return compressed_image;
|
||||
}
|
||||
|
||||
void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
const auto file_name = std::format("0x{:x}.dds", entry.crc_hash);
|
||||
const auto file_out = gmod_dll_path.parent_path() / "textures" / file_name;
|
||||
try {
|
||||
if (std::filesystem::exists(file_out)) {
|
||||
return;
|
||||
}
|
||||
if (!std::filesystem::exists(file_out.parent_path())) {
|
||||
std::filesystem::create_directory(file_out.parent_path());
|
||||
}
|
||||
const auto hr = DirectX::SaveToDDSFile(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DirectX::DDS_FLAGS_NONE,
|
||||
file_out.c_str());
|
||||
if (FAILED(hr)) {
|
||||
Warning("SaveDDSImageToDisk (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
Warning("SaveDDSImageToDisk (%#lX%s): %s\n", entry.crc_hash, entry.ext.c_str(), e.what());
|
||||
}
|
||||
}
|
||||
|
||||
DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress)
|
||||
{
|
||||
DirectX::ScratchImage image;
|
||||
HRESULT hr = 0;
|
||||
|
||||
if (entry.ext == ".dds") {
|
||||
hr = DirectX::LoadFromDDSMemory(entry.data.data(), entry.data.size(), DirectX::DDS_FLAGS_NONE, nullptr, image);
|
||||
}
|
||||
else if (entry.ext == ".tga") {
|
||||
hr = DirectX::LoadFromTGAMemory(entry.data.data(), entry.data.size(), DirectX::TGA_FLAGS_BGR, nullptr, image);
|
||||
}
|
||||
else if (entry.ext == ".hdr") {
|
||||
hr = DirectX::LoadFromHDRMemory(entry.data.data(), entry.data.size(), nullptr, image);
|
||||
}
|
||||
else {
|
||||
hr = DirectX::LoadFromWICMemory(entry.data.data(), entry.data.size(), DirectX::WIC_FLAGS_NONE, nullptr, image);
|
||||
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8X8_UNORM) {
|
||||
image.OverrideFormat(DXGI_FORMAT_B8G8R8A8_UNORM);
|
||||
}
|
||||
}
|
||||
entry.data.clear();
|
||||
if (FAILED(hr)) {
|
||||
Warning("LoadImageFromMemory (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto bgra_image = ImageConvertToBGRA(image, entry);
|
||||
auto mipmapped_image = ImageGenerateMipMaps(bgra_image, entry);
|
||||
const auto compressed_image = compress ? ImageCompress(mipmapped_image, entry) : std::move(mipmapped_image);
|
||||
|
||||
DirectX::Blob dds_blob;
|
||||
hr = DirectX::SaveToDDSMemory(
|
||||
compressed_image.GetImages(),
|
||||
compressed_image.GetImageCount(),
|
||||
compressed_image.GetMetadata(),
|
||||
DirectX::DDS_FLAGS_NONE,
|
||||
dds_blob);
|
||||
if (FAILED(hr)) {
|
||||
Warning("SaveDDSImageToMemory (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
ImageSave(compressed_image, entry);
|
||||
#endif
|
||||
return dds_blob;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
#include "Main.h"
|
||||
#include "D3D9Hooks.h"
|
||||
#include "MinHook.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
import TextureClient;
|
||||
import TextureFunction;
|
||||
import ModfileLoader; // HashCheck::Use64BitCrc
|
||||
|
||||
// Hooked vtable slot indices (frozen D3D9 ABI). Device9Ex shares Device9's prefix.
|
||||
|
||||
namespace {
|
||||
|
||||
// --- IDirect3D9 / IDirect3D9Ex --------------------------------------
|
||||
constexpr int kIDirect3D9_CreateDevice = 16;
|
||||
constexpr int kIDirect3D9Ex_CreateDeviceEx = 20;
|
||||
|
||||
// --- IDirect3DDevice9 -----------------------------------------------
|
||||
constexpr int kDevice_Release = 2;
|
||||
constexpr int kDevice_CreateTexture = 23;
|
||||
constexpr int kDevice_CreateVolumeTexture = 24;
|
||||
constexpr int kDevice_CreateCubeTexture = 25;
|
||||
constexpr int kDevice_UpdateTexture = 31;
|
||||
constexpr int kDevice_BeginScene = 41;
|
||||
constexpr int kDevice_GetTexture = 64;
|
||||
constexpr int kDevice_SetTexture = 65;
|
||||
|
||||
// --- IDirect3D*Texture9 (IUnknown layout) ---------------------------
|
||||
constexpr int kResource_Release = 2;
|
||||
|
||||
void** GetVTable(void* com_object)
|
||||
{
|
||||
return *static_cast<void***>(com_object);
|
||||
}
|
||||
|
||||
// ---- trampolines to the real implementations -----------------------
|
||||
using CreateDevice_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3D9*, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, IDirect3DDevice9**);
|
||||
using CreateDeviceEx_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3D9Ex*, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, D3DDISPLAYMODEEX*, IDirect3DDevice9Ex**);
|
||||
using DeviceRelease_t = ULONG(STDMETHODCALLTYPE*)(IDirect3DDevice9*);
|
||||
using CreateTexture_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*, UINT, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, IDirect3DTexture9**, HANDLE*);
|
||||
using CreateVolumeTexture_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*, UINT, UINT, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, IDirect3DVolumeTexture9**, HANDLE*);
|
||||
using CreateCubeTexture_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, IDirect3DCubeTexture9**, HANDLE*);
|
||||
using UpdateTexture_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*, IDirect3DBaseTexture9*, IDirect3DBaseTexture9*);
|
||||
using BeginScene_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*);
|
||||
using SetTexture_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*, DWORD, IDirect3DBaseTexture9*);
|
||||
using GetTexture_t = HRESULT(STDMETHODCALLTYPE*)(IDirect3DDevice9*, DWORD, IDirect3DBaseTexture9**);
|
||||
using ResourceRelease_t = ULONG(STDMETHODCALLTYPE*)(IUnknown*);
|
||||
|
||||
CreateDevice_t o_CreateDevice = nullptr;
|
||||
CreateDeviceEx_t o_CreateDeviceEx = nullptr;
|
||||
DeviceRelease_t o_DeviceRelease = nullptr;
|
||||
CreateTexture_t o_CreateTexture = nullptr;
|
||||
CreateVolumeTexture_t o_CreateVolumeTexture = nullptr;
|
||||
CreateCubeTexture_t o_CreateCubeTexture = nullptr;
|
||||
UpdateTexture_t o_UpdateTexture = nullptr;
|
||||
BeginScene_t o_BeginScene = nullptr;
|
||||
SetTexture_t o_SetTexture = nullptr;
|
||||
GetTexture_t o_GetTexture = nullptr;
|
||||
ResourceRelease_t o_Tex2DRelease = nullptr;
|
||||
ResourceRelease_t o_VolumeRelease = nullptr;
|
||||
ResourceRelease_t o_CubeRelease = nullptr;
|
||||
|
||||
// A vtable is shared by every instance of its class, so each is hooked once.
|
||||
bool g_d3d9_hooks_installed = false;
|
||||
bool g_device_hooks_installed = false;
|
||||
bool g_tex2d_release_installed = false;
|
||||
bool g_volume_release_installed = false;
|
||||
bool g_cube_release_installed = false;
|
||||
|
||||
std::vector<void*> g_hooked_targets;
|
||||
|
||||
// Set when teardown begins; a detour still reached after this just calls the original.
|
||||
std::atomic<bool> g_unhooked{false};
|
||||
|
||||
// device -> owning TextureClient
|
||||
std::mutex g_devices_mutex;
|
||||
std::unordered_map<IDirect3DDevice9*, TextureClient*> g_devices;
|
||||
|
||||
TextureClient* ClientFor(IDirect3DDevice9* device)
|
||||
{
|
||||
std::lock_guard lk(g_devices_mutex);
|
||||
const auto it = g_devices.find(device);
|
||||
return it != g_devices.end() ? it->second : nullptr;
|
||||
}
|
||||
|
||||
bool HookRaw(void* target, void* detour, void** original)
|
||||
{
|
||||
if (target == nullptr) return false;
|
||||
if (MH_CreateHook(target, detour, original) != MH_OK) {
|
||||
Warning("D3D9Hooks: MH_CreateHook failed for %p\n", target);
|
||||
return false;
|
||||
}
|
||||
if (MH_EnableHook(target) != MH_OK) {
|
||||
Warning("D3D9Hooks: MH_EnableHook failed for %p\n", target);
|
||||
return false;
|
||||
}
|
||||
g_hooked_targets.push_back(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Funnels the fn-ptr <-> void* casts through one spot so call sites stay /WX-clean.
|
||||
template <typename TDetour, typename TOrig>
|
||||
bool Hook(void* target, TDetour detour, TOrig* original)
|
||||
{
|
||||
return HookRaw(target, reinterpret_cast<void*>(detour), reinterpret_cast<void**>(original));
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_CreateDevice(IDirect3D9*, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, IDirect3DDevice9**);
|
||||
HRESULT STDMETHODCALLTYPE h_CreateDeviceEx(IDirect3D9Ex*, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, D3DDISPLAYMODEEX*, IDirect3DDevice9Ex**);
|
||||
ULONG STDMETHODCALLTYPE h_DeviceRelease(IDirect3DDevice9*);
|
||||
HRESULT STDMETHODCALLTYPE h_CreateTexture(IDirect3DDevice9*, UINT, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, IDirect3DTexture9**, HANDLE*);
|
||||
HRESULT STDMETHODCALLTYPE h_CreateVolumeTexture(IDirect3DDevice9*, UINT, UINT, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, IDirect3DVolumeTexture9**, HANDLE*);
|
||||
HRESULT STDMETHODCALLTYPE h_CreateCubeTexture(IDirect3DDevice9*, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, IDirect3DCubeTexture9**, HANDLE*);
|
||||
HRESULT STDMETHODCALLTYPE h_UpdateTexture(IDirect3DDevice9*, IDirect3DBaseTexture9*, IDirect3DBaseTexture9*);
|
||||
HRESULT STDMETHODCALLTYPE h_BeginScene(IDirect3DDevice9*);
|
||||
HRESULT STDMETHODCALLTYPE h_SetTexture(IDirect3DDevice9*, DWORD, IDirect3DBaseTexture9*);
|
||||
HRESULT STDMETHODCALLTYPE h_GetTexture(IDirect3DDevice9*, DWORD, IDirect3DBaseTexture9**);
|
||||
ULONG STDMETHODCALLTYPE h_Tex2DRelease(IUnknown*);
|
||||
ULONG STDMETHODCALLTYPE h_VolumeRelease(IUnknown*);
|
||||
ULONG STDMETHODCALLTYPE h_CubeRelease(IUnknown*);
|
||||
|
||||
void InstallDeviceHooks(IDirect3DDevice9* device)
|
||||
{
|
||||
if (g_device_hooks_installed) return;
|
||||
void** vt = GetVTable(device);
|
||||
Hook(vt[kDevice_Release], &h_DeviceRelease, reinterpret_cast<void**>(&o_DeviceRelease));
|
||||
Hook(vt[kDevice_CreateTexture], &h_CreateTexture, reinterpret_cast<void**>(&o_CreateTexture));
|
||||
Hook(vt[kDevice_CreateVolumeTexture], &h_CreateVolumeTexture, reinterpret_cast<void**>(&o_CreateVolumeTexture));
|
||||
Hook(vt[kDevice_CreateCubeTexture], &h_CreateCubeTexture, reinterpret_cast<void**>(&o_CreateCubeTexture));
|
||||
Hook(vt[kDevice_UpdateTexture], &h_UpdateTexture, reinterpret_cast<void**>(&o_UpdateTexture));
|
||||
Hook(vt[kDevice_BeginScene], &h_BeginScene, reinterpret_cast<void**>(&o_BeginScene));
|
||||
Hook(vt[kDevice_GetTexture], &h_GetTexture, reinterpret_cast<void**>(&o_GetTexture));
|
||||
Hook(vt[kDevice_SetTexture], &h_SetTexture, reinterpret_cast<void**>(&o_SetTexture));
|
||||
g_device_hooks_installed = true;
|
||||
}
|
||||
|
||||
// A texture vtable is reachable only via an instance, so hook Release lazily per kind.
|
||||
void InstallTextureReleaseHook(void* sample_texture, TexType type)
|
||||
{
|
||||
void** vt = GetVTable(sample_texture);
|
||||
switch (type) {
|
||||
case TexType::Tex2D:
|
||||
if (!g_tex2d_release_installed && Hook(vt[kResource_Release], &h_Tex2DRelease, reinterpret_cast<void**>(&o_Tex2DRelease)))
|
||||
g_tex2d_release_installed = true;
|
||||
break;
|
||||
case TexType::Volume:
|
||||
if (!g_volume_release_installed && Hook(vt[kResource_Release], &h_VolumeRelease, reinterpret_cast<void**>(&o_VolumeRelease)))
|
||||
g_volume_release_installed = true;
|
||||
break;
|
||||
case TexType::Cube:
|
||||
if (!g_cube_release_installed && Hook(vt[kResource_Release], &h_CubeRelease, reinterpret_cast<void**>(&o_CubeRelease)))
|
||||
g_cube_release_installed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDeviceCreated(IDirect3DDevice9* device)
|
||||
{
|
||||
if (device == nullptr) return;
|
||||
|
||||
TextureClient* client = nullptr;
|
||||
{
|
||||
// Lock spans check+install+create so racing callers can't double-register.
|
||||
std::lock_guard lk(g_devices_mutex);
|
||||
if (g_devices.contains(device)) return;
|
||||
InstallDeviceHooks(device);
|
||||
client = new TextureClient(device);
|
||||
g_devices.emplace(device, client);
|
||||
}
|
||||
client->Initialize();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_CreateDevice(IDirect3D9* self, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
|
||||
D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
|
||||
{
|
||||
const HRESULT hr = o_CreateDevice(self, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr) && ppReturnedDeviceInterface && *ppReturnedDeviceInterface) {
|
||||
OnDeviceCreated(*ppReturnedDeviceInterface);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_CreateDeviceEx(IDirect3D9Ex* self, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
|
||||
D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, IDirect3DDevice9Ex** ppReturnedDeviceInterface)
|
||||
{
|
||||
const HRESULT hr = o_CreateDeviceEx(self, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr) && ppReturnedDeviceInterface && *ppReturnedDeviceInterface) {
|
||||
OnDeviceCreated(*ppReturnedDeviceInterface);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE h_DeviceRelease(IDirect3DDevice9* self)
|
||||
{
|
||||
const ULONG count = o_DeviceRelease(self);
|
||||
if (g_unhooked) return count;
|
||||
if (count == 0) {
|
||||
TextureClient* client = nullptr;
|
||||
{
|
||||
std::lock_guard lk(g_devices_mutex);
|
||||
const auto it = g_devices.find(self);
|
||||
if (it != g_devices.end()) {
|
||||
client = it->second;
|
||||
g_devices.erase(it);
|
||||
}
|
||||
}
|
||||
delete client; // ~TextureClient drops all side-state
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_CreateTexture(IDirect3DDevice9* self, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||
IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle)
|
||||
{
|
||||
const HRESULT hr = o_CreateTexture(self, Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr) && ppTexture && *ppTexture) {
|
||||
InstallTextureReleaseHook(*ppTexture, TexType::Tex2D);
|
||||
if (auto* client = ClientFor(self))
|
||||
client->OnCreateTexture(static_cast<IDirect3DBaseTexture9*>(*ppTexture), TexType::Tex2D);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_CreateVolumeTexture(IDirect3DDevice9* self, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||
IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle)
|
||||
{
|
||||
const HRESULT hr = o_CreateVolumeTexture(self, Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr) && ppVolumeTexture && *ppVolumeTexture) {
|
||||
InstallTextureReleaseHook(*ppVolumeTexture, TexType::Volume);
|
||||
if (auto* client = ClientFor(self))
|
||||
client->OnCreateTexture(static_cast<IDirect3DBaseTexture9*>(*ppVolumeTexture), TexType::Volume);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_CreateCubeTexture(IDirect3DDevice9* self, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||
IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle)
|
||||
{
|
||||
const HRESULT hr = o_CreateCubeTexture(self, EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr) && ppCubeTexture && *ppCubeTexture) {
|
||||
InstallTextureReleaseHook(*ppCubeTexture, TexType::Cube);
|
||||
if (auto* client = ClientFor(self))
|
||||
client->OnCreateTexture(static_cast<IDirect3DBaseTexture9*>(*ppCubeTexture), TexType::Cube);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_UpdateTexture(IDirect3DDevice9* self, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture)
|
||||
{
|
||||
// Pass the real textures through, then re-evaluate mods on the changed destination.
|
||||
const HRESULT hr = o_UpdateTexture(self, pSourceTexture, pDestinationTexture);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (auto* client = ClientFor(self))
|
||||
client->OnUpdateTexture(pSourceTexture, pDestinationTexture);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_BeginScene(IDirect3DDevice9* self)
|
||||
{
|
||||
if (g_unhooked) return o_BeginScene(self);
|
||||
if (auto* client = ClientFor(self))
|
||||
client->OnBeginScene();
|
||||
return o_BeginScene(self);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_SetTexture(IDirect3DDevice9* self, DWORD Stage, IDirect3DBaseTexture9* pTexture)
|
||||
{
|
||||
if (g_unhooked) return o_SetTexture(self, Stage, pTexture);
|
||||
IDirect3DBaseTexture9* bind = pTexture;
|
||||
if (auto* client = ClientFor(self))
|
||||
bind = client->ResolveBinding(pTexture); // substitute the fake when modded
|
||||
return o_SetTexture(self, Stage, bind);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE h_GetTexture(IDirect3DDevice9* self, DWORD Stage, IDirect3DBaseTexture9** ppTexture)
|
||||
{
|
||||
const HRESULT hr = o_GetTexture(self, Stage, ppTexture);
|
||||
if (g_unhooked) return hr;
|
||||
if (SUCCEEDED(hr) && ppTexture && *ppTexture) {
|
||||
if (auto* client = ClientFor(self)) {
|
||||
if (auto* original = client->ResolveOriginalFromFake(*ppTexture)) {
|
||||
(*ppTexture)->Release(); // drop the fake reference the runtime handed back
|
||||
original->AddRef(); // return the original the game set, with a matching ref
|
||||
*ppTexture = original;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
void ReleaseTextureCleanup(IUnknown* self, ULONG count)
|
||||
{
|
||||
if (count != 0) return;
|
||||
if (auto* client = TextureClient::CurrentClient())
|
||||
client->OnReleaseTexture(reinterpret_cast<IDirect3DBaseTexture9*>(self));
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE h_Tex2DRelease(IUnknown* self)
|
||||
{
|
||||
const ULONG count = o_Tex2DRelease(self);
|
||||
if (g_unhooked) return count;
|
||||
ReleaseTextureCleanup(self, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE h_VolumeRelease(IUnknown* self)
|
||||
{
|
||||
const ULONG count = o_VolumeRelease(self);
|
||||
if (g_unhooked) return count;
|
||||
ReleaseTextureCleanup(self, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE h_CubeRelease(IUnknown* self)
|
||||
{
|
||||
const ULONG count = o_CubeRelease(self);
|
||||
if (g_unhooked) return count;
|
||||
ReleaseTextureCleanup(self, count);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
void InstallD3D9Hooks(IDirect3D9* d3d9, const bool is_ex)
|
||||
{
|
||||
if (d3d9 == nullptr || g_d3d9_hooks_installed) return;
|
||||
g_unhooked = false; // re-arm in case a prior teardown left the flag set
|
||||
void** vt = GetVTable(d3d9);
|
||||
Hook(vt[kIDirect3D9_CreateDevice], &h_CreateDevice, reinterpret_cast<void**>(&o_CreateDevice));
|
||||
if (is_ex) {
|
||||
Hook(vt[kIDirect3D9Ex_CreateDeviceEx], &h_CreateDeviceEx, reinterpret_cast<void**>(&o_CreateDeviceEx));
|
||||
}
|
||||
g_d3d9_hooks_installed = true;
|
||||
}
|
||||
|
||||
bool RegisterExistingDevice(IDirect3DDevice9* device)
|
||||
{
|
||||
if (device == nullptr) return false;
|
||||
{
|
||||
std::lock_guard lk(g_devices_mutex);
|
||||
if (g_devices.contains(device)) return false; // already known
|
||||
if (!g_devices.empty()) return false; // gMod supports a single device at a time
|
||||
}
|
||||
g_unhooked = false; // re-arm in case a prior teardown left the flag set
|
||||
OnDeviceCreated(device); // installs device hooks + TextureClient (idempotent)
|
||||
return ClientFor(device) != nullptr;
|
||||
}
|
||||
|
||||
void RemoveAllD3D9Hooks()
|
||||
{
|
||||
// Signal first: a detour reached after this (e.g. a surviving patch) falls through.
|
||||
g_unhooked = true;
|
||||
|
||||
for (void* target : g_hooked_targets) {
|
||||
MH_DisableHook(target);
|
||||
MH_RemoveHook(target);
|
||||
}
|
||||
g_hooked_targets.clear();
|
||||
|
||||
g_d3d9_hooks_installed = false;
|
||||
g_device_hooks_installed = false;
|
||||
g_tex2d_release_installed = false;
|
||||
g_volume_release_installed = false;
|
||||
g_cube_release_installed = false;
|
||||
|
||||
// Leave the o_* trampoline pointers intact so a surviving detour can still call through.
|
||||
}
|
||||
|
||||
void DestroyAllTextureClients()
|
||||
{
|
||||
// Collect under the lock, delete outside it (~TextureClient takes its own locks).
|
||||
std::vector<TextureClient*> clients;
|
||||
{
|
||||
std::lock_guard lk(g_devices_mutex);
|
||||
for (const auto& entry : g_devices) {
|
||||
clients.push_back(entry.second);
|
||||
}
|
||||
g_devices.clear();
|
||||
}
|
||||
for (auto* client : clients) {
|
||||
delete client;
|
||||
}
|
||||
}
|
||||
|
||||
// All three read state->real directly; gMod never swaps the underlying resource.
|
||||
|
||||
namespace {
|
||||
|
||||
HashTuple HashBits(const void* bits, const int size)
|
||||
{
|
||||
const auto data = static_cast<const char*>(bits);
|
||||
const auto crc32 = TextureFunction::get_crc32(data, size);
|
||||
const auto crc64 = HashCheck::Use64BitCrc() ? TextureFunction::get_crc64(data, size) : 0;
|
||||
return {crc32, crc64};
|
||||
}
|
||||
|
||||
HashTuple HashTexture2D(const TexState* state)
|
||||
{
|
||||
const auto pTexture = static_cast<IDirect3DTexture9*>(state->real);
|
||||
IDirect3DDevice9* device = state->device;
|
||||
|
||||
IDirect3DSurface9* pOffscreenSurface = nullptr;
|
||||
IDirect3DSurface9* pResolvedSurface = nullptr;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc) != D3D_OK) {
|
||||
Warning("GetTextureHash(2D) Failed: GetLevelDesc\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (desc.Pool == D3DPOOL_DEFAULT) {
|
||||
IDirect3DSurface9* pSurfaceLevel_orig = nullptr;
|
||||
if (pTexture->GetSurfaceLevel(0, &pSurfaceLevel_orig) != D3D_OK) {
|
||||
Warning("GetTextureHash(2D) Failed: GetSurfaceLevel 1 (D3DPOOL_DEFAULT)\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
// The surface GetRenderTargetData reads from: either the level itself, or a
|
||||
// non-multisampled resolve of it. Non-owning; pSurfaceLevel_orig and
|
||||
// pResolvedSurface each own a ref and are released exactly once below.
|
||||
IDirect3DSurface9* pCopySource = pSurfaceLevel_orig;
|
||||
|
||||
if (desc.MultiSampleType != D3DMULTISAMPLE_NONE) {
|
||||
if (D3D_OK != device->CreateRenderTarget(desc.Width, desc.Height, desc.Format, D3DMULTISAMPLE_NONE, 0, FALSE, &pResolvedSurface, nullptr)) {
|
||||
pSurfaceLevel_orig->Release();
|
||||
Warning("GetTextureHash(2D) Failed: CreateRenderTarget (D3DPOOL_DEFAULT)\n");
|
||||
return {};
|
||||
}
|
||||
if (D3D_OK != device->StretchRect(pSurfaceLevel_orig, nullptr, pResolvedSurface, nullptr, D3DTEXF_NONE)) {
|
||||
pResolvedSurface->Release();
|
||||
pResolvedSurface = nullptr;
|
||||
pSurfaceLevel_orig->Release();
|
||||
Warning("GetTextureHash(2D) Failed: StretchRect (D3DPOOL_DEFAULT)\n");
|
||||
return {};
|
||||
}
|
||||
pCopySource = pResolvedSurface;
|
||||
}
|
||||
|
||||
if (D3D_OK != device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pOffscreenSurface, nullptr)) {
|
||||
if (pResolvedSurface != nullptr) pResolvedSurface->Release();
|
||||
pSurfaceLevel_orig->Release();
|
||||
Warning("GetTextureHash(2D) Failed: CreateOffscreenPlainSurface (D3DPOOL_DEFAULT)\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (D3D_OK != device->GetRenderTargetData(pCopySource, pOffscreenSurface)) {
|
||||
pOffscreenSurface->Release();
|
||||
if (pResolvedSurface != nullptr) pResolvedSurface->Release();
|
||||
pSurfaceLevel_orig->Release();
|
||||
Warning("GetTextureHash(2D) Failed: GetRenderTargetData (D3DPOOL_DEFAULT)\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
// Copy is done; both source surfaces are finished with. Null pResolvedSurface
|
||||
// so the shared cleanup below treats this as the pOffscreenSurface case.
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->Release();
|
||||
pResolvedSurface = nullptr;
|
||||
}
|
||||
pSurfaceLevel_orig->Release();
|
||||
|
||||
if (pOffscreenSurface->LockRect(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pOffscreenSurface->Release();
|
||||
Warning("GetTextureHash(2D) Failed: LockRect (D3DPOOL_DEFAULT)\n");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else if (pTexture->LockRect(0, &d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
Warning("GetTextureHash(2D) Failed: LockRect 1\n");
|
||||
if (pTexture->GetSurfaceLevel(0, &pResolvedSurface) != D3D_OK) {
|
||||
Warning("GetTextureHash(2D) Failed: GetSurfaceLevel\n");
|
||||
return {};
|
||||
}
|
||||
if (pResolvedSurface->LockRect(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pResolvedSurface->Release();
|
||||
Warning("GetTextureHash(2D) Failed: LockRect 2\n");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const int size = (TextureFunction::GetBitsFromFormat(desc.Format) * desc.Width * desc.Height) / 8;
|
||||
const auto hash = HashBits(d3dlr.pBits, size);
|
||||
|
||||
if (pOffscreenSurface != nullptr) {
|
||||
pOffscreenSurface->UnlockRect();
|
||||
pOffscreenSurface->Release();
|
||||
}
|
||||
else if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->UnlockRect();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else {
|
||||
pTexture->UnlockRect(0);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
HashTuple HashVolume(const TexState* state)
|
||||
{
|
||||
const auto pTexture = static_cast<IDirect3DVolumeTexture9*>(state->real);
|
||||
|
||||
IDirect3DVolume9* pResolvedSurface = nullptr;
|
||||
D3DLOCKED_BOX d3dlr;
|
||||
D3DVOLUME_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc) != D3D_OK) {
|
||||
Warning("GetTextureHash(Volume) Failed: GetLevelDesc\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (pTexture->LockBox(0, &d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
if (pTexture->GetVolumeLevel(0, &pResolvedSurface) != D3D_OK) {
|
||||
Warning("GetTextureHash(Volume) Failed: GetVolumeLevel\n");
|
||||
return {};
|
||||
}
|
||||
if (pResolvedSurface->LockBox(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pResolvedSurface->Release();
|
||||
Warning("GetTextureHash(Volume) Failed: LockBox\n");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const int size = (TextureFunction::GetBitsFromFormat(desc.Format) * desc.Width * desc.Height * desc.Depth) / 8;
|
||||
const auto hash = HashBits(d3dlr.pBits, size);
|
||||
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->UnlockBox();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else {
|
||||
pTexture->UnlockBox(0);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
HashTuple HashCube(const TexState* state)
|
||||
{
|
||||
const auto pTexture = static_cast<IDirect3DCubeTexture9*>(state->real);
|
||||
|
||||
IDirect3DSurface9* pResolvedSurface = nullptr;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc) != D3D_OK) {
|
||||
Warning("GetTextureHash(Cube) Failed: GetLevelDesc\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (pTexture->LockRect(D3DCUBEMAP_FACE_POSITIVE_X, 0, &d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
if (pTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_POSITIVE_X, 0, &pResolvedSurface) != D3D_OK) {
|
||||
Warning("GetTextureHash(Cube) Failed: GetCubeMapSurface\n");
|
||||
return {};
|
||||
}
|
||||
if (pResolvedSurface->LockRect(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pResolvedSurface->Release();
|
||||
Warning("GetTextureHash(Cube) Failed: LockRect\n");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const int size = (TextureFunction::GetBitsFromFormat(desc.Format) * desc.Width * desc.Height) / 8;
|
||||
const auto hash = HashBits(d3dlr.pBits, size);
|
||||
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->UnlockRect();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else {
|
||||
pTexture->UnlockRect(D3DCUBEMAP_FACE_POSITIVE_X, 0);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
HashTuple GetTextureHash(const TexState* state)
|
||||
{
|
||||
if (state == nullptr || state->real == nullptr || state->isFake) return {};
|
||||
switch (state->type) {
|
||||
case TexType::Tex2D: return HashTexture2D(state);
|
||||
case TexType::Volume: return HashVolume(state);
|
||||
case TexType::Cube: return HashCube(state);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "Error.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <cstdio>
|
||||
#include <process.h>
|
||||
#include <Main.h>
|
||||
|
||||
__declspec(noreturn) void FatalAssert(
|
||||
const char* expr,
|
||||
const char* file,
|
||||
unsigned int line,
|
||||
const char* function)
|
||||
{
|
||||
char module_path[MAX_PATH]{};
|
||||
if (gl_hThisInstance) {
|
||||
GetModuleFileName(gl_hThisInstance, module_path, _countof(module_path));
|
||||
}
|
||||
if (!*module_path) {
|
||||
strcpy_s(module_path, "Unknown");
|
||||
}
|
||||
const char* fmt = "Module: %s\n\nExpr: %s\n\nFile: %s\n\nFunction: %s, line %d";
|
||||
int len = snprintf(NULL, 0, fmt, module_path, expr, file, function, line);
|
||||
char* buf = new char[len + 1];
|
||||
snprintf(buf, len + 1, fmt, module_path, expr, file, function, line);
|
||||
|
||||
|
||||
MessageBox(0, buf, "uMod Assertion Failure", MB_OK | MB_ICONERROR);
|
||||
|
||||
delete[] buf;
|
||||
abort();
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
#include "Main.h"
|
||||
#include <Psapi.h>
|
||||
#include "MinHook.h"
|
||||
#include "D3D9Hooks.h"
|
||||
#include <atomic>
|
||||
|
||||
import TextureClient;
|
||||
|
||||
void ExitInstance(bool is_unloading);
|
||||
void InitInstance(HINSTANCE hModule);
|
||||
|
||||
namespace {
|
||||
|
||||
#define DISABLE_HOOK(var) \
|
||||
if (var) { MH_DisableHook(var); }
|
||||
|
||||
using Direct3DCreate9_type = IDirect3D9*(APIENTRY*)(UINT);
|
||||
using Direct3DCreate9Ex_type = HRESULT(APIENTRY*)(UINT SDKVersion, IDirect3D9Ex** ppD3D);
|
||||
using GetProcAddress_type = FARPROC(APIENTRY*)(HMODULE, LPCSTR);
|
||||
|
||||
// Pointer to original address of Direct3DCreate9
|
||||
Direct3DCreate9_type Direct3DCreate9_ret = nullptr;
|
||||
|
||||
// Pointer to original address of Direct3DCreate9
|
||||
Direct3DCreate9Ex_type Direct3DCreate9Ex_ret = nullptr;
|
||||
|
||||
GetProcAddress_type GetProcAddress_fn = nullptr;
|
||||
GetProcAddress_type GetProcAddress_ret = nullptr;
|
||||
|
||||
FILE* stdout_proxy;
|
||||
FILE* stderr_proxy;
|
||||
|
||||
HMODULE gMod_Loaded_d3d9_Module_Handle = nullptr;
|
||||
|
||||
HMODULE FindLoadedModuleByName(const char* name, bool include_this_module = false)
|
||||
{
|
||||
HMODULE hModules[1024];
|
||||
HANDLE hProcess;
|
||||
DWORD cbNeeded;
|
||||
unsigned int i;
|
||||
|
||||
// Get a handle to the current process.
|
||||
hProcess = GetCurrentProcess();
|
||||
if (!EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded))
|
||||
return nullptr;
|
||||
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||
if (hModules[i] == gl_hThisInstance && !include_this_module)
|
||||
continue;
|
||||
TCHAR szModuleName[MAX_PATH];
|
||||
ASSERT(GetModuleFileName(hModules[i], szModuleName, _countof(szModuleName)) > 0);
|
||||
const auto basename = strrchr(szModuleName, '\\');
|
||||
if (basename && _stricmp(basename + 1, name) == 0)
|
||||
return hModules[i];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HMODULE LoadD3d9Dll()
|
||||
{
|
||||
HMODULE found = FindLoadedModuleByName("d3d9.dll");
|
||||
if (!found) {
|
||||
char executable_path[MAX_PATH]{};
|
||||
ASSERT(GetModuleFileName(GetModuleHandle(nullptr), executable_path, _countof(executable_path)) > 0);
|
||||
|
||||
char dll_path[MAX_PATH]{};
|
||||
ASSERT(GetModuleFileName(gl_hThisInstance, dll_path, _countof(dll_path)) > 0);
|
||||
|
||||
const auto exe_path = std::filesystem::path(executable_path);
|
||||
const auto gmod_path = std::filesystem::path(dll_path);
|
||||
|
||||
if (exe_path.parent_path() != gmod_path.parent_path() || gmod_path.filename() != "d3d9.dll") {
|
||||
// Call basic LoadLibrary function; we're not in the same directory as the exe.
|
||||
gMod_Loaded_d3d9_Module_Handle = LoadLibrary("d3d9.dll");
|
||||
}
|
||||
if (!gMod_Loaded_d3d9_Module_Handle) {
|
||||
// Tried resolving d3d9.dll locally, didn't work. Try system directory
|
||||
char buffer[MAX_PATH];
|
||||
ASSERT(GetSystemDirectory(buffer, _countof(buffer)) > 0); // get the system directory, we need to open the original d3d9.dll
|
||||
|
||||
// Append dll name
|
||||
strcat_s(buffer, _countof(buffer), "\\d3d9.dll");
|
||||
gMod_Loaded_d3d9_Module_Handle = LoadLibrary(buffer);
|
||||
}
|
||||
|
||||
ASSERT(gMod_Loaded_d3d9_Module_Handle);
|
||||
|
||||
found = FindLoadedModuleByName("d3d9.dll");
|
||||
ASSERT(found && found == gMod_Loaded_d3d9_Module_Handle);
|
||||
}
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
// GetProcAddress, hooked via OnGetProcAddress
|
||||
Direct3DCreate9_ret = reinterpret_cast<Direct3DCreate9_type>(GetProcAddress(found, "Direct3DCreate9"));
|
||||
Direct3DCreate9Ex_ret = reinterpret_cast<Direct3DCreate9Ex_type>(GetProcAddress(found, "Direct3DCreate9Ex"));
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
FARPROC APIENTRY OnGetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
||||
{
|
||||
ASSERT(GetProcAddress_ret);
|
||||
if ((int)lpProcName < 0xffff)
|
||||
return GetProcAddress_ret(hModule, lpProcName); // lpProcName is ordinal offset, not string
|
||||
|
||||
if (strcmp(lpProcName, "Direct3DCreate9") == 0) {
|
||||
Direct3DCreate9_ret = reinterpret_cast<Direct3DCreate9_type>(GetProcAddress_ret(hModule, lpProcName));
|
||||
return reinterpret_cast<FARPROC>(Direct3DCreate9);
|
||||
}
|
||||
if (strcmp(lpProcName, "Direct3DCreate9Ex") == 0) {
|
||||
Direct3DCreate9Ex_ret = reinterpret_cast<Direct3DCreate9Ex_type>(GetProcAddress_ret(hModule, lpProcName));
|
||||
return reinterpret_cast<FARPROC>(Direct3DCreate9Ex);
|
||||
}
|
||||
return GetProcAddress_ret(hModule, lpProcName);
|
||||
}
|
||||
|
||||
// If the original d3d9 function is nullptr or points to gMod, load the actual d3d9 dll and redirect the addresses
|
||||
void CheckLoadD3d9Dll()
|
||||
{
|
||||
if (!(Direct3DCreate9_ret && Direct3DCreate9_ret != Direct3DCreate9)) {
|
||||
ASSERT(LoadD3d9Dll());
|
||||
ASSERT(Direct3DCreate9_ret && Direct3DCreate9_ret != Direct3DCreate9);
|
||||
}
|
||||
if (!(Direct3DCreate9Ex_ret && Direct3DCreate9Ex_ret != Direct3DCreate9Ex)) {
|
||||
ASSERT(LoadD3d9Dll());
|
||||
ASSERT(Direct3DCreate9Ex_ret && Direct3DCreate9Ex_ret != Direct3DCreate9Ex);
|
||||
}
|
||||
}
|
||||
|
||||
// There may be a sitation where more than 1 gmod is loaded; avoid recursions!
|
||||
bool creating_d3d9 = false;
|
||||
}
|
||||
|
||||
unsigned int gl_ErrorState = 0;
|
||||
HINSTANCE gl_hThisInstance = nullptr;
|
||||
|
||||
IDirect3D9* APIENTRY Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("uMod_Direct3DCreate9: uMod %p\n", Direct3DCreate9);
|
||||
|
||||
ASSERT(!creating_d3d9);
|
||||
creating_d3d9 = true;
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
CheckLoadD3d9Dll();
|
||||
|
||||
IDirect3D9* pIDirect3D9_orig = Direct3DCreate9_ret(SDKVersion); // creating the original IDirect3D9 object
|
||||
ASSERT(pIDirect3D9_orig);
|
||||
|
||||
creating_d3d9 = false;
|
||||
|
||||
// Hook the vtable and hand the game back the real object untouched.
|
||||
InstallD3D9Hooks(pIDirect3D9_orig, false);
|
||||
return pIDirect3D9_orig;
|
||||
}
|
||||
|
||||
HRESULT APIENTRY Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex** ppD3D)
|
||||
{
|
||||
Message("uMod_Direct3DCreate9Ex: uMod %p\n", Direct3DCreate9Ex);
|
||||
|
||||
ASSERT(!creating_d3d9);
|
||||
creating_d3d9 = true;
|
||||
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
CheckLoadD3d9Dll();
|
||||
|
||||
IDirect3D9Ex* pIDirect3D9Ex_orig = nullptr;
|
||||
HRESULT ret = Direct3DCreate9Ex_ret(SDKVersion, &pIDirect3D9Ex_orig); // creating the original IDirect3D9 object
|
||||
|
||||
creating_d3d9 = false;
|
||||
|
||||
if (ret != S_OK)
|
||||
return ret;
|
||||
|
||||
// Hook the vtable (CreateDevice + CreateDeviceEx) and return the real object untouched.
|
||||
InstallD3D9Hooks(pIDirect3D9Ex_orig, true);
|
||||
*ppD3D = pIDirect3D9Ex_orig;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH: {
|
||||
#ifdef _DEBUG
|
||||
wchar_t dllFilePath[512 + 1]{};
|
||||
GetModuleFileNameW(hModule, dllFilePath, 512);
|
||||
gmod_dll_path = dllFilePath;
|
||||
AllocConsole();
|
||||
SetConsoleTitleA("gMod Console");
|
||||
freopen_s(&stdout_proxy, "CONOUT$", "w", stdout);
|
||||
freopen_s(&stderr_proxy, "CONOUT$", "w", stderr);
|
||||
#endif
|
||||
InitInstance(hModule);
|
||||
break;
|
||||
}
|
||||
case DLL_PROCESS_DETACH: {
|
||||
// Process exit (lpReserved != nullptr): other threads are gone and the OS
|
||||
// reclaims everything, so touching MinHook/the device here only risks a hang.
|
||||
if (lpReserved != nullptr)
|
||||
break;
|
||||
// FreeLibrary unload: the device is still live, so tear down cleanly.
|
||||
ExitInstance(true);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadModlists()
|
||||
{
|
||||
Message("Initialize: searching for modlist.txt\n");
|
||||
char gwpath[MAX_PATH]{};
|
||||
GetModuleFileName(GetModuleHandle(nullptr), gwpath, MAX_PATH); // ask for name and path of this executable
|
||||
char dllpath[MAX_PATH]{};
|
||||
GetModuleFileName(gl_hThisInstance, dllpath, MAX_PATH); // ask for name and path of this dll
|
||||
const auto exe_path = std::filesystem::path(gwpath).parent_path();
|
||||
const auto dll_path = std::filesystem::path(dllpath).parent_path();
|
||||
for (const auto& path : {exe_path, dll_path}) {
|
||||
const auto modlist = path / "modlist.txt";
|
||||
if (std::filesystem::exists(modlist)) {
|
||||
Message("Initialize: found %s\n", modlist.string().c_str());
|
||||
std::ifstream t(modlist, std::ios::binary);
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
modlists_contents.emplace_back(modlist.string(), buffer.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InitInstance(HINSTANCE hModule)
|
||||
{
|
||||
Message("InitInstance: %p\n", hModule);
|
||||
|
||||
// Store the handle to this module
|
||||
gl_hThisInstance = hModule;
|
||||
|
||||
LoadModlists();
|
||||
DisableThreadLibraryCalls(hModule); // reduce overhead
|
||||
|
||||
// d3d9.dll shouldn't be loaded at this point.
|
||||
[[maybe_unused]] const auto d3d9_loaded = FindLoadedModuleByName("d3d9.dll");
|
||||
// ASSERT(!d3d9_loaded);
|
||||
|
||||
MH_Initialize();
|
||||
|
||||
// Hook into LoadLibraryA - we'll do our hooks on the flip side
|
||||
GetProcAddress_fn = reinterpret_cast<GetProcAddress_type>(GetProcAddress);
|
||||
ASSERT(GetProcAddress_fn);
|
||||
if (GetProcAddress_fn) {
|
||||
MH_CreateHook(GetProcAddress_fn, OnGetProcAddress, (void**)&GetProcAddress_ret);
|
||||
MH_EnableHook(GetProcAddress_fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Exported entry for late injection: hand gMod an existing device so it hooks
|
||||
// the vtable and mods textures from here on.
|
||||
extern "C" __declspec(dllexport) int __cdecl SetDevice(IDirect3DDevice9* device)
|
||||
{
|
||||
if (!device) return RETURN_BAD_ARGUMENT;
|
||||
try {
|
||||
return RegisterExistingDevice(device) ? RETURN_OK : RETURN_EXISTS;
|
||||
}
|
||||
catch (...) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) int __cdecl AddFile(const wchar_t* path)
|
||||
{
|
||||
if (!path) return RETURN_BAD_ARGUMENT;
|
||||
try {
|
||||
return TextureClient::AddFile(std::filesystem::path(path));
|
||||
}
|
||||
catch (...) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) int __cdecl RemoveFile(const wchar_t* path)
|
||||
{
|
||||
if (!path) return RETURN_BAD_ARGUMENT;
|
||||
try {
|
||||
return TextureClient::RemoveFile(std::filesystem::path(path));
|
||||
}
|
||||
catch (...) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// nullptr first arg = return required size; paths come back in load (priority) order
|
||||
// returns paths separated by null terminator, e.g. "C:\foo.tpf\0C:\bar.zip\0\0"
|
||||
extern "C" __declspec(dllexport) int __cdecl GetFiles(wchar_t* buffer, const size_t buffer_size_chars)
|
||||
{
|
||||
try {
|
||||
const auto files = TextureClient::GetFiles();
|
||||
size_t required = 1;
|
||||
for (const auto& path : files) {
|
||||
required += path.native().size() + 1;
|
||||
}
|
||||
|
||||
if (buffer && buffer_size_chars > 0 && buffer_size_chars >= required) {
|
||||
wchar_t* out = buffer;
|
||||
for (const auto& path : files) {
|
||||
const auto& native = path.native();
|
||||
std::ranges::copy(native, out);
|
||||
out += native.size();
|
||||
*out++ = L'\0';
|
||||
}
|
||||
*out = L'\0';
|
||||
}
|
||||
return static_cast<int>(required);
|
||||
}
|
||||
catch (...) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// Optional clean-shutdown entry: call this from the host (on a normal thread) BEFORE
|
||||
// FreeLibrary so teardown runs off the loader lock, where MinHook can safely suspend
|
||||
// the render thread. A later FreeLibrary then unloads with nothing left to undo.
|
||||
extern "C" __declspec(dllexport) void __cdecl Shutdown()
|
||||
{
|
||||
ExitInstance(true);
|
||||
}
|
||||
|
||||
void ExitInstance(bool is_unloading)
|
||||
{
|
||||
// Teardown must run exactly once, whether reached via Shutdown() or DllMain detach.
|
||||
static std::atomic<bool> torn_down{false};
|
||||
if (torn_down.exchange(true)) return;
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
|
||||
// Revert every D3D9 vtable hook so the original objects are left pristine.
|
||||
RemoveAllD3D9Hooks();
|
||||
|
||||
// On a real unload the device is still alive; release our replacement textures.
|
||||
if (is_unloading) {
|
||||
DestroyAllTextureClients();
|
||||
}
|
||||
|
||||
MH_Uninitialize();
|
||||
|
||||
if (gMod_Loaded_d3d9_Module_Handle)
|
||||
FreeLibrary(gMod_Loaded_d3d9_Module_Handle);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (stdout_proxy)
|
||||
fclose(stdout_proxy);
|
||||
if (stderr_proxy)
|
||||
fclose(stderr_proxy);
|
||||
__try {
|
||||
FreeConsole();
|
||||
}
|
||||
__except (EXCEPTION_CONTINUE_EXECUTION) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
set(VCPKG_TARGET_ARCHITECTURE x86)
|
||||
|
||||
if(PORT MATCHES "dxsdk-d3dx")
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
else()
|
||||
set(VCPKG_CRT_LINKAGE static)
|
||||
set(VCPKG_LIBRARY_LINKAGE static)
|
||||
endif()
|
||||
@@ -1,117 +0,0 @@
|
||||
ifdef NI
|
||||
|
||||
ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "NO_INJECTION"
|
||||
else
|
||||
precompiler_flag = /D "NO_INJECTION"
|
||||
endif
|
||||
|
||||
def_file = /DEF:"uMod_DX9_dll_NO_INJECTION.def"
|
||||
obj_suff = NI.obj
|
||||
dll = d3d9.dll
|
||||
|
||||
else
|
||||
|
||||
ifdef DI
|
||||
ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "DIRECT_INJECTION"
|
||||
else
|
||||
precompiler_flag = /D "DIRECT_INJECTION"
|
||||
endif
|
||||
|
||||
def_file = /DEF:"uMod_DX9_dll_DIRECT_INJECTION.def"
|
||||
obj_suff = DI.obj
|
||||
dll = uMod_d3d9_DI.dll
|
||||
|
||||
else
|
||||
|
||||
ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "HOOK_INJECTION"
|
||||
else
|
||||
precompiler_flag = /D "HOOK_INJECTION"
|
||||
endif
|
||||
|
||||
def_file = /DEF:"uMod_DX9_dll_HOOK_INJECTION.def"
|
||||
obj_suff = HI.obj
|
||||
dll = uMod_d3d9_HI.dll
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
CXX = cl
|
||||
CLINK = link.exe
|
||||
DEFINES = /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS"
|
||||
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 ${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t
|
||||
LFLAGS = /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" /DLL "Winmm.lib" "d3dx9.lib" "dxguid.lib" "user32.lib" "Kernel32.lib" ${def_file} /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO /NXCOMPAT:NO /MACHINE:X86
|
||||
|
||||
obj = obj
|
||||
bin = bin
|
||||
|
||||
objects = ${obj}\uMod_DX9_dll.${obj_suff} \
|
||||
${obj}\uMod_IDirect3D9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3D9Ex.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DDevice9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DDevice9Ex.${obj_suff} \
|
||||
${obj}\uMod_TextureFunction.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DTexture9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DCubeTexture9.${obj_suff} \
|
||||
${obj}\uMod_ArrayHandler.${obj_suff} \
|
||||
${obj}\uMod_TextureClient.${obj_suff} \
|
||||
${obj}\uMod_TextureServer.${obj_suff}
|
||||
|
||||
headers = uMod_Main.h \
|
||||
uMod_Defines.h \
|
||||
uMod_DX9_dll.h \
|
||||
uMod_IDirect3D9.h \
|
||||
uMod_IDirect3DDevice9.h \
|
||||
uMod_TextureFunction.h \
|
||||
uMod_IDirect3DTexture9.h \
|
||||
uMod_IDirect3DVolumeTexture9.h \
|
||||
uMod_IDirect3DCubeTexture9.h \
|
||||
uMod_ArrayHandler.h \
|
||||
uMod_TextureClient.h \
|
||||
uMod_TextureServer.h
|
||||
|
||||
${bin}\d3d9.dll: ${objects}
|
||||
${CLINK} ${LFLAGS} ${objects} /OUT:${bin}\${dll}
|
||||
copy ${bin}\${dll} ..\uMod_GUI\bin\${dll}
|
||||
|
||||
${obj}\uMod_DX9_dll.${obj_suff}: uMod_DX9_dll.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3D9.${obj_suff}: uMod_IDirect3D9.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3D9Ex.${obj_suff}: uMod_IDirect3D9Ex.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DDevice9.${obj_suff}: uMod_IDirect3DDevice9.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DDevice9Ex.${obj_suff}: uMod_IDirect3DDevice9Ex.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureFunction.${obj_suff}: uMod_TextureFunction.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DTexture9.${obj_suff}: uMod_IDirect3DTexture9.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff}: uMod_IDirect3DVolumeTexture9.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DCubeTexture9.${obj_suff}: uMod_IDirect3DCubeTexture9.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ArrayHandler.${obj_suff}: uMod_ArrayHandler.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureClient.${obj_suff}: uMod_TextureClient.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureServer.${obj_suff}: uMod_TextureServer.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
clean:
|
||||
del ${objects} ${bin}\${dll}
|
||||
@@ -1,117 +0,0 @@
|
||||
!IFDEF NI
|
||||
|
||||
!IFDEF LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "NO_INJECTION"
|
||||
!ELSE
|
||||
precompiler_flag = /D "NO_INJECTION"
|
||||
!ENDIF
|
||||
|
||||
def_file = /DEF:"uMod_DX9_dll_NO_INJECTION.def"
|
||||
obj_suff = NI.obj
|
||||
dll = d3d9.dll
|
||||
|
||||
!ELSE
|
||||
|
||||
!IFDEF DI
|
||||
!IFDEF LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "DIRECT_INJECTION"
|
||||
!ELSE
|
||||
precompiler_flag = /D "DIRECT_INJECTION"
|
||||
!ENDIF
|
||||
|
||||
def_file = /DEF:"uMod_DX9_dll_DIRECT_INJECTION.def"
|
||||
obj_suff = DI.obj
|
||||
dll = uMod_d3d9_DI.dll
|
||||
|
||||
!ELSE
|
||||
|
||||
!IFDEF LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "HOOK_INJECTION"
|
||||
!ELSE
|
||||
precompiler_flag = /D "HOOK_INJECTION"
|
||||
!ENDIF
|
||||
|
||||
def_file = /DEF:"uMod_DX9_dll_HOOK_INJECTION.def"
|
||||
obj_suff = HI.obj
|
||||
dll = uMod_d3d9_HI.dll
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
CXX = cl
|
||||
CLINK = link.exe
|
||||
DEFINES = /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS"
|
||||
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 $(DEFINES) $(precompiler_flag) /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t
|
||||
LFLAGS = /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" /DLL "Winmm.lib" "d3dx9.lib" "dxguid.lib" "user32.lib" "Kernel32.lib" $(def_file) /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO /NXCOMPAT:NO /MACHINE:X86
|
||||
|
||||
obj = obj
|
||||
bin = bin
|
||||
|
||||
objects = $(obj)\uMod_DX9_dll.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3D9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3D9Ex.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DDevice9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DDevice9Ex.$(obj_suff) \
|
||||
$(obj)\uMod_TextureFunction.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DTexture9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DVolumeTexture9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DCubeTexture9.$(obj_suff) \
|
||||
$(obj)\uMod_ArrayHandler.$(obj_suff) \
|
||||
$(obj)\uMod_TextureClient.$(obj_suff) \
|
||||
$(obj)\uMod_TextureServer.$(obj_suff)
|
||||
|
||||
headers = uMod_Main.h \
|
||||
uMod_Defines.h \
|
||||
uMod_DX9_dll.h \
|
||||
uMod_IDirect3D9.h \
|
||||
uMod_IDirect3DDevice9.h \
|
||||
uMod_TextureFunction.h \
|
||||
uMod_IDirect3DTexture9.h \
|
||||
uMod_IDirect3DVolumeTexture9.h \
|
||||
uMod_IDirect3DCubeTexture9.h \
|
||||
uMod_ArrayHandler.h \
|
||||
uMod_TextureClient.h \
|
||||
uMod_TextureServer.h
|
||||
|
||||
$(bin)\d3d9.dll: $(objects)
|
||||
$(CLINK) $(LFLAGS) $(objects) /OUT:$(bin)\$(dll)
|
||||
copy $(bin)\$(dll) ..\uMod_GUI\bin\$(dll)
|
||||
|
||||
$(obj)\uMod_DX9_dll.$(obj_suff): uMod_DX9_dll.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_DX9_dll.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3D9.$(obj_suff): uMod_IDirect3D9.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3D9.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3D9Ex.$(obj_suff): uMod_IDirect3D9Ex.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3D9Ex.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3DDevice9.$(obj_suff): uMod_IDirect3DDevice9.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DDevice9.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3DDevice9Ex.$(obj_suff): uMod_IDirect3DDevice9Ex.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DDevice9Ex.cpp
|
||||
|
||||
$(obj)\uMod_TextureFunction.$(obj_suff): uMod_TextureFunction.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_TextureFunction.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3DTexture9.$(obj_suff): uMod_IDirect3DTexture9.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DTexture9.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3DVolumeTexture9.$(obj_suff): uMod_IDirect3DVolumeTexture9.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DVolumeTexture9.cpp
|
||||
|
||||
$(obj)\uMod_IDirect3DCubeTexture9.$(obj_suff): uMod_IDirect3DCubeTexture9.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DCubeTexture9.cpp
|
||||
|
||||
$(obj)\uMod_ArrayHandler.$(obj_suff): uMod_ArrayHandler.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_ArrayHandler.cpp
|
||||
|
||||
$(obj)\uMod_TextureClient.$(obj_suff): uMod_TextureClient.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_TextureClient.cpp
|
||||
|
||||
$(obj)\uMod_TextureServer.$(obj_suff): uMod_TextureServer.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c /Fo$@ uMod_TextureServer.cpp
|
||||
|
||||
clean:
|
||||
del $(objects) $(bin)\$(dll)
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uMod_FileHandler::uMod_FileHandler(void)
|
||||
{
|
||||
Message("uMod_FileHandler(void): %lu\n", this);
|
||||
Number = 0;
|
||||
FieldCounter = 0;
|
||||
Files = NULL;
|
||||
}
|
||||
|
||||
uMod_FileHandler::~uMod_FileHandler(void)
|
||||
{
|
||||
Message("~uMod_FileHandler(void): %lu\n", this);
|
||||
if (Files!=NULL)
|
||||
{
|
||||
for (int i=0; i<FieldCounter; i++) if (Files[i] != NULL) delete [] Files[i];
|
||||
delete [] Files;
|
||||
}
|
||||
}
|
||||
|
||||
int uMod_FileHandler::Add(TextureFileStruct* file)
|
||||
{
|
||||
Message("uMod_FileHandler::Add(%lu): %lu\n", file, this);
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
if (file->Reference>=0) return (RETURN_UPDATE_ALLREADY_ADDED);
|
||||
|
||||
if (Number/FieldLength==FieldCounter) // get more memory
|
||||
{
|
||||
TextureFileStruct*** temp = NULL;
|
||||
try {temp = new TextureFileStruct**[FieldCounter+10];}
|
||||
catch (...)
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
|
||||
for (int i=0; i<FieldCounter; i++) temp[i] = Files[i]; //copy to new allocated memory
|
||||
|
||||
for (int i=FieldCounter; i<FieldCounter+10; i++) temp[i] = NULL; // initialize unused parts to zero
|
||||
|
||||
FieldCounter += 10;
|
||||
|
||||
if (Files!=NULL) delete [] Files;
|
||||
|
||||
Files = temp;
|
||||
}
|
||||
if (Number%FieldLength==0) // maybe we need to get more memory
|
||||
{
|
||||
try {if (Files[Number/FieldLength]==NULL) Files[Number/FieldLength] = new TextureFileStruct*[FieldLength];}
|
||||
catch (...)
|
||||
{
|
||||
Files[Number/FieldLength] = NULL;
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
Files[Number/FieldLength][Number%FieldLength] = file;
|
||||
file->Reference = Number++; //set the reference for a fast deleting
|
||||
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
int uMod_FileHandler::Remove(TextureFileStruct* file)
|
||||
{
|
||||
Message("uMod_FileHandler::Remove(%lu): %lu\n", file, this);
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
int ref = file->Reference;
|
||||
|
||||
if (ref<0) return (RETURN_OK); // returning if no Reference is set
|
||||
file->Reference = -1; //set reference outside of bound
|
||||
if (ref<(--Number)) //if reference is unequal to Number-1 we copy the last entry to the index "ref"
|
||||
{
|
||||
Files[ref/FieldLength][ref%FieldLength] = Files[Number/FieldLength][Number%FieldLength];
|
||||
Files[ref/FieldLength][ref%FieldLength]->Reference = ref; //set the new reference entry
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_FIELDHANDLER_H_
|
||||
#define uMod_FIELDHANDLER_H_
|
||||
|
||||
#include "..\uMod_GlobalDefines.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool ForceReload; // to force a reload of the texture (if it is already modded)
|
||||
char* pData; // store texture file as file in memory
|
||||
unsigned int Size; // size of file
|
||||
int NumberOfTextures;
|
||||
int Reference; // for a fast delete in the FileHandler
|
||||
IDirect3DBaseTexture9 **Textures; // pointer to the fake textures
|
||||
MyTypeHash Hash; // hash value
|
||||
} TextureFileStruct;
|
||||
|
||||
|
||||
|
||||
class uMod_FileHandler // array to store TextureFileStruct
|
||||
{
|
||||
public:
|
||||
uMod_FileHandler(void);
|
||||
~uMod_FileHandler(void);
|
||||
|
||||
int Add( TextureFileStruct* file);
|
||||
int Remove( TextureFileStruct* file);
|
||||
|
||||
int GetNumber(void) {return (Number);}
|
||||
|
||||
TextureFileStruct *operator [] (int i) {if (i<0||i>=Number) return (NULL); else return (Files[i/FieldLength][i%FieldLength]);}
|
||||
|
||||
protected:
|
||||
static const int FieldLength = 1024;
|
||||
long Number;
|
||||
int FieldCounter;
|
||||
TextureFileStruct*** Files;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
class uMod_TextureHandler // array to store uMod_IDirect3DTexture9, uMod_IDirect3DVolumeTexture9 or uMod_IDirect3DCubeTexture9
|
||||
{
|
||||
public:
|
||||
uMod_TextureHandler(void);
|
||||
~uMod_TextureHandler(void);
|
||||
|
||||
int Add( T* texture);
|
||||
int Remove( T* texture);
|
||||
|
||||
int GetNumber(void) {return (Number);}
|
||||
T *operator [] (int i) {if (i<0||i>=Number) return (NULL); else return (Textures[i/FieldLength][i%FieldLength]);}
|
||||
|
||||
private:
|
||||
static const int FieldLength = 1024;
|
||||
long Number;
|
||||
int FieldCounter;
|
||||
T*** Textures;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
uMod_TextureHandler<T>::uMod_TextureHandler(void)
|
||||
{
|
||||
Message("uMod_TextureHandler(void): %lu\n", this);
|
||||
Number = 0;
|
||||
FieldCounter = 0;
|
||||
|
||||
Textures = NULL;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
uMod_TextureHandler<T>::~uMod_TextureHandler(void)
|
||||
{
|
||||
Message("~uMod_TextureHandler(void): %lu\n", this);
|
||||
if (Textures!=NULL)
|
||||
{
|
||||
for (int i=0; i<FieldCounter; i++) if (Textures[i] != NULL) delete [] Textures[i];
|
||||
delete [] Textures;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int uMod_TextureHandler<T>::Add(T* pTexture)
|
||||
{
|
||||
Message("uMod_TextureHandler::Add( %lu): %lu\n", pTexture, this);
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
if (pTexture->Reference>=0) return (RETURN_TEXTURE_ALLREADY_ADDED);
|
||||
|
||||
if (Number/FieldLength==FieldCounter)
|
||||
{
|
||||
T*** temp = NULL;
|
||||
try {temp = new T**[FieldCounter+10];}
|
||||
catch (...)
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
|
||||
for (int i=0; i<FieldCounter; i++) temp[i] = Textures[i];
|
||||
|
||||
for (int i=FieldCounter; i<FieldCounter+10; i++) temp[i] = NULL;
|
||||
|
||||
FieldCounter += 10;
|
||||
|
||||
if (Textures!=NULL) delete [] Textures;
|
||||
|
||||
Textures = temp;
|
||||
}
|
||||
if (Number%FieldLength==0)
|
||||
{
|
||||
try {if (Textures[Number/FieldLength]==NULL) Textures[Number/FieldLength] = new T*[FieldLength];}
|
||||
catch (...)
|
||||
{
|
||||
Textures[Number/FieldLength]=NULL;
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
Textures[Number/FieldLength][Number%FieldLength] = pTexture;
|
||||
pTexture->Reference = Number++;
|
||||
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
int uMod_TextureHandler<T>::Remove(T* pTexture) //will be called, if a texture is completely released
|
||||
{
|
||||
Message("uMod_TextureHandler::Remove( %lu): %lu\n", pTexture, this);
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
int ref = pTexture->Reference;
|
||||
if (ref<0) return (RETURN_OK); // returning if no TextureHandlerRef is set
|
||||
|
||||
if (ref<(--Number))
|
||||
{
|
||||
Textures[ref/FieldLength][ref%FieldLength] = Textures[Number/FieldLength][Number%FieldLength];
|
||||
Textures[ref/FieldLength][ref%FieldLength]->Reference = ref;
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_FIELDHANDLER_H_ */
|
||||
@@ -1,463 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
NEVER USE THIS CODE FOR ILLEGAL PURPOSE
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
//#include "detours.h"
|
||||
//#include "detourxs/detourxs/detourxs.h"
|
||||
|
||||
/*
|
||||
#include "detourxs/detourxs/ADE32.cpp"
|
||||
#include "detourxs/detourxs/detourxs.cpp"
|
||||
*/
|
||||
/*
|
||||
* global variable which are not linked external
|
||||
*/
|
||||
HINSTANCE gl_hOriginalDll = NULL;
|
||||
HINSTANCE gl_hThisInstance = NULL;
|
||||
uMod_TextureServer* gl_TextureServer = NULL;
|
||||
HANDLE gl_ServerThread = NULL;
|
||||
|
||||
typedef IDirect3D9 *(APIENTRY *Direct3DCreate9_type)(UINT);
|
||||
typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
|
||||
#ifndef NO_INJECTION
|
||||
Direct3DCreate9_type Direct3DCreate9_fn; // we need to store the pointer to the original Direct3DCreate9 function after we have done a detour
|
||||
Direct3DCreate9Ex_type Direct3DCreate9Ex_fn; // we need to store the pointer to the original Direct3DCreate9 function after we have done a detour
|
||||
HHOOK gl_hHook = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* global variable which are linked external
|
||||
*/
|
||||
unsigned int gl_ErrorState = 0u;
|
||||
|
||||
#ifdef LOG_MESSAGE
|
||||
FILE* gl_File = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DIRECT_INJECTION
|
||||
void Nothing(void) {(void)NULL;}
|
||||
#endif
|
||||
/*
|
||||
* dll entry routine, here we initialize or clean up
|
||||
*/
|
||||
BOOL WINAPI DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
InitInstance(hModule);
|
||||
break;
|
||||
}
|
||||
case DLL_PROCESS_DETACH:
|
||||
{
|
||||
ExitInstance();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI ServerThread( LPVOID lpParam )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpParam);
|
||||
if (gl_TextureServer!=NULL) gl_TextureServer->MainLoop(); //This is and endless mainloop, it sleep till something is written into the pipe.
|
||||
return (0);
|
||||
}
|
||||
|
||||
void InitInstance(HINSTANCE hModule)
|
||||
{
|
||||
|
||||
DisableThreadLibraryCalls( hModule ); //reduce overhead
|
||||
|
||||
gl_hThisInstance = (HINSTANCE) hModule;
|
||||
|
||||
wchar_t game[MAX_PATH];
|
||||
if (HookThisProgram( game)) //ask if we need to hook this program
|
||||
{
|
||||
OpenMessage();
|
||||
Message("InitInstance: %lu\n", hModule);
|
||||
|
||||
gl_TextureServer = new uMod_TextureServer(game); //create the server which listen on the pipe and prepare the update for the texture clients
|
||||
|
||||
LoadOriginalDll();
|
||||
|
||||
#ifndef NO_INJECTION
|
||||
// we detour the original Direct3DCreate9 to our MyDirect3DCreate9
|
||||
Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress(gl_hOriginalDll, "Direct3DCreate9");
|
||||
if (Direct3DCreate9_fn!=NULL)
|
||||
{
|
||||
Message("Detour: Direct3DCreate9\n");
|
||||
Direct3DCreate9_fn = (Direct3DCreate9_type)DetourFunc( (BYTE*)Direct3DCreate9_fn, (BYTE*)uMod_Direct3DCreate9, 5);
|
||||
}
|
||||
|
||||
Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress(gl_hOriginalDll, "Direct3DCreate9Ex");
|
||||
if (Direct3DCreate9Ex_fn!=NULL)
|
||||
{
|
||||
Message("Detour: Direct3DCreate9Ex\n");
|
||||
Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type)DetourFunc( (BYTE*)Direct3DCreate9Ex_fn, (BYTE*)uMod_Direct3DCreate9Ex, 7);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gl_TextureServer->OpenPipe(game)) //open the pipe and send the name+path of this executable
|
||||
{
|
||||
Message("InitInstance: Pipe not opened\n");
|
||||
return;
|
||||
}
|
||||
|
||||
gl_ServerThread = CreateThread( NULL, 0, ServerThread, NULL, 0, NULL); //creating a thread for the mainloop
|
||||
if (gl_ServerThread==NULL) {Message("InitInstance: Serverthread not started\n");}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LoadOriginalDll(void)
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll
|
||||
|
||||
// Append dll name
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d9.dll");
|
||||
|
||||
// try to load the system's d3d9.dll, if pointer empty
|
||||
if (!gl_hOriginalDll) gl_hOriginalDll = LoadLibrary(buffer);
|
||||
|
||||
if (!gl_hOriginalDll)
|
||||
{
|
||||
ExitProcess(0); // exit the hard way
|
||||
}
|
||||
}
|
||||
|
||||
void ExitInstance()
|
||||
{
|
||||
if (gl_TextureServer!=NULL)
|
||||
{
|
||||
gl_TextureServer->ClosePipe(); //This must be done before the server thread is killed, because the server thread will endless wait on the ReadFile()
|
||||
}
|
||||
if (gl_ServerThread!=NULL)
|
||||
{
|
||||
CloseHandle(gl_ServerThread); // kill the server thread
|
||||
gl_ServerThread = NULL;
|
||||
}
|
||||
if (gl_TextureServer!=NULL)
|
||||
{
|
||||
delete gl_TextureServer; //delete the texture server
|
||||
gl_TextureServer = NULL;
|
||||
}
|
||||
|
||||
// Release the system's d3d9.dll
|
||||
if (gl_hOriginalDll!=NULL)
|
||||
{
|
||||
FreeLibrary(gl_hOriginalDll);
|
||||
gl_hOriginalDll = NULL;
|
||||
}
|
||||
|
||||
CloseMessage();
|
||||
}
|
||||
|
||||
#ifdef NO_INJECTION
|
||||
/*
|
||||
* We do not inject, the game loads this dll by itself thus we must include the Direct3DCreate9 function
|
||||
*/
|
||||
|
||||
IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("WINAPI Direct3DCreate9\n");
|
||||
|
||||
if (!gl_hOriginalDll) LoadOriginalDll(); // looking for the "right d3d9.dll"
|
||||
|
||||
// find original function in original d3d9.dll
|
||||
Direct3DCreate9_type D3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9");
|
||||
|
||||
|
||||
if (!D3DCreate9_fn)
|
||||
{
|
||||
Message("Direct3DCreate9: original function not found in dll\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//Create originale IDirect3D9 object
|
||||
IDirect3D9 *pIDirect3D9_orig = D3DCreate9_fn(SDKVersion);
|
||||
|
||||
//create our uMod_IDirect3D9 object
|
||||
uMod_IDirect3D9 *pIDirect3D9 = new uMod_IDirect3D9( pIDirect3D9_orig, gl_TextureServer);
|
||||
|
||||
// Return pointer to our object instead of "real one"
|
||||
return (pIDirect3D9);
|
||||
}
|
||||
|
||||
HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **ppD3D)
|
||||
{
|
||||
Message("WINAPI Direct3DCreate9Ex\n");
|
||||
|
||||
if (!gl_hOriginalDll) LoadOriginalDll(); // looking for the "right d3d9.dll"
|
||||
|
||||
// find original function in original d3d9.dll
|
||||
Direct3DCreate9Ex_type D3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex");
|
||||
|
||||
|
||||
if (!D3DCreate9Ex_fn)
|
||||
{
|
||||
Message("Direct3DCreate9Ex: original function not found in dll\n");
|
||||
return (D3DERR_NOTAVAILABLE);
|
||||
}
|
||||
|
||||
|
||||
//Create originale IDirect3D9 object
|
||||
IDirect3D9Ex *pIDirect3D9Ex_orig;
|
||||
HRESULT ret = D3DCreate9Ex_fn( SDKVersion, &pIDirect3D9Ex_orig);
|
||||
if (ret!=S_OK) return (ret);
|
||||
|
||||
//create our uMod_IDirect3D9 object
|
||||
uMod_IDirect3D9Ex *pIDirect3D9Ex = new uMod_IDirect3D9Ex( pIDirect3D9Ex_orig, gl_TextureServer);
|
||||
|
||||
ppD3D = &pIDirect3D9Ex_orig; // Return pointer to our object instead of "real one"
|
||||
return (ret);
|
||||
}
|
||||
|
||||
bool HookThisProgram( wchar_t *ret) //this function always return true, it is needed for the name and path of the executable
|
||||
{
|
||||
wchar_t Executable[MAX_PATH];
|
||||
GetModuleFileNameW( GetModuleHandle( NULL ), Executable, MAX_PATH ); //ask for name and path of this executable
|
||||
|
||||
int len = 0;
|
||||
while (Executable[len]) {ret[len] = Executable[len]; len++;}
|
||||
ret[len] = 0;
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* We inject the dll into the game, thus we retour the original Direct3DCreate9 function to our MyDirect3DCreate9 function
|
||||
*/
|
||||
|
||||
IDirect3D9 *APIENTRY uMod_Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("uMod_Direct3DCreate9: original %lu, uMod %lu\n", Direct3DCreate9_fn, uMod_Direct3DCreate9);
|
||||
|
||||
// in the Internet are many tutorials for detouring functions and all of them will work without the following 5 marked lines
|
||||
// but somehow, for me it only works, if I retour the function and calling afterward the original function
|
||||
|
||||
// BEGIN
|
||||
|
||||
LoadOriginalDll();
|
||||
|
||||
RetourFunc((BYTE*) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"), (BYTE*)Direct3DCreate9_fn, 5);
|
||||
Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9");
|
||||
|
||||
/*
|
||||
if (Direct3DCreate9Ex_fn!=NULL)
|
||||
{
|
||||
RetourFunc((BYTE*) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex"), (BYTE*)Direct3DCreate9Ex_fn, 7);
|
||||
Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex");
|
||||
}
|
||||
*/
|
||||
// END
|
||||
|
||||
IDirect3D9 *pIDirect3D9_orig = NULL;
|
||||
if (Direct3DCreate9_fn)
|
||||
{
|
||||
pIDirect3D9_orig = Direct3DCreate9_fn(SDKVersion); //creating the original IDirect3D9 object
|
||||
}
|
||||
else return (NULL);
|
||||
uMod_IDirect3D9 *pIDirect3D9;
|
||||
if (pIDirect3D9_orig)
|
||||
{
|
||||
pIDirect3D9 = new uMod_IDirect3D9( pIDirect3D9_orig, gl_TextureServer); //creating our uMod_IDirect3D9 object
|
||||
}
|
||||
|
||||
// we detour again
|
||||
Direct3DCreate9_fn = (Direct3DCreate9_type)DetourFunc( (BYTE*) Direct3DCreate9_fn, (BYTE*)uMod_Direct3DCreate9,5);
|
||||
/*
|
||||
if (Direct3DCreate9Ex_fn!=NULL)
|
||||
{
|
||||
Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type)DetourFunc( (BYTE*) Direct3DCreate9Ex_fn, (BYTE*)uMod_Direct3DCreate9Ex,7);
|
||||
}
|
||||
*/
|
||||
return (pIDirect3D9); //return our object instead of the "real one"
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D)
|
||||
{
|
||||
Message( "uMod_Direct3DCreate9Ex: original %lu, uMod %lu\n", Direct3DCreate9Ex_fn, uMod_Direct3DCreate9Ex);
|
||||
|
||||
// in the Internet are many tutorials for detouring functions and all of them will work without the following 5 marked lines
|
||||
// but somehow, for me it only works, if I retour the function and calling afterward the original function
|
||||
|
||||
// BEGIN
|
||||
|
||||
LoadOriginalDll();
|
||||
/*
|
||||
if (Direct3DCreate9_fn!=NULL)
|
||||
{
|
||||
RetourFunc((BYTE*) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"), (BYTE*)Direct3DCreate9_fn, 5);
|
||||
Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9");
|
||||
}
|
||||
*/
|
||||
RetourFunc((BYTE*) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex"), (BYTE*)Direct3DCreate9Ex_fn, 7);
|
||||
Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex");
|
||||
// END
|
||||
|
||||
IDirect3D9Ex *pIDirect3D9Ex_orig = NULL;
|
||||
HRESULT ret;
|
||||
if (Direct3DCreate9Ex_fn)
|
||||
{
|
||||
ret = Direct3DCreate9Ex_fn(SDKVersion, &pIDirect3D9Ex_orig); //creating the original IDirect3D9 object
|
||||
}
|
||||
else return (D3DERR_NOTAVAILABLE);
|
||||
|
||||
if (ret!=S_OK) return (ret);
|
||||
|
||||
uMod_IDirect3D9Ex *pIDirect3D9Ex;
|
||||
if (pIDirect3D9Ex_orig)
|
||||
{
|
||||
pIDirect3D9Ex = new uMod_IDirect3D9Ex( pIDirect3D9Ex_orig, gl_TextureServer); //creating our uMod_IDirect3D9 object
|
||||
}
|
||||
|
||||
// we detour again
|
||||
/*
|
||||
if (Direct3DCreate9_fn!=NULL)
|
||||
{
|
||||
Direct3DCreate9_fn = (Direct3DCreate9_type)DetourFunc( (BYTE*) Direct3DCreate9_fn, (BYTE*)uMod_Direct3DCreate9,5);
|
||||
}
|
||||
*/
|
||||
Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type)DetourFunc( (BYTE*) Direct3DCreate9Ex_fn, (BYTE*)uMod_Direct3DCreate9Ex,7);
|
||||
ppD3D = (IDirect3D9Ex**) &pIDirect3D9Ex; //return our object instead of the "real one"
|
||||
return (ret);
|
||||
}
|
||||
|
||||
bool HookThisProgram( wchar_t *ret)
|
||||
{
|
||||
wchar_t Executable[MAX_PATH];
|
||||
wchar_t Game[MAX_PATH];
|
||||
GetModuleFileNameW( GetModuleHandle( NULL ), Executable, MAX_PATH ); //ask for name and path of this executable
|
||||
|
||||
#ifdef HOOK_INJECTION
|
||||
//we use the gloabal hook
|
||||
|
||||
FILE* file;
|
||||
wchar_t *app_path = _wgetenv( L"APPDATA"); //asc for the user application directory
|
||||
wchar_t file_name[MAX_PATH];
|
||||
swprintf_s( file_name, MAX_PATH, L"%ls\\%ls\\%ls", app_path, uMod_APP_DIR, uMod_APP_DX9);
|
||||
if (_wfopen_s( &file, file_name, L"rt,ccs=UTF-16LE")) return (false); // open the file in utf-16 LE mode
|
||||
|
||||
|
||||
//MessageBoxW( NULL, Executable, L"test", 0);
|
||||
while (!feof(file))
|
||||
{
|
||||
if ( fgetws( Game, MAX_PATH, file) != NULL ) //get each line of the file
|
||||
{
|
||||
//MessageBoxW( NULL, Game, L"test", 0);
|
||||
int len = 0;
|
||||
while (Game[len])
|
||||
{
|
||||
if (Game[len]==L'\r' || Game[len]==L'\n') {Game[len]=0; break;} //removing the new line symbols
|
||||
len++;
|
||||
}
|
||||
if ( _wcsicmp( Executable, Game ) == 0 ) //compare both strings
|
||||
{
|
||||
for (int i=0; i<len; i++) ret[i] = Game[i];
|
||||
ret[len] = 0;
|
||||
fclose(file);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
return (false);
|
||||
#endif
|
||||
#ifdef DIRECT_INJECTION
|
||||
// we inject directly
|
||||
int i=0;
|
||||
while ( Game[i]) {ret[i]=Game[i]; i++;}
|
||||
ret[i]=0;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
|
||||
{
|
||||
BYTE *jmp = (BYTE*)malloc(len+5);
|
||||
DWORD dwback = 0;
|
||||
VirtualProtect(jmp, len+5, PAGE_EXECUTE_READWRITE, &dwback); //This is the addition needed for Windows 7 RC
|
||||
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
|
||||
memcpy(jmp, src, len); jmp += len;
|
||||
jmp[0] = 0xE9;
|
||||
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
|
||||
memset(src, 0x90, len);
|
||||
src[0] = 0xE9;
|
||||
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
|
||||
VirtualProtect(src, len, dwback, &dwback);
|
||||
return (jmp-len);
|
||||
}
|
||||
|
||||
bool RetourFunc(BYTE *src, BYTE *restore, const int len)
|
||||
{
|
||||
DWORD dwback;
|
||||
if(!VirtualProtect(src, len, PAGE_READWRITE, &dwback)) { return (false); }
|
||||
if(!memcpy(src, restore, len)) { return (false); }
|
||||
restore[0] = 0xE9;
|
||||
*(DWORD*)(restore+1) = (DWORD)(src - restore) - 5;
|
||||
if(!VirtualProtect(src, len, dwback, &dwback)) { return (false); }
|
||||
return (true);
|
||||
}
|
||||
|
||||
#ifdef HOOK_INJECTION
|
||||
/*
|
||||
* We do not change something, if our hook function is called.
|
||||
* We need this hook only to get our dll loaded into a starting program.
|
||||
*/
|
||||
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return (CallNextHookEx( gl_hHook, nCode, wParam, lParam));
|
||||
}
|
||||
|
||||
void InstallHook(void)
|
||||
{
|
||||
gl_hHook = SetWindowsHookEx( WH_CBT, HookProc, gl_hThisInstance, 0 );
|
||||
}
|
||||
|
||||
void RemoveHook(void)
|
||||
{
|
||||
UnhookWindowsHookEx( gl_hHook );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_DX9_DLL_H_
|
||||
#define uMod_DX9_DLL_H_
|
||||
|
||||
void InitInstance(HINSTANCE hModule);
|
||||
void ExitInstance(void);
|
||||
void LoadOriginalDll(void);
|
||||
bool HookThisProgram( wchar_t *ret);
|
||||
DWORD WINAPI ServerThread( LPVOID lpParam);
|
||||
|
||||
|
||||
|
||||
#ifndef NO_INJECTION
|
||||
|
||||
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
|
||||
bool RetourFunc(BYTE *src, BYTE *restore, const int len);
|
||||
IDirect3D9 *APIENTRY uMod_Direct3DCreate9(UINT SDKVersion);
|
||||
HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
|
||||
#ifdef HOOK_INJECTION
|
||||
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
void InstallHook(void);
|
||||
void RemoveHook(void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DIRECT_INJECTION
|
||||
void Nothing(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
LIBRARY "uMod_d3d9_DI"
|
||||
EXPORTS
|
||||
uMod_Direct3DCreate9 @1
|
||||
uMod_Direct3DCreate9Ex @2
|
||||
Nothing @3
|
||||
@@ -1,6 +0,0 @@
|
||||
LIBRARY "uMod_d3d9_Hook"
|
||||
EXPORTS
|
||||
uMod_Direct3DCreate9 @1
|
||||
uMod_Direct3DCreate9Ex @2
|
||||
InstallHook @3
|
||||
RemoveHook @4
|
||||
@@ -1,4 +0,0 @@
|
||||
LIBRARY "d3d9"
|
||||
EXPORTS
|
||||
Direct3DCreate9 @1
|
||||
Direct3DCreate9Ex @2
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_DEFINES_H_
|
||||
#define uMod_DEFINES_H_
|
||||
|
||||
|
||||
|
||||
#ifdef LOG_MESSAGE
|
||||
extern FILE *gl_File;
|
||||
|
||||
#define Message(...) {if (gl_File!=NULL) {fprintf( gl_File, __VA_ARGS__); fflush(gl_File);}}
|
||||
#ifdef HOOK_INJECTION
|
||||
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "HI R40: 0000000\n");}
|
||||
#endif
|
||||
|
||||
#ifdef DIRECT_INJECTION
|
||||
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "DI 40: 0000000\n");}
|
||||
#endif
|
||||
|
||||
#ifdef NO_INJECTION
|
||||
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "NI R40: 0000000\n");}
|
||||
#endif
|
||||
|
||||
#define CloseMessage(...) {if (gl_File!=NULL) fclose(gl_File);}
|
||||
|
||||
|
||||
#else
|
||||
#define OpenMessage(...)
|
||||
#define Message(...)
|
||||
#define CloseMessage(...)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __CDT_PARSER__
|
||||
typedef unsigned long DWORD64;
|
||||
typedef unsigned long DWORD32;
|
||||
|
||||
#define STDMETHOD(method) virtual HRESULT method
|
||||
#define STDMETHOD_(ret, method) virtual ret method
|
||||
#define sprintf_s(...)
|
||||
#define fprintf(...)
|
||||
#define fclose(...)
|
||||
#define fseek(...)
|
||||
#define ftell(...) 0
|
||||
#define fflush(...)
|
||||
typedef LONG HRESULT;
|
||||
|
||||
#define UNREFERENCED_PARAMETER(...)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* uMod_DEFINES_H_ */
|
||||
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
#ifndef PRE_MESSAGE
|
||||
#define PRE_MESSAGE "uMod_IDirect3D9"
|
||||
#endif
|
||||
|
||||
uMod_IDirect3D9::uMod_IDirect3D9( IDirect3D9 *pOriginal, uMod_TextureServer* server)
|
||||
{
|
||||
Message( PRE_MESSAGE "::" PRE_MESSAGE "( %lu, %lu): %lu\n", pOriginal, server, this);
|
||||
m_pIDirect3D9 = pOriginal;
|
||||
uMod_Server = server;
|
||||
}
|
||||
|
||||
uMod_IDirect3D9::~uMod_IDirect3D9(void)
|
||||
{
|
||||
Message( PRE_MESSAGE "::~" PRE_MESSAGE "(): %lu\n", this);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
*ppvObj = NULL;
|
||||
|
||||
// call this to increase AddRef at original object
|
||||
// and to check if such an interface is there
|
||||
|
||||
HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj);
|
||||
|
||||
if (hRes == NOERROR) // if OK, send our "fake" address
|
||||
{
|
||||
*ppvObj = this;
|
||||
}
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
ULONG __stdcall uMod_IDirect3D9::AddRef(void)
|
||||
{
|
||||
return(m_pIDirect3D9->AddRef());
|
||||
}
|
||||
|
||||
ULONG __stdcall uMod_IDirect3D9::Release(void)
|
||||
{
|
||||
// call original routine
|
||||
ULONG count = m_pIDirect3D9->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
|
||||
return(count);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction)
|
||||
{
|
||||
return(m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction));
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9::GetAdapterCount(void)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterCount());
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterIdentifier(Adapter,Flags,pIdentifier));
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterModeCount(Adapter, Format));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return(m_pIDirect3D9->EnumAdapterModes(Adapter,Format,Mode,pMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterDisplayMode(Adapter,pMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceType(iAdapter,DevType,DisplayFormat,BackBufferFormat,bWindowed));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType,pQualityLevels));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceFormatConversion(Adapter,DeviceType,SourceFormat,TargetFormat));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps)
|
||||
{
|
||||
return(m_pIDirect3D9->GetDeviceCaps(Adapter,DeviceType,pCaps));
|
||||
}
|
||||
|
||||
HMONITOR __stdcall uMod_IDirect3D9::GetAdapterMonitor(UINT Adapter)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterMonitor(Adapter));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface)
|
||||
{
|
||||
Message( PRE_MESSAGE "::CreateDevice(): %lu\n", this);
|
||||
// we intercept this call and provide our own "fake" Device Object
|
||||
HRESULT hres = m_pIDirect3D9->CreateDevice( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
|
||||
|
||||
int count = 1;
|
||||
if (pPresentationParameters!=NULL) count = pPresentationParameters->BackBufferCount;
|
||||
uMod_IDirect3DDevice9 *pIDirect3DDevice9 = new uMod_IDirect3DDevice9(*ppReturnedDeviceInterface, uMod_Server, count);
|
||||
|
||||
// store our pointer (the fake one) for returning it to the calling program
|
||||
*ppReturnedDeviceInterface = pIDirect3DDevice9;
|
||||
|
||||
return(hres);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Michael Koch
|
||||
* (proxydll_9.zip)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3D9_H_
|
||||
#define uMod_IDirect3D9_H_
|
||||
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "uMod_TextureServer.h"
|
||||
#include "uMod_TextureClient.h"
|
||||
|
||||
class uMod_IDirect3D9 : public IDirect3D9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3D9(IDirect3D9 *pOriginal, uMod_TextureServer *server);
|
||||
virtual ~uMod_IDirect3D9(void);
|
||||
|
||||
// The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction);
|
||||
UINT __stdcall GetAdapterCount(void);
|
||||
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) ;
|
||||
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format);
|
||||
HRESULT __stdcall EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ;
|
||||
HRESULT __stdcall CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ;
|
||||
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ;
|
||||
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) ;
|
||||
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat);
|
||||
HRESULT __stdcall GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ;
|
||||
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) ;
|
||||
HRESULT __stdcall CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ;
|
||||
|
||||
private:
|
||||
IDirect3D9 *m_pIDirect3D9;
|
||||
uMod_TextureServer* uMod_Server;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
#define IDirect3D9 IDirect3D9Ex
|
||||
#define uMod_IDirect3D9 uMod_IDirect3D9Ex
|
||||
#define m_pIDirect3D9 m_pIDirect3D9Ex
|
||||
#define PRE_MESSAGE "uMod_IDirect3D9Ex"
|
||||
|
||||
#include "uMod_IDirect3D9.cpp"
|
||||
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::CreateDeviceEx( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface)
|
||||
{
|
||||
Message( "uMod_IDirect3D9Ex::CreateDeviceEx: %lu\n", this);
|
||||
// we intercept this call and provide our own "fake" Device Object
|
||||
HRESULT hres = m_pIDirect3D9Ex->CreateDeviceEx( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
|
||||
|
||||
int count = 1;
|
||||
if (pPresentationParameters!=NULL) count = pPresentationParameters->BackBufferCount;
|
||||
uMod_IDirect3DDevice9Ex *pIDirect3DDevice9Ex = new uMod_IDirect3DDevice9Ex(*ppReturnedDeviceInterface, uMod_Server, count);
|
||||
|
||||
// store our pointer (the fake one) for returning it to the calling program
|
||||
*ppReturnedDeviceInterface = pIDirect3DDevice9Ex;
|
||||
|
||||
return(hres);
|
||||
return (m_pIDirect3D9Ex->CreateDeviceEx( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::EnumAdapterModesEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->EnumAdapterModesEx( Adapter, pFilter, Mode, pMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::GetAdapterDisplayModeEx( UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->GetAdapterDisplayModeEx( Adapter, pMode, pRotation));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::GetAdapterLUID( UINT Adapter, LUID *pLUID)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->GetAdapterLUID( Adapter, pLUID));
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9Ex::GetAdapterModeCountEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->GetAdapterModeCountEx( Adapter, pFilter));
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Michael Koch
|
||||
* (proxydll_9.zip)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3D9Ex_H_
|
||||
#define uMod_IDirect3D9Ex_H_
|
||||
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "uMod_TextureServer.h"
|
||||
#include "uMod_TextureClient.h"
|
||||
|
||||
class uMod_IDirect3D9Ex : public IDirect3D9Ex
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3D9Ex( IDirect3D9Ex *pOriginal, uMod_TextureServer *server);
|
||||
virtual ~uMod_IDirect3D9Ex(void);
|
||||
|
||||
// The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction);
|
||||
UINT __stdcall GetAdapterCount(void);
|
||||
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) ;
|
||||
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format);
|
||||
HRESULT __stdcall EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ;
|
||||
HRESULT __stdcall CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ;
|
||||
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ;
|
||||
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) ;
|
||||
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat);
|
||||
HRESULT __stdcall GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ;
|
||||
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) ;
|
||||
HRESULT __stdcall CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ;
|
||||
|
||||
HRESULT __stdcall CreateDeviceEx( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface);
|
||||
HRESULT __stdcall EnumAdapterModesEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode);
|
||||
HRESULT __stdcall GetAdapterDisplayModeEx( UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
|
||||
HRESULT __stdcall GetAdapterLUID( UINT Adapter, LUID *pLUID);
|
||||
UINT __stdcall GetAdapterModeCountEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter);
|
||||
|
||||
|
||||
private:
|
||||
IDirect3D9Ex *m_pIDirect3D9Ex;
|
||||
uMod_TextureServer* uMod_Server;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* some function (e.g. AddReff()) are presumed to work on the texture object which belong to them
|
||||
* if this texture was switched, we must redirect this calls to the CrossRef_D3Dtex texture object
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000002L);
|
||||
}
|
||||
HRESULT hRes;
|
||||
if (CrossRef_D3Dtex!=NULL)
|
||||
{
|
||||
hRes = CrossRef_D3Dtex->m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==CrossRef_D3Dtex->m_D3Dtex) *ppvObj=this;
|
||||
}
|
||||
else
|
||||
{
|
||||
hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==m_D3Dtex) *ppvObj=this;
|
||||
}
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DCubeTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) return (1); //bug, this case should never happen
|
||||
if (CrossRef_D3Dtex!=NULL)
|
||||
{
|
||||
return (CrossRef_D3Dtex->m_D3Dtex->AddRef());
|
||||
}
|
||||
else return (m_D3Dtex->AddRef());
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DCubeTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::Release(): %lu\n", this);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE)
|
||||
{
|
||||
UnswitchTextures( this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) //if this texture is switched with a fake texture
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9 *fake_texture = CrossRef_D3Dtex;
|
||||
count = fake_texture->m_D3Dtex->Release(); //release the original texture
|
||||
if (count==0) //if texture is released we switch the textures back
|
||||
{
|
||||
UnswitchTextures(this);
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9*) m_D3Ddev)->GetSingleCubeTexture()!=fake_texture) fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetSingleCubeTexture()!=fake_texture) fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (count==0) //if this texture is released, we clean up
|
||||
{
|
||||
// if this texture is the LastCreatedTexture, the next time LastCreatedTexture would be added,
|
||||
// the hash of a non existing texture would be calculated
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9*) m_D3Ddev)->GetLastCreatedCubeTexture()==this) ((uMod_IDirect3DDevice9*) m_D3Ddev)->SetLastCreatedCubeTexture( NULL);
|
||||
else ((uMod_IDirect3DDevice9*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetLastCreatedCubeTexture()==this) ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->SetLastCreatedCubeTexture( NULL);
|
||||
else ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
|
||||
delete(this);
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid));
|
||||
return (m_D3Dtex->FreePrivateData(refguid));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return (m_D3Dtex->SetPriority(PriorityNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetPriority()
|
||||
{
|
||||
return (m_D3Dtex->GetPriority());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DCubeTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DCubeTexture9::GetType()
|
||||
{
|
||||
return (m_D3Dtex->GetType());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return (m_D3Dtex->SetLOD(LODNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetLOD()
|
||||
{
|
||||
return (m_D3Dtex->GetLOD());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetLevelCount()
|
||||
{
|
||||
return (m_D3Dtex->GetLevelCount());
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return (m_D3Dtex->SetAutoGenFilterType(FilterType));
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DCubeTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return (m_D3Dtex->GetAutoGenFilterType());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DCubeTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::AddDirtyRect(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->AddDirtyRect( FaceType, pDirtyRect));
|
||||
return (m_D3Dtex->AddDirtyRect( FaceType, pDirtyRect));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetCubeMapSurface(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetCubeMapSurface( FaceType, Level, ppCubeMapSurface));
|
||||
return (m_D3Dtex->GetCubeMapSurface( FaceType, Level, ppCubeMapSurface));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::LockRect( D3DCUBEMAP_FACES FaceType, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->LockRect( FaceType, Level, pLockedRect, pRect, Flags));
|
||||
return (m_D3Dtex->LockRect( FaceType, Level, pLockedRect, pRect, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::UnlockRect( D3DCUBEMAP_FACES FaceType, UINT Level)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->UnlockRect( FaceType, Level));
|
||||
return (m_D3Dtex->UnlockRect( FaceType, Level));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_IDirect3DCubeTexture9::GetHash(MyTypeHash &hash)
|
||||
{
|
||||
hash=0u;
|
||||
if (FAKE) return (RETURN_BAD_ARGUMENT);
|
||||
IDirect3DCubeTexture9 *pTexture = m_D3Dtex;
|
||||
if (CrossRef_D3Dtex!=NULL) pTexture = CrossRef_D3Dtex->m_D3Dtex;
|
||||
|
||||
//IDirect3DSurface9 *pOffscreenSurface = NULL;
|
||||
//IDirect3DCubeTexture9 *pOffscreenTexture = NULL;
|
||||
IDirect3DSurface9 *pResolvedSurface = NULL;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() (%d %d) %d\n", desc.Width, desc.Height, desc.Format);
|
||||
|
||||
/*
|
||||
if (desc.Pool==D3DPOOL_DEFAULT) //get the raw data of the texture
|
||||
{
|
||||
//Message("uMod_IDirect3DCubeTexture9::GetHash() (D3DPOOL_DEFAULT)\n");
|
||||
|
||||
IDirect3DSurface9 *pSurfaceLevel_orig = NULL;
|
||||
if (pTexture->GetSurfaceLevel( 0, &pSurfaceLevel_orig)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetSurfaceLevel 1 (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
if (desc.MultiSampleType != D3DMULTISAMPLE_NONE)
|
||||
{
|
||||
//Message("uMod_IDirect3DCubeTexture9::GetHash() MultiSampleType\n");
|
||||
if (D3D_OK!=m_D3Ddev->CreateRenderTarget( desc.Width, desc.Height, desc.Format, D3DMULTISAMPLE_NONE, 0, FALSE, &pResolvedSurface, NULL ))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: CreateRenderTarget (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (D3D_OK!=m_D3Ddev->StretchRect( pSurfaceLevel_orig, NULL, pResolvedSurface, NULL, D3DTEXF_NONE ))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: StretchRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
pSurfaceLevel_orig = pResolvedSurface;
|
||||
}
|
||||
|
||||
|
||||
if (D3D_OK!=m_D3Ddev->CreateOffscreenPlainSurface( desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pOffscreenSurface, NULL))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: CreateOffscreenPlainSurface (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
|
||||
if (D3D_OK!=m_D3Ddev->GetRenderTargetData( pSurfaceLevel_orig, pOffscreenSurface))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetRenderTargetData (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
pSurfaceLevel_orig->Release();
|
||||
|
||||
if (pOffscreenSurface->LockRect( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: LockRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
if (pTexture->LockRect( D3DCUBEMAP_FACE_POSITIVE_X, 0, &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetCubeMapSurface( D3DCUBEMAP_FACE_POSITIVE_X, 0, &pResolvedSurface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (pResolvedSurface->LockRect( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int size = (GetBitsFromFormat( desc.Format) * desc.Width*desc.Height)/8;
|
||||
|
||||
hash = GetCRC32( (char*) d3dlr.pBits, size); //calculate the crc32 of the texture
|
||||
/*
|
||||
if (pOffscreenSurface!=NULL)
|
||||
{
|
||||
pOffscreenSurface->UnlockRect();
|
||||
pOffscreenSurface->Release();
|
||||
//pOffscreenTexture->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
}
|
||||
else
|
||||
*/
|
||||
if (pResolvedSurface!=NULL)
|
||||
{
|
||||
pResolvedSurface->UnlockRect();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
pTexture->UnlockRect( D3DCUBEMAP_FACE_POSITIVE_X, 0); //unlock the raw data
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() %#lX (%d %d) %d = %d\n", hash, desc.Width, desc.Height, desc.Format, size);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Matthew L (Azorbix)
|
||||
* (Direct3D StarterKit v3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DCubeTexture9_H
|
||||
#define uMod_IDirect3DCubeTexture9_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "uMod_Defines.h"
|
||||
|
||||
|
||||
|
||||
interface uMod_IDirect3DCubeTexture9 : public IDirect3DCubeTexture9
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9(IDirect3DCubeTexture9 **ppTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = NULL; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DCubeTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
Reference = -1; //need for fast deleting
|
||||
Hash = 0u;
|
||||
FAKE = false;
|
||||
}
|
||||
|
||||
// callback interface
|
||||
IDirect3DCubeTexture9 *m_D3Dtex;
|
||||
uMod_IDirect3DCubeTexture9 *CrossRef_D3Dtex;
|
||||
IDirect3DDevice9 *m_D3Ddev;
|
||||
int Reference;
|
||||
MyTypeHash Hash;
|
||||
bool FAKE;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)();
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew);
|
||||
STDMETHOD_(DWORD, GetLOD)();
|
||||
STDMETHOD_(DWORD, GetLevelCount)();
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType);
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)();
|
||||
STDMETHOD_(void, GenerateMipSubLevels)();
|
||||
|
||||
STDMETHOD(AddDirtyRect)(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DSURFACE_DESC *pDesc);
|
||||
STDMETHOD(GetCubeMapSurface)(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface);
|
||||
STDMETHOD(LockRect)( D3DCUBEMAP_FACES FaceType, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
|
||||
STDMETHOD(UnlockRect)(D3DCUBEMAP_FACES FaceType, UINT Level);
|
||||
|
||||
|
||||
int GetHash(MyTypeHash &hash);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void UnswitchTextures(uMod_IDirect3DCubeTexture9 *pTexture)
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9* CrossRef = pTexture->CrossRef_D3Dtex;
|
||||
if (CrossRef!=NULL)
|
||||
{
|
||||
// switch textures back
|
||||
IDirect3DCubeTexture9* cpy = pTexture->m_D3Dtex;
|
||||
pTexture->m_D3Dtex = CrossRef->m_D3Dtex;
|
||||
CrossRef->m_D3Dtex = cpy;
|
||||
|
||||
// cancel the link
|
||||
CrossRef->CrossRef_D3Dtex = NULL;
|
||||
pTexture->CrossRef_D3Dtex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline int SwitchTextures( uMod_IDirect3DCubeTexture9 *pTexture1, uMod_IDirect3DCubeTexture9 *pTexture2)
|
||||
{
|
||||
if (pTexture1->m_D3Ddev == pTexture2->m_D3Ddev && pTexture1->CrossRef_D3Dtex == NULL && pTexture2->CrossRef_D3Dtex == NULL)
|
||||
{
|
||||
// make cross reference
|
||||
pTexture1->CrossRef_D3Dtex = pTexture2;
|
||||
pTexture2->CrossRef_D3Dtex = pTexture1;
|
||||
|
||||
// switch textures
|
||||
IDirect3DCubeTexture9* cpy = pTexture2->m_D3Dtex;
|
||||
pTexture2->m_D3Dtex = pTexture1->m_D3Dtex;
|
||||
pTexture1->m_D3Dtex = cpy;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
else return (RETURN_TEXTURE_NOT_SWITCHED);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Michael Koch
|
||||
* (proxydll_9.zip)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DDevice9_H_
|
||||
#define uMod_IDirect3DDevice9_H_
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
|
||||
|
||||
class uMod_IDirect3DDevice9 : public IDirect3DDevice9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DDevice9(IDirect3DDevice9* pOriginal, uMod_TextureServer* server, int back_buffer_count);
|
||||
virtual ~uMod_IDirect3DDevice9(void);
|
||||
|
||||
// START: The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface (REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall TestCooperativeLevel(void);
|
||||
UINT __stdcall GetAvailableTextureMem(void);
|
||||
HRESULT __stdcall EvictManagedResources(void);
|
||||
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9);
|
||||
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps);
|
||||
HRESULT __stdcall GetDisplayMode(UINT iSwapChain,D3DDISPLAYMODE* pMode);
|
||||
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
|
||||
HRESULT __stdcall SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap);
|
||||
void __stdcall SetCursorPosition(int X,int Y,DWORD Flags);
|
||||
BOOL __stdcall ShowCursor(BOOL bShow);
|
||||
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) ;
|
||||
HRESULT __stdcall GetSwapChain(UINT iSwapChain,IDirect3DSwapChain9** pSwapChain);
|
||||
UINT __stdcall GetNumberOfSwapChains(void);
|
||||
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
|
||||
HRESULT __stdcall GetBackBuffer(UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer);
|
||||
HRESULT __stdcall GetRasterStatus(UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus);
|
||||
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs);
|
||||
void __stdcall SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp);
|
||||
void __stdcall GetGammaRamp(UINT iSwapChain,D3DGAMMARAMP* pRamp);
|
||||
HRESULT __stdcall CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint);
|
||||
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture);
|
||||
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter);
|
||||
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color);
|
||||
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget);
|
||||
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget);
|
||||
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil);
|
||||
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface);
|
||||
HRESULT __stdcall BeginScene(void);
|
||||
HRESULT __stdcall EndScene(void);
|
||||
HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
|
||||
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall GetLight(DWORD Index,D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall LightEnable(DWORD Index,BOOL Enable);
|
||||
HRESULT __stdcall GetLightEnable(DWORD Index,BOOL* pEnable);
|
||||
HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane);
|
||||
HRESULT __stdcall GetClipPlane(DWORD Index,float* pPlane);
|
||||
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State,DWORD Value);
|
||||
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue);
|
||||
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall BeginStateBlock(void);
|
||||
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture);
|
||||
HRESULT __stdcall SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture);
|
||||
HRESULT __stdcall GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall GetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses);
|
||||
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber);
|
||||
HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber);
|
||||
HRESULT __stdcall SetScissorRect(CONST RECT* pRect);
|
||||
HRESULT __stdcall GetScissorRect( RECT* pRect);
|
||||
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware);
|
||||
BOOL __stdcall GetSoftwareVertexProcessing(void);
|
||||
HRESULT __stdcall SetNPatchMode(float nSegments);
|
||||
float __stdcall GetNPatchMode(void);
|
||||
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
|
||||
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
|
||||
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags);
|
||||
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl);
|
||||
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetFVF(DWORD FVF);
|
||||
HRESULT __stdcall GetFVF(DWORD* pFVF);
|
||||
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader);
|
||||
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride);
|
||||
HRESULT __stdcall GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride);
|
||||
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber,UINT Divider);
|
||||
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber,UINT* Divider);
|
||||
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData);
|
||||
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData);
|
||||
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader);
|
||||
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo);
|
||||
HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo);
|
||||
HRESULT __stdcall DeletePatch(UINT Handle);
|
||||
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery);
|
||||
// END: The original DX9 function definitions
|
||||
|
||||
|
||||
|
||||
uMod_TextureClient* GetuMod_Client(void) {return (uMod_Client);}
|
||||
|
||||
uMod_IDirect3DTexture9* GetLastCreatedTexture(void) {return (LastCreatedTexture);}
|
||||
int SetLastCreatedTexture(uMod_IDirect3DTexture9* pTexture) {LastCreatedTexture=pTexture; return (RETURN_OK);}
|
||||
|
||||
uMod_IDirect3DVolumeTexture9* GetLastCreatedVolumeTexture(void) {return (LastCreatedVolumeTexture);}
|
||||
int SetLastCreatedVolumeTexture(uMod_IDirect3DVolumeTexture9* pTexture) {LastCreatedVolumeTexture=pTexture; return (RETURN_OK);}
|
||||
|
||||
uMod_IDirect3DCubeTexture9* GetLastCreatedCubeTexture(void) {return (LastCreatedCubeTexture);}
|
||||
int SetLastCreatedCubeTexture(uMod_IDirect3DCubeTexture9* pTexture) {LastCreatedCubeTexture=pTexture; return (RETURN_OK);}
|
||||
|
||||
|
||||
uMod_IDirect3DTexture9* GetSingleTexture(void) {return (SingleTexture);}
|
||||
uMod_IDirect3DVolumeTexture9* GetSingleVolumeTexture(void) {return (SingleVolumeTexture);}
|
||||
uMod_IDirect3DCubeTexture9* GetSingleCubeTexture(void) {return (SingleCubeTexture);}
|
||||
|
||||
|
||||
private:
|
||||
int CreateSingleTexture(void);
|
||||
IDirect3DDevice9* m_pIDirect3DDevice9;
|
||||
|
||||
int CounterSaveSingleTexture;
|
||||
uMod_IDirect3DTexture9* SingleTexture;
|
||||
uMod_IDirect3DVolumeTexture9* SingleVolumeTexture;
|
||||
uMod_IDirect3DCubeTexture9* SingleCubeTexture;
|
||||
char SingleTextureMod;
|
||||
|
||||
D3DCOLOR TextureColour;
|
||||
ID3DXFont *OSD_Font;
|
||||
//D3DCOLOR FontColour;
|
||||
int BackBufferCount;
|
||||
bool NormalRendering;
|
||||
|
||||
int uMod_Reference;
|
||||
|
||||
uMod_IDirect3DTexture9* LastCreatedTexture;
|
||||
uMod_IDirect3DVolumeTexture9* LastCreatedVolumeTexture;
|
||||
uMod_IDirect3DCubeTexture9* LastCreatedCubeTexture;
|
||||
|
||||
uMod_TextureServer* uMod_Server;
|
||||
uMod_TextureClient* uMod_Client;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
#define uMod_IDirect3DDevice9 uMod_IDirect3DDevice9Ex
|
||||
#define IDirect3DDevice9 IDirect3DDevice9Ex
|
||||
#define m_pIDirect3DDevice9 m_pIDirect3DDevice9Ex
|
||||
|
||||
#define RETURN_QueryInterface 0x01000001L
|
||||
#define PRE_MESSAGE "uMod_IDirect3DDevice9Ex"
|
||||
|
||||
|
||||
#include "uMod_IDirect3DDevice9.cpp"
|
||||
|
||||
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CheckDeviceState( HWND hWindow)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CheckDeviceState( hWindow));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CheckResourceResidency( IDirect3DResource9 **ppResourceArray, UINT32 NumResources)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CheckResourceResidency( ppResourceArray, NumResources));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::ComposeRects( IDirect3DSurface9 *pSource, IDirect3DSurface9 *pDestination, IDirect3DVertexBuffer9 *pSrcRectDescriptors, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescriptors, D3DCOMPOSERECTSOP Operation, INT XOffset, INT YOffset)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->ComposeRects( pSource, pDestination, pSrcRectDescriptors, NumRects, pDstRectDescriptors, Operation, XOffset, YOffset));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateDepthStencilSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CreateDepthStencilSurfaceEx( Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle, Usage));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateOffscreenPlainSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CreateOffscreenPlainSurfaceEx( Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateRenderTargetEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CreateRenderTargetEx( Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle, Usage));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetDisplayModeEx( UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->GetDisplayModeEx( iSwapChain, pMode, pRotation));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetGPUThreadPriority( INT *pPriority)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->GetGPUThreadPriority( pPriority));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetMaximumFrameLatency( UINT *pMaxLatency)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->GetMaximumFrameLatency( pMaxLatency));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::PresentEx( const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->PresentEx( pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::ResetEx( D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->ResetEx( pPresentationParameters, pFullscreenDisplayMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetConvolutionMonoKernel( UINT Width, UINT Height, float *RowWeights, float *ColumnWeights)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->SetConvolutionMonoKernel( Width, Height, RowWeights, ColumnWeights));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetGPUThreadPriority( INT pPriority)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->SetGPUThreadPriority( pPriority));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetMaximumFrameLatency( UINT pMaxLatency)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->SetMaximumFrameLatency( pMaxLatency));
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::TestCooperativeLevel()
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->TestCooperativeLevel());
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::WaitForVBlank( UINT SwapChainIndex)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->WaitForVBlank( SwapChainIndex));
|
||||
}
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DDevice9Ex_H_
|
||||
#define uMod_IDirect3DDevice9Ex_H_
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
|
||||
|
||||
class uMod_IDirect3DDevice9Ex : public IDirect3DDevice9Ex
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DDevice9Ex( IDirect3DDevice9Ex* pOriginal, uMod_TextureServer* server, int back_buffer_count);
|
||||
virtual ~uMod_IDirect3DDevice9Ex(void);
|
||||
|
||||
// START: The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface (REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall TestCooperativeLevel(void);
|
||||
UINT __stdcall GetAvailableTextureMem(void);
|
||||
HRESULT __stdcall EvictManagedResources(void);
|
||||
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9);
|
||||
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps);
|
||||
HRESULT __stdcall GetDisplayMode(UINT iSwapChain,D3DDISPLAYMODE* pMode);
|
||||
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
|
||||
HRESULT __stdcall SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap);
|
||||
void __stdcall SetCursorPosition(int X,int Y,DWORD Flags);
|
||||
BOOL __stdcall ShowCursor(BOOL bShow);
|
||||
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) ;
|
||||
HRESULT __stdcall GetSwapChain(UINT iSwapChain,IDirect3DSwapChain9** pSwapChain);
|
||||
UINT __stdcall GetNumberOfSwapChains(void);
|
||||
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
|
||||
HRESULT __stdcall GetBackBuffer(UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer);
|
||||
HRESULT __stdcall GetRasterStatus(UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus);
|
||||
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs);
|
||||
void __stdcall SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp);
|
||||
void __stdcall GetGammaRamp(UINT iSwapChain,D3DGAMMARAMP* pRamp);
|
||||
HRESULT __stdcall CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint);
|
||||
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture);
|
||||
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter);
|
||||
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color);
|
||||
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget);
|
||||
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget);
|
||||
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil);
|
||||
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface);
|
||||
HRESULT __stdcall BeginScene(void);
|
||||
HRESULT __stdcall EndScene(void);
|
||||
HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
|
||||
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall GetLight(DWORD Index,D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall LightEnable(DWORD Index,BOOL Enable);
|
||||
HRESULT __stdcall GetLightEnable(DWORD Index,BOOL* pEnable);
|
||||
HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane);
|
||||
HRESULT __stdcall GetClipPlane(DWORD Index,float* pPlane);
|
||||
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State,DWORD Value);
|
||||
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue);
|
||||
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall BeginStateBlock(void);
|
||||
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture);
|
||||
HRESULT __stdcall SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture);
|
||||
HRESULT __stdcall GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall GetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses);
|
||||
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber);
|
||||
HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber);
|
||||
HRESULT __stdcall SetScissorRect(CONST RECT* pRect);
|
||||
HRESULT __stdcall GetScissorRect( RECT* pRect);
|
||||
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware);
|
||||
BOOL __stdcall GetSoftwareVertexProcessing(void);
|
||||
HRESULT __stdcall SetNPatchMode(float nSegments);
|
||||
float __stdcall GetNPatchMode(void);
|
||||
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
|
||||
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
|
||||
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags);
|
||||
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl);
|
||||
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetFVF(DWORD FVF);
|
||||
HRESULT __stdcall GetFVF(DWORD* pFVF);
|
||||
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader);
|
||||
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride);
|
||||
HRESULT __stdcall GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride);
|
||||
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber,UINT Divider);
|
||||
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber,UINT* Divider);
|
||||
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData);
|
||||
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData);
|
||||
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader);
|
||||
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo);
|
||||
HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo);
|
||||
HRESULT __stdcall DeletePatch(UINT Handle);
|
||||
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery);
|
||||
|
||||
|
||||
|
||||
HRESULT __stdcall CheckDeviceState( HWND hWindow);
|
||||
HRESULT __stdcall CheckResourceResidency( IDirect3DResource9 **pResourceArray, UINT32 NumResources);
|
||||
HRESULT __stdcall ComposeRects( IDirect3DSurface9 *pSource, IDirect3DSurface9 *pDestination, IDirect3DVertexBuffer9 *pSrcRectDescriptors, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescriptors, D3DCOMPOSERECTSOP Operation, INT XOffset, INT YOffset);
|
||||
HRESULT __stdcall CreateDepthStencilSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
|
||||
HRESULT __stdcall CreateOffscreenPlainSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
|
||||
HRESULT __stdcall CreateRenderTargetEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
|
||||
HRESULT __stdcall GetDisplayModeEx( UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
|
||||
HRESULT __stdcall GetGPUThreadPriority( INT *pPriority);
|
||||
HRESULT __stdcall GetMaximumFrameLatency( UINT *pMaxLatency);
|
||||
HRESULT __stdcall PresentEx( const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags);
|
||||
HRESULT __stdcall ResetEx( D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode);
|
||||
HRESULT __stdcall SetConvolutionMonoKernel( UINT Width, UINT Height, float *RowWeights, float *ColumnWeights);
|
||||
HRESULT __stdcall SetGPUThreadPriority( INT pPriority);
|
||||
HRESULT __stdcall SetMaximumFrameLatency( UINT pMaxLatency);
|
||||
//HRESULT __stdcall TestCooperativeLevel();
|
||||
HRESULT __stdcall WaitForVBlank( UINT SwapChainIndex);
|
||||
|
||||
|
||||
// END: The original DX9 function definitions
|
||||
|
||||
|
||||
uMod_TextureClient* GetuMod_Client(void) {return (uMod_Client);}
|
||||
|
||||
uMod_IDirect3DTexture9* GetLastCreatedTexture(void) {return (LastCreatedTexture);}
|
||||
int SetLastCreatedTexture(uMod_IDirect3DTexture9* pTexture) {LastCreatedTexture=pTexture; return (RETURN_OK);}
|
||||
|
||||
uMod_IDirect3DVolumeTexture9* GetLastCreatedVolumeTexture(void) {return (LastCreatedVolumeTexture);}
|
||||
int SetLastCreatedVolumeTexture(uMod_IDirect3DVolumeTexture9* pTexture) {LastCreatedVolumeTexture=pTexture; return (RETURN_OK);}
|
||||
|
||||
uMod_IDirect3DCubeTexture9* GetLastCreatedCubeTexture(void) {return (LastCreatedCubeTexture);}
|
||||
int SetLastCreatedCubeTexture(uMod_IDirect3DCubeTexture9* pTexture) {LastCreatedCubeTexture=pTexture; return (RETURN_OK);}
|
||||
|
||||
|
||||
uMod_IDirect3DTexture9* GetSingleTexture(void) {return (SingleTexture);}
|
||||
uMod_IDirect3DVolumeTexture9* GetSingleVolumeTexture(void) {return (SingleVolumeTexture);}
|
||||
uMod_IDirect3DCubeTexture9* GetSingleCubeTexture(void) {return (SingleCubeTexture);}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int CreateSingleTexture(void);
|
||||
IDirect3DDevice9Ex* m_pIDirect3DDevice9Ex;
|
||||
|
||||
int CounterSaveSingleTexture;
|
||||
uMod_IDirect3DTexture9* SingleTexture;
|
||||
uMod_IDirect3DVolumeTexture9* SingleVolumeTexture;
|
||||
uMod_IDirect3DCubeTexture9* SingleCubeTexture;
|
||||
char SingleTextureMod;
|
||||
|
||||
D3DCOLOR TextureColour;
|
||||
ID3DXFont *OSD_Font;
|
||||
//D3DCOLOR FontColour;
|
||||
int BackBufferCount;
|
||||
bool NormalRendering;
|
||||
|
||||
int uMod_Reference;
|
||||
|
||||
uMod_IDirect3DTexture9* LastCreatedTexture;
|
||||
uMod_IDirect3DVolumeTexture9* LastCreatedVolumeTexture;
|
||||
uMod_IDirect3DCubeTexture9* LastCreatedCubeTexture;
|
||||
|
||||
uMod_TextureServer* uMod_Server;
|
||||
uMod_TextureClient* uMod_Client;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* some function (e.g. AddReff()) are presumed to work on the texture object which belong to them
|
||||
* if this texture was switched, we must redirect this calls to the CrossRef_D3Dtex texture object
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000000L);
|
||||
}
|
||||
HRESULT hRes;
|
||||
if (CrossRef_D3Dtex!=NULL)
|
||||
{
|
||||
hRes = CrossRef_D3Dtex->m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==CrossRef_D3Dtex->m_D3Dtex) *ppvObj=this;
|
||||
}
|
||||
else
|
||||
{
|
||||
hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==m_D3Dtex) *ppvObj=this;
|
||||
}
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) return (1); //bug, this case should never happen
|
||||
if (CrossRef_D3Dtex!=NULL)
|
||||
{
|
||||
return (CrossRef_D3Dtex->m_D3Dtex->AddRef());
|
||||
}
|
||||
else return (m_D3Dtex->AddRef());
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::Release(): %lu\n", this);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE)
|
||||
{
|
||||
UnswitchTextures( this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) //if this texture is switched with a fake texture
|
||||
{
|
||||
uMod_IDirect3DTexture9 *fake_texture = CrossRef_D3Dtex;
|
||||
count = fake_texture->m_D3Dtex->Release(); //release the original texture
|
||||
if (count==0) //if texture is released we switch the textures back
|
||||
{
|
||||
UnswitchTextures(this);
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9*) m_D3Ddev)->GetSingleTexture()!=fake_texture) fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetSingleTexture()!=fake_texture) fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (count==0) //if this texture is released, we clean up
|
||||
{
|
||||
// if this texture is the LastCreatedTexture, the next time LastCreatedTexture would be added,
|
||||
// the hash of a non existing texture would be calculated
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9*) m_D3Ddev)->GetLastCreatedTexture()==this) ((uMod_IDirect3DDevice9*) m_D3Ddev)->SetLastCreatedTexture( NULL);
|
||||
else ((uMod_IDirect3DDevice9*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetLastCreatedTexture()==this) ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->SetLastCreatedTexture( NULL);
|
||||
else ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
|
||||
delete(this);
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DTexture9::Release() end: %lu\n", this);
|
||||
return (count);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid));
|
||||
return (m_D3Dtex->FreePrivateData(refguid));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return (m_D3Dtex->SetPriority(PriorityNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetPriority()
|
||||
{
|
||||
return (m_D3Dtex->GetPriority());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DTexture9::GetType()
|
||||
{
|
||||
return (m_D3Dtex->GetType());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return (m_D3Dtex->SetLOD(LODNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetLOD()
|
||||
{
|
||||
return (m_D3Dtex->GetLOD());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetLevelCount()
|
||||
{
|
||||
return (m_D3Dtex->GetLevelCount());
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return (m_D3Dtex->SetAutoGenFilterType(FilterType));
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return (m_D3Dtex->GetAutoGenFilterType());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetSurfaceLevel(Level, ppSurfaceLevel));
|
||||
return (m_D3Dtex->GetSurfaceLevel(Level, ppSurfaceLevel));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags));
|
||||
return (m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::UnlockRect(UINT Level)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->UnlockRect(Level));
|
||||
return (m_D3Dtex->UnlockRect(Level));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::AddDirtyRect(CONST RECT* pDirtyRect)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->AddDirtyRect(pDirtyRect));
|
||||
return (m_D3Dtex->AddDirtyRect(pDirtyRect));
|
||||
}
|
||||
|
||||
|
||||
int uMod_IDirect3DTexture9::GetHash(MyTypeHash &hash)
|
||||
{
|
||||
hash=0u;
|
||||
if (FAKE) return (RETURN_BAD_ARGUMENT);
|
||||
IDirect3DTexture9 *pTexture = m_D3Dtex;
|
||||
if (CrossRef_D3Dtex!=NULL) pTexture = CrossRef_D3Dtex->m_D3Dtex;
|
||||
|
||||
IDirect3DSurface9 *pOffscreenSurface = NULL;
|
||||
//IDirect3DTexture9 *pOffscreenTexture = NULL;
|
||||
IDirect3DSurface9 *pResolvedSurface = NULL;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DTexture9::GetHash() (%d %d) %d\n", desc.Width, desc.Height, desc.Format);
|
||||
|
||||
|
||||
if (desc.Pool==D3DPOOL_DEFAULT) //get the raw data of the texture
|
||||
{
|
||||
//Message("uMod_IDirect3DTexture9::GetHash() (D3DPOOL_DEFAULT)\n");
|
||||
|
||||
IDirect3DSurface9 *pSurfaceLevel_orig = NULL;
|
||||
if (pTexture->GetSurfaceLevel( 0, &pSurfaceLevel_orig)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: GetSurfaceLevel 1 (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
if (desc.MultiSampleType != D3DMULTISAMPLE_NONE)
|
||||
{
|
||||
//Message("uMod_IDirect3DTexture9::GetHash() MultiSampleType\n");
|
||||
if (D3D_OK!=m_D3Ddev->CreateRenderTarget( desc.Width, desc.Height, desc.Format, D3DMULTISAMPLE_NONE, 0, FALSE, &pResolvedSurface, NULL ))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: CreateRenderTarget (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (D3D_OK!=m_D3Ddev->StretchRect( pSurfaceLevel_orig, NULL, pResolvedSurface, NULL, D3DTEXF_NONE ))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: StretchRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
pSurfaceLevel_orig = pResolvedSurface;
|
||||
}
|
||||
|
||||
if (D3D_OK!=m_D3Ddev->CreateOffscreenPlainSurface( desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pOffscreenSurface, NULL))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: CreateOffscreenPlainSurface (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
|
||||
if (D3D_OK!=m_D3Ddev->GetRenderTargetData( pSurfaceLevel_orig, pOffscreenSurface))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: GetRenderTargetData (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
pSurfaceLevel_orig->Release();
|
||||
|
||||
if (pOffscreenSurface->LockRect( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: LockRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
else if (pTexture->LockRect( 0, &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetSurfaceLevel(0, &pResolvedSurface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (pResolvedSurface->LockRect( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
int size = (GetBitsFromFormat( desc.Format) * desc.Width*desc.Height)/8;
|
||||
|
||||
hash = GetCRC32( (char*) d3dlr.pBits, size); //calculate the crc32 of the texture
|
||||
|
||||
if (pOffscreenSurface!=NULL)
|
||||
{
|
||||
pOffscreenSurface->UnlockRect();
|
||||
pOffscreenSurface->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
}
|
||||
else if (pResolvedSurface!=NULL)
|
||||
{
|
||||
pResolvedSurface->UnlockRect();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else pTexture->UnlockRect(0);
|
||||
|
||||
Message("uMod_IDirect3DTexture9::GetHash() %#lX (%d %d) %d = %d\n", hash, desc.Width, desc.Height, desc.Format, size);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Matthew L (Azorbix)
|
||||
* (Direct3D StarterKit v3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DTexture9_H
|
||||
#define uMod_IDirect3DTexture9_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "uMod_Defines.h"
|
||||
|
||||
|
||||
|
||||
interface uMod_IDirect3DTexture9 : public IDirect3DTexture9
|
||||
{
|
||||
uMod_IDirect3DTexture9(IDirect3DTexture9 **ppTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = NULL; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
Reference = -1; //need for fast deleting
|
||||
Hash = 0u;
|
||||
FAKE = false;
|
||||
}
|
||||
|
||||
// callback interface
|
||||
IDirect3DTexture9 *m_D3Dtex;
|
||||
uMod_IDirect3DTexture9 *CrossRef_D3Dtex;
|
||||
IDirect3DDevice9 *m_D3Ddev;
|
||||
int Reference;
|
||||
MyTypeHash Hash;
|
||||
bool FAKE;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)();
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew);
|
||||
STDMETHOD_(DWORD, GetLOD)();
|
||||
STDMETHOD_(DWORD, GetLevelCount)();
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType);
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)();
|
||||
STDMETHOD_(void, GenerateMipSubLevels)();
|
||||
STDMETHOD(GetLevelDesc)(UINT Level,D3DSURFACE_DESC *pDesc);
|
||||
STDMETHOD(GetSurfaceLevel)(UINT Level,IDirect3DSurface9** ppSurfaceLevel);
|
||||
STDMETHOD(LockRect)(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
|
||||
STDMETHOD(UnlockRect)(UINT Level);
|
||||
STDMETHOD(AddDirtyRect)(CONST RECT* pDirtyRect);
|
||||
|
||||
int GetHash(MyTypeHash &hash);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void UnswitchTextures(uMod_IDirect3DTexture9 *pTexture)
|
||||
{
|
||||
uMod_IDirect3DTexture9* CrossRef = pTexture->CrossRef_D3Dtex;
|
||||
if (CrossRef!=NULL)
|
||||
{
|
||||
// switch textures back
|
||||
IDirect3DTexture9* cpy = pTexture->m_D3Dtex;
|
||||
pTexture->m_D3Dtex = CrossRef->m_D3Dtex;
|
||||
CrossRef->m_D3Dtex = cpy;
|
||||
|
||||
// cancel the link
|
||||
CrossRef->CrossRef_D3Dtex = NULL;
|
||||
pTexture->CrossRef_D3Dtex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline int SwitchTextures( uMod_IDirect3DTexture9 *pTexture1, uMod_IDirect3DTexture9 *pTexture2)
|
||||
{
|
||||
if (pTexture1->m_D3Ddev == pTexture2->m_D3Ddev && pTexture1->CrossRef_D3Dtex == NULL && pTexture2->CrossRef_D3Dtex == NULL)
|
||||
{
|
||||
// make cross reference
|
||||
pTexture1->CrossRef_D3Dtex = pTexture2;
|
||||
pTexture2->CrossRef_D3Dtex = pTexture1;
|
||||
|
||||
// switch textures
|
||||
IDirect3DTexture9* cpy = pTexture2->m_D3Dtex;
|
||||
pTexture2->m_D3Dtex = pTexture1->m_D3Dtex;
|
||||
pTexture1->m_D3Dtex = cpy;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
else return (RETURN_TEXTURE_NOT_SWITCHED);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,385 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* some function (e.g. AddReff()) are presumed to work on the texture object which belong to them
|
||||
* if this texture was switched, we must redirect this calls to the CrossRef_D3Dtex texture object
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000001L);
|
||||
}
|
||||
HRESULT hRes;
|
||||
if (CrossRef_D3Dtex!=NULL)
|
||||
{
|
||||
hRes = CrossRef_D3Dtex->m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==CrossRef_D3Dtex->m_D3Dtex) *ppvObj=this;
|
||||
}
|
||||
else
|
||||
{
|
||||
hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==m_D3Dtex) *ppvObj=this;
|
||||
}
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DVolumeTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) return (1); //bug, this case should never happen
|
||||
if (CrossRef_D3Dtex!=NULL)
|
||||
{
|
||||
return (CrossRef_D3Dtex->m_D3Dtex->AddRef());
|
||||
}
|
||||
else return (m_D3Dtex->AddRef());
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DVolumeTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::Release(): %lu\n", this);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE)
|
||||
{
|
||||
UnswitchTextures( this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) //if this texture is switched with a fake texture
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9 *fake_texture = CrossRef_D3Dtex;
|
||||
count = fake_texture->m_D3Dtex->Release(); //release the original texture
|
||||
if (count==0) //if texture is released we switch the textures back
|
||||
{
|
||||
UnswitchTextures(this);
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9*) m_D3Ddev)->GetSingleVolumeTexture()!=fake_texture) fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetSingleVolumeTexture()!=fake_texture) fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (count==0) //if this texture is released, we clean up
|
||||
{
|
||||
// if this texture is the LastCreatedTexture, the next time LastCreatedTexture would be added,
|
||||
// the hash of a non existing texture would be calculated
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9*) m_D3Ddev)->GetLastCreatedVolumeTexture()==this) ((uMod_IDirect3DDevice9*) m_D3Ddev)->SetLastCreatedVolumeTexture( NULL);
|
||||
else ((uMod_IDirect3DDevice9*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetLastCreatedVolumeTexture()==this) ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->SetLastCreatedVolumeTexture( NULL);
|
||||
else ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
|
||||
delete(this);
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid));
|
||||
return (m_D3Dtex->FreePrivateData(refguid));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return (m_D3Dtex->SetPriority(PriorityNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetPriority()
|
||||
{
|
||||
return (m_D3Dtex->GetPriority());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DVolumeTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DVolumeTexture9::GetType()
|
||||
{
|
||||
return (m_D3Dtex->GetType());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return (m_D3Dtex->SetLOD(LODNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetLOD()
|
||||
{
|
||||
return (m_D3Dtex->GetLOD());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetLevelCount()
|
||||
{
|
||||
return (m_D3Dtex->GetLevelCount());
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return (m_D3Dtex->SetAutoGenFilterType(FilterType));
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DVolumeTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return (m_D3Dtex->GetAutoGenFilterType());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DVolumeTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::AddDirtyBox(CONST D3DBOX *pDirtyBox)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->AddDirtyBox(pDirtyBox));
|
||||
return (m_D3Dtex->AddDirtyBox(pDirtyBox));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetLevelDesc(UINT Level, D3DVOLUME_DESC *pDesc)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetVolumeLevel(UINT Level, IDirect3DVolume9 **ppVolumeLevel)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetVolumeLevel(Level, ppVolumeLevel));
|
||||
return (m_D3Dtex->GetVolumeLevel(Level, ppVolumeLevel));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::LockBox(UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox ,DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->LockBox(Level, pLockedVolume, pBox, Flags));
|
||||
return (m_D3Dtex->LockBox(Level, pLockedVolume, pBox, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::UnlockBox(UINT Level)
|
||||
{
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->UnlockBox(Level));
|
||||
return (m_D3Dtex->UnlockBox(Level));
|
||||
}
|
||||
|
||||
|
||||
int uMod_IDirect3DVolumeTexture9::GetHash(MyTypeHash &hash)
|
||||
{
|
||||
hash=0u;
|
||||
if (FAKE) return (RETURN_BAD_ARGUMENT);
|
||||
IDirect3DVolumeTexture9 *pTexture = m_D3Dtex;
|
||||
if (CrossRef_D3Dtex!=NULL) pTexture = CrossRef_D3Dtex->m_D3Dtex;
|
||||
|
||||
//IDirect3DVolume9 *pOffscreenSurface = NULL;
|
||||
//IDirect3DVolumeTexture9 *pOffscreenTexture = NULL;
|
||||
IDirect3DVolume9 *pResolvedSurface = NULL;
|
||||
D3DLOCKED_BOX d3dlr;
|
||||
D3DVOLUME_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() (%d %d %d) %d\n", desc.Width, desc.Height, desc.Depth, desc.Format);
|
||||
|
||||
/*
|
||||
if (desc.Pool==D3DPOOL_DEFAULT) //get the raw data of the texture
|
||||
{
|
||||
//Message("uMod_IDirect3DVolumeTexture9::GetHash() (D3DPOOL_DEFAULT)\n");
|
||||
|
||||
IDirect3DSurface9 *pSurfaceLevel_orig = NULL;
|
||||
if (pTexture->GetSurfaceLevel( 0, &pSurfaceLevel_orig)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetSurfaceLevel 1 (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
/*
|
||||
if (desc.MultiSampleType != D3DMULTISAMPLE_NONE)
|
||||
{
|
||||
//Message("uMod_IDirect3DVolumeTexture9::GetHash() MultiSampleType\n");
|
||||
if (D3D_OK!=m_D3Ddev->CreateRenderTarget( desc.Width, desc.Height, desc.Format, D3DMULTISAMPLE_NONE, 0, FALSE, &pResolvedSurface, NULL ))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: CreateRenderTarget (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (D3D_OK!=m_D3Ddev->StretchRect( pSurfaceLevel_orig, NULL, pResolvedSurface, NULL, D3DTEXF_NONE ))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: StretchRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
pSurfaceLevel_orig = pResolvedSurface;
|
||||
}
|
||||
*/
|
||||
//CreateTexture(8, 8, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, (IDirect3DVolumeTexture9**) &SingleTexture, NULL)
|
||||
/*
|
||||
if (D3D_OK!=m_D3Ddev->CreateTexture( desc.Width, desc.Height, 1, 0, desc.Format, D3DPOOL_SYSTEMMEM, &pOffscreenTexture, NULL))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: CreateTexture (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
if (pOffscreenTexture->GetSurfaceLevel( 0, &pOffscreenSurface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetSurfaceLevel 2 (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
if (D3D_OK!=m_D3Ddev->GetRenderTargetData( pSurfaceLevel_orig, pOffscreenSurface))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
pOffscreenTexture->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetRenderTargetData (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
pSurfaceLevel_orig->Release();
|
||||
|
||||
if (pOffscreenSurface->LockRect( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
pOffscreenTexture->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (D3D_OK!=m_D3Ddev->CreateOffscreenPlainSurface( desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pOffscreenSurface, NULL))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: CreateOffscreenPlainSurface (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
|
||||
if (D3D_OK!=m_D3Ddev->GetRenderTargetData( pSurfaceLevel_orig, pOffscreenSurface))
|
||||
{
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetRenderTargetData (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
pSurfaceLevel_orig->Release();
|
||||
|
||||
if (pOffscreenSurface->LockRect( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
if (pResolvedSurface!=NULL) pResolvedSurface->Release();
|
||||
pOffscreenSurface->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect (D3DPOOL_DEFAULT)\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
if (pTexture->LockBox( 0, &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetVolumeLevel(0, &pResolvedSurface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (pResolvedSurface->LockBox( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
int size = (GetBitsFromFormat( desc.Format) * desc.Width*desc.Height*desc.Depth)/8;
|
||||
|
||||
hash = GetCRC32( (char*) d3dlr.pBits, size); //calculate the crc32 of the texture
|
||||
|
||||
|
||||
if (pResolvedSurface!=NULL)
|
||||
{
|
||||
pResolvedSurface->UnlockBox();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else pTexture->UnlockBox(0);
|
||||
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() %#lX (%d %d) %d = %d\n", hash, desc.Width, desc.Height, desc.Format, size);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Matthew L (Azorbix)
|
||||
* (Direct3D StarterKit v3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DVolumeTexture9_H
|
||||
#define uMod_IDirect3DVolumeTexture9_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "uMod_Defines.h"
|
||||
|
||||
|
||||
|
||||
interface uMod_IDirect3DVolumeTexture9 : public IDirect3DVolumeTexture9
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 **ppTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = NULL; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DVolumeTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
Reference = -1; //need for fast deleting
|
||||
Hash = 0u;
|
||||
FAKE = false;
|
||||
}
|
||||
|
||||
// callback interface
|
||||
IDirect3DVolumeTexture9 *m_D3Dtex;
|
||||
uMod_IDirect3DVolumeTexture9 *CrossRef_D3Dtex;
|
||||
IDirect3DDevice9 *m_D3Ddev;
|
||||
int Reference;
|
||||
MyTypeHash Hash;
|
||||
bool FAKE;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)();
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew);
|
||||
STDMETHOD_(DWORD, GetLOD)();
|
||||
STDMETHOD_(DWORD, GetLevelCount)();
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType);
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)();
|
||||
STDMETHOD_(void, GenerateMipSubLevels)();
|
||||
STDMETHOD(AddDirtyBox)(CONST D3DBOX *pDirtyBox);
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DVOLUME_DESC *pDesc);
|
||||
STDMETHOD(GetVolumeLevel)(UINT Level, IDirect3DVolume9 **ppVolumeLevel);
|
||||
STDMETHOD(LockBox)(UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags);
|
||||
STDMETHOD(UnlockBox)(UINT Level);
|
||||
|
||||
|
||||
int GetHash(MyTypeHash &hash);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void UnswitchTextures(uMod_IDirect3DVolumeTexture9 *pTexture)
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9* CrossRef = pTexture->CrossRef_D3Dtex;
|
||||
if (CrossRef!=NULL)
|
||||
{
|
||||
// switch textures back
|
||||
IDirect3DVolumeTexture9* cpy = pTexture->m_D3Dtex;
|
||||
pTexture->m_D3Dtex = CrossRef->m_D3Dtex;
|
||||
CrossRef->m_D3Dtex = cpy;
|
||||
|
||||
// cancel the link
|
||||
CrossRef->CrossRef_D3Dtex = NULL;
|
||||
pTexture->CrossRef_D3Dtex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline int SwitchTextures( uMod_IDirect3DVolumeTexture9 *pTexture1, uMod_IDirect3DVolumeTexture9 *pTexture2)
|
||||
{
|
||||
if (pTexture1->m_D3Ddev == pTexture2->m_D3Ddev && pTexture1->CrossRef_D3Dtex == NULL && pTexture2->CrossRef_D3Dtex == NULL)
|
||||
{
|
||||
// make cross reference
|
||||
pTexture1->CrossRef_D3Dtex = pTexture2;
|
||||
pTexture2->CrossRef_D3Dtex = pTexture1;
|
||||
|
||||
// switch textures
|
||||
IDirect3DVolumeTexture9* cpy = pTexture2->m_D3Dtex;
|
||||
pTexture2->m_D3Dtex = pTexture1->m_D3Dtex;
|
||||
pTexture1->m_D3Dtex = cpy;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
else return (RETURN_TEXTURE_NOT_SWITCHED);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_MAIN_H_
|
||||
#define uMod_MAIN_H_
|
||||
|
||||
#define WINVER _WIN32_WINNT_WINXP
|
||||
#define _WIN32_WINNT _WIN32_WINNT_WINXP
|
||||
#define _WIN32_WINDOWS _WIN32_WINNT_WINXP
|
||||
#define NTDDI_VERSION NTDDI_WINXP
|
||||
//#define NTDDI_LONGHORN NTDDI_WINXP
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../uMod_GlobalDefines.h"
|
||||
#include "../uMod_Error.h"
|
||||
#include "uMod_Defines.h"
|
||||
#include "uMod_DX9_dll.h"
|
||||
#include "uMod_TextureFunction.h"
|
||||
|
||||
#include "uMod_IDirect3D9.h"
|
||||
#include "uMod_IDirect3D9Ex.h"
|
||||
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DDevice9Ex.h"
|
||||
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
|
||||
#include "uMod_ArrayHandler.h"
|
||||
#include "uMod_TextureServer.h"
|
||||
#include "uMod_TextureClient.h"
|
||||
|
||||
|
||||
extern unsigned int gl_ErrorState;
|
||||
|
||||
#endif
|
||||
@@ -1,863 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
uMod_TextureClient::uMod_TextureClient(uMod_TextureServer* server, IDirect3DDevice9* device)
|
||||
{
|
||||
Message("uMod_TextureClient::uMod_TextureClient(void): %lu\n", this);
|
||||
Server = server;
|
||||
D3D9Device = device;
|
||||
BoolSaveAllTextures = false;
|
||||
BoolSaveSingleTexture = false;
|
||||
KeyBack = 0;
|
||||
KeySave = 0;
|
||||
KeyNext = 0;
|
||||
SavePath[0]=0;
|
||||
GameName[0]=0;
|
||||
|
||||
NumberToMod = 0;
|
||||
FileToMod = NULL;
|
||||
|
||||
if (Server!=NULL)
|
||||
{
|
||||
if (Server->AddClient( this, &FileToMod, &NumberToMod))
|
||||
{
|
||||
Server=NULL;
|
||||
NumberToMod = 0;
|
||||
FileToMod = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<NumberToMod; i++) {FileToMod[i].NumberOfTextures=0; FileToMod[i].Textures = NULL;}
|
||||
}
|
||||
}
|
||||
Mutex = CreateMutex(NULL, false, NULL);
|
||||
|
||||
Update = NULL;
|
||||
NumberOfUpdate = -1;
|
||||
FontColour = D3DCOLOR_ARGB(255,255,0,0);
|
||||
TextureColour = D3DCOLOR_ARGB(255,0,255,0);
|
||||
}
|
||||
|
||||
uMod_TextureClient::~uMod_TextureClient(void)
|
||||
{
|
||||
Message("uMod_TextureClient::~uMod_TextureClient(void): %lu\n", this);
|
||||
if (Server!=NULL) Server->RemoveClient(this);
|
||||
|
||||
if (Mutex!=NULL) CloseHandle(Mutex);
|
||||
|
||||
if (Update!=NULL) delete [] Update;
|
||||
if (FileToMod!=NULL)
|
||||
{
|
||||
for (int i=0; i<NumberToMod; i++) if (FileToMod[i].Textures!=NULL) delete [] FileToMod[i].Textures;
|
||||
delete [] FileToMod;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient::AddTexture( uMod_IDirect3DTexture9* pTexture)
|
||||
{
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice
|
||||
|
||||
if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture
|
||||
|
||||
Message("uMod_TextureClient::AddTexture( %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
MyTypeHash hash;
|
||||
if (int ret = pTexture->GetHash( hash)) return (ret);
|
||||
|
||||
pTexture->Hash = hash;
|
||||
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
OriginalTextures.Add( pTexture); // add the texture to the list of original texture
|
||||
|
||||
return (LookUpToMod(pTexture)); // check if this texture should be modded
|
||||
}
|
||||
|
||||
int uMod_TextureClient::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture)
|
||||
{
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice
|
||||
|
||||
if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture
|
||||
|
||||
Message("uMod_TextureClient::AddTexture( Volume: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
MyTypeHash hash;
|
||||
if (int ret = pTexture->GetHash( hash)) return (ret);
|
||||
|
||||
pTexture->Hash = hash;
|
||||
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
OriginalVolumeTextures.Add( pTexture); // add the texture to the list of original texture
|
||||
|
||||
return (LookUpToMod(pTexture)); // check if this texture should be modded
|
||||
}
|
||||
|
||||
int uMod_TextureClient::AddTexture( uMod_IDirect3DCubeTexture9* pTexture)
|
||||
{
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice
|
||||
|
||||
if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture
|
||||
|
||||
Message("uMod_TextureClient::AddTexture( Cube: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
MyTypeHash hash;
|
||||
if (int ret = pTexture->GetHash( hash)) return (ret);
|
||||
|
||||
pTexture->Hash = hash;
|
||||
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
OriginalCubeTextures.Add( pTexture); // add the texture to the list of original texture
|
||||
|
||||
return (LookUpToMod(pTexture)); // check if this texture should be modded
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::RemoveTexture( uMod_IDirect3DTexture9* pTexture) // is called from a texture, if it is finally released
|
||||
{
|
||||
Message("uMod_TextureClient::RemoveTexture( %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
if (pTexture->FAKE)
|
||||
{
|
||||
// we need to set the corresponding FileToMod[X].pTexture to NULL, to avoid a link to a non existing texture object
|
||||
int ref = pTexture->Reference;
|
||||
if (ref>=0 && ref<NumberToMod)
|
||||
{
|
||||
for (int i=0; i<FileToMod[ref].NumberOfTextures; i++) if (FileToMod[ref].Textures[i] == pTexture)
|
||||
{
|
||||
FileToMod[ref].NumberOfTextures--;
|
||||
for (int j=i; j<FileToMod[ref].NumberOfTextures; j++) FileToMod[ref].Textures[j] = FileToMod[ref].Textures[j+1];
|
||||
FileToMod[ref].Textures[FileToMod[ref].NumberOfTextures] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (OriginalTextures.Remove( pTexture)); //remove this texture form the list
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::RemoveTexture( uMod_IDirect3DVolumeTexture9* pTexture) // is called from a texture, if it is finally released
|
||||
{
|
||||
Message("uMod_TextureClient::RemoveTexture( Volume %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
if (pTexture->FAKE)
|
||||
{
|
||||
// we need to set the corresponding FileToMod[X].pTexture to NULL, to avoid a link to a non existing texture object
|
||||
int ref = pTexture->Reference;
|
||||
if (ref>=0 && ref<NumberToMod)
|
||||
{
|
||||
for (int i=0; i<FileToMod[ref].NumberOfTextures; i++) if (FileToMod[ref].Textures[i] == pTexture)
|
||||
{
|
||||
FileToMod[ref].NumberOfTextures--;
|
||||
for (int j=i; j<FileToMod[ref].NumberOfTextures; j++) FileToMod[ref].Textures[j] = FileToMod[ref].Textures[j+1];
|
||||
FileToMod[ref].Textures[FileToMod[ref].NumberOfTextures] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (OriginalVolumeTextures.Remove( pTexture)); //remove this texture form the list
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::RemoveTexture( uMod_IDirect3DCubeTexture9* pTexture) // is called from a texture, if it is finally released
|
||||
{
|
||||
Message("uMod_TextureClient::RemoveTexture( Cube %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
if (pTexture->FAKE)
|
||||
{
|
||||
// we need to set the corresponding FileToMod[X].pTexture to NULL, to avoid a link to a non existing texture object
|
||||
int ref = pTexture->Reference;
|
||||
if (ref>=0 && ref<NumberToMod)
|
||||
{
|
||||
for (int i=0; i<FileToMod[ref].NumberOfTextures; i++) if (FileToMod[ref].Textures[i] == pTexture)
|
||||
{
|
||||
FileToMod[ref].NumberOfTextures--;
|
||||
for (int j=i; j<FileToMod[ref].NumberOfTextures; j++) FileToMod[ref].Textures[j] = FileToMod[ref].Textures[j+1];
|
||||
FileToMod[ref].Textures[FileToMod[ref].NumberOfTextures] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (OriginalCubeTextures.Remove( pTexture)); //remove this texture form the list
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient::SaveAllTextures(bool val)
|
||||
{
|
||||
Message("uMod_TextureClient::SaveAllTextures( %d): %lu\n", val, this);
|
||||
BoolSaveAllTextures=val;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::SaveSingleTexture(bool val)
|
||||
{
|
||||
Message("uMod_TextureClient::SaveSingleTexture( %d): %lu\n", val, this);
|
||||
if (BoolSaveSingleTexture && !val) //if BoolSaveSingleTexture is set to false and was previously true we switch the SingleTexture back
|
||||
{
|
||||
uMod_IDirect3DTexture9* pTexture;
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) pTexture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleTexture(); //this texture must no be added twice
|
||||
else pTexture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleTexture(); //this texture must no be added twice
|
||||
|
||||
if (pTexture!=NULL) UnswitchTextures(pTexture);
|
||||
}
|
||||
BoolSaveSingleTexture = val;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient::SetSaveDirectory( wchar_t *dir)
|
||||
{
|
||||
Message("uMod_TextureClient::SetSaveDirectory( %ls): %lu\n", dir, this);
|
||||
int i = 0;
|
||||
for (i=0; i<MAX_PATH && (dir[i]); i++) SavePath[i] = dir[i];
|
||||
if (i==MAX_PATH)
|
||||
{
|
||||
SavePath[0]=0;
|
||||
return (RETURN_BAD_ARGUMENT);
|
||||
}
|
||||
else SavePath[i]=0;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::SetGameName( wchar_t *name)
|
||||
{
|
||||
Message("uMod_TextureClient::SetGameName( %ls): %lu\n", name, this);
|
||||
int i = 0;
|
||||
for (i=0; i<MAX_PATH && (name[i]); i++) GameName[i] = name[i];
|
||||
if (i==MAX_PATH)
|
||||
{
|
||||
GameName[0]=0;
|
||||
return (RETURN_BAD_ARGUMENT);
|
||||
}
|
||||
else GameName[i]=0;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::SaveTexture(uMod_IDirect3DTexture9* pTexture)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);}
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_T_%#lX.dds", SavePath, GameName, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\T_%#lX.dds", SavePath, pTexture->Hash);
|
||||
Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);}
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_V_%#lX.dds", SavePath, GameName, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\V_%#lX.dds", SavePath, pTexture->Hash);
|
||||
Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::SaveTexture(uMod_IDirect3DCubeTexture9* pTexture)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);}
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_C_%#lX.dds", SavePath, GameName, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\C_%#lX.dds", SavePath, pTexture->Hash);
|
||||
Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::AddUpdate(TextureFileStruct* update, int number) //client must delete the update array
|
||||
{
|
||||
Message("AddUpdate( %lu, %d): %lu\n", update, number, this);
|
||||
if (int ret = LockMutex()) {gl_ErrorState |= uMod_ERROR_TEXTURE; return (ret);}
|
||||
if (Update!=NULL) delete [] Update;
|
||||
Update = update;
|
||||
NumberOfUpdate = number;
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::MergeUpdate(void)
|
||||
{
|
||||
if (NumberOfUpdate<0) {return (RETURN_OK);}
|
||||
if (int ret = LockMutex()) {gl_ErrorState |= uMod_ERROR_TEXTURE ; return (ret);}
|
||||
|
||||
Message("MergeUpdate(): %lu\n", this);
|
||||
|
||||
for (int i=0; i<NumberOfUpdate; i++) {Update[i].NumberOfTextures=0; Update[i].Textures = NULL;} // this is already done, but safety comes first ^^
|
||||
|
||||
int pos_old=0;
|
||||
int pos_new=0;
|
||||
int *to_lookup = NULL;
|
||||
if (NumberOfUpdate>0) to_lookup = new int[NumberOfUpdate];
|
||||
int num_to_lookup = 0;
|
||||
|
||||
/*
|
||||
* FileToMod contains the old files (textures) which should replace the target textures (if they are loaded by the game)
|
||||
* Update contains the new files (textures) which should replace the target textures (if they are loaded by the game)
|
||||
*
|
||||
* Both arrays (FileToMod and Update) are sorted according to their hash values.
|
||||
*
|
||||
* First we go through both arrays linearly and
|
||||
* 1) take over the old entry if the hash is the same,
|
||||
* 2) release old fake texture (if target texture exist and is not in the Update)
|
||||
* 3) or mark newly added fake texture (if they are not in FileToMod)
|
||||
*/
|
||||
|
||||
while (pos_old<NumberToMod && pos_new<NumberOfUpdate)
|
||||
{
|
||||
if (FileToMod[pos_old].Hash > Update[pos_new].Hash) // this fake texture is new
|
||||
{
|
||||
to_lookup[num_to_lookup++] = pos_new++; // keep this fake texture in mind, we must search later for it through all original textures
|
||||
// we increase only the new counter by one
|
||||
}
|
||||
else if (FileToMod[pos_old].Hash < Update[pos_new].Hash) // this fake texture is not in the update
|
||||
{
|
||||
for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
|
||||
if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory
|
||||
FileToMod[pos_old].NumberOfTextures = 0;
|
||||
FileToMod[pos_old].Textures = NULL;
|
||||
|
||||
pos_old++; // we increase only the old counter by one
|
||||
}
|
||||
else // the hash value is the same, thus this texture is in the array FileToMod as well as in the array Update
|
||||
{
|
||||
if (Update[pos_new].ForceReload)
|
||||
{
|
||||
if (FileToMod[pos_old].NumberOfTextures>0)
|
||||
{
|
||||
Update[pos_new].Textures = new IDirect3DBaseTexture9*[FileToMod[pos_old].NumberOfTextures];
|
||||
}
|
||||
for (int i=0; i<FileToMod[pos_old].NumberOfTextures; i++)
|
||||
{
|
||||
IDirect3DBaseTexture9 *base_texture;
|
||||
int ret = FileToMod[pos_old].Textures[i]->QueryInterface( IID_IDirect3D9, (void**)&base_texture);
|
||||
switch (ret)
|
||||
{
|
||||
case 0x01000000L:
|
||||
{
|
||||
uMod_IDirect3DTexture9 *pTexture = (uMod_IDirect3DTexture9*) FileToMod[pos_old].Textures[i];//
|
||||
uMod_IDirect3DTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex;
|
||||
pTexture->Release();
|
||||
i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i
|
||||
|
||||
uMod_IDirect3DTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pRefTexture))
|
||||
{
|
||||
Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Update[pos_new].Textures[Update[pos_new].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = pos_new;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01000001L:
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9 *pTexture = (uMod_IDirect3DVolumeTexture9*) FileToMod[pos_old].Textures[i];//
|
||||
uMod_IDirect3DVolumeTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex;
|
||||
pTexture->Release();
|
||||
i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i
|
||||
|
||||
uMod_IDirect3DVolumeTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pRefTexture))
|
||||
{
|
||||
Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Update[pos_new].Textures[Update[pos_new].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = pos_new;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01000002L:
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9 *pTexture = (uMod_IDirect3DCubeTexture9*) FileToMod[pos_old].Textures[i];//
|
||||
uMod_IDirect3DCubeTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex;
|
||||
pTexture->Release();
|
||||
i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i
|
||||
|
||||
uMod_IDirect3DCubeTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pRefTexture))
|
||||
{
|
||||
Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Update[pos_new].Textures[Update[pos_new].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = pos_new;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break; // this is no fake texture and QueryInterface failed, because IDirect3DBaseTexture9 object cannot be a IDirect3D9 object ;)
|
||||
}
|
||||
}
|
||||
}
|
||||
else // the texture might be loaded or not
|
||||
{
|
||||
Update[pos_new].NumberOfTextures = FileToMod[pos_old].NumberOfTextures;
|
||||
Update[pos_new].Textures = FileToMod[pos_old].Textures;
|
||||
FileToMod[pos_old].NumberOfTextures = 0;
|
||||
FileToMod[pos_old].Textures = NULL;
|
||||
}
|
||||
// we increase both counters by one
|
||||
pos_old++;
|
||||
pos_new++;
|
||||
}
|
||||
}
|
||||
|
||||
while (pos_old<NumberToMod) //this fake textures are not in the Update
|
||||
{
|
||||
for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
|
||||
//for (int i=0; i<FileToMod[pos_old].NumberOfTextures; i++) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
|
||||
if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory
|
||||
FileToMod[pos_old].Textures = NULL;
|
||||
pos_old++;
|
||||
}
|
||||
while (pos_new<NumberOfUpdate) //this fake textures are newly added
|
||||
{
|
||||
to_lookup[num_to_lookup++] = pos_new++; //keep this fake texture in mind, we must search later for it through all original textures
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if (num_to_lookup>0) we need to look through all original textures
|
||||
* because there were newly added textures and we don't know
|
||||
* if the corresponding target textures are loaded by the game or not.
|
||||
*
|
||||
* Note: to_lookup[num_to_lookup++] = pos_new++; is in ascending order,
|
||||
* thus Update[to_lookup[pos]].Hash is also sorted ascending!
|
||||
*/
|
||||
/*
|
||||
uMod_IDirect3DTexture9 *single_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleTexture();
|
||||
if (num_to_lookup>0)
|
||||
{
|
||||
int num = OriginalTextures.GetNumber();
|
||||
for (int i=0; i<num; i++)
|
||||
if (OriginalTextures[i]->CrossRef_D3Dtex==NULL || OriginalTextures[i]->CrossRef_D3Dtex==single_texture)
|
||||
// We need look only for textures, that are not switched or switched with the single_texture.
|
||||
// The single_texture is a special texture, which you can toggle through all original texture, if save single texture is turned on.
|
||||
{
|
||||
MyTypeHash hash = OriginalTextures[i]->Hash;
|
||||
|
||||
if (hash<Update[to_lookup[0]].Hash || hash>Update[to_lookup[num_to_lookup-1]].Hash) continue;
|
||||
|
||||
int index = -1;
|
||||
int pos = num_to_lookup/2;
|
||||
int begin = 0;
|
||||
int end = num_to_lookup-1;
|
||||
|
||||
// We look in the middle of the interval and each step we halve the interval,
|
||||
// unless we find the texture or the size of the interval is less than 3.
|
||||
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
|
||||
while (begin+1<end) // as long as the interval is longer than two
|
||||
{
|
||||
if (hash > Update[to_lookup[pos]].Hash) // the new interval is the right half of the actual interval
|
||||
{
|
||||
begin = pos+1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
|
||||
}
|
||||
else if (hash < Update[to_lookup[pos]].Hash) // the new interval is the left half of the actual interval
|
||||
{
|
||||
end = pos-1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
|
||||
}
|
||||
else {index = to_lookup[pos]; break;} // we hit the correct hash
|
||||
}
|
||||
if (index<0) // if we did not find the hash, it might be in the last interval
|
||||
{
|
||||
for (int i=begin; i<=end; i++) if (Update[to_lookup[i]].Hash==hash) index = to_lookup[i];
|
||||
}
|
||||
|
||||
if (index>=0) // target texture is loaded by the game
|
||||
{
|
||||
if (OriginalTextures[i]->CrossRef_D3Dtex!=NULL) UnswitchTextures(OriginalTextures[i]); // this texture was switched with the single texture
|
||||
|
||||
uMod_IDirect3DTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (Update[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, OriginalTextures[i]))
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[Update[index].NumberOfTextures+1];
|
||||
for (int j=0; j<Update[index].NumberOfTextures; j++) temp[j] = Update[index].Textures[j];
|
||||
|
||||
if (Update[index].Textures!=NULL) delete [] Update[index].Textures;
|
||||
Update[index].Textures = temp;
|
||||
|
||||
Update[index].Textures[Update[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (FileToMod!=NULL)
|
||||
{
|
||||
//for (int i=0; i<NumberToMod; i++) if (FileToMod[i].Textures!=NULL) delete [] FileToMod[i].Textures;
|
||||
delete [] FileToMod;
|
||||
}
|
||||
|
||||
FileToMod = Update;
|
||||
NumberToMod = NumberOfUpdate;
|
||||
|
||||
NumberOfUpdate = -1;
|
||||
Update = NULL;
|
||||
|
||||
|
||||
if (num_to_lookup>0)
|
||||
{
|
||||
uMod_IDirect3DTexture9* single_texture;
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) single_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleTexture(); //this texture must no be added twice
|
||||
else single_texture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleTexture(); //this texture must no be added twice
|
||||
|
||||
int num = OriginalTextures.GetNumber();
|
||||
for (int i=0; i<num; i++) if (OriginalTextures[i]->CrossRef_D3Dtex==NULL || OriginalTextures[i]->CrossRef_D3Dtex==single_texture)
|
||||
{
|
||||
UnswitchTextures(OriginalTextures[i]); //this we can do always, so we unswitch the single texture
|
||||
LookUpToMod( OriginalTextures[i], num_to_lookup, to_lookup);
|
||||
}
|
||||
|
||||
uMod_IDirect3DVolumeTexture9 *single_volume_texture;
|
||||
if (ret == 0x01000000L) single_volume_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleVolumeTexture(); //this texture must no be added twice
|
||||
else single_volume_texture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleVolumeTexture(); //this texture must no be added twice
|
||||
num = OriginalVolumeTextures.GetNumber();
|
||||
for (int i=0; i<num; i++) if (OriginalVolumeTextures[i]->CrossRef_D3Dtex==NULL || OriginalVolumeTextures[i]->CrossRef_D3Dtex==single_volume_texture)
|
||||
{
|
||||
UnswitchTextures(OriginalVolumeTextures[i]); //this we can do always, so we unswitch the single texture
|
||||
LookUpToMod( OriginalVolumeTextures[i], num_to_lookup, to_lookup);
|
||||
}
|
||||
|
||||
uMod_IDirect3DCubeTexture9 *single_cube_texture;
|
||||
if (ret == 0x01000000L) single_cube_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleCubeTexture(); //this texture must no be added twice
|
||||
else single_cube_texture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleCubeTexture(); //this texture must no be added twice
|
||||
num = OriginalCubeTextures.GetNumber();
|
||||
for (int i=0; i<num; i++) if (OriginalCubeTextures[i]->CrossRef_D3Dtex==NULL || OriginalCubeTextures[i]->CrossRef_D3Dtex==single_cube_texture)
|
||||
{
|
||||
UnswitchTextures(OriginalCubeTextures[i]); //this we can do always, so we unswitch the single texture
|
||||
LookUpToMod( OriginalCubeTextures[i], num_to_lookup, to_lookup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (to_lookup != NULL) delete [] to_lookup;
|
||||
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::LockMutex(void)
|
||||
{
|
||||
if (( gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX) )) return (RETURN_NO_MUTEX);
|
||||
if (WAIT_OBJECT_0!=WaitForSingleObject( Mutex, 100)) return (RETURN_MUTEX_LOCK); //waiting 100ms, to wait infinite pass INFINITE
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::UnlockMutex(void)
|
||||
{
|
||||
if (ReleaseMutex(Mutex)==0) return (RETURN_MUTEX_UNLOCK);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list)
|
||||
{
|
||||
if(NumberToMod>0)
|
||||
{
|
||||
if (index_list==NULL || num_index_list==0)
|
||||
{
|
||||
if (hash<FileToMod[0].Hash || hash>FileToMod[NumberToMod-1].Hash) return (-1);
|
||||
int pos = NumberToMod/2;
|
||||
int begin = 0;
|
||||
int end = NumberToMod-1;
|
||||
|
||||
// We look in the middle of the interval and each step we halve the interval,
|
||||
// unless we find the texture or the size of the interval is less than 3.
|
||||
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
|
||||
while (begin+1<end) // as long as the interval is longer than two
|
||||
{
|
||||
if (hash > FileToMod[pos].Hash) // the new interval is the right half of the actual interval
|
||||
{
|
||||
begin = pos+1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else if (hash < FileToMod[pos].Hash) // the new interval is the left half of the actual interval
|
||||
{
|
||||
end = pos-1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else {return (pos); break;} // we hit the correct hash
|
||||
}
|
||||
for ( pos=begin; pos<=end; pos++) if (FileToMod[pos].Hash==hash) return (pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hash<FileToMod[index_list[0]].Hash || hash>FileToMod[index_list[num_index_list-1]].Hash) return (-1);
|
||||
int pos = num_index_list/2;
|
||||
int begin = 0;
|
||||
int end = num_index_list-1;
|
||||
|
||||
// We look in the middle of the interval and each step we halve the interval,
|
||||
// unless we find the texture or the size of the interval is less than 3.
|
||||
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
|
||||
while (begin+1<end) // as long as the interval is longer than two
|
||||
{
|
||||
if (hash > FileToMod[index_list[pos]].Hash) // the new interval is the right half of the actual interval
|
||||
{
|
||||
begin = pos+1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else if (hash < FileToMod[index_list[pos]].Hash) // the new interval is the left half of the actual interval
|
||||
{
|
||||
end = pos-1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else {return (index_list[pos]); break;} // we hit the correct hash
|
||||
}
|
||||
for ( pos=begin; pos<=end; pos++) if (FileToMod[index_list[pos]].Hash==hash) return (index_list[pos]);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod( %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
|
||||
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
|
||||
int index = LookUpToMod( pTexture->Hash, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
{
|
||||
uMod_IDirect3DTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pTexture))
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1];
|
||||
for (int j=0; j<FileToMod[index].NumberOfTextures; j++) temp[j] = FileToMod[index].Textures[j];
|
||||
|
||||
if (FileToMod[index].Textures!=NULL) delete [] FileToMod[index].Textures;
|
||||
FileToMod[index].Textures = temp;
|
||||
|
||||
FileToMod[index].Textures[FileToMod[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod( Volume %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
|
||||
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
|
||||
int index = LookUpToMod( pTexture->Hash, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pTexture))
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1];
|
||||
for (int j=0; j<FileToMod[index].NumberOfTextures; j++) temp[j] = FileToMod[index].Textures[j];
|
||||
|
||||
if (FileToMod[index].Textures!=NULL) delete [] FileToMod[index].Textures;
|
||||
FileToMod[index].Textures = temp;
|
||||
|
||||
FileToMod[index].Textures[FileToMod[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod( Cube %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
|
||||
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
|
||||
int index = LookUpToMod( pTexture->Hash, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pTexture))
|
||||
{
|
||||
Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1];
|
||||
for (int j=0; j<FileToMod[index].NumberOfTextures; j++) temp[j] = FileToMod[index].Textures[j];
|
||||
|
||||
if (FileToMod[index].Textures!=NULL) delete [] FileToMod[index].Textures;
|
||||
FileToMod[index].Textures = temp;
|
||||
|
||||
FileToMod[index].Textures[FileToMod[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture) // to load fake texture from a file in memory
|
||||
{
|
||||
Message("LoadTexture( %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
if (D3D_OK != D3DXCreateTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DTexture9 **) ppTexture))
|
||||
//if (D3D_OK != D3DXCreateTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DTexture9 **) ppTexture))
|
||||
{
|
||||
*ppTexture=NULL;
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
(*ppTexture)->FAKE = true;
|
||||
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice
|
||||
|
||||
Message("LoadTexture( %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture) // to load fake texture from a file in memory
|
||||
{
|
||||
Message("LoadTexture( Volume %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DVolumeTexture9 **) ppTexture))
|
||||
//if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DVolumeTexture9 **) ppTexture))
|
||||
{
|
||||
*ppTexture=NULL;
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
(*ppTexture)->FAKE = true;
|
||||
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice
|
||||
|
||||
Message("LoadTexture( Volume %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture) // to load fake texture from a file in memory
|
||||
{
|
||||
Message("LoadTexture( Cube %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
if (D3D_OK != D3DXCreateCubeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DCubeTexture9 **) ppTexture))
|
||||
//if (D3D_OK != D3DXCreateCubeTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DCubeTexture9 **) ppTexture))
|
||||
{
|
||||
*ppTexture=NULL;
|
||||
return (RETURN_TEXTURE_NOT_LOADED);
|
||||
}
|
||||
(*ppTexture)->FAKE = true;
|
||||
|
||||
void *cpy;
|
||||
long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice
|
||||
|
||||
Message("LoadTexture( Cube %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_TEXTUREHANDLER_HPP
|
||||
#define uMod_TEXTUREHANDLER_HPP
|
||||
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "..\uMod_Error.h"
|
||||
|
||||
|
||||
class uMod_TextureServer;
|
||||
|
||||
/*
|
||||
* An object of this class is owned by each d3d9 device.
|
||||
* functions called by the Server are called from the server thread instance.
|
||||
* All other functions are called from the render thread instance of the game itself.
|
||||
*/
|
||||
|
||||
class uMod_TextureClient
|
||||
{
|
||||
public:
|
||||
uMod_TextureClient(uMod_TextureServer* server, IDirect3DDevice9* device);
|
||||
~uMod_TextureClient(void);
|
||||
|
||||
int AddTexture( uMod_IDirect3DTexture9* tex); //called from uMod_IDirect3DDevice9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
int AddTexture( uMod_IDirect3DVolumeTexture9* tex); //called from uMod_IDirect3DVolumeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
int AddTexture( uMod_IDirect3DCubeTexture9* tex); //called from uMod_IDirect3DCubeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
|
||||
int RemoveTexture( uMod_IDirect3DTexture9* tex); //called from uMod_IDirect3DTexture9::Release()
|
||||
int RemoveTexture( uMod_IDirect3DVolumeTexture9* tex); //called from uMod_IDirect3DVolumeTexture9::Release()
|
||||
int RemoveTexture( uMod_IDirect3DCubeTexture9* tex); //called from uMod_IDirect3DCubeTexture9::Release()
|
||||
|
||||
int SaveAllTextures(bool val); //called from the Server
|
||||
int SaveSingleTexture(bool val); //called from the Server
|
||||
|
||||
int SetSaveDirectory( wchar_t *dir); //called from the Server
|
||||
int SetGameName( wchar_t *dir); //called from the Server
|
||||
|
||||
int SaveTexture(uMod_IDirect3DTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
int SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
int SaveTexture(uMod_IDirect3DCubeTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
|
||||
|
||||
|
||||
int SetKeyBack( int key) {if (key>0) KeyBack = key; return (RETURN_OK);} //called from the Server
|
||||
int SetKeySave( int key) {if (key>0) KeySave = key; return (RETURN_OK);} //called from the Server
|
||||
int SetKeyNext( int key) {if (key>0) KeyNext = key; return (RETURN_OK);} //called from the Server
|
||||
|
||||
int SetFontColour( DWORD r, DWORD g, DWORD b) {FontColour = D3DCOLOR_ARGB(255, r,g,b); return (RETURN_OK);} //called from the Server
|
||||
int SetTextureColour( DWORD r, DWORD g, DWORD b) {TextureColour = D3DCOLOR_ARGB(255, r,g,b); return (RETURN_OK);} //called from the Server
|
||||
|
||||
|
||||
int AddUpdate(TextureFileStruct* update, int number); //called from the Server, client object must delete update array
|
||||
int MergeUpdate(void); //called from uMod_IDirect3DDevice9::BeginScene()
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
int LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
int LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
uMod_TextureHandler<uMod_IDirect3DTexture9> OriginalTextures; // stores the pointer to the uMod_IDirect3DTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DVolumeTexture9> OriginalVolumeTextures; // stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DCubeTexture9> OriginalCubeTextures; // stores the pointer to the uMod_IDirect3DCubeTexture9 objects created by the game
|
||||
|
||||
bool BoolSaveAllTextures;
|
||||
bool BoolSaveSingleTexture;
|
||||
int KeyBack;
|
||||
int KeySave;
|
||||
int KeyNext;
|
||||
|
||||
D3DCOLOR FontColour;
|
||||
D3DCOLOR TextureColour;
|
||||
|
||||
private:
|
||||
uMod_TextureServer* Server;
|
||||
IDirect3DDevice9* D3D9Device;
|
||||
wchar_t SavePath[MAX_PATH];
|
||||
wchar_t GameName[MAX_PATH];
|
||||
|
||||
TextureFileStruct* Update;
|
||||
int NumberOfUpdate;
|
||||
|
||||
int LockMutex();
|
||||
int UnlockMutex();
|
||||
HANDLE Mutex;
|
||||
|
||||
int NumberToMod; // number of texture to be modded
|
||||
TextureFileStruct* FileToMod; // array which stores the file in memory and the hash of each texture to be modded
|
||||
|
||||
|
||||
int LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list); // called from LookUpToMod(...);
|
||||
int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture); // called if a target texture is found
|
||||
int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture); // called if a target texture is found
|
||||
int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture); // called if a target texture is found
|
||||
|
||||
// and the corresponding fake texture should be loaded
|
||||
|
||||
//MyTypeHash GetHash(unsigned char *str, int len);
|
||||
//unsigned int GetCRC32(char *pcDatabuf, unsigned int ulDatalen);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_TEXTUREHANDLER_HPP_ */
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
/*
|
||||
MyTypeHash GetHash(unsigned char *str, int len) // estimate the hash
|
||||
{
|
||||
MyTypeHash hash = 0;
|
||||
for (int i=0; i<len; i++) hash = str[i] + (hash << 6) + (hash << 16) - hash;
|
||||
return (hash);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO RS !!
|
||||
*
|
||||
* who gave me his hashing algorithm (well or crc32 algorithm^^)
|
||||
*
|
||||
The hash function is CRC32 using polynomial 0xEDB88320.
|
||||
However, the hashed data is calculated incorrectly in TexMod: it's simply BytesPerPixel * Width * Height, from the beginning of the data (that is mapped using LockRect).
|
||||
The problem is that it doesn't take the pitch into account and BytesPerPixel may be wrong for some rare formats (not sure about that).
|
||||
*/
|
||||
|
||||
|
||||
#define CRC32POLY 0xEDB88320u /* CRC-32 Polynom */
|
||||
#define ulCrc_in 0xffffffff
|
||||
|
||||
unsigned int GetCRC32( char *pcDatabuf, unsigned int ulDatalen)
|
||||
{
|
||||
unsigned int crc = ulCrc_in;
|
||||
for (unsigned int idx = 0u; idx<ulDatalen; idx++)
|
||||
{
|
||||
unsigned int data = *pcDatabuf++;
|
||||
for (unsigned int bit = 0u; bit<8u; bit++, data >>=1)
|
||||
{
|
||||
crc = (crc >> 1) ^ (((crc ^ data) & 1) ? CRC32POLY : 0);
|
||||
}
|
||||
}
|
||||
return (crc);
|
||||
}
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef uMod_TEXTUREFUNCTION_H_
|
||||
#define uMod_TEXTUREFUNCTION_H_
|
||||
|
||||
|
||||
unsigned int GetCRC32( char *pcDatabuf, unsigned int ulDatalen);
|
||||
/*
|
||||
case D3DFMT_MULTI2_ARGB8:
|
||||
case D3DFMT_VERTEXDATA:
|
||||
*/
|
||||
inline int GetBitsFromFormat(D3DFORMAT format)
|
||||
{
|
||||
switch(format) //switch trough the formats to calculate the size of the raw data
|
||||
{
|
||||
case D3DFMT_A1: // 1-bit monochrome.
|
||||
{
|
||||
return (1);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_R3G3B2: // 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
|
||||
case D3DFMT_A8: // 8-bit alpha only.
|
||||
case D3DFMT_A8P8: // 8-bit color indexed with 8 bits of alpha.
|
||||
case D3DFMT_P8: // 8-bit color indexed.
|
||||
case D3DFMT_L8: // 8-bit luminance only.
|
||||
case D3DFMT_A4L4: // 8-bit using 4 bits each for alpha and luminance.
|
||||
case D3DFMT_FORCE_DWORD:
|
||||
case D3DFMT_S8_LOCKABLE: // A lockable 8-bit stencil buffer.
|
||||
{
|
||||
return (8);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_D16_LOCKABLE: //16-bit z-buffer bit depth.
|
||||
case D3DFMT_D15S1: // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
|
||||
case D3DFMT_L6V5U5: // 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
|
||||
case D3DFMT_V8U8: // 16-bit bump-map format using 8 bits each for u and v data.
|
||||
case D3DFMT_CxV8U8: // 16-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 - U2 - V2).
|
||||
case D3DFMT_R5G6B5: // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
|
||||
case D3DFMT_X1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color.
|
||||
case D3DFMT_A1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
|
||||
case D3DFMT_A4R4G4B4: // 16-bit ARGB pixel format with 4 bits for each channel.
|
||||
case D3DFMT_A8R3G3B2: // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
|
||||
case D3DFMT_X4R4G4B4: // 16-bit RGB pixel format using 4 bits for each color.
|
||||
case D3DFMT_L16: // 16-bit luminance only.
|
||||
case D3DFMT_R16F: // 16-bit float format using 16 bits for the red channel.
|
||||
case D3DFMT_A8L8: // 16-bit using 8 bits each for alpha and luminance.
|
||||
case D3DFMT_D16: // 16-bit z-buffer bit depth.
|
||||
case D3DFMT_INDEX16: // 16-bit index buffer bit depth.
|
||||
case D3DFMT_G8R8_G8B8: // ??
|
||||
case D3DFMT_R8G8_B8G8: // ??
|
||||
case D3DFMT_UYVY: // ??
|
||||
case D3DFMT_YUY2: // ??
|
||||
{
|
||||
return (16);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case D3DFMT_R8G8B8: //24-bit RGB pixel format with 8 bits per channel.
|
||||
{
|
||||
return (24);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_R32F: // 32-bit float format using 32 bits for the red channel.
|
||||
case D3DFMT_X8L8V8U8: // 32-bit bump-map format with luminance using 8 bits for each channel.
|
||||
case D3DFMT_A2W10V10U10: // 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.
|
||||
case D3DFMT_Q8W8V8U8: // 32-bit bump-map format using 8 bits for each channel.
|
||||
case D3DFMT_V16U16: // 32-bit bump-map format using 16 bits for each channel.
|
||||
case D3DFMT_A8R8G8B8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8R8G8B8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_A2B10G10R10: // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
|
||||
case D3DFMT_A8B8G8R8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8B8G8R8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_G16R16: // 32-bit pixel format using 16 bits each for green and red.
|
||||
case D3DFMT_G16R16F: // 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
|
||||
case D3DFMT_A2R10G10B10: // 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
|
||||
case D3DFMT_D32: // 32-bit z-buffer bit depth.
|
||||
case D3DFMT_D24S8: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
|
||||
case D3DFMT_D24X8: //32-bit z-buffer bit depth using 24 bits for the depth channel.
|
||||
case D3DFMT_D24X4S4: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
|
||||
case D3DFMT_D32F_LOCKABLE: // A lockable format where the depth value is represented as a standard IEEE floating-point number.
|
||||
case D3DFMT_D24FS8: // A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
|
||||
case D3DFMT_D32_LOCKABLE: // A lockable 32-bit depth buffer.
|
||||
case D3DFMT_INDEX32: // 32-bit index buffer bit depth.
|
||||
//case : //
|
||||
//case : //
|
||||
//case : //
|
||||
//case : //
|
||||
{
|
||||
return (32);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_G32R32F: // 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
|
||||
case D3DFMT_Q16W16V16U16: // 64-bit bump-map format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16: // 64-bit pixel format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16F: // 64-bit float format using 16 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return (64);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_A32B32G32R32F: // 128-bit float format using 32 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return (128);
|
||||
break;
|
||||
}
|
||||
case D3DFMT_DXT2:
|
||||
case D3DFMT_DXT3:
|
||||
case D3DFMT_DXT4:
|
||||
case D3DFMT_DXT5:
|
||||
{
|
||||
return (8);
|
||||
break;
|
||||
}
|
||||
case D3DFMT_DXT1:
|
||||
{
|
||||
return (4);
|
||||
break;
|
||||
}
|
||||
default: //compressed formats
|
||||
{
|
||||
return (4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* uMod_TEXTUREFUNCTION_H_ */
|
||||
@@ -1,768 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
uMod_TextureServer::uMod_TextureServer(wchar_t *game)
|
||||
{
|
||||
Message("uMod_TextureServer(void): %lu\n", this);
|
||||
|
||||
Mutex = CreateMutex(NULL, false, NULL);
|
||||
|
||||
Clients = NULL;
|
||||
NumberOfClients = 0;
|
||||
LenghtOfClients = 0;
|
||||
BoolSaveAllTextures = false;
|
||||
BoolSaveSingleTexture = false;
|
||||
SavePath[0] = 0;
|
||||
|
||||
int len=0;
|
||||
int path_pos=0;
|
||||
int dot_pos=0;
|
||||
for (len=0; len<MAX_PATH && (game[len]); len++)
|
||||
{
|
||||
if (game[len]==L'\\' || game[len]==L'/') path_pos=len+1;
|
||||
else if (game[len]==L'.') dot_pos=len;
|
||||
}
|
||||
|
||||
if (dot_pos>path_pos) len = dot_pos - path_pos;
|
||||
else len -= path_pos;
|
||||
|
||||
for (int i=0; i<len; i++) GameName[i] = game[i+path_pos];
|
||||
|
||||
if (len<MAX_PATH) GameName[len] = 0;
|
||||
else GameName[0] = 0;
|
||||
|
||||
KeyBack = 0;
|
||||
KeySave = 0;
|
||||
KeyNext = 0;
|
||||
|
||||
FontColour = 0u;
|
||||
TextureColour = 0u;
|
||||
|
||||
Pipe.In = INVALID_HANDLE_VALUE;
|
||||
Pipe.Out = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
uMod_TextureServer::~uMod_TextureServer(void)
|
||||
{
|
||||
Message("~uMod_TextureServer(void): %lu\n", this);
|
||||
if (Mutex != NULL) CloseHandle(Mutex);
|
||||
|
||||
//delete the files in memory
|
||||
int num = CurrentMod.GetNumber();
|
||||
for (int i = 0; i < num; i++) delete[] CurrentMod[i]->pData; //delete the file content of the texture
|
||||
|
||||
num = OldMod.GetNumber();
|
||||
for (int i = 0; i < num; i++) delete[] OldMod[i]->pData; //delete the file content of the texture
|
||||
|
||||
if (Pipe.In != INVALID_HANDLE_VALUE ) CloseHandle(Pipe.In);
|
||||
Pipe.In = INVALID_HANDLE_VALUE;
|
||||
if (Pipe.Out != INVALID_HANDLE_VALUE) CloseHandle(Pipe.Out);
|
||||
Pipe.Out = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
int uMod_TextureServer::AddClient(uMod_TextureClient *client, TextureFileStruct** update, int* number) // called from a client
|
||||
{
|
||||
Message("AddClient(%lu): %lu\n", client, this);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
// the following functions must not change the original uMod_IDirect3DDevice9 object
|
||||
// somehow on game start some uMod_IDirect3DDevice9 object are created, which must rest unchanged!!
|
||||
// these objects are released and are not used for rendering
|
||||
client->SetGameName(GameName);
|
||||
client->SaveAllTextures(BoolSaveAllTextures);
|
||||
client->SaveSingleTexture(BoolSaveSingleTexture);
|
||||
client->SetSaveDirectory(SavePath);
|
||||
if (KeyBack > 0) client->SetKeyBack(KeyBack);
|
||||
if (KeySave > 0) client->SetKeySave(KeySave);
|
||||
if (KeyNext > 0) client->SetKeyNext(KeyNext);
|
||||
|
||||
if (FontColour>0u)
|
||||
{
|
||||
DWORD r = (FontColour>>16)&0xFF;
|
||||
DWORD g = (FontColour>>8)&0xFF;
|
||||
DWORD b = (FontColour)&0xFF;
|
||||
client->SetFontColour( r, g, b);
|
||||
}
|
||||
if (TextureColour>0u)
|
||||
{
|
||||
DWORD r = (TextureColour>>16)&0xFF;
|
||||
DWORD g = (TextureColour>>8)&0xFF;
|
||||
DWORD b = (TextureColour)&0xFF;
|
||||
client->SetTextureColour( r, g, b);
|
||||
}
|
||||
|
||||
|
||||
if (int ret = PrepareUpdate( update, number)) return (ret); // get a copy of all texture to be modded
|
||||
|
||||
|
||||
if (NumberOfClients == LenghtOfClients) //allocate more memory
|
||||
{
|
||||
uMod_TextureClient** temp = NULL;
|
||||
try {temp = new uMod_TextureClient*[LenghtOfClients + 10];}
|
||||
catch (...)
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
|
||||
if (int ret = UnlockMutex()) return (ret);
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
for (int i=0; i<LenghtOfClients; i++) temp[i] = Clients[i];
|
||||
if (Clients!=NULL) delete [] Clients;
|
||||
Clients = temp;
|
||||
LenghtOfClients += 10;
|
||||
}
|
||||
Clients[NumberOfClients++] = client;
|
||||
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::RemoveClient(uMod_TextureClient *client) // called from a client
|
||||
{
|
||||
Message("RemoveClient(%lu): %lu\n", client);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
for (int i = 0; i < NumberOfClients; i++) if (client == Clients[i])
|
||||
{
|
||||
NumberOfClients--;
|
||||
Clients[i] = Clients[NumberOfClients];
|
||||
break;
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::AddFile( char* buffer, unsigned int size, MyTypeHash hash, bool force) // called from Mainloop()
|
||||
{
|
||||
Message("uMod_TextureServer::AddFile( %lu %lu, %#lX, %d): %lu\n", buffer, size, hash, force, this);
|
||||
|
||||
TextureFileStruct* temp = NULL;
|
||||
|
||||
int num = CurrentMod.GetNumber();
|
||||
for (int i=0; i<num; i++) if (CurrentMod[i]->Hash == hash) //look through all current textures
|
||||
{
|
||||
if (force) {temp = CurrentMod[i]; break;} // we need to reload it
|
||||
else return (RETURN_OK); // we still have added this texture
|
||||
}
|
||||
if (temp==NULL) // if not found, look through all old textures
|
||||
{
|
||||
num = OldMod.GetNumber();
|
||||
for (int i=0; i<num; i++) if (OldMod[i]->Hash == hash)
|
||||
{
|
||||
temp = OldMod[i];
|
||||
OldMod.Remove(temp);
|
||||
CurrentMod.Add(temp);
|
||||
if (force) break; // we must reload it
|
||||
else return (RETURN_OK); // we should not reload it
|
||||
}
|
||||
}
|
||||
|
||||
bool new_file = true;
|
||||
if (temp!=NULL) //if it was found, we delete the old file content
|
||||
{
|
||||
new_file = false;
|
||||
if (temp->pData!=NULL) delete [] temp->pData;
|
||||
temp->pData = NULL;
|
||||
}
|
||||
else //if it was not found, we need to create a new object
|
||||
{
|
||||
new_file = true;
|
||||
temp = new TextureFileStruct;
|
||||
temp->Reference = -1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
temp->pData = new char[size];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!new_file) CurrentMod.Remove( temp); // if this is a not a new file it is in the list of the CurrentMod
|
||||
delete temp;
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<size; i++) temp->pData[i] = buffer[i];
|
||||
|
||||
temp->Size = size;
|
||||
temp->NumberOfTextures = 0;
|
||||
temp->Textures = NULL;
|
||||
temp->Hash = hash;
|
||||
|
||||
//if (new_file) temp->ForceReload = false; // no need to force a load of the texture
|
||||
//else
|
||||
temp->ForceReload = force;
|
||||
|
||||
Message("End AddFile(%#lX)\n", hash);
|
||||
if (new_file) return (CurrentMod.Add(temp)); // new files must be added to the list of the CurrentMod
|
||||
else return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::AddFile(wchar_t* file_name, MyTypeHash hash, bool force) // called from Mainloop
|
||||
// this functions does the same, but loads the file content from disk
|
||||
{
|
||||
Message("uMod_TextureServer::AddFile( %ls, %#lX, %d): %lu\n", file_name, hash, force, this);
|
||||
|
||||
TextureFileStruct* temp = NULL;
|
||||
|
||||
int num = CurrentMod.GetNumber();
|
||||
for (int i = 0; i < num; i++) if (CurrentMod[i]->Hash == hash)
|
||||
{
|
||||
if (force) {temp = CurrentMod[i]; break;}
|
||||
else return (RETURN_OK);
|
||||
}
|
||||
if (temp==NULL)
|
||||
{
|
||||
num = OldMod.GetNumber();
|
||||
for (int i = 0; i < num; i++) if (OldMod[i]->Hash == hash)
|
||||
{
|
||||
temp = OldMod[i];
|
||||
OldMod.Remove(temp);
|
||||
CurrentMod.Add(temp);
|
||||
if (force) break;
|
||||
else return (RETURN_OK);
|
||||
}
|
||||
}
|
||||
|
||||
FILE* file;
|
||||
if (_wfopen_s(&file, file_name, L"rb") != 0)
|
||||
{
|
||||
Message("AddFile( ): file not found\n");
|
||||
return (RETURN_FILE_NOT_LOADED);
|
||||
}
|
||||
|
||||
fseek (file, 0, SEEK_END);
|
||||
unsigned int size = ftell(file);
|
||||
fseek (file, 0, SEEK_SET);
|
||||
|
||||
bool new_file = true;
|
||||
if (temp!=NULL)
|
||||
{
|
||||
new_file = false;
|
||||
if (temp->pData!=NULL) delete [] temp->pData;
|
||||
temp->pData = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_file = true;
|
||||
temp = new TextureFileStruct;
|
||||
temp->Reference = -1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
temp->pData = new char[size];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!new_file) CurrentMod.Remove( temp);
|
||||
delete temp;
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
int result = fread(temp->pData, 1, size, file);
|
||||
fclose(file);
|
||||
if (result != size)
|
||||
{
|
||||
delete[] temp->pData;
|
||||
if (!new_file) CurrentMod.Remove( temp);
|
||||
delete temp;
|
||||
return (RETURN_FILE_NOT_LOADED);
|
||||
}
|
||||
|
||||
temp->Size = size;
|
||||
temp->NumberOfTextures = 0;
|
||||
temp->Textures = NULL;
|
||||
temp->Hash = hash;
|
||||
|
||||
if (new_file) temp->ForceReload = false;
|
||||
else temp->ForceReload = force;
|
||||
|
||||
Message("End AddFile(%#lX)\n", hash);
|
||||
if (new_file) return (CurrentMod.Add(temp));
|
||||
else return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::RemoveFile(MyTypeHash hash) // called from Mainloop()
|
||||
{
|
||||
Message("RemoveFile( %lu): %lu\n", hash, this);
|
||||
|
||||
int num = CurrentMod.GetNumber();
|
||||
for (int i = 0; i < num; i++) if (CurrentMod[i]->Hash == hash)
|
||||
{
|
||||
TextureFileStruct* temp = CurrentMod[i];
|
||||
CurrentMod.Remove(temp);
|
||||
return (OldMod.Add(temp));
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SaveAllTextures(bool val) // called from Mainloop()
|
||||
{
|
||||
if (BoolSaveAllTextures == val) return (RETURN_OK);
|
||||
BoolSaveAllTextures = val;
|
||||
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SaveAllTextures(BoolSaveAllTextures);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SaveSingleTexture(bool val) // called from Mainloop()
|
||||
{
|
||||
if (BoolSaveSingleTexture == val) return (RETURN_OK);
|
||||
BoolSaveSingleTexture = val;
|
||||
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SaveSingleTexture(BoolSaveSingleTexture);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SetSaveDirectory(wchar_t *dir) // called from Mainloop()
|
||||
{
|
||||
Message("uMod_TextureServer::SetSaveDirectory( %ls): %lu\n", dir, this);
|
||||
int i = 0;
|
||||
for (i = 0; i < MAX_PATH && (dir[i]); i++) SavePath[i] = dir[i];
|
||||
if (i == MAX_PATH)
|
||||
{
|
||||
SavePath[0] = 0;
|
||||
return (RETURN_BAD_ARGUMENT);
|
||||
}
|
||||
else SavePath[i] = 0;
|
||||
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SetSaveDirectory(SavePath);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SetKeyBack(int key) // called from Mainloop()
|
||||
{
|
||||
if (KeyBack == key || KeySave == key || KeyNext == key) return (RETURN_OK);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
KeyBack = key;
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SetKeyBack(key);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SetKeySave(int key) // called from Mainloop()
|
||||
{
|
||||
if (KeyBack == key || KeySave == key || KeyNext == key) return (RETURN_OK);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
KeySave = key;
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SetKeySave(key);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SetKeyNext(int key) // called from Mainloop()
|
||||
{
|
||||
if (KeyBack == key || KeySave == key || KeyNext == key) return (RETURN_OK);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
KeyNext = key;
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SetKeyNext(key);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SetFontColour(DWORD colour) // called from Mainloop()
|
||||
{
|
||||
if (colour==0u) return (RETURN_OK);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
FontColour = colour;
|
||||
DWORD r = (FontColour>>16)&0xFF;
|
||||
DWORD g = (FontColour>>8)&0xFF;
|
||||
DWORD b = (FontColour)&0xFF;
|
||||
Message("uMod_TextureServer::SetFontColour( %u %u %u): %lu\n", r ,g ,b, this);
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SetFontColour( r, g, b);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::SetTextureColour(DWORD colour) // called from Mainloop()
|
||||
{
|
||||
if (colour==0u) return (RETURN_OK);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_SERVER;
|
||||
return (ret);
|
||||
}
|
||||
TextureColour = colour;
|
||||
DWORD r = (TextureColour>>16)&0xFF;
|
||||
DWORD g = (TextureColour>>8)&0xFF;
|
||||
DWORD b = (TextureColour)&0xFF;
|
||||
Message("uMod_TextureServer::SetTextureColour( %u %u %u): %lu\n", r ,g ,b, this);
|
||||
for (int i = 0; i < NumberOfClients; i++)
|
||||
{
|
||||
Clients[i]->SetTextureColour( r, g, b);
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
int uMod_TextureServer::PropagateUpdate(uMod_TextureClient* client) // called from Mainloop(), send the update to all clients
|
||||
{
|
||||
Message("PropagateUpdate(%lu): %lu\n", client, this);
|
||||
if (int ret = LockMutex())
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_TEXTURE;
|
||||
return (ret);
|
||||
}
|
||||
if (client != NULL)
|
||||
{
|
||||
TextureFileStruct* update;
|
||||
int number;
|
||||
if (int ret = PrepareUpdate( &update, &number)) return (ret);
|
||||
client->AddUpdate(update, number);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<NumberOfClients; i++)
|
||||
{
|
||||
TextureFileStruct* update;
|
||||
int number;
|
||||
if (int ret = PrepareUpdate( &update, &number)) return (ret);
|
||||
Clients[i]->AddUpdate(update, number);
|
||||
}
|
||||
}
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
#define cpy_file_struct( a, b) \
|
||||
{ \
|
||||
a.ForceReload = b.ForceReload; \
|
||||
a.pData = b.pData; \
|
||||
a.Size = b.Size; \
|
||||
a.NumberOfTextures = b.NumberOfTextures; \
|
||||
a.Reference = b.Reference; \
|
||||
a.Textures = b.Textures; \
|
||||
a.Hash = b.Hash; }
|
||||
|
||||
int TextureFileStruct_Compare( const void * elem1, const void * elem2 )
|
||||
{
|
||||
TextureFileStruct *tex1 = (TextureFileStruct*)elem1;
|
||||
TextureFileStruct *tex2 = (TextureFileStruct*)elem2;
|
||||
if (tex1->Hash < tex2->Hash) return (-1);
|
||||
if (tex1->Hash > tex2->Hash) return (+1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::PrepareUpdate(TextureFileStruct** update, int* number) // called from the PropagateUpdate() and AddClient.
|
||||
// Prepare an update for one client. The allocated memory must deleted by the client.
|
||||
{
|
||||
Message("PrepareUpdate(%lu, %d): %lu\n", update, number, this);
|
||||
|
||||
TextureFileStruct* temp = NULL;
|
||||
int num = CurrentMod.GetNumber();
|
||||
if (num>0)
|
||||
{
|
||||
try {temp = new TextureFileStruct[num];}
|
||||
catch (...)
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
|
||||
for (int i=0; i<num; i++) cpy_file_struct(temp[i], (*(CurrentMod[i])));
|
||||
qsort( temp, num, sizeof(TextureFileStruct), TextureFileStruct_Compare);
|
||||
}
|
||||
|
||||
|
||||
*update = temp;
|
||||
*number = num;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
#undef cpy_file_struct
|
||||
|
||||
int uMod_TextureServer::LockMutex(void)
|
||||
{
|
||||
if (( gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX) )) return (RETURN_NO_MUTEX);
|
||||
if (WAIT_OBJECT_0!=WaitForSingleObject( Mutex, 100)) return (RETURN_MUTEX_LOCK); //waiting 100ms, to wait infinite pass INFINITE
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::UnlockMutex(void)
|
||||
{
|
||||
if (ReleaseMutex( Mutex) == 0) return (RETURN_MUTEX_UNLOCK);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::MainLoop(void) // run as a separated thread
|
||||
{
|
||||
Message("MainLoop: begin\n");
|
||||
if (Pipe.In == INVALID_HANDLE_VALUE) return (RETURN_PIPE_NOT_OPENED);
|
||||
char *buffer;
|
||||
try {buffer = new char[BIG_BUFSIZE];}
|
||||
catch (...) {return (RETURN_NO_MEMORY);}
|
||||
|
||||
unsigned long num;
|
||||
|
||||
Message("MainLoop: started\n");
|
||||
bool update_textures = false;
|
||||
bool more_textures = false;
|
||||
while (1)
|
||||
{
|
||||
Message("MainLoop: run\n");
|
||||
bool ret = ReadFile(Pipe.In, // pipe handle
|
||||
buffer, // buffer to receive reply
|
||||
BIG_BUFSIZE, // size of buffer
|
||||
&num, // number of bytes read
|
||||
NULL); // not overlapped
|
||||
|
||||
Message("MainLoop: read something (%lu)\n", num);
|
||||
if (ret || GetLastError() == ERROR_MORE_DATA)
|
||||
{
|
||||
unsigned int pos = 0;
|
||||
MsgStruct *commands;
|
||||
more_textures = false;
|
||||
while (pos <= num - sizeof(MsgStruct))
|
||||
{
|
||||
commands = (MsgStruct*) &buffer[pos];
|
||||
unsigned int size = 0u;
|
||||
bool force = false;
|
||||
|
||||
switch (commands->Control)
|
||||
{
|
||||
case CONTROL_MORE_TEXTURES:
|
||||
{
|
||||
more_textures=true;
|
||||
break;
|
||||
}
|
||||
case CONTROL_FORCE_RELOAD_TEXTURE: force=true;
|
||||
case CONTROL_ADD_TEXTURE:
|
||||
{
|
||||
size = commands->Value;
|
||||
Message("MainLoop: CONTROL_ADD_TEXTURE (%#lX %u, %u %u): %lu\n", commands->Hash, size, sizeof(MsgStruct), sizeof(char), this);
|
||||
if (pos + sizeof(MsgStruct) + size <= num) AddFile( (wchar_t*) &buffer[pos + sizeof(MsgStruct)], commands->Hash, force);
|
||||
update_textures = true;
|
||||
force = false;
|
||||
break;
|
||||
}
|
||||
case CONTROL_FORCE_RELOAD_TEXTURE_DATA: force=true;
|
||||
case CONTROL_ADD_TEXTURE_DATA:
|
||||
{
|
||||
size = commands->Value;
|
||||
Message("MainLoop: CONTROL_FORCE_RELOAD_TEXTURE_DATA (%#lX %u, %u %u): %lu\n", commands->Hash, size, sizeof(MsgStruct), sizeof(char), this);
|
||||
if (pos + sizeof(MsgStruct) + size <= num) AddFile( &buffer[pos + sizeof(MsgStruct)], size, commands->Hash, force);
|
||||
update_textures = true;
|
||||
force = false;
|
||||
break;
|
||||
}
|
||||
|
||||
case CONTROL_REMOVE_TEXTURE:
|
||||
{
|
||||
Message("MainLoop: CONTROL_REMOVE_TEXTURE (%#lX): %lu\n", commands->Hash, this);
|
||||
RemoveFile(commands->Hash);
|
||||
update_textures = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case CONTROL_SAVE_SINGLE:
|
||||
{
|
||||
Message("MainLoop: CONTROL_SAVE_SINGLE (%d): %lu\n", commands->Value, this);
|
||||
if (commands->Value == 0) SaveSingleTexture(false);
|
||||
else SaveSingleTexture(true);
|
||||
break;
|
||||
}
|
||||
case CONTROL_SAVE_ALL:
|
||||
{
|
||||
Message("MainLoop: CONTROL_SAVE_ALL (%d): %lu\n", commands->Value, this);
|
||||
if (commands->Value == 0) SaveAllTextures(false);
|
||||
else SaveAllTextures(true);
|
||||
break;
|
||||
}
|
||||
case CONTROL_SET_DIR:
|
||||
{
|
||||
size = commands->Value;
|
||||
if (pos + sizeof(MsgStruct) +size <= num) SetSaveDirectory( (wchar_t*) &buffer[pos + sizeof(MsgStruct)]);
|
||||
break;
|
||||
}
|
||||
|
||||
case CONTROL_KEY_BACK:
|
||||
{
|
||||
Message("MainLoop: CONTROL_KEY_BACK (%#X): %lu\n", commands->Value, this);
|
||||
SetKeyBack(commands->Value);
|
||||
break;
|
||||
}
|
||||
case CONTROL_KEY_SAVE:
|
||||
{
|
||||
Message("MainLoop: CONTROL_KEY_SAVE (%#X): %lu\n", commands->Value, this);
|
||||
SetKeySave(commands->Value);
|
||||
break;
|
||||
}
|
||||
case CONTROL_KEY_NEXT:
|
||||
{
|
||||
Message("MainLoop: CONTROL_KEY_NEXT (%#X): %lu\n", commands->Value, this);
|
||||
SetKeyNext(commands->Value);
|
||||
break;
|
||||
}
|
||||
case CONTROL_FONT_COLOUR:
|
||||
{
|
||||
Message("MainLoop: CONTROL_FONT_COLOUR (%#X): %lu\n", commands->Value, this);
|
||||
SetFontColour(commands->Value);
|
||||
break;
|
||||
}
|
||||
case CONTROL_TEXTURE_COLOUR:
|
||||
{
|
||||
Message("MainLoop: CONTROL_TEXTURE_COLOUR (%#X): %lu\n", commands->Value, this);
|
||||
SetTextureColour(commands->Value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Message("MainLoop: DEFAULT: %lu %lu %#lX\n", commands->Control, commands->Value, commands->Hash, this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pos += sizeof(MsgStruct) + size;
|
||||
}
|
||||
if (!more_textures && update_textures) {PropagateUpdate(); update_textures=false;}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message("MainLoop: error in ReadFile()\n");
|
||||
delete [] buffer;
|
||||
ClosePipe();
|
||||
return (RETURN_OK);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::OpenPipe(wchar_t *game) // called from InitInstance()
|
||||
{
|
||||
Message("OpenPipe: Out\n")
|
||||
// open first outgoing pipe !!
|
||||
Pipe.Out = CreateFileW(PIPE_Game2uMod, // pipe name
|
||||
GENERIC_WRITE, // write access
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||
if (Pipe.Out == INVALID_HANDLE_VALUE) return (RETURN_PIPE_NOT_OPENED);
|
||||
|
||||
unsigned int len = 0u;
|
||||
while (game[len]) len++;
|
||||
len++; //to send also the zero
|
||||
unsigned long num;
|
||||
//send name of this game to uMod_GUI
|
||||
WriteFile(Pipe.Out, (const void*) game, len * sizeof(wchar_t), &num, NULL);
|
||||
|
||||
// now we can open the pipe for reading
|
||||
Message("OpenPipe: In\n");
|
||||
Pipe.In = CreateFileW(PIPE_uMod2Game, // pipe name
|
||||
GENERIC_READ, // read access
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
if (Pipe.In == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(Pipe.In);
|
||||
Pipe.In = INVALID_HANDLE_VALUE;
|
||||
return (RETURN_PIPE_NOT_OPENED);
|
||||
}
|
||||
|
||||
Message("OpenPipe: Done\n");
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureServer::ClosePipe(void) //called from ExitInstance, this must be done, otherwise the Mainloop will wait endless on the ReadFile()
|
||||
{
|
||||
Message("ClosePipe:\n");
|
||||
|
||||
// We close the outgoing pipe first.
|
||||
// The GUI will notice that the opposite side of it incoming pipe is closed
|
||||
// and closes it outgoing (our incoming) pipe and thus cancel the ReadFile() in the Mainloop()
|
||||
|
||||
if (Pipe.Out != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DisconnectNamedPipe(Pipe.Out);
|
||||
CloseHandle(Pipe.Out);
|
||||
Pipe.Out = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (Pipe.In != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DisconnectNamedPipe(Pipe.In);
|
||||
CloseHandle(Pipe.In);
|
||||
Pipe.In = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return (RETURN_OK);
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_TEXTURESERVER_H_
|
||||
#define uMod_TEXTURESERVER_H_
|
||||
|
||||
#include "../uMod_GlobalDefines.h"
|
||||
#include "uMod_ArrayHandler.h"
|
||||
|
||||
|
||||
/*
|
||||
* An object of this class is created only once.
|
||||
* The Mainloop functions is executed by a server thread,
|
||||
* which listen on a pipe.
|
||||
*
|
||||
* Functions called by the Client are called from the a thread instance of the game itself.
|
||||
* Nearly all other functions are called from the server thread instance.
|
||||
*/
|
||||
|
||||
|
||||
class uMod_TextureClient;
|
||||
|
||||
class uMod_TextureServer
|
||||
{
|
||||
public:
|
||||
uMod_TextureServer(wchar_t *name);
|
||||
~uMod_TextureServer(void);
|
||||
|
||||
int AddClient(uMod_TextureClient *client, TextureFileStruct** update, int* number); // called from a Client
|
||||
int RemoveClient(uMod_TextureClient *client); // called from a Client
|
||||
|
||||
int OpenPipe(wchar_t *name); // called on initialization of our d3d9 fake dll
|
||||
int ClosePipe(void); // called on exit of our d3d9 fake dll
|
||||
int MainLoop(void); // is executed in a server thread
|
||||
|
||||
|
||||
// following functions are only public for testing purpose !!
|
||||
// they should be private and only be called from the Mainloop
|
||||
|
||||
int AddFile( char* buffer, unsigned int size, MyTypeHash hash, bool force); // called from Mainloop(), if the content of the texture is sent
|
||||
int AddFile( wchar_t* file_name, MyTypeHash hash, bool force); // called from Mainloop(), if the name and the path to the file is sent
|
||||
int RemoveFile( MyTypeHash hash); // called from Mainloop()
|
||||
|
||||
int SaveAllTextures(bool val); // called from Mainloop()
|
||||
int SaveSingleTexture(bool val); // called from Mainloop()
|
||||
|
||||
int SetSaveDirectory( wchar_t *dir); // called from Mainloop()
|
||||
|
||||
|
||||
int SetKeyBack( int key); // called from Mainloop()
|
||||
int SetKeySave( int key); // called from Mainloop()
|
||||
int SetKeyNext( int key); // called from Mainloop()
|
||||
|
||||
int SetFontColour(DWORD colour); // called from Mainloop()
|
||||
int SetTextureColour(DWORD colour); // called from Mainloop()
|
||||
|
||||
private:
|
||||
bool BoolSaveAllTextures;
|
||||
bool BoolSaveSingleTexture;
|
||||
wchar_t SavePath[MAX_PATH];
|
||||
wchar_t GameName[MAX_PATH];
|
||||
|
||||
int PropagateUpdate(uMod_TextureClient* client=NULL); // called from Mainloop() if texture are loaded or removed
|
||||
int PrepareUpdate(TextureFileStruct** update, int* number); // called from PropagateUpdate() and AddClient()
|
||||
// generate a copy of the current texture to be modded
|
||||
// the file content of the textures are not copied, the clients get the pointer to the file content
|
||||
// but the arrays allocate by this function, must be deleted by the client
|
||||
|
||||
int LockMutex();
|
||||
int UnlockMutex();
|
||||
HANDLE Mutex;
|
||||
|
||||
|
||||
int KeyBack;
|
||||
int KeySave;
|
||||
int KeyNext;
|
||||
|
||||
DWORD FontColour;
|
||||
DWORD TextureColour;
|
||||
|
||||
|
||||
PipeStruct Pipe;
|
||||
|
||||
uMod_TextureClient** Clients;
|
||||
int NumberOfClients;
|
||||
int LenghtOfClients;
|
||||
|
||||
uMod_FileHandler CurrentMod; // hold the file content of texture
|
||||
uMod_FileHandler OldMod; // hold the file content of texture which were added previously but are not needed any more
|
||||
// this is needed, because a texture clients might not have merged the last update and thus hold pointers to the file content of old textures
|
||||
};
|
||||
|
||||
|
||||
#endif /* uMod_TEXTURESERVER_H_ */
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_ERROR_H_
|
||||
#define uMod_ERROR_H_
|
||||
|
||||
|
||||
// define return values, a value less than zero indicates an error
|
||||
#define RETURN_OK 0
|
||||
|
||||
#define RETURN_FATAL_ERROR -1
|
||||
#define RETURN_NO_MEMORY -2
|
||||
#define RETURN_BAD_ARGUMENT -3
|
||||
|
||||
#define RETURN_NO_IDirect3DDevice9 -10
|
||||
|
||||
#define RETURN_TEXTURE_NOT_LOADED -20
|
||||
#define RETURN_TEXTURE_NOT_SAVED -21
|
||||
#define RETURN_TEXTURE_NOT_FOUND -22
|
||||
#define RETURN_TEXTURE_ALLREADY_ADDED -23
|
||||
#define RETURN_TEXTURE_NOT_SWITCHED -24
|
||||
|
||||
#define RETURN_LockRect_FAILED -30
|
||||
#define RETURN_UnlockRect_FAILED -31
|
||||
#define RETURN_GetLevelDesc_FAILED -32
|
||||
|
||||
|
||||
#define RETURN_NO_MUTEX -40
|
||||
#define RETURN_MUTEX_LOCK -41
|
||||
#define RETURN_MUTEX_UNLOCK -42
|
||||
|
||||
#define RETURN_UPDATE_ALLREADY_ADDED -50
|
||||
#define RETURN_FILE_NOT_LOADED -51
|
||||
|
||||
#define RETURN_PIPE_NOT_OPENED 60
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// define error states
|
||||
#define uMod_ERROR_FATAL 1u
|
||||
#define uMod_ERROR_MUTEX 1u<<1
|
||||
#define uMod_ERROR_PIPE 1u<<2
|
||||
#define uMod_ERROR_MEMORY 1u<<3
|
||||
#define uMod_ERROR_TEXTURE 1u<<4
|
||||
#define uMod_ERROR_MULTIPLE_IDirect3D9 1u<<5
|
||||
#define uMod_ERROR_MULTIPLE_IDirect3DDevice9 1u<<6
|
||||
#define uMod_ERROR_UPDATE 1u<<7
|
||||
#define uMod_ERROR_SERVER 1u<<8
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_ERROR_H_ */
|
||||
@@ -1,116 +0,0 @@
|
||||
Warnung: Du verwendest diese Programm auf eigene Gefahr hin!
|
||||
1) Wenn das Programm abstürzt, wirst du wahrscheinlich keinen Support
|
||||
vom Spielehersteller bekommen. Aber du kannst den Fehler gerne
|
||||
angeben unter: http://code.google.com/p/texmod/issues/list
|
||||
2) Spiele können detektieren, ob sie verändert werden, daher riskierst du
|
||||
einen Bann deines online Accounts.
|
||||
3) Dies ist eine open-source Projekt. Der Code kann von jedem erhalten, verändert
|
||||
und kompiliert werden. Lade Universal Modding Engine nur von offiziellen Quellen runter,
|
||||
denen du vertraust. Lade es selbst runter und verwende keine Versionen,
|
||||
die du von Team- oder Gildenmitgliedern geschickt bekommen hast.
|
||||
http://code.google.com/p/texmod/downloads/list
|
||||
|
||||
|
||||
Universal Modding Engine verwendet die D3DX9_43.dll (32bit). Wegen den EULA kann
|
||||
diese dll nicht mit Universal Modding Engine mit geliefert werden. Wenn diese dll auf
|
||||
deinem System nicht installiert ist, wird dich Universal Modding Engine darauf hinweisen.
|
||||
|
||||
|
||||
Was kann Universal Modding Engine (uMod) V1.0?
|
||||
|
||||
-einzelne Texturen aus einem Spiel extrahieren und speichern (Die Zieltextur kann im Spiel geändert werden.)
|
||||
-alle Texturen aus einem Spiel extrahieren und speichern
|
||||
-Texturen in ein Spiel laden und Zieltexturen ersetzen
|
||||
-Support einzelner dds Texturen
|
||||
-Support von zip-Dateien
|
||||
-Support der originalen TexMod *.tpf Datein
|
||||
|
||||
Alle diese Optionen können während des Spieles an und aus geschaltet werden!
|
||||
Du kannst also nach einer Textur suchen, diese speichern, sie anschließend
|
||||
editieren, sie in das Spiel laden, sie nach bearbeiten und wieder in das
|
||||
Spiel laden, ... oder Mods aktivieren und deaktivieren
|
||||
und das alles ohne das Spiel neu starten zu müssen.
|
||||
|
||||
Randbemerkung: Wenn alle Texturen gespeichert werden sollen, so geschieht das nur,
|
||||
wenn die Texturen vom Spiel geladen werden und auch nur in dem Moment, wenn sie
|
||||
geladen werden. Stellst du diese Option an, während die Map bereits geladen ist, wird
|
||||
wahrscheinlich nichts geschehen, da alle Texturen für diese Map bereits geladen sind.
|
||||
Wechsle also die Map oder lade erneut.
|
||||
|
||||
Zip Dateien können eine "texmod.def" Datei enthalten, welche die Hash-Werte und
|
||||
Dateinamen enthält. Jede Zeile sollte dem Format "hash|filename.dds" entsprechen.
|
||||
Wenn es keine "texmod.def" Datei enthält, wird jede Datei entpackt und jene, deren
|
||||
Namen auf das Wildcard "*_hash.dds" zutrifft, werden benutzt.
|
||||
Die Zip Datei kann eine "Comment.txt" Datei enthalten. Der Inhalte wird als Kommentar
|
||||
in der GUI angezeigt.
|
||||
|
||||
Wenn du einzelne Dateien lädst, sollten diese dem Wildcard "*_hash.dds" entsprechen.
|
||||
|
||||
|
||||
Wie interagiert Universal Modding Engine mit den Spielen?
|
||||
|
||||
Universal Modding Engine klingt sich zwischen die Verbindung vom Spiel und DirectX ein.
|
||||
Das verlangt, dass Universal Modding Engine bereits vor dem Spiel gestartet wird.
|
||||
|
||||
Die GUI von Universal Modding Engine fungiert als Server. Ein Spiel, in das sich erfolgreich
|
||||
eingeklingt wurde, verbindet sich beim Programmstart mit dem Server.
|
||||
Die GUI von Universal Modding Engine kann mehrere Spiele gleichzeitig verwalten.
|
||||
Jede Instanz eines Spieles wird auch separat gehandhabt (wenn ein Spiel
|
||||
mehrfach gestartet wird).
|
||||
|
||||
|
||||
Wie bekomme ich Universal Modding Engine zum laufen?
|
||||
|
||||
Es gibt drei Wege wie uMod sich in die DirectX Verbindung einklinken kann:
|
||||
(Benutze NICHT mehrere Methoden gleichzeitig!)
|
||||
|
||||
1) Füge die Spiel-exe über das Menü "Einstellungen->Spiel hinzufügen" hinzu.
|
||||
Für Steam siehe unten.
|
||||
|
||||
bekannte Probleme: Guild Wars (Win XP)
|
||||
|
||||
2) Starte das Spiel direkt durch OTM über das Menü
|
||||
"Einstellungen->Sarte Spiel durch OTM" oder
|
||||
"Einstellungen->Sarte Spiel durch OTM (mit Kommandozeile)".
|
||||
Das Spiel startet sofort.
|
||||
|
||||
3) Kopiere die d3d9.dll (vom uMod Verzeichnis) in das Spiele Verzeichnis.
|
||||
Einige Spiele laden eine dll zuerst aus dem eigenen Verzeichnis bevor sie im
|
||||
Systemverzeichnis suchen. Nur für diese Spiele wird diese Methode funktionieren.
|
||||
WARNUNG: Kopiere diese dll niemals in das Systemverzeichnis!!
|
||||
|
||||
bekannte Probleme: Guild Wars
|
||||
|
||||
Wenn du dich für die erste oder dritte Methode entschieden hast, starte einfach
|
||||
Universal Modding Engine und danach das Spiel. Starte das Spiel in beiden Fällen NICHT über
|
||||
Universal Modding Engine .
|
||||
|
||||
Wenn das Spiel startet und alles glatt läuft, öffnet sich sofort ein neuer Tab in uMod.
|
||||
In diesem Tab kannst du nun das Spiel modden. Drücke den "Update" Button um
|
||||
die Einstellungen an das Spiel zu senden. Du kannst deine aktuellen Einstellungen auch
|
||||
als ein Template speichern. Ein Template kann auch als Standard eingestellt werden.
|
||||
Es wird dann automatisch geladen und an das Spiel gesendet, wenn
|
||||
dieses Spiel das nächste Mal gestartet wird.
|
||||
|
||||
Um einen Mod zu laden, musst du das Häkchen vor den Namen setzen. Wenn du
|
||||
den Mod entladen willst, entferne das Häkchen und klicke auf "Update".
|
||||
|
||||
Der Update Button lädt nur Veränderungen (wenn 1) Pakete aus der Liste entfernt
|
||||
wurden, 2) du die Häkchen verändert hast oder 3) sich die Reihenfolge geändert hat)
|
||||
Der "neu laden" Button erzwingt das Neuladen von Festplatte (z.B. wenn du die
|
||||
Texturen verändert hast).
|
||||
|
||||
Weil verschiedene Mods die gleiche Ziel-Textur verändern könnten, wird nur die
|
||||
Mod-Textur des ersten Mods berücksichtigt. Die Aktion dieses Mods (also Laden oder
|
||||
Entladen) wird durchgeführt, ungeachtet dessen, was die restlichen Mods mit der
|
||||
Ziel-Textur machen sollen.
|
||||
|
||||
|
||||
Wie bekommt man Universal Modding Engine mit Steam zum Laufen?
|
||||
|
||||
uMod schaut auf den Namen und auf das Verzeichnis der ausgeführten Spiel-exe.
|
||||
Daher solltest du nicht die steam.exe sondern die Spiel.exe hinzufügen.
|
||||
z.B.: C:\Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
Wenn du die entsprechende exe nicht findest, kannst du das Spiel normal starten und
|
||||
über den TaskManager die entsprechende exe suchen. Über Rechstklick->Eigenschaften
|
||||
erfährst du dann auch den Pfad der exe.
|
||||
@@ -1,107 +0,0 @@
|
||||
WARNING: You use this program at your own risk!
|
||||
1) If the program crash, you won't get probably any support from the game developer,
|
||||
but you can report the bug under http://code.google.com/p/texmod/issues/list
|
||||
2) Games can detected if they are modified, so you might risk a ban
|
||||
of your online account!
|
||||
3) This is an open-source project. The code can be retrieved, modified and compiled
|
||||
by everyone. Download Universal Modding Engine only from sources you trust!
|
||||
Download it by your self and don't use versions, send to you by team or guild members!
|
||||
http://code.google.com/p/texmod/downloads/list
|
||||
|
||||
Universal Modding Engine uses the D3DX9_43.dll (32bit). Due to the EULA this dll
|
||||
cannot be delivered together with Universal Modding Engine . If D3DX9_43.dll is not
|
||||
installed on your system, Universal Modding Engine will give you a hint at program start.
|
||||
|
||||
|
||||
What can Universal Modding Engine (uMod) V1.0?
|
||||
|
||||
-extract and save single textures from a DX9 game (the target texture can be toggled in the game)
|
||||
-extract and save all textures from a DX9 game
|
||||
-load textures into a game to replace target textures
|
||||
-support single dds texture
|
||||
-support zip-files as whole mod package
|
||||
-support the original TexMod *.tpf files
|
||||
|
||||
All these options can be switched on or off, while the game is already running!
|
||||
So you can search for a texture in the game, save it to disk, edit it,
|
||||
load it into the game, edit it again and load it into the game again, ...,
|
||||
actiavate or deactivate mods and all without a restart of the game.
|
||||
|
||||
side note: If "save all textures" is switched on, the texture will only be saved, if
|
||||
the textures are loaded by the game and only in the moment they are loaded.
|
||||
If you switch this option on, while a map is loaded, probably nothing will hapen,
|
||||
because all textures are loaded for this map. Change the Map or reload it again.
|
||||
|
||||
Zip files can include a "texmod.def" file which contains the hash and the file name.
|
||||
Each line should be in the format "hash|filename.dds"
|
||||
If it does not contain a "texmod.def" each file will be unpacked and those which match
|
||||
the wildcard "*_hash.dds" will be used.
|
||||
The zip file can include a "Comment.txt" file. The content will be shown as comment
|
||||
in the GUI.
|
||||
|
||||
If you load single files, they should match the wildcard "*_hash.dds"
|
||||
|
||||
|
||||
How does Universal Modding Engine interact with the game?
|
||||
|
||||
Universal Modding Engine intercept the connection between the game and DirectX.
|
||||
It is required, that Universal Modding Engine is running before the game is started.
|
||||
|
||||
The GUI of Universal Modding Engine act as a server. A game which is successfully
|
||||
intercepted with the Universal Modding Engine-dll will connect on program start to the server.
|
||||
The GUI of Universal Modding Engine can handle multiple games at the same time. It will
|
||||
also process each instance of a game as separate process (if the same game
|
||||
was started more than once).
|
||||
|
||||
|
||||
How to get Universal Modding Engine work?
|
||||
|
||||
There are three ways how Universal Modding Engine can intercept the DirectX connection:
|
||||
(Do NOT use more than one method simultaneously!)
|
||||
|
||||
1) Add the games-binary through the menu "Main->Add game"
|
||||
For Steam see below.
|
||||
|
||||
known problems: Guild Wars (Win XP)
|
||||
|
||||
2) Start the game directly through uMod though the menu
|
||||
"Main->Start game through uMod" or
|
||||
"Main->Start game through uMod (with command line)".
|
||||
The game start immediately.
|
||||
|
||||
3) Copy the d3d9.dll (from the Universal Modding Engine directory) into the game directory.
|
||||
Some games load a dll first from their own directory before they look up the system directory.
|
||||
Only for these games this method will work.
|
||||
WARNING: never copy this dll into your system directory!!
|
||||
|
||||
known problems: Guild Wars
|
||||
|
||||
If you have chosen the first or third method, you simply start Universal Modding Engine
|
||||
and afterwards the game. Do NOT start the game through Universal Modding Engine.
|
||||
|
||||
If the game starts and all works fine, a new tab opens immediately in uMod.
|
||||
In this tab you can now mod the game. Press the "update" button to commit
|
||||
the changes to the game. You can also save your current settings as a template.
|
||||
One template can be set as default for a game, which will be loaded and
|
||||
and committed automatically when you start this game the next time.
|
||||
|
||||
To load a mod, you must set the check mark of the file. If you wish to unload a mod,
|
||||
just remove the check mark and click on update again.
|
||||
|
||||
Clicking on update will only update the differences (if packages have been
|
||||
removed from the list, you toggled check marks or changed the order). The reload
|
||||
button forces to reload from disk (if you have edited the texture itself).
|
||||
|
||||
Due to the fact that different mods can modify the same target texture, only the
|
||||
mod-texture of the first file in the list is taken into account. The action of this file
|
||||
(load or unload) is proceeded regardless of what the following mods are opposed
|
||||
to do with their mod-textures.
|
||||
|
||||
|
||||
How to get Universal Modding Engine work together with Steam?
|
||||
|
||||
Universal Modding Engine looks for the name and the path of the executed binary.
|
||||
Thus you shall not add the steam.exe but rather the game.exe
|
||||
e.g.: C:\Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
If you cannot find the exe, just start the game and use the TaskManager
|
||||
to search for it. You can figure out the path through right click->properties.
|
||||
@@ -1,110 +0,0 @@
|
||||
ATTENTION : Vous utilisez ce programme à vous risque !
|
||||
1) Si le programme plante, vous n'aurez probablement aucune aide des développeurs,
|
||||
mais vous pouvez envoyer le bogue sur http://code.google.com/p/texmod/issues/list
|
||||
2) Les jeux peuvent détecter les modifications de uMod, vous prenez le risque de bannir
|
||||
votre compte en ligne !
|
||||
3) C'est un projet open-source. Le code peut être récupéré, modifié et compilé
|
||||
par tout le monde. Téléchargez Universal Modding Engine seulement sur des sources sûres !
|
||||
Ne télécharger pas et n'utiliser pas d'autres versions modifiées de ce logiciel,
|
||||
par exemple des versions envoyées par votre équipe ou votre guilde !
|
||||
Le site officiel : http://code.google.com/p/texmod/downloads/list
|
||||
|
||||
Universal Modding Engine utilise le D3DX9_43.dll (32bit). En raison de la licence CLUF cette dll
|
||||
ne peut pas être livrée avec Universal Modding Engine . Si vous n'avez pas D3DX9_43.dll
|
||||
d'installé sur votre système, Universal Modding Engine va vous afficher un message
|
||||
au démarrage du programme.
|
||||
|
||||
|
||||
Que fait Universal Modding Engine (uMod) V1.0 ?
|
||||
|
||||
-Extraire et sauvegarder des textures d'un jeu DX9 (la texture d'origine peut se modifier)
|
||||
-Extraire et sauvegarder toutes les textures d'un jeu DX9
|
||||
-Charger des textures dans un jeu pour remplacer les textures d'origines
|
||||
-Supporte les textures DDS
|
||||
-Supporte les fichiers compressés (ZIP) pour faire un MOD (modifier plusieurs textures à la fois)
|
||||
-Supporte les fichiers de TexMod *.tpf
|
||||
|
||||
Toutes les options peuvent s'activer ou se désactiver, pendant que le jeu est lancé !
|
||||
Ainsi, vous pouvez rechercher une texture dans le jeu, l'enregistrer sur disque, la modifier,
|
||||
la charger dans le jeu, éditer une autre texture, la charger dans le jeu, etc...,
|
||||
Activer ou désactiver des MODs sans aucun redémarrage du jeu.
|
||||
|
||||
Remarque : Si vous cochez "Sauvegarder toutes les textures", les textures qui seront enregistrées,
|
||||
sont les textures chargées dans le jeu après le moment où vous avez coché la case.
|
||||
Si vous activez cette option, pendant qu'une carte est chargée, vous n'allez probablement rien enregistrer,
|
||||
parce que toutes les textures sont déjà chargées. Changez de Carte ou rechargez-là.
|
||||
|
||||
Les fichiers compressés peuvent inclure le fichier "texmod.def" qui contient le hash et le nom du fichier.
|
||||
Chaque ligne doit avoir le format "hash|filename.dds"
|
||||
Si elle ne contient pas un "texmod.def" chaque fichier sera décompressé et seuls les fichiers ayant
|
||||
le format "*_hash.dds" seront utilisés.
|
||||
Le fichier zip peut inclure un fichier "Comment.txt". Le contenu sera affiché comme commentaire
|
||||
dans l'interface graphique.
|
||||
|
||||
Si vous chargez des textures seules, elles doivent correspondre au format "*_hash.dds"
|
||||
|
||||
|
||||
Comment Universal Modding Engine interagit avec les jeux ?
|
||||
|
||||
Universal Modding Engine intercepte la connexion entre le jeu et DirectX.
|
||||
Il est nécessaire, que Universal Modding Engine soit lancé avant le jeu.
|
||||
|
||||
L'interface graphique de Universal Modding Engine est comme un serveur.
|
||||
Un jeu correctement intercepté par Universal Modding Engine-dll se connectera au démarrage sur le serveur.
|
||||
L'interface graphique de Universal Modding Engine peut gérer plusieurs jeux en même temps. Il sera
|
||||
également traiter chaque jeu en tant que processus indépendant (si le même jeu
|
||||
a été lancé plus d'une fois).
|
||||
|
||||
|
||||
Comment Universal Modding Engine fonctionne ?
|
||||
|
||||
Il y a trois façon pour que Universal Modding Engine intercepte la connexion à DirectX :
|
||||
(Ne PAS utiliser plus d'une méthode à la fois !)
|
||||
|
||||
1) Ajouter l'exécutable du jeu dans le menu "Réglages->Ajouter un jeu"
|
||||
Pour Steam, voir plus bas.
|
||||
|
||||
Problèmes connus : Guild Wars (Win XP)
|
||||
|
||||
2) Lancer le jeu directement via le menu uMod
|
||||
"Réglages->Lancer le jeu avec uMod" ou
|
||||
"Réglages->Lancer le jeu avec uMod (en ligne de commande)".
|
||||
Le jeu se lance directement.
|
||||
|
||||
3) Copier le d3d9.dll (depuis le répertoire de Universal Modding Engine) dans votre dossier de jeu.
|
||||
Certain jeu recherche les DLLs dans leur répertoire avant d'aller chercher les DLLs dans
|
||||
le dossier du système.
|
||||
Cette méthode ne fonctionne que sur certain jeu.
|
||||
ATTENTION : Ne jamais copier ce fichier DLL dans votre répertoire système !!!
|
||||
|
||||
Problèmes connus : Guild Wars
|
||||
|
||||
Si vous avez choisi la première ou la troisième méthode, il vous suffit de lancer Universal Modding Engine
|
||||
et de lancer le jeu séparément. Ne PAS lancer le jeu via uMod.
|
||||
|
||||
Si le jeu se lance et tout fonctionne, un nouveau onglet va s'ouvrir directement dans uMod.
|
||||
Dans cet onglet vous pouvez modifier le jeu. Appuyer sur "Mettre à jour"
|
||||
pour envoyer les changements au jeu. Vous pouvez sauvegarder vos paramètres actuels comme thème.
|
||||
Un thème peut être lancé par défaut au démarrage d'un jeu.
|
||||
|
||||
Pour charger une texture ou un mod, vous devez cocher la case du fichier. Si vous voulez décharger un mod,
|
||||
il faut simplement décocher la case et cliquer sur "Mettre à jour".
|
||||
|
||||
En cliquant sur "Mettre à jour", seules les textures chargées dans uMod seront misent à jour
|
||||
(si une texture chargée est supprimée de la liste, cela va juste décocher la texture).
|
||||
Cliquez sur "Mettre à jour (Recharger)" pour recharger les fichiers de texture sur le disque dur.
|
||||
(Si vous venez de modifier une texture déjà chargée par exemple).
|
||||
|
||||
En raison du fait que plusieurs mods peuvent modifier la même texture, seuls le mod / la texture
|
||||
du premier fichier de la liste est pris en compte pour la modification. L'action de ce mod
|
||||
(c'est à dire le chargement ou le déchargement) est effectuée, indépendamment des autres mods.
|
||||
|
||||
|
||||
Comment faire pour que Universal Modding Engine fonctionne avec Steam ?
|
||||
|
||||
Universal Modding Engine cherche le nom et le chemin du fichier binaire exécuté.
|
||||
Ainsi vous ne devez pas ajouter Steam.exe mais plutôt le game.exe
|
||||
exemple : C:\Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
Si vous ne trouvez pas l'exécutable, il suffit de commencer le jeu et
|
||||
d'utiliser "le Gestionnaire des tâches" pour rechercher dans quel dossier il se trouve en
|
||||
faisant un clique droit sur le nom de l'exécutable "Propriétés"->"Emplacement".
|
||||
@@ -1,152 +0,0 @@
|
||||
If you have created a language package and would like to add to the officially download, please send it to me.
|
||||
Email address and support can be found at http://code.google.com/p/texmod/
|
||||
|
||||
|
||||
The file name must match the wildcard uMod_LanguagePack_NAMEOFLANGUAGE.txt
|
||||
Format of an entry is divided into 3 parts: 1) Keyword directly followed by a colon, 2) message, and 3) end symbol "|"
|
||||
Restriction of the the message: do not use "|" within a message!!
|
||||
|
||||
You can also use utf-16LE encoding, but you have to label the file as uMod_LanguagePackU_NAMEOFLANGUAGE.txt
|
||||
|
||||
comments must start with an "#" and must end with |
|
||||
|
||||
e.g.
|
||||
|
||||
#
|
||||
|
||||
this is a comment
|
||||
|
||||
|
|
||||
|
||||
Keyword:
|
||||
|
||||
Message1 line1
|
||||
Message1 line2
|
||||
|
||||
|
|
||||
|
||||
Keyword2:Message2|
|
||||
Keyword3:Message3 line1
|
||||
Message3 line2|
|
||||
|
||||
|
||||
There is no need to include all keywords, since English is loaded each time as default and afterwards the entries are replaced.
|
||||
English itself is compiled into the uMod_GUI.exe, thus there exists no uMod_LanguagePack_English.txt.
|
||||
|
||||
The following list is an example of how an English package would look like (maybe not all keywords are present).
|
||||
|
||||
|
||||
|
||||
MenuHelp:
|
||||
Help|
|
||||
MenuAbout:
|
||||
About|
|
||||
MenuAcknowledgement:Acknowledgement|
|
||||
MenuStartGame:Start game through uMod|
|
||||
MenuStartGameCMD :Start game through uMod (with command line)|
|
||||
MenuUseHook:Use global hook|
|
||||
MenuAddGame:
|
||||
Add game|
|
||||
MenuDeleteGame:
|
||||
Delete Game|
|
||||
MenuLoadTemplate:Load template|
|
||||
MenuSaveTemplate:Save template|
|
||||
MenuSaveTemplateAs:Save template as ...|
|
||||
MenuSetDefaultTemplate:Set template as default|
|
||||
MenuLanguage:Change language|
|
||||
MenuExit:Exit|
|
||||
MainMenuMain:Main|
|
||||
MainMenuHelp:
|
||||
Help|
|
||||
|
||||
|
||||
ButtonOpen:
|
||||
Open texture|
|
||||
ButtonDirectory:
|
||||
save directory|
|
||||
ButtonUpdate:
|
||||
Update|
|
||||
ButtonReload:Update (reload)|
|
||||
|
||||
|
||||
ChooseFile:Choose a file|
|
||||
ChooseDir:
|
||||
Choose a directory|
|
||||
CheckBoxSaveSingleTexture:
|
||||
Save single texture|
|
||||
TextCtrlTemplate:Template: |
|
||||
CheckBoxSaveAllTextures:
|
||||
Save all textures|
|
||||
TextCtrlSavePath:
|
||||
Save path: |
|
||||
SelectLanguage:
|
||||
Select a language|
|
||||
StartGame:Select the game to start.|
|
||||
CommandLine:Set command line arguments.|
|
||||
ChooseGame:
|
||||
Select a game binary.
|
||||
DeleteGame:
|
||||
Select the games to be deleted.|
|
||||
GameAlreadyAdded:
|
||||
Game has been already added.|
|
||||
ExitGameAnyway:
|
||||
Closing Universal Modding Engine while a game is running might lead to a crash of the game.
|
||||
Exit anyway?|
|
||||
NoComment:
|
||||
No comment.|
|
||||
Author:
|
||||
Author: |
|
||||
|
||||
|
||||
Error_GameIsHooked:The global hook is active and this game will be injected! Please delete the game from the list or disable the hook.|
|
||||
Error_ProcessNotStarted:The game could not be started.|
|
||||
Error_RemoveHook:Removing the Hook while a game is running might lead to crash.|
|
||||
Error_FileNotSupported:
|
||||
This file type is not supported:|
|
||||
Error_DLLNotFound:
|
||||
Could not load the dll.
|
||||
The dll injection won't work.
|
||||
This might happen if D3DX9_43.dll is not installed on your system.
|
||||
Please install the newest DirectX End-User Runtime Web Installer.|
|
||||
Error_FktNotFound:
|
||||
Could not load function out of dll.
|
||||
The dll injection won't work.|
|
||||
Error_AlreadyRunning:An other instance of Universal Modding Engine is already running.|
|
||||
Error_Send:
|
||||
Could not send to game.|
|
||||
Error_KeyTwice:
|
||||
You assigned a key twice.|
|
||||
Error_NoSavePath:
|
||||
You did not set a save path.|
|
||||
Error_KeyNotSet:
|
||||
At least one key is not set.|
|
||||
Error_SaveFile:
|
||||
Could not save to file.|
|
||||
Error_NoPipe:
|
||||
Pipe is not opened.|
|
||||
Error_WritePipe:
|
||||
Could not write in pipe.|
|
||||
Error_FlushPipe:
|
||||
Could not flush pipe buffer.|
|
||||
Error_Hash:
|
||||
Could not find hash, maybe file is not named as *_HASH.dds|
|
||||
Error_FileOpen:
|
||||
Could not open file.|
|
||||
Error_FileRead:
|
||||
Could not read file.|
|
||||
Error_Memory:
|
||||
Could not allocate enough memory|
|
||||
Error_Unzip:
|
||||
Could not unzip.|
|
||||
Error_ZipEntry:
|
||||
Could not find zip entry.|
|
||||
KeyBack:
|
||||
Back|
|
||||
KeySave:
|
||||
Save|
|
||||
KeyNext:
|
||||
Next|
|
||||
FontColour:
|
||||
Font colour (RGB):|
|
||||
TextureColour:
|
||||
Texture colour (RGB):|
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,75 +0,0 @@
|
||||
# by mirHL|
|
||||
|
||||
MenuHelp:Aiuto|
|
||||
MenuAbout:Informazioni|
|
||||
MenuAcknowledgement:Riconoscimenti|
|
||||
MenuStartGame:Avvia il gioco da uMod|
|
||||
MenuStartGameCMD:Avvia il gioco da uMod (con riga di comando)|
|
||||
MenuUseHook:Usa hook globale|
|
||||
MenuAddGame:Aggiungi gioco|
|
||||
MenuDeleteGame:Rimuovi gioco|
|
||||
MenuLoadTemplate:Carica template|
|
||||
MenuSaveTemplate:Salva template|
|
||||
MenuSaveTemplateAs:Salva template come...|
|
||||
MenuSetDefaultTemplate:Imposta template come predefinito|
|
||||
MenuLanguage:Cambia lingua (Change language)|
|
||||
MenuExit:Esci|
|
||||
MainMenuMain:Comandi|
|
||||
MainMenuHelp:Aiuto|
|
||||
|
||||
|
||||
ButtonOpen:Apri texture/archivio|
|
||||
ButtonDirectory:Imposta cartella lavoro|
|
||||
ButtonUpdate:Aggiorna|
|
||||
ButtonReload:Aggiorna (ricarica)|
|
||||
|
||||
|
||||
ChooseFile:Seleziona un file|
|
||||
ChooseDir:Seleziona una cartella|
|
||||
CheckBoxSaveSingleTexture:Salva singole texture|
|
||||
TextCtrlTemplate:Template: |
|
||||
CheckBoxSaveAllTextures:Salva tutte le texture|
|
||||
TextCtrlSavePath:Percorso lavori: |
|
||||
SelectLanguage:Seleziona una lingua|
|
||||
StartGame:Seleziona il gioco da far partire.|
|
||||
CommandLine:Imposta opzioni da riga di comando.|
|
||||
ChooseGame:Seleziona un eseguibile di un gioco.|
|
||||
DeleteGame:Seleziona i giochi da rimuovere.|
|
||||
GameAlreadyAdded:Il gioco è già stato aggiunto.|
|
||||
ExitGameAnyway:Chiudere uMod mentre il gioco è in esecuzione potrebbe farlo crashare.
|
||||
Uscire comunque?|
|
||||
NoComment:Nessun commento.|
|
||||
Author:Autore: |
|
||||
|
||||
|
||||
Error_GameIsHooked:L'hook globale è attivo e questo è in conflitto col lancio! Per favore rimuovi il gioco dalla lista o spegni l'hook.|
|
||||
Error_ProcessNotStarted:Il gioco non è potuto essere avviato.|
|
||||
Error_RemoveHook:Rimuovere l'Hook mentre il gioco è in esecuzione potrebbe farlo crashare.|
|
||||
Error_FileNotSupported:Questo tipo di file non è supportato:|
|
||||
Error_DLLNotFound:
|
||||
Impossibile caricare la dll.
|
||||
La dll injection non funzionerà.
|
||||
Questo accade perchè D3DX9_43.dll non è installato nel sistema.
|
||||
Installa DirectX End-User Runtime Web Installer.|
|
||||
Error_FktNotFound:Impossibile caricare una funzione fuori della dll.
|
||||
La dll injection non funzionerà.|
|
||||
Error_AlreadyRunning:Un altro processo di uMod è in esecuzione.|
|
||||
Error_Send:Impossibile arrivare al gioco.|
|
||||
Error_KeyTwice:Hai assegnato due volte lo stesso tasto.|
|
||||
Error_NoSavePath:Non hai selezionato un percorso di salvataggio.|
|
||||
Error_KeyNotSet:Qualche tasto non è assegnato.|
|
||||
Error_SaveFile:Impossibile salvare il file.|
|
||||
Error_NoPipe:Pipe non è aperto.|
|
||||
Error_WritePipe:impossibile scrivere in pipe.|
|
||||
Error_FlushPipe:Impossibile ripulire pipe buffer.|
|
||||
Error_Hash:Impossibile trovare l'hash, forse il file non è chiamato *_HASH.dds|
|
||||
Error_FileOpen:Impossibile aprire il file.|
|
||||
Error_FileRead:Impossibile leggere il file.|
|
||||
Error_Memory:Impossibile allocare abbastanza memoria|
|
||||
Error_Unzip:Impossibile scomprimere.|
|
||||
Error_ZipEntry:Impossibile trovare Zip entry.|
|
||||
KeyBack:Precedente|
|
||||
KeySave:Salva|
|
||||
KeyNext:Successivo|
|
||||
FontColour:Colore caratteri (RGB):|
|
||||
TextureColour:Colore texture (RGB):|
|
||||
@@ -1,149 +0,0 @@
|
||||
# =========================================================================
|
||||
# This configuration file was generated by
|
||||
# Bakefile 0.2.8 (http://www.bakefile.org)
|
||||
# Beware that all changes made to this file will be overwritten next
|
||||
# time you run Bakefile!
|
||||
# =========================================================================
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# These are configurable options:
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# Compiler flags to link shared library
|
||||
#LINK_DLL_FLAGS ?= -shared
|
||||
LINK_DLL_FLAGS ?=
|
||||
|
||||
# Compiler flags to link loadable module
|
||||
#LINK_MODULE_FLAGS ?= -shared
|
||||
LINK_MODULE_FLAGS ?=
|
||||
|
||||
# C compiler
|
||||
CC = gcc
|
||||
|
||||
# C++ compiler
|
||||
CXX = g++
|
||||
|
||||
# Standard flags for CC
|
||||
CFLAGS ?=
|
||||
|
||||
# Standard flags for C++
|
||||
CXXFLAGS ?= -Wno-unused
|
||||
|
||||
# Standard preprocessor flags (common for CC and CXX)
|
||||
CPPFLAGS ?=
|
||||
|
||||
# Standard linker flags
|
||||
LDFLAGS ?= -static-libgcc -static-libstdc++
|
||||
|
||||
# The C preprocessor
|
||||
CPP ?= $(CC) -E
|
||||
|
||||
# What type of library to build? [0,1]
|
||||
SHARED ?= 0
|
||||
|
||||
# Build wxUniversal instead of native port? [0,1]
|
||||
WXUNIV ?= 0
|
||||
|
||||
# Compile Unicode build of wxWidgets? [0,1]
|
||||
UNICODE ?= 1
|
||||
|
||||
# Use MSLU library when building Unicode version. [0,1]
|
||||
MSLU ?= 0
|
||||
|
||||
# Type of compiled binaries [debug,release]
|
||||
BUILD ?= release
|
||||
|
||||
# Should debugging info be included in the executables? The default value
|
||||
# "default" means that debug info will be included if BUILD=debug
|
||||
# and not included if BUILD=release. [0,1,default]
|
||||
DEBUG_INFO ?= 0
|
||||
|
||||
# Value of wxDEBUG_LEVEL. The default value is the same as 1 and means that all
|
||||
# but expensive assert checks are enabled, use 0 to completely remove debugging
|
||||
# code. [0,1,default]
|
||||
DEBUG_FLAG ?= 0
|
||||
|
||||
# Multiple libraries or single huge monolithic one? [0,1]
|
||||
MONOLITHIC ?= 0
|
||||
|
||||
# Build GUI libraries? [0,1]
|
||||
USE_GUI ?= 1
|
||||
|
||||
# Build wxHTML library (USE_GUI must be 1)? [0,1]
|
||||
USE_HTML ?= 1
|
||||
|
||||
# Build multimedia library (USE_GUI must be 1)? [0,1]
|
||||
USE_MEDIA ?= 1
|
||||
|
||||
# Build wxXRC library (USE_GUI must be 1)? [0,1]
|
||||
USE_XRC ?= 1
|
||||
|
||||
# Build wxAUI library (USE_GUI must be 1)? [0,1]
|
||||
USE_AUI ?= 1
|
||||
|
||||
# Build wxRibbon library (USE_GUI must be 1)? [0,1]
|
||||
USE_RIBBON ?= 1
|
||||
|
||||
# Build wxPropertyGrid library (USE_GUI must be 1)? [0,1]
|
||||
USE_PROPGRID ?= 1
|
||||
|
||||
# Build wxRichTextCtrl library (USE_GUI must be 1)? [0,1]
|
||||
USE_RICHTEXT ?= 1
|
||||
|
||||
# Build wxStyledTextCtrl library (USE_GUI must be 1)? [0,1]
|
||||
USE_STC ?= 1
|
||||
|
||||
# Build OpenGL canvas library (USE_GUI must be 1)? [0,1]
|
||||
USE_OPENGL ?= 1
|
||||
|
||||
# Build quality assurance classes library (USE_GUI must be 1)? [0,1]
|
||||
USE_QA ?= 0
|
||||
|
||||
# Enable exceptions in compiled code. [0,1]
|
||||
USE_EXCEPTIONS ?= 1
|
||||
|
||||
# Enable run-time type information (RTTI) in compiled code. [0,1]
|
||||
USE_RTTI ?= 1
|
||||
|
||||
# Enable threading in compiled code. [0,1]
|
||||
USE_THREADS ?= 1
|
||||
|
||||
# Enable wxCairoContext for platforms other than Linux/GTK. [0,1]
|
||||
USE_CAIRO ?= 0
|
||||
|
||||
# Is this official build by wxWidgets developers? [0,1]
|
||||
OFFICIAL_BUILD ?= 0
|
||||
|
||||
# Use this to name your customized DLLs differently
|
||||
VENDOR ?= custom
|
||||
|
||||
#
|
||||
WX_FLAVOUR ?=
|
||||
|
||||
#
|
||||
WX_LIB_FLAVOUR ?=
|
||||
|
||||
# Name of your custom configuration. This affects directory
|
||||
# where object files are stored as well as the location of
|
||||
# compiled .lib files and setup.h under the lib/ toplevel directory.
|
||||
CFG ?=
|
||||
|
||||
# Compiler flags needed to compile test suite in tests directory. If you want
|
||||
# to run the tests, set it so that the compiler can find CppUnit headers.
|
||||
CPPUNIT_CFLAGS ?=
|
||||
|
||||
# Linker flags needed to link test suite in tests directory. If you want
|
||||
# to run the tests, include CppUnit library here.
|
||||
CPPUNIT_LIBS ?=
|
||||
|
||||
# Version of C runtime library to use. You can change this to
|
||||
# static if SHARED=0, but it is highly recommended to not do
|
||||
# it if SHARED=1 unless you know what you are doing. [dynamic,static]
|
||||
RUNTIME_LIBS ?= static
|
||||
|
||||
# Set the version of your Mingw installation here.
|
||||
# "3" ...... this is for Mingw 2.0 or newer (comes with gcc3)
|
||||
# "2.95" ... for Mingw 1.1 or any of the older versions [3,2.95]
|
||||
GCC_VERSION ?= 3
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
# =========================================================================
|
||||
# This configuration file was generated by
|
||||
# Bakefile 0.2.8 (http://www.bakefile.org)
|
||||
# Beware that all changes made to this file will be overwritten next
|
||||
# time you run Bakefile!
|
||||
# =========================================================================
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# These are configurable options:
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# C compiler
|
||||
CC = cl
|
||||
|
||||
# C++ compiler
|
||||
CXX = cl
|
||||
|
||||
# Standard flags for CC
|
||||
CFLAGS =
|
||||
|
||||
# Standard flags for C++
|
||||
CXXFLAGS =
|
||||
|
||||
# Standard preprocessor flags (common for CC and CXX)
|
||||
CPPFLAGS =
|
||||
|
||||
# Standard linker flags
|
||||
LDFLAGS =
|
||||
|
||||
# The C preprocessor
|
||||
CPP = $(CC) /EP /nologo
|
||||
|
||||
# What type of library to build? [0,1]
|
||||
SHARED = 0
|
||||
|
||||
# Build wxUniversal instead of native port? [0,1]
|
||||
WXUNIV = 0
|
||||
|
||||
# Compile Unicode build of wxWidgets? [0,1]
|
||||
UNICODE = 1
|
||||
|
||||
# Use MSLU library when building Unicode version. [0,1]
|
||||
MSLU = 0
|
||||
|
||||
# Type of compiled binaries [debug,release]
|
||||
BUILD = release
|
||||
|
||||
# The target processor architecture must be specified when it is not X86.
|
||||
# This does not affect the compiler output, so you still need to make sure
|
||||
# your environment is set up appropriately with the correct compiler in the
|
||||
# PATH. Rather it affects some options passed to some of the common build
|
||||
# utilities such as the resource compiler and the linker.
|
||||
#
|
||||
# Accepted values: AMD64, IA64.
|
||||
TARGET_CPU = $(CPU)
|
||||
|
||||
# Should debugging info be included in the executables? The default value
|
||||
# "default" means that debug info will be included if BUILD=debug
|
||||
# and not included if BUILD=release. [0,1,default]
|
||||
DEBUG_INFO = 1
|
||||
|
||||
# Value of wxDEBUG_LEVEL. The default value is the same as 1 and means that all
|
||||
# but expensive assert checks are enabled, use 0 to completely remove debugging
|
||||
# code. [0,1,default]
|
||||
DEBUG_FLAG = 0
|
||||
|
||||
# Link against debug (e.g. msvcrtd.dll) or release (msvcrt.dll) RTL?
|
||||
# Default is to use debug CRT if and only if BUILD==debug. [0,1,default]
|
||||
DEBUG_RUNTIME_LIBS = default
|
||||
|
||||
# Multiple libraries or single huge monolithic one? [0,1]
|
||||
MONOLITHIC = 0
|
||||
|
||||
# Build GUI libraries? [0,1]
|
||||
USE_GUI = 1
|
||||
|
||||
# Build wxHTML library (USE_GUI must be 1)? [0,1]
|
||||
USE_HTML = 1
|
||||
|
||||
# Build multimedia library (USE_GUI must be 1)? [0,1]
|
||||
USE_MEDIA = 1
|
||||
|
||||
# Build wxXRC library (USE_GUI must be 1)? [0,1]
|
||||
USE_XRC = 1
|
||||
|
||||
# Build wxAUI library (USE_GUI must be 1)? [0,1]
|
||||
USE_AUI = 1
|
||||
|
||||
# Build wxRibbon library (USE_GUI must be 1)? [0,1]
|
||||
USE_RIBBON = 1
|
||||
|
||||
# Build wxPropertyGrid library (USE_GUI must be 1)? [0,1]
|
||||
USE_PROPGRID = 1
|
||||
|
||||
# Build wxRichTextCtrl library (USE_GUI must be 1)? [0,1]
|
||||
USE_RICHTEXT = 1
|
||||
|
||||
# Build wxStyledTextCtrl library (USE_GUI must be 1)? [0,1]
|
||||
USE_STC = 1
|
||||
|
||||
# Build OpenGL canvas library (USE_GUI must be 1)? [0,1]
|
||||
USE_OPENGL = 1
|
||||
|
||||
# Build quality assurance classes library (USE_GUI must be 1)? [0,1]
|
||||
USE_QA = 1
|
||||
|
||||
# Enable exceptions in compiled code. [0,1]
|
||||
USE_EXCEPTIONS = 1
|
||||
|
||||
# Enable run-time type information (RTTI) in compiled code. [0,1]
|
||||
USE_RTTI = 1
|
||||
|
||||
# Enable threading in compiled code. [0,1]
|
||||
USE_THREADS = 1
|
||||
|
||||
# Enable wxCairoContext for platforms other than Linux/GTK. [0,1]
|
||||
USE_CAIRO = 0
|
||||
|
||||
# Is this official build by wxWidgets developers? [0,1]
|
||||
OFFICIAL_BUILD = 0
|
||||
|
||||
# Use this to name your customized DLLs differently
|
||||
VENDOR = custom
|
||||
|
||||
#
|
||||
WX_FLAVOUR =
|
||||
|
||||
#
|
||||
WX_LIB_FLAVOUR =
|
||||
|
||||
# Name of your custom configuration. This affects directory
|
||||
# where object files are stored as well as the location of
|
||||
# compiled .lib files and setup.h under the lib/ toplevel directory.
|
||||
CFG =
|
||||
|
||||
# Compiler flags needed to compile test suite in tests directory. If you want
|
||||
# to run the tests, set it so that the compiler can find CppUnit headers.
|
||||
CPPUNIT_CFLAGS =
|
||||
|
||||
# Linker flags needed to link test suite in tests directory. If you want
|
||||
# to run the tests, include CppUnit library here.
|
||||
CPPUNIT_LIBS =
|
||||
|
||||
# Version of C runtime library to use. You can change this to
|
||||
# static if SHARED=0, but it is highly recommended to not do
|
||||
# it if SHARED=1 unless you know what you are doing. [dynamic,static]
|
||||
RUNTIME_LIBS = static
|
||||
|
||||
@@ -1,284 +0,0 @@
|
||||
# =========================================================================
|
||||
# This makefile was generated by
|
||||
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
|
||||
# Do not modify, all changes will be overwritten!
|
||||
# =========================================================================
|
||||
|
||||
include config.gcc
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Do not modify the rest of this file!
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
### Variables: ###
|
||||
|
||||
CPPDEPS = -MT$@ -MF$@.d -MD
|
||||
WX_RELEASE_NODOT = 29
|
||||
OBJS = \
|
||||
obj
|
||||
OBJS_exe = \
|
||||
bin
|
||||
WX_DIR = D:\Programme\wxWidgets-2.9.2
|
||||
LIBDIRNAME = $(WX_DIR)\lib\gcc_$(LIBTYPE_SUFFIX)$(CFG)
|
||||
SETUPHDIR = \
|
||||
$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
|
||||
MINIMAL_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG_2) $(__THREADSFLAG) \
|
||||
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
$(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) $(__MSLU_DEFINE_p) \
|
||||
$(__GFXCTX_DEFINE_p) -I$(SETUPHDIR) -I$(WX_DIR)\include -W -Wall -Wextra -I. \
|
||||
$(__DLLFLAG_p) -DNOPCH $(__RTTIFLAG_5) \
|
||||
$(__EXCEPTIONSFLAG_6) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
|
||||
MINIMAL_OBJECTS = \
|
||||
$(OBJS)\uMod_rc.o \
|
||||
$(OBJS)\unzip.o \
|
||||
$(OBJS)\uMod_DirectInjection.o \
|
||||
$(OBJS)\uMod_GUI.o \
|
||||
$(OBJS)\uMod_GameInfo.o \
|
||||
$(OBJS)\uMod_GamePage.o \
|
||||
$(OBJS)\uMod_Server.o \
|
||||
$(OBJS)\uMod_Client.o \
|
||||
$(OBJS)\uMod_File.o \
|
||||
$(OBJS)\uMod_Sender.o \
|
||||
$(OBJS)\uMod_Settings.o \
|
||||
$(OBJS)\uMod_AddTexture.o \
|
||||
$(OBJS)\uMod_Language.o
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
ifeq ($(GCC_VERSION),2.95)
|
||||
GCCFLAGS = -fvtable-thunks
|
||||
endif
|
||||
ifeq ($(USE_GUI),0)
|
||||
PORTNAME = base
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
PORTNAME = msw
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
ifeq ($(DEBUG_FLAG),default)
|
||||
WXDEBUGFLAG = d
|
||||
endif
|
||||
endif
|
||||
ifeq ($(DEBUG_FLAG),1)
|
||||
WXDEBUGFLAG = d
|
||||
endif
|
||||
ifeq ($(UNICODE),1)
|
||||
WXUNICODEFLAG = u
|
||||
endif
|
||||
ifeq ($(WXUNIV),1)
|
||||
WXUNIVNAME = univ
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
WXDLLFLAG = dll
|
||||
endif
|
||||
ifeq ($(SHARED),0)
|
||||
LIBTYPE_SUFFIX = lib
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
LIBTYPE_SUFFIX = dll
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
EXTRALIBS_FOR_BASE =
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
EXTRALIBS_FOR_BASE =
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
__OPTIMIZEFLAG_2 = -O0 -g
|
||||
endif
|
||||
ifeq ($(BUILD),release)
|
||||
__OPTIMIZEFLAG_2 = -O2
|
||||
endif
|
||||
ifeq ($(USE_RTTI),0)
|
||||
__RTTIFLAG_5 = -fno-rtti
|
||||
endif
|
||||
ifeq ($(USE_RTTI),1)
|
||||
__RTTIFLAG_5 =
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),0)
|
||||
__EXCEPTIONSFLAG_6 = -fno-exceptions
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),1)
|
||||
__EXCEPTIONSFLAG_6 =
|
||||
endif
|
||||
ifeq ($(WXUNIV),1)
|
||||
__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
|
||||
endif
|
||||
ifeq ($(WXUNIV),1)
|
||||
__WXUNIV_DEFINE_p_1 = --define __WXUNIVERSAL__
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
ifeq ($(DEBUG_FLAG),default)
|
||||
__DEBUG_DEFINE_p = -D__WXDEBUG__
|
||||
endif
|
||||
endif
|
||||
ifeq ($(DEBUG_FLAG),1)
|
||||
__DEBUG_DEFINE_p = -D__WXDEBUG__
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
ifeq ($(DEBUG_FLAG),default)
|
||||
__DEBUG_DEFINE_p_1 = --define __WXDEBUG__
|
||||
endif
|
||||
endif
|
||||
ifeq ($(DEBUG_FLAG),1)
|
||||
__DEBUG_DEFINE_p_1 = --define __WXDEBUG__
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),0)
|
||||
__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),0)
|
||||
__EXCEPTIONS_DEFINE_p_1 = --define wxNO_EXCEPTIONS
|
||||
endif
|
||||
ifeq ($(USE_RTTI),0)
|
||||
__RTTI_DEFINE_p = -DwxNO_RTTI
|
||||
endif
|
||||
ifeq ($(USE_RTTI),0)
|
||||
__RTTI_DEFINE_p_1 = --define wxNO_RTTI
|
||||
endif
|
||||
ifeq ($(USE_THREADS),0)
|
||||
__THREAD_DEFINE_p = -DwxNO_THREADS
|
||||
endif
|
||||
ifeq ($(USE_THREADS),0)
|
||||
__THREAD_DEFINE_p_1 = --define wxNO_THREADS
|
||||
endif
|
||||
ifeq ($(UNICODE),1)
|
||||
__UNICODE_DEFINE_p = -D_UNICODE
|
||||
endif
|
||||
ifeq ($(UNICODE),1)
|
||||
__UNICODE_DEFINE_p_1 = --define _UNICODE
|
||||
endif
|
||||
ifeq ($(MSLU),1)
|
||||
__MSLU_DEFINE_p = -DwxUSE_UNICODE_MSLU=1
|
||||
endif
|
||||
ifeq ($(MSLU),1)
|
||||
__MSLU_DEFINE_p_1 = --define wxUSE_UNICODE_MSLU=1
|
||||
endif
|
||||
ifeq ($(USE_GDIPLUS),1)
|
||||
__GFXCTX_DEFINE_p = -DwxUSE_GRAPHICS_CONTEXT=1
|
||||
endif
|
||||
ifeq ($(USE_GDIPLUS),1)
|
||||
__GFXCTX_DEFINE_p_1 = --define wxUSE_GRAPHICS_CONTEXT=1
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
__DLLFLAG_p = -DWXUSINGDLL
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
__DLLFLAG_p_1 = --define WXUSINGDLL
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
__WXLIB_CORE_p = \
|
||||
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
__WXLIB_BASE_p = \
|
||||
-lwxbase$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
__WXLIB_MONO_p = \
|
||||
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_TIFF_p = -lwxtiff$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_JPEG_p = -lwxjpeg$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_PNG_p = -lwxpng$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(MSLU),1)
|
||||
__UNICOWS_LIB_p = -lunicows
|
||||
endif
|
||||
ifeq ($(USE_GDIPLUS),1)
|
||||
__GDIPLUS_LIB_p = -lgdiplus
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
ifeq ($(DEBUG_INFO),default)
|
||||
__DEBUGINFO = -g
|
||||
endif
|
||||
endif
|
||||
ifeq ($(BUILD),release)
|
||||
ifeq ($(DEBUG_INFO),default)
|
||||
__DEBUGINFO =
|
||||
endif
|
||||
endif
|
||||
ifeq ($(DEBUG_INFO),0)
|
||||
__DEBUGINFO =
|
||||
endif
|
||||
ifeq ($(DEBUG_INFO),1)
|
||||
__DEBUGINFO = -g
|
||||
endif
|
||||
ifeq ($(USE_THREADS),0)
|
||||
__THREADSFLAG =
|
||||
endif
|
||||
ifeq ($(USE_THREADS),1)
|
||||
__THREADSFLAG = -mthreads
|
||||
endif
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
$(OBJS):
|
||||
-if not exist $(OBJS) mkdir $(OBJS)
|
||||
|
||||
all: $(OBJS_exe)
|
||||
$(OBJS_exe):
|
||||
-if not exist $(OBJS_exe) mkdir $(OBJS_exe)
|
||||
|
||||
### Targets: ###
|
||||
|
||||
all: $(OBJS_exe)\uMod.exe
|
||||
|
||||
clean:
|
||||
-if exist $(OBJS)\*.o del $(OBJS)\*.o
|
||||
-if exist $(OBJS)\*.d del $(OBJS)\*.d
|
||||
-if exist $(OBJS_exe)\uMod.exe del $(OBJS_exe)\uMod.exe
|
||||
|
||||
$(OBJS_exe)\uMod.exe: $(MINIMAL_OBJECTS) $(OBJS)\uMod_rc.o
|
||||
$(CXX) -o $@ $(MINIMAL_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) -Wl,--subsystem,windows -mwindows $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__GDIPLUS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
|
||||
|
||||
$(OBJS)\uMod_rc.o: uMod.rc uMod.ico
|
||||
windres --use-temp-file -i $< -o $@
|
||||
|
||||
$(OBJS)\unzip.o: ./unzip.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_DirectInjection.o: ./uMod_DirectInjection.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_GUI.o: ./uMod_GUI.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_GameInfo.o: ./uMod_GameInfo.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_GamePage.o: ./uMod_GamePage.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_Server.o: ./uMod_Server.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_Client.o: ./uMod_Client.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_File.o: ./uMod_File.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_Sender.o: ./uMod_Sender.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_Settings.o: ./uMod_Settings.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_AddTexture.o: ./uMod_AddTexture.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\uMod_Language.o: ./uMod_Language.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
||||
# Dependencies tracking:
|
||||
-include $(OBJS)/*.d
|
||||
@@ -1,401 +0,0 @@
|
||||
# =========================================================================
|
||||
# This makefile was generated by
|
||||
# Bakefile 0.2.8 (http://www.bakefile.org)
|
||||
# Do not modify, all changes will be overwritten!
|
||||
# =========================================================================
|
||||
|
||||
!include <config.vc>
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Do not modify the rest of this file!
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
### Variables: ###
|
||||
|
||||
WX_RELEASE_NODOT = 29
|
||||
COMPILER_PREFIX = vc
|
||||
OBJS = \
|
||||
obj
|
||||
OBJS_exe = \
|
||||
bin
|
||||
WX_DIR = D:\Programme\wxWidgets-2.9.2
|
||||
LIBDIRNAME = \
|
||||
$(WX_DIR)\lib\$(COMPILER_PREFIX)$(DIR_SUFFIX_CPU)_$(LIBTYPE_SUFFIX)$(CFG)
|
||||
SETUPHDIR = \
|
||||
$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
|
||||
MINIMAL_CXXFLAGS = /M$(__RUNTIME_LIBS_10)$(__DEBUGRUNTIME_4) /DWIN32 \
|
||||
$(__DEBUGINFO_0) /Fd$(OBJS)\uMod_GUI.pdb $(____DEBUGRUNTIME_3_p) \
|
||||
$(__OPTIMIZEFLAG_6) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \
|
||||
$(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) \
|
||||
$(__MSLU_DEFINE_p) /I$(SETUPHDIR) /I$(WX_DIR)\include \
|
||||
$(____CAIRO_INCLUDEDIR_FILENAMES_p) /W4 /I. $(__DLLFLAG_p) /D_WINDOWS \
|
||||
/DNOPCH $(__RTTIFLAG_11) $(__EXCEPTIONSFLAG_12) \
|
||||
$(CPPFLAGS) $(CXXFLAGS)
|
||||
MINIMAL_OBJECTS = \
|
||||
$(OBJS)\unzip.obj \
|
||||
$(OBJS)\uMod_DirectInjection.obj \
|
||||
$(OBJS)\uMod_GUI.obj \
|
||||
$(OBJS)\uMod_GameInfo.obj \
|
||||
$(OBJS)\uMod_GamePage.obj \
|
||||
$(OBJS)\uMod_Server.obj \
|
||||
$(OBJS)\uMod_Client.obj \
|
||||
$(OBJS)\uMod_File.obj \
|
||||
$(OBJS)\uMod_Sender.obj \
|
||||
$(OBJS)\uMod_Settings.obj \
|
||||
$(OBJS)\uMod_AddTexture.obj \
|
||||
$(OBJS)\uMod_Language.obj
|
||||
MINIMAL_RESOURCES = \
|
||||
$(OBJS)\uMod_GUI.res
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
!if "$(USE_GUI)" == "0"
|
||||
PORTNAME = base
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
PORTNAME = msw
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
WXDEBUGFLAG = d
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
WXDEBUGFLAG = d
|
||||
!endif
|
||||
!if "$(UNICODE)" == "1"
|
||||
WXUNICODEFLAG = u
|
||||
!endif
|
||||
!if "$(WXUNIV)" == "1"
|
||||
WXUNIVNAME = univ
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "AMD64"
|
||||
DIR_SUFFIX_CPU = _amd64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "IA64"
|
||||
DIR_SUFFIX_CPU = _ia64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "amd64"
|
||||
DIR_SUFFIX_CPU = _amd64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ia64"
|
||||
DIR_SUFFIX_CPU = _ia64
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
WXDLLFLAG = dll
|
||||
!endif
|
||||
!if "$(SHARED)" == "0"
|
||||
LIBTYPE_SUFFIX = lib
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
LIBTYPE_SUFFIX = dll
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "AMD64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "IA64"
|
||||
LINK_TARGET_CPU = /MACHINE:IA64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "amd64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ia64"
|
||||
LINK_TARGET_CPU = /MACHINE:IA64
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
EXTRALIBS_FOR_BASE =
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1"
|
||||
EXTRALIBS_FOR_BASE =
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_0 = /Zi
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_0 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_0 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_0 = /Zi
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_1 = /DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_1 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_1 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_1 = /DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_2 = $(__DEBUGRUNTIME_5)
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_2 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_2 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_2 = $(__DEBUGRUNTIME_5)
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME_3_p = /D_DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME_3_p =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
____DEBUGRUNTIME_3_p =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
____DEBUGRUNTIME_3_p = /D_DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME_3_p_1 = /d _DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME_3_p_1 =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
____DEBUGRUNTIME_3_p_1 =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
____DEBUGRUNTIME_3_p_1 = /d _DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME_4 = d
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME_4 =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__DEBUGRUNTIME_4 =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
__DEBUGRUNTIME_4 = d
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME_5 =
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME_5 = /opt:ref /opt:icf
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__DEBUGRUNTIME_5 = /opt:ref /opt:icf
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
__DEBUGRUNTIME_5 =
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug"
|
||||
__OPTIMIZEFLAG_6 = /Od
|
||||
!endif
|
||||
!if "$(BUILD)" == "release"
|
||||
__OPTIMIZEFLAG_6 = /O2
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "0"
|
||||
__THREADSFLAG_9 = L
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "1"
|
||||
__THREADSFLAG_9 = T
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "dynamic"
|
||||
__RUNTIME_LIBS_10 = D
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "static"
|
||||
__RUNTIME_LIBS_10 = $(__THREADSFLAG_9)
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "0"
|
||||
__RTTIFLAG_11 =
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "1"
|
||||
__RTTIFLAG_11 = /GR
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "0"
|
||||
__EXCEPTIONSFLAG_12 =
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "1"
|
||||
__EXCEPTIONSFLAG_12 = /EHsc
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
|
||||
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NO_VC_CRTDBG_p_1 = /d __NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
|
||||
__NO_VC_CRTDBG_p_1 = /d __NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(WXUNIV)" == "1"
|
||||
__WXUNIV_DEFINE_p = /D__WXUNIVERSAL__
|
||||
!endif
|
||||
!if "$(WXUNIV)" == "1"
|
||||
__WXUNIV_DEFINE_p_1 = /d __WXUNIVERSAL__
|
||||
!endif
|
||||
!if "$(DEBUG_FLAG)" == "0"
|
||||
__DEBUG_DEFINE_p = /DwxDEBUG_LEVEL=0
|
||||
!endif
|
||||
!if "$(DEBUG_FLAG)" == "0"
|
||||
__DEBUG_DEFINE_p_1 = /d wxDEBUG_LEVEL=0
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__NDEBUG_DEFINE_p = /DNDEBUG
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NDEBUG_DEFINE_p = /DNDEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__NDEBUG_DEFINE_p_1 = /d NDEBUG
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NDEBUG_DEFINE_p_1 = /d NDEBUG
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "0"
|
||||
__EXCEPTIONS_DEFINE_p = /DwxNO_EXCEPTIONS
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "0"
|
||||
__EXCEPTIONS_DEFINE_p_1 = /d wxNO_EXCEPTIONS
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "0"
|
||||
__RTTI_DEFINE_p = /DwxNO_RTTI
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "0"
|
||||
__RTTI_DEFINE_p_1 = /d wxNO_RTTI
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "0"
|
||||
__THREAD_DEFINE_p = /DwxNO_THREADS
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "0"
|
||||
__THREAD_DEFINE_p_1 = /d wxNO_THREADS
|
||||
!endif
|
||||
!if "$(UNICODE)" == "0"
|
||||
__UNICODE_DEFINE_p = /DwxUSE_UNICODE=0
|
||||
!endif
|
||||
!if "$(UNICODE)" == "1"
|
||||
__UNICODE_DEFINE_p = /D_UNICODE
|
||||
!endif
|
||||
!if "$(UNICODE)" == "0"
|
||||
__UNICODE_DEFINE_p_1 = /d wxUSE_UNICODE=0
|
||||
!endif
|
||||
!if "$(UNICODE)" == "1"
|
||||
__UNICODE_DEFINE_p_1 = /d _UNICODE
|
||||
!endif
|
||||
!if "$(MSLU)" == "1"
|
||||
__MSLU_DEFINE_p = /DwxUSE_UNICODE_MSLU=1
|
||||
!endif
|
||||
!if "$(MSLU)" == "1"
|
||||
__MSLU_DEFINE_p_1 = /d wxUSE_UNICODE_MSLU=1
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
____CAIRO_INCLUDEDIR_FILENAMES_p = /I$(CAIRO_ROOT)\include\cairo
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
____CAIRO_INCLUDEDIR_FILENAMES_1_p = /i $(CAIRO_ROOT)\include\cairo
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
__DLLFLAG_p = /DWXUSINGDLL
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
__DLLFLAG_p_1 = /d WXUSINGDLL
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
__WXLIB_CORE_p = \
|
||||
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core.lib
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
__WXLIB_BASE_p = \
|
||||
wxbase$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1"
|
||||
__WXLIB_MONO_p = \
|
||||
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_TIFF_p = wxtiff$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_JPEG_p = wxjpeg$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_PNG_p = wxpng$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(MSLU)" == "1"
|
||||
__UNICOWS_LIB_p = unicows.lib
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
__CAIRO_LIB_p = cairo.lib
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
____CAIRO_LIBDIR_FILENAMES_p = /LIBPATH:$(CAIRO_ROOT)\lib
|
||||
!endif
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
$(OBJS):
|
||||
-if not exist $(OBJS) mkdir $(OBJS)
|
||||
|
||||
### Targets: ###
|
||||
|
||||
all: $(OBJS_exe)\uMod.exe
|
||||
|
||||
clean:
|
||||
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
|
||||
-if exist $(OBJS)\*.res del $(OBJS)\*.res
|
||||
-if exist $(OBJS)\*.pch del $(OBJS)\*.pch
|
||||
-if exist $(OBJS_exe)\uMod_GUI.exe del $(OBJS_exe)\uMod.exe
|
||||
-if exist $(OBJS_exe)\uMod_GUI.ilk del $(OBJS_exe)\uMod_GUI.ilk
|
||||
-if exist $(OBJS_exe)\uMod_GUI.pdb del $(OBJS_exe)\uMod_GUI.pdb
|
||||
|
||||
$(OBJS_exe)\uMod.exe: $(MINIMAL_OBJECTS) $(OBJS)\uMod_GUI.res
|
||||
link /NOLOGO /OUT:$@ $(__DEBUGINFO_1) /pdb:"$(OBJS)\uMod_GUI.pdb" $(__DEBUGINFO_2) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) /SUBSYSTEM:WINDOWS $(____CAIRO_LIBDIR_FILENAMES_p) $(LDFLAGS) @<<
|
||||
$(MINIMAL_OBJECTS) $(MINIMAL_RESOURCES) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib
|
||||
<<
|
||||
|
||||
$(OBJS)\uMod_GUI.res: uMod.rc
|
||||
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_3_p_1) $(__NO_VC_CRTDBG_p_1) /d __WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) $(__MSLU_DEFINE_p_1) /i $(SETUPHDIR) /i . $(__DLLFLAG_p_1) /d _WINDOWS /d NOPCH uMod.rc
|
||||
|
||||
#$(OBJS)\display_display.obj: .\display.cpp
|
||||
# $(CXX) /c /nologo /TP /Fo$@ $(DISPLAY_CXXFLAGS) .\display.cpp
|
||||
|
||||
$(OBJS)\unzip.obj: .\unzip.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\unzip.cpp
|
||||
|
||||
$(OBJS)\uMod_DirectInjection.obj: .\uMod_DirectInjection.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_DirectInjection.cpp
|
||||
|
||||
$(OBJS)\uMod_GUI.obj: .\uMod_GUI.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_GUI.cpp
|
||||
|
||||
$(OBJS)\uMod_GameInfo.obj: .\uMod_GameInfo.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_GameInfo.cpp
|
||||
|
||||
$(OBJS)\uMod_GamePage.obj: .\uMod_GamePage.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_GamePage.cpp
|
||||
|
||||
$(OBJS)\uMod_Server.obj: .\uMod_Server.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Server.cpp
|
||||
|
||||
$(OBJS)\uMod_Client.obj: .\uMod_Client.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Client.cpp
|
||||
|
||||
$(OBJS)\uMod_File.obj: .\uMod_File.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_File.cpp
|
||||
|
||||
$(OBJS)\uMod_Sender.obj: .\uMod_Sender.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Sender.cpp
|
||||
|
||||
$(OBJS)\uMod_Settings.obj: .\uMod_Settings.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Settings.cpp
|
||||
|
||||
$(OBJS)\uMod_AddTexture.obj: .\uMod_AddTexture.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_AddTexture.cpp
|
||||
|
||||
$(OBJS)\uMod_Language.obj: .\uMod_Language.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Language.cpp
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
@@ -1 +0,0 @@
|
||||
MAINICON ICON "uMod.ico"
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
AddTextureClass::AddTextureClass(void)
|
||||
{
|
||||
Num = 0;
|
||||
Textures = NULL;
|
||||
Size = NULL;
|
||||
Hash = NULL;
|
||||
WasAdded = NULL;
|
||||
Len=0;
|
||||
|
||||
Add = false;
|
||||
Force = false;
|
||||
Loaded = false;
|
||||
OwnMemory = false;
|
||||
}
|
||||
|
||||
AddTextureClass::~AddTextureClass(void)
|
||||
{
|
||||
ReleaseMemory();
|
||||
}
|
||||
|
||||
int AddTextureClass::ReleaseMemory(void)
|
||||
{
|
||||
if (OwnMemory)
|
||||
{
|
||||
if (Size!=NULL) delete [] Size;
|
||||
if (Hash!=NULL) delete [] Hash;
|
||||
if (WasAdded!=NULL) delete [] WasAdded;
|
||||
|
||||
|
||||
if (Textures!=NULL)
|
||||
{
|
||||
for (unsigned int i=0; i<Num && i<Len; i++) if (Textures[i]!=NULL) delete [] Textures[i];
|
||||
delete [] Textures;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AddTextureClass::SetSize(int num)
|
||||
{
|
||||
Num = 0;
|
||||
if (GetMemory( Size, num, 0u)) return -1;
|
||||
if (GetMemory( Hash, num)) return -1;
|
||||
if (GetMemory( WasAdded, num, false)) return -1;
|
||||
if (GetMemory( Textures, num, (char*)0)) return -1;
|
||||
|
||||
OwnMemory = true;
|
||||
Len = num;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AddTextureClass::InheriteMemory(AddTextureClass &tex)
|
||||
{
|
||||
if (!tex.OwnMemory)
|
||||
{
|
||||
if (SetSize(tex.Len)) return -1;
|
||||
for (unsigned int i=0u; i<tex.Len; i++) Hash[i] = tex.Hash[i];
|
||||
for (unsigned int i=0u; i<tex.Len; i++) WasAdded[i] = tex.WasAdded[i];
|
||||
for (unsigned int i=0u; i<tex.Len; i++) Size[i] = tex.Size[i];
|
||||
for (unsigned int i=0u; i<tex.Num; i++) if (tex.Textures[i]!=NULL && tex.Size[i]>0)
|
||||
{
|
||||
if (GetMemory( Textures[i], tex.Size[i])) return -1;
|
||||
for (unsigned int j=0u; j<tex.Size[i]; j++) Textures[i][j] = tex.Textures[i][j];
|
||||
Size[i] = tex.Size[i];
|
||||
}
|
||||
Len = tex.Len;
|
||||
Num = tex.Num;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseMemory();
|
||||
Hash = tex.Hash;
|
||||
WasAdded = tex.WasAdded;
|
||||
Size = tex.Size;
|
||||
Textures = tex.Textures;
|
||||
Len = tex.Len;
|
||||
Num = tex.Num;
|
||||
OwnMemory = true;
|
||||
tex.OwnMemory = false;
|
||||
}
|
||||
Add = tex.Add;
|
||||
Force = tex.Force;
|
||||
Loaded = tex.Loaded;
|
||||
|
||||
File = tex.File;
|
||||
Comment = tex.Comment;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_ADDTEXTURE_H_
|
||||
#define uMod_ADDTEXTURE_H_
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
class AddTextureClass
|
||||
{
|
||||
public:
|
||||
AddTextureClass(void);
|
||||
~AddTextureClass(void);
|
||||
int ReleaseMemory(void);
|
||||
|
||||
int SetSize(int num);
|
||||
int InheriteMemory(AddTextureClass &tex);
|
||||
|
||||
unsigned int Num;
|
||||
char **Textures;
|
||||
unsigned int *Size;
|
||||
unsigned long *Hash;
|
||||
bool *WasAdded;
|
||||
unsigned int Len;
|
||||
|
||||
bool Add;
|
||||
bool Force;
|
||||
bool Loaded;
|
||||
bool OwnMemory;
|
||||
wxString File;
|
||||
wxString Comment;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_ADDTEXTURE_H_ */
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
uMod_Client::uMod_Client( PipeStruct &pipe, uMod_Frame *frame) : wxThread(wxTHREAD_JOINABLE)
|
||||
{
|
||||
Pipe.In = pipe.In;
|
||||
Pipe.Out = pipe.Out;
|
||||
MainFrame = frame;
|
||||
}
|
||||
|
||||
uMod_Client::~uMod_Client(void)
|
||||
{
|
||||
if (Pipe.Out != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DisconnectNamedPipe(Pipe.Out);
|
||||
CloseHandle(Pipe.Out);
|
||||
Pipe.Out = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if (Pipe.In != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DisconnectNamedPipe(Pipe.In);
|
||||
CloseHandle(Pipe.In);
|
||||
Pipe.In = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
void* uMod_Client::Entry(void)
|
||||
{
|
||||
char buffer[SMALL_BUFSIZE];
|
||||
while (1)
|
||||
{
|
||||
unsigned long size;
|
||||
bool ret = ReadFile(
|
||||
Pipe.In, // handle to pipe
|
||||
buffer, // buffer to receive data
|
||||
SMALL_BUFSIZE, // size of buffer
|
||||
&size, // number of bytes read
|
||||
NULL); // not overlapped I/O
|
||||
|
||||
if (ret || GetLastError()==ERROR_MORE_DATA)
|
||||
{
|
||||
unsigned int pos=0;
|
||||
MsgStruct *commands;
|
||||
bool update_textures = false;
|
||||
while (pos<size-sizeof(MsgStruct))
|
||||
{
|
||||
commands = (MsgStruct*) &buffer[pos];
|
||||
//unsigned int add_length = 0;
|
||||
/*
|
||||
switch (commands->Control)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
pos+=sizeof(MsgStruct);// + add_length;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
CloseHandle(Pipe.In);
|
||||
Pipe.In = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(Pipe.Out);
|
||||
Pipe.Out = INVALID_HANDLE_VALUE;
|
||||
|
||||
uMod_Event event( uMod_EVENT_TYPE, ID_Delete_Game);
|
||||
event.SetClient(this);
|
||||
wxPostEvent( MainFrame, event);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_CLIENT_H_
|
||||
#define uMod_CLIENT_H_
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
// an object of this class is created for each running game
|
||||
// it reads out of the incoming pipe (it must run as thread)
|
||||
// if the pipe is closed (Game is canceled) it send a messeage to the main thread
|
||||
// it should read the error state from the dll, but this is not yet implemented
|
||||
class uMod_Client : public wxThread
|
||||
{
|
||||
public:
|
||||
uMod_Client( PipeStruct &pipe, uMod_Frame *frame);
|
||||
virtual ~uMod_Client(void);
|
||||
|
||||
void* Entry(void);
|
||||
|
||||
|
||||
PipeStruct Pipe;
|
||||
|
||||
private:
|
||||
uMod_Frame *MainFrame;
|
||||
};
|
||||
|
||||
#endif /* uMod_CLIENT_H_ */
|
||||
@@ -1,519 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Drew_Benton
|
||||
* http://www.codeproject.com/KB/threads/completeinject.aspx
|
||||
*
|
||||
*/
|
||||
|
||||
#include "uMod_Main.h"
|
||||
/***************************************************************************************************/
|
||||
// Function:
|
||||
// Inject
|
||||
//
|
||||
// Parameters:
|
||||
// HANDLE hProcess - The handle to the process to inject the DLL into.
|
||||
//
|
||||
// const char* dllname - The name of the DLL to inject into the process.
|
||||
//
|
||||
// const char* funcname - The name of the function to call once the DLL has been injected.
|
||||
//
|
||||
// Description:
|
||||
// This function will inject a DLL into a process and execute an exported function
|
||||
// from the DLL to "initialize" it. The function should be in the format shown below,
|
||||
// not parameters and no return type. Do not forget to prefix extern "C" if you are in C++
|
||||
//
|
||||
// __declspec(dllexport) void FunctionName(void)
|
||||
//
|
||||
// The function that is called in the injected DLL
|
||||
// -MUST- return, the loader waits for the thread to terminate before removing the
|
||||
// allocated space and returning control to the Loader. This method of DLL injection
|
||||
// also adds error handling, so the end user knows if something went wrong.
|
||||
/***************************************************************************************************/
|
||||
|
||||
void Inject(HANDLE hProcess, const wchar_t* dllname, const char* funcname)
|
||||
{
|
||||
//------------------------------------------//
|
||||
// Function variables. //
|
||||
//------------------------------------------//
|
||||
|
||||
// Main DLL we will need to load
|
||||
HMODULE kernel32 = NULL;
|
||||
|
||||
// Main functions we will need to import
|
||||
FARPROC loadlibrary = NULL;
|
||||
FARPROC getprocaddress = NULL;
|
||||
FARPROC exitprocess = NULL;
|
||||
FARPROC exitthread = NULL;
|
||||
FARPROC freelibraryandexitthread = NULL;
|
||||
|
||||
// The workspace we will build the codecave on locally
|
||||
LPBYTE workspace = NULL;
|
||||
DWORD workspaceIndex = 0;
|
||||
|
||||
// The memory in the process we write to
|
||||
LPVOID codecaveAddress = NULL;
|
||||
DWORD dwCodecaveAddress = 0;
|
||||
|
||||
// Strings we have to write into the process
|
||||
char injectDllName[MAX_PATH + 1] = {0};
|
||||
char injectFuncName[MAX_PATH + 1] = {0};
|
||||
char injectError0[MAX_PATH + 1] = {0};
|
||||
char injectError1[MAX_PATH + 1] = {0};
|
||||
char injectError2[MAX_PATH + 1] = {0};
|
||||
char user32Name[MAX_PATH + 1] = {0};
|
||||
char msgboxName[MAX_PATH + 1] = {0};
|
||||
|
||||
// Placeholder addresses to use the strings
|
||||
DWORD user32NameAddr = 0;
|
||||
DWORD user32Addr = 0;
|
||||
DWORD msgboxNameAddr = 0;
|
||||
DWORD msgboxAddr = 0;
|
||||
DWORD dllAddr = 0;
|
||||
DWORD dllNameAddr = 0;
|
||||
DWORD funcNameAddr = 0;
|
||||
DWORD error0Addr = 0;
|
||||
DWORD error1Addr = 0;
|
||||
DWORD error2Addr = 0;
|
||||
|
||||
// Where the codecave execution should begin at
|
||||
DWORD codecaveExecAddr = 0;
|
||||
|
||||
// Handle to the thread we create in the process
|
||||
HANDLE hThread = NULL;
|
||||
|
||||
// Temp variables
|
||||
DWORD dwTmpSize = 0;
|
||||
|
||||
// Old protection on page we are writing to in the process and the bytes written
|
||||
DWORD oldProtect = 0;
|
||||
DWORD bytesRet = 0;
|
||||
|
||||
//------------------------------------------//
|
||||
// Variable initialization. //
|
||||
//------------------------------------------//
|
||||
|
||||
// Get the address of the main DLL
|
||||
kernel32 = LoadLibraryW(L"kernel32.dll");
|
||||
|
||||
// Get our functions
|
||||
loadlibrary = GetProcAddress(kernel32, "LoadLibraryA");
|
||||
getprocaddress = GetProcAddress(kernel32, "GetProcAddress");
|
||||
exitprocess = GetProcAddress(kernel32, "ExitProcess");
|
||||
exitthread = GetProcAddress(kernel32, "ExitThread");
|
||||
freelibraryandexitthread = GetProcAddress(kernel32, "FreeLibraryAndExitThread");
|
||||
|
||||
// This section will cause compiler warnings on VS8,
|
||||
// you can upgrade the functions or ignore them
|
||||
|
||||
// Build names
|
||||
_snprintf(injectDllName, MAX_PATH, "%ls", dllname);
|
||||
_snprintf(injectFuncName, MAX_PATH, "%s", funcname);
|
||||
_snprintf(user32Name, MAX_PATH, "user32.dll");
|
||||
_snprintf(msgboxName, MAX_PATH, "MessageBoxA");
|
||||
|
||||
// Build error messages
|
||||
_snprintf(injectError0, MAX_PATH, "Error");
|
||||
_snprintf(injectError1, MAX_PATH, "Could not load the dll: %s", injectDllName);
|
||||
_snprintf(injectError2, MAX_PATH, "Could not load the function: %s", injectFuncName);
|
||||
|
||||
// Create the workspace
|
||||
workspace = (LPBYTE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1024);
|
||||
|
||||
// Allocate space for the codecave in the process
|
||||
codecaveAddress = VirtualAllocEx(hProcess, 0, 1024, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
dwCodecaveAddress = PtrToUlong(codecaveAddress);
|
||||
|
||||
// Note there is no error checking done above for any functions that return a pointer/handle.
|
||||
// I could have added them, but it'd just add more messiness to the code and not provide any real
|
||||
// benefit. It's up to you though in your final code if you want it there or not.
|
||||
|
||||
//------------------------------------------//
|
||||
// Data and string writing. //
|
||||
//------------------------------------------//
|
||||
|
||||
// Write out the address for the user32 dll address
|
||||
user32Addr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = 0;
|
||||
memcpy(workspace + workspaceIndex, &dwTmpSize, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Write out the address for the MessageBoxA address
|
||||
msgboxAddr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = 0;
|
||||
memcpy(workspace + workspaceIndex, &dwTmpSize, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Write out the address for the injected DLL's module
|
||||
dllAddr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = 0;
|
||||
memcpy(workspace + workspaceIndex, &dwTmpSize, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// User32 Dll Name
|
||||
user32NameAddr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(user32Name) + 1;
|
||||
memcpy(workspace + workspaceIndex, user32Name, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
// MessageBoxA name
|
||||
msgboxNameAddr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(msgboxName) + 1;
|
||||
memcpy(workspace + workspaceIndex, msgboxName, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
// Dll Name
|
||||
dllNameAddr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(injectDllName) + 1;
|
||||
memcpy(workspace + workspaceIndex, injectDllName, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
// Function Name
|
||||
funcNameAddr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(injectFuncName) + 1;
|
||||
memcpy(workspace + workspaceIndex, injectFuncName, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
// Error Message 1
|
||||
error0Addr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(injectError0) + 1;
|
||||
memcpy(workspace + workspaceIndex, injectError0, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
// Error Message 2
|
||||
error1Addr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(injectError1) + 1;
|
||||
memcpy(workspace + workspaceIndex, injectError1, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
|
||||
// Error Message 3
|
||||
error2Addr = workspaceIndex + dwCodecaveAddress;
|
||||
dwTmpSize = (DWORD)strlen(injectError2) + 1;
|
||||
memcpy(workspace + workspaceIndex, injectError2, dwTmpSize);
|
||||
workspaceIndex += dwTmpSize;
|
||||
|
||||
// Pad a few INT3s after string data is written for seperation
|
||||
workspace[workspaceIndex++] = 0xCC;
|
||||
workspace[workspaceIndex++] = 0xCC;
|
||||
workspace[workspaceIndex++] = 0xCC;
|
||||
|
||||
// Store where the codecave execution should begin
|
||||
codecaveExecAddr = workspaceIndex + dwCodecaveAddress;
|
||||
|
||||
// For debugging - infinite loop, attach onto process and step over
|
||||
//workspace[workspaceIndex++] = 0xEB;
|
||||
//workspace[workspaceIndex++] = 0xFE;
|
||||
|
||||
//------------------------------------------//
|
||||
// User32.dll loading. //
|
||||
//------------------------------------------//
|
||||
|
||||
// User32 DLL Loading
|
||||
// PUSH 0x00000000 - Push the address of the DLL name to use in LoadLibraryA
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &user32NameAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of LoadLibraryA into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &loadlibrary, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call LoadLibraryA
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// MessageBoxA Loading
|
||||
// PUSH 0x000000 - Push the address of the function name to load
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &msgboxNameAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Push EAX, module to use in GetProcAddress
|
||||
workspace[workspaceIndex++] = 0x50;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of GetProcAddress into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &getprocaddress, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call GetProcAddress
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// MOV [ADDRESS], EAX - Save the address to our variable
|
||||
workspace[workspaceIndex++] = 0xA3;
|
||||
memcpy(workspace + workspaceIndex, &msgboxAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
//------------------------------------------//
|
||||
// Injected dll loading. //
|
||||
//------------------------------------------//
|
||||
|
||||
/*
|
||||
// This is the way the following assembly code would look like in C/C++
|
||||
|
||||
// Load the injected DLL into this process
|
||||
HMODULE h = LoadLibrary("mydll.dll");
|
||||
if(!h)
|
||||
{
|
||||
MessageBox(0, "Could not load the dll: mydll.dll", "Error", MB_ICONERROR);
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
// Get the address of the export function
|
||||
FARPROC p = GetProcAddress(h, "Initialize");
|
||||
if(!p)
|
||||
{
|
||||
MessageBox(0, "Could not load the function: Initialize", "Error", MB_ICONERROR);
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
// So we do not need a function pointer interface
|
||||
__asm call p
|
||||
|
||||
// Exit the thread so the loader continues
|
||||
ExitThread(0);
|
||||
*/
|
||||
|
||||
// DLL Loading
|
||||
// PUSH 0x00000000 - Push the address of the DLL name to use in LoadLibraryA
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &dllNameAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of LoadLibraryA into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &loadlibrary, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call LoadLibraryA
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// Error Checking
|
||||
// CMP EAX, 0
|
||||
workspace[workspaceIndex++] = 0x83;
|
||||
workspace[workspaceIndex++] = 0xF8;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// JNZ EIP + 0x1E to skip over eror code
|
||||
workspace[workspaceIndex++] = 0x75;
|
||||
workspace[workspaceIndex++] = 0x1E;
|
||||
|
||||
// Error Code 1
|
||||
// MessageBox
|
||||
// PUSH 0x10 (MB_ICONHAND)
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x10;
|
||||
|
||||
// PUSH 0x000000 - Push the address of the MessageBox title
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &error0Addr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// PUSH 0x000000 - Push the address of the MessageBox message
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &error1Addr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Push 0
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// MOV EAX, [ADDRESS] - Move the address of MessageBoxA into EAX
|
||||
workspace[workspaceIndex++] = 0xA1;
|
||||
memcpy(workspace + workspaceIndex, &msgboxAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call MessageBoxA
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// ExitProcess
|
||||
// Push 0
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of ExitProcess into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &exitprocess, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call MessageBoxA
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// Now we have the address of the injected DLL, so save the handle
|
||||
|
||||
// MOV [ADDRESS], EAX - Save the address to our variable
|
||||
workspace[workspaceIndex++] = 0xA3;
|
||||
memcpy(workspace + workspaceIndex, &dllAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Load the initilize function from it
|
||||
|
||||
// PUSH 0x000000 - Push the address of the function name to load
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &funcNameAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Push EAX, module to use in GetProcAddress
|
||||
workspace[workspaceIndex++] = 0x50;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of GetProcAddress into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &getprocaddress, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call GetProcAddress
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// Error Checking
|
||||
// CMP EAX, 0
|
||||
workspace[workspaceIndex++] = 0x83;
|
||||
workspace[workspaceIndex++] = 0xF8;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// JNZ EIP + 0x1C to skip eror code
|
||||
workspace[workspaceIndex++] = 0x75;
|
||||
workspace[workspaceIndex++] = 0x1C;
|
||||
|
||||
// Error Code 2
|
||||
// MessageBox
|
||||
// PUSH 0x10 (MB_ICONHAND)
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x10;
|
||||
|
||||
// PUSH 0x000000 - Push the address of the MessageBox title
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &error0Addr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// PUSH 0x000000 - Push the address of the MessageBox message
|
||||
workspace[workspaceIndex++] = 0x68;
|
||||
memcpy(workspace + workspaceIndex, &error2Addr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Push 0
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of MessageBoxA into EAX
|
||||
workspace[workspaceIndex++] = 0xA1;
|
||||
memcpy(workspace + workspaceIndex, &msgboxAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call MessageBoxA
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// ExitProcess
|
||||
// Push 0
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of ExitProcess into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &exitprocess, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// Now that we have the address of the function, we cam call it,
|
||||
// if there was an error, the messagebox would be called as well.
|
||||
|
||||
// CALL EAX - Call ExitProcess -or- the Initialize function
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
|
||||
// If we get here, the Initialize function has been called,
|
||||
// so it's time to close this thread and optionally unload the DLL.
|
||||
|
||||
//------------------------------------------//
|
||||
// Exiting from the injected dll. //
|
||||
//------------------------------------------//
|
||||
|
||||
// Call ExitThread to leave the DLL loaded
|
||||
#if 1
|
||||
// Push 0 (exit code)
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of ExitThread into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &exitthread, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call ExitThread
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
#endif
|
||||
|
||||
// Call FreeLibraryAndExitThread to unload DLL
|
||||
#if 0
|
||||
// Push 0 (exit code)
|
||||
workspace[workspaceIndex++] = 0x6A;
|
||||
workspace[workspaceIndex++] = 0x00;
|
||||
|
||||
// PUSH [0x000000] - Push the address of the DLL module to unload
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0x35;
|
||||
memcpy(workspace + workspaceIndex, &dllAddr, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// MOV EAX, ADDRESS - Move the address of FreeLibraryAndExitThread into EAX
|
||||
workspace[workspaceIndex++] = 0xB8;
|
||||
memcpy(workspace + workspaceIndex, &freelibraryandexitthread, 4);
|
||||
workspaceIndex += 4;
|
||||
|
||||
// CALL EAX - Call FreeLibraryAndExitThread
|
||||
workspace[workspaceIndex++] = 0xFF;
|
||||
workspace[workspaceIndex++] = 0xD0;
|
||||
#endif
|
||||
|
||||
//------------------------------------------//
|
||||
// Code injection and cleanup. //
|
||||
//------------------------------------------//
|
||||
|
||||
// Change page protection so we can write executable code
|
||||
VirtualProtectEx(hProcess, codecaveAddress, workspaceIndex, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
|
||||
// Write out the patch
|
||||
WriteProcessMemory(hProcess, codecaveAddress, workspace, workspaceIndex, &bytesRet);
|
||||
|
||||
// Restore page protection
|
||||
VirtualProtectEx(hProcess, codecaveAddress, workspaceIndex, oldProtect, &oldProtect);
|
||||
|
||||
// Make sure our changes are written right away
|
||||
FlushInstructionCache(hProcess, codecaveAddress, workspaceIndex);
|
||||
|
||||
// Free the workspace memory
|
||||
HeapFree(GetProcessHeap(), 0, workspace);
|
||||
|
||||
// Execute the thread now and wait for it to exit, note we execute where the code starts, and not the codecave start
|
||||
// (since we wrote strings at the start of the codecave) -- NOTE: void* used for VC6 compatibility instead of UlongToPtr
|
||||
hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)((void*)codecaveExecAddr), 0, 0, NULL);
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
|
||||
// Free the memory in the process that we allocated
|
||||
VirtualFreeEx(hProcess, codecaveAddress, 0, MEM_RELEASE);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_INJECTDIRECTLY_H_
|
||||
#define uMod_INJECTDIRECTLY_H_
|
||||
|
||||
|
||||
|
||||
void Inject(HANDLE hProcess, const wchar_t* dllname, const char* funcname);
|
||||
|
||||
#endif /* uMod_INJECTDIRECTLY_H_ */
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_EVENTTYPE_H_
|
||||
#define uMod_EVENTTYPE_H_
|
||||
#include "uMod_Client.h"
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
//we need our own event to pass send some arguments from the server or the client thread to the main thread
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE( uMod_EVENT_TYPE, -1)
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
class uMod_Event : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
uMod_Event( wxEventType commandType = uMod_EVENT_TYPE, int id = 0 )
|
||||
: wxCommandEvent(commandType, id) { }
|
||||
virtual ~uMod_Event(void) {}
|
||||
|
||||
// You *must* copy here the data to be transported
|
||||
uMod_Event( const uMod_Event &event )
|
||||
: wxCommandEvent(event) { this->SetText( event.GetText()); PipeIn=((uMod_Event&)event).GetPipeIn(); PipeOut=((uMod_Event&)event).GetPipeOut(); Name=((uMod_Event&)event).GetName(); Client=((uMod_Event&)event).GetClient();}
|
||||
|
||||
// Required for sending with wxPostEvent()
|
||||
wxEvent* Clone() const { return new uMod_Event(*this); }
|
||||
|
||||
wxString GetText() const { return m_Text; }
|
||||
void SetText( const wxString& text ) { m_Text = text; }
|
||||
|
||||
wxString GetName(void) {return Name;}
|
||||
HANDLE GetPipeIn(void) {return PipeIn;}
|
||||
HANDLE GetPipeOut(void) {return PipeOut;}
|
||||
uMod_Client * GetClient(void) {return Client;}
|
||||
|
||||
void SetName( wxString name) {Name=name;}
|
||||
void SetPipeIn( HANDLE pipe) {PipeIn=pipe;}
|
||||
void SetPipeOut( HANDLE pipe) {PipeOut=pipe;}
|
||||
void SetClient( uMod_Client *client) {Client=client;}
|
||||
|
||||
private:
|
||||
|
||||
wxString Name;
|
||||
HANDLE PipeIn;
|
||||
HANDLE PipeOut;
|
||||
uMod_Client *Client;
|
||||
|
||||
wxString m_Text;
|
||||
};
|
||||
|
||||
|
||||
#endif /* uMod_EVENTTYPE_H_ */
|
||||
@@ -1,441 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "uMod_Main.h"
|
||||
#include "unzip.h"
|
||||
|
||||
|
||||
uMod_File::uMod_File(void)
|
||||
{
|
||||
Loaded=false;
|
||||
XORed=false;
|
||||
FileInMemory=NULL;
|
||||
MemoryLength=0u;
|
||||
FileLen=0u;
|
||||
}
|
||||
|
||||
uMod_File::uMod_File(const wxString &file)
|
||||
{
|
||||
Loaded=false;
|
||||
XORed=false;
|
||||
FileInMemory=NULL;
|
||||
MemoryLength=0u;
|
||||
FileLen=0u;
|
||||
SetFile(file);
|
||||
}
|
||||
|
||||
|
||||
uMod_File::~uMod_File(void)
|
||||
{
|
||||
if (FileInMemory!=NULL) delete [] FileInMemory;
|
||||
}
|
||||
|
||||
|
||||
bool uMod_File::FileSupported(void)
|
||||
{
|
||||
wxString file_type = FileName.AfterLast( '.');
|
||||
if (file_type == L"zip") return true;
|
||||
else if (file_type == L"tpf") return true;
|
||||
else if (file_type == L"dds") return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int uMod_File::GetComment( wxString &tool_tip)
|
||||
{
|
||||
wxString file_type = FileName.AfterLast( '.');
|
||||
if (file_type == L"zip")
|
||||
{
|
||||
if (int ret = GetCommentZip( tool_tip)) return ret;
|
||||
}
|
||||
else if (file_type == L"tpf")
|
||||
{
|
||||
if (int ret = GetCommentTpf( tool_tip)) return ret;
|
||||
}
|
||||
else if (file_type == L"dds")
|
||||
{
|
||||
tool_tip = Language->NoComment;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_File::GetContent( AddTextureClass &tex, bool add)
|
||||
{
|
||||
wxString file_type = FileName.AfterLast( '.');
|
||||
if (file_type == L"zip")
|
||||
{
|
||||
AddZip( tex, add, false);
|
||||
}
|
||||
else if (file_type == L"tpf")
|
||||
{
|
||||
AddZip( tex, add, true);
|
||||
}
|
||||
else if (file_type == L"dds")
|
||||
{
|
||||
AddFile( tex, add);
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError << Language->Error_FileNotSupported;
|
||||
LastError << "\n" << FileName;
|
||||
}
|
||||
if (LastError.Len()>0) return -1;
|
||||
else
|
||||
{
|
||||
if (add) tex.Loaded = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int uMod_File::ReadFile(void)
|
||||
{
|
||||
if (Loaded) return 0;
|
||||
XORed=false;
|
||||
|
||||
wxFile dat;
|
||||
if (!dat.Access(FileName, wxFile::read)) {LastError << Language->Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
dat.Open(FileName, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Language->Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
FileLen = dat.Length();
|
||||
if (FileLen==0) {LastError << Language->Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
|
||||
if (FileLen>=MemoryLength)
|
||||
{
|
||||
if (FileInMemory!=NULL) delete [] FileInMemory;
|
||||
try {FileInMemory = new char [FileLen+1];}
|
||||
catch (...) {FileInMemory=NULL; MemoryLength=0; FileLen=0; LastError << Language->Error_Memory; return -1;}
|
||||
MemoryLength = FileLen+1;
|
||||
}
|
||||
unsigned int result = dat.Read( FileInMemory, FileLen);
|
||||
dat.Close();
|
||||
|
||||
if (result != FileLen) {FileLen=0; LastError << Language->Error_FileRead<<"\n" << FileName; return -1;}
|
||||
FileInMemory[FileLen]=0;
|
||||
|
||||
Loaded = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_File::UnXOR(void)
|
||||
{
|
||||
if (XORed) return 0;
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Tonttu
|
||||
* (TPFcreate 1.5)
|
||||
*
|
||||
*/
|
||||
unsigned int *buff = (unsigned int*) FileInMemory;
|
||||
unsigned int TPF_XOR = 0x3FA43FA4u;
|
||||
unsigned int size = FileLen/4u;
|
||||
for (unsigned int i=0; i<size; i++) buff[i] ^= TPF_XOR;
|
||||
for (unsigned int i=size*4u; i<size*4u+FileLen%4u; i++) ((unsigned char*) FileInMemory)[i]^=(unsigned char) TPF_XOR;
|
||||
|
||||
|
||||
unsigned int pos = FileLen-1;
|
||||
while (pos>0u && FileInMemory[pos]) pos--;
|
||||
if (pos>0u && pos<FileLen-1) FileLen = pos+1;
|
||||
XORed = true;
|
||||
|
||||
/*
|
||||
* original code by Tonttu
|
||||
* The last bytes are not revealed correctly
|
||||
unsigned int j=0;
|
||||
while ( j <= result - 4 )
|
||||
{
|
||||
*( unsigned int* )( &buffer[j] ) ^= TPF_XOR;
|
||||
j += 4;
|
||||
}
|
||||
|
||||
while ( j < result )
|
||||
{
|
||||
buffer[j] ^= (unsigned char )( TPF_XOR >> 24 );
|
||||
TPF_XOR <<= 4;
|
||||
j++;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_File::GetCommentZip( wxString &tool_tip)
|
||||
{
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
HZIP ZIP_Handle = OpenZip( FileInMemory, FileLen, NULL);
|
||||
if (ZIP_Handle==NULL) {tool_tip = Language->NoComment; LastError << Language->Error_Unzip; return -1;}
|
||||
|
||||
ZIPENTRY ze;
|
||||
int index;
|
||||
FindZipItem( ZIP_Handle, L"Comment.txt", false, &index, &ze);
|
||||
if (index>=0) //if Comment.txt is present in the zip file
|
||||
{
|
||||
char* comment;
|
||||
int len = ze.unc_size;
|
||||
try {comment=new char[len+1];}
|
||||
catch(...) {tool_tip = Language->NoComment; LastError << Language->Error_Memory; return -1;}
|
||||
ZRESULT zr = UnzipItem( ZIP_Handle, index, comment, len);
|
||||
|
||||
if (zr!=ZR_OK && zr!=ZR_MORE) {delete [] comment; tool_tip = Language->NoComment; LastError << Language->Error_Unzip <<"\nZIP:" << L"Comment.txt"; return -1;}
|
||||
comment[len]=0;
|
||||
tool_tip = comment;
|
||||
delete [] comment;
|
||||
}
|
||||
else tool_tip = Language->NoComment;
|
||||
|
||||
CloseZip(ZIP_Handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_File::GetCommentTpf( wxString &tool_tip)
|
||||
{
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
UnXOR();
|
||||
tool_tip = &FileInMemory[FileLen];
|
||||
tool_tip.Prepend( Language->Author);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int uMod_File::AddFile( AddTextureClass &tex, bool add)
|
||||
{
|
||||
tex.SetSize(1);
|
||||
unsigned long temp_hash;
|
||||
|
||||
wxString name = FileName.AfterLast( '_');
|
||||
name = name.BeforeLast( '.');
|
||||
if (!name.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\n" << FileName << "\n"; return -1;} // return if hash could not be extracted
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
try {tex.Textures[0] = new char[FileLen];}
|
||||
catch (...) {tex.Textures[0]=NULL; LastError << Language->Error_Memory; return -1;}
|
||||
for (unsigned int i=0; i<FileLen; i++) tex.Textures[0][i] = FileInMemory[i];
|
||||
tex.Size[0] = FileLen;
|
||||
}
|
||||
else {tex.Size[0] = 0; tex.Textures[0] = NULL;}
|
||||
|
||||
tex.Num = 1;
|
||||
tex.Hash[0] = temp_hash;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_File::AddZip( AddTextureClass &tex, bool add, bool tpf)
|
||||
{
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
if (tpf)
|
||||
{
|
||||
UnXOR();
|
||||
|
||||
const char pw[] = {0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, 0xA6, 0xBD,
|
||||
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
|
||||
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
|
||||
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
|
||||
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
|
||||
0x46, 0x6F, '\0'};
|
||||
|
||||
return AddContent( pw, tex, add);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AddContent( NULL, tex, add);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int uMod_File::AddContent( const char* pw, AddTextureClass &tex, bool add)
|
||||
{
|
||||
// Thats is really nasty code, but atm I am happy that it works. I should try an other unzip api,
|
||||
// This one seems to behave very strange.
|
||||
// I know, that also a bug in my code could be reason for the crashes, but UnzipItem( ... ) unzipes wrong files
|
||||
// and GetZipItem( ... ) returns garbage as file names, and the next call of GetZipItem( ... ) blows up the program.
|
||||
//
|
||||
// I have commented line 3519 in unzip.cpp.
|
||||
// It was stated this is a bug, but it did not solve my problems.
|
||||
//
|
||||
// closing and reopen the zip handle did the trick.
|
||||
//
|
||||
|
||||
HZIP ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
|
||||
if (ZIP_Handle==NULL) {LastError << Language->Error_Unzip; return -1;}
|
||||
|
||||
ZIPENTRY ze;
|
||||
int index;
|
||||
FindZipItem( ZIP_Handle, L"texmod.def", false, &index, &ze);
|
||||
if (index>=0) //if texmod.def is present in the zip file
|
||||
{
|
||||
char* def;
|
||||
int len = ze.unc_size;
|
||||
try {def=new char[len+1];}
|
||||
catch(...) {LastError << Language->Error_Memory; return -1;}
|
||||
ZRESULT zr = UnzipItem( ZIP_Handle, index, def, len);
|
||||
|
||||
if (zr!=ZR_OK && zr!=ZR_MORE) {delete [] def; return -1;}
|
||||
def[len]=0;
|
||||
|
||||
wxStringTokenizer token( def, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
|
||||
tex.SetSize(num);
|
||||
|
||||
unsigned long temp_hash;
|
||||
int count = 0;
|
||||
wxString entry;
|
||||
wxString file;
|
||||
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
entry = token.GetNextToken();
|
||||
file = entry.BeforeFirst( '|');
|
||||
if (!file.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\nTPF:" << entry << "\n"; continue;}
|
||||
|
||||
file = entry.AfterFirst( '|');
|
||||
file.Replace( "\r", "");
|
||||
|
||||
while ( (file[0]=='.' && (file[1]=='/' || file[1]=='\\')) || file[0]=='/' || file[0]=='\\') file.Remove(0,1);
|
||||
|
||||
if (add)
|
||||
{
|
||||
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
|
||||
if (index>=0)
|
||||
{
|
||||
try {tex.Textures[count] = new char[ze.unc_size];}
|
||||
catch(...)
|
||||
{
|
||||
tex.Textures[count] = NULL;
|
||||
LastError << Language->Error_Memory;
|
||||
continue;
|
||||
}
|
||||
|
||||
ZRESULT rz = UnzipItem( ZIP_Handle, index, tex.Textures[count], ze.unc_size);
|
||||
if (rz!=ZR_OK && rz!=ZR_MORE)
|
||||
{
|
||||
delete [] tex.Textures[count];
|
||||
LastError << Language->Error_Unzip <<"\nTPF:" << file << "\n";
|
||||
tex.Textures[count] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = ze.unc_size;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError << Language->Error_Unzip <<"\nTPF:" << file << "\n";
|
||||
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
|
||||
ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
delete [] def;
|
||||
tex.Num = count;
|
||||
}
|
||||
else // texmod.def is not present in the zip file
|
||||
{
|
||||
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
|
||||
ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
|
||||
if (ZIP_Handle==NULL) {LastError << Language->Error_Unzip; return -1;}
|
||||
wxString name;
|
||||
wxString file;
|
||||
GetZipItem( ZIP_Handle, -1, &ze); //ask for number of entries
|
||||
int num = ze.index;
|
||||
|
||||
tex.SetSize(num);
|
||||
int count = 0;
|
||||
unsigned long temp_hash;
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
if (GetZipItem( ZIP_Handle, i, &ze)!=ZR_OK) continue; //ask for name and size
|
||||
int len = ze.unc_size;
|
||||
|
||||
char *buffer;
|
||||
try {buffer = new char[len+1];}
|
||||
catch(...)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
ZRESULT rz = UnzipItem( ZIP_Handle, i, buffer, len);
|
||||
if (rz!=ZR_OK && rz!=ZR_MORE)
|
||||
{
|
||||
delete [] buffer;
|
||||
buffer = NULL;
|
||||
LastError << Language->Error_Unzip <<"\nZIP:" << file << "\n";
|
||||
}
|
||||
|
||||
file = ze.name;
|
||||
if (file.Len()==0) continue;
|
||||
|
||||
name = file.AfterLast( '.');
|
||||
if (name!="dds") continue; //if this is not texture file, continue
|
||||
|
||||
name = file.AfterLast( '_');
|
||||
name = name.BeforeLast( '.');
|
||||
|
||||
if (!name.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\nZIP:" << file << "\n"; continue;} //if hash could not be extracted
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (buffer==NULL) continue;
|
||||
|
||||
tex.Textures[count] = buffer;
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = len;//ze.unc_size;
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer!=NULL) delete [] buffer;
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
tex.Num = count;
|
||||
}
|
||||
|
||||
CloseZip(ZIP_Handle);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef uMod_FILE_H_
|
||||
#define uMod_FILE_H_
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
class uMod_File
|
||||
{
|
||||
public:
|
||||
uMod_File(void);
|
||||
uMod_File(const wxString &file);
|
||||
~uMod_File(void);
|
||||
|
||||
bool FileSupported(void);
|
||||
|
||||
int GetComment( wxString &tool_tip);
|
||||
int GetContent( AddTextureClass &tex, bool add);
|
||||
|
||||
int SetFile(const wxString &file) {FileName=file;Loaded=false; return 0;}
|
||||
wxString GetFile(void) {return FileName;}
|
||||
|
||||
|
||||
wxString LastError;
|
||||
|
||||
private:
|
||||
int ReadFile(void);
|
||||
|
||||
int UnXOR(void);
|
||||
int GetCommentZip( wxString &tool_tip);
|
||||
int GetCommentTpf( wxString &tool_tip);
|
||||
|
||||
int AddFile( AddTextureClass &tex, bool add);
|
||||
int AddZip( AddTextureClass &tex, bool add, bool tpf);
|
||||
int AddContent( const char* pw, AddTextureClass &tex, bool add);
|
||||
|
||||
wxString FileName;
|
||||
bool Loaded;
|
||||
bool XORed;
|
||||
char *FileInMemory;
|
||||
unsigned int MemoryLength;
|
||||
unsigned int FileLen;
|
||||
};
|
||||
|
||||
|
||||
#endif /* uMod_FILE_H_ */
|
||||
@@ -1,987 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef __CDT_PARSER__
|
||||
|
||||
DEFINE_EVENT_TYPE(uMod_EVENT_TYPE)
|
||||
|
||||
BEGIN_EVENT_TABLE(uMod_Frame, wxFrame)
|
||||
EVT_CLOSE(uMod_Frame::OnClose)
|
||||
|
||||
EVT_BUTTON(ID_Button_Open, uMod_Frame::OnButtonOpen)
|
||||
EVT_BUTTON(ID_Button_Path, uMod_Frame::OnButtonPath)
|
||||
EVT_BUTTON(ID_Button_Update, uMod_Frame::OnButtonUpdate)
|
||||
EVT_BUTTON(ID_Button_Reload, uMod_Frame::OnButtonReload)
|
||||
|
||||
EVT_MENU(ID_Menu_Help, uMod_Frame::OnMenuHelp)
|
||||
EVT_MENU(ID_Menu_About, uMod_Frame::OnMenuAbout)
|
||||
EVT_MENU(ID_Menu_Acknowledgement, uMod_Frame::OnMenuAcknowledgement)
|
||||
|
||||
|
||||
EVT_MENU(ID_Menu_StartGame, uMod_Frame::OnMenuStartGame)
|
||||
EVT_MENU(ID_Menu_StartGameCMD, uMod_Frame::OnMenuStartGame)
|
||||
|
||||
EVT_MENU(ID_Menu_AddGame, uMod_Frame::OnMenuAddGame)
|
||||
EVT_MENU(ID_Menu_DeleteGame, uMod_Frame::OnMenuDeleteGame)
|
||||
EVT_MENU(ID_Menu_UseHook, uMod_Frame::OnMenuUseHook)
|
||||
|
||||
EVT_MENU(ID_Menu_LoadTemplate, uMod_Frame::OnMenuOpenTemplate)
|
||||
EVT_MENU(ID_Menu_SaveTemplate, uMod_Frame::OnMenuSaveTemplate)
|
||||
EVT_MENU(ID_Menu_SaveTemplateAs, uMod_Frame::OnMenuSaveTemplateAs)
|
||||
EVT_MENU(ID_Menu_SetDefaultTemplate, uMod_Frame::OnMenuSetDefaultTemplate)
|
||||
|
||||
EVT_MENU(ID_Menu_Lang, uMod_Frame::OnMenuLanguage)
|
||||
EVT_MENU(ID_Menu_Exit, uMod_Frame::OnMenuExit)
|
||||
|
||||
EVT_COMMAND (ID_Add_Game, uMod_EVENT_TYPE, uMod_Frame::OnAddGame)
|
||||
EVT_COMMAND (ID_Delete_Game, uMod_EVENT_TYPE, uMod_Frame::OnDeleteGame)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
#endif
|
||||
|
||||
MyApp::~MyApp(void)
|
||||
{
|
||||
if (CheckForSingleRun!=NULL) CloseHandle( CheckForSingleRun);
|
||||
}
|
||||
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
uMod_Settings set;
|
||||
set.Load();
|
||||
|
||||
Language = new uMod_Language(set.Language);
|
||||
CheckForSingleRun = CreateMutex( NULL, true, L"Global\\uMod_CheckForSingleRun");
|
||||
if (ERROR_ALREADY_EXISTS == GetLastError())
|
||||
{
|
||||
wxMessageBox( Language->Error_AlreadyRunning, "ERROR", wxOK|wxICON_ERROR);
|
||||
return false;
|
||||
}
|
||||
uMod_Frame *frame = new uMod_Frame( uMod_VERSION, set);
|
||||
SetTopWindow( frame );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
uMod_Frame::uMod_Frame(const wxString& title, uMod_Settings &set)
|
||||
: wxFrame((wxFrame *)NULL, -1, title, wxPoint(set.XPos,set.YPos), wxSize(set.XSize,set.YSize)), Settings(set)
|
||||
{
|
||||
SetIcon(wxICON(MAINICON));
|
||||
H_DX9_DLL = NULL;
|
||||
|
||||
Server = new uMod_Server( this);
|
||||
Server->Create();
|
||||
Server->Run();
|
||||
|
||||
MenuBar = new wxMenuBar;
|
||||
//MenuMain = new wxMenu;
|
||||
MenuMain = new wxMenu;
|
||||
MenuHelp = new wxMenu;
|
||||
|
||||
MenuMain->Append ( ID_Menu_StartGame, Language->MenuStartGame);
|
||||
MenuMain->Append ( ID_Menu_StartGameCMD, Language->MenuStartGameCMD);
|
||||
MenuMain->AppendSeparator();
|
||||
|
||||
MenuMain->Append( ID_Menu_AddGame, Language->MenuAddGame );
|
||||
MenuMain->Append( ID_Menu_DeleteGame, Language->MenuDeleteGame );
|
||||
MenuMain->AppendCheckItem ( ID_Menu_UseHook, Language->MenuUseHook);
|
||||
MenuMain->Check( ID_Menu_UseHook, Settings.UseHook);
|
||||
|
||||
MenuMain->AppendSeparator();
|
||||
MenuMain->Append( ID_Menu_LoadTemplate, Language->MenuLoadTemplate );
|
||||
MenuMain->Append( ID_Menu_SaveTemplate, Language->MenuSaveTemplate );
|
||||
MenuMain->Append( ID_Menu_SaveTemplateAs, Language->MenuSaveTemplateAs );
|
||||
MenuMain->Append( ID_Menu_SetDefaultTemplate, Language->MenuSetDefaultTemplate );
|
||||
MenuMain->AppendSeparator();
|
||||
MenuMain->Append( ID_Menu_Lang, Language->MenuLanguage );
|
||||
MenuMain->Append( ID_Menu_Exit, Language->MenuExit );
|
||||
|
||||
MenuHelp->Append( ID_Menu_Help, Language->MenuHelp );
|
||||
MenuHelp->Append( ID_Menu_About, Language->MenuAbout );
|
||||
MenuHelp->Append( ID_Menu_Acknowledgement, Language->MenuAcknowledgement );
|
||||
|
||||
MenuBar->Append( MenuMain, Language->MainMenuMain );
|
||||
MenuBar->Append( MenuHelp, Language->MainMenuHelp );
|
||||
|
||||
SetMenuBar(MenuBar);
|
||||
|
||||
|
||||
MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
Notebook = new wxNotebook( this, wxID_ANY);
|
||||
Notebook->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));
|
||||
MainSizer->Add( (wxWindow*) Notebook, 1, wxEXPAND , 0 );
|
||||
|
||||
ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
OpenButton = new wxButton( this, ID_Button_Open, Language->ButtonOpen, wxDefaultPosition, wxSize(100,24));
|
||||
DirectoryButton = new wxButton( this, ID_Button_Path, Language->ButtonDirectory, wxDefaultPosition, wxSize(100,24));
|
||||
UpdateButton = new wxButton( this, ID_Button_Update, Language->ButtonUpdate, wxDefaultPosition, wxSize(100,24));
|
||||
ReloadButton = new wxButton( this, ID_Button_Reload, Language->ButtonReload, wxDefaultPosition, wxSize(100,24));
|
||||
|
||||
ButtonSizer->Add( (wxWindow*) OpenButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) DirectoryButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) UpdateButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) ReloadButton, 1, wxEXPAND, 0);
|
||||
MainSizer->Add( ButtonSizer, 0, wxEXPAND , 0 );
|
||||
|
||||
|
||||
SetSizer( MainSizer);
|
||||
|
||||
NumberOfGames = 0;
|
||||
MaxNumberOfGames = 10;
|
||||
Clients = NULL;
|
||||
if (GetMemory( Clients, MaxNumberOfGames))
|
||||
{
|
||||
wxMessageBox( Language->Error_Memory, "ERROR", wxOK|wxICON_ERROR);
|
||||
}
|
||||
LoadTemplate();
|
||||
|
||||
Show( true );
|
||||
|
||||
{
|
||||
HMODULE dll = LoadLibraryW( L"D3DX9_43.dll");
|
||||
if (dll==NULL)
|
||||
{
|
||||
wxMessageBox( Language->Error_D3DX9NotFound, "ERROR", wxOK|wxICON_ERROR);
|
||||
}
|
||||
else FreeLibrary(dll);
|
||||
}
|
||||
|
||||
if (Settings.UseHook) InstallHook();
|
||||
DeactivateGamesControl();
|
||||
}
|
||||
|
||||
uMod_Frame::~uMod_Frame(void)
|
||||
{
|
||||
if (Server!=(uMod_Server*)0)
|
||||
{
|
||||
KillServer();
|
||||
Server->Wait();
|
||||
delete Server;
|
||||
Server = NULL;
|
||||
}
|
||||
|
||||
RemoveHook();
|
||||
|
||||
if (Clients!=NULL) delete [] Clients;
|
||||
|
||||
Settings.Language = Language->GetCurrentLanguage();
|
||||
GetSize( &Settings.XSize, &Settings.YSize);
|
||||
GetPosition( &Settings.XPos, &Settings.YPos);
|
||||
Settings.Save();
|
||||
}
|
||||
|
||||
int uMod_Frame::KillServer(void)
|
||||
{
|
||||
HANDLE pipe = CreateFileW( PIPE_Game2uMod,// pipe name
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
if (pipe == INVALID_HANDLE_VALUE) return -1;
|
||||
|
||||
const wchar_t *str = ABORT_SERVER;
|
||||
unsigned int len=0u;
|
||||
while (str[len]) len++;
|
||||
len++; //to send also the zero
|
||||
unsigned long num;
|
||||
WriteFile( pipe, (const void*) str, len*sizeof(wchar_t), &num, NULL);
|
||||
CloseHandle(pipe);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void uMod_Frame::OnAddGame( wxCommandEvent &event)
|
||||
{
|
||||
if (NumberOfGames>=MaxNumberOfGames)
|
||||
{
|
||||
if (GetMoreMemory( Clients, MaxNumberOfGames, MaxNumberOfGames+10))
|
||||
{
|
||||
wxMessageBox( Language->Error_Memory, "ERROR", wxOK|wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
MaxNumberOfGames += 10;
|
||||
}
|
||||
|
||||
wxString name = ((uMod_Event&)event).GetName();
|
||||
PipeStruct pipe;
|
||||
|
||||
pipe.In = ((uMod_Event&)event).GetPipeIn();
|
||||
pipe.Out = ((uMod_Event&)event).GetPipeOut();
|
||||
|
||||
uMod_Client *client = new uMod_Client( pipe, this);
|
||||
client->Create();
|
||||
client->Run();
|
||||
|
||||
wxString save_file;
|
||||
int num = SaveFile_Exe.GetCount();
|
||||
for (int i=0; i<num; i++) if (name==SaveFile_Exe[i])
|
||||
{
|
||||
save_file = SaveFile_Name[i];
|
||||
break;
|
||||
}
|
||||
|
||||
uMod_GamePage *page = new uMod_GamePage( Notebook, name, save_file, client->Pipe);
|
||||
if (page->LastError.Len()>0)
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
delete page;
|
||||
return;
|
||||
}
|
||||
name = name.AfterLast('\\');
|
||||
name = name.AfterLast('/');
|
||||
name = name.BeforeLast('.');
|
||||
Notebook->AddPage( page, name, true);
|
||||
|
||||
Clients[NumberOfGames] = client;
|
||||
NumberOfGames++;
|
||||
if (NumberOfGames==1) ActivateGamesControl();
|
||||
}
|
||||
|
||||
void uMod_Frame::OnDeleteGame( wxCommandEvent &event)
|
||||
{
|
||||
uMod_Client *client = ((uMod_Event&)event).GetClient();
|
||||
for (int i=0; i<NumberOfGames; i++) if (Clients[i]==client)
|
||||
{
|
||||
Notebook->DeletePage(i);
|
||||
Clients[i]->Wait();
|
||||
delete Clients[i];
|
||||
NumberOfGames--;
|
||||
for (int j=i; j<NumberOfGames; j++) Clients[j] = Clients[j+1];
|
||||
|
||||
if (NumberOfGames==0) DeactivateGamesControl();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void uMod_Frame::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
if (event.CanVeto() && NumberOfGames>0)
|
||||
{
|
||||
if (wxMessageBox(Language->ExitGameAnyway, "ERROR", wxYES_NO|wxICON_ERROR)!=wxYES) {event.Veto(); return;}
|
||||
}
|
||||
event.Skip();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void uMod_Frame::OnButtonOpen(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
|
||||
//wxString file_name = wxFileSelector( Language->ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
wxString file_name = wxFileSelector( Language->ChooseFile, page->GetOpenPath(), "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
page->SetOpenPath(file_name.BeforeLast( '/'));
|
||||
if (page->AddTexture( file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnButtonPath(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
wxString dir = wxDirSelector( Language->ChooseDir, page->GetSavePath());
|
||||
if ( !dir.empty() )
|
||||
{
|
||||
page->SetSavePath( dir);
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnButtonUpdate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
if (page->UpdateGame())
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnButtonReload(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
if (page->ReloadGame())
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void uMod_Frame::OnMenuOpenTemplate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
|
||||
//wxString file_name = wxFileSelector( Language->ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/templates";
|
||||
wxString file_name = wxFileSelector( Language->ChooseFile, dir, "", "*.txt", "text (*.txt)|*.txt", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
if (page->LoadTemplate( file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuSaveTemplate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
wxString file_name = page->GetTemplateName();
|
||||
|
||||
if ( file_name.empty() )
|
||||
{
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/templates";
|
||||
file_name = wxFileSelector( Language->ChooseFile, dir, "", "*.txt", "text (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
||||
}
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
if (page->SaveTemplate(file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuSaveTemplateAs(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/templates";
|
||||
wxString file_name = wxFileSelector( Language->ChooseFile, dir, "", "*.txt", "text (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
if (page->SaveTemplate(file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuSetDefaultTemplate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
wxString exe = page->GetExeName();
|
||||
wxString file = page->GetTemplateName();
|
||||
|
||||
int num = SaveFile_Exe.GetCount();
|
||||
bool hit = false;
|
||||
for (int i=0; i<num; i++) if (SaveFile_Exe[i]==exe)
|
||||
{
|
||||
SaveFile_Name[i] = file;
|
||||
hit = true;
|
||||
break;
|
||||
}
|
||||
if (!hit)
|
||||
{
|
||||
SaveFile_Exe.Add(exe);
|
||||
SaveFile_Name.Add(file);
|
||||
}
|
||||
if (SaveTemplate())
|
||||
{
|
||||
wxMessageBox(LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
LastError.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuLanguage(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxArrayString lang;
|
||||
Language->GetLanguages( lang);
|
||||
wxString choice = wxGetSingleChoice( Language->SelectLanguage, Language->SelectLanguage, lang);
|
||||
if (choice.Len()>0)
|
||||
{
|
||||
if (Language->LoadLanguage(choice))
|
||||
{
|
||||
wxMessageBox(Language->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
Language->LastError.Empty();
|
||||
return;
|
||||
}
|
||||
MenuBar->SetMenuLabel( 0, Language->MainMenuMain);
|
||||
MenuMain->SetLabel( ID_Menu_StartGame, Language->MenuStartGame);
|
||||
MenuMain->SetLabel( ID_Menu_StartGameCMD, Language->MenuStartGameCMD);
|
||||
|
||||
MenuMain->SetLabel( ID_Menu_AddGame, Language->MenuAddGame);
|
||||
MenuMain->SetLabel( ID_Menu_DeleteGame, Language->MenuDeleteGame);
|
||||
MenuMain->SetLabel( ID_Menu_UseHook, Language->MenuUseHook);
|
||||
|
||||
MenuMain->SetLabel( ID_Menu_LoadTemplate, Language->MenuLoadTemplate );
|
||||
MenuMain->SetLabel( ID_Menu_SaveTemplate, Language->MenuSaveTemplate );
|
||||
MenuMain->SetLabel( ID_Menu_SaveTemplateAs, Language->MenuSaveTemplateAs );
|
||||
MenuMain->SetLabel( ID_Menu_SetDefaultTemplate, Language->MenuSetDefaultTemplate );
|
||||
|
||||
MenuMain->SetLabel( ID_Menu_Lang, Language->MenuLanguage);
|
||||
MenuMain->SetLabel( ID_Menu_Exit, Language->MenuExit );
|
||||
|
||||
MenuBar->SetMenuLabel( 1, Language->MainMenuHelp);
|
||||
MenuHelp->SetLabel( ID_Menu_Help, Language->MenuHelp);
|
||||
MenuHelp->SetLabel( ID_Menu_About, Language->MenuAbout);
|
||||
MenuHelp->SetLabel( ID_Menu_Acknowledgement, Language->MenuAcknowledgement);
|
||||
|
||||
|
||||
OpenButton->SetLabel( Language->ButtonOpen);
|
||||
DirectoryButton->SetLabel( Language->ButtonDirectory);
|
||||
UpdateButton->SetLabel( Language->ButtonUpdate);
|
||||
ReloadButton->SetLabel( Language->ButtonReload);
|
||||
|
||||
int num = Notebook->GetPageCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
uMod_GamePage* page = (uMod_GamePage*) Notebook->GetPage(i);
|
||||
page->UpdateLanguage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuExit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuHelp(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString help;
|
||||
if (Language->GetHelpMessage( help))
|
||||
{
|
||||
wxMessageBox(Language->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
Language->LastError.Empty();
|
||||
return;
|
||||
}
|
||||
|
||||
wxMessageBox( help, Language->MenuHelp, wxOK);
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString msg;
|
||||
msg << uMod_VERSION << "\n\nProject members:\n\nROTA (developer)\nKing Brace Blane (PR)\n\nhttp://code.google.com/p/texmod/";
|
||||
wxMessageBox( msg, "Info", wxOK);
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuAcknowledgement(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString msg;
|
||||
msg << "King Brace Blane and ROTA thank:\n\n";
|
||||
msg << "RS for coding the original TexMod and for information about the used hashing algorithm\n\n";
|
||||
msg << "EvilAlex for translation into Russian and bug fixing\n";
|
||||
msg << "ReRRemi for translation into French\n";
|
||||
msg << "mirHL for translation into Italian\n";
|
||||
msg << "Vergil for help with German ;)";
|
||||
|
||||
wxMessageBox( msg, Language->MenuAcknowledgement, wxOK);
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuStartGame(wxCommandEvent& event)
|
||||
{
|
||||
bool use_cmd = false;
|
||||
if (event.GetId() == ID_Menu_StartGameCMD) use_cmd = true;
|
||||
|
||||
wxArrayString games, cmd, choices;
|
||||
|
||||
GetInjectedGames( games, cmd);
|
||||
int num = games.GetCount();
|
||||
|
||||
choices = games;
|
||||
choices.Add( Language->StartGame);
|
||||
|
||||
int index = wxGetSingleChoiceIndex( Language->MenuStartGame, Language->MenuStartGame, choices);
|
||||
|
||||
if (index < 0) return;
|
||||
else if (index==num)
|
||||
{
|
||||
wxString file_name = wxFileSelector( Language->ChooseGame, "", "", "exe", "binary (*.exe)|*.exe", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
bool hit = false;
|
||||
for (int i=0; i<num; i++) if (file_name==games[i]) {hit=true; index=i; break;}
|
||||
|
||||
if (!hit)
|
||||
{
|
||||
games.Add(file_name);
|
||||
cmd.Add("");
|
||||
}
|
||||
}
|
||||
else return;
|
||||
}
|
||||
|
||||
wxString command_line;
|
||||
if (use_cmd)
|
||||
{
|
||||
command_line = cmd[index];
|
||||
command_line = wxGetTextFromUser( Language->CommandLine, Language->CommandLine, command_line);
|
||||
if (!command_line.IsEmpty()) cmd[index] = command_line;
|
||||
}
|
||||
|
||||
SetInjectedGames( games, cmd);
|
||||
|
||||
if (Settings.UseHook)
|
||||
{
|
||||
wxArrayString array;
|
||||
if (GetHookedGames( array)) array.Empty();
|
||||
|
||||
int num = array.GetCount();
|
||||
for (int i=0; i<num; i++) if (array[i] == games[index])
|
||||
{
|
||||
wxMessageBox(Language->Error_GameIsHooked, "ERROR", wxOK|wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
STARTUPINFOW si = {0};
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
|
||||
wxString path = games[index].BeforeLast('\\');
|
||||
wxString exe;
|
||||
|
||||
if (use_cmd) exe << "\"" << games[index] << "\" " << command_line;
|
||||
else exe = games[index];
|
||||
|
||||
|
||||
bool result = CreateProcess(NULL, (wchar_t*) exe.wc_str(), NULL, NULL, FALSE,
|
||||
CREATE_SUSPENDED, NULL, path.wc_str(), &si, &pi);
|
||||
if(!result)
|
||||
{
|
||||
wxMessageBox( Language->Error_ProcessNotStarted, "ERROR", wxOK|wxICON_ERROR);
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
wxString dll = wxGetCwd();
|
||||
dll.Append( L"\\" uMod_d3d9_DI_dll);
|
||||
|
||||
Inject(pi.hProcess, dll.wc_str(), "Nothing");
|
||||
ResumeThread(pi.hThread);
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuUseHook(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
bool use_hook = MenuMain->IsChecked(ID_Menu_UseHook);
|
||||
|
||||
if (Settings.UseHook!=use_hook)
|
||||
{
|
||||
if (Settings.UseHook)
|
||||
{
|
||||
if (NumberOfGames>0)
|
||||
{
|
||||
MenuMain->Check(ID_Menu_UseHook, true);
|
||||
wxMessageBox(Language->Error_RemoveHook, "ERROR", wxOK|wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
RemoveHook();
|
||||
}
|
||||
else
|
||||
{
|
||||
InstallHook();
|
||||
}
|
||||
Settings.UseHook=use_hook;
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuAddGame(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString file_name = wxFileSelector( Language->ChooseGame, "", "", "exe", "binary (*.exe)|*.exe", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
wxArrayString array;
|
||||
if (GetHookedGames( array)) array.Empty();
|
||||
|
||||
int num = array.GetCount();
|
||||
for (int i=0; i<num; i++) if (array[i] == file_name)
|
||||
{
|
||||
wxMessageBox(Language->GameAlreadyAdded, "ERROR", wxOK|wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
array.Add(file_name);
|
||||
if (SetHookedGames( array))
|
||||
{
|
||||
wxMessageBox( LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
LastError.Empty();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::OnMenuDeleteGame(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxArrayInt selections;
|
||||
wxArrayString array;
|
||||
if (GetHookedGames( array))
|
||||
{
|
||||
wxMessageBox( LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
LastError.Empty();
|
||||
return;
|
||||
}
|
||||
wxGetSelectedChoices( selections, Language->DeleteGame, Language->DeleteGame, array);
|
||||
|
||||
int num = selections.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
array.RemoveAt( selections[i]-i); //this will work only if selections is sorted !!
|
||||
}
|
||||
|
||||
if (SetHookedGames( array))
|
||||
{
|
||||
wxMessageBox( LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
LastError.Empty();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int uMod_Frame::ActivateGamesControl(void)
|
||||
{
|
||||
MenuMain->Enable( ID_Menu_LoadTemplate, true);
|
||||
MenuMain->Enable( ID_Menu_SaveTemplate, true);
|
||||
MenuMain->Enable( ID_Menu_SaveTemplateAs, true);
|
||||
MenuMain->Enable( ID_Menu_SetDefaultTemplate, true);
|
||||
|
||||
|
||||
OpenButton->Enable( true);
|
||||
DirectoryButton->Enable( true);
|
||||
UpdateButton->Enable( true);
|
||||
ReloadButton->Enable( true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_Frame::DeactivateGamesControl(void)
|
||||
{
|
||||
MenuMain->Enable( ID_Menu_LoadTemplate, false);
|
||||
MenuMain->Enable( ID_Menu_SaveTemplate, false);
|
||||
MenuMain->Enable( ID_Menu_SaveTemplateAs, false);
|
||||
MenuMain->Enable( ID_Menu_SetDefaultTemplate, false);
|
||||
|
||||
|
||||
OpenButton->Enable( false);
|
||||
DirectoryButton->Enable( false);
|
||||
UpdateButton->Enable( false);
|
||||
ReloadButton->Enable( false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_Frame::GetHookedGames( wxArrayString &array)
|
||||
{
|
||||
wxFile file;
|
||||
wxString name;
|
||||
wchar_t *app_path = _wgetenv( L"APPDATA");
|
||||
name.Printf("%ls\\%ls\\%ls", app_path, uMod_APP_DIR, uMod_APP_DX9);
|
||||
|
||||
if (!file.Access(name, wxFile::read)) {LastError << Language->Error_FileOpen << "\n" << name; return -1;}
|
||||
file.Open(name, wxFile::read);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << name ; return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Language->Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Language->Error_FileRead<<"\n" << name; return -1;}
|
||||
|
||||
wchar_t *buff = (wchar_t*)buffer;
|
||||
len/=2;
|
||||
buff[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buff;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
array.Empty();
|
||||
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
array.Add( token.GetNextToken());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_Frame::SetHookedGames( const wxArrayString &array)
|
||||
{
|
||||
wxFile file;
|
||||
wxString name;
|
||||
wchar_t *app_path = _wgetenv( L"APPDATA");
|
||||
name.Printf("%ls\\%ls", app_path, uMod_APP_DIR);
|
||||
|
||||
if (! wxDir::Exists(name))
|
||||
{
|
||||
wxDir::Make(name);
|
||||
}
|
||||
|
||||
name.Printf("%ls\\%ls\\%ls", app_path, uMod_APP_DIR, uMod_APP_DX9);
|
||||
file.Open(name, wxFile::write);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << name ; return -1;}
|
||||
wxString content;
|
||||
|
||||
int num = array.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
content = array[i];
|
||||
content << "\n";
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
}
|
||||
file.Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define DI_FILE "uMod_DI_Games.txt"
|
||||
int uMod_Frame::GetInjectedGames( wxArrayString &games, wxArrayString &cmd)
|
||||
{
|
||||
wxFile file;
|
||||
|
||||
if (!file.Access( DI_FILE, wxFile::read)) {LastError << Language->Error_FileOpen << "\n" << DI_FILE; return -1;}
|
||||
file.Open( DI_FILE, wxFile::read);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << DI_FILE ; return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Language->Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Language->Error_FileRead<<"\n" << DI_FILE; return -1;}
|
||||
|
||||
wchar_t *buff = (wchar_t*)buffer;
|
||||
len/=2;
|
||||
buff[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buff;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
games.Empty();
|
||||
games.Alloc(num);
|
||||
cmd.Empty();
|
||||
cmd.Alloc(num);
|
||||
wxString entry;
|
||||
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
entry = token.GetNextToken();
|
||||
games.Add( entry.BeforeFirst('|'));
|
||||
cmd.Add( entry.AfterFirst('|'));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_Frame::SetInjectedGames( wxArrayString &games, wxArrayString &cmd)
|
||||
{
|
||||
wxFile file;
|
||||
|
||||
file.Open( DI_FILE, wxFile::write);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << DI_FILE ; return -1;}
|
||||
wxString content;
|
||||
|
||||
int num = games.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
content = games[i];
|
||||
content << "|" << cmd[i] << "\n";
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
}
|
||||
file.Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#define SAVE_FILE "uMod_SaveFiles.txt"
|
||||
|
||||
int uMod_Frame::LoadTemplate(void)
|
||||
{
|
||||
wxFile file;
|
||||
if (!file.Access(SAVE_FILE, wxFile::read)) {LastError << Language->Error_FileOpen << "\n" << SAVE_FILE; return -1;}
|
||||
file.Open(SAVE_FILE, wxFile::read);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << SAVE_FILE ; return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Language->Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Language->Error_FileRead<<"\n" << SAVE_FILE; return -1;}
|
||||
|
||||
wchar_t *buff = (wchar_t*)buffer;
|
||||
len/=2;
|
||||
buff[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buff;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
SaveFile_Exe.Empty();
|
||||
SaveFile_Exe.Alloc(num+10);
|
||||
SaveFile_Name.Empty();
|
||||
SaveFile_Name.Alloc(num+10);
|
||||
|
||||
wxString line;
|
||||
wxString exe;
|
||||
wxString name;
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
line = token.GetNextToken();
|
||||
exe = line.BeforeFirst('|');
|
||||
name = line.AfterFirst('|');
|
||||
name.Replace("\r","");
|
||||
SaveFile_Exe.Add( exe);
|
||||
SaveFile_Name.Add( name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_Frame::SaveTemplate(void)
|
||||
{
|
||||
wxFile file;
|
||||
file.Open(SAVE_FILE, wxFile::write);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << SAVE_FILE ; return -1;}
|
||||
wxString content;
|
||||
|
||||
int num = SaveFile_Exe.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
content = SaveFile_Exe[i];
|
||||
content << "|" << SaveFile_Name[i] << "\n";
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
}
|
||||
file.Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void uMod_Frame::InstallHook(void)
|
||||
{
|
||||
if (H_DX9_DLL==NULL)
|
||||
{
|
||||
H_DX9_DLL = LoadLibraryW(uMod_d3d9_Hook_dll);
|
||||
if (H_DX9_DLL!=NULL)
|
||||
{
|
||||
typedef void (*fkt_typ)(void);
|
||||
fkt_typ install_hook = (fkt_typ) GetProcAddress( H_DX9_DLL, "InstallHook");
|
||||
if (install_hook!=NULL) install_hook();
|
||||
else
|
||||
{
|
||||
DWORD error = GetLastError();
|
||||
wchar_t *error_msg;
|
||||
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error_msg, 0, NULL );
|
||||
wxString temp = Language->Error_DLLNotFound;
|
||||
temp << "\n" << uMod_d3d9_Hook_dll;
|
||||
temp << "\n" << error_msg << "Code: " << error;
|
||||
wxMessageBox( temp, "ERROR", wxOK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD error = GetLastError();
|
||||
wchar_t *error_msg;
|
||||
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error_msg, 0, NULL );
|
||||
wxString temp = Language->Error_DLLNotFound;
|
||||
temp << "\n" << uMod_d3d9_Hook_dll;
|
||||
temp << "\n" << error_msg << "Code: " << error;
|
||||
wxMessageBox(temp, "ERROR", wxOK|wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uMod_Frame::RemoveHook(void)
|
||||
{
|
||||
if (H_DX9_DLL!=NULL)
|
||||
{
|
||||
typedef void (*fkt_typ)(void);
|
||||
fkt_typ remove_hook = (fkt_typ) GetProcAddress( H_DX9_DLL, "RemoveHook");
|
||||
if (remove_hook!=NULL) remove_hook();
|
||||
FreeLibrary(H_DX9_DLL);
|
||||
}
|
||||
H_DX9_DLL = NULL;
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_GUI_H_
|
||||
#define uMod_GUI_H_
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
class uMod_Frame : public wxFrame
|
||||
{
|
||||
public:
|
||||
uMod_Frame(const wxString& title, uMod_Settings &set);
|
||||
~uMod_Frame(void);
|
||||
|
||||
|
||||
|
||||
void OnAddGame( wxCommandEvent &event);
|
||||
void OnDeleteGame( wxCommandEvent &event);
|
||||
|
||||
void OnClose(wxCloseEvent& WXUNUSED(event));
|
||||
|
||||
|
||||
void OnButtonOpen(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonPath(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonUpdate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonReload(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuStartGame( wxCommandEvent &event);
|
||||
|
||||
void OnMenuUseHook( wxCommandEvent &event);
|
||||
void OnMenuAddGame(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuDeleteGame(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuOpenTemplate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuSaveTemplate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuSaveTemplateAs(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuSetDefaultTemplate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuLanguage(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuExit(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuHelp(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuAbout(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuAcknowledgement(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
private:
|
||||
|
||||
int ActivateGamesControl(void);
|
||||
int DeactivateGamesControl(void);
|
||||
|
||||
uMod_Settings Settings;
|
||||
int KillServer(void);
|
||||
int GetHookedGames( wxArrayString &array);
|
||||
int SetHookedGames( const wxArrayString &array);
|
||||
|
||||
int GetInjectedGames( wxArrayString &games, wxArrayString &cmd);
|
||||
int SetInjectedGames( wxArrayString &games, wxArrayString &cmd);
|
||||
|
||||
uMod_Server *Server;
|
||||
|
||||
wxNotebook *Notebook;
|
||||
|
||||
|
||||
wxButton *OpenButton;
|
||||
wxButton *DirectoryButton;
|
||||
wxButton *UpdateButton;
|
||||
wxButton *ReloadButton;
|
||||
|
||||
|
||||
wxMenuBar *MenuBar;
|
||||
wxMenu *MenuMain;
|
||||
wxMenu *MenuHelp;
|
||||
|
||||
wxBoxSizer *MainSizer;
|
||||
wxBoxSizer *ButtonSizer;
|
||||
|
||||
|
||||
int NumberOfGames;
|
||||
int MaxNumberOfGames;
|
||||
uMod_Client **Clients;
|
||||
|
||||
int LoadTemplate(void);
|
||||
int SaveTemplate(void);
|
||||
wxArrayString SaveFile_Exe;
|
||||
wxArrayString SaveFile_Name;
|
||||
|
||||
|
||||
void InstallHook(void);
|
||||
void RemoveHook(void);
|
||||
|
||||
HMODULE H_DX9_DLL;
|
||||
|
||||
wxString LastError;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class MyApp : public wxApp
|
||||
{
|
||||
public:
|
||||
virtual ~MyApp();
|
||||
virtual bool OnInit();
|
||||
|
||||
private:
|
||||
HANDLE CheckForSingleRun;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,333 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
uMod_GameInfo::uMod_GameInfo(void)
|
||||
{
|
||||
Checked = NULL;
|
||||
NumberOfChecked = 0;
|
||||
LengthOfChecked = 0;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
uMod_GameInfo::~uMod_GameInfo(void)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
}
|
||||
|
||||
void uMod_GameInfo::Init(void)
|
||||
{
|
||||
SaveSingleTexture = false;
|
||||
SaveAllTextures = false;
|
||||
|
||||
KeyBack = -1;
|
||||
KeySave = -1;
|
||||
KeyNext = -1;
|
||||
FontColour[0]=255;FontColour[1]=0;FontColour[2]=0;
|
||||
TextureColour[0]=0;TextureColour[1]=255;TextureColour[2]=0;
|
||||
NumberOfChecked = 0;
|
||||
SavePath.Empty();
|
||||
OpenPath.Empty();
|
||||
Files.Empty();
|
||||
}
|
||||
|
||||
int uMod_GameInfo::SaveToFile( const wxString &file_name)
|
||||
{
|
||||
wxFile file;
|
||||
|
||||
//if (!file.Access(name, wxFile::write)) return -1;
|
||||
file.Open(file_name, wxFile::write);
|
||||
if (!file.IsOpened()) {return -1;}
|
||||
|
||||
wxString content;
|
||||
if (SavePath.Len()>0)
|
||||
{
|
||||
content.Printf( L"SavePath:%ls\n", SavePath.wc_str());
|
||||
file.Write( content.char_str(), content.Len());
|
||||
}
|
||||
|
||||
if (OpenPath.Len()>0)
|
||||
{
|
||||
content.Printf( L"OpenPath:%ls\n", OpenPath.wc_str());
|
||||
file.Write( content.char_str(), content.Len());
|
||||
}
|
||||
|
||||
content.Printf( L"SaveAllTextures:%d\nSaveSingleTexture:%d\n", SaveAllTextures, SaveSingleTexture);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
|
||||
if (KeyBack>=0)
|
||||
{
|
||||
content.Printf( L"KeyBack:%d\n", KeyBack);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
}
|
||||
if (KeySave>=0)
|
||||
{
|
||||
content.Printf( L"KeySave:%d\n", KeySave);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
}
|
||||
if (KeyNext>=0)
|
||||
{
|
||||
content.Printf( L"KeyNext:%d\n", KeyNext);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
}
|
||||
|
||||
content.Printf( L"FontColour:%d,%d,%d\n", FontColour[0], FontColour[1], FontColour[2]);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
content.Printf( L"TextureColour:%d,%d,%d\n", TextureColour[0], TextureColour[1], TextureColour[2]);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
|
||||
int num = Files.GetCount();
|
||||
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
if (i<NumberOfChecked)
|
||||
{
|
||||
if (Checked[i]) content.Printf( L"Add_true:%ls\n", Files[i].wc_str());
|
||||
else content.Printf( L"Add_false:%ls\n", Files[i].wc_str());
|
||||
}
|
||||
else content.Printf( L"Add_true:%ls\n", Files[i].wc_str());
|
||||
file.Write( content.char_str(), content.Len());
|
||||
}
|
||||
|
||||
file.Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_GameInfo::LoadFromFile( const wxString &file_name)
|
||||
{
|
||||
Init();
|
||||
if (file_name.Len()==0) return -1;
|
||||
|
||||
wxFile file;
|
||||
if (!file.Access(file_name, wxFile::read)) return -1;
|
||||
file.Open(file_name, wxFile::read);
|
||||
if (!file.IsOpened()) {return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+1];}
|
||||
catch (...) {return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; return -1;}
|
||||
|
||||
buffer[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buffer;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
if (LengthOfChecked<num)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
try {Checked = new bool [num+100];}
|
||||
catch (...) {Checked=NULL;LengthOfChecked=0; return -1;}
|
||||
LengthOfChecked = num+100;
|
||||
}
|
||||
|
||||
wxString line;
|
||||
wxString command;
|
||||
wxString temp;
|
||||
Files.Alloc(num);
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
line = token.GetNextToken();
|
||||
command = line.BeforeFirst(':');
|
||||
|
||||
|
||||
if (command == L"Add_true")
|
||||
{
|
||||
Checked[NumberOfChecked++] = true;
|
||||
Files.Add(line.AfterFirst(':'));
|
||||
}
|
||||
else if (command == L"Add_false")
|
||||
{
|
||||
Checked[NumberOfChecked++] = false;
|
||||
Files.Add(line.AfterFirst(':'));
|
||||
}
|
||||
else if (command == L"SavePath") SavePath = line.AfterFirst(':');
|
||||
else if (command == L"OpenPath") OpenPath = line.AfterFirst(':');
|
||||
else if (command == L"SaveAllTextures")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp[0]=='0') SaveAllTextures = false;
|
||||
else SaveAllTextures = true;
|
||||
}
|
||||
else if (command == L"SaveSingleTexture")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp[0]=='0') SaveSingleTexture = false;
|
||||
else SaveSingleTexture = true;
|
||||
}
|
||||
else if (command == L"KeyBack")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
long key;
|
||||
if (temp.ToLong( &key)) KeyBack = key;
|
||||
else KeyBack = -1;
|
||||
}
|
||||
else if (command == L"KeySave")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
long key;
|
||||
if (temp.ToLong( &key)) KeySave = key;
|
||||
else KeySave = -1;
|
||||
}
|
||||
else if (command == L"KeyNext")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
long key;
|
||||
if (temp.ToLong( &key)) KeyNext = key;
|
||||
else KeyNext = -1;
|
||||
}
|
||||
else if (command == L"FontColour")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.BeforeFirst(',');
|
||||
long colour;
|
||||
if (temp.ToLong( &colour)) FontColour[0] = colour;
|
||||
else FontColour[0] = 255;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterFirst(',');
|
||||
temp = temp.BeforeFirst(',');
|
||||
if (temp.ToLong( &colour)) FontColour[1] = colour;
|
||||
else FontColour[1] = 0;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterLast(',');
|
||||
if (temp.ToLong( &colour)) FontColour[2] = colour;
|
||||
else FontColour[2] = 0;
|
||||
}
|
||||
else if (command == L"TextureColour")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.BeforeFirst(',');
|
||||
long colour;
|
||||
if (temp.ToLong( &colour)) TextureColour[0] = colour;
|
||||
else TextureColour[0] = 0;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterFirst(',');
|
||||
temp = temp.BeforeFirst(',');
|
||||
if (temp.ToLong( &colour)) TextureColour[1] = colour;
|
||||
else TextureColour[1] = 255;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterLast(',');
|
||||
if (temp.ToLong( &colour)) TextureColour[2] = colour;
|
||||
else TextureColour[2] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
if (NumberOfChecked>=LengthOfChecked)
|
||||
{
|
||||
bool *t_bool;
|
||||
try {t_bool = new bool [LengthOfChecked+100];}
|
||||
catch (...) {return -1;}
|
||||
for (int i=0; i<LengthOfChecked; i++) t_bool[i]=Checked[i];
|
||||
delete [] Checked;
|
||||
Checked = t_bool;
|
||||
LengthOfChecked +=100;
|
||||
}
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_GameInfo::GetChecked( bool* array, int num) const
|
||||
{
|
||||
for (int i=0; i<num && i<NumberOfChecked; i++) array[i] = Checked[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GameInfo::SetChecked( bool* array, int num)
|
||||
{
|
||||
if (num>LengthOfChecked)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
try {Checked = new bool [num+100];}
|
||||
catch (...) {Checked=NULL; LengthOfChecked = 0; return -1;}
|
||||
LengthOfChecked = num+100;
|
||||
}
|
||||
for (int i=0; i<num; i++) Checked[i] = array[i];
|
||||
NumberOfChecked = num;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GameInfo::SetSaveSingleTexture(bool val)
|
||||
{
|
||||
SaveSingleTexture = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GameInfo::SetSaveAllTextures(bool val)
|
||||
{
|
||||
SaveAllTextures = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void uMod_GameInfo::SetFiles(const wxArrayString &files)
|
||||
{
|
||||
Files = files;
|
||||
}
|
||||
|
||||
void uMod_GameInfo::GetFiles( wxArrayString &files) const
|
||||
{
|
||||
files = Files;
|
||||
}
|
||||
|
||||
uMod_GameInfo& uMod_GameInfo::operator = (const uMod_GameInfo &rhs)
|
||||
{
|
||||
SaveSingleTexture = rhs.SaveSingleTexture;
|
||||
SaveAllTextures = rhs.SaveAllTextures;
|
||||
|
||||
KeyBack = rhs.KeyBack;
|
||||
KeySave = rhs.KeySave;
|
||||
KeyNext = rhs.KeyNext;
|
||||
|
||||
if (LengthOfChecked<rhs.LengthOfChecked)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
Checked = new bool [rhs.LengthOfChecked];
|
||||
LengthOfChecked = rhs.LengthOfChecked;
|
||||
}
|
||||
NumberOfChecked = rhs.NumberOfChecked;
|
||||
for (int i=0; i<NumberOfChecked; i++) Checked[i] = rhs.Checked[i];
|
||||
|
||||
SavePath = rhs.SavePath;
|
||||
OpenPath = rhs.OpenPath;
|
||||
Files = rhs.Files;
|
||||
|
||||
for (int i=0; i<3; i++) FontColour[i]=rhs.FontColour[i];
|
||||
for (int i=0; i<3; i++) TextureColour[i]=rhs.TextureColour[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_GAME_H_
|
||||
#define uMod_GAME_H_
|
||||
#include "uMod_Main.h"
|
||||
|
||||
//this class is intended as a storing object for each game
|
||||
// one should ad an assignment operator, loading and saving default values, ...
|
||||
class uMod_GameInfo
|
||||
{
|
||||
public:
|
||||
uMod_GameInfo(void);
|
||||
~uMod_GameInfo(void);
|
||||
void Init(void);
|
||||
|
||||
|
||||
int SaveToFile( const wxString &file_name);
|
||||
int LoadFromFile( const wxString &file_name);
|
||||
|
||||
int GetChecked( bool* array, int num) const;
|
||||
int SetChecked( bool* array, int num);
|
||||
|
||||
int SetSaveSingleTexture(bool val);
|
||||
bool GetSaveSingleTexture(void) const {return SaveSingleTexture;}
|
||||
|
||||
int SetSaveAllTextures(bool val);
|
||||
bool GetSaveAllTextures(void) const {return SaveAllTextures;}
|
||||
|
||||
void SetFiles(const wxArrayString &files);
|
||||
void GetFiles( wxArrayString &files) const;
|
||||
//void AddTexture( const wxString &textures);
|
||||
|
||||
int GetNumberOfFiles(void) const {return Files.GetCount();}
|
||||
|
||||
int SendTextures(void);
|
||||
|
||||
int GetKeyBack() const {return KeyBack;}
|
||||
int SetKeyBack(int key) {KeyBack=key; return 0;}
|
||||
|
||||
int GetKeySave() const {return KeySave;}
|
||||
int SetKeySave(int key) {KeySave=key; return 0;}
|
||||
|
||||
int GetKeyNext() const {return KeyNext;}
|
||||
int SetKeyNext(int key) {KeyNext=key; return 0;}
|
||||
|
||||
int SetFontColour(const int *colour) {FontColour[0]=colour[0];FontColour[1]=colour[1];FontColour[2]=colour[2];return 0;}
|
||||
int GetFontColour(int *colour) const {colour[0]=FontColour[0];colour[1]=FontColour[1];colour[2]=FontColour[2];return 0;}
|
||||
|
||||
int SetTextureColour(const int *colour) {TextureColour[0]=colour[0];TextureColour[1]=colour[1];TextureColour[2]=colour[2];return 0;}
|
||||
int GetTextureColour(int *colour) const {colour[0]=TextureColour[0];colour[1]=TextureColour[1];colour[2]=TextureColour[2];return 0;}
|
||||
|
||||
int SetOpenPath(const wxString &path) {OpenPath=path; return 0;}
|
||||
wxString GetOpenPath(void) const {return OpenPath;}
|
||||
|
||||
int SetSavePath(const wxString &path) {SavePath=path; return 0;}
|
||||
wxString GetSavePath(void) const {return SavePath;}
|
||||
|
||||
uMod_GameInfo& operator = (const uMod_GameInfo &rhs);
|
||||
|
||||
private:
|
||||
|
||||
bool *Checked;
|
||||
int NumberOfChecked;
|
||||
int LengthOfChecked;
|
||||
|
||||
bool SaveSingleTexture;
|
||||
bool SaveAllTextures;
|
||||
|
||||
wxArrayString Files;
|
||||
|
||||
int KeyBack;
|
||||
int KeySave;
|
||||
int KeyNext;
|
||||
|
||||
int FontColour[3];
|
||||
int TextureColour[3];
|
||||
|
||||
wxString OpenPath;
|
||||
wxString SavePath;
|
||||
};
|
||||
|
||||
|
||||
#endif /* uMod_SERVER_H_ */
|
||||
@@ -1,525 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
uMod_GamePage::uMod_GamePage( wxNotebook *parent, const wxString &exe, const wxString &save, PipeStruct &pipe)
|
||||
: wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL), Sender(pipe)
|
||||
{
|
||||
ExeName = exe;
|
||||
TemplateName = save;
|
||||
|
||||
//SetBackgroundColour( *wxLIGHT_GREY);
|
||||
//SetBackgroundColour( wxColour( "LIGHT GREY"));
|
||||
|
||||
CheckBoxHSizers = NULL;
|
||||
CheckButtonUp = NULL;
|
||||
CheckButtonDown = NULL;
|
||||
CheckButtonDelete = NULL;
|
||||
CheckBoxes = NULL;
|
||||
|
||||
MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
|
||||
TemplateFile = new wxTextCtrl(this, wxID_ANY, Language->TextCtrlTemplate, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
MainSizer->Add( (wxWindow*) TemplateFile, 0, wxEXPAND, 0);
|
||||
MainSizer->AddSpacer(10);
|
||||
|
||||
SizerKeys[0] = new wxBoxSizer(wxHORIZONTAL);
|
||||
SizerKeys[1] = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
TextKeyBack = new wxTextCtrl(this, wxID_ANY, Language->KeyBack, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SizerKeys[0]->Add( (wxWindow*) TextKeyBack, 1, wxEXPAND, 0);
|
||||
ChoiceKeyBack = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language->KeyStrings);
|
||||
SizerKeys[1]->Add( (wxWindow*) ChoiceKeyBack, 1, wxEXPAND, 0);
|
||||
|
||||
TextKeySave = new wxTextCtrl(this, wxID_ANY, Language->KeySave, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SizerKeys[0]->Add( (wxWindow*) TextKeySave, 1, wxEXPAND, 0);
|
||||
ChoiceKeySave = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language->KeyStrings);
|
||||
SizerKeys[1]->Add( (wxWindow*) ChoiceKeySave, 1, wxEXPAND, 0);
|
||||
|
||||
TextKeyNext = new wxTextCtrl(this, wxID_ANY, Language->KeyNext, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SizerKeys[0]->Add( (wxWindow*) TextKeyNext, 1, wxEXPAND, 0);
|
||||
ChoiceKeyNext = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language->KeyStrings);
|
||||
SizerKeys[1]->Add( (wxWindow*) ChoiceKeyNext, 1, wxEXPAND, 0);
|
||||
|
||||
MainSizer->Add( SizerKeys[0], 0, wxEXPAND, 0);
|
||||
MainSizer->Add( SizerKeys[1], 0, wxEXPAND, 0);
|
||||
|
||||
|
||||
FontColourSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
FontColour[0] = new wxTextCtrl(this, wxID_ANY, Language->FontColour, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
FontColour[1] = new wxTextCtrl(this, wxID_ANY, "255", wxDefaultPosition, wxDefaultSize);
|
||||
FontColour[2] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
FontColour[3] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
for (int i=0; i<4; i++) FontColourSizer->Add( (wxWindow*) FontColour[i], 1, wxEXPAND, 0);
|
||||
|
||||
TextureColourSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
TextureColour[0] = new wxTextCtrl(this, wxID_ANY, Language->TextureColour, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
TextureColour[1] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
TextureColour[2] = new wxTextCtrl(this, wxID_ANY, "255", wxDefaultPosition, wxDefaultSize);
|
||||
TextureColour[3] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
for (int i=0; i<4; i++) TextureColourSizer->Add( (wxWindow*) TextureColour[i], 1, wxEXPAND, 0);
|
||||
|
||||
|
||||
MainSizer->Add( FontColourSizer, 0, wxEXPAND, 0);
|
||||
MainSizer->Add( TextureColourSizer, 0, wxEXPAND, 0);
|
||||
|
||||
SaveSingleTexture = new wxCheckBox( this, -1, Language->CheckBoxSaveSingleTexture);
|
||||
MainSizer->Add( (wxWindow*) SaveSingleTexture, 0, wxEXPAND, 0);
|
||||
|
||||
SaveAllTextures = new wxCheckBox( this, -1, Language->CheckBoxSaveAllTextures);
|
||||
MainSizer->Add( (wxWindow*) SaveAllTextures, 0, wxEXPAND, 0);
|
||||
|
||||
SavePath = new wxTextCtrl(this, wxID_ANY, Language->TextCtrlSavePath, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
MainSizer->Add( (wxWindow*) SavePath, 0, wxEXPAND, 0);
|
||||
|
||||
MainSizer->AddSpacer(10);
|
||||
|
||||
NumberOfEntry = 0;
|
||||
MaxNumberOfEntry = 1024;
|
||||
if (GetMemory( CheckBoxes, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
if (GetMemory( CheckBoxHSizers, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return ;}
|
||||
if (GetMemory( CheckButtonUp, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDown, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDelete, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
SavePath->SetValue(Language->TextCtrlSavePath);
|
||||
|
||||
|
||||
SetSizer(MainSizer);
|
||||
|
||||
SetScrollRate(0, 20);
|
||||
MainSizer->FitInside(this);
|
||||
|
||||
if (TemplateName.Len()>0) LoadTemplate(TemplateName);
|
||||
}
|
||||
|
||||
uMod_GamePage::~uMod_GamePage(void)
|
||||
{
|
||||
for (int i=0; i<NumberOfEntry; i++)
|
||||
{
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonUp, this, ID_Button_Texture+3*i);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDown, this, ID_Button_Texture+3*i+1);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDelete, this, ID_Button_Texture+3*i+2);
|
||||
}
|
||||
|
||||
delete [] CheckBoxHSizers;
|
||||
delete [] CheckButtonUp;
|
||||
delete [] CheckButtonDown;
|
||||
delete [] CheckButtonDelete;
|
||||
delete [] CheckBoxes;
|
||||
}
|
||||
|
||||
int uMod_GamePage::SetSavePath( const wxString &path)
|
||||
{
|
||||
wxString save_path = Language->TextCtrlSavePath;
|
||||
save_path << path;
|
||||
SavePath->SetValue(save_path);
|
||||
Game.SetSavePath( path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_GamePage::AddTexture( const wxString &file_name)
|
||||
{
|
||||
if (NumberOfEntry>=MaxNumberOfEntry)
|
||||
{
|
||||
if (GetMoreMemory( CheckBoxes, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckBoxHSizers, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonUp, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDown, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDelete, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
MaxNumberOfEntry+=1024;
|
||||
}
|
||||
uMod_File file( file_name);
|
||||
if (!file.FileSupported()) {LastError << Language->Error_FileNotSupported << "\n" << file_name; return -1;}
|
||||
|
||||
wxString tool_tip;
|
||||
file.GetComment( tool_tip);
|
||||
|
||||
CheckBoxHSizers[NumberOfEntry] = new wxBoxSizer(wxHORIZONTAL);
|
||||
CheckBoxes[NumberOfEntry] = new wxCheckBox( this, -1, file_name);
|
||||
CheckBoxes[NumberOfEntry]->SetValue( true);
|
||||
CheckBoxes[NumberOfEntry]->SetToolTip( tool_tip);
|
||||
|
||||
wchar_t button_txt[2];
|
||||
button_txt[0] = 8657;
|
||||
button_txt[1] = 0;
|
||||
CheckButtonUp[NumberOfEntry] = new wxButton( this, ID_Button_Texture+3*NumberOfEntry, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonUp, this, ID_Button_Texture+3*NumberOfEntry);
|
||||
|
||||
button_txt[0] = 8659;
|
||||
CheckButtonDown[NumberOfEntry] = new wxButton( this, ID_Button_Texture+3*NumberOfEntry+1, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDown, this, ID_Button_Texture+3*NumberOfEntry+1);
|
||||
|
||||
CheckButtonDelete[NumberOfEntry] = new wxButton( this, ID_Button_Texture+3*NumberOfEntry+2, L"X", wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDelete, this, ID_Button_Texture+3*NumberOfEntry+2);
|
||||
|
||||
CheckBoxHSizers[NumberOfEntry]->Add( (wxWindow*) CheckBoxes[NumberOfEntry], 1, wxEXPAND, 0);
|
||||
CheckBoxHSizers[NumberOfEntry]->Add( (wxWindow*) CheckButtonUp[NumberOfEntry], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[NumberOfEntry]->Add( (wxWindow*) CheckButtonDown[NumberOfEntry], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[NumberOfEntry]->Add( (wxWindow*) CheckButtonDelete[NumberOfEntry], 0, wxEXPAND, 0);
|
||||
|
||||
MainSizer->Add( CheckBoxHSizers[NumberOfEntry], 0, wxEXPAND, 0);
|
||||
Files.Add( file_name);
|
||||
NumberOfEntry++;
|
||||
MainSizer->Layout();
|
||||
MainSizer->FitInside(this);
|
||||
|
||||
return UpdateGame();
|
||||
}
|
||||
|
||||
int uMod_GamePage::GetSettings(void)
|
||||
{
|
||||
int key_back = ChoiceKeyBack->GetSelection();
|
||||
int key_save = ChoiceKeySave->GetSelection();
|
||||
int key_next = ChoiceKeyNext->GetSelection();
|
||||
|
||||
if (key_back==key_save && key_back!=wxNOT_FOUND) {LastError << Language->Error_KeyTwice; return 1;}
|
||||
if (key_back==key_next && key_back!=wxNOT_FOUND) {LastError << Language->Error_KeyTwice; return 1;}
|
||||
if (key_save==key_next && key_save!=wxNOT_FOUND) {LastError << Language->Error_KeyTwice; return 1;}
|
||||
|
||||
bool save_single = SaveSingleTexture->GetValue();
|
||||
bool save_all = SaveAllTextures->GetValue();
|
||||
wxString path = Game.GetSavePath();
|
||||
if ( (save_single || save_all) && path.Len()==0) {LastError << Language->Error_NoSavePath; return 1;}
|
||||
|
||||
if ( save_single && ( key_back==wxNOT_FOUND || key_save==wxNOT_FOUND || key_next==wxNOT_FOUND) ) {LastError << Language->Error_KeyNotSet; return 1;}
|
||||
|
||||
if (key_back!=wxNOT_FOUND) Game.SetKeyBack(key_back);
|
||||
if (key_save!=wxNOT_FOUND) Game.SetKeySave(key_save);
|
||||
if (key_next!=wxNOT_FOUND) Game.SetKeyNext(key_next);
|
||||
|
||||
Game.SetSaveSingleTexture( save_single);
|
||||
Game.SetSaveAllTextures( save_all);
|
||||
|
||||
int colour[3];
|
||||
colour[0] = GetColour( FontColour[1], 255);
|
||||
colour[1] = GetColour( FontColour[2], 0);
|
||||
colour[2] = GetColour( FontColour[3], 0);
|
||||
SetColour( &FontColour[1], colour);
|
||||
Game.SetFontColour(colour);
|
||||
|
||||
colour[0] = GetColour( TextureColour[1], 0);
|
||||
colour[1] = GetColour( TextureColour[2], 255);
|
||||
colour[2] = GetColour( TextureColour[3], 0);
|
||||
SetColour( &TextureColour[1], colour);
|
||||
Game.SetTextureColour(colour);
|
||||
|
||||
Game.SetFiles( Files);
|
||||
|
||||
bool *checked = NULL;
|
||||
if (GetMemory( checked, NumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
for (int i=0; i<NumberOfEntry; i++) checked[i] = CheckBoxes[i]->GetValue();
|
||||
Game.SetChecked( checked, NumberOfEntry);
|
||||
delete [] checked;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GamePage::UpdateGame(void)
|
||||
{
|
||||
if (int ret = GetSettings()) return ret;
|
||||
|
||||
if (int ret = Sender.Send( Game, GameOld, false))
|
||||
{
|
||||
LastError = Language->Error_Send;
|
||||
LastError << "\n" << Sender.LastError;
|
||||
Sender.LastError.Empty();
|
||||
return ret;
|
||||
}
|
||||
|
||||
GameOld = Game;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_GamePage::ReloadGame(void)
|
||||
{
|
||||
if (int ret = GetSettings()) return ret;
|
||||
|
||||
if (int ret = Sender.Send( Game, GameOld, true))
|
||||
{
|
||||
LastError = Language->Error_Send;
|
||||
LastError << "\n" << Sender.LastError;
|
||||
Sender.LastError.Empty();
|
||||
return ret;
|
||||
}
|
||||
|
||||
GameOld = Game;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GamePage::SaveTemplate( const wxString &file_name)
|
||||
{
|
||||
if (int ret = GetSettings()) return ret;
|
||||
if (int ret = Game.SaveToFile( file_name))
|
||||
{
|
||||
LastError = Language->Error_SaveFile;
|
||||
LastError <<"\n" << file_name;
|
||||
return ret;
|
||||
}
|
||||
TemplateName = file_name;
|
||||
wxString path;
|
||||
path = Language->TextCtrlTemplate;
|
||||
path << TemplateName;
|
||||
TemplateFile->SetValue( path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GamePage::LoadTemplate( const wxString &file_name)
|
||||
{
|
||||
if (Game.LoadFromFile(file_name)) return -1;
|
||||
TemplateName = file_name;
|
||||
wxArrayString comments;
|
||||
|
||||
if (Sender.Send( Game, GameOld, true, &comments)==0) GameOld = Game;
|
||||
|
||||
wxString path;
|
||||
path = Language->TextCtrlTemplate;
|
||||
path << TemplateName;
|
||||
TemplateFile->SetValue( path);
|
||||
|
||||
int key = Game.GetKeyBack();
|
||||
if (key>=0) ChoiceKeyBack->SetSelection( key);
|
||||
key = Game.GetKeySave();
|
||||
if (key>=0) ChoiceKeySave->SetSelection( key);
|
||||
key = Game.GetKeyNext();
|
||||
if (key>=0) ChoiceKeyNext->SetSelection( key);
|
||||
|
||||
int colour[3];
|
||||
Game.GetFontColour( colour);
|
||||
SetColour( &FontColour[1], colour);
|
||||
Game.GetTextureColour( colour);
|
||||
SetColour( &TextureColour[1], colour);
|
||||
|
||||
SaveSingleTexture->SetValue( Game.GetSaveSingleTexture());
|
||||
SaveAllTextures->SetValue( Game.GetSaveAllTextures());
|
||||
|
||||
path = Language->TextCtrlSavePath;
|
||||
path << Game.GetSavePath();
|
||||
SavePath->SetValue( path);
|
||||
|
||||
int new_NumberOfEntry = Game.GetNumberOfFiles();
|
||||
|
||||
Game.GetFiles( Files);
|
||||
|
||||
if (new_NumberOfEntry>=MaxNumberOfEntry)
|
||||
{
|
||||
MaxNumberOfEntry = ((NumberOfEntry/1024)+1)*1024;
|
||||
if (GetMoreMemory( CheckBoxes, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckBoxHSizers, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonUp, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDown, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDelete, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
}
|
||||
|
||||
bool *checked = NULL;
|
||||
if (GetMemory( checked, new_NumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
Game.GetChecked( checked, new_NumberOfEntry);
|
||||
|
||||
|
||||
for (int i=0; i<NumberOfEntry && i<new_NumberOfEntry; i++)
|
||||
{
|
||||
CheckBoxes[i]->SetLabel( Files[i]);
|
||||
CheckBoxes[i]->SetValue( checked[i]);
|
||||
CheckBoxes[i]->SetToolTip( comments[i]);
|
||||
}
|
||||
|
||||
for (int i=new_NumberOfEntry; i<NumberOfEntry; i++)
|
||||
{
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonUp, this, ID_Button_Texture+3*i);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDown, this, ID_Button_Texture+3*i+1);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDelete, this, ID_Button_Texture+3*i+2);
|
||||
|
||||
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckBoxes[i]);
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckButtonUp[i]);
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckButtonDown[i]);
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckButtonDelete[i]);
|
||||
|
||||
MainSizer->Detach( CheckBoxHSizers[i]);
|
||||
|
||||
delete CheckBoxes[i];
|
||||
delete CheckButtonUp[i];
|
||||
delete CheckButtonDown[i];
|
||||
delete CheckButtonDelete[i];
|
||||
delete CheckBoxHSizers[i];
|
||||
}
|
||||
for (int i=NumberOfEntry; i<new_NumberOfEntry; i++)
|
||||
{
|
||||
CheckBoxHSizers[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
CheckBoxes[i] = new wxCheckBox( this, -1, Files[i]);
|
||||
CheckBoxes[i]->SetValue( checked[i]);
|
||||
CheckBoxes[i]->SetToolTip( comments[i]);
|
||||
|
||||
wchar_t button_txt[2];
|
||||
button_txt[0] = 8657;
|
||||
button_txt[1] = 0;
|
||||
|
||||
CheckButtonUp[i] = new wxButton( this, ID_Button_Texture+3*i, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonUp, this, ID_Button_Texture+3*i);
|
||||
|
||||
button_txt[0] = 8659;
|
||||
CheckButtonDown[i] = new wxButton( this, ID_Button_Texture+3*i+1, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDown, this, ID_Button_Texture+3*i+1);
|
||||
|
||||
CheckButtonDelete[i] = new wxButton( this, ID_Button_Texture+3*i+2, L"X", wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDelete, this, ID_Button_Texture+3*i+2);
|
||||
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckBoxes[i], 1, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonUp[i], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonDown[i], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonDelete[i], 0, wxEXPAND, 0);
|
||||
|
||||
MainSizer->Add( CheckBoxHSizers[i], 0, wxEXPAND, 0);
|
||||
}
|
||||
delete [] checked;
|
||||
NumberOfEntry = new_NumberOfEntry;
|
||||
|
||||
MainSizer->Layout();
|
||||
MainSizer->FitInside(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GamePage::SetColour( wxTextCtrl** txt, int *colour)
|
||||
{
|
||||
wxString temp;
|
||||
for (int i=0; i<3; i++)
|
||||
{
|
||||
temp.Empty();
|
||||
temp << colour[i];
|
||||
txt[i]->SetValue( temp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GamePage::GetColour( wxTextCtrl* txt, int def)
|
||||
{
|
||||
wxString temp = txt->GetValue();
|
||||
long colour;
|
||||
if (temp.ToLong(&colour))
|
||||
{
|
||||
if (colour<0) colour=0;
|
||||
else if (colour>255) colour=255;
|
||||
}
|
||||
else colour = def;
|
||||
return colour;
|
||||
}
|
||||
|
||||
|
||||
void uMod_GamePage::OnButtonUp(wxCommandEvent& event)
|
||||
{
|
||||
int id = (event.GetId() - ID_Button_Texture)/3;
|
||||
if (id <=0 || id>= NumberOfEntry) return;
|
||||
|
||||
wxString cpy_str = Files[id];
|
||||
Files[id] = Files[id-1];
|
||||
Files[id-1] = cpy_str;
|
||||
|
||||
CheckBoxes[id]->SetLabel(Files[id]);
|
||||
CheckBoxes[id-1]->SetLabel(Files[id-1]);
|
||||
|
||||
bool cpy_checked = CheckBoxes[id]->GetValue();
|
||||
CheckBoxes[id]->SetValue(CheckBoxes[id-1]->GetValue());
|
||||
CheckBoxes[id-1]->SetValue(cpy_checked);
|
||||
|
||||
cpy_str = CheckBoxes[id]->GetToolTip()->GetTip();
|
||||
wxString cpy_str2 = CheckBoxes[id-1]->GetToolTip()->GetTip();
|
||||
CheckBoxes[id]->SetToolTip(cpy_str2);
|
||||
CheckBoxes[id-1]->SetToolTip(cpy_str);
|
||||
|
||||
}
|
||||
|
||||
void uMod_GamePage::OnButtonDown(wxCommandEvent& event)
|
||||
{
|
||||
int id = (event.GetId() - ID_Button_Texture-1)/3;
|
||||
if (id <0 || id>= NumberOfEntry-1) return;
|
||||
|
||||
wxString cpy_str = Files[id];
|
||||
Files[id] = Files[id+1];
|
||||
Files[id+1] = cpy_str;
|
||||
|
||||
CheckBoxes[id]->SetLabel(Files[id]);
|
||||
CheckBoxes[id+1]->SetLabel(Files[id+1]);
|
||||
|
||||
bool cpy_checked = CheckBoxes[id]->GetValue();
|
||||
CheckBoxes[id]->SetValue(CheckBoxes[id+1]->GetValue());
|
||||
CheckBoxes[id+1]->SetValue(cpy_checked);
|
||||
|
||||
cpy_str = CheckBoxes[id]->GetToolTip()->GetTip();
|
||||
wxString cpy_str2 = CheckBoxes[id+1]->GetToolTip()->GetTip();
|
||||
CheckBoxes[id]->SetToolTip(cpy_str2);
|
||||
CheckBoxes[id+1]->SetToolTip(cpy_str);
|
||||
}
|
||||
|
||||
void uMod_GamePage::OnButtonDelete(wxCommandEvent& event)
|
||||
{
|
||||
int id = (event.GetId() - ID_Button_Texture-2)/3;
|
||||
if (id <0 || id>= NumberOfEntry) return;
|
||||
|
||||
for (int i=id+1; i<NumberOfEntry; i++) CheckBoxes[i-1]->SetLabel(Files[i]);
|
||||
for (int i=id+1; i<NumberOfEntry; i++) CheckBoxes[i-1]->SetValue(CheckBoxes[i]->GetValue());
|
||||
wxString cpy_str;
|
||||
for (int i=id+1; i<NumberOfEntry; i++)
|
||||
{
|
||||
cpy_str = CheckBoxes[i]->GetToolTip()->GetTip();
|
||||
CheckBoxes[i-1]->SetToolTip(cpy_str);
|
||||
}
|
||||
|
||||
Files.RemoveAt(id, 1);
|
||||
NumberOfEntry--;
|
||||
|
||||
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonUp, this, ID_Button_Texture+3*NumberOfEntry);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDown, this, ID_Button_Texture+3*NumberOfEntry+1);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &uMod_GamePage::OnButtonDelete, this, ID_Button_Texture+3*NumberOfEntry+2);
|
||||
|
||||
|
||||
CheckBoxHSizers[NumberOfEntry]->Detach( (wxWindow*) CheckBoxes[NumberOfEntry]);
|
||||
CheckBoxHSizers[NumberOfEntry]->Detach( (wxWindow*) CheckButtonUp[NumberOfEntry]);
|
||||
CheckBoxHSizers[NumberOfEntry]->Detach( (wxWindow*) CheckButtonDown[NumberOfEntry]);
|
||||
CheckBoxHSizers[NumberOfEntry]->Detach( (wxWindow*) CheckButtonDelete[NumberOfEntry]);
|
||||
|
||||
MainSizer->Detach( CheckBoxHSizers[NumberOfEntry]);
|
||||
|
||||
delete CheckBoxes[NumberOfEntry];
|
||||
delete CheckButtonUp[NumberOfEntry];
|
||||
delete CheckButtonDown[NumberOfEntry];
|
||||
delete CheckButtonDelete[NumberOfEntry];
|
||||
delete CheckBoxHSizers[NumberOfEntry];
|
||||
}
|
||||
|
||||
|
||||
int uMod_GamePage::UpdateLanguage(void)
|
||||
{
|
||||
TextKeyBack->SetValue( Language->KeyBack);
|
||||
TextKeySave->SetValue( Language->KeySave);
|
||||
TextKeyNext->SetValue( Language->KeyNext);
|
||||
FontColour[0]->SetValue( Language->FontColour);
|
||||
TextureColour[0]->SetValue( Language->TextureColour);
|
||||
SaveAllTextures->SetLabel( Language->CheckBoxSaveAllTextures);
|
||||
SaveSingleTexture->SetLabel( Language->CheckBoxSaveSingleTexture);
|
||||
wxString temp = Language->TextCtrlSavePath;
|
||||
temp << Game.GetSavePath();
|
||||
SavePath->SetValue( temp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_GAMEPAGE_H_
|
||||
#define uMod_GAMEPAGE_H_
|
||||
#include "uMod_Main.h"
|
||||
|
||||
// this page is opened if a game is started.
|
||||
class uMod_GamePage : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
uMod_GamePage( wxNotebook *parent, const wxString &exe, const wxString &save, PipeStruct &pipe);
|
||||
virtual ~uMod_GamePage(void);
|
||||
|
||||
int AddTexture( const wxString &file_name);
|
||||
|
||||
int UpdateGame(void);
|
||||
int ReloadGame(void);
|
||||
|
||||
int SaveTemplate( const wxString &file_name);
|
||||
int LoadTemplate( const wxString &file_name);
|
||||
|
||||
wxString GetExeName(void) {return ExeName;}
|
||||
wxString GetTemplateName(void) {return TemplateName;}
|
||||
|
||||
int SetOpenPath(const wxString &path) {return Game.SetOpenPath(path);}
|
||||
wxString GetOpenPath(void) {return Game.GetOpenPath();}
|
||||
|
||||
int SetSavePath(const wxString &path);
|
||||
wxString GetSavePath(void) {return Game.GetSavePath();}
|
||||
|
||||
|
||||
void OnButtonUp(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonDown(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonDelete(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
int UpdateLanguage(void);
|
||||
|
||||
wxString LastError;
|
||||
|
||||
private:
|
||||
|
||||
int GetSettings(void);
|
||||
int SetColour( wxTextCtrl** txt, int *colour);
|
||||
int GetColour( wxTextCtrl* txt, int def);
|
||||
|
||||
wxString ExeName;
|
||||
wxString TemplateName;
|
||||
|
||||
wxBoxSizer *SizerKeys[2];
|
||||
wxTextCtrl *TextKeyBack;
|
||||
wxTextCtrl *TextKeySave;
|
||||
wxTextCtrl *TextKeyNext;
|
||||
wxChoice *ChoiceKeyBack;
|
||||
wxChoice *ChoiceKeySave;
|
||||
wxChoice *ChoiceKeyNext;
|
||||
|
||||
wxBoxSizer *FontColourSizer;
|
||||
wxTextCtrl *FontColour[4];
|
||||
wxBoxSizer *TextureColourSizer;
|
||||
wxTextCtrl *TextureColour[4];
|
||||
|
||||
wxBoxSizer *MainSizer;
|
||||
|
||||
wxTextCtrl *TemplateFile;
|
||||
wxCheckBox *SaveAllTextures;
|
||||
wxCheckBox *SaveSingleTexture;
|
||||
wxTextCtrl *SavePath;
|
||||
|
||||
wxBoxSizer **CheckBoxHSizers;
|
||||
wxButton **CheckButtonUp;
|
||||
wxButton **CheckButtonDown;
|
||||
wxButton **CheckButtonDelete;
|
||||
|
||||
wxCheckBox **CheckBoxes;
|
||||
int NumberOfEntry;
|
||||
int MaxNumberOfEntry;
|
||||
|
||||
|
||||
wxArrayString Files;
|
||||
uMod_GameInfo Game;
|
||||
uMod_GameInfo GameOld;
|
||||
|
||||
uMod_Sender Sender;
|
||||
|
||||
|
||||
//DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif /* uMod_GAMEPAGE_H_ */
|
||||
@@ -1,727 +0,0 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
uMod_Language *Language = NULL;
|
||||
|
||||
uMod_Language::uMod_Language(void)
|
||||
{
|
||||
LoadDefault();
|
||||
LoadKeys();
|
||||
}
|
||||
|
||||
uMod_Language::uMod_Language(const wxString &name)
|
||||
{
|
||||
LoadLanguage(name);
|
||||
LoadKeys();
|
||||
LastError.Empty();
|
||||
}
|
||||
|
||||
|
||||
int uMod_Language::GetLanguages(wxArrayString &lang)
|
||||
{
|
||||
wxArrayString files;
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/languages";
|
||||
wxDir::GetAllFiles( dir, &files, "uMod_LanguagePack_*.txt");
|
||||
wxDir::GetAllFiles( dir, &files, "uMod_LanguagePackU_*.txt");
|
||||
lang.Empty();
|
||||
lang.Alloc(files.GetCount()+1);
|
||||
lang.Add("English");
|
||||
|
||||
wxString temp;
|
||||
int num = files.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
temp = files[i];
|
||||
temp = temp.AfterLast('\\');
|
||||
temp = temp.AfterFirst('_');
|
||||
temp = temp.AfterFirst('_');
|
||||
temp = temp.BeforeLast('.');
|
||||
lang.Add(temp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_Language::GetHelpMessage(wxString &help)
|
||||
{
|
||||
wxString file;
|
||||
file << "README_" << CurrentLanguage << ".txt";
|
||||
|
||||
wxFile dat;
|
||||
bool utf16=false;
|
||||
if (!dat.Access(file, wxFile::read))
|
||||
{
|
||||
file.Empty();
|
||||
file << "READMEU_" << CurrentLanguage << ".txt";
|
||||
utf16=true;
|
||||
if (!dat.Access(file, wxFile::read))
|
||||
{
|
||||
utf16=false;
|
||||
file = "README_English.txt";
|
||||
if (!dat.Access(file, wxFile::read)) {LastError << Error_FileOpen <<"\n" << file; return -1;}
|
||||
}
|
||||
}
|
||||
dat.Open(file, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Error_FileOpen <<"\n" << file; return -1;}
|
||||
unsigned len = dat.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = dat.Read( buffer, len);
|
||||
dat.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Error_FileRead<<"\n" << file; return -1;}
|
||||
|
||||
if (utf16)
|
||||
{
|
||||
wchar_t *buf = (wchar_t*) buffer;
|
||||
len/=2;
|
||||
buf[len]=0;
|
||||
help=buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[len]=0;
|
||||
help=buffer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define CheckEntry( command, msg, target) \
|
||||
if ( command == #target ) \
|
||||
{ \
|
||||
target = msg; \
|
||||
} else
|
||||
|
||||
int uMod_Language::LoadLanguage(const wxString &name)
|
||||
{
|
||||
LoadDefault();
|
||||
if (name=="English") return 0;
|
||||
|
||||
wxString file_name;
|
||||
file_name << "languages/uMod_LanguagePack_" << name << ".txt";
|
||||
|
||||
bool utf16=false;
|
||||
wxFile dat;
|
||||
if (!dat.Access(file_name, wxFile::read))
|
||||
{
|
||||
utf16=true;
|
||||
file_name.Empty();
|
||||
file_name << "languages/uMod_LanguagePackU_" << name << ".txt";
|
||||
if (!dat.Access(file_name, wxFile::read)){LastError << Error_FileOpen <<"\n" << file_name; return -1;}
|
||||
}
|
||||
dat.Open(file_name, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Error_FileOpen <<"\n" << file_name; return -1;}
|
||||
unsigned len = dat.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = dat.Read( buffer, len);
|
||||
dat.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Error_FileRead<<"\n" << file_name; return -1;}
|
||||
|
||||
CurrentLanguage = name;
|
||||
wxString content;
|
||||
|
||||
if (utf16)
|
||||
{
|
||||
wchar_t *buf = (wchar_t*) buffer;
|
||||
len/=2;
|
||||
buf[len]=0;
|
||||
if (buf[0]==0XFEFF || buf[0]==0XFFFE) content=&buf[1]; //get rid of the BOM
|
||||
else content=buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[len]=0;
|
||||
content = buffer;
|
||||
}
|
||||
|
||||
wxStringTokenizer token( content, "|");
|
||||
int num = token.CountTokens();
|
||||
wxString entry;
|
||||
wxString command;
|
||||
wxString msg;
|
||||
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
entry = token.GetNextToken();
|
||||
if (entry[0]=='#') continue;
|
||||
command = entry.BeforeFirst(':');
|
||||
command.Replace( "\r", "");
|
||||
command.Replace( "\n", "");
|
||||
msg = entry.AfterFirst(':');
|
||||
|
||||
while (msg[0]=='\r' || msg[0]=='\n') msg.Remove(0,1);
|
||||
while (msg.Last()=='\n' || msg.Last()=='\r') msg.RemoveLast(1);
|
||||
|
||||
CheckEntry( command, msg, MenuLanguage)
|
||||
CheckEntry( command, msg, MenuHelp)
|
||||
CheckEntry( command, msg, MenuAbout)
|
||||
CheckEntry( command, msg, MenuAcknowledgement)
|
||||
CheckEntry( command, msg, MenuStartGame)
|
||||
CheckEntry( command, msg, MenuStartGameCMD)
|
||||
CheckEntry( command, msg, MenuUseHook)
|
||||
CheckEntry( command, msg, MenuAddGame)
|
||||
CheckEntry( command, msg, MenuDeleteGame)
|
||||
CheckEntry( command, msg, MenuLoadTemplate)
|
||||
CheckEntry( command, msg, MenuSaveTemplate)
|
||||
CheckEntry( command, msg, MenuSaveTemplateAs)
|
||||
CheckEntry( command, msg, MenuSetDefaultTemplate)
|
||||
CheckEntry( command, msg, MenuExit)
|
||||
CheckEntry( command, msg, MainMenuMain)
|
||||
CheckEntry( command, msg, MainMenuHelp)
|
||||
CheckEntry( command, msg, ButtonOpen)
|
||||
CheckEntry( command, msg, ButtonDirectory)
|
||||
CheckEntry( command, msg, ButtonUpdate)
|
||||
CheckEntry( command, msg, ButtonReload)
|
||||
CheckEntry( command, msg, ChooseFile)
|
||||
CheckEntry( command, msg, ChooseDir)
|
||||
CheckEntry( command, msg, TextCtrlTemplate)
|
||||
CheckEntry( command, msg, CheckBoxSaveSingleTexture)
|
||||
CheckEntry( command, msg, CheckBoxSaveAllTextures)
|
||||
CheckEntry( command, msg, TextCtrlSavePath)
|
||||
CheckEntry( command, msg, SelectLanguage)
|
||||
CheckEntry( command, msg, StartGame)
|
||||
CheckEntry( command, msg, CommandLine)
|
||||
CheckEntry( command, msg, ChooseGame)
|
||||
CheckEntry( command, msg, DeleteGame)
|
||||
CheckEntry( command, msg, GameAlreadyAdded)
|
||||
CheckEntry( command, msg, ExitGameAnyway)
|
||||
CheckEntry( command, msg, NoComment)
|
||||
CheckEntry( command, msg, Author)
|
||||
CheckEntry( command, msg, Error_GameIsHooked)
|
||||
CheckEntry( command, msg, Error_ProcessNotStarted)
|
||||
CheckEntry( command, msg, Error_RemoveHook)
|
||||
CheckEntry( command, msg, Error_FileNotSupported)
|
||||
CheckEntry( command, msg, Error_FktNotFound)
|
||||
CheckEntry( command, msg, Error_D3DX9NotFound)
|
||||
CheckEntry( command, msg, Error_DLLNotFound)
|
||||
CheckEntry( command, msg, Error_AlreadyRunning)
|
||||
CheckEntry( command, msg, Error_Send)
|
||||
CheckEntry( command, msg, Error_KeyTwice)
|
||||
CheckEntry( command, msg, Error_NoSavePath)
|
||||
CheckEntry( command, msg, Error_KeyNotSet)
|
||||
CheckEntry( command, msg, Error_SaveFile)
|
||||
CheckEntry( command, msg, Error_NoPipe)
|
||||
CheckEntry( command, msg, Error_WritePipe)
|
||||
CheckEntry( command, msg, Error_FlushPipe)
|
||||
CheckEntry( command, msg, Error_Hash)
|
||||
CheckEntry( command, msg, Error_FileOpen)
|
||||
CheckEntry( command, msg, Error_FileRead)
|
||||
CheckEntry( command, msg, Error_Memory)
|
||||
CheckEntry( command, msg, Error_Unzip)
|
||||
CheckEntry( command, msg, Error_ZipEntry)
|
||||
CheckEntry( command, msg, KeyBack)
|
||||
CheckEntry( command, msg, KeySave)
|
||||
CheckEntry( command, msg, KeyNext)
|
||||
CheckEntry( command, msg, FontColour)
|
||||
CheckEntry( command, msg, TextureColour)
|
||||
{}
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
return 0;
|
||||
}
|
||||
#undef CheckEntry
|
||||
|
||||
|
||||
int uMod_Language::LoadDefault(void)
|
||||
{
|
||||
CurrentLanguage="English";
|
||||
|
||||
MenuLanguage = "Change language";
|
||||
MenuHelp = "Help";
|
||||
MenuAbout = "About";
|
||||
MenuAcknowledgement = "Acknowledgement";
|
||||
|
||||
MenuStartGame = "Start game through uMod";
|
||||
MenuStartGameCMD = "Start game through uMod (with command line)";
|
||||
|
||||
MenuUseHook = "Use global hook";
|
||||
MenuAddGame = "Add game";
|
||||
MenuDeleteGame = "Delete game";
|
||||
MenuLoadTemplate = "Load template";
|
||||
MenuSaveTemplate = "Save template";
|
||||
MenuSaveTemplateAs = "Save template as ...";
|
||||
MenuSetDefaultTemplate = "Set template as default";
|
||||
MenuExit = "Exit";
|
||||
|
||||
MainMenuMain = "Main";
|
||||
MainMenuHelp = "Help";
|
||||
|
||||
ButtonOpen = "Open texture/package";
|
||||
ButtonDirectory = "Set save directory";
|
||||
ButtonUpdate = "Update";
|
||||
ButtonReload = "Update (reload)";
|
||||
|
||||
ChooseFile = "Choose a file";
|
||||
ChooseDir = "Choose a directory";
|
||||
|
||||
TextCtrlTemplate = "Template: ";
|
||||
CheckBoxSaveSingleTexture = "Save single texture";
|
||||
CheckBoxSaveAllTextures = "Save all textures";
|
||||
TextCtrlSavePath = "Save path:";
|
||||
|
||||
SelectLanguage = "Select a language.";
|
||||
|
||||
StartGame = "Select the game to start.";
|
||||
CommandLine = "Set command line arguments.";
|
||||
|
||||
ChooseGame = "Select a game binary.";
|
||||
DeleteGame = "Select the games to be deleted.";
|
||||
GameAlreadyAdded = "Game has been already added.";
|
||||
ExitGameAnyway = "Closing OpenTexMod while a game is running might lead to a crash of the game.\nExit anyway?";
|
||||
NoComment = "No comment.";
|
||||
Author = "Author: ";
|
||||
|
||||
Error_GameIsHooked = "The global hook is active and this game will be injected! Please delete the game from the list or disable the hook.";
|
||||
Error_ProcessNotStarted = "The game could not be started.";
|
||||
Error_RemoveHook = "Removing the Hook while a game is running might lead to crash.";
|
||||
|
||||
Error_FileNotSupported = "This file type is not supported:\n";
|
||||
Error_D3DX9NotFound = "The D3DX9_43.dll (32bit) is not available on your system.\nPlease install the newest DirectX End-User Runtime Installer.";
|
||||
Error_DLLNotFound = "Could not load the dll.\nThe dll injection won't work.\nThis might happen if D3DX9_43.dll (32bit) is not installed on your system.\nPlease install the newest DirectX End-User Runtime Web Installer.";
|
||||
Error_FktNotFound = "Could not load function out of dll.\nThe dll injection won't work.";
|
||||
Error_AlreadyRunning = "An other instance of OpenTexMod is already running.";
|
||||
|
||||
Error_Send = "Could not send to game.";
|
||||
Error_KeyTwice = "You have assigned the same key twice.";
|
||||
Error_NoSavePath = "You did not set a save path.";
|
||||
Error_KeyNotSet = "At least one key is not set.";
|
||||
Error_SaveFile = "Could not save to file.";
|
||||
Error_NoPipe = "Pipe is not opened.";
|
||||
Error_WritePipe = "Could not write in pipe.";
|
||||
Error_FlushPipe = "Could not flush pipe buffer.";
|
||||
Error_Hash = "Could not find hash, maybe file is not named as *_HASH.dds";
|
||||
Error_FileOpen = "Could not open file:";
|
||||
Error_FileRead = "Could not read file:";
|
||||
Error_Memory = "Could not allocate enough memory.";
|
||||
Error_Unzip = "Could not unzip.";
|
||||
Error_ZipEntry = "Could not find zip entry.";
|
||||
|
||||
|
||||
KeyBack = "Back";
|
||||
KeySave = "Save";
|
||||
KeyNext = "Next";
|
||||
|
||||
|
||||
FontColour = "Font colour (RGB):";
|
||||
TextureColour = "Texture colour (RGB):";
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define AddKey( name, key ) \
|
||||
{ \
|
||||
KeyStrings.Add( name ); \
|
||||
KeyValues.Add( key ); \
|
||||
}
|
||||
int uMod_Language::LoadKeys(void)
|
||||
{
|
||||
KeyStrings.Empty();
|
||||
KeyValues.Empty();
|
||||
/*
|
||||
|
||||
#define VK_LBUTTON 0x01
|
||||
#define VK_RBUTTON 0x02
|
||||
#define VK_CANCEL 0x03
|
||||
#define VK_MBUTTON 0x04 // NOT contiguous with L & RBUTTON
|
||||
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define VK_XBUTTON1 0x05 // NOT contiguous with L & RBUTTON
|
||||
#define VK_XBUTTON2 0x06 // NOT contiguous with L & RBUTTON
|
||||
#endif // _WIN32_WINNT >= 0x0500
|
||||
|
||||
|
||||
// * 0x07 : unassigned
|
||||
|
||||
*/
|
||||
AddKey( "VK_BACK", VK_BACK );
|
||||
AddKey( "VK_TAB", VK_TAB );
|
||||
AddKey( "VK_CLEAR", VK_CLEAR );
|
||||
AddKey( "VK_RETURN", VK_RETURN );
|
||||
AddKey( "VK_SHIFT", VK_SHIFT );
|
||||
AddKey( "VK_CONTROL", VK_CONTROL );
|
||||
AddKey( "VK_MENU", VK_MENU );
|
||||
AddKey( "VK_PAUSE", VK_PAUSE );
|
||||
AddKey( "VK_CAPITAL", VK_CAPITAL );
|
||||
//AddKey( );
|
||||
//AddKey( );
|
||||
//AddKey( );
|
||||
//AddKey( );
|
||||
/*
|
||||
#define VK_BACK 0x08
|
||||
#define VK_TAB 0x09
|
||||
|
||||
|
||||
// 0x0A - 0x0B : reserved
|
||||
|
||||
|
||||
#define VK_CLEAR 0x0C
|
||||
#define VK_RETURN 0x0D
|
||||
|
||||
#define VK_SHIFT 0x10
|
||||
#define VK_CONTROL 0x11
|
||||
#define VK_MENU 0x12
|
||||
#define VK_PAUSE 0x13
|
||||
#define VK_CAPITAL 0x14
|
||||
|
||||
#define VK_KANA 0x15
|
||||
#define VK_HANGEUL 0x15 // old name - should be here for compatibility
|
||||
#define VK_HANGUL 0x15
|
||||
#define VK_JUNJA 0x17
|
||||
#define VK_FINAL 0x18
|
||||
#define VK_HANJA 0x19
|
||||
#define VK_KANJI 0x19
|
||||
|
||||
*/
|
||||
|
||||
AddKey( "VK_ESCAPE", VK_ESCAPE );
|
||||
/*
|
||||
#define VK_ESCAPE 0x1B
|
||||
|
||||
#define VK_CONVERT 0x1C
|
||||
#define VK_NONCONVERT 0x1D
|
||||
#define VK_ACCEPT 0x1E
|
||||
#define VK_MODECHANGE 0x1F
|
||||
*/
|
||||
|
||||
AddKey( "VK_SPACE", VK_SPACE );
|
||||
AddKey( "VK_PRIOR", VK_PRIOR );
|
||||
AddKey( "VK_NEXT", VK_NEXT );
|
||||
AddKey( "VK_END", VK_END );
|
||||
AddKey( "VK_HOME", VK_HOME );
|
||||
AddKey( "VK_LEFT", VK_LEFT );
|
||||
AddKey( "VK_UP", VK_UP );
|
||||
AddKey( "VK_RIGHT", VK_RIGHT );
|
||||
AddKey( "VK_DOWN", VK_DOWN );
|
||||
AddKey( "VK_SELECT", VK_SELECT );
|
||||
AddKey( "VK_PRINT", VK_PRINT );
|
||||
AddKey( "VK_EXECUTE", VK_EXECUTE );
|
||||
AddKey( "VK_SNAPSHOT", VK_SNAPSHOT );
|
||||
AddKey( "VK_INSERT", VK_INSERT );
|
||||
AddKey( "VK_DELETE", VK_DELETE );
|
||||
AddKey( "VK_HELP", VK_HELP );
|
||||
/*
|
||||
#define VK_SPACE 0x20
|
||||
#define VK_PRIOR 0x21
|
||||
#define VK_NEXT 0x22
|
||||
#define VK_END 0x23
|
||||
#define VK_HOME 0x24
|
||||
#define VK_LEFT 0x25
|
||||
#define VK_UP 0x26
|
||||
#define VK_RIGHT 0x27
|
||||
#define VK_DOWN 0x28
|
||||
#define VK_SELECT 0x29
|
||||
#define VK_PRINT 0x2A
|
||||
#define VK_EXECUTE 0x2B
|
||||
#define VK_SNAPSHOT 0x2C
|
||||
#define VK_INSERT 0x2D
|
||||
#define VK_DELETE 0x2E
|
||||
#define VK_HELP 0x2F
|
||||
|
||||
|
||||
// * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
|
||||
// * 0x40 : unassigned
|
||||
// * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
|
||||
*/
|
||||
int count = 0x30;
|
||||
AddKey( "0", count++);
|
||||
AddKey( "1", count++);
|
||||
AddKey( "2", count++);
|
||||
AddKey( "3", count++);
|
||||
AddKey( "4", count++);
|
||||
AddKey( "5", count++);
|
||||
AddKey( "6", count++);
|
||||
AddKey( "7", count++);
|
||||
AddKey( "8", count++);
|
||||
AddKey( "9", count++);
|
||||
|
||||
count = 0x41;
|
||||
AddKey( "a", count++);
|
||||
AddKey( "b", count++);
|
||||
AddKey( "c", count++);
|
||||
AddKey( "d", count++);
|
||||
AddKey( "e", count++);
|
||||
AddKey( "f", count++);
|
||||
AddKey( "g", count++);
|
||||
AddKey( "h", count++);
|
||||
AddKey( "i", count++);
|
||||
AddKey( "j", count++);
|
||||
AddKey( "k", count++);
|
||||
AddKey( "l", count++);
|
||||
AddKey( "m", count++);
|
||||
AddKey( "n", count++);
|
||||
AddKey( "o", count++);
|
||||
AddKey( "p", count++);
|
||||
AddKey( "q", count++);
|
||||
AddKey( "r", count++);
|
||||
AddKey( "s", count++);
|
||||
AddKey( "t", count++);
|
||||
AddKey( "u", count++);
|
||||
AddKey( "v", count++);
|
||||
AddKey( "w", count++);
|
||||
AddKey( "x", count++);
|
||||
AddKey( "y", count++);
|
||||
AddKey( "z", count++);
|
||||
|
||||
/*
|
||||
|
||||
#define VK_LWIN 0x5B
|
||||
#define VK_RWIN 0x5C
|
||||
#define VK_APPS 0x5D
|
||||
|
||||
|
||||
// 0x5E : reserved
|
||||
*/
|
||||
|
||||
|
||||
AddKey( "VK_SLEEP", VK_SLEEP );
|
||||
AddKey( "VK_NUMPAD0", VK_NUMPAD0 );
|
||||
AddKey( "VK_NUMPAD1", VK_NUMPAD1 );
|
||||
AddKey( "VK_NUMPAD2", VK_NUMPAD2 );
|
||||
AddKey( "VK_NUMPAD3", VK_NUMPAD3 );
|
||||
AddKey( "VK_NUMPAD4", VK_NUMPAD4 );
|
||||
AddKey( "VK_NUMPAD5", VK_NUMPAD5 );
|
||||
AddKey( "VK_NUMPAD6", VK_NUMPAD6 );
|
||||
AddKey( "VK_NUMPAD7", VK_NUMPAD7 );
|
||||
AddKey( "VK_NUMPAD8", VK_NUMPAD8 );
|
||||
AddKey( "VK_NUMPAD9", VK_NUMPAD9 );
|
||||
AddKey( "VK_MULTIPLY", VK_MULTIPLY );
|
||||
AddKey( "VK_ADD", VK_ADD );
|
||||
AddKey( "VK_SEPARATOR", VK_SEPARATOR );
|
||||
AddKey( "VK_SUBTRACT", VK_SUBTRACT );
|
||||
AddKey( "VK_DECIMAL", VK_DECIMAL );
|
||||
AddKey( "VK_DIVIDE", VK_DIVIDE );
|
||||
AddKey( "VK_F1", VK_F1 );
|
||||
AddKey( "VK_F2", VK_F2 );
|
||||
AddKey( "VK_F3", VK_F3 );
|
||||
AddKey( "VK_F4", VK_F4 );
|
||||
AddKey( "VK_F5", VK_F5 );
|
||||
AddKey( "VK_F6", VK_F6 );
|
||||
AddKey( "VK_F7", VK_F7 );
|
||||
AddKey( "VK_F8", VK_F8 );
|
||||
AddKey( "VK_F9", VK_F9 );
|
||||
AddKey( "VK_F10", VK_F10 );
|
||||
AddKey( "VK_F12", VK_F12 );
|
||||
AddKey( "VK_F12", VK_F12 );
|
||||
|
||||
/*
|
||||
|
||||
#define VK_SLEEP 0x5F
|
||||
|
||||
#define VK_NUMPAD0 0x60
|
||||
#define VK_NUMPAD1 0x61
|
||||
#define VK_NUMPAD2 0x62
|
||||
#define VK_NUMPAD3 0x63
|
||||
#define VK_NUMPAD4 0x64
|
||||
#define VK_NUMPAD5 0x65
|
||||
#define VK_NUMPAD6 0x66
|
||||
#define VK_NUMPAD7 0x67
|
||||
#define VK_NUMPAD8 0x68
|
||||
#define VK_NUMPAD9 0x69
|
||||
#define VK_MULTIPLY 0x6A
|
||||
#define VK_ADD 0x6B
|
||||
#define VK_SEPARATOR 0x6C
|
||||
#define VK_SUBTRACT 0x6D
|
||||
#define VK_DECIMAL 0x6E
|
||||
#define VK_DIVIDE 0x6F
|
||||
#define VK_F1 0x70
|
||||
#define VK_F2 0x71
|
||||
#define VK_F3 0x72
|
||||
#define VK_F4 0x73
|
||||
#define VK_F5 0x74
|
||||
#define VK_F6 0x75
|
||||
#define VK_F7 0x76
|
||||
#define VK_F8 0x77
|
||||
#define VK_F9 0x78
|
||||
#define VK_F10 0x79
|
||||
#define VK_F11 0x7A
|
||||
#define VK_F12 0x7B
|
||||
#define VK_F13 0x7C
|
||||
#define VK_F14 0x7D
|
||||
#define VK_F15 0x7E
|
||||
#define VK_F16 0x7F
|
||||
#define VK_F17 0x80
|
||||
#define VK_F18 0x81
|
||||
#define VK_F19 0x82
|
||||
#define VK_F20 0x83
|
||||
#define VK_F21 0x84
|
||||
#define VK_F22 0x85
|
||||
#define VK_F23 0x86
|
||||
#define VK_F24 0x87
|
||||
|
||||
|
||||
// 0x88 - 0x8F : unassigned
|
||||
*/
|
||||
|
||||
AddKey( "VK_NUMLOCK", VK_NUMLOCK );
|
||||
AddKey( "VK_SCROLL", VK_SCROLL );
|
||||
/*
|
||||
|
||||
#define VK_NUMLOCK 0x90
|
||||
#define VK_SCROLL 0x91
|
||||
|
||||
|
||||
// NEC PC-9800 kbd definitions
|
||||
|
||||
#define VK_OEM_NEC_EQUAL 0x92 // '=' key on numpad
|
||||
|
||||
|
||||
// Fujitsu/OASYS kbd definitions
|
||||
|
||||
#define VK_OEM_FJ_JISHO 0x92 // 'Dictionary' key
|
||||
#define VK_OEM_FJ_MASSHOU 0x93 // 'Unregister word' key
|
||||
#define VK_OEM_FJ_TOUROKU 0x94 // 'Register word' key
|
||||
#define VK_OEM_FJ_LOYA 0x95 // 'Left OYAYUBI' key
|
||||
#define VK_OEM_FJ_ROYA 0x96 // 'Right OYAYUBI' key
|
||||
|
||||
//
|
||||
// 0x97 - 0x9F : unassigned
|
||||
//
|
||||
|
||||
//
|
||||
// VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
|
||||
// Used only as parameters to GetAsyncKeyState() and GetKeyState().
|
||||
// No other API or message will distinguish left and right keys in this way.
|
||||
|
||||
#define VK_LSHIFT 0xA0
|
||||
#define VK_RSHIFT 0xA1
|
||||
#define VK_LCONTROL 0xA2
|
||||
#define VK_RCONTROL 0xA3
|
||||
#define VK_LMENU 0xA4
|
||||
#define VK_RMENU 0xA5
|
||||
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define VK_BROWSER_BACK 0xA6
|
||||
#define VK_BROWSER_FORWARD 0xA7
|
||||
#define VK_BROWSER_REFRESH 0xA8
|
||||
#define VK_BROWSER_STOP 0xA9
|
||||
#define VK_BROWSER_SEARCH 0xAA
|
||||
#define VK_BROWSER_FAVORITES 0xAB
|
||||
#define VK_BROWSER_HOME 0xAC
|
||||
|
||||
#define VK_VOLUME_MUTE 0xAD
|
||||
#define VK_VOLUME_DOWN 0xAE
|
||||
#define VK_VOLUME_UP 0xAF
|
||||
#define VK_MEDIA_NEXT_TRACK 0xB0
|
||||
#define VK_MEDIA_PREV_TRACK 0xB1
|
||||
#define VK_MEDIA_STOP 0xB2
|
||||
#define VK_MEDIA_PLAY_PAUSE 0xB3
|
||||
#define VK_LAUNCH_MAIL 0xB4
|
||||
#define VK_LAUNCH_MEDIA_SELECT 0xB5
|
||||
#define VK_LAUNCH_APP1 0xB6
|
||||
#define VK_LAUNCH_APP2 0xB7
|
||||
|
||||
#endif // _WIN32_WINNT >= 0x0500
|
||||
|
||||
|
||||
// 0xB8 - 0xB9 : reserved
|
||||
|
||||
|
||||
#define VK_OEM_1 0xBA // ';:' for US
|
||||
#define VK_OEM_PLUS 0xBB // '+' any country
|
||||
#define VK_OEM_COMMA 0xBC // ',' any country
|
||||
#define VK_OEM_MINUS 0xBD // '-' any country
|
||||
#define VK_OEM_PERIOD 0xBE // '.' any country
|
||||
#define VK_OEM_2 0xBF // '/?' for US
|
||||
#define VK_OEM_3 0xC0 // '`~' for US
|
||||
|
||||
|
||||
// 0xC1 - 0xD7 : reserved
|
||||
|
||||
|
||||
// 0xD8 - 0xDA : unassigned
|
||||
|
||||
|
||||
#define VK_OEM_4 0xDB // '[{' for US
|
||||
#define VK_OEM_5 0xDC // '\|' for US
|
||||
#define VK_OEM_6 0xDD // ']}' for US
|
||||
#define VK_OEM_7 0xDE // ''"' for US
|
||||
#define VK_OEM_8 0xDF
|
||||
|
||||
|
||||
// 0xE0 : reserved
|
||||
|
||||
|
||||
/
|
||||
// Various extended or enhanced keyboards
|
||||
|
||||
#define VK_OEM_AX 0xE1 // 'AX' key on Japanese AX kbd
|
||||
#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd.
|
||||
#define VK_ICO_HELP 0xE3 // Help key on ICO
|
||||
#define VK_ICO_00 0xE4 // 00 key on ICO
|
||||
|
||||
#if(WINVER >= 0x0400)
|
||||
#define VK_PROCESSKEY 0xE5
|
||||
#endif // WINVER >= 0x0400
|
||||
|
||||
#define VK_ICO_CLEAR 0xE6
|
||||
|
||||
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define VK_PACKET 0xE7
|
||||
#endif // _WIN32_WINNT >= 0x0500
|
||||
|
||||
|
||||
// 0xE8 : unassigned
|
||||
|
||||
|
||||
//Nokia/Ericsson definitions
|
||||
|
||||
#define VK_OEM_RESET 0xE9
|
||||
#define VK_OEM_JUMP 0xEA
|
||||
#define VK_OEM_PA1 0xEB
|
||||
#define VK_OEM_PA2 0xEC
|
||||
#define VK_OEM_PA3 0xED
|
||||
#define VK_OEM_WSCTRL 0xEE
|
||||
#define VK_OEM_CUSEL 0xEF
|
||||
#define VK_OEM_ATTN 0xF0
|
||||
#define VK_OEM_FINISH 0xF1
|
||||
#define VK_OEM_COPY 0xF2
|
||||
#define VK_OEM_AUTO 0xF3
|
||||
#define VK_OEM_ENLW 0xF4
|
||||
#define VK_OEM_BACKTAB 0xF5
|
||||
|
||||
#define VK_ATTN 0xF6
|
||||
#define VK_CRSEL 0xF7
|
||||
#define VK_EXSEL 0xF8
|
||||
#define VK_EREOF 0xF9
|
||||
#define VK_PLAY 0xFA
|
||||
#define VK_ZOOM 0xFB
|
||||
#define VK_NONAME 0xFC
|
||||
#define VK_PA1 0xFD
|
||||
#define VK_OEM_CLEAR 0xFE
|
||||
|
||||
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user