Files
firestorm/MW4/set-appcompat.ps1
T
a0331e78d2 Compiled Build 5.1.0b_RC1 Files
Deployed game tree copied back from the Windows build machine, containing the
compiled 5.1.0b_RC1 binaries and every asset the deploy produces. 846 files:
21 added, 825 modified.

Freshly built binaries: MW4.exe, Launcher.exe, autoconfig.exe, ctcls.dll,
MissionLang.dll, ScriptStrings.dll, Language.dll and the rest of the runtime DLL
set, carrying everything merged this cycle -- the 16-pilots-plus-cameraship launch
fix, the MFD mode 4 split-display support and its stutter fix, -tmon, -tcoop, -fps,
-tbaud, the Load File console lobby feature, configurable Rookie Mission, and the
English Language.dll build.

New in the deployment:
- set-appcompat.bat / set-appcompat.ps1 -- the one-click AppCompat shim installer,
  now shipped by deploy-mw4.ps1 so any copy of an install can repair its own
  registration (the layer is keyed on the exe's full path).
- libmysql.dll -- required by mw4print 2.0's MySQL export, late-bound at runtime.
- Four hsh art files restored from 5.0.7D: MFD/assassin2.bmp, Mechs/battlemaster
  iic.bmp, Mechs/behemoth ii.bmp, Mechs/mad cat mkii.bmp.
- banner.txt, dbstruct.txt -- mw4print banner text and the exported DB structure
  reference.

dgVoodoo2 is included as MW4/dgvoodoo2_files/ -- deliberately in a subfolder and
NOT alongside the executable. Nothing loads from there, so the files are available
for a pod owner to install on Windows 10/11 without being active by default. This
keeps XP pods safe: they use native DirectDraw, and having dgVoodoo2 loose in the
game folder would break them. Do not move these files up a level in the repo.

Runtime leftovers from testing on the build machine are included as well
(DDrawCompat logs, DebugLog.txt, mw4-help.txt, two screenshots), consistent with
this repo's stated purpose as a full disaster-recovery mirror in which nothing is
excluded on purpose.

All binaries and art are stored via Git LFS per .gitattributes; verified that
MW4.exe, libmysql.dll, the dgVoodoo2 DLLs and the screenshots staged as LFS
pointers rather than raw blobs.

Co-authored-by: Claude Opus 5 (Anthropic) <noreply@anthropic.com>
Co-authored-by: GitHub Copilot <copilot@github.com>
2026-07-25 19:52:43 -05:00

176 lines
7.1 KiB
PowerShell
Executable File

<#
set-appcompat.ps1 - apply the DirectDraw compatibility shim to the MW4 executables
sitting NEXT TO this script, wherever that copy of the game happens to live.
WHY THIS EXISTS
MW4 renders at bitdepth=16. Modern GPUs report ZERO 16-bit display modes, so the
exclusive-fullscreen path cannot set a mode and fails. The DWM8And16BitMitigation
AppCompat layer is what makes 8/16-bit fullscreen work under the desktop compositor.
Without it GameOS reports:
"Another application is preventing use of full screen mode."
That message is a catch-all raised after every SetDisplayMode attempt has failed --
it even scans for NetMeeting -- so it sends you hunting for a conflicting program
that does not exist. The real cause is the missing shim.
The layer is keyed on the executable's FULL PATH. Every install needs its own entry,
and copying or moving an install silently loses it. Hence this script: run it from
inside any deployment and it fixes that deployment.
USAGE
Double-click set-appcompat.bat (recommended - one click, no execution-policy fuss)
or: .\set-appcompat.ps1 apply the shim
.\set-appcompat.ps1 -Remove remove the entries this script adds
.\set-appcompat.ps1 -WhatIfOnly report current state, change nothing
Run as Administrator to also write the all-users (HKLM) entry. Without elevation the
per-user (HKCU) entry is written, which is enough for the account that runs the game.
#>
param(
[string]$Layer = "DWM8And16BitMitigation HIGHDPIAWARE",
[switch]$Remove,
[switch]$WhatIfOnly
)
$ErrorActionPreference = "Stop"
# --- Locate ourselves -------------------------------------------------------------
# $PSScriptRoot is empty on very old hosts and when dot-sourced, so fall back.
$here = $PSScriptRoot
if ([string]::IsNullOrEmpty($here)) {
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
}
$hkcuLayers = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
$hklmLayers = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
$isAdmin = ([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
Write-Host ""
Write-Host "MW4 DirectDraw compatibility shim" -ForegroundColor Cyan
Write-Host "---------------------------------" -ForegroundColor Cyan
Write-Host " folder : $here"
Write-Host " elevated : $(if ($isAdmin) { 'yes (HKCU + HKLM)' } else { 'no (HKCU only)' })"
Write-Host ""
# --- Find the executables that need it --------------------------------------------
# Only the game/editor executables drive DirectDraw. Launcher/autoconfig/mw4print do not.
$wanted = @("MW4.exe", "MW4pro.exe", "MW4Ed2.exe")
$targets = @()
foreach ($name in $wanted) {
$p = Join-Path $here $name
if (Test-Path -LiteralPath $p) { $targets += $p }
}
if ($targets.Count -eq 0) {
Write-Host "No MW4 executables found next to this script." -ForegroundColor Red
Write-Host "Expected one of: $($wanted -join ', ')"
Write-Host "Put this script in the same folder as MW4.exe and run it again."
exit 1
}
# --- Helpers ----------------------------------------------------------------------
function Get-Layer([string]$root, [string]$exe) {
if (-not (Test-Path -LiteralPath $root)) { return $null }
$item = Get-ItemProperty -LiteralPath $root -ErrorAction SilentlyContinue
if ($null -eq $item) { return $null }
$prop = $item.PSObject.Properties | Where-Object { $_.Name -eq $exe }
if ($null -eq $prop) { return $null }
return $prop.Value
}
function Set-Layer([string]$root, [string]$exe, [string]$value) {
if (-not (Test-Path -LiteralPath $root)) { New-Item -Path $root -Force | Out-Null }
Set-ItemProperty -LiteralPath $root -Name $exe -Value $value -Type String
}
$failed = 0
foreach ($exe in $targets) {
Write-Host $exe -ForegroundColor White
$before = Get-Layer $hkcuLayers $exe
if ($null -ne $before) {
Write-Host " existing HKCU : $before" -ForegroundColor DarkGray
# The historical failure mode: a HIGHDPIAWARE-only entry, which suppresses the
# automatic shim and produces exactly the fullscreen failure this script fixes.
if (-not $Remove -and $before -notmatch "DWM8And16BitMitigation") {
Write-Host " NOTE: entry exists but has no DWM8And16BitMitigation -" -ForegroundColor Yellow
Write-Host " this specific state BLOCKS fullscreen. Replacing it." -ForegroundColor Yellow
}
}
if ($WhatIfOnly) {
$lm = Get-Layer $hklmLayers $exe
Write-Host " existing HKLM : $(if ($null -ne $lm) { $lm } else { '(none)' })" -ForegroundColor DarkGray
Write-Host ""
continue
}
if ($Remove) {
Remove-ItemProperty -LiteralPath $hkcuLayers -Name $exe -ErrorAction SilentlyContinue
if ($isAdmin) {
Remove-ItemProperty -LiteralPath $hklmLayers -Name $exe -ErrorAction SilentlyContinue
}
Write-Host " removed" -ForegroundColor Yellow
Write-Host ""
continue
}
# Per-user. No admin needed, and applies to the account that actually runs the game.
Set-Layer $hkcuLayers $exe $Layer
# All-users, if we can. Note the different value format: the HKLM entries use a
# leading "$ " marker. Do not copy one format into the other key.
if ($isAdmin) {
Set-Layer $hklmLayers $exe ("$ " + ($Layer -replace '\s*HIGHDPIAWARE\s*', ''))
}
# Verify by reading back rather than trusting the write.
$after = Get-Layer $hkcuLayers $exe
if ($after -eq $Layer) {
Write-Host " HKCU set : $after" -ForegroundColor Green
} else {
Write-Host " HKCU FAILED : got '$after'" -ForegroundColor Red
$failed++
}
if ($isAdmin) {
$afterM = Get-Layer $hklmLayers $exe
if ($null -ne $afterM) {
Write-Host " HKLM set : $afterM" -ForegroundColor Green
} else {
Write-Host " HKLM FAILED" -ForegroundColor Red
$failed++
}
}
Write-Host ""
}
if ($WhatIfOnly) {
Write-Host "Report only - nothing was changed." -ForegroundColor Cyan
exit 0
}
if ($failed -gt 0) {
Write-Host "$failed registry write(s) failed." -ForegroundColor Red
exit 1
}
if ($Remove) {
Write-Host "Shim removed. Fullscreen will fail on modern GPUs until it is re-applied." -ForegroundColor Yellow
} else {
Write-Host "Done. The shim is read when the process starts -" -ForegroundColor Green
Write-Host "restart MW4 to pick it up. No reboot needed." -ForegroundColor Green
if (-not $isAdmin) {
Write-Host ""
Write-Host "Applied for the current user only. To cover all accounts on this" -ForegroundColor DarkGray
Write-Host "machine, run this script again as Administrator." -ForegroundColor DarkGray
}
}
exit 0