Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(tools): extract-game.sh lays out the games from a disc or iso
Andreas Bergerd5e5dd9ae808
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 95ea7880c..713c2d565 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,7 @@ found and fixed — EA's own, not port damage.**- The game runs on Apple silicon Macs and on Linux, the Steam Deck included, as a program built for that machine. There is no Wine or Proton underneath. It draws through Metal on a Mac and through Vulkan on Linux, from the same Zero Hour files you already own.- The first start finds your game. It looks in your Steam libraries, `~/Games`, `/Applications`, and CrossOver and Whisky bottles, and asks for the folder only when it comes up empty.- One command builds it. `./build-macos.sh` leaves a Mac app ready to open and `./build-linux.sh` a folder ready to start, and each checks your machine first and names the package to install for anything missing. On Linux it can make an AppImage, a .deb, an .rpm, an Arch package and a Flatpak, none of them carrying EA's files, and the Flatpak has played a full check match on a Steam Deck.+- No Windows needed to get the game's files onto a Mac or Linux either. `./extract-game.sh` takes a Zero Hour or Generals disc, an `.iso` of one, or a folder copied from a Windows install, and lays the two games out where the game finds them, Generals inside Zero Hour's folder. It asks before it writes to the default folder or over files already there, and says when a game is still missing.- One game on every machine. A replay recorded on a Mac plays back on Linux and on Windows to the same checksum, and the other way round, and a Mac and a Linux PC have played a LAN match together without once disagreeing. A Mac or Linux game could not join a Windows one: the check every machine runs before a network game failed, because the Mac and Linux copies of the game's data files ended each line differently from Windows'. They agree now. A match between Windows and a Mac has not been played yet.- Text on the Linux menus is as wide as on Windows. Linux has no Arial, and the font standing in for it reports a wider average letter, so every menu font the game sets to a fixed width came out a quarter narrower than it should, the "Generals" lettering and the menu buttons among them. Each is measured against Arial's own figure now, and lands within one percent of Windows.- The game no longer crashes on some Linux PCs as its window opens. The game hands out memory its own way, and on Linux the graphics driver gets its memory from the game too. Some drivers, AMD's on Debian 12 among them, need every piece lined up on a 16-byte boundary, and the game's lined up on 4, so the start died or went through depending on where the pieces happened to fall. On Linux everything outside the game's own pools now comes from the system, which lines it up as the driver expects.diff --git a/README.md b/README.mdindex 6651e8196..4adba1b45 100644--- a/README.md+++ b/README.md@@ -198,6 +198,12 @@ because Zero Hour mounts both. Saves and replays go toThe upscaled art has no download there. Copy the `Reforged*.big` files into `ReforgedArt/` in thatfolder by hand, or play at the original textures.+No install to point it at? `./extract-game.sh <iso|folder> [target]` lays the games out from a disc, an+`.iso` or a copy of a Windows install, without installing or Wine: Zero Hour into target, Generals into+`target/ZH_Generals`. The default target is `~/Games/Command & Conquer Generals Zero Hour`, after asking.+Run it once per disc. It needs `7z` or `bsdtar` for an `.iso`, and `unshield` for InstallShield discs.+Discs carry 1.00 and the engine is 1.04's, so files from a 1.04 install (Steam, the EA app) are safer.+<details><summary>Settings the options screen does not show</summary>diff --git a/extract-game.sh b/extract-game.shnew file mode 100755index 000000000..53c1c19d5--- /dev/null+++ b/extract-game.sh@@ -0,0 +1,144 @@+#!/usr/bin/env bash+# Additional terms under GNU GPL section 7 apply: see LICENSE.md.+#+# This program is free software: you can redistribute it and/or modify+# it under the terms of the GNU General Public License as published by+# the Free Software Foundation, either version 3 of the License, or+# (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program. If not, see <http://www.gnu.org/licenses/>.+#+# Lays out Zero Hour and Generals from an install medium or an existing install, without installing or Wine.+#+# ./extract-game.sh <source> [target]+#+# source an .iso, a mounted disc, or a folder holding an install (a copy of a Windows one)+# target the Zero Hour folder to fill; default ~/Games/Command & Conquer Generals Zero Hour, after asking+#+# Zero Hour's files go into target, Generals' into target/ZH_Generals, where the game looks (README.md,+# "Where it looks for Zero Hour"). Run it once per disc when the games are on separate media.+# InstallShield media (data1.hdr + data1.cab) need unshield; an .iso needs 7z or bsdtar.++set -euo pipefail++DEFAULT_TARGET="$HOME/Games/Command & Conquer Generals Zero Hour"++say() { echo "[extract] $*"; }+fail() { echo "[extract] ERROR: $*" >&2; exit 1; }+confirm() {+ local answer+ read -r -p "[extract] $1 [y/N] " answer || true+ [[ $answer == [yY] || $answer == [yY][eE][sS] ]]+}++usage() { echo "usage: $0 <iso|folder> [target] (default target: $DEFAULT_TARGET)" >&2; exit 2; }+[ $# -ge 1 ] && [ $# -le 2 ] || usage+source=$1+[ -e "$source" ] || fail "\"$source\" does not exist."++if [ $# -eq 2 ]; then+ target=$2+else+ target=$DEFAULT_TARGET+ confirm "Extract to \"$target\"?" || fail "cancelled; name a target as the second argument."+fi+mkdir -p "$target"+target=$(cd "$target" && pwd)++# Scratch space beside the target: a DVD's worth of files would not fit a RAM-backed /tmp.+work=$(mktemp -d "$(dirname "$target")/.extract-game.XXXXXX")+trap 'rm -rf "$work"' EXIT++# --- the medium's files ---+if [ -d "$source" ]; then+ tree=$(cd "$source" && pwd)+else+ say "unpacking $source"+ tree="$work/iso"+ mkdir -p "$tree"+ if command -v 7z >/dev/null 2>&1; then+ 7z x -y -bd -o"$tree" "$source" >/dev/null || fail "7z could not unpack \"$source\"."+ elif command -v bsdtar >/dev/null 2>&1; then+ bsdtar -xf "$source" -C "$tree" || fail "bsdtar could not unpack \"$source\"."+ else+ fail "unpacking an image needs 7z or bsdtar: sudo apt-get install 7zip (or p7zip-full), or mount it and pass the folder."+ fi+fi++# InstallShield keeps the files in cabinets, one folder per component group; merged, the groups give back+# the installed tree.+mapfile -t headers < <(find "$tree" -type f -iname 'data1.hdr')+if [ ${#headers[@]} -gt 0 ]; then+ command -v unshield >/dev/null 2>&1 || fail "this is an InstallShield medium; install unshield (sudo apt-get install unshield)."+ merged="$work/merged"+ mkdir -p "$merged"+ for header in "${headers[@]}"; do+ say "unpacking the InstallShield cabinets beside $header"+ groups="$work/groups"+ rm -rf "$groups"+ unshield -d "$groups" x "$header" >/dev/null || fail "unshield could not unpack \"$header\"."+ for group in "$groups"/*/; do+ cp -a "$group." "$merged/"+ done+ done+ tree=$merged+fi++# --- find each game by the archive it is known by ---+find_root() {+ local hit+ hit=$(find "$tree" -type f -iname "$1" -print -quit)+ [ -n "$hit" ] && dirname "$hit"+}+zero_hour=$(find_root 'INIZH.big' || true)+generals=$(find_root 'Textures.big' || true)+# an install whose Generals sits beside it, where the game itself would look+if [ -z "$generals" ] && [ -n "$zero_hour" ] && [ -d "$source" ]; then+ for beside in "$zero_hour/../Command & Conquer Generals" "$zero_hour/../Command & Conquer(tm) Generals"; do+ if [ -d "$beside" ] && [ -n "$(find "$beside" -maxdepth 1 -type f -iname 'Textures.big' -print -quit)" ]; then+ generals=$(cd "$beside" && pwd)+ break+ fi+ done+fi+# both in one folder: the game reads Generals from the Zero Hour folder itself, nothing to split+[ "$generals" != "$zero_hour" ] || generals=+[ -n "$zero_hour" ] || [ -n "$generals" ] \+ || fail "no INIZH.big (Zero Hour) or Textures.big (Generals) under \"$source\". Is it the install medium?"++copy_into() {+ local from=$1 to=$2+ mkdir -p "$to"+ if [ -n "$(ls -A "$to" 2>/dev/null | grep -v -x ZH_Generals || true)" ]; then+ confirm "\"$to\" already has files. Overwrite the ones the medium also has?" || fail "cancelled."+ fi+ say "copying $(basename "$from") -> $to"+ # the Zero Hour folder's own copy of Generals stays out of the Zero Hour copy+ find "$from" -mindepth 1 -maxdepth 1 ! -iname ZH_Generals -exec cp -a {} "$to/" \;+}++[ -z "$zero_hour" ] || copy_into "$zero_hour" "$target"+[ -z "$generals" ] || copy_into "$generals" "$target/ZH_Generals"++# --- what the game will find ---+has() { [ -n "$(find "$1" -maxdepth 1 -type f -iname "$2" -print -quit 2>/dev/null)" ]; }+missing=+has "$target" 'INIZH.big' || missing="$missing Zero Hour (INIZH.big)"+has "$target" 'Textures.big' || has "$target/ZH_Generals" 'Textures.big' || missing="$missing${missing:+,} Generals (Textures.big)"+if [ -n "$missing" ]; then+ say "done, but \"$target\" still lacks$missing: run this again with that game's medium and the same target."+ exit 0+fi+say "done: Zero Hour in \"$target\", Generals in ZH_Generals inside it."+say "a disc carries version 1.00; the engine is Zero Hour 1.04's, so a 1.04 install's files are the safer source."+if [ "$target" = "$DEFAULT_TARGET" ]; then+ say "the game finds this folder by itself."+else+ say "start the game with -root \"$target\", or choose this folder when it asks."+fi