Cross-Platform Scripts: - extract_z_asset.sh: Linux/Unix single file extraction - batch_extract_z_assets.sh: Linux/Unix batch extraction - pack_z_asset.sh: Linux/Unix asset packing - extract_z_asset.ps1: Windows PowerShell extraction Server Integration: - AssetExtractionService.cs: C# service for ZLIB extraction/packing - AssetManagementController.cs: API endpoints for asset management - POST /api/AssetManagement/extract - POST /api/AssetManagement/pack - POST /api/AssetManagement/batch-extract - GET /api/AssetManagement/list - Registered AssetExtractionService in Program.cs Features: - Extracts .z files (ZLIB compressed textures/data) - Packs files to .z format with ZLIB compression - Batch processing support - Cross-platform (Windows/Linux/macOS) - Server-side API for remote asset management - Path traversal protection Documentation: - ASSET_EXTRACTION_GUIDE.md: Complete integration guide - Tools/README.md: CLI tool documentation Based on: Tankonline/Real-Racing-3-Texture-Extraction-Tool Converted to cross-platform bash/PowerShell scripts + C# service Ready for .pak asset extraction when files arrive from community Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
80 lines
1.9 KiB
Bash
80 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
# RR3 Asset Packer - Cross-Platform
|
|
# Compresses files with ZLIB to create .z format
|
|
|
|
set -euo pipefail
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
CYAN='\033[0;36m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${YELLOW} RR3 Asset Packer - Linux/Unix${NC}"
|
|
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
# Check Python 3
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo -e "${RED}ERROR: Python 3 is not installed!${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Check arguments
|
|
if [ "$#" -lt 1 ]; then
|
|
echo "Usage: $0 <input_file>"
|
|
echo ""
|
|
echo "Example:"
|
|
echo " $0 sprites_0.etc.dds"
|
|
echo ""
|
|
echo "Output will be: input_file.z"
|
|
exit 1
|
|
fi
|
|
|
|
INPUT_FILE="$1"
|
|
|
|
if [ ! -f "$INPUT_FILE" ]; then
|
|
echo -e "${RED}ERROR: Input file not found: $INPUT_FILE${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
OUTPUT_FILE="${INPUT_FILE}.z"
|
|
|
|
echo -e "${GREEN}Input:${NC} $INPUT_FILE"
|
|
echo -e "${GREEN}Output:${NC} $OUTPUT_FILE"
|
|
echo ""
|
|
|
|
# Pack with Python
|
|
python3 - "$INPUT_FILE" "$OUTPUT_FILE" << 'PYTHON_SCRIPT'
|
|
import sys
|
|
import zlib
|
|
import os
|
|
|
|
input_file = sys.argv[1]
|
|
output_file = sys.argv[2]
|
|
|
|
print("Reading file...")
|
|
with open(input_file, "rb") as f:
|
|
data = f.read()
|
|
|
|
print(f"Input size: {len(data):,} bytes")
|
|
|
|
print("Compressing with ZLIB (level 9)...")
|
|
compressed = zlib.compress(data, level=9)
|
|
|
|
print(f"Compressed size: {len(compressed):,} bytes")
|
|
print(f"Compression ratio: {(1 - len(compressed) / len(data)) * 100:.1f}%")
|
|
|
|
print("Writing output...")
|
|
with open(output_file, "wb") as f:
|
|
f.write(compressed)
|
|
|
|
print("")
|
|
print("✅ Packing complete!")
|
|
PYTHON_SCRIPT
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Done!${NC}"
|