Merge pull request #1 from sindoring/launch-configuration

build: add VSCode launch configuration to automatically build MPQ and
This commit is contained in:
Ilyas
2026-03-18 10:20:04 +04:00
committed by GitHub
10 changed files with 1661 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
WOW_HOME=C:\Games\World of Warcraft 3.3.5
+1
View File
@@ -0,0 +1 @@
.env
+17
View File
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run WoW with MPQ",
"type": "node",
"request": "launch",
"runtimeExecutable": "powershell",
"args": [
"-ExecutionPolicy",
"Bypass",
"-File",
"${workspaceFolder}/run.ps1"
]
}
]
}
@@ -325,7 +325,7 @@
</Shadow>
<Color r="1.0" g="0.78" b="0"/>
</FontString>
<FontString name="AccountLoginSavePasswordText" inherits="GlueFontNormalSmall" text="REMEMBER_PASSWORDS">
<FontString name="AccountLoginSavePasswordText" inherits="GlueFontNormalSmall" text="REMEMBER_SHIT">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="AccountLoginSaveAccountNameText" relativePoint="BOTTOMLEFT">
<Offset x="0" y="-8"/>
+22
View File
@@ -0,0 +1,22 @@
@REM @ECHO OFF
@REM REM the next line deletes the cache
@REM CALL "Wow.exe" -console -login "admin" -password "123456"
@REM # Exit
@echo off
cd /d %WOW_HOME%
echo Clearing cache...
rm "Cache\WDB\ruRU\creaturecache.wdb"
rm "Cache\WDB\ruRU\gameobjectcache.wdb"
rm "Cache\WDB\ruRU\itemcache.wdb"
rm "Cache\WDB\ruRU\itemnamecache.wdb"
rm "Cache\WDB\ruRU\itemtextcache.wdb"
rm "Cache\WDB\ruRU\npccache.wdb"
rm "Cache\WDB\ruRU\pagetextcache.wdb"
rm "Cache\WDB\ruRU\questcache.wdb"
rm "Cache\WDB\ruRU\wowcache.wdb"
echo Launching WoW...
start Wow.exe
+68
View File
@@ -0,0 +1,68 @@
# Stop on errors
$ErrorActionPreference = "Stop"
# --- Resolve project root (folder where script is located)
$ROOT = Split-Path -Parent $MyInvocation.MyCommand.Path
# --- Load .env if WOW_HOME not already set
if (-not $env:WOW_HOME) {
$envFile = Join-Path $ROOT ".env"
if (Test-Path $envFile) {
Write-Host "Loading .env file..."
Get-Content $envFile | ForEach-Object {
if ($_ -match "^\s*([^#][^=]+)=(.+)$") {
$name = $matches[1].Trim()
$value = $matches[2].Trim()
[System.Environment]::SetEnvironmentVariable($name, $value)
Set-Item -Path "Env:$name" -Value $value
}
}
}
}
# --- Validate WOW_HOME
if (-not $env:WOW_HOME) {
Write-Error "WOW_HOME is not set (env or .env)"
exit 1
}
$WOW_HOME = $env:WOW_HOME
Write-Host "WOW_HOME = $WOW_HOME"
# --- Paths
$INPUT_DIR = Join-Path $ROOT "patch-ruRU-5"
$OUTPUT_MPQ = Join-Path $WOW_HOME "Data\ruRU\patch-ruRU-5.MPQ"
$TOOL = Join-Path $ROOT "tool\target\release\tool.exe"
$RELOAD_SCRIPT = Join-Path $ROOT "reload_wow.bat"
# --- Ensure tool exists
if (!(Test-Path $TOOL)) {
Write-Host "Building Rust tool..."
Push-Location (Join-Path $ROOT "tool")
cargo build --release
Pop-Location
}
# --- Ensure WoW directory exists
$wowDataDir = Join-Path $WOW_HOME "Data\ruRU"
if (!(Test-Path $wowDataDir)) {
New-Item -ItemType Directory -Force -Path $wowDataDir | Out-Null
}
# --- Build MPQ
Write-Host "Building MPQ..."
& $TOOL $INPUT_DIR $OUTPUT_MPQ
# --- Verify result
if (!(Test-Path $OUTPUT_MPQ)) {
Write-Error "MPQ build failed!"
exit 1
}
Write-Host "MPQ created at $OUTPUT_MPQ"
# --- Run WoW reload script
Write-Host "Launching WoW..."
cmd /c $RELOAD_SCRIPT
+1
View File
@@ -0,0 +1 @@
target/
+1470
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "tool"
version = "0.1.0"
edition = "2024"
[dependencies]
walkdir = "2.5.0"
wow-mpq = "0.6.4"
+72
View File
@@ -0,0 +1,72 @@
use std::env;
use std::error::Error;
use std::path::PathBuf;
use walkdir::WalkDir;
use wow_mpq::{ArchiveBuilder, FormatVersion, ListfileOption};
use wow_mpq::compression::flags;
fn main() -> Result<(), Box<dyn Error>> {
// Read arguments
let args: Vec<String> = env::args().collect();
if args.len() != 3 {
eprintln!("Usage: mpq-builder <input_dir> <output.mpq>");
std::process::exit(1);
}
let input_dir = PathBuf::from(&args[1]);
let output_file = &args[2];
if !input_dir.exists() {
return Err("Input directory does not exist".into());
}
// Normalize base path (IMPORTANT for Windows)
let base = input_dir.canonicalize()?;
println!("Input directory: {}", base.display());
println!("Output file: {}", output_file);
// Configure MPQ builder
let mut builder = ArchiveBuilder::new()
.version(FormatVersion::V2)
.block_size(7) // 64KB sectors
.default_compression(flags::ZLIB)
.listfile_option(ListfileOption::Generate);
// Walk directory
for entry in WalkDir::new(&base)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file())
{
// Canonicalize each file path (fixes StripPrefixError)
let full_path = entry.path().canonicalize()?;
// Safely compute relative path
let rel_path = match full_path.strip_prefix(&base) {
Ok(p) => p,
Err(_) => {
eprintln!("Skipping (prefix mismatch): {}", full_path.display());
continue;
}
};
// Convert to MPQ-style path (forward slashes!)
let archive_path = rel_path
.to_string_lossy()
.replace("\\", "/");
println!("Adding: {}", archive_path);
builder = builder.add_file(&full_path, &archive_path);
}
// Build archive
builder.build(output_file)?;
println!("✅ MPQ archive created: {}", output_file);
Ok(())
}