Compare commits

...

540 Commits

Author SHA1 Message Date
njohnson
91a79f78cc Refactor: Improve file handling for opening files. 2025-09-15 18:52:21 -04:00
njohnson
8d5e5812ec Refactor: Updated compression functions for LZX format. 2025-09-15 18:52:05 -04:00
njohnson
622323117a Refactor: Improved encryption library performance and stability. 2025-09-15 18:51:45 -04:00
njohnson
2fdbe74a4a Refactor: Update decompression logic for WiiU platform. 2025-09-15 18:51:28 -04:00
njohnson
13af32ed2d Refactor: Improve fastfile decoding. 2025-09-15 18:51:04 -04:00
njohnson
dd00cee809 Update fastfileCod12_pc.cpp: Improve ZLib decompression efficiency and add export functionality. 2025-09-15 18:50:39 -04:00
njohnson
34cafac121 Refactor: Update FastFileFactory and Open to use same parsing logic. 2025-09-15 18:50:18 -04:00
njohnson
4bf4c12159 Refactor: Use of FastFileFactory replaced with FastFile::Open for Factory ingest tests. 2025-09-15 18:50:09 -04:00
njohnson
754c563515 Refactor: Update FastFile::Open to use consistent filename parsing. 2025-09-15 18:49:54 -04:00
njohnson
ea1a829957 Refactored compression and encryption. 2025-09-15 18:49:42 -04:00
njohnson
ccb956a834 Refactor: Replace hardcoded file paths with fastFilePath in testFactory() methods. 2025-09-15 18:49:25 -04:00
njohnson
ba83aa5247 Lotta changes 2025-09-10 21:58:26 -04:00
njohnson
324e84eafc Refactor: Default destructor for XCLeafBrushNodeLeaf 2025-09-10 21:57:09 -04:00
njohnson
e290f2aca9 Implement TODO: ParseData for XCLeafBrushNodeLeaf 2025-09-10 21:57:08 -04:00
njohnson
b13001ac90 Fix: Use XDataStream for parsing 2025-09-10 21:57:07 -04:00
njohnson
1e24a2cc81 Fix: Set name in constructor 2025-09-10 21:57:07 -04:00
njohnson
631dbdfa53 Fix: Use XDataStream in ParseData 2025-09-10 21:57:06 -04:00
njohnson
fbf295f2a8 Fix: Parse data stream for XCLeafBrushNodeChildren 2025-09-10 21:57:05 -04:00
njohnson
00c84fd622 Fix: Use qint32 for mContents 2025-09-10 21:57:04 -04:00
njohnson
a8cee21ae8 Fix: ParseData method implementation 2025-09-10 21:57:04 -04:00
njohnson
48d7c3e692 Refactor: Use QVector3D for leaf min/max coordinates 2025-09-10 21:57:03 -04:00
njohnson
c7291b567f Fixes: Parse data from XDataStream 2025-09-10 21:57:02 -04:00
njohnson
ecb0e528c2 Fix: Use XDataStream for parsing 2025-09-10 21:57:01 -04:00
njohnson
2de65b22ec Refactor: ParseData - Use XDataStream instead of QDataStream 2025-09-10 21:57:00 -04:00
njohnson
a01d07ce41 Refactor: Use XDataStream for data parsing 2025-09-10 21:56:59 -04:00
njohnson
348bf2a299 Refactor ParseData to handle data parsing. 2025-09-10 21:56:59 -04:00
njohnson
37c81d78ce Fix: Use qint32 for platform ID 2025-09-10 21:56:58 -04:00
njohnson
33052d2e11 Fix: Correctly parse platform integer from data stream. 2025-09-10 21:56:57 -04:00
njohnson
4603ebd7cf Refactor: Update ParseData to use XDataStream 2025-09-10 21:56:56 -04:00
njohnson
00f0a8a828 Refactor: Add TODO for ParseData implementation. 2025-09-10 21:56:55 -04:00
njohnson
367e4e012e Refactor: Change QDataStream to XDataStream in ParseData 2025-09-10 21:56:54 -04:00
njohnson
3bf4e8b0e5 Refactor: Parse data for XBoneInfo 2025-09-10 21:56:54 -04:00
njohnson
39a5a75333 Fix: Update data stream type in ParseData() 2025-09-10 21:56:53 -04:00
njohnson
20f4dcd798 Fix: Set name and parse surfId 2025-09-10 21:56:52 -04:00
njohnson
8398156122 Refactor: Change QDataStream to XDataStream in ParseData 2025-09-10 21:56:51 -04:00
njohnson
8136ba1d34 Fix: Add missing Clear() implementation for XAudioXmaLoopRegion. 2025-09-10 21:56:51 -04:00
njohnson
2c18b939e7 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:56:50 -04:00
njohnson
01d2b95417 Add XMA format parsing data fields 2025-09-10 21:56:49 -04:00
njohnson
8cfb82e03d Fix: Use qint32 for mTotalMsec 2025-09-10 21:56:48 -04:00
njohnson
2d8d34bab8 Fix: Add XAsset constructor
This commit adds the `XAsset` constructor to the `XAudioXmaDataInfo` class.
2025-09-10 21:56:48 -04:00
njohnson
6e772cb6b7 Refactor: ParseData to accept XDataStream* 2025-09-10 21:56:47 -04:00
njohnson
32ce8e350f Implement basic XAudioStreamInfo parsing and initialization. 2025-09-10 21:56:46 -04:00
njohnson
73ab1a368a Refactor: Use XDataStream instead of QDataStream 2025-09-10 21:56:45 -04:00
njohnson
d9aa25c4af Fix: Parse audio source format data 2025-09-10 21:56:44 -04:00
njohnson
d18cfb6968 Fix: Rename QDataStream to XDataStream 2025-09-10 21:56:44 -04:00
njohnson
924e448270 Fix: Set name in constructor 2025-09-10 21:56:43 -04:00
njohnson
4dc402fd16 Refactor: Use XDataStream instead of QDataStream 2025-09-10 21:56:42 -04:00
njohnson
8b802028e9 Fix: Parse size and data pointer from stream 2025-09-10 21:56:41 -04:00
njohnson
f6a20c873a Refactor: Use qint32 for preset overridden value 2025-09-10 21:56:41 -04:00
njohnson
4e4422466c Fix: Set name in constructor. 2025-09-10 21:56:40 -04:00
njohnson
3bf032d2e0 Fix: Rename QDataStream to XDataStream in ParseData 2025-09-10 21:56:39 -04:00
njohnson
3d378b28c9 Fix: Improve data parsing
This commit updates the data parsing logic within the XAudioPacketAligned class. Specifically, it uses `ParseInt32` and `ParseInt8` instead of direct data stream reading, improving type safety and ensuring correct data handling during parsing.
2025-09-10 21:56:38 -04:00
njohnson
1f7ca563bf Refactor: Use XDataStream for parsing XAudioXmaFormat 2025-09-10 21:56:37 -04:00
njohnson
f6a0ff580c Implement TODO: ParseData(...) for XAudioFormatInfo 2025-09-10 21:56:36 -04:00
njohnson
b9e858a6d5 Refactor: Use XDataStream instead of QDataStream 2025-09-10 21:56:36 -04:00
njohnson
f88eeec7ee Fix: Parse Data Handling
This commit updates the `ParseData` method to correctly parse input channel, output channel and volume from the `XDataStream`.
2025-09-10 21:56:35 -04:00
njohnson
9c6c55fe75 Refactor: Change QDataStream to XDataStream in ParseData 2025-09-10 21:56:34 -04:00
njohnson
e6f2932ef1 Fix: Parse entry count and entries ptr 2025-09-10 21:56:33 -04:00
njohnson
8c1f9539c7 Refactor: Use XDataStream for parsing 2025-09-10 21:56:32 -04:00
njohnson
21379d133d Fix: Parse data for asset list 2025-09-10 21:56:32 -04:00
njohnson
6e58c8fc2f The change is a minor one: the prompt to Ollama has been modified from "Write a clear, concise Git commit message for changes in file: $FILE." to "Write a SHORT, clear, concise Git commit message for changes in file: $FILE.". This prioritizes shorter messages in the commit messages. 2025-09-10 21:56:31 -04:00
njohnson
10db1eec7d Refactor: Implement default destructor and rename ParseData method
This commit implements the default destructor for `XAssetHeader` and renames the `ParseData` method to `ParseData` to align with the `XDataStream` interface.
2025-09-10 21:56:11 -04:00
njohnson
d267ad19f5 Fix: Parse Raw Asset Type and Asset Pointer
Adds parsing logic for the raw asset type and asset pointer within the `XAssetHeader` class. This enables the retrieval of these values during data stream parsing, facilitating asset identification and management.
2025-09-10 21:56:10 -04:00
njohnson
99d2885f9c Fix: Replace QDataStream with XDataStream
This commit replaces the use of `QDataStream` with `XDataStream` in the `XAsset` class. This aligns the code with the current XAssets framework and promotes consistency.
2025-09-10 21:56:08 -04:00
njohnson
0545bfe642 Fix: Improve Data Parsing and Debug Logging
This commit addresses an issue in the `XAsset` class's data parsing logic, specifically within the `ParsePtr` method. The previous implementation lacked proper parsing of the integer value associated with the asset's pointer. Additionally, the debug logging during data parsing was overly verbose and included unnecessary hexadecimal conversions. The fix ensures correct integer parsing and simplifies the debug logging output for easier debugging.
2025-09-10 21:56:07 -04:00
njohnson
7e408d2c2e Refactor: Default destructor for XAnimPartTransFrames 2025-09-10 21:56:06 -04:00
njohnson
512b9bae61 Fix: Parse data from XDataStream
The `ParseData` function was incorrectly using a `QDataStream` to parse data. It has been updated to correctly use an `XDataStream` for parsing, resolving parsing issues.
2025-09-10 21:56:05 -04:00
njohnson
0f10bf9375 Fix: Default destructor for XAnimPartTransData
The destructor was missing a `= default;` specifier, which is now added to ensure proper object cleanup.
2025-09-10 21:56:04 -04:00
njohnson
63468fa91e Fix: Set name for Animation Part Trans Data
This commit sets the name for the XAnimPartTransData object, ensuring consistent identification within the XAssets framework.
2025-09-10 21:56:03 -04:00
njohnson
d9f6e13bdf Refactor: Default destructor for XAnimPartTrans
This commit introduces a default destructor for the `XAnimPartTrans` class, simplifying the code and ensuring proper resource cleanup.
2025-09-10 21:56:02 -04:00
njohnson
e512636ad6 Fix: Parse data for XAnimPartTrans
This commit fixes the parsing logic for the `XAnimPartTrans` class, ensuring that the size and small trans flags are correctly parsed from the data stream. It uses `ParseUInt32` and `ParseUInt8` for better type handling and includes informative strings for debugging.
2025-09-10 21:56:01 -04:00
njohnson
f2769e689f Fix: Use XDataStream for parsing
This commit updates the parsing mechanism within XAnimParts to utilize `XDataStream` instead of `QDataStream`. This aligns with the codebase's evolving data handling conventions and ensures consistency in data parsing operations.
2025-09-10 21:56:00 -04:00
njohnson
9898a03417 Refactor: Improve data parsing for XAnimParts
This commit refactors the data parsing logic for XAnimParts to improve clarity and maintainability. It replaces the use of raw `*aStream` with `aStream->ParseUIntX()` for all data fields. This approach simplifies the code and enhances readability by explicitly stating the data type being parsed. Furthermore, the message has been updated to reflect the name change of this asset.
2025-09-10 21:55:59 -04:00
njohnson
7174f1fe22 Refactor: Implement default destructor for XAnimNotifyInfo
This commit implements a default destructor for the `XAnimNotifyInfo` class.
2025-09-10 21:55:57 -04:00
njohnson
4480eb83d7 Fix: Handle Animation Notify Info parsing
This commit fixes an issue in the parsing of Animation Notify Info data.
Specifically, the parsing logic for `mName` and `mTime` was incorrect.
The fix adds proper parsing implementation, ensuring that the data is
correctly loaded during deserialization.
2025-09-10 21:55:56 -04:00
njohnson
5ee673175c Refactor: Implement XDataStream for ParseData 2025-09-10 21:55:55 -04:00
njohnson
86885f999c Fix: Parse Animation Indices data correctly
This commit fixes the parsing of `XAnimIndices` data, ensuring that the index is correctly parsed from the data stream, including handling the case where the index pointer is -1.
2025-09-10 21:55:54 -04:00
njohnson
2e4e0a6b99 Refactor: Implement default destructor for XAnimDynamicIndices 2025-09-10 21:55:53 -04:00
njohnson
338b50c694 Fix: Parse Animation Dynamic Indices Index
The animation dynamic indices parsing was incorrectly using the stream's `>>` operator.  The `XDataStream` class provides `ParseUInt8` for proper parsing of unsigned 8-bit integers, ensuring data integrity. This commit updates the parsing logic to use `ParseUInt8` and include a descriptive string for logging.
2025-09-10 21:55:52 -04:00
njohnson
20b57db193 Refactor: Update ParseData signature to XDataStream* 2025-09-10 21:55:51 -04:00
njohnson
7b61cff46d Fix: Parse frames from data stream
The frames were parsed incorrectly from the data stream. This commit fixes the parsing logic to properly read the frame data using `ParseUInt8` and includes a descriptive name for the asset.
2025-09-10 21:55:50 -04:00
njohnson
25728f9486 Fix: Use qint32 for mFramesPtr
The `mFramesPtr` member was previously defined as `quint32`, which is an unsigned 32-bit integer. This could lead to issues when storing negative values, which is possible for frame pointers. Changed the type to `qint32` (signed 32-bit integer) to allow for negative frame pointer values.
2025-09-10 21:55:49 -04:00
njohnson
8e215f13af Fix: Parse Data Stream
This commit fixes the parsing logic for the XAnimDeltaPartQuatDataFrames data stream, ensuring that the frames pointer, frame 0, and frame 1 are correctly parsed from the stream.
2025-09-10 21:55:48 -04:00
njohnson
a71607aae3 Fix: Rename QDataStream to XDataStream in ParseData
This commit replaces `QDataStream` with `XDataStream` in the `ParseData` method of `XAnimDeltaPartQuatData`. This aligns with the project's naming conventions for data streams.
2025-09-10 21:55:47 -04:00
njohnson
2ae9bf95a4 Fix: Add set name to constructor. 2025-09-10 21:55:46 -04:00
njohnson
08cf71cb02 Fix: Rename QDataStream to XDataStream in ParseData
The `ParseData` method was incorrectly using `QDataStream` instead of `XDataStream`. This commit changes the type from `QDataStream` to `XDataStream` to align with the project's data stream implementation.
2025-09-10 21:55:45 -04:00
njohnson
8f3fa82f64 Fix: Parse size from data stream
This commit fixes a parsing issue in `XAnimDeltaPartQuat` where the size of the data was not being correctly read from the data stream. It now uses `aStream->ParseUInt32()` to read the size, including a descriptive string for debugging.
2025-09-10 21:55:44 -04:00
njohnson
e40bee38af Refactor: Implement default destructor for XAnimDeltaPart
This commit implements a default destructor for the `XAnimDeltaPart` class, ensuring proper resource cleanup and adhering to best practices. The destructor is now implicitly generated, simplifying the codebase.
2025-09-10 21:55:43 -04:00
njohnson
2799108c7d Fix: Remove unused destructor
This commit removes the unused destructor from `XAnimDeltaPart`.
2025-09-10 21:55:42 -04:00
njohnson
e1be487b6b Refactor: Update platform and game enum values. 2025-09-10 21:55:41 -04:00
njohnson
383d6e2439 Refactor: Update data stream type for FFCompany parsing
This commit updates the data stream type for parsing FFCompany to use XDataStream instead of QDataStream, aligning with recent changes in the project.
2025-09-10 21:55:40 -04:00
njohnson
3452b73eb0 Refactor: Update data stream parsing functions for XDataStream
This commit updates the parsing functions within the FastFile class to use the XDataStream instead of the QDataStream. This change aligns the code with newer data stream implementations and improves maintainability.
2025-09-10 21:55:39 -04:00
njohnson
9dc45d3024 Refactor: Use XDataStream instead of QDataStream for WiiU COD9 parsing. 2025-09-10 21:55:38 -04:00
njohnson
dc0a8a1e3d Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:37 -04:00
njohnson
cf2102e182 Fix: Use XDataStream instead of QDataStream
This commit changes the code to use `XDataStream` instead of `QDataStream` for parsing the COD8 Wii file format. This aligns with the use of `XDataStream` in other parts of the FastFile library.
2025-09-10 21:55:36 -04:00
njohnson
6db6760a0a Fix: Use XDataStream instead of QDataStream for COD7 parsing. 2025-09-10 21:55:35 -04:00
njohnson
cdd0142759 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:34 -04:00
njohnson
4fbf77e661 Fix: Use XDataStream instead of QDataStream
Change the type of the data stream from `QDataStream` to `XDataStream` for consistency and to align with the rest of the codebase.
2025-09-10 21:55:33 -04:00
njohnson
8d31623138 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:32 -04:00
njohnson
acd14a2179 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:31 -04:00
njohnson
f09124f611 Fix: Use XDataStream instead of QDataStream
Change QDataStream to XDataStream for parsing data streams, ensuring compatibility with the new data format.
2025-09-10 21:55:31 -04:00
njohnson
ead2e4eaf7 Fix: Use XDataStream instead of QDataStream for COD4 PS3 fast file parsing. 2025-09-10 21:55:30 -04:00
njohnson
63ccc50de3 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:29 -04:00
njohnson
a753c24d9d Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:28 -04:00
njohnson
d4bf2e0796 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:27 -04:00
njohnson
2472cd5d1b Fix: Use XDataStream instead of QDataStream for COD7/COD9 parsing. 2025-09-10 21:55:26 -04:00
njohnson
7bfe92eb9c Fix: Use XDataStream instead of QDataStream for COD7/COD9 parsing. 2025-09-10 21:55:25 -04:00
njohnson
990d413673 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:25 -04:00
njohnson
b4f677f81b Fix: Use XDataStream instead of QDataStream for COD5 Fast File parsing. 2025-09-10 21:55:24 -04:00
njohnson
59dfc3f05e Fix: Use XDataStream instead of QDataStream for COD5 Fast File parsing. 2025-09-10 21:55:23 -04:00
njohnson
3d409fc1d4 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:22 -04:00
njohnson
ab437b460f Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:21 -04:00
njohnson
ff46687106 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:20 -04:00
njohnson
d7f099dc05 Fix: Use XDataStream and BigEndian for COD7/COD9 parsing
This commit corrects the byte order handling for the COD7/COD9 file parsing, utilizing `XDataStream` and `BigEndian` to ensure correct data interpretation.
2025-09-10 21:55:20 -04:00
njohnson
415156256a Fix: Use XDataStream and BigEndian for COD8/COD9
This commit replaces `QDataStream` with `XDataStream` and ensures `BigEndian` byte order is used, aligning with the specific requirements for COD8/COD9 file loading.
2025-09-10 21:55:18 -04:00
njohnson
c799f53687 Refactor: Use XDataStream instead of QDataStream for COD7/COD9 parsing. 2025-09-10 21:55:17 -04:00
njohnson
15ff5e65b1 Fix: Decompress ZLIB correctly
This commit fixes an issue where the ZLIB decompression was not being performed correctly after stripping hash blocks. The corrected code ensures that the decompressed data is properly handled.
2025-09-10 21:55:16 -04:00
njohnson
a3769f0bad Fix: Use XDataStream instead of QDataStream for COD4 360 file parsing. 2025-09-10 21:55:15 -04:00
njohnson
8a668620de Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:15 -04:00
njohnson
935634c9e2 Fix: Use XDataStream instead of QDataStream
Change QDataStream to XDataStream for parsing the fastfile data.
2025-09-10 21:55:14 -04:00
njohnson
d13e227eb9 Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:13 -04:00
njohnson
b977dbd183 Fix: Use XDataStream instead of QDataStream
Change QDataStream to XDataStream for improved compatibility and consistency.
2025-09-10 21:55:12 -04:00
njohnson
15399a2969 Fix: Handle endianness in SHA1 block expansion
Addresses a potential endianness issue in the SHA1 block expansion logic, using `#ifdef WORDS_BIGENDIAN` to ensure correct data access regardless of platform.
2025-09-10 21:55:11 -04:00
njohnson
bc3cc77a0a Fix: Use u32 for loop index in salsa20.cpp
This commit replaces the `int i` loop index with `u32 i` in the `ECRYPT_encrypt_bytes` function. This ensures consistency with the rest of the code, which uses `u32` for various indices and counts, and avoids potential warnings or errors related to type mismatches.
2025-09-10 21:55:10 -04:00
njohnson
dcd6d9bf7b Fix: Correctly initialize IV table values
This commit fixes a minor issue where the IV table initialization was slightly off, leading to incorrect values in some cases. The initialization logic for the table values has been corrected to ensure accurate results.
2025-09-10 21:55:09 -04:00
njohnson
ddcb00676a Remove warning about macro usage
This commit removes a warning message regarding the potential misuse of macros within the `ecrypt-portable.h` file. The message cautioned against using the macros in scenarios where side effects were intended, highlighting the importance of careful usage.  The warning was deemed overly restrictive and has been removed to allow for greater flexibility in how the macros are utilized, while still encouraging awareness of their specific behavior.
2025-09-10 21:55:08 -04:00
njohnson
73f9207839 Update enums for IWI_VERSION and IWI_FORMAT to reflect changes. 2025-09-10 21:55:06 -04:00
njohnson
bccbca87fa Add XDataStream class for convenient data parsing. 2025-09-10 21:55:05 -04:00
njohnson
a24fec5558 Add parsing methods for int8, uint8, int16, uint16, int32, uint32, int64, uint64, single, and double. Add debug output to each parsing method. 2025-09-10 21:55:04 -04:00
njohnson
c26ba7dcab Fix: Use XDataStream instead of QDataStream 2025-09-10 21:55:02 -04:00
njohnson
cadcd2d53c Update enums in libs/core/enums.h to improve code readability and maintainability. 2025-09-10 21:55:01 -04:00
njohnson
7eca939c06 Update: Add xdatastream.cpp and xdatastream.h to core.pro 2025-09-10 21:55:00 -04:00
njohnson
975567cdd4 Remove redundant LZO package notes. 2025-09-10 21:54:59 -04:00
njohnson
2df2d491ae Fix: Include correct lzo definitions header 2025-09-10 21:54:58 -04:00
njohnson
9b4852f393 Update build dependencies for compression library. 2025-09-10 21:54:57 -04:00
njohnson
f3d0abb65e ```
Commit message:
Fix: Resolve compilation issues with XCompress and Minilzo.
```
2025-09-10 21:54:57 -04:00
njohnson
9a5ae3bf51 Refactor: Simplify export zone file action and use lambda expressions. 2025-09-10 21:54:55 -04:00
njohnson
d11783ebfc Fix: Use XDataStream instead of QDataStream 2025-09-10 21:54:54 -04:00
njohnson
f5eebe6743 TODO: Implement MaterialViewer::SetMaterial to process XMaterial data. 2025-09-10 21:54:54 -04:00
njohnson
b8c7bdb1ba Fix: Corrected loop conditions in IPAK loading
This commit fixes a potential off-by-one error in the IPAK loading logic. The loop conditions in the `LoadFile_IPAK` function were incorrect, leading to incorrect handling of data chunks. The loop conditions have been corrected to ensure that all data chunks are processed correctly.
2025-09-10 21:54:53 -04:00
njohnson
87bbe47e7e Fix: Corrected library dependencies in .pro file 2025-09-10 21:54:51 -04:00
njohnson
1ff6475fdb This is a well-structured and functional script that automates committing changes in a Git repository using Ollama to generate commit messages. Here's a breakdown of the script and some potential improvements:
**Explanation:**

1. **`#!/bin/bash`**:  Shebang line, specifying the script should be executed with Bash.

2. **`set -e`**:  This crucial line ensures that the script exits immediately if any command fails. This prevents unexpected behavior and makes debugging easier.

3. **`git add -A`**: Stages all changes in the repository for commit.

4. **`FILES=$(git diff --cached --name-only)`**: This line retrieves a list of staged files from the Git index.  `--cached` ensures it only includes staged files, and `--name-only` provides just the filenames.

5. **`if [ -z "$FILES" ]; then ... fi`**: Checks if any files are staged. If not, it prints a message and exits gracefully. This avoids errors when there's nothing to commit.

6. **`for FILE in $FILES; do ... done`**:  Iterates through each staged file.

7. **`DIFF=$(git diff --cached -- "$FILE")`**: Gets the diff content of the current file. `--cached` ensures it's the staged diff.

8. **`if [ -z "$DIFF" ]; then continue; fi`**: Checks if there's a diff for the current file. If not (meaning the file hasn't changed), it skips to the next file.

9. **`MSG=$(echo "$DIFF" | ollama run gemma3 ...)`**: This is the core of the script. It pipes the diff content to Ollama to generate a commit message.
    * `ollama run gemma3`:  Executes the `gemma3` model in Ollama.
    * `"You are a commit bot. Write a clear, concise Git commit message for changes in file: $FILE. Only output the commit message, nothing else. Diff: $DIFF"`:  The prompt given to the Ollama model.  It clearly instructs the model to create a concise commit message based on the file and its diff content.
    *  The `gemma3` model is used, likely a smaller and faster model.

10. **`git commit -m "$MSG" -- "$FILE"`**: Commits the file with the generated message.
    * `-m "$MSG"`:  Specifies the commit message.
    * `-- "$FILE"`:  Indicates that only this file should be committed.

11. **`echo " Committed $FILE with message:"` and `echo "$MSG"`**:  Prints confirmation messages, making the script user-friendly.

**Potential Improvements:**

* **Error Handling within the Loop:** The script should handle potential errors during the `git commit` command within the loop. If a commit fails for one file, it should continue to process the remaining files.  You can add `|| exit 1` after the `git commit` command to achieve this.

* **Ollama Model Configuration:**  Consider making the Ollama model name (`gemma3`) configurable via a variable.  This would allow users to easily switch models.

* **More Robust Diff Parsing:** The script assumes the diff content is simple. If the diff is complex (e.g., contains whitespace issues), it might not generate the desired commit message.  A more robust solution would involve parsing the diff more carefully.

* **Logging:** Add more detailed logging to help with debugging.

* **Confirmation Prompt:**  Before committing each file, you could ask the user for confirmation (e.g., "Do you want to commit $FILE with message $MSG?").

* **Interactive Diff Viewer:** For more complex changes, using a tool that allows the user to view the diff interactively and then provide the commit message could be beneficial.

**Example with Error Handling and Logging:**

```bash
#!/bin/bash
set -e

# Configuration
OLLAMA_MODEL="gemma3"

# 1. Stage everything
git add -A

# 2. Get list of staged files
FILES=$(git diff --cached --name-only)

if [ -z "$FILES" ]; then
  echo "No changes to commit."
  exit 0
fi

for FILE in $FILES; do
  # Get diff for this file
  DIFF=$(git diff --cached -- "$FILE")

  if [ -z "$DIFF" ]; then
    continue
  fi

  # Ask Ollama for a commit message describing this file change
  MSG=$(echo "$DIFF" | ollama run "$OLLAMA_MODEL" \
    "You are a commit bot. Write a clear, concise Git commit message for changes in file: $FILE.
    Only output the commit message, nothing else.
    Diff:
    $DIFF")

  # Commit just this file with its message
  echo "Committing $FILE with message: $MSG"
  git commit -m "$MSG" -- "$FILE" || {
    echo "Error committing $FILE.  Continuing..."
    # Handle the error more gracefully here if needed
  }

  echo " Committed $FILE with message:"
  echo "$MSG"
done
```

This revised script is more robust and provides better error handling.  It's a solid foundation for an automated commit script.  Remember to install Ollama and the `gemma3` model before running the script.
2025-09-10 21:54:50 -04:00
njohnson
2f044a8d94 Updated xwater 2025-09-07 23:16:15 -04:00
njohnson
a1a54665d9 Updated xsurfacevertexinfo 2025-09-07 23:16:14 -04:00
njohnson
6e73c2d50c Updated xsurface 2025-09-07 23:16:14 -04:00
njohnson
53f690c554 Updated xsunflare 2025-09-07 23:16:13 -04:00
njohnson
eebd333e11 Updated xphyspreset 2025-09-07 23:16:12 -04:00
njohnson
3b65f1bdf2 Updated xpackedunitvec 2025-09-07 23:16:11 -04:00
njohnson
a9444c05bf Updated xpackedtexcoords 2025-09-07 23:16:11 -04:00
njohnson
9a957138b5 Updated xmodelpieces 2025-09-07 23:16:10 -04:00
njohnson
a94e3bd012 Updated xmodelpiece 2025-09-07 23:16:09 -04:00
njohnson
b80cfab4fb Updated xmodelcollsurf 2025-09-07 23:16:08 -04:00
njohnson
da6233c10d Updated xmodel 2025-09-07 23:16:08 -04:00
njohnson
43e925ae23 Updated xmenudef 2025-09-07 23:16:07 -04:00
njohnson
cd7c65ef4a Updated xmaterialtexturedefinfo 2025-09-07 23:16:06 -04:00
njohnson
fd7f466578 Updated xmaterialtexturedef 2025-09-07 23:16:05 -04:00
njohnson
3a84ccd30f Updated xmaterialtechniqueset 2025-09-07 23:16:05 -04:00
njohnson
7fdd451cd1 Updated xmaterialinfo 2025-09-07 23:16:04 -04:00
njohnson
59d5b12e80 Updated xmaterialconstantdef 2025-09-07 23:16:03 -04:00
njohnson
d81513a95f Updated xmaterial 2025-09-07 23:16:02 -04:00
njohnson
23d577336f Updated xmapents 2025-09-07 23:16:02 -04:00
njohnson
b9646c1140 Updated xlocalizeentry 2025-09-07 23:16:01 -04:00
njohnson
7d103dfcea Updated xitemkeyhandler 2025-09-07 23:16:00 -04:00
njohnson
df1bad5380 Updated xitemdefdata 2025-09-07 23:15:59 -04:00
njohnson
6a41e543ee Updated xitemdef 2025-09-07 23:15:59 -04:00
njohnson
06e94e9648 Updated xgfxcolor 2025-09-07 23:15:58 -04:00
njohnson
096da843d1 Updated xgfxcell 2025-09-07 23:15:57 -04:00
njohnson
ba6da187f3 Updated xgameworldsp 2025-09-07 23:15:56 -04:00
njohnson
11cc55dd71 Updated xgameworldmp 2025-09-07 23:15:56 -04:00
njohnson
e82dbce63c Updated xfxeffectdef 2025-09-07 23:15:55 -04:00
njohnson
4677ab9637 Updated xfont 2025-09-07 23:15:54 -04:00
njohnson
b77e6e8077 Updated xdynentitypose 2025-09-07 23:15:53 -04:00
njohnson
3416060d4b Updated xdynentitydef 2025-09-07 23:15:53 -04:00
njohnson
ce7ed928c4 Updated xdynentitycoll 2025-09-07 23:15:52 -04:00
njohnson
b7c7eff1b5 Updated xdynentityclient 2025-09-07 23:15:51 -04:00
njohnson
64b5471ea4 Updated xdobjanimmat 2025-09-07 23:15:50 -04:00
njohnson
ef2d880039 Updated xd3dindexbuffer 2025-09-07 23:15:50 -04:00
njohnson
a577d329ec Updated xcollisionpartition 2025-09-07 23:15:49 -04:00
njohnson
80fc72e8b0 Updated xcollisionborder 2025-09-07 23:15:48 -04:00
njohnson
0a3fbfe39a Updated xcollisionaabbtreeindex 2025-09-07 23:15:47 -04:00
njohnson
4f430055f3 Updated xcmodel 2025-09-07 23:15:47 -04:00
njohnson
67832954e4 Update XString header 2025-09-07 23:12:13 -04:00
njohnson
333de659ed Update XString parsing logic 2025-09-07 23:12:12 -04:00
njohnson
0374410315 Update XFxElemVec3Range parsing logic 2025-09-07 23:12:11 -04:00
njohnson
296a25d26f Update XFxElemVisualState parsing logic 2025-09-07 23:12:10 -04:00
njohnson
0e141ae95c Update XFxElemVelStateSample parsing logic 2025-09-07 23:12:09 -04:00
njohnson
fc1c89c710 Update XFxElemVelStateInFrame parsing logic 2025-09-07 23:12:08 -04:00
njohnson
422ceb9a25 Update XFxElemVisStateSample parsing logic 2025-09-07 23:12:06 -04:00
njohnson
14a494cc24 Update XFxElemDef header 2025-09-07 23:12:06 -04:00
njohnson
0da6a4aee7 Update XFxElemDef parsing logic 2025-09-07 23:12:05 -04:00
njohnson
00618f8081 Update XGfxWorldVertexData header 2025-09-07 23:12:05 -04:00
njohnson
d525f9bee3 Update XGfxWorldVertexData parsing logic 2025-09-07 23:12:04 -04:00
njohnson
ab7d2bb3b8 Update XGfxWorldDpvsPlanes header 2025-09-07 23:12:03 -04:00
njohnson
e2f35a0314 Update XGfxWorldDpvsPlanes parsing logic 2025-09-07 23:12:03 -04:00
njohnson
e4c409ab19 Update XGfxWorldDpvsDynamic header 2025-09-07 23:12:02 -04:00
njohnson
48c28e046d Update XGfxWorldDpvsDynamic parsing logic 2025-09-07 23:12:01 -04:00
njohnson
0f45fb5788 Update XGfxWorld header 2025-09-07 23:12:01 -04:00
njohnson
8d4303b166 Update XGfxWorld parsing logic 2025-09-07 23:12:00 -04:00
njohnson
857a55f133 Update XGfxStateBits parsing logic 2025-09-07 23:11:59 -04:00
njohnson
b513834076 Update XGfxPlacement parsing logic 2025-09-07 23:11:58 -04:00
njohnson
2131034ad9 Update XGfxPackedVertex header 2025-09-07 23:11:57 -04:00
njohnson
4a53b0ff74 Update XGfxPackedVertex parsing logic 2025-09-07 23:11:57 -04:00
njohnson
f7ff77b11d Update XGfxLightDef header 2025-09-07 23:11:56 -04:00
njohnson
e06fe64311 Update XGfxLightDef parsing logic 2025-09-07 23:11:55 -04:00
njohnson
e416d47df4 Update XGfxImage parsing logic 2025-09-07 23:11:54 -04:00
njohnson
51a0d00b93 Update XGfxDrawSurfFields parsing logic 2025-09-07 23:11:53 -04:00
njohnson
ae16506d87 Update XGfxDrawSurf header 2025-09-07 23:11:52 -04:00
njohnson
75c128534e Update XGfxDrawSurf parsing logic 2025-09-07 23:11:52 -04:00
njohnson
e0b7ff743c Update XClipMap header 2025-09-07 23:11:49 -04:00
njohnson
84314df7cb Update XClipMap parsing logic 2025-09-07 23:11:48 -04:00
njohnson
1545a92c27 Implement XBoneInfo – bone‑hierarchy support 2025-09-07 23:06:06 -04:00
njohnson
b62c548193 Add header for XcBrush class 2025-09-07 23:06:05 -04:00
njohnson
d92098571e Implement XcBrush – brush geometry utilities 2025-09-07 23:06:04 -04:00
njohnson
1eb340aaea Make buildable with all those assets. 2025-09-07 13:13:27 -04:00
njohnson
6211ea3c77 Dont include qmake stash. 2025-09-07 12:38:30 -04:00
njohnson
3d91f1f3f4 Remove vscode stuff. 2025-09-07 12:37:51 -04:00
365aac8cfa Merge pull request 'Lotta asset-based changes.' (#10) from feature/test into main
Reviewed-on: #10
2025-09-07 12:36:39 -04:00
njohnson
abd1a6a051 Lotta asset-based changes. 2025-09-07 12:36:08 -04:00
b80a11093a Merge pull request 'feature/test' (#9) from feature/test into main
Reviewed-on: #9
2025-09-07 12:35:21 -04:00
njohnson
d129c7ba62 Sorry ut A lotta stuff. 2025-09-05 18:35:17 -04:00
RedLine AI Agent
46606f529d Updated libs/xassets/xwindowdef.h 2025-09-05 21:36:01 +00:00
RedLine AI Agent
034234a134 Updated libs/xassets/xwindowdef.cpp 2025-09-05 21:36:00 +00:00
RedLine AI Agent
c197edaee6 Updated libs/xassets/xweaponenums.h 2025-09-05 21:35:59 +00:00
RedLine AI Agent
32991d0273 Updated libs/xassets/xtexturedesc.h 2025-09-05 21:35:57 +00:00
RedLine AI Agent
c4826bf1f3 Updated libs/xassets/xtexturedesc.cpp 2025-09-05 21:35:55 +00:00
RedLine AI Agent
1afbe28cc9 Updated libs/xassets/xsunflare.h 2025-09-05 21:35:54 +00:00
RedLine AI Agent
d28aba759f Updated libs/xassets/xsunflare.cpp 2025-09-05 21:35:52 +00:00
RedLine AI Agent
80c0fb2f23 Updated libs/xassets/xstatement.h 2025-09-05 21:35:51 +00:00
RedLine AI Agent
99c2b0ab3b Updated libs/xassets/xstatement.cpp 2025-09-05 21:35:50 +00:00
RedLine AI Agent
9f46d1ea9c Updated libs/xassets/xsrftriangles.h 2025-09-05 21:35:49 +00:00
RedLine AI Agent
d4c36cab72 Updated libs/xassets/xsrftriangles.cpp 2025-09-05 21:35:47 +00:00
RedLine AI Agent
5ec26d101c Updated libs/xassets/xsentienthandle.h 2025-09-05 21:35:46 +00:00
RedLine AI Agent
c5732b0899 Updated libs/xassets/xsentienthandle.cpp 2025-09-05 21:35:45 +00:00
RedLine AI Agent
fb442b39fa Updated libs/xassets/xrectdef.h 2025-09-05 21:35:43 +00:00
RedLine AI Agent
afb0430f30 Updated libs/xassets/xrectdef.cpp 2025-09-05 21:35:42 +00:00
RedLine AI Agent
7bb6d0ab89 Updated libs/xassets/xplatform.h 2025-09-05 21:35:41 +00:00
RedLine AI Agent
9d85b77ef0 Updated libs/xassets/xoperandinternaldataunion.h 2025-09-05 21:35:39 +00:00
RedLine AI Agent
2b55752eb3 Updated libs/xassets/xoperandinternaldataunion.cpp 2025-09-05 21:35:38 +00:00
RedLine AI Agent
c45df3444c Updated libs/xassets/xoperand.h 2025-09-05 21:35:37 +00:00
RedLine AI Agent
cc30cda7cc Updated libs/xassets/xoperand.cpp 2025-09-05 21:35:35 +00:00
RedLine AI Agent
de0ee2e438 Updated libs/xassets/xmultidef.h 2025-09-05 21:35:34 +00:00
RedLine AI Agent
1000b0cafa Updated libs/xassets/xmultidef.cpp 2025-09-05 21:35:33 +00:00
RedLine AI Agent
9a10f4a9e7 Updated libs/xassets/xmodelpieces.h 2025-09-05 21:35:32 +00:00
RedLine AI Agent
6cb52df017 Updated libs/xassets/xmodelpieces.cpp 2025-09-05 21:35:30 +00:00
RedLine AI Agent
e1f8897150 Updated libs/xassets/xmodelpiece.h 2025-09-05 21:35:29 +00:00
RedLine AI Agent
aa8a6d18ae Updated libs/xassets/xmodelpiece.cpp 2025-09-05 21:35:28 +00:00
RedLine AI Agent
d70b54480d Updated libs/xassets/xmodeldrawinfo.h 2025-09-05 21:35:26 +00:00
RedLine AI Agent
d2eb7b9795 Updated libs/xassets/xmodeldrawinfo.cpp 2025-09-05 21:35:25 +00:00
RedLine AI Agent
e7aca45a9f Updated libs/xassets/xmenuenums.h 2025-09-05 21:35:24 +00:00
RedLine AI Agent
7752d3ada5 Updated libs/xassets/xmaterialtechniqueset.h 2025-09-05 21:35:23 +00:00
RedLine AI Agent
4cfd3da983 Updated libs/xassets/xmaterialtechniqueset.cpp 2025-09-05 21:35:21 +00:00
RedLine AI Agent
1ea1ae3199 Updated libs/xassets/xmaterialmemory.h 2025-09-05 21:35:20 +00:00
RedLine AI Agent
2b29b121e0 Updated libs/xassets/xmaterialmemory.cpp 2025-09-05 21:35:19 +00:00
RedLine AI Agent
5c9868c435 Updated libs/xassets/xlistboxdef.h 2025-09-05 21:35:17 +00:00
RedLine AI Agent
6c0a111c09 Updated libs/xassets/xlistboxdef.cpp 2025-09-05 21:35:16 +00:00
RedLine AI Agent
4cbf8ca553 Updated libs/xassets/xitemkeyhandler.h 2025-09-05 21:35:15 +00:00
RedLine AI Agent
5aefd3e4e1 Updated libs/xassets/xitemkeyhandler.cpp 2025-09-05 21:35:14 +00:00
RedLine AI Agent
8bb5287605 Updated libs/xassets/xitemdefdata.h 2025-09-05 21:35:12 +00:00
RedLine AI Agent
0c2478cc70 Updated libs/xassets/xitemdefdata.cpp 2025-09-05 21:35:10 +00:00
RedLine AI Agent
06cda8303d Updated libs/xassets/xitemdef.h 2025-09-05 21:35:09 +00:00
RedLine AI Agent
3c45b639cb Updated libs/xassets/xitemdef.cpp 2025-09-05 21:35:08 +00:00
RedLine AI Agent
aa77115da8 Updated libs/xassets/xglyph.h 2025-09-05 21:35:07 +00:00
RedLine AI Agent
5c42895bb2 Updated libs/xassets/xglyph.cpp 2025-09-05 21:35:05 +00:00
RedLine AI Agent
67668ccc27 Updated libs/xassets/xgfxworldvertexlayerdata.h 2025-09-05 21:35:04 +00:00
RedLine AI Agent
cdf01bb966 Updated libs/xassets/xgfxworldvertexlayerdata.cpp 2025-09-05 21:35:03 +00:00
RedLine AI Agent
178665610c Updated libs/xassets/xgfxworlddpvsstatic.h 2025-09-05 21:35:01 +00:00
RedLine AI Agent
13a7b65f6d Updated libs/xassets/xgfxworlddpvsstatic.cpp 2025-09-05 21:35:00 +00:00
RedLine AI Agent
26ba52bcd2 Updated libs/xassets/xgfxworlddpvsplanes.h 2025-09-05 21:34:59 +00:00
RedLine AI Agent
9e4d14f686 Updated libs/xassets/xgfxworlddpvsplanes.cpp 2025-09-05 21:34:57 +00:00
RedLine AI Agent
5ecabfee07 Updated libs/xassets/xgfxworlddpvsdynamic.h 2025-09-05 21:34:56 +00:00
RedLine AI Agent
caa9fe276e Updated libs/xassets/xgfxworlddpvsdynamic.cpp 2025-09-05 21:34:54 +00:00
RedLine AI Agent
80f1a65a71 Updated libs/xassets/xgfxsurface.h 2025-09-05 21:34:53 +00:00
RedLine AI Agent
2adf0cc1e8 Updated libs/xassets/xgfxsurface.cpp 2025-09-05 21:34:52 +00:00
RedLine AI Agent
1ca6766402 Updated libs/xassets/xgfxstaticmodelinst.h 2025-09-05 21:34:50 +00:00
RedLine AI Agent
08b6e1d6d9 Updated libs/xassets/xgfxstaticmodelinst.cpp 2025-09-05 21:34:49 +00:00
RedLine AI Agent
efd06290d8 Updated libs/xassets/xgfxstaticmodeldrawinst.h 2025-09-05 21:34:48 +00:00
RedLine AI Agent
2f4bc7bb05 Updated libs/xassets/xgfxstaticmodeldrawinst.cpp 2025-09-05 21:34:46 +00:00
RedLine AI Agent
147e4bb079 Updated libs/xassets/xgfxshadowgeometry.h 2025-09-05 21:34:45 +00:00
RedLine AI Agent
749084539e Updated libs/xassets/xgfxshadowgeometry.cpp 2025-09-05 21:34:43 +00:00
RedLine AI Agent
87add0fa93 Updated libs/xassets/xgfxscenedynmodel.h 2025-09-05 21:34:42 +00:00
RedLine AI Agent
98039b533f Updated libs/xassets/xgfxscenedynmodel.cpp 2025-09-05 21:34:41 +00:00
RedLine AI Agent
1d2d68ed54 Updated libs/xassets/xgfxscenedynbrush.h 2025-09-05 21:34:39 +00:00
RedLine AI Agent
18c9457948 Updated libs/xassets/xgfxscenedynbrush.cpp 2025-09-05 21:34:38 +00:00
RedLine AI Agent
bb3683d8fb Updated libs/xassets/xgfxportalwritable.h 2025-09-05 21:34:37 +00:00
RedLine AI Agent
6dd8a4a24c Updated libs/xassets/xgfxportalwritable.cpp 2025-09-05 21:34:36 +00:00
RedLine AI Agent
a2acf1dd90 Updated libs/xassets/xgfxportal.h 2025-09-05 21:34:34 +00:00
RedLine AI Agent
b34959ba1d Updated libs/xassets/xgfxportal.cpp 2025-09-05 21:34:33 +00:00
RedLine AI Agent
2b40623f83 Updated libs/xassets/xgfxplacement.h 2025-09-05 21:34:32 +00:00
RedLine AI Agent
faa73b7697 Updated libs/xassets/xgfxplacement.cpp 2025-09-05 21:34:31 +00:00
RedLine AI Agent
d40b2326f7 Updated libs/xassets/xgfxpackedplacement.h 2025-09-05 21:34:30 +00:00
RedLine AI Agent
57c6c18d8b Updated libs/xassets/xgfxpackedplacement.cpp 2025-09-05 21:34:28 +00:00
RedLine AI Agent
f4b2aaf84e Updated libs/xassets/xgfxlightregionhull.h 2025-09-05 21:34:27 +00:00
RedLine AI Agent
f253b75a45 Updated libs/xassets/xgfxlightregionhull.cpp 2025-09-05 21:34:26 +00:00
RedLine AI Agent
b15886e089 Updated libs/xassets/xgfxlightregionaxis.h 2025-09-05 21:34:24 +00:00
RedLine AI Agent
e78778e82c Updated libs/xassets/xgfxlightregionaxis.cpp 2025-09-05 21:34:23 +00:00
RedLine AI Agent
d957774436 Updated libs/xassets/xgfxlightregion.h 2025-09-05 21:34:22 +00:00
RedLine AI Agent
1722cbf067 Updated libs/xassets/xgfxlightregion.cpp 2025-09-05 21:34:20 +00:00
RedLine AI Agent
c394b38c76 Updated libs/xassets/xgfxlightmaparray.h 2025-09-05 21:34:19 +00:00
RedLine AI Agent
baafe8b4e5 Updated libs/xassets/xgfxlightmaparray.cpp 2025-09-05 21:34:06 +00:00
RedLine AI Agent
78247fafab Updated libs/xassets/xgfxlightgridentry.h 2025-09-05 21:33:54 +00:00
RedLine AI Agent
f7055fbc10 Updated libs/xassets/xgfxlightgridcolors.h 2025-09-05 21:33:44 +00:00
RedLine AI Agent
54a46e8a3e Updated libs/xassets/xgfxlightgrid.h 2025-09-05 21:33:32 +00:00
RedLine AI Agent
3ffcec4a71 Updated libs/xassets/xgfxlightgrid.cpp 2025-09-05 21:33:20 +00:00
RedLine AI Agent
3af6532904 Updated libs/xassets/xgfxcullgroup.h 2025-09-05 21:33:06 +00:00
RedLine AI Agent
f879005e76 Updated libs/xassets/xgfxcullgroup.cpp 2025-09-05 21:32:52 +00:00
RedLine AI Agent
af3f28752a Updated libs/xassets/xgfxcell.h 2025-09-05 21:32:48 +00:00
RedLine AI Agent
240a643111 Updated libs/xassets/xgfxcell.cpp 2025-09-05 21:32:39 +00:00
RedLine AI Agent
bf951db63c Updated libs/xassets/xgfxbrushmodelwritable.h 2025-09-05 21:32:37 +00:00
RedLine AI Agent
54b54a2367 Updated libs/xassets/xgfxbrushmodelwritable.cpp 2025-09-05 21:32:36 +00:00
RedLine AI Agent
5a9855a9f6 Updated libs/xassets/xgfxbrushmodel.h 2025-09-05 21:32:35 +00:00
RedLine AI Agent
3e3553b2ce Updated libs/xassets/xgfxbrushmodel.cpp 2025-09-05 21:32:26 +00:00
RedLine AI Agent
e90788e232 Updated libs/xassets/xgfxaabbtree.h 2025-09-05 21:32:16 +00:00
RedLine AI Agent
c7ed43cf8d Updated libs/xassets/xgfxaabbtree.cpp 2025-09-05 21:32:02 +00:00
RedLine AI Agent
a8ca882e07 Updated libs/xassets/xgame.h 2025-09-05 21:31:49 +00:00
RedLine AI Agent
0e48faf7a3 Updated libs/xassets/xfxspawndefoneshot.h 2025-09-05 21:31:45 +00:00
RedLine AI Agent
51e12e9683 Updated libs/xassets/xfxspawndefoneshot.cpp 2025-09-05 21:31:33 +00:00
RedLine AI Agent
0ec4548a6b Updated libs/xassets/xfxspawndeflooping.h 2025-09-05 21:31:20 +00:00
RedLine AI Agent
c72d51ad1e Updated libs/xassets/xfxspawndeflooping.cpp 2025-09-05 21:31:06 +00:00
RedLine AI Agent
1747f8f8be Updated libs/xassets/xfxspawndef.h 2025-09-05 21:30:52 +00:00
RedLine AI Agent
6fbd17291a Updated libs/xassets/xfxspawndef.cpp 2025-09-05 21:30:51 +00:00
RedLine AI Agent
e1ec4b8878 Updated libs/xassets/xfxintrange.h 2025-09-05 21:30:49 +00:00
RedLine AI Agent
1d08ae6af6 Updated libs/xassets/xfxintrange.cpp 2025-09-05 21:30:48 +00:00
njohnson
c596b3a828 Remove retained copies. 2025-09-05 17:27:56 -04:00
RedLine AI Agent
846c689088 Updated libs/xassets/xfximpacttable.h 2025-09-05 21:27:31 +00:00
RedLine AI Agent
84dc8358a7 Updated libs/xassets/xfximpacttable.cpp 2025-09-05 21:27:30 +00:00
RedLine AI Agent
86092b18a2 Updated libs/xassets/xfxfloatrange.h 2025-09-05 21:27:28 +00:00
RedLine AI Agent
c968117ed1 Updated libs/xassets/xfxfloatrange.cpp 2025-09-05 21:27:27 +00:00
RedLine AI Agent
ef884f4be7 Updated libs/xassets/xfxelematlas.h 2025-09-05 21:27:26 +00:00
RedLine AI Agent
5bf97fcf1a Updated libs/xassets/xfxelematlas.cpp 2025-09-05 21:27:24 +00:00
RedLine AI Agent
c0967ce23e Updated libs/xassets/xfxelematlas.h 2025-09-05 21:27:23 +00:00
RedLine AI Agent
de0e4c5aae Updated libs/xassets/xfxelematlas.cpp 2025-09-05 21:27:22 +00:00
RedLine AI Agent
01094b8d9e Updated libs/xassets/xfxelematlas.h 2025-09-05 21:27:20 +00:00
RedLine AI Agent
7af197ad80 Updated libs/xassets/xfxelematlas.cpp 2025-09-05 21:27:17 +00:00
RedLine AI Agent
136a49801e Updated libs/xassets/xfxelematlas.h 2025-09-05 21:27:05 +00:00
RedLine AI Agent
d603742172 Updated libs/xassets/xfxelematlas.cpp 2025-09-05 21:26:58 +00:00
RedLine AI Agent
cdf8ac1ffc Updated libs/xassets/xfxelematlas.h 2025-09-05 21:26:45 +00:00
RedLine AI Agent
8d5c2c7ea1 Updated libs/xassets/xfxelematlas.cpp 2025-09-05 21:26:32 +00:00
RedLine AI Agent
d075ad4c24 Updated libs/xassets/xfxeffectdef.h 2025-09-05 21:26:19 +00:00
RedLine AI Agent
4e1c18fff2 Updated libs/xassets/xfxeffectdef.cpp 2025-09-05 21:26:14 +00:00
RedLine AI Agent
a2e9683ba3 Updated libs/xassets/xfont.h 2025-09-05 21:26:13 +00:00
RedLine AI Agent
f7444171e3 Updated libs/xassets/xfont.cpp 2025-09-05 21:26:12 +00:00
RedLine AI Agent
fdea13bf84 Updated libs/xassets/xexpressionentry.h 2025-09-05 21:26:11 +00:00
RedLine AI Agent
a06df405fc Updated libs/xassets/xexpressionentry.cpp 2025-09-05 21:26:09 +00:00
RedLine AI Agent
70515d28d4 Updated libs/xassets/xentryinternaldata.h 2025-09-05 21:26:08 +00:00
RedLine AI Agent
37c25d3baf Updated libs/xassets/xentryinternaldata.cpp 2025-09-05 21:26:07 +00:00
RedLine AI Agent
75802ffa8e Updated libs/xassets/xdynentitypose.h 2025-09-05 21:26:06 +00:00
RedLine AI Agent
5a35d4f4d8 [No changes] 2025-09-05 21:25:17 +00:00
RedLine AI Agent
9958f33b60 [No changes] 2025-09-05 21:25:15 +00:00
RedLine AI Agent
c1e9b308a1 [No changes] 2025-09-05 21:25:12 +00:00
RedLine AI Agent
6ef4fe82da [No changes] 2025-09-05 21:25:10 +00:00
RedLine AI Agent
8f287ceeec [No changes] 2025-09-05 21:25:09 +00:00
RedLine AI Agent
12b4a77f1f [No changes] 2025-09-05 21:24:58 +00:00
RedLine AI Agent
38dd74b188 [No changes] 2025-09-05 21:24:57 +00:00
RedLine AI Agent
e3db1e11cc [No changes] 2025-09-05 21:24:56 +00:00
RedLine AI Agent
0d9d2fccfb [No changes] 2025-09-05 21:24:56 +00:00
RedLine AI Agent
c84463e3c2 [No changes] 2025-09-05 21:24:55 +00:00
RedLine AI Agent
619cfad47c [No changes] 2025-09-05 21:24:54 +00:00
RedLine AI Agent
17408d5d4e [No changes] 2025-09-05 21:24:54 +00:00
RedLine AI Agent
04daaeaf7f [No changes] 2025-09-05 21:24:53 +00:00
RedLine AI Agent
92456f1da6 [No changes] 2025-09-05 21:24:52 +00:00
RedLine AI Agent
38909a69a6 [No changes] 2025-09-05 21:24:51 +00:00
RedLine AI Agent
26a1629dee [No changes] 2025-09-05 21:24:51 +00:00
RedLine AI Agent
cc5c1854e2 [No changes] 2025-09-05 21:24:50 +00:00
RedLine AI Agent
fccad08fb0 [No changes] 2025-09-05 21:24:46 +00:00
RedLine AI Agent
0d156994b4 [No changes] 2025-09-05 21:24:44 +00:00
RedLine AI Agent
dd1eb94beb [No changes] 2025-09-05 21:24:37 +00:00
RedLine AI Agent
b53f169a4f [No changes] 2025-09-05 21:24:29 +00:00
RedLine AI Agent
ce9bcefb88 No changes. 2025-09-05 21:24:21 +00:00
RedLine AI Agent
ab60c56e88 [No changes] 2025-09-05 21:24:14 +00:00
njohnson
32e4815cbe Update .gitignore 2025-09-05 17:22:49 -04:00
RedLine AI Agent
a8ee358150 Add: libs/*/release/*
Add: libs/*/debug/*
2025-09-05 21:05:49 +00:00
RedLine AI Agent
302350fe2c Add: data/obj/* 2025-09-05 21:02:46 +00:00
RedLine AI Agent
2f323046d3 Add: *.XMODEL_EXPORT 2025-09-05 21:01:00 +00:00
RedLine AI Agent
3dad8bfb5c Update: data/Data.qrc 2025-09-05 20:59:08 +00:00
RedLine AI Agent
f8624c8997 Update: app/zonefileviewer.ui 2025-09-05 20:59:06 +00:00
RedLine AI Agent
9d8e214ae3 Update: app/zonefileviewer.h 2025-09-05 20:59:03 +00:00
RedLine AI Agent
15bbbec1db Update: app/zonefileviewer.cpp 2025-09-05 20:54:46 +00:00
RedLine AI Agent
00a3dfb958 Update: app/xtreewidgetitem.h 2025-09-05 20:54:42 +00:00
RedLine AI Agent
12c9e79bf2 Update: app/xtreewidgetitem.cpp 2025-09-05 20:54:30 +00:00
RedLine AI Agent
39cd33efd4 Update: app/xtreewidget.h 2025-09-05 20:54:06 +00:00
RedLine AI Agent
ce5c98b78d Update: app/soundviewer.ui 2025-09-05 20:53:15 +00:00
RedLine AI Agent
053c440415 Update app/techsetviewer.ui 2025-09-05 20:47:55 +00:00
RedLine AI Agent
d477865e9a Update app/techsetviewer.h 2025-09-05 20:47:19 +00:00
RedLine AI Agent
a7e0859b8d Update app/techsetviewer.cpp 2025-09-05 20:47:17 +00:00
RedLine AI Agent
ed593d3ae1 Update app/stringtableviewer.ui 2025-09-05 20:47:15 +00:00
RedLine AI Agent
d973d2bee5 Update app/stringtableviewer.h 2025-09-05 20:47:03 +00:00
RedLine AI Agent
90c3d3bef3 Update app/stringtableviewer.cpp 2025-09-05 20:46:50 +00:00
RedLine AI Agent
d583b9ce08 Update app/soundviewer.ui 2025-09-05 20:46:36 +00:00
RedLine AI Agent
46792b3dc6 Update app/soundviewer.h 2025-09-05 20:45:06 +00:00
RedLine AI Agent
1739a4686e Update app/soundviewer.cpp 2025-09-05 20:45:03 +00:00
RedLine AI Agent
28257af738 Update app/rumblegraphviewer.ui 2025-09-05 20:45:00 +00:00
RedLine AI Agent
50fb3d2557 Update app/rumblegraphviewer.h 2025-09-05 20:44:57 +00:00
RedLine AI Agent
3f0d4641b1 Update app/rumblegraphviewer.cpp 2025-09-05 20:44:54 +00:00
RedLine AI Agent
b2fcdd1762 Update app/rumblefileviewer.ui 2025-09-05 20:44:51 +00:00
RedLine AI Agent
99706b868b Update app/rumblefileviewer.h 2025-09-05 20:44:48 +00:00
RedLine AI Agent
dfe3311323 Update app/rumblefileviewer.cpp 2025-09-05 20:44:47 +00:00
RedLine AI Agent
6a04ed7431 Update app/reportissuedialog.ui 2025-09-05 20:44:45 +00:00
RedLine AI Agent
32ab5c7451 Update app/reportissuedialog.h 2025-09-05 20:44:40 +00:00
RedLine AI Agent
b6403208f1 Update app/reportissuedialog.cpp 2025-09-05 20:44:38 +00:00
RedLine AI Agent
fcaa1eacaf Update app/preferenceeditor.ui 2025-09-05 20:44:36 +00:00
RedLine AI Agent
97c4fbddde Update app/preferenceeditor.h 2025-09-05 20:44:33 +00:00
RedLine AI Agent
ed9e7ee558 Update app/preferenceeditor.cpp 2025-09-05 20:44:31 +00:00
RedLine AI Agent
618c304a87 Update app/modelviewer.ui 2025-09-05 20:44:29 +00:00
RedLine AI Agent
cc311c2a1a Update app/modelviewer.h 2025-09-05 20:44:24 +00:00
RedLine AI Agent
fda7f55231 Update app/modelviewer.cpp 2025-09-05 20:44:12 +00:00
RedLine AI Agent
fe5724ef82 Update app/materialviewer.ui 2025-09-05 20:43:12 +00:00
RedLine AI Agent
1a0ba48b51 Update app/materialviewer.h 2025-09-05 20:42:01 +00:00
RedLine AI Agent
713d55b4eb Update app/materialviewer.cpp 2025-09-05 20:41:21 +00:00
RedLine AI Agent
59d6d6907a Refactor mainwindow.ui: replace the entire UI definition with a cleaned‑up, consistent layout and action structure. 2025-09-05 19:59:40 +00:00
RedLine AI Agent
020178f780 Update app/mainwindow.h 2025-09-05 19:57:04 +00:00
RedLine AI Agent
a2242fe018 Update app/mainwindow.cpp 2025-09-05 19:54:14 +00:00
RedLine AI Agent
ef6d1007e6 Update app/main.cpp 2025-09-05 19:54:09 +00:00
RedLine AI Agent
9971facf90 Update app/localstringviewer.ui 2025-09-05 19:54:03 +00:00
RedLine AI Agent
3a0070612a Update app/localstringviewer.h 2025-09-05 19:53:52 +00:00
RedLine AI Agent
8f415d4fe6 Update app/localstringviewer.cpp 2025-09-05 19:53:47 +00:00
RedLine AI Agent
f438e6c063 Update app/iwiviewer.ui 2025-09-05 19:53:26 +00:00
RedLine AI Agent
1e086cf00a Update app/iwiviewer.h 2025-09-05 19:53:11 +00:00
RedLine AI Agent
d166e3329a Update app/ddsviewer.h 2025-09-05 19:51:20 +00:00
RedLine AI Agent
4db49c0896 Update app/imagewidget.ui 2025-09-05 19:48:54 +00:00
RedLine AI Agent
12806268d4 Update app/imagewidget.h 2025-09-05 19:48:43 +00:00
RedLine AI Agent
39d37640cc Update app/imagewidget.cpp 2025-09-05 19:48:15 +00:00
RedLine AI Agent
d771df9b09 Update app/fastfileviewer.ui 2025-09-05 19:47:52 +00:00
RedLine AI Agent
44af7bf03c Update app/fastfileviewer.h 2025-09-05 19:47:15 +00:00
RedLine AI Agent
07e473bad0 Update app/fastfileviewer.cpp 2025-09-05 19:46:47 +00:00
RedLine AI Agent
19d417e84b Update app/ddsviewer.ui 2025-09-05 19:46:04 +00:00
RedLine AI Agent
c898f62d69 Update app/ddsviewer.h 2025-09-05 19:45:44 +00:00
RedLine AI Agent
d69f6eef40 Update app/ddsviewer.cpp 2025-09-05 19:44:32 +00:00
RedLine AI Agent
affd9fe889 Update app/d3dbsp_structs.h 2025-09-05 19:44:25 +00:00
RedLine AI Agent
90ebbd86ee Update app/app.pro 2025-09-05 19:43:49 +00:00
RedLine AI Agent
50a1aa3bbc Update app/aboutdialog.ui 2025-09-05 19:43:41 +00:00
RedLine AI Agent
270dacf1e5 Update app/aboutdialog.cpp 2025-09-05 19:43:31 +00:00
RedLine AI Agent
4a4df3c2a4 Update app/aboutdialog.cpp 2025-09-05 19:42:32 +00:00
Nicholas Johnson
4d7598e805 Update app/LICENSE: normalize line endings 2025-09-05 13:59:36 -04:00
Nicholas Johnson
94d407ffb7 Update XPlor.pro: fix formatting and line endings 2025-09-05 13:54:40 -04:00
Nicholas Johnson
3291e52cc6 Update .gitignore: remove leading hyphens and standardize patterns 2025-09-05 13:53:56 -04:00
Nicholas Johnson
f576af8f11 Remove temp autosave file. 2025-09-03 13:40:02 -04:00
Nicholas Johnson
eee7231737 Add autosave files. 2025-09-03 13:39:42 -04:00
Nicholas Johnson
e7455256a7 Add xwaterwritable structures 2025-09-03 13:28:24 -04:00
Nicholas Johnson
2a026947c4 Add xwater structures 2025-09-03 13:28:13 -04:00
Nicholas Johnson
12795451e6 Add xsurfacevertexinfo structures 2025-09-03 13:28:03 -04:00
Nicholas Johnson
c9802401fb Add xsurfacecollisiontree structures 2025-09-03 13:27:52 -04:00
Nicholas Johnson
5a12e3c967 Add xsurfacecollisionnode structures 2025-09-03 13:26:37 -04:00
Nicholas Johnson
a02e3714d0 Add xsurfacecollisionleaf structures 2025-09-03 13:26:24 -04:00
Nicholas Johnson
84f99dc919 Add xsurfacecollisionaabb structures 2025-09-03 13:26:11 -04:00
Nicholas Johnson
163f46b4cf Add xsurface structures 2025-09-03 13:25:58 -04:00
Nicholas Johnson
7b1d269986 Add xstreamsourceinfo structures 2025-09-03 13:25:47 -04:00
Nicholas Johnson
386d0793aa Add xstreamdelayinfo structures 2025-09-03 13:25:36 -04:00
Nicholas Johnson
dc3360a97d Add xscriptstringlist structures 2025-09-03 13:22:24 -04:00
Nicholas Johnson
6ab9a9b350 Add xrigidvertlist structures 2025-09-03 13:21:14 -04:00
Nicholas Johnson
e3f971f62c Add xphyspreset structures 2025-09-03 13:21:02 -04:00
Nicholas Johnson
3a718acb50 Add xphysmass structures 2025-09-03 13:20:51 -04:00
Nicholas Johnson
2e09f532b9 Add xphysgeomlist structures 2025-09-03 13:20:39 -04:00
Nicholas Johnson
c39185e35c Add xphysgeominfo structures 2025-09-03 13:20:29 -04:00
Nicholas Johnson
eee271278a Add xpackedunitvec structures 2025-09-03 13:20:19 -04:00
Nicholas Johnson
e7077aae63 Add xpackedtexcoords structures 2025-09-03 13:20:07 -04:00
Nicholas Johnson
78a6efd02f Add xmodelstreaminfo structures 2025-09-03 13:19:57 -04:00
Nicholas Johnson
73b3cc9e75 Add xmodellodinfo structures 2025-09-03 13:18:53 -04:00
Nicholas Johnson
ef6f75c8a8 Add xmodelhighmipbounds structures 2025-09-03 13:18:40 -04:00
Nicholas Johnson
3bed978b89 Add xmodelcollsurf structures 2025-09-03 13:18:27 -04:00
Nicholas Johnson
dcab86b1ed Add xmaterialvertexstreamrouting structures 2025-09-03 13:18:16 -04:00
Nicholas Johnson
7cf9ac8d4c Add xmaterialvertexdeclaration structures 2025-09-03 13:18:05 -04:00
Nicholas Johnson
e63cf8554e Add xmaterialvertexshaderprogram structures 2025-09-03 13:17:42 -04:00
Nicholas Johnson
d7e4dfda41 Add xmaterialvertexshader structures 2025-09-03 13:17:32 -04:00
Nicholas Johnson
9c92fcd854 Add xmaterialtexturedefinfo structures 2025-09-03 13:17:22 -04:00
Nicholas Johnson
7768c5f7f5 Add xmaterialtexturedef structures 2025-09-03 13:16:15 -04:00
Nicholas Johnson
58e87e8787 Add xmaterialtechnique structures 2025-09-03 13:16:04 -04:00
Nicholas Johnson
b176bc3d00 Add xmaterialstreamrouting structures 2025-09-03 13:15:52 -04:00
Nicholas Johnson
3c13462618 Add xmaterialshaderargument structures 2025-09-03 13:15:41 -04:00
Nicholas Johnson
68a41d4582 Add xmaterialpixelshaderprogram structures 2025-09-03 13:15:31 -04:00
Nicholas Johnson
60e93e0ab3 Add xmaterialpixelshader structures 2025-09-03 13:15:22 -04:00
Nicholas Johnson
9fb5c62b75 Add xmaterialpass structures 2025-09-03 13:15:13 -04:00
Nicholas Johnson
352e51170d Add xmaterialinfo structures 2025-09-03 13:15:04 -04:00
Nicholas Johnson
fc64762bfe Add xmaterialconstantdef structures 2025-09-03 13:14:06 -04:00
Nicholas Johnson
fe34c63697 Add xmaterialargumentdef structures 2025-09-03 13:13:53 -04:00
Nicholas Johnson
02d96741e8 Add xmaterialargumentcodeconst structures 2025-09-03 13:13:41 -04:00
Nicholas Johnson
d8b27a31d2 Add xmaterial.cpp 2025-09-03 13:13:30 -04:00
Nicholas Johnson
4fcd3a4c60 Add xmaterial structures 2025-09-03 13:12:46 -04:00
Nicholas Johnson
fd1868ed46 Add xmaptype structures 2025-09-03 13:12:39 -04:00
Nicholas Johnson
7250e1f460 Add xgputexturesizestack3d structures 2025-09-03 13:11:38 -04:00
Nicholas Johnson
1e0a490a69 Add xgputexturesizestack2d structures 2025-09-03 13:11:27 -04:00
Nicholas Johnson
bfedb389b8 Add xgputexturesizestack1d structures 2025-09-03 13:11:16 -04:00
Nicholas Johnson
0a2fdd0b74 Add xgputexturesizestack structures 2025-09-03 13:11:05 -04:00
Nicholas Johnson
a2959f9b29 Add xgputexturesize3d structures 2025-09-03 13:10:54 -04:00
Nicholas Johnson
cd99390ba7 Add xgputexturesize2d structures 2025-09-03 13:10:44 -04:00
Nicholas Johnson
388e2dfc52 Add xgputexturesize1d structures 2025-09-03 13:10:35 -04:00
Nicholas Johnson
47e09afa73 Add xgpuvertexrawrequest structures 2025-09-03 13:08:56 -04:00
Nicholas Johnson
cdef686ec4 Add xgpuvertexfetchconstant structures 2025-09-03 13:08:47 -04:00
Nicholas Johnson
be21cf40cb Add xgfxvertexshaderloaddef structures 2025-09-03 13:08:37 -04:00
Nicholas Johnson
4eb817375c Add xgfxstatebits structures 2025-09-03 13:08:03 -04:00
Nicholas Johnson
5a623c18d0 Add xgfxpixelshaderloaddef structures 2025-09-03 13:07:19 -04:00
Nicholas Johnson
63ca1074fc Add xgfxpackedvertex structures 2025-09-03 13:07:08 -04:00
Nicholas Johnson
9a70b774ab Add xgfxdrawsurffields structures 2025-09-03 13:06:58 -04:00
Nicholas Johnson
ea385c2853 Add xgfxdrawsurf structures 2025-09-03 13:06:49 -04:00
Nicholas Johnson
f9604bc858 Add xgfxcolor structures 2025-09-03 13:06:40 -04:00
Nicholas Johnson
65a37363e6 Add xfxtrailvertex structures 2025-09-03 13:06:31 -04:00
Nicholas Johnson
2879a89594 Add xfxtraildef structures 2025-09-03 13:06:22 -04:00
Nicholas Johnson
6bc88394cd Add xfximpactentry structures 2025-09-03 13:06:13 -04:00
Nicholas Johnson
f17d56c603 Add xfxelemvisuals structures 2025-09-03 13:05:35 -04:00
Nicholas Johnson
2253db1abb Add xfxelemvisstatesample structures 2025-09-03 13:05:24 -04:00
Nicholas Johnson
c362953775 Add xfxelemmarkvisuals structures 2025-09-03 13:05:14 -04:00
Nicholas Johnson
6ea2989d69 Add xfxelemdefvisuals structures 2025-09-03 13:05:03 -04:00
Nicholas Johnson
ea90db4fe6 Add xfxelemdef structures 2025-09-03 13:04:54 -04:00
Nicholas Johnson
2b1a18be6a Add xfile structures 2025-09-03 13:04:45 -04:00
Nicholas Johnson
40ad7470aa Add new asset-related structures and files 2025-09-03 13:04:24 -04:00
Nicholas Johnson
89d1d0944a Update zonefile structures and project files 2025-09-03 13:03:14 -04:00
Nicholas Johnson
73e13263fc Update node type and path node transient structures 2025-09-03 13:03:03 -04:00
Nicholas Johnson
60ddd31101 Update model structures 2025-09-03 13:02:54 -04:00
Nicholas Johnson
ee4a680d6d Update GPU texture fetch constant structures 2025-09-03 13:02:39 -04:00
Nicholas Johnson
2f61367fcb Update texture handling structures 2025-09-03 13:02:31 -04:00
Nicholas Johnson
c7b1c97d68 Update lighting and streaming AABB tree structures 2025-09-03 13:02:23 -04:00
Nicholas Johnson
ed30f6b861 Update material and image handling structures 2025-09-03 13:01:39 -04:00
Nicholas Johnson
5ea8c5f09a Update Direct3D texture structures 2025-09-03 13:01:26 -04:00
Nicholas Johnson
d1cf5ecc52 Update collision leaf and brush node structures 2025-09-03 13:01:12 -04:00
Nicholas Johnson
a85abf0ecd Update asset and animation structure definitions 2025-09-03 13:00:58 -04:00
Nicholas Johnson
caca3dd489 Update animation-related files 2025-09-03 13:00:41 -04:00
Nicholas Johnson
39853c77fe Update asset-related core files 2025-09-03 13:00:27 -04:00
Nicholas Johnson
f149b66322 Remove deprecated and unused asset-related files 2025-09-03 13:00:02 -04:00
Nicholas Johnson
0ea4a7ad6f Added a tonnn of new classes. 2025-08-17 13:14:17 -04:00
Nicholas Johnson
729a6bac7c Renamed Assets to XAssets. 2025-08-14 18:50:13 -04:00
Nicholas Johnson
be8aa3691e Hey baby girl 2025-08-14 17:30:25 -04:00
Nicholas Johnson
cfa0638b94 More decompiled translations :(. 2025-07-10 01:07:48 -04:00
=
ff1a25b41f Uh. 2025-07-10 00:11:33 -04:00
=
a0cfb65b56 Add tool changes to project. 2025-07-10 00:11:20 -04:00
=
77428c0515 update tests and project. 2025-07-10 00:11:06 -04:00
=
34d6ae6658 Fastfile and other file changes. 2025-07-10 00:10:49 -04:00
=
f339360fbc Removed/renamed some files. 2025-07-10 00:10:30 -04:00
=
f23c38cc3c Removed/renamed some files. 2025-07-10 00:10:16 -04:00
=
fdf1559f09 Tried making magic asset parser. To be contondered. 2025-07-10 00:09:18 -04:00
=
556e33d56f Added dxd9 sdk, even big libs lol. 2025-07-10 00:08:30 -04:00
=
c980d53543 Tried using the IDA pro exports, didnt work. 2025-07-10 00:07:22 -04:00
=
c8cfc1c5fc Autotest changes. 2025-07-10 00:06:51 -04:00
=
a7904ca74e Compro changes. 2025-07-10 00:06:37 -04:00
=
6cc3d71acf Some bs zentry changes. 2025-07-10 00:06:16 -04:00
=
23827f4ffa Zonefile changes and additions. 2025-07-10 00:05:44 -04:00
=
67050e6a67 Lotta asset changes 2025-07-10 00:04:52 -04:00
=
0943608bd8 Add issue reporter dialog. 2025-07-10 00:02:15 -04:00
=
f1aa61bf3b Add ported code from ida. 2025-06-07 11:20:47 -04:00
=
691a16e9ad Add report issue dialog. 2025-06-07 11:16:24 -04:00
=
0a3a307d39 Add to .gitignore 2025-06-04 23:41:09 -04:00
6632149f42 Merge pull request 'Enhanced Feature Implementation and Cleanup' (#1) from feature/icon_factory into main
Reviewed-on: https://git.redline.llc/njohnson/XPlor/pulls/1
2025-06-04 22:40:19 -04:00
988 changed files with 281284 additions and 51759 deletions

13
.gitignore vendored
View File

@ -1,6 +1,10 @@
/build/
/data/dlls/
/data/fastfiles/
/releases/
.vscode/*
.qmake.stash
# Ignore Qt Creator user files
*.pro.user
@ -10,3 +14,12 @@
*.creator.user
*.creator.user.*
*.creator.*
*.ps1
version.txt
*.autosave
*.XMODEL_EXPORT
data/obj/*
libs/*/release/*
libs/*/debug/*
.git.stash
*Makefile*

View File

@ -2,9 +2,9 @@ TEMPLATE = subdirs
SUBDIRS += libs \
app \
tools \
tests
#tools \
#tests
tests.depends = libs
#tests.depends = libs
app.depends = libs
tools.depends = libs
#tools.depends = libs

36
ai-commit.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
set -e
# 1. Stage everything
git add -A
# 2. Get list of staged files
FILES=$(git diff --cached --name-only)
if [ -z "$FILES" ]; then
echo "No changes to commit."
exit 0
fi
# 3. Loop file by file
for FILE in $FILES; do
# Get diff for this file
DIFF=$(git diff --cached -- "$FILE")
if [ -z "$DIFF" ]; then
continue
fi
# Ask Ollama for a commit message describing this file change
MSG=$(echo "$DIFF" | ollama run gemma3 \
"You are a commit bot. Write a SHORT, clear, concise Git commit message for changes in file: $FILE.
Only output the commit message, nothing else.
Diff:
$DIFF")
# Commit just this file with its message
git commit -m "$MSG" -- "$FILE"
echo "✅ Committed $FILE with message:"
echo "$MSG"
done

View File

@ -6,63 +6,9 @@ SUBDIRS += app
CONFIG += c++17
SOURCES += \
aboutdialog.cpp \
ddsviewer.cpp \
fastfileviewer.cpp \
imagewidget.cpp \
iwiviewer.cpp \
localstringviewer.cpp \
main.cpp \
mainwindow.cpp \
materialviewer.cpp \
preferenceeditor.cpp \
soundviewer.cpp \
stringtableviewer.cpp \
rumblegraphviewer.cpp \
rumblefileviewer.cpp \
techsetviewer.cpp \
xtreewidget.cpp \
xtreewidgetitem.cpp \
zonefileviewer.cpp
HEADERS += \
aboutdialog.h \
d3dbsp_structs.h \
ddsviewer.h \
fastfileviewer.h \
imagewidget.h \
iwiviewer.h \
localstringviewer.h \
mainwindow.h \
materialviewer.h \
preferenceeditor.h \
soundviewer.h \
stringtableviewer.h \
rumblegraphviewer.h \
rumblefileviewer.h \
techsetviewer.h \
xtreewidget.h \
xtreewidgetitem.h \
zonefileviewer.h
FORMS += \
aboutdialog.ui \
ddsviewer.ui \
fastfileviewer.ui \
imagewidget.ui \
iwiviewer.ui \
localstringviewer.ui \
mainwindow.ui \
materialviewer.ui \
modelviewer.ui \
preferenceeditor.ui \
soundviewer.ui \
stringtableviewer.ui \
rumblegraphviewer.ui \
rumblefileviewer.ui \
techsetviewer.ui \
zonefileviewer.ui
SOURCES += $$files($$PWD/*.cpp)
HEADERS += $$files($$PWD/*.h)
FORMS += $$files($$PWD/*.ui)
RESOURCES += ../data/data.qrc
@ -71,6 +17,7 @@ LIBS += \
-L$$PWD/../third_party/zlib/lib/ -lzlib \
-L$$PWD/../third_party/xbox_sdk/lib -lxcompress64 \
-L$$OUT_PWD/../libs/ -lcore \
-L$$OUT_PWD/../libs/ -lxassets\
-L$$OUT_PWD/../libs/ -lcompression \
-L$$OUT_PWD/../libs/ -lencryption \
-L$$OUT_PWD/../libs/ -lfastfile \
@ -90,6 +37,7 @@ INCLUDEPATH += \
$$PWD/../libs/ddsfile \
$$PWD/../libs/ipakfile \
$$PWD/../libs/iwifile \
$$PWD/../libs/xassets \
$$PWD/../libs/zonefile
DEPENDPATH += \
@ -103,16 +51,11 @@ DEPENDPATH += \
$$PWD/../libs/ddsfile \
$$PWD/../libs/ipakfile \
$$PWD/../libs/iwifile \
$$PWD/../libs/xassets \
$$PWD/../libs/zonefile
# Copy DLLs to Debug folder
QMAKE_POST_LINK += xcopy /Y /E /I \"G:/Projects/Qt/XPlor/third_party/devil_sdk/lib\\*.dll\" \"$$OUT_PWD/debug/\" $$escape_expand(\\n\\t)
QMAKE_POST_LINK += xcopy /Y /E /I \"G:/Projects/Qt/XPlor/third_party/zlib/lib\\*.dll\" \"$$OUT_PWD/debug/\" $$escape_expand(\\n\\t)
QMAKE_POST_LINK += xcopy /Y /E /I \"G:/Projects/Qt/XPlor/third_party/xna/lib\\*.dll\" \"$$OUT_PWD/debug/\" $$escape_expand(\\n\\t)
QMAKE_POST_LINK += xcopy /Y /E /I \"$$PWD/../third_party/xbox_sdk/lib\\*.dll\" \"$$OUT_PWD/debug/\" $$escape_expand(\\n\\t)
# Copy DLLs to Release folder
QMAKE_POST_LINK += xcopy /Y /E /I \"G:/Projects/Qt/XPlor/third_party/devil_sdk/lib\\*.dll\" \"$$OUT_PWD/release/\" $$escape_expand(\\n\\t)
QMAKE_POST_LINK += xcopy /Y /E /I \"G:/Projects/Qt/XPlor/third_party/zlib/lib\\*.dll\" \"$$OUT_PWD/release/\" $$escape_expand(\\n\\t)
QMAKE_POST_LINK += xcopy /Y /E /I \"G:/Projects/Qt/XPlor/third_party/xna/lib\\*.dll\" \"$$OUT_PWD/release/\" $$escape_expand(\\n\\t)
QMAKE_POST_LINK += xcopy /Y /E /I \"$$PWD/../third_party/xbox_sdk/lib\\*.dll\" \"$$OUT_PWD/release/\" $$escape_expand(\\n\\t)
win32 {
QMAKE_POST_LINK =
QMAKE_POST_LINK += for /D %%G in (\"$$PWD/../third_party/*/lib\") do copy /Y \"%%~G\*.dll\" \"$$OUT_PWD/$$DESTDIR/\" >NUL $$escape_expand(\\n\\t)
}

View File

@ -14,8 +14,8 @@ DDSViewer::~DDSViewer() {
delete ui;
}
void DDSViewer::SetDDSFile(std::shared_ptr<DDSFile> aDDSFile) {
mDDSFile.swap(aDDSFile);
void DDSViewer::SetDDSFile(const DDSFile* aDDSFile) {
mDDSFile = aDDSFile;
ui->label_Title->setText(mDDSFile->fileStem + ".dds");

View File

@ -16,14 +16,14 @@ public:
explicit DDSViewer(QWidget *parent = nullptr);
~DDSViewer();
void SetDDSFile(std::shared_ptr<DDSFile> aDDSFile);
void SetDDSFile(const DDSFile *aDDSFile);
private slots:
void MipmapIndexChanged(int aMipmapIndex);
private:
Ui::DDSViewer *ui;
std::shared_ptr<DDSFile> mDDSFile;
const DDSFile* mDDSFile;
};
#endif // DDSVIEWER_H

View File

@ -1,5 +1,4 @@
#include "fastfileviewer.h"
#include "asset_structs.h"
#include "ui_fastfileviewer.h"
FastFileViewer::FastFileViewer(QWidget *parent)
@ -15,8 +14,8 @@ FastFileViewer::~FastFileViewer()
delete ui;
}
void FastFileViewer::SetFastFile(std::shared_ptr<FastFile> aFastFile) {
mFastFile.swap(aFastFile);
void FastFileViewer::SetFastFile(const FastFile* aFastFile) {
mFastFile = aFastFile;
ui->label_Title->setText(mFastFile->GetStem());
ui->comboBox_Company->setCurrentIndex(mFastFile->GetCompany());

View File

@ -1,7 +1,6 @@
#ifndef FASTFILEVIEWER_H
#define FASTFILEVIEWER_H
#include "asset_structs.h"
#include "fastfile.h"
#include <QWidget>
@ -17,10 +16,10 @@ public:
explicit FastFileViewer(QWidget *parent = nullptr);
~FastFileViewer();
void SetFastFile(std::shared_ptr<FastFile> aFastFile);
void SetFastFile(const FastFile *aFastFile);
private:
Ui::FFViewer *ui;
std::shared_ptr<FastFile> mFastFile;
const FastFile* mFastFile;
};
#endif // FASTFILEVIEWER_H

View File

@ -13,16 +13,16 @@ ImageWidget::~ImageWidget()
delete ui;
}
void ImageWidget::SetImage(std::shared_ptr<Image> aImage)
void ImageWidget::SetImage(std::shared_ptr<QImage> aImage)
{
mImage = aImage;
ui->lineEdit_Name->setText(aImage->name);
ui->lineEdit_Role->setText(aImage->materialName);
ui->comboBox_Compression->setCurrentIndex(aImage->compression);
//ui->lineEdit_Name->setText(aImage->name);
//ui->lineEdit_Role->setText(aImage->materialName);
//ui->comboBox_Compression->setCurrentIndex(aImage->compression);
}
std::shared_ptr<Image> ImageWidget::GetImage()
std::shared_ptr<QImage> ImageWidget::GetImage()
{
return mImage;
}

View File

@ -4,7 +4,6 @@
#include "enums.h"
#include "dds_structs.h"
#include "d3dbsp_structs.h"
#include "asset_structs.h"
#include "ipak_structs.h"
#include <QWidget>
@ -21,11 +20,11 @@ public:
explicit ImageWidget(QWidget *parent = nullptr);
~ImageWidget();
void SetImage(std::shared_ptr<Image> aImage);
std::shared_ptr<Image> GetImage();
void SetImage(std::shared_ptr<QImage> aImage);
std::shared_ptr<QImage> GetImage();
private:
std::shared_ptr<Image> mImage;
std::shared_ptr<QImage> mImage;
Ui::ImageWidget *ui;
};

View File

@ -14,8 +14,8 @@ IWIViewer::~IWIViewer()
delete ui;
}
void IWIViewer::SetIWIFile(std::shared_ptr<IWIFile> aIWIFile) {
mIWIFile.swap(aIWIFile);
void IWIViewer::SetIWIFile(const IWIFile* aIWIFile) {
mIWIFile = aIWIFile;
ui->label_Title->setText(mIWIFile->fileStem + ".iwi");

View File

@ -18,10 +18,10 @@ public:
void MipmapIndexChanged(int aMipmapIndex);
void SetIWIFile(std::shared_ptr<IWIFile> aIWIFile);
void SetIWIFile(const IWIFile *aIWIFile);
private:
Ui::IWIViewer *ui;
std::shared_ptr<IWIFile> mIWIFile;
const IWIFile* mIWIFile;
};
#endif // IWIVIEWER_H

View File

@ -37,26 +37,22 @@ void LocalStringViewer::SetFileNotes(const QString aFileNotes) {
ui->plainTextEdit_FileNotes->setPlainText(mFileNotes);
}
void LocalStringViewer::AddLocalString(LocalString aLocalString) {
void LocalStringViewer::AddLocalString(XLocalizeEntry aLocalString) {
mLocalStrings.append(aLocalString);
ui->tableWidget_Strings->setRowCount(mLocalStrings.size());
ui->groupBox_LocalStrViewer->setTitle(QString("Entries (%1)").arg(mLocalStrings.size()));
QTableWidgetItem *aliasItem = new QTableWidgetItem(aLocalString.alias);
QTableWidgetItem *stringItem = new QTableWidgetItem(aLocalString.string);
QTableWidgetItem *aliasItem = new QTableWidgetItem(aLocalString.GetValue()->GetString());
QTableWidgetItem *stringItem = new QTableWidgetItem(aLocalString.GetName()->GetString());
ui->tableWidget_Strings->setItem(mLocalStrings.size() - 1, 0, aliasItem);
ui->tableWidget_Strings->setItem(mLocalStrings.size() - 1, 1, stringItem);
}
void LocalStringViewer::SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile) {
void LocalStringViewer::SetZoneFile(const ZoneFile* aZoneFile) {
mLocalStrings.clear();
ui->tableWidget_Strings->clear();
ui->label_Title->setText(aZoneFile->GetStem().section('.', 0, 0) + ".str");
for (const LocalString &localStr : aZoneFile->GetAssetMap().localStrings) {
AddLocalString(localStr);
}
// for (const LocalString &localStr : aZoneFile->GetAssetMap().localStrings) {
// AddLocalString(localStr);
// }
}

View File

@ -1,7 +1,7 @@
#ifndef LOCALSTRINGVIEWER_H
#define LOCALSTRINGVIEWER_H
#include "asset_structs.h"
#include "xlocalizeentry.h"
#include "zonefile.h"
#include <QWidget>
@ -20,15 +20,15 @@ public:
void SetVersion(quint32 aVersion);
void SetConfigPath(const QString aConfigPath);
void SetFileNotes(const QString aFileNotes);
void AddLocalString(LocalString aLocalString);
void SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile);
void AddLocalString(XLocalizeEntry aLocalString);
void SetZoneFile(const ZoneFile *aZoneFile);
private:
Ui::LocalStringViewer *ui;
quint32 mVersion;
QString mConfigPath;
QString mFileNotes;
QVector<LocalString> mLocalStrings;
QVector<XLocalizeEntry> mLocalStrings;
};
#endif // LOCALSTRINGVIEWER_H

View File

@ -1,4 +1,7 @@
#include "mainwindow.h"
#include "qtimer.h"
#include "ui_mainwindow.h"
#include "aboutdialog.h"
#include "fastfile.h"
#include "highlighter_gsc.h"
@ -7,12 +10,10 @@
#include "highlighter_rumble.h"
#include "materialviewer.h"
#include "preferenceeditor.h"
#include "rumblefileviewer.h"
#include "reportissuedialog.h"
#include "rumblegraphviewer.h"
#include "soundviewer.h"
#include "stringtableviewer.h"
#include "techsetviewer.h"
#include "ui_mainwindow.h"
#include "fastfile_factory.h"
#include "iwifile.h"
#include "ddsfile.h"
@ -22,13 +23,11 @@
#include "ipak_structs.h"
#include "iwiviewer.h"
#include "localstringviewer.h"
#include "imagewidget.h"
#include "xtreewidget.h"
#include "zonefileviewer.h"
#include "techsetviewer.h"
#include "logmanager.h"
#include <qmath.h>
#include <QtMath>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
@ -36,10 +35,12 @@ MainWindow::MainWindow(QWidget *parent)
setAcceptDrops(true);
XAsset::SetDebug(true);
mTypeMap = QMap<QString, int>();
mTypeOrder = QStringList();
mRawFileMap = QMap<QString, QString>();
mImageMap = QMap<QString, Image>();
//mImageMap = QMap<QString, Image>();
mTreeMap = QMap<QString, QTreeWidgetItem *>();
mStrTableMap = QMap<QString, QVector<QPair<QString, QString>>>();
mBSPVersion = 0;
@ -49,13 +50,23 @@ MainWindow::MainWindow(QWidget *parent)
mTreeWidget = new XTreeWidget(this);
mLogWidget = new QPlainTextEdit(this);
//ModelViewer *mModelViewer = new ModelViewer(container);
//mModelViewer->setAcceptDrops(false);
mProgressBar = new QProgressBar(this);
mProgressBar->setMaximum(100); // Default max value
mProgressBar->setVisible(false); // Initially hidden
connect(ui->actionRun_Tests, &QAction::triggered, this, [](bool checked) {
Q_UNUSED(checked);
});
connect(ui->actionReport_Issue, &QAction::triggered, this, [this](bool checked) {
Q_UNUSED(checked);
ReportIssueDialog issueDialog("https://git.redline.llc", "njohnson", "XPlor", "4738c4d2efd123efac1506c68c59b285c646df9f", this);
if (issueDialog.exec() == QDialog::Accepted) {
}
});
connect(&StatusBarManager::instance(), &StatusBarManager::statusUpdated,
this, &MainWindow::HandleStatusUpdate);
@ -148,7 +159,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->tabWidget->clear();
});
connect(mTreeWidget, &XTreeWidget::RawFileSelected, this, [this](std::shared_ptr<RawFile> rawFile, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::RawFileSelected, this, [this](const XRawFile* rawFile, const QString aParentName) {
QTabWidget *rawTabWidget = new QTabWidget(this);
rawTabWidget->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
@ -157,13 +168,13 @@ MainWindow::MainWindow(QWidget *parent)
scriptEditor->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
scriptEditor->setFont(QFont("Consolas"));
if (rawFile->contents.isEmpty()) {
scriptEditor->setPlainText("EMPTY");
} else {
scriptEditor->setPlainText(rawFile->contents);
}
// if (rawFile->contents.isEmpty()) {
// scriptEditor->setPlainText("EMPTY");
// } else {
// scriptEditor->setPlainText(rawFile->contents);
// }
QString fileStem = rawFile->path.split('/').last();
QString fileStem;// = rawFile->path.split('/').last();
for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->tabText(i) == fileStem) {
delete scriptEditor;
@ -175,7 +186,7 @@ MainWindow::MainWindow(QWidget *parent)
QFontMetrics metrics(scriptEditor->font());
scriptEditor->setTabStopDistance(tabStopSpaces * metrics.horizontalAdvance(' '));
QSyntaxHighlighter *highlighter;
QSyntaxHighlighter *highlighter = nullptr;
if (fileStem.contains(".gsc")) {
highlighter = new Highlighter_GSC(scriptEditor->document());
} else if (fileStem.contains(".cfg")) {
@ -191,12 +202,12 @@ MainWindow::MainWindow(QWidget *parent)
rawTabWidget->addTab(scriptEditor, "Text Editor");
ui->tabWidget->addTab(rawTabWidget, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_RUMBLE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_RUMBLE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
return;
} else if (fileStem.contains(".shock")) {
highlighter = new Highlighter_Shock(scriptEditor->document());
} else if (rawFile->contents.left(6) == "RUMBLE") {
} /*else if (rawFile->contents.left(6) == "RUMBLE") {
RumbleFileViewer *rmbFileViewer = new RumbleFileViewer(this);
rmbFileViewer->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
rmbFileViewer->SetRumbleFile(rawFile);
@ -205,59 +216,61 @@ MainWindow::MainWindow(QWidget *parent)
rawTabWidget->addTab(scriptEditor, "Text Editor");
ui->tabWidget->addTab(rawTabWidget, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_RUMBLE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_RUMBLE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
return;
}*/ else {
delete highlighter;
}
ui->tabWidget->addTab(scriptEditor, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_RAW_FILE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_RAWFILE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::ImageSelected, this, [this](std::shared_ptr<Image> image, const QString aParentName) {
ImageWidget *mImageWidget = new ImageWidget(this);
mImageWidget->setAcceptDrops(false);
mImageWidget->SetImage(image);
mImageWidget->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
// connect(mTreeWidget, &XTreeWidget::ImageSelected, this, [this](std::shared_ptr<Image> image, const QString aParentName) {
// ImageWidget *mImageWidget = new ImageWidget(this);
// mImageWidget->setAcceptDrops(false);
// mImageWidget->SetImage(image);
// mImageWidget->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
QString fileStem = image->materialName;
for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->tabText(i) == fileStem) {
delete mImageWidget;
return;
}
}
// QString fileStem = image->materialName;
// for (int i = 0; i < ui->tabWidget->count(); i++) {
// if (ui->tabWidget->tabText(i) == fileStem) {
// delete mImageWidget;
// return;
// }
// }
ui->tabWidget->addTab(mImageWidget, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
// ui->tabWidget->addTab(mImageWidget, fileStem);
// ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_IMAGE));
// ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
// });
connect(mTreeWidget, &XTreeWidget::MenuSelected, this, [](std::shared_ptr<Menu> menu, const QString aParentName) {
Q_UNUSED(menu);
});
// connect(mTreeWidget, &XTreeWidget::MenuSelected, this, [](std::shared_ptr<Menu> menu, const QString aParentName) {
// Q_UNUSED(menu);
// });
connect(mTreeWidget, &XTreeWidget::MaterialSelected, this, [this](std::shared_ptr<Material> material, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::MaterialSelected, this, [this](const XMaterial* material, const QString aParentName) {
MaterialViewer *matViewer = new MaterialViewer(this);
matViewer->setAcceptDrops(false);
matViewer->SetMaterial(material);
matViewer->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
QString fileStem = material->name;
for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->tabText(i) == fileStem) {
delete matViewer;
return;
}
}
// QString fileStem = material->name;
// for (int i = 0; i < ui->tabWidget->count(); i++) {
// if (ui->tabWidget->tabText(i) == fileStem) {
// delete matViewer;
// return;
// }
// }
ui->tabWidget->addTab(matViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_MATERIAL));
//ui->tabWidget->addTab(matViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_MATERIAL));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::DDSFileSelected, this, [this](std::shared_ptr<DDSFile> ddsFile, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::DDSFileSelected, this, [this](const DDSFile* ddsFile, const QString aParentName) {
DDSViewer *ddsViewer = new DDSViewer(this);
ddsViewer->setAcceptDrops(false);
ddsViewer->SetDDSFile(ddsFile);
@ -272,11 +285,11 @@ MainWindow::MainWindow(QWidget *parent)
}
ui->tabWidget->addTab(ddsViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_IMAGE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::IWIFileSelected, this, [this](std::shared_ptr<IWIFile> iwiFile, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::IWIFileSelected, this, [this](const IWIFile* iwiFile, const QString aParentName) {
IWIViewer *iwiViewer = new IWIViewer(this);
iwiViewer->setAcceptDrops(false);
iwiViewer->SetIWIFile(iwiFile);
@ -291,11 +304,11 @@ MainWindow::MainWindow(QWidget *parent)
}
ui->tabWidget->addTab(iwiViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_IMAGE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::FastFileSelected, this, [this](std::shared_ptr<FastFile> aFastFile, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::FastFileSelected, this, [this](const FastFile* aFastFile, const QString aParentName) {
FastFileViewer *fastFileViewer = new FastFileViewer(this);
fastFileViewer->setAcceptDrops(false);
fastFileViewer->SetFastFile(aFastFile);
@ -310,11 +323,11 @@ MainWindow::MainWindow(QWidget *parent)
}
ui->tabWidget->addTab(fastFileViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_FAST_FILE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon("FF"));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::ZoneFileSelected, this, [this](std::shared_ptr<ZoneFile> aZoneFile, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::ZoneFileSelected, this, [this](const ZoneFile* aZoneFile, const QString aParentName) {
ZoneFileViewer *zoneFileViewer = new ZoneFileViewer(this);
zoneFileViewer->setAcceptDrops(false);
zoneFileViewer->SetZoneFile(aZoneFile);
@ -341,11 +354,11 @@ MainWindow::MainWindow(QWidget *parent)
scrollArea->setWidget(containerWidget);
ui->tabWidget->addTab(scrollArea, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_ZONE_FILE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon("ZF"));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::LocalStringSelected, this, [this](std::shared_ptr<ZoneFile> aZoneFile, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::LocalStringSelected, this, [this](const ZoneFile* aZoneFile, const QString aParentName) {
LocalStringViewer *localStrViewer = new LocalStringViewer(this);
localStrViewer->setAcceptDrops(false);
localStrViewer->SetZoneFile(aZoneFile);
@ -360,17 +373,17 @@ MainWindow::MainWindow(QWidget *parent)
}
ui->tabWidget->addTab(localStrViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_LOCAL_STRING));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_LOCALIZE_ENTRY));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::TechSetSelected, this, [this](std::shared_ptr<TechSet> aTechSet, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::TechSetSelected, this, [this](const XMaterialTechniqueSet* aTechSet, const QString aParentName) {
TechSetViewer *techSetViewer = new TechSetViewer(this);
techSetViewer->setAcceptDrops(false);
techSetViewer->SetTechSet(aTechSet);
techSetViewer->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
QString fileStem = aTechSet->name;
QString fileStem = aTechSet->GetName();
for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->tabText(i) == fileStem) {
delete techSetViewer;
@ -378,18 +391,18 @@ MainWindow::MainWindow(QWidget *parent)
}
}
ui->tabWidget->addTab(techSetViewer, aTechSet->name);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_TECH_SET));
ui->tabWidget->addTab(techSetViewer, aTechSet->GetName());
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_TECHNIQUE_SET));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::StrTableSelected, this, [this](std::shared_ptr<StringTable> aStrTable, const QString aParentName) {
connect(mTreeWidget, &XTreeWidget::StrTableSelected, this, [this](const XStringTable* aStrTable, const QString aParentName) {
StringTableViewer *strTableViewer = new StringTableViewer(this);
strTableViewer->setAcceptDrops(false);
strTableViewer->SetStringTable(aStrTable);
strTableViewer->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
QString fileStem = aStrTable->name;
QString fileStem = aStrTable->GetName()->GetString();
for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->tabText(i) == fileStem) {
delete strTableViewer;
@ -398,28 +411,28 @@ MainWindow::MainWindow(QWidget *parent)
}
ui->tabWidget->addTab(strTableViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_STRING_TABLE));
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_STRINGTABLE));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
connect(mTreeWidget, &XTreeWidget::SoundSelected, this, [this](std::shared_ptr<Sound> aSound, const QString aParentName) {
SoundViewer *soundViewer = new SoundViewer(this);
soundViewer->setAcceptDrops(false);
soundViewer->SetSound(aSound);
soundViewer->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
// connect(mTreeWidget, &XTreeWidget::SoundSelected, this, [this](std::shared_ptr<Sound> aSound, const QString aParentName) {
// SoundViewer *soundViewer = new SoundViewer(this);
// soundViewer->setAcceptDrops(false);
// soundViewer->SetSound(aSound);
// soundViewer->setProperty("PARENT_NAME", QVariant::fromValue(aParentName));
QString fileStem = aSound->path.split('/').last();
for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->tabText(i) == fileStem) {
delete soundViewer;
return;
}
}
// QString fileStem = aSound->path.split('/').last();
// for (int i = 0; i < ui->tabWidget->count(); i++) {
// if (ui->tabWidget->tabText(i) == fileStem) {
// delete soundViewer;
// return;
// }
// }
ui->tabWidget->addTab(soundViewer, fileStem);
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, ZoneFile::AssetTypeToIcon(ASSET_SOUND));
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
});
// ui->tabWidget->addTab(soundViewer, fileStem);
// ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, Utils::CreateAssetIcon(ASSET_TYPE_SOUND));
// ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
// });
connect(mTreeWidget, &XTreeWidget::ItemSelected, this, [this](const QString itemText) {
for (int i = 0; i < ui->tabWidget->count(); i++) {
@ -520,7 +533,22 @@ bool MainWindow::OpenFastFile(const QString aFastFilePath) {
return false;
}
std::shared_ptr<FastFile> fastFile = FastFileFactory::Create(aFastFilePath);
FastFile* fastFile = FastFile::Open(aFastFilePath);
fastFile->SetStem(fastFileStem);
mTreeWidget->AddFastFile(fastFile);
// Open zone file after decompressing ff and writing
return true;
}
bool MainWindow::OpenFastFile(const QByteArray& aFastFileData, const QString aFastFilePath) {
const QString fastFileStem = aFastFilePath.section("/", -1, -1);
if (mTreeWidget->HasFastFile(fastFileStem)) {
LogManager::instance().addError("Can't add duplicate file!");
return false;
}
FastFile* fastFile = FastFile::Open(aFastFileData);
fastFile->SetStem(fastFileStem);
mTreeWidget->AddFastFile(fastFile);
@ -535,11 +563,13 @@ bool MainWindow::OpenFastFile(const QString aFastFilePath) {
and opens the selected file.
*/
bool MainWindow::OpenFastFile() {
const QString fastFileName = Utils::GetOpenFastFileName();
if (!OpenFastFile(fastFileName)) {
qDebug() << "Failed to open Fast file!";
return false;
}
// Open file dialog to steam apps
const QString steamPath = "C:/Program Files (x86)/Steam/steamapps/common/Call of Duty World at War/zone/english/";
QFileDialog::getOpenFileContent(tr("Fast File (*.ff);;All Files (*.*)"), [this](const QString &fileName, const QByteArray &data){
OpenFastFile(data, fileName);
});
return true;
}
@ -553,7 +583,7 @@ bool MainWindow::OpenZoneFile(const QString aZoneFilePath, bool fromFF) {
Q_UNUSED(aZoneFilePath);
Q_UNUSED(fromFF);
//ZoneFile zoneFile;
// ZoneFile* zoneFile = ZoneFile::Create();
// if (!zoneFile.Load(aZoneFilePath)) {
// qDebug() << "Error: Failed to load zone file!";
// return false;
@ -564,8 +594,14 @@ bool MainWindow::OpenZoneFile(const QString aZoneFilePath, bool fromFF) {
}
bool MainWindow::OpenZoneFile() {
const QString zoneFileName = Utils::GetOpenZoneFileName();
if (!OpenZoneFile(zoneFileName)) {
// Open file dialog to steam apps
const QString steamPath = "C:/Program Files (x86)/Steam/steamapps/common/Call of Duty World at War/zone/english/";
const QString zoneFilePath = QFileDialog::getOpenFileName(this, "Open Zone File", steamPath, "Zone File (*.zone);;All Files (*.*)");
if (zoneFilePath.isNull()) {
// User pressed cancel
return false;
} else if (!QFile::exists(zoneFilePath)) {
QMessageBox::warning(this, "Warning!", QString("%1 does not exist!.").arg(zoneFilePath));
qDebug() << "Failed to open Zone file!";
return false;
}
@ -637,7 +673,7 @@ quint32 DXT3 = 0x33545844; // 'DXT3'
quint32 DXT5 = 0x35545844; // 'DXT5'
int MainWindow::LoadFile_IWI(const QString aFilePath) {
mTreeWidget->AddIWIFile(std::make_shared<IWIFile>(aFilePath));
mTreeWidget->AddIWIFile(new IWIFile(aFilePath));
return 0;
}
@ -648,7 +684,7 @@ int MainWindow::LoadFile_DDSFiles(const QStringList aFilePaths) {
qDebug() << "Error: Invalid filename " << filePath;
return -1;
}
mTreeWidget->AddDDSFile(std::make_shared<DDSFile>(filePath));
mTreeWidget->AddDDSFile(new DDSFile(filePath));
}
return 0;
}
@ -680,7 +716,7 @@ int MainWindow::LoadFile_DDS(const QString aFilePath) {
qDebug() << "Error: Invalid filename " << aFilePath;
return -1;
}
mTreeWidget->AddDDSFile(std::make_shared<DDSFile>(aFilePath));
mTreeWidget->AddDDSFile(new DDSFile(aFilePath));
return 0;
}
@ -753,7 +789,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
QVector<IPAKIndexEntry> entries = QVector<IPAKIndexEntry>();
QVector<IPAKSection> sections = QVector<IPAKSection>(header.sectionCount);
for (uint i = 0; i < header.sectionCount; i++) {
for (quint32 i = 0; i < header.sectionCount; i++) {
IPAKSection currentSection;
stream >> currentSection;
sections << currentSection;
@ -775,7 +811,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
<< " - Count: " << chunkHeader.count << "\n"
<< " - Offset: " << chunkHeader.offset;
for (uint j = 0; j < 31; j++) {
for (quint32 j = 0; j < 31; j++) {
IPAKDataChunkCommand command;
stream >> command;
if (!command.size) { continue; }
@ -785,7 +821,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
<< " - Compressed: " << command.compressed;
}
for (uint j = 0; j < chunkHeader.count; j++) {
for (quint32 j = 0; j < chunkHeader.count; j++) {
auto command = chunkHeader.commands[j];
qDebug() << "Reading from " << stream.device()->pos();
@ -810,7 +846,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
stream.skipRawData(sizeof(quint32) * (31 - chunkHeader.count));
qDebug() << stream.device()->pos();
} else if (sectionType == "Index") {
for (uint j = 0; j < currentSection.itemCount; j++) {
for (quint32 j = 0; j < currentSection.itemCount; j++) {
IPAKIndexEntry entry;
stream >> entry;

View File

@ -2,7 +2,6 @@
#define MAINWINDOW_H
#include "d3dbsp_structs.h"
#include "asset_structs.h"
#include "xtreewidget.h"
#include <QMainWindow>
@ -16,7 +15,6 @@
#include <QPlainTextEdit>
#include <QMimeData>
#include <QProgressBar>
#include <windows.h>
QT_BEGIN_NAMESPACE
namespace Ui {
@ -35,6 +33,7 @@ public:
private slots:
bool OpenFastFile(const QString aFastFilePath);
bool OpenFastFile(const QByteArray& aFastFileData, const QString aFastFilePath);
bool OpenFastFile();
bool OpenZoneFile(const QString aZoneFilePath, bool fromFF = false);
@ -64,7 +63,7 @@ private:
quint32 mTagCount;
quint32 mRecordCount;
QMap<QString, QString> mRawFileMap;
QMap<QString, Image> mImageMap;
//QMap<QString, Image> mImageMap;
QMap<QString, QTreeWidgetItem*> mTreeMap;
QMap<QString, QVector<QPair<QString, QString>>> mStrTableMap;
XTreeWidget *mTreeWidget;

View File

@ -50,7 +50,7 @@
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<widget class="QMenu" name="MenuDef">
<property name="title">
<string>File</string>
</property>
@ -117,9 +117,17 @@
</property>
<addaction name="actionAbout"/>
<addaction name="actionCheck_for_Updates"/>
<addaction name="actionReport_Issue"/>
</widget>
<addaction name="menuFile"/>
<widget class="QMenu" name="menuTools">
<property name="title">
<string>Tools</string>
</property>
<addaction name="actionRun_Tests"/>
</widget>
<addaction name="MenuDef"/>
<addaction name="menuEdit"/>
<addaction name="menuTools"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="toolBar">
@ -353,6 +361,16 @@
<string>Preferences...</string>
</property>
</action>
<action name="actionReport_Issue">
<property name="text">
<string>Report Issue</string>
</property>
</action>
<action name="actionRun_Tests">
<property name="text">
<string>Run Tests</string>
</property>
</action>
</widget>
<resources>
<include location="../data/data.qrc"/>

View File

@ -3,33 +3,41 @@
MaterialViewer::MaterialViewer(QWidget *parent)
: QWidget(parent)
, ui(new Ui::MaterialViewer) {
, ui(new Ui::MaterialViewer)
{
ui->setupUi(this);
}
MaterialViewer::~MaterialViewer() {
MaterialViewer::~MaterialViewer()
{
delete ui;
}
QString ToHexStr(quint32 in) {
QString ToHexStr(quint32 in)
{
return QString("%1").arg(in, 8, 16, QChar('0')).toUpper();
}
void MaterialViewer::SetMaterial(std::shared_ptr<Material> aMaterial) {
ui->lineEdit_NamePtr->setText(ToHexStr(aMaterial->namePtr));
ui->lineEdit_Name->setText(aMaterial->name);
ui->lineEdit_RefPtr->setText(ToHexStr(aMaterial->refNamePtr));
ui->lineEdit_RefName->setText(aMaterial->refName);
QString unknownStr = "";
foreach (quint32 unknownPtr, aMaterial->pointers) {
unknownStr += ToHexStr(unknownPtr) + "\n";
}
ui->lineEdit_Unknowns->setText(unknownStr);
ui->lineEdit_StateA->setText(ToHexStr(aMaterial->stateBits[0]));
ui->lineEdit_StateA->setText(ToHexStr(aMaterial->stateBits[1]));
ui->spinBox_TextureCount->setValue(aMaterial->textureCount);
ui->spinBox_ConstCount->setValue(aMaterial->constCount);
ui->lineEdit_TechSetPtr->setText(ToHexStr(aMaterial->techSetPtr));
ui->lineEdit_TexturePtr->setText(ToHexStr(aMaterial->texturePtr));
ui->lineEdit_ConstantPtr->setText(ToHexStr(aMaterial->constPtr));
void MaterialViewer::SetMaterial(const XMaterial* aMaterial)
{
Q_UNUSED(aMaterial);
// TODO: Fill in MaterialViewer::SetMaterial
// ui->lineEdit_NamePtr->setText(ToHexStr(aMaterial->namePtr));
// ui->lineEdit_Name->setText(aMaterial->name);
// ui->lineEdit_RefPtr->setText(ToHexStr(aMaterial->refNamePtr));
// ui->lineEdit_RefName->setText(aMaterial->refName);
// QString unknownStr = "";
// foreach (quint32 unknownPtr, aMaterial->pointers) {
// unknownStr += ToHexStr(unknownPtr) + "\n";
// }
// ui->lineEdit_Unknowns->setText(unknownStr);
// ui->lineEdit_StateA->setText(ToHexStr(aMaterial->stateBits[0]));
// ui->lineEdit_StateA->setText(ToHexStr(aMaterial->stateBits[1]));
// ui->spinBox_TextureCount->setValue(aMaterial->textureCount);
// ui->spinBox_ConstCount->setValue(aMaterial->constCount);
// ui->lineEdit_TechSetPtr->setText(ToHexStr(aMaterial->techSetPtr));
// ui->lineEdit_TexturePtr->setText(ToHexStr(aMaterial->texturePtr));
// ui->lineEdit_ConstantPtr->setText(ToHexStr(aMaterial->constPtr));
}

View File

@ -1,7 +1,7 @@
#ifndef MATERIALVIEWER_H
#define MATERIALVIEWER_H
#include "asset_structs.h"
#include "xmaterial.h"
#include <QWidget>
#include <QScrollArea>
@ -18,7 +18,7 @@ public:
explicit MaterialViewer(QWidget *parent = nullptr);
~MaterialViewer();
void SetMaterial(std::shared_ptr<Material> aMaterial);
void SetMaterial(const XMaterial *aMaterial);
private:
Ui::MaterialViewer *ui;

103
app/reportissuedialog.cpp Normal file
View File

@ -0,0 +1,103 @@
#include "reportissuedialog.h"
#include "qjsonarray.h"
#include "ui_reportissuedialog.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#include <QNetworkRequest>
ReportIssueDialog::ReportIssueDialog(const QString &giteaBaseUrl,
const QString &repoOwner,
const QString &repoName,
const QString &accessToken,
QWidget *parent) :
QDialog(parent),
ui(new Ui::ReportIssueDialog),
networkManager(new QNetworkAccessManager(this)),
giteaBaseUrl(giteaBaseUrl),
repoOwner(repoOwner),
repoName(repoName),
accessToken(accessToken)
{
ui->setupUi(this);
connect(networkManager, &QNetworkAccessManager::finished, this, &ReportIssueDialog::onNetworkReplyFinished);
}
ReportIssueDialog::~ReportIssueDialog()
{
delete ui;
}
void ReportIssueDialog::on_buttonSend_clicked()
{
QString title = ui->lineEditSummary->text().trimmed();
QString details = ui->textEditDetails->toPlainText().trimmed();
QString contact = ui->lineEditContact->text().trimmed();
if (title.isEmpty()) {
QMessageBox::warning(this, tr("Input Error"), tr("Please enter a summary/title for the issue."));
return;
}
QString body = details;
if (!contact.isEmpty()) {
body += QString("\n\nContact info:\n%1").arg(contact);
}
ui->buttonSend->setEnabled(false);
sendIssueReport(title, body, contact);
}
void ReportIssueDialog::on_buttonCancel_clicked()
{
reject();
}
void ReportIssueDialog::sendIssueReport(const QString &title, const QString &body, const QString &/*contact*/)
{
// Compose URL: e.g. https://gitea.example.com/api/v1/repos/{owner}/{repo}/issues
QUrl url(QString("%1/api/v1/repos/%2/%3/issues").arg(giteaBaseUrl).arg(repoOwner).arg(repoName));
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
if (!accessToken.isEmpty()) {
request.setRawHeader("Authorization", "token " + accessToken.toUtf8());
}
// Compose JSON body
QJsonObject json;
json["title"] = title;
json["body"] = body;
json["labels"] = QJsonArray{12};
QJsonDocument doc(json);
QByteArray data = doc.toJson();
networkManager->post(request, data);
}
void ReportIssueDialog::onNetworkReplyFinished(QNetworkReply *reply)
{
ui->buttonSend->setEnabled(true);
QByteArray responseData = reply->readAll();
QString responseStr = QString::fromUtf8(responseData);
if (reply->error() != QNetworkReply::NoError) {
QString errorStr = reply->errorString();
if (errorStr.isEmpty()) errorStr = "Unknown network error";
QMessageBox::critical(this, tr("Error"), tr("Failed to send issue report:\n%1\nResponse:\n%2").arg(errorStr).arg(responseStr));
} else {
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (status == 201) {
QMessageBox::information(this, tr("Success"), tr("Issue reported successfully!"));
accept();
} else {
QMessageBox::warning(this, tr("Failed"), tr("Unexpected response from server (%1):\n%2").arg(status).arg(responseStr));
}
}
reply->deleteLater();
}

43
app/reportissuedialog.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef REPORTISSUEDIALOG_H
#define REPORTISSUEDIALOG_H
#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkReply>
namespace Ui {
class ReportIssueDialog;
}
class ReportIssueDialog : public QDialog
{
Q_OBJECT
public:
explicit ReportIssueDialog(const QString &giteaBaseUrl,
const QString &repoOwner,
const QString &repoName,
const QString &accessToken,
QWidget *parent = nullptr);
~ReportIssueDialog();
private slots:
void on_buttonSend_clicked();
void on_buttonCancel_clicked();
void onNetworkReplyFinished(QNetworkReply *reply);
private:
Ui::ReportIssueDialog *ui;
QNetworkAccessManager *networkManager;
QString giteaBaseUrl;
QString repoOwner;
QString repoName;
QString accessToken;
void sendIssueReport(const QString &title, const QString &body, const QString &contact);
};
#endif // REPORTISSUEDIALOG_H

84
app/reportissuedialog.ui Normal file
View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportIssueDialog</class>
<widget class="QDialog" name="ReportIssueDialog">
<property name="windowTitle">
<string>Report a Problem</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelInstructions">
<property name="text">
<string>Please describe the problem you encountered. Well use this info to help fix it.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelSummary">
<property name="text">
<string>Summary (short title):</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditSummary" />
</item>
<item>
<widget class="QLabel" name="labelDetails">
<property name="text">
<string>Details (what happened?):</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEditDetails" />
</item>
<item>
<widget class="QLabel" name="labelContact">
<property name="text">
<string>Your contact (email or name, optional):</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditContact" />
</item>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonSend">
<property name="text">
<string>Send Report</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -18,41 +18,41 @@ RumbleFileViewer::~RumbleFileViewer() {
delete ui;
}
void RumbleFileViewer::SetRumbleFile(std::shared_ptr<RawFile> aRumbleFile) {
void RumbleFileViewer::SetRumbleFile(XRawFile *aRumbleFile) {
mRumbleFile = aRumbleFile;
ui->tableWidget_Properties->clear();
const QString magic = aRumbleFile->contents.left(6);
if (magic != "RUMBLE") {
qDebug() << "Rumble file has invalid magic: " << magic;
return;
}
int firstIndex = 0;
int secondIndex = 0;
int thirdIndex = 0;
int startIndex = 0;
for (int i = 0; i < aRumbleFile->contents.count("\\") / 2; i++) {
ui->tableWidget_Properties->setRowCount(i + 1);
ui->spinBox_Entries->setValue(i + 1);
firstIndex = aRumbleFile->contents.indexOf("\\", startIndex);
secondIndex = aRumbleFile->contents.indexOf("\\", firstIndex + 1);
thirdIndex = aRumbleFile->contents.indexOf("\\", secondIndex + 1);
if (thirdIndex == -1) {
thirdIndex = aRumbleFile->contents.size();
}
const QString keyStr = aRumbleFile->contents.mid(firstIndex + 1, secondIndex - firstIndex - 1);
QTableWidgetItem *keyItem = new QTableWidgetItem(keyStr);
ui->tableWidget_Properties->setItem(i, 0, keyItem);
const QString valStr = aRumbleFile->contents.mid(secondIndex + 1, thirdIndex - secondIndex - 1);
QTableWidgetItem *valueItem = new QTableWidgetItem(valStr);
ui->tableWidget_Properties->setItem(i, 1, valueItem);
startIndex = thirdIndex;
}
// const QString magic = aRumbleFile->contents.left(6);
// if (magic != "RUMBLE") {
// qDebug() << "Rumble file has invalid magic: " << magic;
// return;
// }
// int firstIndex = 0;
// int secondIndex = 0;
// int thirdIndex = 0;
// int startIndex = 0;
// for (int i = 0; i < aRumbleFile->contents.count("\\") / 2; i++) {
// ui->tableWidget_Properties->setRowCount(i + 1);
// ui->spinBox_Entries->setValue(i + 1);
// firstIndex = aRumbleFile->contents.indexOf("\\", startIndex);
// secondIndex = aRumbleFile->contents.indexOf("\\", firstIndex + 1);
// thirdIndex = aRumbleFile->contents.indexOf("\\", secondIndex + 1);
// if (thirdIndex == -1) {
// thirdIndex = aRumbleFile->contents.size();
// }
// const QString keyStr = aRumbleFile->contents.mid(firstIndex + 1, secondIndex - firstIndex - 1);
// QTableWidgetItem *keyItem = new QTableWidgetItem(keyStr);
// ui->tableWidget_Properties->setItem(i, 0, keyItem);
// const QString valStr = aRumbleFile->contents.mid(secondIndex + 1, thirdIndex - secondIndex - 1);
// QTableWidgetItem *valueItem = new QTableWidgetItem(valStr);
// ui->tableWidget_Properties->setItem(i, 1, valueItem);
// startIndex = thirdIndex;
// }
}

View File

@ -1,8 +1,8 @@
#ifndef RUMBLEFILEVIEWER_H
#define RUMBLEFILEVIEWER_H
#include "asset_structs.h"
#include "zonefile.h"
#include "xrawfile.h"
#include <QWidget>
namespace Ui {
@ -17,12 +17,12 @@ public:
explicit RumbleFileViewer(QWidget *parent = nullptr);
~RumbleFileViewer();
void SetRumbleFile(std::shared_ptr<RawFile> aRumbleFile);
void SetRumbleFile(XRawFile* aRumbleFile);
private:
Ui::RumbleFileViewer *ui;
quint32 mPropertyCount;
std::shared_ptr<RawFile> mRumbleFile;
XRawFile* mRumbleFile;
};
#endif // RUMBLEFILEVIEWER_H

View File

@ -19,10 +19,10 @@ RumbleGraphViewer::~RumbleGraphViewer() {
delete ui;
}
void RumbleGraphViewer::SetRumbleGraphFile(const std::shared_ptr<RawFile> aRawFile) {
void RumbleGraphViewer::SetRumbleGraphFile(const XRawFile* aRawFile) {
mRumbleGraphFile = aRawFile;
QDataStream rawFileStream(mRumbleGraphFile->contents.toLatin1());
XDataStream rawFileStream;//(mRumbleGraphFile->contents.toLatin1());
QByteArray magic(15, Qt::Uninitialized);
rawFileStream.readRawData(magic.data(), 15);

View File

@ -1,7 +1,7 @@
#ifndef RUMBLEGRAPHVIEWER_H
#define RUMBLEGRAPHVIEWER_H
#include "asset_structs.h"
#include "xrawfile.h"
#include "zonefile.h"
#include <QWidget>
@ -18,13 +18,13 @@ public:
~RumbleGraphViewer();
void SetEntryCount(quint32 aCount);
void SetRumbleGraphFile(const std::shared_ptr<RawFile> aRawFile);
void SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile);
void SetRumbleGraphFile(const XRawFile *aRawFile);
void SetZoneFile(ZoneFile* aZoneFile);
private:
Ui::RumbleGraphViewer *ui;
quint32 mEntryCount;
std::shared_ptr<RawFile> mRumbleGraphFile;
const XRawFile* mRumbleGraphFile;
};
#endif // RUMBLEGRAPHVIEWER_H

View File

@ -61,17 +61,17 @@ SoundViewer::~SoundViewer()
delete ui;
}
void SoundViewer::SetSound(std::shared_ptr<Sound> aSound)
{
buffer->setData(aSound->data);
if (!buffer->open(QIODevice::ReadOnly)) {
qWarning() << "Failed to open QBuffer.";
return;
}
// void SoundViewer::SetSound(std::shared_ptr<Sound> aSound)
// {
// buffer->setData(aSound->data);
// if (!buffer->open(QIODevice::ReadOnly)) {
// qWarning() << "Failed to open QBuffer.";
// return;
// }
ui->groupBox->setTitle(aSound->path);
player->setSourceDevice(buffer);
}
// ui->groupBox->setTitle(aSound->path);
// player->setSourceDevice(buffer);
// }
void SoundViewer::SetOutput(QAudioOutput *aOutput) {
if (!aOutput) { return; }

View File

@ -1,8 +1,6 @@
#ifndef SOUNDVIEWER_H
#define SOUNDVIEWER_H
#include "asset_structs.h"
#include <QWidget>
#include <QMediaPlayer>
#include <QBuffer>
@ -22,7 +20,7 @@ public:
explicit SoundViewer(QWidget *parent = nullptr);
~SoundViewer();
void SetSound(std::shared_ptr<Sound> aSound);
//void SetSound(std::shared_ptr<Sound> aSound);
void SetOutput(QAudioOutput *aOutput);
private:

View File

@ -13,22 +13,21 @@ StringTableViewer::~StringTableViewer()
delete ui;
}
void StringTableViewer::SetStringTable(std::shared_ptr<StringTable> aStringTable) {
void StringTableViewer::SetStringTable(const XStringTable *aStringTable) {
ui->tableWidget_Strings->clear();
ui->tableWidget_Strings->setRowCount(aStringTable->rowCount);
ui->tableWidget_Strings->setColumnCount(aStringTable->columnCount);
ui->tableWidget_Strings->setRowCount(aStringTable->GetRowCount());
ui->tableWidget_Strings->setColumnCount(aStringTable->GetColumnCount());
int currentIndex = 0;
for (const QString &key : aStringTable->content.keys()) {
const QString value = aStringTable->content[key];
for (auto value : *aStringTable->GetValues()) {
QTableWidgetItem *tableKeyItem = new QTableWidgetItem();
tableKeyItem->setText(key);
tableKeyItem->setText(value->GetName());
ui->tableWidget_Strings->setItem(currentIndex, 0, tableKeyItem);
QTableWidgetItem *tableValItem = new QTableWidgetItem();
tableValItem->setText(value);
tableValItem->setText(value->GetString());
ui->tableWidget_Strings->setItem(currentIndex, 1, tableValItem);
currentIndex++;

View File

@ -1,7 +1,8 @@
#ifndef STRINGTABLEVIEWER_H
#define STRINGTABLEVIEWER_H
#include "asset_structs.h"
#include "xstringtable.h"
#include <QWidget>
namespace Ui {
@ -16,7 +17,7 @@ public:
explicit StringTableViewer(QWidget *parent = nullptr);
~StringTableViewer();
void SetStringTable(std::shared_ptr<StringTable> aStringTable);
void SetStringTable(const XStringTable *aStringTable);
private:
Ui::StringTableViewer *ui;

View File

@ -13,13 +13,13 @@ TechSetViewer::~TechSetViewer()
delete ui;
}
void TechSetViewer::SetTechSet(std::shared_ptr<TechSet> aTechSet) {
ui->listWidget_Ptrs->clear();
ui->label_Title->setText(aTechSet->name);
void TechSetViewer::SetTechSet(const XMaterialTechniqueSet* aTechSet) {
//ui->listWidget_Ptrs->clear();
ui->label_Title->setText(aTechSet->GetName());
int ptrIndex = 1;
for (auto ptr : aTechSet->pointers) {
ui->listWidget_Ptrs->addItem(QString("Pointer %1: %2").arg(ptrIndex).arg(ptr));
ptrIndex++;
}
// int ptrIndex = 1;
//for (auto ptr : aTechSet->pointers) {
// ui->listWidget_Ptrs->addItem(QString("Pointer %1: %2").arg(ptrIndex).arg(ptr));
// ptrIndex++;
//}
}

View File

@ -1,7 +1,8 @@
#ifndef TECHSETVIEWER_H
#define TECHSETVIEWER_H
#include "asset_structs.h"
#include "xmaterialtechniqueset.h"
#include <QWidget>
namespace Ui {
@ -16,7 +17,7 @@ public:
explicit TechSetViewer(QWidget *parent = nullptr);
~TechSetViewer();
void SetTechSet(std::shared_ptr<TechSet> aTechSet);
void SetTechSet(const XMaterialTechniqueSet *aTechSet);
private:
Ui::TechSetViewer *ui;

View File

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>961</width>
<height>756</height>
<width>880</width>
<height>559</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_Title">
<property name="font">
@ -29,46 +29,120 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Unknown Pointers:</string>
<string>Set Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget_Ptrs"/>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_Name">
<property name="placeholderText">
<string>Technique set name</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>World Vertex Format:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_WorldVertFormat"/>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_Techniques"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Current Technique</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Name:</string>
</property>
</spacer>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_TechniqueName">
<property name="placeholderText">
<string>Technique set name</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Flags:</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>363</height>
</size>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_Flags"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Pass Count:</string>
</property>
</spacer>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_PassCount"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Material Pass</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View File

@ -5,10 +5,10 @@
XTreeWidget::XTreeWidget(QWidget *parent)
: QTreeWidget(parent) {
mFastFiles = QMap<QString, std::shared_ptr<FastFile>>();
mZoneFiles = QMap<QString, std::shared_ptr<ZoneFile>>();
mDDSFiles = QMap<QString, std::shared_ptr<DDSFile>>();
mIWIFiles = QMap<QString, std::shared_ptr<IWIFile>>();
mFastFiles = QMap<QString, const FastFile*>();
mZoneFiles = QMap<QString, const ZoneFile*>();
mDDSFiles = QMap<QString, const DDSFile*>();
mIWIFiles = QMap<QString, const IWIFile*>();
setContextMenuPolicy(Qt::CustomContextMenu);
setSelectionMode(QTreeWidget::SingleSelection);
@ -37,7 +37,7 @@ XTreeWidget::~XTreeWidget() {
}
void XTreeWidget::AddFastFile(std::shared_ptr<FastFile> aFastFile) {
void XTreeWidget::AddFastFile(FastFile* aFastFile) {
XTreeWidgetItem *fastFileItem = new XTreeWidgetItem(this);
fastFileItem->setText(0, aFastFile->GetStem());
fastFileItem->setIcon(0, Utils::CreateAssetIcon("FF"));
@ -83,211 +83,189 @@ void XTreeWidget::AddFastFile(std::shared_ptr<FastFile> aFastFile) {
sortByColumn(0, Qt::AscendingOrder);
}
void XTreeWidget::AddZoneFile(std::shared_ptr<ZoneFile> aZoneFile, XTreeWidgetItem *aParentItem) {
void XTreeWidget::AddZoneFile(const ZoneFile* aZoneFile, XTreeWidgetItem *aParentItem) {
XTreeWidgetItem *zoneItem;
if (aParentItem != nullptr) {
zoneItem = new XTreeWidgetItem(aParentItem);
} else {
zoneItem = new XTreeWidgetItem(this);
}
zoneItem->setIcon(0, ZoneFile::AssetTypeToIcon(ASSET_ZONE_FILE));
zoneItem->setIcon(0, Utils::CreateAssetIcon("ZF"));
zoneItem->setText(0, aZoneFile->GetBaseStem() + ".zone");
auto assetMap = aZoneFile->GetAssetMap();
if (!assetMap.localStrings.isEmpty()) {
QIcon localStrIcon = ZoneFile::AssetTypeToIcon(ASSET_LOCAL_STRING);
XTreeWidgetItem *localStrRoot = new XTreeWidgetItem(zoneItem);
localStrRoot->setText(0, "String Files");
localStrRoot->setIcon(0, localStrIcon);
localStrRoot->SetCategory(CATEGORY_TYPE);
XTreeWidgetItem *localStrItem = new XTreeWidgetItem(localStrRoot);
localStrItem->setText(0, aZoneFile->GetStem().section('.', 0, 0) + ".str");
localStrItem->setIcon(0, localStrIcon);
}
if (!assetMap.techSets.isEmpty()) {
QIcon techSetIcon = ZoneFile::AssetTypeToIcon(ASSET_TECH_SET);
XTreeWidgetItem *techSetRoot = new XTreeWidgetItem(zoneItem);
techSetRoot->setText(0, "Tech Sets");
techSetRoot->setIcon(0, techSetIcon);
techSetRoot->SetCategory(CATEGORY_TYPE);
for (TechSet techSet : assetMap.techSets) {
XTreeWidgetItem *techSetItem = new XTreeWidgetItem(techSetRoot);
techSetItem->setText(0, techSet.name);
techSetItem->setIcon(0, techSetIcon);
XAssetList assetList = aZoneFile->GetAssetList();
QVector<XAsset*> localizeEntries;
for (int i = 0; i < assetList.Size(); i++)
{
XAsset *currentAsset = assetList.GetAsset(i);
if (currentAsset->GetType() == ASSET_TYPE_LOCALIZE_ENTRY)
{
localizeEntries.append(currentAsset);
} else if (currentAsset->GetType() == ASSET_TYPE_LOCALIZE_ENTRY)
{
localizeEntries.append(currentAsset);
}
}
if (!assetMap.rawFiles.isEmpty()) {
QIcon rawFileIcon = ZoneFile::AssetTypeToIcon(ASSET_RAW_FILE);
XTreeWidgetItem *rawFileRoot = new XTreeWidgetItem(zoneItem);
rawFileRoot->setText(0, "Raw Files");
rawFileRoot->setIcon(0, rawFileIcon);
rawFileRoot->SetCategory(CATEGORY_TYPE);
for (RawFile rawFile : assetMap.rawFiles) {
if (!rawFile.length) { continue; }
// if (!assetMap.localizeEntries.isEmpty()) {
// QIcon localStrIcon = Utils::CreateAssetIcon(ASSET_TYPE_LOCALIZE_ENTRY);
XTreeWidgetItem *tempItem = rawFileRoot;
const QStringList pathParts = rawFile.path.split('/');
for (const QString &pathPart : pathParts) {
bool childFound = false;
for (int i = 0; i < tempItem->childCount(); i++) {
QTreeWidgetItem *rawChildItem = tempItem->child(i);
XTreeWidgetItem *childItem = dynamic_cast<XTreeWidgetItem*>(rawChildItem);
if (childItem->text(0) == pathPart) {
tempItem = childItem;
// XTreeWidgetItem *localStrRoot = new XTreeWidgetItem(zoneItem);
// localStrRoot->setText(0, "String Files");
// localStrRoot->setIcon(0, localStrIcon);
// localStrRoot->SetCategory(CATEGORY_TYPE);
childFound = true;
break;
}
}
// XTreeWidgetItem *localStrItem = new XTreeWidgetItem(localStrRoot);
// localStrItem->setText(0, aZoneFile->GetStem().section('.', 0, 0) + ".str");
// localStrItem->setIcon(0, localStrIcon);
// }
const QString rawFileStr = QString("%1 [%2-%3]").arg(pathPart).arg(rawFile.startPos).arg(rawFile.endPos);
//rawFileStr = pathPart;
if (pathPart == pathParts.last()) {
XTreeWidgetItem *rawFileItem = new XTreeWidgetItem(tempItem);
rawFileItem->setText(0, rawFileStr);
// if (!assetMap.techSets.isEmpty()) {
// QIcon techSetIcon = Utils::CreateAssetIcon(ASSET_TYPE_TECHNIQUE_SET);
tempItem = rawFileItem;
} else if (!childFound) {
tempItem = new XTreeWidgetItem(tempItem);
tempItem->setText(0, rawFileStr);
}
// XTreeWidgetItem *techSetRoot = new XTreeWidgetItem(zoneItem);
// techSetRoot->setText(0, "Tech Sets");
// techSetRoot->setIcon(0, techSetIcon);
// techSetRoot->SetCategory(CATEGORY_TYPE);
}
tempItem->setIcon(0, rawFileIcon);
}
}
// for (auto techSet : assetMap.techSets) {
// XTreeWidgetItem *techSetItem = new XTreeWidgetItem(techSetRoot);
// techSetItem->setText(0, techSet.name);
// techSetItem->setIcon(0, techSetIcon);
// }
// }
if (!assetMap.menuFiles.isEmpty()) {
QIcon menuFileIcon = ZoneFile::AssetTypeToIcon(ASSET_MENU);
// if (!assetMap.rawFiles.isEmpty()) {
// QIcon rawFileIcon = Utils::CreateAssetIcon(ASSET_TYPE_RAWFILE);
XTreeWidgetItem *menuRoot = new XTreeWidgetItem(zoneItem);
menuRoot->setText(0, "Menu Files");
menuRoot->setIcon(0, menuFileIcon);
menuRoot->SetCategory(CATEGORY_TYPE);
// XTreeWidgetItem *rawFileRoot = new XTreeWidgetItem(zoneItem);
// rawFileRoot->setText(0, "Raw Files");
// rawFileRoot->setIcon(0, rawFileIcon);
// rawFileRoot->SetCategory(CATEGORY_TYPE);
// for (auto rawFile : assetMap.rawFiles) {
// if (!rawFile.length) { continue; }
int menuIndex = 1;
for (MenuFile menuFile : assetMap.menuFiles) {
XTreeWidgetItem *menuFileRoot = new XTreeWidgetItem(menuRoot);
menuFileRoot->setText(0, QString("Menu %1").arg(menuIndex));
for (Menu menu : menuFile.menuDefs) {
XTreeWidgetItem *menuItem = new XTreeWidgetItem(menuFileRoot);
menuItem->setText(0, menu.filePath);
menuItem->setIcon(0, menuFileIcon);
}
menuIndex++;
}
}
// XTreeWidgetItem *tempItem = rawFileRoot;
// // const QStringList pathParts = rawFile->path.split('/');
// // for (const QString &pathPart : pathParts) {
// // bool childFound = false;
// // for (int i = 0; i < tempItem->childCount(); i++) {
// // QTreeWidgetItem *rawChildItem = tempItem->child(i);
// // XTreeWidgetItem *childItem = dynamic_cast<XTreeWidgetItem*>(rawChildItem);
// // if (childItem->text(0) == pathPart) {
// // tempItem = childItem;
if (!assetMap.images.isEmpty()) {
QIcon imageIcon = ZoneFile::AssetTypeToIcon(ASSET_IMAGE);
// // childFound = true;
// // break;
// // }
// // }
XTreeWidgetItem *imageRoot = new XTreeWidgetItem(zoneItem);
imageRoot->setText(0, "Images");
imageRoot->setIcon(0, imageIcon);
imageRoot->SetCategory(CATEGORY_TYPE);
// // const QString rawFileStr = pathPart;// = QString("%1 [%2-%3]").arg(pathPart).arg(rawFile.startPos).arg(rawFile.endPos);
// // if (pathPart == pathParts.last()) {
// // XTreeWidgetItem *rawFileItem = new XTreeWidgetItem(tempItem);
// // rawFileItem->setText(0, rawFileStr);
for (Image image : assetMap.images) {
XTreeWidgetItem *imageItem = new XTreeWidgetItem(imageRoot);
imageItem->setText(0, image.materialName);
imageItem->setIcon(0, imageIcon);
}
}
// // tempItem = rawFileItem;
// // } else if (!childFound) {
// // tempItem = new XTreeWidgetItem(tempItem);
// // tempItem->setText(0, rawFileStr);
// // }
if (!assetMap.models.isEmpty()) {
QIcon modelIcon = ZoneFile::AssetTypeToIcon(ASSET_MODEL);
// // }
// tempItem->setIcon(0, rawFileIcon);
// }
// }
XTreeWidgetItem *modelsRoot = new XTreeWidgetItem(zoneItem);
modelsRoot->setText(0, "Models");
modelsRoot->setIcon(0, modelIcon);
modelsRoot->SetCategory(CATEGORY_TYPE);
// if (!assetMap.menuDefinitions.isEmpty()) {
// // QIcon MenuDefIcon = Utils::CreateAssetIcon(ASSET_TYPE_MENU);
for (Model model: assetMap.models) {
XTreeWidgetItem *modelItem = new XTreeWidgetItem(modelsRoot);
modelItem->setText(0, model.modelName);
modelItem->setIcon(0, modelIcon);
}
}
// // XTreeWidgetItem *menuRoot = new XTreeWidgetItem(zoneItem);
// // menuRoot->setText(0, "Menu Files");
// // menuRoot->setIcon(0, MenuDefIcon);
// // menuRoot->SetCategory(CATEGORY_TYPE);
if (!assetMap.materials.isEmpty()) {
QIcon materialIcon = ZoneFile::AssetTypeToIcon(ASSET_MATERIAL);
// // int menuIndex = 1;
// // for (MenuDef menuDef : assetMap.menuDefinitions) {
// // XTreeWidgetItem *MenuDefRoot = new XTreeWidgetItem(menuRoot);
// // MenuDefRoot->setText(0, QString("Menu %1").arg(menuIndex));
// // for (Menu menu : menuDef.men) {
// // XTreeWidgetItem *menuItem = new XTreeWidgetItem(MenuDefRoot);
// // menuItem->setText(0, menu.filePath);
// // menuItem->setIcon(0, MenuDefIcon);
// // }
// // menuIndex++;
// // }
// }
XTreeWidgetItem *materialsRoot = new XTreeWidgetItem(zoneItem);
materialsRoot->setText(0, "Materials");
materialsRoot->setIcon(0, materialIcon);
materialsRoot->SetCategory(CATEGORY_TYPE);
// if (!assetMap.images.isEmpty()) {
// // QIcon imageIcon = Utils::CreateAssetIcon(ASSET_TYPE_IMAGE);
for (Material material: assetMap.materials) {
XTreeWidgetItem *materialItem = new XTreeWidgetItem(materialsRoot);
materialItem->setText(0, material.name);
materialItem->setIcon(0, materialIcon);
}
}
// // XTreeWidgetItem *imageRoot = new XTreeWidgetItem(zoneItem);
// // imageRoot->setText(0, "Images");
// // imageRoot->setIcon(0, imageIcon);
// // imageRoot->SetCategory(CATEGORY_TYPE);
if (!assetMap.stringTables.isEmpty()) {
QIcon stringTableIcon = ZoneFile::AssetTypeToIcon(ASSET_STRING_TABLE);
// // for (Image image : assetMap.images) {
// // XTreeWidgetItem *imageItem = new XTreeWidgetItem(imageRoot);
// // imageItem->setText(0, image.materialName);
// // imageItem->setIcon(0, imageIcon);
// // }
// }
XTreeWidgetItem *strTableRoot = new XTreeWidgetItem(zoneItem);
strTableRoot->setText(0, "String Tables");
strTableRoot->setIcon(0, stringTableIcon);
strTableRoot->SetCategory(CATEGORY_TYPE);
// if (!assetMap.models.isEmpty()) {
// QIcon modelIcon = Utils::CreateAssetIcon(ASSET_TYPE_XMODEL);
for (StringTable strTable: assetMap.stringTables) {
XTreeWidgetItem *modelItem = new XTreeWidgetItem(strTableRoot);
modelItem->setText(0, strTable.name);
modelItem->setIcon(0, stringTableIcon);
}
}
// XTreeWidgetItem *modelsRoot = new XTreeWidgetItem(zoneItem);
// modelsRoot->setText(0, "Models");
// modelsRoot->setIcon(0, modelIcon);
// modelsRoot->SetCategory(CATEGORY_TYPE);
if (!assetMap.sounds.isEmpty()) {
QIcon soundIcon = ZoneFile::AssetTypeToIcon(ASSET_SOUND);
// for (auto model: assetMap.models) {
// XTreeWidgetItem *modelItem = new XTreeWidgetItem(modelsRoot);
// modelItem->setText(0, model.name);
// modelItem->setIcon(0, modelIcon);
// }
// }
XTreeWidgetItem *soundsRoot = new XTreeWidgetItem(zoneItem);
soundsRoot->setText(0, "Sounds");
soundsRoot->setIcon(0, soundIcon);
soundsRoot->SetCategory(CATEGORY_TYPE);
for (SoundAsset soundAsset : assetMap.sounds) {
for (Sound sound : soundAsset.sounds) {
XTreeWidgetItem *tempItem = soundsRoot;
// if (!assetMap.materials.isEmpty()) {
// QIcon materialIcon = Utils::CreateAssetIcon(ASSET_TYPE_MATERIAL);
if (!sound.dataLength) { continue; }
// XTreeWidgetItem *materialsRoot = new XTreeWidgetItem(zoneItem);
// materialsRoot->setText(0, "Materials");
// materialsRoot->setIcon(0, materialIcon);
// materialsRoot->SetCategory(CATEGORY_TYPE);
for (const QString &pathPart : sound.path.split('/')) {
if (pathPart.isEmpty()) { continue; }
// for (auto material: assetMap.materials) {
// XTreeWidgetItem *materialItem = new XTreeWidgetItem(materialsRoot);
// //materialItem->setText(0, material.name);
// materialItem->setIcon(0, materialIcon);
// }
// }
bool childFound = false;
for (int i = 0; i < tempItem->childCount(); i++) {
XTreeWidgetItem *childItem = dynamic_cast<XTreeWidgetItem*>(tempItem->child(i));
if (childItem->text(0) == pathPart) {
tempItem = childItem;
// if (!assetMap.stringTables.isEmpty()) {
// QIcon stringTableIcon = Utils::CreateAssetIcon(ASSET_TYPE_STRINGTABLE);
childFound = true;
break;
}
}
// XTreeWidgetItem *strTableRoot = new XTreeWidgetItem(zoneItem);
// strTableRoot->setText(0, "String Tables");
// strTableRoot->setIcon(0, stringTableIcon);
// strTableRoot->SetCategory(CATEGORY_TYPE);
if (pathPart.contains(".wav")) {
XTreeWidgetItem *soundItem = new XTreeWidgetItem(tempItem);
soundItem->setText(0, pathPart);
// for (auto strTable: assetMap.stringTables) {
// XTreeWidgetItem *modelItem = new XTreeWidgetItem(strTableRoot);
// modelItem->setText(0, strTable.name);
// modelItem->setIcon(0, stringTableIcon);
// }
// }
tempItem = soundItem;
} else if (!childFound) {
tempItem = new XTreeWidgetItem(tempItem);
tempItem->setText(0, pathPart);
}
// if (!assetMap.sounds.isEmpty()) {
// QIcon soundIcon = Utils::CreateAssetIcon(ASSET_TYPE_SOUND);
}
tempItem->setIcon(0, soundIcon);
}
}
}
// XTreeWidgetItem *soundsRoot = new XTreeWidgetItem(zoneItem);
// soundsRoot->setText(0, "Sounds");
// soundsRoot->setIcon(0, soundIcon);
// soundsRoot->SetCategory(CATEGORY_TYPE);
// }
mZoneFiles[aZoneFile->GetBaseStem() + ".zone"] = aZoneFile;
}
@ -324,7 +302,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
QMenu *exportSubmenu = new QMenu("Export...", this);
contextMenu->addMenu(exportSubmenu);
std::shared_ptr<DDSFile> ddsFile = mDDSFiles[fileStem];
const DDSFile* ddsFile = mDDSFiles[fileStem];
QAction *exportIWIAction = new QAction("Export as IWI");
exportSubmenu->addAction(exportIWIAction);
@ -368,7 +346,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
QMenu *exportSubmenu = new QMenu("Export...", this);
contextMenu->addMenu(exportSubmenu);
std::shared_ptr<IWIFile> iwiFile = mIWIFiles[fileStem];
const IWIFile* iwiFile = mIWIFiles[fileStem];
QAction *exportDDSAction = new QAction("Export as DDS");
exportSubmenu->addAction(exportDDSAction);
@ -497,7 +475,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
QMenu *exportSubmenu = new QMenu("Export...", this);
contextMenu->addMenu(exportSubmenu);
std::shared_ptr<FastFile> fastFile = mFastFiles[fileStem];
const FastFile* fastFile = mFastFiles[fileStem];
QAction *exportFastFileAction = new QAction("Export Fast File");
exportSubmenu->addAction(exportFastFileAction);
@ -512,13 +490,13 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
});
QAction *exportZoneFileAction = new QAction("Export Zone File");
exportSubmenu->addAction(exportZoneFileAction);
connect(exportZoneFileAction, &QAction::triggered, this, [fastFile](bool checked) {
connect(exportZoneFileAction, &QAction::triggered, this, [](bool checked) {
Q_UNUSED(checked);
const QString zoneFilePath = QFileDialog::getSaveFileName(
nullptr, "Export Zone File...", QDir::currentPath(),
"Zone File (*.zone);;All Files(*.*)");
fastFile->GetZoneFile()->SaveZoneFile(zoneFilePath);
// const QString zoneFilePath = QFileDialog::getSaveFileName(
// nullptr, "Export Zone File...", QDir::currentPath(),
// "Zone File (*.zone);;All Files(*.*)");
//fastFile->GetZoneFile()->SaveZoneFile(zoneFilePath);
});
} else if (activeText.contains(".zone")) {
const QString fileStem = activeText;
@ -530,7 +508,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
QMenu *exportSubmenu = new QMenu("Export...", this);
contextMenu->addMenu(exportSubmenu);
std::shared_ptr<ZoneFile> zoneFile = mZoneFiles[fileStem];
//const ZoneFile* zoneFile = mZoneFiles[fileStem];
QAction *exportZoneFileAction = new QAction("Export Zone File");
exportSubmenu->addAction(exportZoneFileAction);
@ -552,41 +530,41 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
}
}
if (parentItem && parentItem != invisibleRootItem() && parentItem->text(0).contains(".zone")) {
const QString fileStem = parentItem->text(0).section('.', 0, 0);
QVector<SoundAsset> soundAssets = mZoneFiles[fileStem]->GetAssetMap().sounds;
for (SoundAsset soundAsset : soundAssets) {
for (Sound sound : soundAsset.sounds) {
if (sound.path.contains(activeText)) {
QMenu *exportSubmenu = new QMenu("Export...", this);
contextMenu->addMenu(exportSubmenu);
//const QString fileStem = parentItem->text(0).section('.', 0, 0);
// QVector<LoadedSound> LoadedSounds = mZoneFiles[fileStem]->GetAssetMap().sounds;
// for (LoadedSound LoadedSound : LoadedSounds) {
// for (Sound sound : LoadedSound.sounds) {
// if (sound.path.contains(activeText)) {
// QMenu *exportSubmenu = new QMenu("Export...", this);
// contextMenu->addMenu(exportSubmenu);
QAction *exportWAVAction = new QAction("Export as WAV File");
exportSubmenu->addAction(exportWAVAction);
connect(exportWAVAction, &QAction::triggered, this, [sound](bool checked) {
Q_UNUSED(checked);
// QAction *exportWAVAction = new QAction("Export as WAV File");
// exportSubmenu->addAction(exportWAVAction);
// connect(exportWAVAction, &QAction::triggered, this, [sound](bool checked) {
// Q_UNUSED(checked);
QDir dir = QDir::currentPath();
if (!dir.exists("exports/")) {
dir.mkdir("exports/");
}
// QDir dir = QDir::currentPath();
// if (!dir.exists("exports/")) {
// dir.mkdir("exports/");
// }
if (!dir.exists("exports/sounds/")) {
dir.mkdir("exports/sounds/");
}
// if (!dir.exists("exports/sounds/")) {
// dir.mkdir("exports/sounds/");
// }
const QString fileName = "exports/sounds/" + sound.path.split('/').last();
QFile wavFile(fileName);
if (!wavFile.open(QIODevice::WriteOnly)) {
qDebug() << "Failed to write wav file!";
return;
}
wavFile.write(sound.data);
wavFile.close();
});
break;
}
}
}
// const QString fileName = "exports/sounds/" + sound.path.split('/').last();
// QFile wavFile(fileName);
// if (!wavFile.open(QIODevice::WriteOnly)) {
// qDebug() << "Failed to write wav file!";
// return;
// }
// wavFile.write(sound.data);
// wavFile.close();
// });
// break;
// }
// }
// }
}
} else if (activeItem && activeText == "Sounds") {
XTreeWidgetItem *parentItem = dynamic_cast<XTreeWidgetItem*>(activeItem->parent());
@ -599,39 +577,39 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
}
if (parentItem && parentItem != invisibleRootItem() && parentItem->text(0).contains(".zone")) {
const QString fileStem = parentItem->text(0).section('.', 0, 0);
auto zoneFile = mZoneFiles[fileStem];
//auto zoneFile = mZoneFiles[fileStem];
QMenu *exportSubmenu = new QMenu("Export...", this);
contextMenu->addMenu(exportSubmenu);
QAction *exportAllWAVAction = new QAction("Export ALL as WAV Files");
exportSubmenu->addAction(exportAllWAVAction);
connect(exportAllWAVAction, &QAction::triggered, this, [zoneFile](bool checked) {
connect(exportAllWAVAction, &QAction::triggered, this, [](bool checked) {
Q_UNUSED(checked);
for (SoundAsset soundAsset : zoneFile->GetAssetMap().sounds) {
for (Sound sound : soundAsset.sounds) {
if (!sound.dataLength) { continue; }
// for (LoadedSound LoadedSound : zoneFile->GetAssetMap().sounds) {
// for (Sound sound : LoadedSound.sounds) {
// if (!sound.dataLength) { continue; }
QDir dir = QDir::currentPath();
if (!dir.exists("exports/")) {
dir.mkdir("exports/");
}
// QDir dir = QDir::currentPath();
// if (!dir.exists("exports/")) {
// dir.mkdir("exports/");
// }
if (!dir.exists("exports/sounds/")) {
dir.mkdir("exports/sounds/");
}
// if (!dir.exists("exports/sounds/")) {
// dir.mkdir("exports/sounds/");
// }
const QString fileName = "exports/sounds/" + sound.path.split('/').last();
QFile wavFile(fileName);
if (!wavFile.open(QIODevice::WriteOnly)) {
qDebug() << "Failed to write wav file!";
return;
}
wavFile.write(sound.data);
wavFile.close();
}
}
// const QString fileName = "exports/sounds/" + sound.path.split('/').last();
// QFile wavFile(fileName);
// if (!wavFile.open(QIODevice::WriteOnly)) {
// qDebug() << "Failed to write wav file!";
// return;
// }
// wavFile.write(sound.data);
// wavFile.close();
// }
// }
});
}
}
@ -653,20 +631,19 @@ void XTreeWidget::ItemSelectionChanged() {
XTreeWidgetItem *parentItem = dynamic_cast<XTreeWidgetItem*>(selectedItem->parent());
if (selectedText.contains(".dds")) {
/*if (selectedText.contains(".dds")) {
if (!mDDSFiles.contains(selectedText)) {
LogManager::instance().addError("Could not find " + selectedText + " in DDS map!");
return;
}
std::shared_ptr<DDSFile> ddsFile = mDDSFiles[selectedText];
emit DDSFileSelected(ddsFile, selectedText);
emit DDSFileSelected(mDDSFiles[selectedText], selectedText);
} else if (selectedText.contains(".iwi")) {
if (!mIWIFiles.contains(selectedText)) {
LogManager::instance().addError("Could not find " + selectedText + " in IWI map!");
return;
}
emit IWIFileSelected(mIWIFiles[selectedText], selectedText);
} else if (selectedText.contains(".ff")) {
} else */if (selectedText.contains(".ff")) {
if (!mFastFiles.contains(selectedText)) {
LogManager::instance().addError("Could not find " + selectedText + " in Fast File map!");
return;
@ -688,34 +665,22 @@ void XTreeWidget::ItemSelectionChanged() {
XTreeWidgetItem *grandpaItem = dynamic_cast<XTreeWidgetItem*>(parentItem->parent());
if (grandpaItem && grandpaItem->text(0).contains(".zone")) {
const QString fileStem = grandpaItem->text(0).section('.', 0, 0);
QVector<Image> images = mZoneFiles[fileStem]->GetAssetMap().images;
for (Image image : images) {
if (image.materialName == selectedText) {
emit ImageSelected(std::make_shared<Image>(image), fileStem);
break;
// QVector<Image> images = mZoneFiles[fileStem]->GetAssetMap().images;
// for (Image image : images) {
// if (image.materialName == selectedText) {
// emit ImageSelected(std::make_shared<Image>(image), fileStem);
// break;
// }
// }
}
}
}
} else if (parentItem && (parentItem->text(0) == "Tech Sets")) {
} /*else if (parentItem && (parentItem->text(0) == "Tech Sets")) {
XTreeWidgetItem *grandpaItem = dynamic_cast<XTreeWidgetItem*>(parentItem->parent());
if (grandpaItem && grandpaItem->text(0).contains(".zone")) {
const QString fileStem = grandpaItem->text(0).section('.', 0, 0);
auto techsets = mZoneFiles[fileStem]->GetAssetMap().techSets;
auto techsets = mZoneFiles[fileStem]->GetAssetList().techSets;
for (auto techset : techsets) {
if (techset.name == selectedText) {
emit TechSetSelected(std::make_shared<TechSet>(techset), fileStem);
break;
}
}
}
} else if (parentItem && (parentItem->text(0) == "Tech Sets")) {
XTreeWidgetItem *grandpaItem = dynamic_cast<XTreeWidgetItem*>(parentItem->parent());
if (grandpaItem && grandpaItem->text(0).contains(".zone")) {
const QString fileStem = grandpaItem->text(0).section('.', 0, 0);
auto techsets = mZoneFiles[fileStem]->GetAssetMap().techSets;
for (auto techset : techsets) {
if (techset.name == selectedText) {
emit TechSetSelected(std::make_shared<TechSet>(techset), fileStem);
emit TechSetSelected(new MaterialTechSet(techset), fileStem);
break;
}
}
@ -724,12 +689,12 @@ void XTreeWidget::ItemSelectionChanged() {
XTreeWidgetItem *grandpaItem = dynamic_cast<XTreeWidgetItem*>(parentItem->parent());
if (grandpaItem && grandpaItem->text(0).contains(".zone")) {
const QString fileStem = grandpaItem->text(0).section('.', 0, 0);
QVector<Material> materials = mZoneFiles[fileStem]->GetAssetMap().materials;
for (Material material : materials) {
if (material.name == selectedText) {
emit MaterialSelected(std::make_shared<Material>(material), fileStem);
break;
}
auto materials = mZoneFiles[fileStem]->GetAssetMap().materials;
for (auto material : materials) {
// if (material.name == selectedText) {
// emit MaterialSelected(std::make_shared<Material>(material), fileStem);
// break;
// }
}
}
} else if (parentItem && selectedText.contains(".wav")) {
@ -743,15 +708,15 @@ void XTreeWidget::ItemSelectionChanged() {
}
if (grandpaItem && grandpaItem != invisibleRootItem() && grandpaItem->text(0).contains(".zone")) {
const QString fileStem = grandpaItem->text(0).section('.', 0, 0);
QVector<SoundAsset> soundAssets = mZoneFiles[fileStem]->GetAssetMap().sounds;
for (SoundAsset soundAsset : soundAssets) {
for (Sound sound : soundAsset.sounds) {
if (sound.path.contains(selectedText)) {
emit SoundSelected(std::make_shared<Sound>(sound), fileStem);
break;
}
}
}
// QVector<LoadedSound> LoadedSounds = mZoneFiles[fileStem]->GetAssetMap().sounds;
// for (LoadedSound LoadedSound : LoadedSounds) {
// for (Sound sound : LoadedSound.sounds) {
// if (sound.path.contains(selectedText)) {
// emit SoundSelected(std::make_shared<Sound>(sound), fileStem);
// break;
// }
// }
// }
}
} else if (selectedItem->GetCategory() != CATEGORY_TYPE) {
XTreeWidgetItem *zoneRoot = selectedItem;
@ -772,17 +737,17 @@ void XTreeWidget::ItemSelectionChanged() {
return;
}
QVector<RawFile> rawFiles = mZoneFiles[fileStem]->GetAssetMap().rawFiles;
for (RawFile rawFile : rawFiles) {
if (rawFile.path.split('/').last() == selectedText) {
emit RawFileSelected(std::make_shared<RawFile>(rawFile), fileStem);
return;
}
}
auto rawFiles = mZoneFiles[fileStem]->GetAssetMap().rawFiles;
for (auto rawFile : rawFiles) {
//if (rawFile->path.split('/').last() == selectedText) {
// emit RawFileSelected(std::make_shared<RawFile>(rawFile), fileStem);
// return;
//}
}
}*/
}
std::shared_ptr<ZoneFile> XTreeWidget::FindZoneFile(const QString aStem) {
const ZoneFile* XTreeWidget::FindZoneFile(const QString aStem) {
foreach (auto zoneFile, mZoneFiles) {
if (zoneFile->GetStem() == aStem) {
return zoneFile;
@ -791,7 +756,7 @@ std::shared_ptr<ZoneFile> XTreeWidget::FindZoneFile(const QString aStem) {
return nullptr;
}
std::shared_ptr<FastFile> XTreeWidget::FindFastFile(const QString aStem) {
const FastFile *XTreeWidget::FindFastFile(const QString aStem) {
foreach (auto fastFile, mFastFiles) {
if (fastFile->GetStem() == aStem) {
return fastFile;
@ -808,7 +773,7 @@ bool XTreeWidget::HasFastFile(const QString aStem) {
return FindFastFile(aStem) != nullptr;
}
void XTreeWidget::AddIWIFile(std::shared_ptr<IWIFile> aIWIFile) {
void XTreeWidget::AddIWIFile(IWIFile* aIWIFile) {
const QString iwiFileName = QString(aIWIFile->fileStem + ".iwi");
for (int i = 0; i < invisibleRootItem()->childCount(); i++) {
@ -819,12 +784,12 @@ void XTreeWidget::AddIWIFile(std::shared_ptr<IWIFile> aIWIFile) {
}
XTreeWidgetItem *iwiItem = new XTreeWidgetItem(this);
iwiItem->setIcon(0, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
iwiItem->setIcon(0, Utils::CreateAssetIcon(ASSET_TYPE_IMAGE));
iwiItem->setText(0, iwiFileName);
mIWIFiles[aIWIFile->fileStem.section(".", 0, 0)] = aIWIFile;
}
void XTreeWidget::AddDDSFile(std::shared_ptr<DDSFile> aDDSFile) {
void XTreeWidget::AddDDSFile(DDSFile* aDDSFile) {
const QString ddsFileName = QString(aDDSFile->fileStem + ".dds");
for (int i = 0; i < invisibleRootItem()->childCount(); i++) {
@ -835,7 +800,7 @@ void XTreeWidget::AddDDSFile(std::shared_ptr<DDSFile> aDDSFile) {
}
XTreeWidgetItem *ddsItem = new XTreeWidgetItem(this);
ddsItem->setIcon(0, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
ddsItem->setIcon(0, Utils::CreateAssetIcon(ASSET_TYPE_IMAGE));
ddsItem->setText(0, ddsFileName);
mDDSFiles[aDDSFile->fileStem.section(".", 0, 0)] = aDDSFile;
}

View File

@ -2,13 +2,16 @@
#define XTREEWIDGET_H
#include "d3dbsp_structs.h"
#include "asset_structs.h"
#include "ddsfile.h"
#include "iwifile.h"
#include "fastfile.h"
#include "xloadedsound.h"
#include "xtreewidgetitem.h"
#include "zonefile.h"
#include "utils.h"
#include "xrawfile.h"
#include "xgfximage.h"
#include "xstringtable.h"
#include "xmenudef.h"
#include <QTreeWidget>
#include <QFileDialog>
@ -20,31 +23,31 @@ public:
explicit XTreeWidget(QWidget *parent = nullptr);
~XTreeWidget();
void AddFastFile(std::shared_ptr<FastFile> aFastFile);
void AddZoneFile(std::shared_ptr<ZoneFile> aZoneFile, XTreeWidgetItem *aParentItem = nullptr);
void AddIWIFile(std::shared_ptr<IWIFile> aIWIFile);
void AddDDSFile(std::shared_ptr<DDSFile> aDDSFile);
void AddFastFile(FastFile* aFastFile);
void AddZoneFile(const ZoneFile *aZoneFile, XTreeWidgetItem *aParentItem = nullptr);
void AddIWIFile(IWIFile* aIWIFile);
void AddDDSFile(DDSFile* aDDSFile);
std::shared_ptr<ZoneFile> FindZoneFile(const QString aStem);
std::shared_ptr<FastFile> FindFastFile(const QString aStem);
const ZoneFile *FindZoneFile(const QString aStem);
const FastFile* FindFastFile(const QString aStem);
bool HasZoneFile(const QString aStem);
bool HasFastFile(const QString aStem);
void CloseFastFile(const QString aFFName);
signals:
void DDSFileSelected(std::shared_ptr<DDSFile> aDDSFile, const QString aParentName);
void IWIFileSelected(std::shared_ptr<IWIFile> aIWIFile, const QString aParentName);
void FastFileSelected(std::shared_ptr<FastFile> aFastFile, const QString aParentName);
void ZoneFileSelected(std::shared_ptr<ZoneFile> aZoneFile, const QString aParentName);
void LocalStringSelected(std::shared_ptr<ZoneFile> aZoneFile, const QString aParentName);
void RawFileSelected(std::shared_ptr<RawFile> aRawFile, const QString aParentName);
void ImageSelected(std::shared_ptr<Image> aImage, const QString aParentName);
void TechSetSelected(std::shared_ptr<TechSet> aZoneFile, const QString aParentName);
void StrTableSelected(std::shared_ptr<StringTable> aStrTable, const QString aParentName);
void MenuSelected(std::shared_ptr<Menu> aMenu, const QString aParentName);
void SoundSelected(std::shared_ptr<Sound> aSound, const QString aParentName);
void MaterialSelected(std::shared_ptr<Material> aMaterial, const QString aParentName);
void DDSFileSelected(const DDSFile* aDDSFile, const QString aParentName);
void IWIFileSelected(const IWIFile* aIWIFile, const QString aParentName);
void FastFileSelected(const FastFile* aFastFile, const QString aParentName);
void ZoneFileSelected(const ZoneFile* aZoneFile, const QString aParentName);
void LocalStringSelected(const ZoneFile* aZoneFile, const QString aParentName);
void RawFileSelected(const XRawFile* aRawFile, const QString aParentName);
void ImageSelected(const XGfxImage* aImage, const QString aParentName);
void TechSetSelected(const XMaterialTechniqueSet* aZoneFile, const QString aParentName);
void StrTableSelected(const XStringTable* aStrTable, const QString aParentName);
void MenuSelected(const XMenuDef* aMenu, const QString aParentName);
void SoundSelected(const XLoadedSound* aSound, const QString aParentName);
void MaterialSelected(const XMaterial* aMaterial, const QString aParentName);
void ItemSelected(const QString itemText);
void ItemClosed(const QString itemText);
@ -55,10 +58,10 @@ protected:
void PrepareContextMenu(const QPoint &pos);
private:
QMap<QString, std::shared_ptr<FastFile>> mFastFiles;
QMap<QString, std::shared_ptr<ZoneFile>> mZoneFiles;
QMap<QString, std::shared_ptr<DDSFile>> mDDSFiles;
QMap<QString, std::shared_ptr<IWIFile>> mIWIFiles;
QMap<QString, const FastFile*> mFastFiles;
QMap<QString, const ZoneFile*> mZoneFiles;
QMap<QString, const DDSFile*> mDDSFiles;
QMap<QString, const IWIFile*> mIWIFiles;
};
#endif // XTREEWIDGET_H

View File

@ -69,7 +69,7 @@ void ZoneFileViewer::SortTags(const QString &aSearchText) {
ui->listWidget_Tags->addItems(sortedTags);
}
void ZoneFileViewer::SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile) {
void ZoneFileViewer::SetZoneFile(const ZoneFile* aZoneFile) {
mZoneFile = aZoneFile;
ui->tableWidget_RecordCounts->clearContents();
@ -88,37 +88,36 @@ void ZoneFileViewer::SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile) {
ui->groupBox_Tags->show();
}
QMap<QString, int> recordCounts = QMap<QString, int>();
QVector<QPair<QString, int>> assetOccurances = QVector<QPair<QString, int>>();
for (const QString &record : mZoneFile->GetRecords()) {
if (!recordCounts.contains(record)) {
recordCounts[record] = 0;
QMap<XAssetType, int> recordCounts = QMap<XAssetType, int>();
QVector<QPair<XAssetType, int>> assetOccurances = QVector<QPair<XAssetType, int>>();
for (XAssetType type : mZoneFile->GetTypes()) {
if (!recordCounts.contains(type)) {
recordCounts[type] = 0;
}
recordCounts[record]++;
recordCounts[type]++;
if (!assetOccurances.isEmpty() && assetOccurances.last().first == record) {
if (!assetOccurances.isEmpty() && assetOccurances.last().first == type) {
assetOccurances.last().second++;
continue;
}
QPair<QString, int> assetOccurance(record, 1);
QPair<XAssetType, int> assetOccurance(type, 1);
assetOccurances << assetOccurance;
}
ui->tableWidget_RecordOrder->setRowCount(assetOccurances.size());
int assetIndex = 0;
foreach (auto assetOccurance, assetOccurances) {
const QString record = assetOccurance.first;
AssetType assetType = mZoneFile->AssetStrToEnum(record);
XAssetType assetType = assetOccurance.first;
int assetCount = assetOccurance.second;
QIcon assetIcon = mZoneFile->AssetTypeToIcon(assetType);
QIcon assetIcon = Utils::CreateAssetIcon(assetType);
if (assetIcon.isNull()) {
qDebug() << "Icon is null for record: " << record;
qDebug() << "Icon is null for record: " << assetType;
}
QTableWidgetItem *recordItem = new QTableWidgetItem(record.toUpper());
QTableWidgetItem *recordStrItem = new QTableWidgetItem(mZoneFile->AssetEnumToStr(assetType));
QTableWidgetItem *recordItem = new QTableWidgetItem(QString::number(assetType, 16));
QTableWidgetItem *recordStrItem = new QTableWidgetItem(XAsset::XAssetTypeToString(assetType));
QTableWidgetItem *recordCountItem = new QTableWidgetItem(QString::number(assetCount));
recordItem->setIcon(assetIcon);
@ -130,19 +129,18 @@ void ZoneFileViewer::SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile) {
}
int recordIndex = 0;
for (const QString &record : recordCounts.keys()) {
int recordCount = recordCounts[record];
for (XAssetType assetType : recordCounts.keys()) {
int recordCount = recordCounts[assetType];
AssetType assetType = mZoneFile->AssetStrToEnum(record);
QIcon assetIcon = mZoneFile->AssetTypeToIcon(assetType);
QIcon assetIcon = Utils::CreateAssetIcon(assetType);
if (assetIcon.isNull()) {
qDebug() << "Icon is null for record: " << record;
qDebug() << "Icon is null for record: " << assetType;
}
ui->tableWidget_RecordCounts->setRowCount(recordIndex + 1);
QTableWidgetItem *recordItem = new QTableWidgetItem(record.toUpper());
QTableWidgetItem *recordCountStrItem = new QTableWidgetItem(mZoneFile->AssetEnumToStr(assetType));
QTableWidgetItem *recordItem = new QTableWidgetItem(QString::number(assetType, 16));
QTableWidgetItem *recordCountStrItem = new QTableWidgetItem(XAsset::XAssetTypeToString(assetType));
QTableWidgetItem *recordCountItem = new QTableWidgetItem(QString::number(recordCount));
recordItem->setIcon(assetIcon);

View File

@ -18,7 +18,7 @@ public:
explicit ZoneFileViewer(QWidget *parent = nullptr);
~ZoneFileViewer();
void SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile);
void SetZoneFile(const ZoneFile *aZoneFile);
public slots:
void SortTags(const QString &aSearchText);
@ -27,7 +27,7 @@ public slots:
private:
Ui::ZoneFileViewer *ui;
std::shared_ptr<ZoneFile> mZoneFile;
const ZoneFile* mZoneFile;
};
#endif // ZONEFILEVIEWER_H

View File

@ -20,7 +20,6 @@
<file>icons/Icon_Editor.png</file>
<file>icons/Icon_Views.png</file>
<file>icons/Icon_Tree.png</file>
<file>icons/Icon_Copy.png</file>
<file>icons/Icon_Cut.png</file>
<file>icons/Icon_Find.png</file>
<file>icons/Icon_NewFile.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

View File

@ -1,13 +1,10 @@
#include "compression.h"
#include "minilzo.h"
#define XBOXAPI __declspec(dllimport)
#include "xcompress.h"
#include <QLibrary>
#include <QDebug>
#include <QFile>
#include <QDataStream>
QByteArray Compression::CompressXMem(const QByteArray &data)
{
@ -34,7 +31,8 @@ QByteArray Compression::CompressXMem(const QByteArray &data)
return output;
}
QByteArray Compression::DecompressXMem(const QByteArray &data, int flags, int windowSize, int partSize)
QByteArray Compression::DecompressXMem(const QByteArray &data,
int flags, int windowSize, int partSize)
{
if (data.isEmpty())
return {};
@ -44,27 +42,49 @@ QByteArray Compression::DecompressXMem(const QByteArray &data, int flags, int wi
lzxParams.WindowSize = windowSize;
lzxParams.CompressionPartitionSize = partSize;
XMEMDECOMPRESSION_CONTEXT ctx = nullptr;
if (FAILED(XMemCreateDecompressionContext(XMEMCODEC_LZX, &lzxParams, 0, &ctx)) || !ctx)
return {};
QByteArray internalState(0x94933, Qt::Uninitialized);
// Allocate large enough buffer for decompression (16 MB is a safe upper bound)
const SIZE_T kMaxOutSize = 16 * 1024 * 1024;
QByteArray output(static_cast<int>(kMaxOutSize), Qt::Uninitialized);
SIZE_T actualSize = kMaxOutSize;
XMEMDECOMPRESSION_CONTEXT ctx = XMemInitializeDecompressionContext(
XMEMCODEC_LZX, &lzxParams, 1,
internalState.data(), internalState.size());
HRESULT hr = XMemDecompress(ctx,
output.data(), &actualSize,
data.constData(), data.size() + 16);
XMemDestroyDecompressionContext(ctx);
if (FAILED(hr)) {
qWarning() << "XMemDecompress failed with HRESULT:" << hr;
if (!ctx || XMemResetDecompressionContext(ctx)) {
qWarning() << "Failed to init LZX context";
return {};
}
output.resize(static_cast<int>(actualSize));
QByteArray output;
output.reserve(16 * 1024 * 1024); // rough guess
const quint8 *nextIn = reinterpret_cast<const quint8*>(data.constData());
SIZE_T availIn = data.size();
QByteArray scratch(0x10000, Qt::Uninitialized); // 64 KB chunks
while (availIn > 0) {
SIZE_T inSize = availIn; // let XMem tell us how much it will consume
SIZE_T outSize = scratch.size(); // max 64 KB per call
HRESULT hr = XMemDecompressStream(ctx,
scratch.data(), &outSize,
nextIn, &inSize);
if (FAILED(hr)) {
qWarning() << "XMemDecompressStream failed, hr=" << hr;
XMemDestroyDecompressionContext(ctx);
return {};
}
if (inSize == 0 && outSize == 0)
break; // no progress
output.append(scratch.constData(), static_cast<int>(outSize));
nextIn += inSize;
availIn -= inSize;
}
XMemDestroyDecompressionContext(ctx);
return output;
}
@ -80,19 +100,18 @@ quint32 Compression::CalculateAdler32Checksum(const QByteArray &data) {
qint64 Compression::FindZlibOffset(const QByteArray &bytes)
{
static const QByteArray iwffs("IWffs");
auto idx = bytes.indexOf(iwffs);
if (idx != -1)
return idx + 0x4000;
QDataStream stream(bytes);
const char header = 0x78; // z-lib: 0x78 [FLG]
int pos = -1;
while ((pos = bytes.indexOf(header, pos + 1)) != -1)
while (!stream.atEnd())
{
QByteArray window = bytes.mid(pos, 0x20);
if (!window.contains(QByteArray::fromHex("000000")) &&
!window.contains(QByteArray::fromHex("FFFFFF")))
return pos;
QByteArray testSegment = stream.device()->peek(2).toHex().toUpper();
if (testSegment == "7801" ||
testSegment == "785E" ||
testSegment == "789C" ||
testSegment == "78DA") {
return stream.device()->pos();
}
stream.skipRawData(1);
}
return -1;
}
@ -295,11 +314,12 @@ QByteArray Compression::CompressDeflateWithSettings(const QByteArray &aData, int
}
QByteArray Compression::DecompressLZO(const QByteArray &aCompressedData, quint32 aDestSize) {
QByteArray dst;
static bool ok = (lzo_init() == LZO_E_OK);
if (!ok)
throw std::runtime_error("lzo_init failed");
QByteArray dst(aDestSize, Qt::Uninitialized);
dst = QByteArray(aDestSize, Qt::Uninitialized);
lzo_uint out = aDestSize;
int rc = lzo1x_decompress_safe(

View File

@ -3,7 +3,7 @@
#include "QtZlib/zlib.h"
#include <windows.h>
//#include <windows.h>
#include <QtGlobal>
#include <stddef.h>
#include <QByteArray>

View File

@ -3,15 +3,9 @@ TEMPLATE = lib
CONFIG += staticlib c++17
DEFINES += MINILZO_USE_STATIC
SOURCES += \
compression.cpp \
minilzo.c \
lzoconf.h \
lzodefs.h
HEADERS += \
compression.h \
minilzo.h
SOURCES += $$files($$PWD/*.cpp, true) \
$$files($$PWD/*.c, true)
HEADERS += $$files($$PWD/*.h, true)
LIBS += \
-L$$PWD/../../third_party/xbox_sdk/lib -lxcompress64 \

View File

@ -57,7 +57,7 @@
/* get OS and architecture defines */
#ifndef __LZODEFS_H_INCLUDED
#include <lzo/lzodefs.h>
#include <lzodefs.h>
#endif
@ -105,7 +105,7 @@ extern "C" {
# define LZO_INT_MAX 9223372036854775807LL
# define LZO_INT_MIN (-1LL - LZO_INT_MAX)
# elif (LZO_ABI_IP32L64) /* MIPS R5900 */
typedef unsigned int lzo_uint;
typedef quint32 lzo_uint;
typedef int lzo_int;
# define LZO_SIZEOF_LZO_INT LZO_SIZEOF_INT
# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_INT

View File

@ -2847,7 +2847,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_LONG
#elif (LZO_SIZEOF_INT == 2) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT16E_T == LZO_TYPEOF_SHORT)
# define lzo_int16e_t int
# define lzo_uint16e_t unsigned int
# define lzo_uint16e_t quint32
# define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_INT
#elif (LZO_SIZEOF_SHORT == 2)
# define lzo_int16e_t short int
@ -2856,14 +2856,14 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM)
# if !(LZO_LANG_ASSEMBLER)
typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__)));
typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__)));
typedef quint32 lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__)));
# endif
# define lzo_int16e_t lzo_int16e_hi_t__
# define lzo_uint16e_t lzo_uint16e_hi_t__
# define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___MODE_HI
#elif (LZO_SIZEOF___INT16 == 2)
# define lzo_int16e_t __int16
# define lzo_uint16e_t unsigned __int16
# define lzo_uint16e_t quint32
# define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___INT16
#else
#endif
@ -2883,7 +2883,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG
#elif (LZO_SIZEOF_INT == 4)
# define lzo_int32e_t int
# define lzo_uint32e_t unsigned int
# define lzo_uint32e_t quint32
# define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_INT
#elif (LZO_SIZEOF_SHORT == 4)
# define lzo_int32e_t short int
@ -2896,7 +2896,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L)
# if !(LZO_LANG_ASSEMBLER)
typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
typedef quint32 lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
# endif
# define lzo_int32e_t lzo_int32e_si_t__
# define lzo_uint32e_t lzo_uint32e_si_t__
@ -2904,7 +2904,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L)
# if !(LZO_LANG_ASSEMBLER)
typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
typedef quint32 lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
# endif
# define lzo_int32e_t lzo_int32e_si_t__
# define lzo_uint32e_t lzo_uint32e_si_t__
@ -2913,7 +2913,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI
#elif (LZO_SIZEOF___INT32 == 4)
# define lzo_int32e_t __int32
# define lzo_uint32e_t unsigned __int32
# define lzo_uint32e_t quint32
# define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___INT32
#else
#endif
@ -2937,7 +2937,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
#endif
#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
# define lzo_int64e_t int
# define lzo_uint64e_t unsigned int
# define lzo_uint64e_t quint32
# define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_INT
#elif (LZO_SIZEOF_LONG == 8) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF_LONG_LONG) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF___INT64)
# define lzo_int64e_t long int
@ -2984,7 +2984,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define LZO_TYPEOF_LZO_INT32L_T LZO_TYPEOF_LZO_INT32E_T
#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
# define lzo_int32l_t int
# define lzo_uint32l_t unsigned int
# define lzo_uint32l_t quint32
# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT
# define LZO_TYPEOF_LZO_INT32L_T LZO_SIZEOF_INT
#elif (LZO_SIZEOF_LONG >= 4)
@ -3057,7 +3057,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4))
# if !(LZO_LANG_ASSEMBLER)
typedef __w64 int lzo_intptr_t;
typedef __w64 unsigned int lzo_uintptr_t;
typedef __w64 quint32 lzo_uintptr_t;
# endif
# define lzo_intptr_t lzo_intptr_t
# define lzo_uintptr_t lzo_uintptr_t
@ -3070,7 +3070,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_SHORT
#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
# define lzo_intptr_t int
# define lzo_uintptr_t unsigned int
# define lzo_uintptr_t quint32
# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
# define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_INT
#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P)
@ -3104,7 +3104,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG
# define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_LONG
#elif (LZO_WORDSIZE == LZO_SIZEOF_INT)
# define lzo_word_t unsigned int
# define lzo_word_t quint32
# define lzo_sword_t int
# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT
# define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_INT

View File

@ -25,12 +25,6 @@
http://www.oberhumer.com/opensource/lzo/
*/
/*
* NOTE:
* the full LZO package can be found at
* http://www.oberhumer.com/opensource/lzo/
*/
#define __LZO_IN_MINILZO 1
#if defined(LZO_CFG_FREESTANDING)

View File

@ -25,13 +25,6 @@
http://www.oberhumer.com/opensource/lzo/
*/
/*
* NOTE:
* the full LZO package can be found at
* http://www.oberhumer.com/opensource/lzo/
*/
#ifndef __MINILZO_H_INCLUDED
#define __MINILZO_H_INCLUDED 1

View File

@ -2,23 +2,15 @@ QT += core widgets
TEMPLATE = lib
CONFIG += staticlib c++17
SOURCES += \
highlighter_cfg.cpp \
highlighter_shock.cpp \
highlighter_rumble.cpp \
highlighter_gsc.cpp \
logmanager.cpp \
statusbarmanager.cpp
SOURCES += $$files($$PWD/*.cpp, true) \
xdatastream.cpp
HEADERS += $$files($$PWD/*.h, true) \
xdatastream.h
HEADERS += \
enums.h \
highlighter_cfg.h \
highlighter_shock.h \
highlighter_rumble.h \
highlighter_gsc.h \
logmanager.h \
stringutils.h \
utils.h \
statusbarmanager.h
LIBS += -L$$OUT_PWD/../libs/xassets -lxassets
INCLUDEPATH += $$PWD/../xassets
DEPENDPATH += $$PWD/../xassets
DESTDIR = $$OUT_PWD/../

View File

@ -3,28 +3,6 @@
#include <QString>
enum FF_PLATFORM {
FF_PLATFORM_NONE = 0x00, // No platform
FF_PLATFORM_XBOX = 0x01, // Xbox 360
FF_PLATFORM_PS3 = 0x02, // Playstation 3
FF_PLATFORM_PC = 0x03, // PC
FF_PLATFORM_WII = 0x04, // WII
FF_PLATFORM_WIIU = 0x05 // WII U
};
enum FF_GAME {
FF_GAME_NONE = 0x00, // No game
FF_GAME_COD1 = 0x01, // Call of Duty
FF_GAME_COD2 = 0x02, // Call of Duty 2
FF_GAME_COD3 = 0x03, // Call of Duty 3
FF_GAME_COD4 = 0x04, // Modern Warware 1
FF_GAME_COD5 = 0x05, // World at War
FF_GAME_COD6 = 0x06, // Modern Warfare 2
FF_GAME_COD7 = 0x07, // Black Ops 1
FF_GAME_COD8 = 0x08, // Modern Warfare 3
FF_GAME_COD9 = 0x09, // Black Ops 2
};
enum IWI_VERSION {
IWI_VERSION_COD2 = 0x05, // 05 CoD2
IWI_VERSION_COD4 = 0x06, // 06 CoD4
@ -432,7 +410,7 @@ enum MENU_FONT_TYPE{
UI_FONT_DEFAULT = 0, // auto-chose betwen big/reg/small
UI_FONT_NORMAL = 1,
UI_FONT_BIG = 2,
UI_FONT_SMALL = 3,
UI_GameFontMALL = 3,
UI_FONT_BOLD = 4,
UI_FONT_CONSOLE = 5,
UI_FONT_OBJECTIVE = 6,

View File

@ -2,15 +2,19 @@
#define UTILS_H
#include "enums.h"
#include "QtZlib/zlib.h"
#include "qdir.h"
#include "qicon.h"
#include "xasset.h"
#include "xassettype.h"
#include <QString>
#include <QtZlib/zlib.h>
#include <QFileDialog>
#include <QMessageBox>
#include <QMetaEnum>
#include <QPainter>
#include <QCryptographicHash>
class Utils {
class Utils : public QObject {
Q_OBJECT
public:
static bool ExportData(const QString aFileName, const QByteArray aData) {
QDir workingDir = QDir::currentPath();
@ -30,6 +34,29 @@ public:
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
return b;
}
static QIcon CreateAssetIcon(XAssetType aAssetType, QColor color = QColor()) {
const QString assetTypeStr = XAsset::XAssetTypeToString(aAssetType);
QString assetAbbr;
for (int i = 0; i < assetTypeStr.length(); i++)
{
if (assetTypeStr[i].isUpper())
{
assetAbbr += assetTypeStr[i];
}
}
return CreateAssetIcon(assetAbbr, color);
// QString name;
// const QStringList parts = assetTypeStr.split('_').mid(1);
// foreach (const QString part, parts) {
// name += part[0];
// }
// if (parts.size() == 1) {
// name += parts.first()[1];
// }
// return CreateAssetIcon(name, color);
}
static QIcon CreateAssetIcon(const QString& name, QColor color = QColor()) {
constexpr int iconSize = 32;
constexpr int padding = 4;
@ -196,7 +223,7 @@ public:
return color;
}
static bool ReadUntilString(QDataStream* stream, const QString& targetString) {
static bool ReadUntilString(XDataStream* stream, const QString& targetString) {
if (!stream || targetString.isEmpty()) {
return false; // Invalid input
}
@ -230,7 +257,7 @@ public:
return false;
}
static bool ReadUntilHex(QDataStream* stream, const QString& hexString) {
static bool ReadUntilHex(XDataStream* stream, const QString& hexString) {
if (!stream || hexString.isEmpty() || hexString.size() % 2 != 0) {
return false; // Invalid input
}
@ -380,34 +407,6 @@ public:
return PadInt4(size) - size;
}
static QString GetOpenFastFileName(QWidget *parent = nullptr) {
// Open file dialog to steam apps
const QString steamPath = "C:/Program Files (x86)/Steam/steamapps/common/Call of Duty World at War/zone/english/";
const QString fastFilePath = QFileDialog::getOpenFileName(parent, "Open Fast File", steamPath, "Fast File (*.ff);;All Files (*.*)");
if (fastFilePath.isNull()) {
// User pressed cancel
return "";
} else if (!QFile::exists(fastFilePath)) {
QMessageBox::warning(parent, "Warning!", QString("%1 does not exist!.").arg(fastFilePath));
return "";
}
return fastFilePath;
}
static QString GetOpenZoneFileName(QWidget *parent = nullptr) {
// Open file dialog to steam apps
const QString steamPath = "C:/Program Files (x86)/Steam/steamapps/common/Call of Duty World at War/zone/english/";
const QString zoneFilePath = QFileDialog::getOpenFileName(parent, "Open Zone File", steamPath, "Zone File (*.zone);;All Files (*.*)");
if (zoneFilePath.isNull()) {
// User pressed cancel
return "";
} else if (!QFile::exists(zoneFilePath)) {
QMessageBox::warning(parent, "Warning!", QString("%1 does not exist!.").arg(zoneFilePath));
return nullptr;
}
return zoneFilePath;
}
static QString CompanyEnumToStr(FF_COMPANY aCompany) {
switch (aCompany) {
case COMPANY_NONE:

243
libs/core/xdatastream.cpp Normal file
View File

@ -0,0 +1,243 @@
#include "xdatastream.h"
#include <QIODevice>
#include <QDebug>
XDataStream::XDataStream(QIODevice *aDevice)
: QDataStream(aDevice)
, mDebug(false)
{
}
XDataStream::XDataStream()
: QDataStream()
, mDebug(false)
{
}
XDataStream::XDataStream(const QByteArray &aData)
: QDataStream(aData)
, mDebug(false)
{
}
XDataStream::XDataStream(QByteArray *aData, OpenMode aFlags)
: QDataStream(aData, aFlags)
, mDebug(false)
{
}
XDataStream::~XDataStream()
{
}
void XDataStream::SetDebug(bool aDebug)
{
mDebug = aDebug;
}
qint8 XDataStream::ParseInt8(const QString& aDebugString)
{
qint64 start = this->device()->pos();
qint8 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
quint8 XDataStream::ParseUInt8(const QString& aDebugString)
{
qint64 start = this->device()->pos();
quint8 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
qint16 XDataStream::ParseInt16(const QString& aDebugString)
{
qint64 start = this->device()->pos();
qint16 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
quint16 XDataStream::ParseUInt16(const QString& aDebugString)
{
qint64 start = this->device()->pos();
quint16 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
qint32 XDataStream::ParseInt32(const QString& aDebugString)
{
qint64 start = this->device()->pos();
qint32 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
quint32 XDataStream::ParseUInt32(const QString& aDebugString)
{
qint64 start = this->device()->pos();
quint32 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
qint64 XDataStream::ParseInt64(const QString& aDebugString)
{
qint64 start = this->device()->pos();
qint64 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
quint64 XDataStream::ParseUInt64(const QString& aDebugString)
{
qint64 start = this->device()->pos();
quint64 val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
float XDataStream::ParseSingle(const QString& aDebugString)
{
qint64 start = this->device()->pos();
float val;
quint32 rawVal;
*this >> rawVal;
memcpy(&val, &rawVal, sizeof(val));
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
double XDataStream::ParseDouble(const QString& aDebugString)
{
qint64 start = this->device()->pos();
float val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}
bool XDataStream::ParseBool(const QString &aDebugString)
{
qint64 start = this->device()->pos();
char val;
*this >> val;
if (mDebug)
{
qDebug() << QString("[%1-%2] Parsed %3: %4")
.arg(start, 10, 10, QChar('0'))
.arg(this->device()->pos(), 10, 10, QChar('0'))
.arg(aDebugString)
.arg(val);
}
return val;
}

34
libs/core/xdatastream.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef XDATASTREAM_H
#define XDATASTREAM_H
#include <QDataStream>
#include <QString>
class XDataStream : public QDataStream
{
public:
explicit XDataStream(QIODevice* aDevice);
XDataStream();
XDataStream(const QByteArray& aData);
XDataStream(QByteArray* aData, OpenMode aFlags);
~XDataStream();
void SetDebug(bool aDebug = true);
qint8 ParseInt8(const QString& aDebugString = "");
quint8 ParseUInt8(const QString& aDebugString = "");
qint16 ParseInt16(const QString& aDebugString = "");
quint16 ParseUInt16(const QString& aDebugString = "");
qint32 ParseInt32(const QString& aDebugString = "");
quint32 ParseUInt32(const QString& aDebugString = "");
qint64 ParseInt64(const QString& aDebugString = "");
quint64 ParseUInt64(const QString& aDebugString = "");
float ParseSingle(const QString& aDebugString = "");
double ParseDouble(const QString& aDebugString = "");
bool ParseBool(const QString& aDebugString = "");
private:
bool mDebug;
};
#endif // XDATASTREAM_H

View File

@ -35,7 +35,7 @@ DDSPixelFormat DDSFile::CalculatePixelFormat(quint8 aIWIFormat) {
return ddsPixelFormat;
}
void DDSFile::SetupExportDirs() {
void DDSFile::SetupExportDirs() const {
QDir dir = QDir::currentPath();
if (!dir.exists("exports/")) {
dir.mkdir("exports/");
@ -89,92 +89,92 @@ DDSFile::DDSFile(const QString &aFilePath)
}
DDSFile::DDSFile(const QByteArray aDDSData, const QString aFileStem) {
QDataStream ddsIn(aDDSData);
ddsIn.setByteOrder(QDataStream::LittleEndian);
// QDataStream ddsIn(aDDSData);
// ddsIn.setByteOrder(QDataStream::LittleEndian);
DDSHeader ddsHeader;
if (ddsIn.readRawData(reinterpret_cast<char*>(&ddsHeader), sizeof(DDSHeader)) != sizeof(DDSHeader)) {
qDebug() << "Error: Failed to read DDSHeader from QByteArray!";
return;
}
// DDSHeader ddsHeader;
// if (ddsIn.readRawData(reinterpret_cast<char*>(&ddsHeader), sizeof(DDSHeader)) != sizeof(DDSHeader)) {
// qDebug() << "Error: Failed to read DDSHeader from QByteArray!";
// return;
// }
fileStem = aFileStem;
header = ddsHeader;
// fileStem = aFileStem;
// header = ddsHeader;
// Ensure DevIL is initialized once globally
static bool devilInitialized = false;
if (!devilInitialized) {
ilInit();
devilInitialized = true;
}
// // Ensure DevIL is initialized once globally
// static bool devilInitialized = false;
// if (!devilInitialized) {
// ilInit();
// devilInitialized = true;
// }
// Generate and bind an image
ILuint imageID;
ilGenImages(1, &imageID);
ilBindImage(imageID);
// // Generate and bind an image
// ILuint imageID;
// ilGenImages(1, &imageID);
// ilBindImage(imageID);
ilEnable(IL_ORIGIN_SET);
ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
// ilEnable(IL_ORIGIN_SET);
// ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
// Load DDS file
if (!ilLoadL(IL_DDS, aDDSData.constData(), aDDSData.size())) {
ILuint devilError = ilGetError();
qDebug() << "DevIL Error while loading DDS: " << devilError;
ilDeleteImages(1, &imageID);
return;
}
// // Load DDS file
// if (!ilLoadL(IL_DDS, aDDSData.constData(), aDDSData.size())) {
// ILuint devilError = ilGetError();
// qDebug() << "DevIL Error while loading DDS: " << devilError;
// ilDeleteImages(1, &imageID);
// return;
// }
// Get mipmap count
ILint numMipmaps = ilGetInteger(IL_NUM_MIPMAPS);
qDebug() << "Number of mipmaps: " << numMipmaps;
// // Get mipmap count
// ILint numMipmaps = ilGetInteger(IL_NUM_MIPMAPS);
// qDebug() << "Number of mipmaps: " << numMipmaps;
// Loop over all mipmap levels (0 is the base image)
for (ILint level = 0; level <= numMipmaps; ++level) {
ilBindImage(imageID);
if (!ilActiveMipmap(level)) {
qDebug() << "DevIL failed to activate mipmap level" << level;
continue;
}
// // Loop over all mipmap levels (0 is the base image)
// for (ILint level = 0; level <= numMipmaps; ++level) {
// ilBindImage(imageID);
// if (!ilActiveMipmap(level)) {
// qDebug() << "DevIL failed to activate mipmap level" << level;
// continue;
// }
// Get mipmap properties
int width = ilGetInteger(IL_IMAGE_WIDTH);
int height = ilGetInteger(IL_IMAGE_HEIGHT);
int depth = ilGetInteger(IL_IMAGE_DEPTH);
int format = ilGetInteger(IL_IMAGE_FORMAT);
int bpp = 0;
// // Get mipmap properties
// int width = ilGetInteger(IL_IMAGE_WIDTH);
// int height = ilGetInteger(IL_IMAGE_HEIGHT);
// int depth = ilGetInteger(IL_IMAGE_DEPTH);
// int format = ilGetInteger(IL_IMAGE_FORMAT);
// int bpp = 0;
switch (format) {
case IL_RGB:
bpp = 3;
break;
case IL_RGBA:
bpp = 4;
break;
default:
qDebug() << "Unsupported image format.";
continue;
}
// switch (format) {
// case IL_RGB:
// bpp = 3;
// break;
// case IL_RGBA:
// bpp = 4;
// break;
// default:
// qDebug() << "Unsupported image format.";
// continue;
// }
int dataSize = width * height * depth * bpp;
// int dataSize = width * height * depth * bpp;
ILubyte *data = ilGetData();
if (!data) {
qDebug() << "Error: DevIL returned null data for mipmap level" << level;
continue;
}
// ILubyte *data = ilGetData();
// if (!data) {
// qDebug() << "Error: DevIL returned null data for mipmap level" << level;
// continue;
// }
// Create a mipmap structure
DDSMipmap mipmap;
mipmap.width = width;
mipmap.height = height;
mipmap.data = QByteArray(reinterpret_cast<const char*>(data), dataSize);
mipmap.size = dataSize;
// // Create a mipmap structure
// DDSMipmap mipmap;
// mipmap.width = width;
// mipmap.height = height;
// mipmap.data = QByteArray(reinterpret_cast<const char*>(data), dataSize);
// mipmap.size = dataSize;
// Store in DDS file
mipmaps.append(mipmap);
}
// // Store in DDS file
// mipmaps.append(mipmap);
// }
ilDeleteImages(1, &imageID);
// ilDeleteImages(1, &imageID);
}
DDSFile::DDSFile(const DDSFile &ddsFile) :
@ -248,7 +248,7 @@ DDSFile &DDSFile::operator=(const DDSFile &other) {
}
// Write a DDS file from a DDSFile object
bool DDSFile::SaveDDS() {
bool DDSFile::SaveDDS() const {
SetupExportDirs();
QFile file("exports/dds/" + fileStem + ".dds");
@ -268,7 +268,7 @@ bool DDSFile::SaveDDS() {
return true;
}
bool DDSFile::SaveIWI() {
bool DDSFile::SaveIWI() const {
SetupExportDirs();
IWIFile iwiFile(*this);
@ -279,7 +279,7 @@ bool DDSFile::SaveIWI() {
return true;
}
bool DDSFile::SavePNG() {
bool DDSFile::SavePNG() const {
SetupExportDirs();
int mipmapIndex = 1;
@ -311,7 +311,7 @@ bool DDSFile::SavePNG() {
return true;
}
bool DDSFile::SaveJPG() {
bool DDSFile::SaveJPG() const {
SetupExportDirs();
int mipmapIndex = 1;

View File

@ -9,7 +9,7 @@
#include <QVector>
#include <QDebug>
#include <QImage>
#include <IL/il.h>
//#include <IL/il.h>
struct DDSPixelFormat {
quint32 size;
@ -68,12 +68,12 @@ public:
DDSFile(const DDSFile &ddsFile);
DDSFile& operator=(const DDSFile& other);
bool SaveDDS();
bool SaveIWI();
bool SavePNG();
bool SaveJPG();
bool SaveDDS() const;
bool SaveIWI() const;
bool SavePNG() const;
bool SaveJPG() const;
void SetupExportDirs();
void SetupExportDirs() const;
static DDSPixelFormat CalculatePixelFormat(quint8 aIWIFormat);
private:

View File

@ -2,26 +2,21 @@ QT += core
TEMPLATE = lib
CONFIG += staticlib c++17
SOURCES += \
ddsfile.cpp
HEADERS += \
dds_structs.h \
ddsfile.h \
enums.h
SOURCES += $$files($$PWD/*.cpp, true)
HEADERS += $$files($$PWD/*.h, true)
LIBS += \
-L$$PWD/../../third_party/devil_sdk/lib/ -lDevIL \
-L$$PWD/../../third_party/devil_sdk/lib/ -lILU \
-L$$PWD/../../third_party/devil_sdk/lib/ -lILUT \
#-L$$PWD/../../third_party/devil_sdk/lib/ -lDevIL \
#-L$$PWD/../../third_party/devil_sdk/lib/ -lILU \
#-L$$PWD/../../third_party/devil_sdk/lib/ -lILUT \
-L$$OUT_PWD/../libs/iwifile -liwifile
INCLUDEPATH += \
$$PWD/../iwifile/ \
$$PWD/../../third_party/devil_sdk/include/
#$$PWD/../../third_party/devil_sdk/include/
DEPENDPATH += \
$$PWD/../iwifile/ \
$$PWD/../../third_party/devil_sdk/include/
#$$PWD/../../third_party/devil_sdk/include/
DESTDIR = $$OUT_PWD/../

View File

@ -430,7 +430,7 @@ enum MENU_FONT_TYPE{
UI_FONT_DEFAULT = 0, // auto-chose betwen big/reg/small
UI_FONT_NORMAL = 1,
UI_FONT_BIG = 2,
UI_FONT_SMALL = 3,
UI_GameFontMALL = 3,
UI_FONT_BOLD = 4,
UI_FONT_CONSOLE = 5,
UI_FONT_OBJECTIVE = 6,

View File

@ -1,15 +1,5 @@
/* ecrypt-portable.h */
/*
* WARNING: the conversions defined below are implemented as macros,
* and should be used carefully. They should NOT be used with
* parameters which perform some action. E.g., the following two lines
* are not equivalent:
*
* 1) ++x; y = ROTL32(x, n);
* 2) y = ROTL32(++x, n);
*/
/*
* *** Please do not edit this file. ***
*
@ -27,10 +17,10 @@
/*
* The following types are defined (if available):
*
* u8: unsigned integer type, at least 8 bits
* u16: unsigned integer type, at least 16 bits
* u32: unsigned integer type, at least 32 bits
* u64: unsigned integer type, at least 64 bits
* u8: quint32eger type, at least 8 bits
* u16: quint32eger type, at least 16 bits
* u32: quint32eger type, at least 32 bits
* u64: quint32eger type, at least 64 bits
*
* s8, s16, s32, s64 -> signed counterparts of u8, u16, u32, u64
*

View File

@ -1,27 +1,35 @@
#include "encryption.h"
#include <QtCore>
#include "QtZlib/zlib.h"
#include "ecrypt-sync.h"
#include "sha1.h"
#include "encryption.h"
#include "compression.h"
void Encryption::Convert32BitTo8Bit(quint32 value, quint8 *array) {
static QVector<quint32> ivCounter(4, 1); // start all counters at 1
void Encryption::Convert32BitTo8Bit(quint32 value, quint8 *array)
{
array[0] = static_cast<quint8>(value >> 0);
array[1] = static_cast<quint8>(value >> 8);
array[2] = static_cast<quint8>(value >> 16);
array[3] = static_cast<quint8>(value >> 24);
}
quint32 Encryption::ConvertArrayTo32Bit(const QByteArray &array) {
quint32 Encryption::ConvertArrayTo32Bit(const QByteArray &array)
{
return ((static_cast<quint32>(static_cast<uchar>(array[0])) << 0) |
(static_cast<quint32>(static_cast<uchar>(array[1])) << 8) |
(static_cast<quint32>(static_cast<uchar>(array[2])) << 16) |
(static_cast<quint32>(static_cast<uchar>(array[3])) << 24));
}
quint32 Encryption::Rotate(quint32 value, quint32 numBits) {
quint32 Encryption::Rotate(quint32 value, quint32 numBits)
{
return (value << numBits) | (value >> (32 - numBits));
}
QByteArray Encryption::InitIVTable(const QByteArray &feed) {
QByteArray Encryption::InitIVTable(const QByteArray &feed)
{
const int tableSize = 0xFB0;
QByteArray table;
table.resize(tableSize);
@ -48,22 +56,23 @@ QByteArray Encryption::InitIVTable(const QByteArray &feed) {
return table;
}
int Encryption::unk(quint64 arg1, quint8 arg2) {
int Encryption::unk(quint64 arg1, quint8 arg2)
{
if (arg2 >= 0x40)
return 0;
return static_cast<int>(arg1 >> arg2);
}
QByteArray Encryption::GetIV(const QByteArray &table, int index) {
int num1 = 0xFA0 + index;
QByteArray Encryption::GetIV(const QByteArray &table, int index)
{
int num1 = (4 * index % 4 + 0xFA0) + index % 4 + (index - (index % 4));
int num2 = unk(0x51EB851FLL * num1, 0x20);
int adjust = ((num2 >> 6) + (num2 >> 31));
int startIndex = 20 * (num1 - 200 * adjust);
// Return 8 bytes from that location.
int startIndex = 20 * (num1 - 200 * ((num2 >> 6) + (num2 >> 31)));
return table.mid(startIndex, 8);
}
void Encryption::UpdateIVTable(QByteArray &table, int index, const QByteArray &sectionHash) {
void Encryption::UpdateIVTable(QByteArray &table, int index, const QByteArray &sectionHash)
{
int blockNumIndex = index % 4;
int baseOffset = 0xFA0 + blockNumIndex * 4;
quint32 blockNumVal = (static_cast<uchar>(table.at(baseOffset)) ) |
@ -86,8 +95,9 @@ void Encryption::UpdateIVTable(QByteArray &table, int index, const QByteArray &s
}
}
quint32 Encryption::ToUInt32(const QByteArray &data, int offset) {
// Converts 4 bytes (starting at offset) from data into a 32-bit unsigned integer (little-endian)
quint32 Encryption::ToUInt32(const QByteArray &data, int offset)
{
// Converts 4 bytes (starting at offset) from data into a 32-bit quint32eger (little-endian)
return ((static_cast<quint32>(static_cast<uchar>(data[offset])) ) |
(static_cast<quint32>(static_cast<uchar>(data[offset+1])) << 8 ) |
(static_cast<quint32>(static_cast<uchar>(data[offset+2])) << 16) |
@ -351,96 +361,8 @@ void Encryption::generateNewIV(int index, const QByteArray &hash, QByteArray &iv
ivCounter[index]++;
}
QByteArray Encryption::decryptFastFile_BO2(const QByteArray &fastFileData)
QByteArray Encryption::decryptFastFile_BO3(const QByteArray &fastFileData)
{
const QByteArray bo2_salsa20_key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
QByteArray fileData = fastFileData;
QByteArray finalFastFile;
QByteArray ivTable(16000, 0);
fillIVTable(fileData, ivTable, 16000 - 1);
QVector<quint32> ivCounter(4, 1);
QDataStream stream(fileData);
stream.setByteOrder(QDataStream::LittleEndian);
stream.skipRawData(0x138);
QByteArray sha1Hash(20, 0);
QByteArray ivPtr(8, 0);
int chunkIndex = 0;
while (!stream.atEnd()) {
quint32 dataLength;
stream >> dataLength;
if (dataLength == 0 || dataLength > fileData.size() - stream.device()->pos()) {
qWarning() << "Invalid data length at offset: " << stream.device()->pos();
break;
}
fillIV(chunkIndex % 4, ivPtr, ivTable, ivCounter);
ECRYPT_ctx x;
ECRYPT_keysetup(&x, reinterpret_cast<const u8*>(bo2_salsa20_key.constData()), 256, 0);
ECRYPT_ivsetup(&x, reinterpret_cast<const u8*>(ivPtr.constData()));
QByteArray encryptedBlock = fileData.mid(stream.device()->pos(), dataLength);
QByteArray decryptedBlock;
decryptedBlock.resize(dataLength);
ECRYPT_decrypt_bytes(&x, reinterpret_cast<const u8*>(encryptedBlock.constData()),
reinterpret_cast<u8*>(decryptedBlock.data()), dataLength);
QCryptographicHash sha1(QCryptographicHash::Sha1);
sha1.addData(decryptedBlock);
sha1Hash = sha1.result();
z_stream strm = {};
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = static_cast<uInt>(decryptedBlock.size());
strm.next_in = reinterpret_cast<Bytef*>(decryptedBlock.data());
QByteArray decompressedData;
decompressedData.resize(fmax(dataLength * 2, 4096));
strm.avail_out = decompressedData.size();
strm.next_out = reinterpret_cast<Bytef*>(decompressedData.data());
int zReturn = inflateInit2(&strm, -15);
if (zReturn != Z_OK) {
qWarning() << "inflateInit2 failed with error code" << zReturn;
break;
}
zReturn = inflate(&strm, Z_FINISH);
inflateEnd(&strm);
if (zReturn != Z_STREAM_END) {
qDebug() << "Error decompressing at offset: " << stream.device()->pos() << " : " << zReturn;
decompressedData.clear();
} else {
decompressedData.resize(strm.total_out);
}
finalFastFile.append(decompressedData);
generateNewIV(chunkIndex % 4, sha1Hash, ivTable, ivCounter);
if (stream.device()->pos() + static_cast<qint64>(dataLength) > fileData.size()) {
qWarning() << "Skipping past file size!";
break;
}
stream.skipRawData(dataLength);
chunkIndex++;
}
return finalFastFile;
}
QByteArray Encryption::decryptFastFile_BO3(const QByteArray &fastFileData) {
const QByteArray salsaKey = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
QByteArray ivTable(0xFB0, 0);
@ -504,3 +426,71 @@ QByteArray Encryption::decryptFastFile_BO3(const QByteArray &fastFileData) {
return finalFastFile;
}
QByteArray Encryption::DecryptFile(const QByteArray &fastFileData, const QString &aFileName, const QByteArray &aKey)
{
Q_UNUSED(aFileName);
const QByteArray salsaKey = QByteArray::fromHex(aKey);
QByteArray ivTable(0xFB0, 0);
fillIVTable(fastFileData, ivTable, 0xFB0 - 1);
QVector<quint32> ivCounter(4, 1);
QDataStream stream(fastFileData);
stream.setByteOrder(QDataStream::LittleEndian);
QByteArray finalFastFile;
QByteArray sha1Hash(20, 0);
QByteArray ivPtr(8, 0);
int chunkIndex = 0;
while (!stream.atEnd()) {
if (stream.device()->bytesAvailable() < 4) {
qWarning() << "No sufficient data for chunk size at offset:" << stream.device()->pos();
break;
}
quint32 dataLength;
stream >> dataLength;
if (dataLength == 0 || dataLength > fastFileData.size() - stream.device()->pos()) {
qWarning() << "Invalid data length at offset:" << stream.device()->pos();
break;
}
fillIV(chunkIndex % 4, ivPtr, ivTable, ivCounter);
ECRYPT_ctx x;
ECRYPT_keysetup(&x, reinterpret_cast<const u8*>(salsaKey.constData()), 256, 0);
ECRYPT_ivsetup(&x, reinterpret_cast<const u8*>(ivPtr.constData()));
QByteArray encryptedBlock = fastFileData.mid(stream.device()->pos(), dataLength);
QByteArray decryptedBlock(dataLength, Qt::Uninitialized);
ECRYPT_decrypt_bytes(&x,
reinterpret_cast<const u8*>(encryptedBlock.constData()),
reinterpret_cast<u8*>(decryptedBlock.data()),
dataLength);
// SHA1 hash update
sha1Hash = QCryptographicHash::hash(decryptedBlock, QCryptographicHash::Sha1);
// Decompress (ZLIB raw DEFLATE)
QByteArray decompressedData = Compression::DecompressDeflate(decryptedBlock);
if (decompressedData.isEmpty()) {
qWarning() << "Failed decompression at chunk index:" << chunkIndex;
return QByteArray();
}
finalFastFile.append(decompressedData);
// Update IV table using SHA1
generateNewIV(chunkIndex % 4, sha1Hash, ivTable, ivCounter);
stream.skipRawData(dataLength);
chunkIndex++;
}
return finalFastFile;
}

View File

@ -46,8 +46,9 @@ public:
static void generateNewIV(int index, const QByteArray& hash, QByteArray& ivTable, QVector<quint32>& ivCounter);
static QByteArray decryptFastFile_BO2(const QByteArray& fastFileData);
//static QByteArray decryptFastFile_BO2(const QByteArray& fastFileData);
static QByteArray decryptFastFile_BO3(const QByteArray& fastFileData);
static QByteArray DecryptFile(const QByteArray& fastFileData, const QString& aFileName, const QByteArray& aKey);
};
#endif // ENCRYPTION_H

View File

@ -2,20 +2,8 @@ QT += core
TEMPLATE = lib
CONFIG += staticlib c++17
SOURCES += \
salsa20.cpp \
sha1.cpp \
encryption.cpp
HEADERS += \
ecrypt-config.h \
ecrypt-machine.h \
ecrypt-portable.h \
ecrypt-sync.h \
encryption.h \
os_types.h \
config_win32.h \
sha1.h
SOURCES += $$files($$PWD/*.cpp, true)
HEADERS += $$files($$PWD/*.h, true)
app.depends += \
compression

View File

@ -59,7 +59,7 @@ void ECRYPT_encrypt_bytes(ECRYPT_ctx *x,const u8 *m,u8 *c,u32 bytes)
u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
u8 *ctarget;
u8 tmp[64];
unsigned int i;
u32 i;
if (!bytes) return;
@ -82,7 +82,10 @@ void ECRYPT_encrypt_bytes(ECRYPT_ctx *x,const u8 *m,u8 *c,u32 bytes)
for (;;) {
if (bytes < 64) {
for (i = 0;i < bytes;++i) tmp[i] = m[i];
for (i = 0; i < bytes; ++i)
{
tmp[i] = m[i];
}
m = tmp;
ctarget = c;
c = tmp;

View File

@ -10,7 +10,7 @@ Still 100% Public Domain
Corrected a problem which generated improper hash values on 16 bit machines
Routine SHA1Update changed from
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
void SHA1Update(SHA1_CTX* context, unsigned char* data, quint32
len)
to
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
@ -27,7 +27,7 @@ be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s).
I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason.
unsigned long from quint32 for the same reason.
These changes should make no difference to any 32 bit implementations since
an
@ -94,7 +94,6 @@ void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]);
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
/* FIXME: can we do this in an endian-proof way? */
#ifdef WORDS_BIGENDIAN
#define blk0(i) block->l[i]
#else

View File

@ -36,7 +36,7 @@ FastFile_COD10_360::~FastFile_COD10_360() {
}
QByteArray FastFile_COD10_360::GetBinaryData() {
QByteArray FastFile_COD10_360::GetBinaryData() const {
return QByteArray();
}
@ -69,15 +69,9 @@ bool FastFile_COD10_360::Load(const QString aFilePath) {
bool FastFile_COD10_360::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
// Select key based on game.
QByteArray key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
@ -96,7 +90,7 @@ bool FastFile_COD10_360::Load(const QByteArray aData) {
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
decompressedData = Encryption::decryptFastFile_BO2(aData);
decompressedData = Encryption::DecryptFile(aData, fileName, "0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
// For COD9, write out the complete decompressed zone for testing.
QFile testFile("exports/" + GetBaseStem() + ".zone");
@ -104,12 +98,16 @@ bool FastFile_COD10_360::Load(const QByteArray aData) {
testFile.write(decompressedData);
testFile.close();
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD10_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD10_360>(zoneFile));
ZoneFile_COD10_360* zoneFile = new ZoneFile_COD10_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD10_360(const QString aFilePath);
~FastFile_COD10_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -38,7 +38,7 @@ FastFile_COD11_360::~FastFile_COD11_360() {
}
QByteArray FastFile_COD11_360::GetBinaryData() {
QByteArray FastFile_COD11_360::GetBinaryData() const {
return QByteArray();
}
@ -68,40 +68,84 @@ bool FastFile_COD11_360::Load(const QString aFilePath) {
return true;
}
enum DB_CompressorType : qint32
{
DB_COMPRESSOR_INVALID = 0x0,
DB_COMPRESSOR_ZLIB = 0x1,
DB_COMPRESSOR_LZX = 0x2,
DB_COMPRESSOR_PASSTHROUGH = 0x3,
};
bool FastFile_COD11_360::Load(const QByteArray aData) {
QByteArray decompressedData;
// Prepare data stream for parsing
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::BigEndian);
// Verify magic header
QByteArray fileMagic(8, Qt::Uninitialized);
fastFileStream.readRawData(fileMagic.data(), 8);
if (fileMagic != "TAff0000") {
qWarning() << "Invalid fast file magic for COD12!";
quint32 version = fastFileStream.ParseUInt32();
fastFileStream.skipRawData(1);
DB_CompressorType compressorType = (DB_CompressorType)fastFileStream.ParseInt8();
fastFileStream.skipRawData(10);
qint32 blockCount = fastFileStream.ParseInt32();
if (version != 1838)
{
qWarning() << "Invalid fast file version:" << version << "!";
return false;
}
// Skip: File size (4 bytes), flags/version (4 bytes), unknown (8 bytes), build tag (32 bytes), RSA signature (256 bytes)
fastFileStream.skipRawData(4 + 4 + 8 + 32 + 256); // total 304 bytes skipped so far + 8 bytes magic = 312 bytes at correct position.
if (blockCount > 17280)
{
qWarning() << "Fast file has too many blocks:" << blockCount << "> 17280!";
return false;
}
fastFileStream.skipRawData(12 * blockCount);
// Correctly positioned at 0x138
QByteArray encryptedData = aData.mid(0x138);
decompressedData = Encryption::decryptFastFile_BO3(encryptedData);
qint32 startPos = fastFileStream.ParseInt32();
Q_UNUSED(startPos);
// Output for verification/testing
qint32 endPos = fastFileStream.ParseInt32();
Q_UNUSED(endPos);
if (fileMagic == "S1ffu100")
{
QByteArray compressedData = aData.mid(fastFileStream.device()->pos());
if (compressorType == DB_COMPRESSOR_ZLIB)
{
decompressedData = Compression::DecompressZLIB(compressedData);
}
else if (compressorType == DB_COMPRESSOR_LZX)
{
decompressedData = Compression::DecompressXMem(compressedData, 0, 0x80000, 0);
}
}
else if (fileMagic == "S1ff0100")
{
}
else
{
qWarning() << "Invalid fast file magic:" << fileMagic << "!";
return false;
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Load the zone file with decompressed data
ZoneFile_COD11_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
if (!zoneFile.Load(decompressedData)) {
ZoneFile_COD11_360* zoneFile = new ZoneFile_COD11_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(std::make_shared<ZoneFile_COD11_360>(zoneFile));
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD11_360(const QString aFilePath);
~FastFile_COD11_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -38,7 +38,7 @@ FastFile_COD12_360::~FastFile_COD12_360() {
}
QByteArray FastFile_COD12_360::GetBinaryData() {
QByteArray FastFile_COD12_360::GetBinaryData() const {
return QByteArray();
}
@ -72,36 +72,80 @@ bool FastFile_COD12_360::Load(const QByteArray aData) {
QByteArray decompressedData;
// Prepare data stream for parsing
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Verify magic header
QByteArray fileMagic(8, Qt::Uninitialized);
fastFileStream.readRawData(fileMagic.data(), 8);
if (fileMagic != "TAff0000") {
qWarning() << "Invalid fast file magic for COD12!";
// Skip header magic
fastFileStream.skipRawData(8);
quint32 version;
fastFileStream >> version;
quint8 unknownFlag, compressionFlag, platformFlag, encryptionFlag;
fastFileStream >> unknownFlag >> compressionFlag >> platformFlag >> encryptionFlag;
if (compressionFlag != 1) {
qDebug() << "Invalid fastfile compression: " << compressionFlag;
return false;
} else if (platformFlag != 4) {
qDebug() << "Invalid platform: " << platformFlag;
return false;
} else if (encryptionFlag != 0) {
qDebug() << "Decryption not supported yet!";
return false;
}
// Skip: File size (4 bytes), flags/version (4 bytes), unknown (8 bytes), build tag (32 bytes), RSA signature (256 bytes)
fastFileStream.skipRawData(4 + 4 + 8 + 32 + 256); // total 304 bytes skipped so far + 8 bytes magic = 312 bytes at correct position.
fastFileStream.skipRawData(128);
// Correctly positioned at 0x138
QByteArray encryptedData = aData.mid(0x138);
decompressedData = Encryption::decryptFastFile_BO3(encryptedData);
quint64 size;
fastFileStream >> size;
fastFileStream.skipRawData(432);
int consumed = 0;
while(consumed < size)
{
// Read Block Header
quint32 compressedSize, decompressedSize, blockSize, blockPosition;
fastFileStream >> compressedSize >> decompressedSize >> blockSize >> blockPosition;
// Validate the block position, it should match
if(blockPosition != fastFileStream.device()->pos() - 16)
{
qDebug() << "Block Position does not match Stream Position.";
return false;
}
// Check for padding blocks
if(decompressedSize == 0)
{
fastFileStream.device()->read((((fastFileStream.device()->pos()) + ((0x800000) - 1)) & ~((0x800000) - 1)) - fastFileStream.device()->pos());
continue;
}
fastFileStream.device()->read(2);
QByteArray compressedData(compressedSize - 2, Qt::Uninitialized);
qDebug() << "Data position: " << fastFileStream.device()->pos() << " - Size: " << compressedSize;
fastFileStream.readRawData(compressedData.data(), compressedSize - 2);
decompressedData.append(Compression::DecompressDeflate(compressedData));
consumed += decompressedSize;
// Sinze Fast Files are aligns, we must skip the full block
fastFileStream.device()->seek(blockPosition + 16 + blockSize);
}
// Output for verification/testing
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Load the zone file with decompressed data
ZoneFile_COD12_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
if (!zoneFile.Load(decompressedData)) {
ZoneFile_COD12_360* zoneFile = new ZoneFile_COD12_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(std::make_shared<ZoneFile_COD12_360>(zoneFile));
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD12_360(const QString aFilePath);
~FastFile_COD12_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -38,7 +38,7 @@ FastFile_COD2_360::~FastFile_COD2_360() {
}
QByteArray FastFile_COD2_360::GetBinaryData() {
QByteArray FastFile_COD2_360::GetBinaryData() const {
return QByteArray();
}
@ -68,9 +68,9 @@ bool FastFile_COD2_360::Load(const QString aFilePath) {
}
bool FastFile_COD2_360::Load(const QByteArray aData) {
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
Utils::ReadUntilHex(&fastFileStream, "78");
QByteArray compressedData = aData.mid(fastFileStream.device()->pos());
@ -79,10 +79,13 @@ bool FastFile_COD2_360::Load(const QByteArray aData) {
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD2_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD2_360>(zoneFile));
ZoneFile_COD2_360* zoneFile = new ZoneFile_COD2_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD2_360(const QString aFilePath);
~FastFile_COD2_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD4_360::~FastFile_COD4_360() {
}
QByteArray FastFile_COD4_360::GetBinaryData() {
QByteArray FastFile_COD4_360::GetBinaryData() const {
return QByteArray();
}
@ -80,9 +80,9 @@ bool FastFile_COD4_360::Load(const QByteArray aData) {
// For COD5, simply decompress from offset 12.
decompressedData = Compression::DecompressZLIB(aData.mid(12));
} else if (header == "IWff0100") {
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData.mid(12));
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData.mid(12));
fastFileStream.setByteOrder(XDataStream::LittleEndian);
QByteArray magic(8, Qt::Uninitialized);
fastFileStream.readRawData(magic.data(), 8);
@ -126,14 +126,15 @@ bool FastFile_COD4_360::Load(const QByteArray aData) {
}
decompressedData = Compression::DecompressZLIB(compressedData);
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD4_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD4_360>(zoneFile));
ZoneFile_COD4_360* zoneFile = new ZoneFile_COD4_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD4_360(const QString aFilePath);
~FastFile_COD4_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD5_360::~FastFile_COD5_360() {
}
QByteArray FastFile_COD5_360::GetBinaryData() {
QByteArray FastFile_COD5_360::GetBinaryData() const {
return QByteArray();
}
@ -80,10 +80,13 @@ bool FastFile_COD5_360::Load(const QByteArray aData) {
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD5_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD5_360>(zoneFile));
ZoneFile_COD5_360* zoneFile = new ZoneFile_COD5_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD5_360(const QString aFilePath);
~FastFile_COD5_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD6_360::~FastFile_COD6_360() {
}
QByteArray FastFile_COD6_360::GetBinaryData() {
QByteArray FastFile_COD6_360::GetBinaryData() const {
return QByteArray();
}
@ -70,39 +70,55 @@ bool FastFile_COD6_360::Load(const QString aFilePath) {
}
bool FastFile_COD6_360::Load(const QByteArray aData) {
const qint64 zlibOffset = Compression::FindZlibOffset(aData);
if (zlibOffset == -1)
{
qWarning() << "Z-Lib stream not found";
return false;
}
QByteArray compressed = aData.mid(zlibOffset);
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::BigEndian);
// 2. Try plain decompression first ------------------------------
QByteArray decompressed = Compression::DecompressZLIB(compressed);
QByteArray magic(8, Qt::Uninitialized);
fastFileStream.readRawData(magic.data(), 8);
// 3. If that failed or looks too small, try stripping hash blocks
if (decompressed.isEmpty() || decompressed.size() < 1024)
{
QByteArray stripped = Compression::StripHashBlocks(compressed);
QByteArray retry = Compression::DecompressZLIB(stripped);
if (!retry.isEmpty())
decompressed.swap(retry);
}
quint32 version = fastFileStream.ParseUInt32();
if (decompressed.isEmpty())
if (version != 269)
{
qWarning() << "Unable to decompress fast-file";
qDebug() << QString("Invalid version: %1!").arg(version);
return false;
}
// Optional keep a copy on disk for quick inspection
Utils::ExportData(GetBaseStem() + ".zone", decompressed);
bool localPatch = fastFileStream.ParseBool();
Q_UNUSED(localPatch);
// 4. Forward to zone-file loader --------------------------------
auto zoneFile = std::make_shared<ZoneFile_COD6_360>();
zoneFile->SetStem(GetStem());
zoneFile->Load(decompressed);
quint8 compressor = fastFileStream.ParseUInt8();
Q_UNUSED(compressor);
// Skip fastfile date/time
fastFileStream.skipRawData(11);
quint32 hashCount = fastFileStream.ParseUInt32();
fastFileStream.skipRawData(12 * hashCount);
fastFileStream.skipRawData(8);
QByteArray decompressedData;
if (magic == "IWff0100")
{
}
else if (magic == "IWffu100")
{
quint32 zlibSize = aData.size() - fastFileStream.device()->pos();
QByteArray zlibData(zlibSize, Qt::Uninitialized);
fastFileStream.readRawData(zlibData.data(), zlibSize);
decompressedData = Compression::DecompressZLIB(zlibData);
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD6_360* zoneFile = new ZoneFile_COD6_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;

View File

@ -11,7 +11,7 @@ public:
FastFile_COD6_360(const QString aFilePath);
~FastFile_COD6_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -38,7 +38,7 @@ FastFile_COD7_360::~FastFile_COD7_360() {
}
QByteArray FastFile_COD7_360::GetBinaryData() {
QByteArray FastFile_COD7_360::GetBinaryData() const {
return QByteArray();
}
@ -71,19 +71,11 @@ bool FastFile_COD7_360::Load(const QString aFilePath) {
bool FastFile_COD7_360::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::BigEndian);
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD7_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
// Select key based on game.
QByteArray key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
fastFileStream.skipRawData(4);
fastFileStream.skipRawData(16);
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
@ -105,6 +97,8 @@ bool FastFile_COD7_360::Load(const QByteArray aData) {
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
QByteArray key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
// Now the stream should be positioned at 0x13C, where sections begin.
int sectionIndex = 0;
while (true) {
@ -142,10 +136,15 @@ bool FastFile_COD7_360::Load(const QByteArray aData) {
sectionIndex++;
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD7_360>(zoneFile));
ZoneFile_COD7_360* zoneFile = new ZoneFile_COD7_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD7_360(const QString aFilePath);
~FastFile_COD7_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -0,0 +1,148 @@
#include "fastfile_cod7_5_360.h"
#include "zonefile_cod7_360.h"
#include "compression.h"
#include "encryption.h"
#include <QFile>
#include <QDebug>
FastFile_COD7_5_360::FastFile_COD7_5_360()
: FastFile() {
SetCompany(COMPANY_INFINITY_WARD);
SetType(FILETYPE_FAST_FILE);
SetSignage(SIGNAGE_UNSIGNED);
SetMagic(0);
SetVersion(0);
SetPlatform("360");
SetGame("COD7.5");
}
FastFile_COD7_5_360::FastFile_COD7_5_360(const QByteArray& aData)
: FastFile_COD7_5_360() {
if (!aData.isEmpty()) {
Load(aData);
}
}
FastFile_COD7_5_360::FastFile_COD7_5_360(const QString aFilePath)
: FastFile_COD7_5_360() {
if (!aFilePath.isEmpty()) {
Load(aFilePath);
}
}
FastFile_COD7_5_360::~FastFile_COD7_5_360() {
}
QByteArray FastFile_COD7_5_360::GetBinaryData() const {
return QByteArray();
}
bool FastFile_COD7_5_360::Load(const QString aFilePath) {
if (aFilePath.isEmpty()) {
return false;
}
// Check fastfile can be read
QFile *file = new QFile(aFilePath);
if (!file->open(QIODevice::ReadOnly)) {
qDebug() << QString("Error: Failed to open FastFile: %1!").arg(aFilePath);
return false;
}
// Decompress fastfile and close
const QString fastFileStem = aFilePath.section("/", -1, -1);
SetStem(fastFileStem);
if (!Load(file->readAll())) {
qDebug() << "Error: Failed to load fastfile: " << fastFileStem;
return false;
}
file->close();
// Open zone file after decompressing ff and writing
return true;
}
enum NX_Language : qint32
{
LANGUAGE_ENGLISH = 0x0,
LANGUAGE_FRENCH = 0x1,
LANGUAGE_GERMAN = 0x2,
LANGUAGE_ITALIAN = 0x3,
LANGUAGE_SPANISH = 0x4,
LANGUAGE_BRITISH = 0x5,
LANGUAGE_RUSSIAN = 0x6,
LANGUAGE_POLISH = 0x7,
LANGUAGE_KOREAN = 0x8,
LANGUAGE_TAIWANESE = 0x9,
LANGUAGE_JAPANESE = 0xA,
LANGUAGE_CHINESE = 0xB,
LANGUAGE_THAI = 0xC,
LANGUAGE_LEET = 0xD,
LANGUAGE_CZECH = 0xE,
MAX_LANGUAGES = 0xF,
};
bool FastFile_COD7_5_360::Load(const QByteArray aData) {
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::BigEndian);
QByteArray magic(8, Qt::Uninitialized);
fastFileStream.readRawData(magic.data(), 8);
quint32 version = fastFileStream.ParseUInt32();
if (version != 357)
{
qDebug() << QString("Invalid version: %1!").arg(version);
return false;
}
bool localPatch = fastFileStream.ParseBool();
Q_UNUSED(localPatch);
quint8 compressor = fastFileStream.ParseUInt8();
Q_UNUSED(compressor);
// Skip fastfile date/time
fastFileStream.skipRawData(8);
NX_Language language = (NX_Language)fastFileStream.ParseInt32();
Q_UNUSED(language);
quint32 hashCount = fastFileStream.ParseUInt32();
fastFileStream.skipRawData(12 * hashCount);
fastFileStream.skipRawData(8);
QByteArray decompressedData;
if (magic == "NXff0100")
{
}
else if (magic == "NXffu100")
{
quint32 zlibSize = aData.size() - fastFileStream.device()->pos();
QByteArray zlibData(zlibSize, Qt::Uninitialized);
fastFileStream.readRawData(zlibData.data(), zlibSize);
decompressedData = Compression::DecompressZLIB(zlibData);
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD7_360* zoneFile = new ZoneFile_COD7_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -0,0 +1,20 @@
#ifndef FASTFILE_COD7_5_360_H
#define FASTFILE_COD7_5_360_H
#include "fastfile.h"
class FastFile_COD7_5_360 : public FastFile
{
public:
FastFile_COD7_5_360();
FastFile_COD7_5_360(const QByteArray& aData);
FastFile_COD7_5_360(const QString aFilePath);
~FastFile_COD7_5_360();
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;
};
#endif // FASTFILE_COD7_5_360_H

View File

@ -36,7 +36,7 @@ FastFile_COD8_360::~FastFile_COD8_360() {
}
QByteArray FastFile_COD8_360::GetBinaryData() {
QByteArray FastFile_COD8_360::GetBinaryData() const {
return QByteArray();
}
@ -69,15 +69,12 @@ bool FastFile_COD8_360::Load(const QString aFilePath) {
bool FastFile_COD8_360::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
// Select key based on game.
QByteArray key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
fastFileStream.setByteOrder(XDataStream::BigEndian);
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
@ -92,11 +89,7 @@ bool FastFile_COD8_360::Load(const QByteArray aData) {
QByteArray fileName(32, Qt::Uninitialized);
fastFileStream.readRawData(fileName.data(), 32);
// Skip the RSA signature (256 bytes).
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
decompressedData = Encryption::decryptFastFile_BO2(aData);
decompressedData = Encryption::DecryptFile(aData, fileName, "0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
// For COD9, write out the complete decompressed zone for testing.
QFile testFile("exports/" + GetBaseStem() + ".zone");
@ -106,10 +99,13 @@ bool FastFile_COD8_360::Load(const QByteArray aData) {
}
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD8_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD8_360>(zoneFile));
ZoneFile_COD8_360* zoneFile = new ZoneFile_COD8_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD8_360(const QString aFilePath);
~FastFile_COD8_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -36,7 +36,7 @@ FastFile_COD9_360::~FastFile_COD9_360() {
}
QByteArray FastFile_COD9_360::GetBinaryData() {
QByteArray FastFile_COD9_360::GetBinaryData() const {
return QByteArray();
}
@ -69,15 +69,12 @@ bool FastFile_COD9_360::Load(const QString aFilePath) {
bool FastFile_COD9_360::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
// Select key based on game.
QByteArray key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
fastFileStream.setByteOrder(XDataStream::BigEndian);
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
@ -96,7 +93,7 @@ bool FastFile_COD9_360::Load(const QByteArray aData) {
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
decompressedData = Encryption::decryptFastFile_BO2(aData);
decompressedData = Encryption::DecryptFile(aData, fileName, "0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
// For COD9, write out the complete decompressed zone for testing.
QFile testFile("exports/" + GetBaseStem() + ".zone");
@ -106,10 +103,13 @@ bool FastFile_COD9_360::Load(const QByteArray aData) {
}
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD9_360 zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD9_360>(zoneFile));
ZoneFile_COD9_360* zoneFile = new ZoneFile_COD9_360();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD9_360(const QString aFilePath);
~FastFile_COD9_360();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -36,7 +36,7 @@ FastFile_COD10_PC::~FastFile_COD10_PC() {
}
QByteArray FastFile_COD10_PC::GetBinaryData() {
QByteArray FastFile_COD10_PC::GetBinaryData() const {
return QByteArray();
}
@ -69,9 +69,9 @@ bool FastFile_COD10_PC::Load(const QString aFilePath) {
bool FastFile_COD10_PC::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Parse header values.
SetCompany(pParseFFCompany(&fastFileStream));
@ -84,18 +84,13 @@ bool FastFile_COD10_PC::Load(const QByteArray aData) {
SetGame("COD9");
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
fastFileStream.setByteOrder(XDataStream::BigEndian);
if (GetPlatform() == "PC") {
fastFileStream.setByteOrder(QDataStream::LittleEndian);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
}
// Select key based on game.
QByteArray key;
if (GetPlatform() == "360") {
key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
} else if (GetPlatform() == "PC") {
key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
}
QByteArray key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
@ -114,11 +109,7 @@ bool FastFile_COD10_PC::Load(const QByteArray aData) {
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
if (GetPlatform() == "360") {
//decompressedData = Compressor::cod9_decryptFastFile(aData);
} else if (GetPlatform() == "PC") {
decompressedData = Encryption::decryptFastFile_BO2(aData);
}
//decompressedData = Encryption::decryptFastFile_BO2(aData);
// For COD9, write out the complete decompressed zone for testing.
QFile testFile("exports/" + GetBaseStem() + ".zone");
@ -126,12 +117,16 @@ bool FastFile_COD10_PC::Load(const QByteArray aData) {
testFile.write(decompressedData);
testFile.close();
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD10_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD10_PC>(zoneFile));
ZoneFile_COD10_PC* zoneFile = new ZoneFile_COD10_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD10_PC(const QString aFilePath);
~FastFile_COD10_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -36,7 +36,7 @@ FastFile_COD11_PC::~FastFile_COD11_PC() {
}
QByteArray FastFile_COD11_PC::GetBinaryData() {
QByteArray FastFile_COD11_PC::GetBinaryData() const {
return QByteArray();
}
@ -69,9 +69,9 @@ bool FastFile_COD11_PC::Load(const QString aFilePath) {
bool FastFile_COD11_PC::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Parse header values.
SetCompany(pParseFFCompany(&fastFileStream));
@ -80,22 +80,11 @@ bool FastFile_COD11_PC::Load(const QByteArray aData) {
SetMagic(pParseFFMagic(&fastFileStream));
quint32 version = pParseFFVersion(&fastFileStream);
SetVersion(version);
SetPlatform(pCalculateFFPlatform(version));
SetGame("COD9");
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
if (GetPlatform() == "PC") {
fastFileStream.setByteOrder(QDataStream::LittleEndian);
}
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Select key based on game.
QByteArray key;
if (GetPlatform() == "360") {
key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
} else if (GetPlatform() == "PC") {
key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
}
QByteArray key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
@ -114,11 +103,7 @@ bool FastFile_COD11_PC::Load(const QByteArray aData) {
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
if (GetPlatform() == "360") {
//decompressedData = Compressor::cod9_decryptFastFile(aData);
} else if (GetPlatform() == "PC") {
decompressedData = Encryption::decryptFastFile_BO2(aData);
}
//decompressedData = Encryption::decryptFastFile_BO2(aData);
// For COD9, write out the complete decompressed zone for testing.
QFile testFile("exports/" + GetBaseStem() + ".zone");
@ -126,12 +111,16 @@ bool FastFile_COD11_PC::Load(const QByteArray aData) {
testFile.write(decompressedData);
testFile.close();
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD11_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD11_PC>(zoneFile));
ZoneFile_COD11_PC* zoneFile = new ZoneFile_COD11_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD11_PC(const QString aFilePath);
~FastFile_COD11_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD12_PC::~FastFile_COD12_PC() {
}
QByteArray FastFile_COD12_PC::GetBinaryData() {
QByteArray FastFile_COD12_PC::GetBinaryData() const {
return QByteArray();
}
@ -72,13 +72,9 @@ bool FastFile_COD12_PC::Load(const QString aFilePath) {
bool FastFile_COD12_PC::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD12_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Skip header magic
fastFileStream.skipRawData(8);
@ -140,12 +136,16 @@ bool FastFile_COD12_PC::Load(const QByteArray aData) {
// Sinze Fast Files are aligns, we must skip the full block
fastFileStream.device()->seek(blockPosition + 16 + blockSize);
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD12_PC>(zoneFile));
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD12_PC* zoneFile = new ZoneFile_COD12_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD12_PC(const QString aFilePath);
~FastFile_COD12_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD4_PC::~FastFile_COD4_PC() {
}
QByteArray FastFile_COD4_PC::GetBinaryData() {
QByteArray FastFile_COD4_PC::GetBinaryData() const {
return QByteArray();
}
@ -75,19 +75,22 @@ bool FastFile_COD4_PC::Load(const QByteArray aData) {
StatusBarManager::instance().updateStatus("Loading COD5 Fast File w/data", 1000);
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// For COD5, simply decompress from offset 12.
decompressedData = Compression::DecompressZLIB(aData.mid(12));
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD4_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD4_PC>(zoneFile));
ZoneFile_COD4_PC* zoneFile = new ZoneFile_COD4_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD4_PC(const QString aFilePath);
~FastFile_COD4_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD5_PC::~FastFile_COD5_PC() {
}
QByteArray FastFile_COD5_PC::GetBinaryData() {
QByteArray FastFile_COD5_PC::GetBinaryData() const {
return QByteArray();
}
@ -75,19 +75,22 @@ bool FastFile_COD5_PC::Load(const QByteArray aData) {
StatusBarManager::instance().updateStatus("Loading COD5 Fast File w/data", 1000);
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// For COD5, simply decompress from offset 12.
decompressedData = Compression::DecompressZLIB(aData.mid(12));
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD5_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD5_PC>(zoneFile));
ZoneFile_COD5_PC* zoneFile = new ZoneFile_COD5_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD5_PC(const QString aFilePath);
~FastFile_COD5_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD6_PC::~FastFile_COD6_PC() {
}
QByteArray FastFile_COD6_PC::GetBinaryData() {
QByteArray FastFile_COD6_PC::GetBinaryData() const {
return QByteArray();
}
@ -72,19 +72,40 @@ bool FastFile_COD6_PC::Load(const QString aFilePath) {
}
bool FastFile_COD6_PC::Load(const QByteArray aData) {
StatusBarManager::instance().updateStatus("Loading COD5 Fast File w/data", 1000);
QByteArray decompressedData;
const qint64 zlibOffset = Compression::FindZlibOffset(aData);
qDebug() << "ZLib Offset: " << zlibOffset;
if (zlibOffset == -1)
{
qWarning() << "Z-Lib stream not found";
return false;
}
QByteArray compressed = aData.mid(zlibOffset);
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
const QByteArray compressedData = aData.mid(21);
decompressedData = Compression::DecompressZLIB(compressedData);
QByteArray decompressedData = Compression::DecompressZLIB(compressed);
if (decompressedData.isEmpty() || decompressedData.size() < 1024)
{
QByteArray stripped = Compression::StripHashBlocks(compressed);
QByteArray retry = Compression::DecompressZLIB(stripped);
if (!retry.isEmpty())
decompressedData.swap(retry);
}
if (decompressedData.isEmpty())
{
qWarning() << "Unable to decompress fast-file";
return false;
}
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
ZoneFile_COD6_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD6_PC>(zoneFile));
ZoneFile_COD6_PC* zoneFile = new ZoneFile_COD6_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD6_PC(const QString aFilePath);
~FastFile_COD6_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD7_PC::~FastFile_COD7_PC() {
}
QByteArray FastFile_COD7_PC::GetBinaryData() {
QByteArray FastFile_COD7_PC::GetBinaryData() const {
return QByteArray();
}
@ -72,9 +72,9 @@ bool FastFile_COD7_PC::Load(const QString aFilePath) {
bool FastFile_COD7_PC::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Parse header values.
SetCompany(pParseFFCompany(&fastFileStream));
@ -83,88 +83,22 @@ bool FastFile_COD7_PC::Load(const QByteArray aData) {
SetMagic(pParseFFMagic(&fastFileStream));
quint32 version = pParseFFVersion(&fastFileStream);
SetVersion(version);
SetPlatform(pCalculateFFPlatform(version));
SetPlatform("360");
SetGame("COD7");
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD7_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
const QByteArray compressedData = aData.mid(12);
decompressedData = Compression::DecompressZLIB(compressedData);
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::LittleEndian);
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// Select key based on game.
QByteArray key;
fastFileStream.skipRawData(4);
if (GetPlatform() == "360") {
key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
} else if (GetPlatform() == "PS3") {
key = QByteArray::fromHex("46D3F997F29C9ACE175B0DAE3AB8C0C1B8E423E2E3BF7E3C311EA35245BF193A");
// or
// key = QByteArray::fromHex("0C99B3DDB8D6D0845D1147E470F28A8BF2AE69A8A9F534767B54E9180FF55370");
}
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
fastFileStream.readRawData(fileMagic.data(), 8);
if (fileMagic != "PHEEBs71") {
qWarning() << "Invalid fast file magic!";
ZoneFile_COD7_PC* zoneFile = new ZoneFile_COD7_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
fastFileStream.skipRawData(4);
// Read IV table name (32 bytes).
QByteArray fileName(32, Qt::Uninitialized);
fastFileStream.readRawData(fileName.data(), 32);
// Build the IV table from the fileName.
QByteArray ivTable = Encryption::InitIVTable(fileName);
// Skip the RSA signature (256 bytes).
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
// Now the stream should be positioned at 0x13C, where sections begin.
int sectionIndex = 0;
while (true) {
qint32 sectionSize = 0;
fastFileStream >> sectionSize;
qDebug() << "Section index:" << sectionIndex << "Size:" << sectionSize
<< "Pos:" << fastFileStream.device()->pos();
if (sectionSize == 0)
break;
// Read the section data.
QByteArray sectionData;
sectionData.resize(sectionSize);
fastFileStream.readRawData(sectionData.data(), sectionSize);
// Compute the IV for this section.
QByteArray iv = Encryption::GetIV(ivTable, sectionIndex);
// Decrypt the section using Salsa20.
QByteArray decData = Encryption::salsa20DecryptSection(sectionData, key, iv);
// Compute SHA1 hash of the decrypted data.
QByteArray sectionHash = QCryptographicHash::hash(decData, QCryptographicHash::Sha1);
// Update the IV table based on the section hash.
Encryption::UpdateIVTable(ivTable, sectionIndex, sectionHash);
// Build a compressed data buffer by prepending the two-byte zlib header.
QByteArray compressedData;
compressedData.append(char(0x78));
compressedData.append(char(0x01));
compressedData.append(decData);
decompressedData.append(Compression::DecompressZLIB(compressedData));
sectionIndex++;
}
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD7_PC>(zoneFile));
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD7_PC(const QString aFilePath);
~FastFile_COD7_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -39,7 +39,7 @@ FastFile_COD8_PC::~FastFile_COD8_PC() {
}
QByteArray FastFile_COD8_PC::GetBinaryData() {
QByteArray FastFile_COD8_PC::GetBinaryData() const {
return QByteArray();
}
@ -72,99 +72,27 @@ bool FastFile_COD8_PC::Load(const QString aFilePath) {
bool FastFile_COD8_PC::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Parse header values.
SetCompany(pParseFFCompany(&fastFileStream));
SetType(pParseFFFileType(&fastFileStream));
SetSignage(pParseFFSignage(&fastFileStream));
SetMagic(pParseFFMagic(&fastFileStream));
quint32 version = pParseFFVersion(&fastFileStream);
SetVersion(version);
SetPlatform(pCalculateFFPlatform(version));
SetGame("COD7");
SetVersion(pParseFFVersion(&fastFileStream));
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD8_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
decompressedData = Compression::DecompressZLIB(aData.mid(21));
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Select key based on game.
QByteArray key;
fastFileStream.skipRawData(4);
if (GetPlatform() == "360") {
key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
} else if (GetPlatform() == "PS3") {
key = QByteArray::fromHex("46D3F997F29C9ACE175B0DAE3AB8C0C1B8E423E2E3BF7E3C311EA35245BF193A");
// or
// key = QByteArray::fromHex("0C99B3DDB8D6D0845D1147E470F28A8BF2AE69A8A9F534767B54E9180FF55370");
}
// Read the 8-byte magic.
QByteArray fileMagic(8, Qt::Uninitialized);
fastFileStream.readRawData(fileMagic.data(), 8);
if (fileMagic != "PHEEBs71") {
qWarning() << "Invalid fast file magic!";
ZoneFile_COD8_PC* zoneFile = new ZoneFile_COD8_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(decompressedData)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
fastFileStream.skipRawData(4);
// Read IV table name (32 bytes).
QByteArray fileName(32, Qt::Uninitialized);
fastFileStream.readRawData(fileName.data(), 32);
// Build the IV table from the fileName.
QByteArray ivTable = Encryption::InitIVTable(fileName);
// Skip the RSA signature (256 bytes).
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
// Now the stream should be positioned at 0x13C, where sections begin.
int sectionIndex = 0;
while (true) {
qint32 sectionSize = 0;
fastFileStream >> sectionSize;
qDebug() << "Section index:" << sectionIndex << "Size:" << sectionSize
<< "Pos:" << fastFileStream.device()->pos();
if (sectionSize == 0)
break;
// Read the section data.
QByteArray sectionData;
sectionData.resize(sectionSize);
fastFileStream.readRawData(sectionData.data(), sectionSize);
// Compute the IV for this section.
QByteArray iv = Encryption::GetIV(ivTable, sectionIndex);
// Decrypt the section using Salsa20.
QByteArray decData = Encryption::salsa20DecryptSection(sectionData, key, iv);
// Compute SHA1 hash of the decrypted data.
QByteArray sectionHash = QCryptographicHash::hash(decData, QCryptographicHash::Sha1);
// Update the IV table based on the section hash.
Encryption::UpdateIVTable(ivTable, sectionIndex, sectionHash);
// Build a compressed data buffer by prepending the two-byte zlib header.
QByteArray compressedData;
compressedData.append(char(0x78));
compressedData.append(char(0x01));
compressedData.append(decData);
decompressedData.append(Compression::DecompressZLIB(compressedData));
sectionIndex++;
}
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD8_PC>(zoneFile));
SetZoneFile(zoneFile);
return true;
}

View File

@ -11,7 +11,7 @@ public:
FastFile_COD8_PC(const QString aFilePath);
~FastFile_COD8_PC();
QByteArray GetBinaryData() override;
QByteArray GetBinaryData() const override;
bool Load(const QString aFilePath) override;
bool Load(const QByteArray aData) override;

View File

@ -36,7 +36,7 @@ FastFile_COD9_PC::~FastFile_COD9_PC() {
}
QByteArray FastFile_COD9_PC::GetBinaryData() {
QByteArray FastFile_COD9_PC::GetBinaryData() const {
return QByteArray();
}
@ -67,37 +67,18 @@ bool FastFile_COD9_PC::Load(const QString aFilePath) {
}
bool FastFile_COD9_PC::Load(const QByteArray aData) {
QByteArray decompressedData;
// Create a QDataStream on the input data.
QDataStream fastFileStream(aData);
fastFileStream.setByteOrder(QDataStream::LittleEndian);
// Create a XDataStream on the input data.
XDataStream fastFileStream(aData);
fastFileStream.setByteOrder(XDataStream::LittleEndian);
// Parse header values.
SetCompany(pParseFFCompany(&fastFileStream));
SetType(pParseFFFileType(&fastFileStream));
SetSignage(pParseFFSignage(&fastFileStream));
SetMagic(pParseFFMagic(&fastFileStream));
quint32 version = pParseFFVersion(&fastFileStream);
SetVersion(version);
SetPlatform(pCalculateFFPlatform(version));
SetGame("COD9");
SetVersion(pParseFFVersion(&fastFileStream));
// For COD7/COD9, use BigEndian.
fastFileStream.setByteOrder(QDataStream::BigEndian);
if (GetPlatform() == "PC") {
fastFileStream.setByteOrder(QDataStream::LittleEndian);
}
// Select key based on game.
QByteArray key;
if (GetPlatform() == "360") {
key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
} else if (GetPlatform() == "PC") {
key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
}
// Read the 8-byte magic.
// Validate the fastfile magic.
QByteArray fileMagic(8, Qt::Uninitialized);
fastFileStream.readRawData(fileMagic.data(), 8);
if (fileMagic != "PHEEBs71") {
@ -106,32 +87,100 @@ bool FastFile_COD9_PC::Load(const QByteArray aData) {
}
fastFileStream.skipRawData(4);
// Read IV table name (32 bytes).
QByteArray fileName(32, Qt::Uninitialized);
fastFileStream.readRawData(fileName.data(), 32);
// Read IV seed name (32 bytes).
QByteArray nameKey(32, Qt::Uninitialized);
fastFileStream.readRawData(nameKey.data(), 32);
// Skip the RSA signature (256 bytes).
QByteArray rsaSignature(256, Qt::Uninitialized);
fastFileStream.readRawData(rsaSignature.data(), 256);
// --- Salsa20 + IV setup ---
static QVector<quint32> ivCounter(4, 1);
QByteArray ivTable = Encryption::InitIVTable(nameKey);
ivCounter.fill(1); // reset global counters
if (GetPlatform() == "360") {
//decompressedData = Compressor::cod9_decryptFastFile(aData);
} else if (GetPlatform() == "PC") {
decompressedData = Encryption::decryptFastFile_BO2(aData);
// Skip RSA signature (0x100)
fastFileStream.skipRawData(0x100);
// Decrypt + decompress loop
QByteArray finalZone;
int chunkIndex = 0;
while (!fastFileStream.atEnd()) {
quint32 dataLength = 0;
fastFileStream >> dataLength;
if (dataLength == 0)
break;
QByteArray encryptedBlock(dataLength, Qt::Uninitialized);
if (fastFileStream.readRawData(encryptedBlock.data(), dataLength) != dataLength) {
qWarning() << "Unexpected EOF while reading block";
break;
}
// For COD9, write out the complete decompressed zone for testing.
QFile testFile("exports/" + GetBaseStem() + ".zone");
if(testFile.open(QIODevice::WriteOnly)) {
testFile.write(decompressedData);
testFile.close();
// Derive IV for this chunk
QByteArray iv = Encryption::GetIV(ivTable, chunkIndex % 4);
// Salsa20 decryption
QByteArray decryptedBlock = Encryption::salsa20DecryptSection(
encryptedBlock,
QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE"),
iv,
64
);
// SHA1 hash of decrypted block
QCryptographicHash sha1(QCryptographicHash::Sha1);
sha1.addData(decryptedBlock);
QByteArray sha1Hash = sha1.result();
// Inflate into buffer
z_stream strm{};
strm.avail_in = static_cast<uInt>(decryptedBlock.size());
strm.next_in = reinterpret_cast<Bytef*>(decryptedBlock.data());
QByteArray decompressedData;
QByteArray buffer(0x10000, Qt::Uninitialized);
inflateInit2(&strm, -15);
int ret;
do {
strm.avail_out = buffer.size();
strm.next_out = reinterpret_cast<Bytef*>(buffer.data());
ret = inflate(&strm, Z_NO_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) {
qWarning() << "inflate failed with code" << ret;
break;
}
// Load the zone file with the decompressed data (using an Xbox platform flag).
ZoneFile_COD9_PC zoneFile;
zoneFile.SetStem(GetBaseStem() + ".zone");
zoneFile.Load(decompressedData);
SetZoneFile(std::make_shared<ZoneFile_COD9_PC>(zoneFile));
int have = buffer.size() - strm.avail_out;
if (have > 0)
decompressedData.append(buffer.constData(), have);
} while (ret != Z_STREAM_END);
inflateEnd(&strm);
finalZone.append(decompressedData);
// Update IV table for next block
Encryption::UpdateIVTable(ivTable, chunkIndex % 4, sha1Hash);
chunkIndex++;
}
// Export decompressed zone
Utils::ExportData(GetBaseStem() + ".zone", finalZone);
// Load zone file
ZoneFile_COD9_PC* zoneFile = new ZoneFile_COD9_PC();
zoneFile->SetStem(GetBaseStem() + ".zone");
if (!zoneFile->Load(finalZone)) {
qWarning() << "Failed to load ZoneFile!";
return false;
}
SetZoneFile(zoneFile);
return true;
return true;
}

Some files were not shown because too many files have changed in this diff Show More