From bf4e822b342bb6919c1851828296af721ea7aa2e Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sat, 6 May 2023 16:37:44 -0700 Subject: [PATCH] ImageMagick 6 fix (hopefully) and early support for HL_STEAM_INSTALL. However, due to a CRC mismatch in c1a0d.bsp it will fail to build a valid pak0.pak at this time. --- README | 6 +++++- build_pak0.sh | 16 ++++++++++++++++ dl_sources.sh | 7 ++++++- rip_sources.sh | 19 ++++++++++++++++--- start.sh | 24 ++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 5 deletions(-) mode change 100755 => 100644 rip_sources.sh diff --git a/README b/README index 8336903..0c8e4a0 100644 --- a/README +++ b/README @@ -38,7 +38,7 @@ Requirements: - working C compiler - GNU make (probably) - wget -- magick (as part of ImageMagick) +- magick/convert (as part of ImageMagick) Getting started: @@ -55,6 +55,10 @@ steaminstall_halflife.exe ...and place them alongside this README file. +If you want to use your local Steam Half-Life installation, +pass the HL_STEAM_INSTALL environment variable like so: +`HL_STEAM_INSTALL="/path/to/Half-Life" ./start` + The end result is placed into ./_build for you to copy wherever. diff --git a/build_pak0.sh b/build_pak0.sh index cc1191f..e9a666d 100755 --- a/build_pak0.sh +++ b/build_pak0.sh @@ -39,6 +39,22 @@ find_file () fi done + if [ ! -z "$HL_STEAM_INSTALL" ] + then + find "$HL_STEAM_INSTALL" -type f -name "${SEARCHNAME}" | while read FOUND + do + CHECK=$(sha256sum "${FOUND}" | cut -d ' ' -f 1) + #echo "$CHECK == $2" + + if [ "${CHECK}" = "$2" ] + then + mkdir -p "${PAK0_OUTDIR}/$(dirname $1)" + cp -v "${FOUND}" "${PAK0_OUTDIR}/$1" + exit 0 + fi + done + fi + if [ ! -f "${PAK0_OUTDIR}/$1" ] then echo "${1}" >> "./_build/missing-$3-pak0.txt" diff --git a/dl_sources.sh b/dl_sources.sh index 4ec0c94..cba0fda 100755 --- a/dl_sources.sh +++ b/dl_sources.sh @@ -30,4 +30,9 @@ fetch_resource "http://archive.org/download/Half-lifeUplink/hluplink.exe" "Half- fetch_resource "http://archive.org/download/half-life-patches/English/Update 1.1.1.0 English/hl1110.exe" "Half-Life: Patch 1.1.1.0" fetch_resource "https://archive.org/download/opfor-demo/opfordemofull.exe" "Half-Life: Opposing Force - Demo" fetch_resource "https://downloads.ammahls.com/HLSDK/hl_sdk_v23.exe" "Half-Life SDK v2.3" -fetch_resource "http://archive.org/download/steaminstall_halflife/steaminstall_halflife.exe" "Steam Installer with Half-Life Cache" \ No newline at end of file + +# if we pass a Steam path, skip this one +if [ -z "$HL_STEAM_INSTALL" ] +then + fetch_resource "http://archive.org/download/steaminstall_halflife/steaminstall_halflife.exe" "Steam Installer with Half-Life Cache" +fi \ No newline at end of file diff --git a/rip_sources.sh b/rip_sources.sh old mode 100755 new mode 100644 index cd79352..fb25cd3 --- a/rip_sources.sh +++ b/rip_sources.sh @@ -31,7 +31,11 @@ x_rewise "hluplink.exe" x_rewise "hl1110.exe" x_rewise "opfordemofull.exe" x_rewise "hl_sdk_v23.exe" -x_rewise "steaminstall_halflife.exe" + +if [ -z "$HL_STEAM_INSTALL" ] +then + x_rewise "steaminstall_halflife.exe" +fi mkdir -p "./_tmp/hluplink-pak0" pakextract -o "./_tmp/hluplink-pak0" "./_tmp/hluplink.exe/MAINDIR/valve/pak0.PAK" @@ -39,11 +43,20 @@ pakextract -o "./_tmp/hluplink-pak0" "./_tmp/hluplink.exe/MAINDIR/valve/pak0.PAK mkdir -p "./_tmp/opfordemofull-pak0" pakextract -o "./_tmp/opfordemofull-pak0" "./_tmp/opfordemofull.exe/MAINDIR/valve/pak0.PAK" -mkdir -p "./_tmp/half-life.gcf" -hlextract -p "./_tmp/steaminstall_halflife.exe/MAINDIR/SteamApps/half-life.gcf" -d "./_tmp/half-life.gcf" -e "root/valve/" +if [ -z "$HL_STEAM_INSTALL" ] +then + mkdir -p "./_tmp/half-life.gcf" + hlextract -p "./_tmp/steaminstall_halflife.exe/MAINDIR/SteamApps/half-life.gcf" -d "./_tmp/half-life.gcf" -e "root/valve/" +fi ./ccase.sh -r "./_tmp" # if anything goes wrong here, it's probably imagemagick messing with the image +if [ ! -x "$(command -v magick)" ]; then + convert "./_tmp/hluplink-pak0/gfx/shell/btns_main.bmp" -compress none -crop 156x4836+0+0 BMP3:"./_tmp/btns_main.bmp" +else + magick "./_tmp/hluplink-pak0/gfx/shell/btns_main.bmp" -compress none -crop 156x4836+0+0 BMP3:"./_tmp/btns_main.bmp" +fi + magick "./_tmp/hluplink-pak0/gfx/shell/btns_main.bmp" -compress none -crop 156x4836+0+0 BMP3:"./_tmp/btns_main.bmp" bmpfix "./_tmp/hl1110.exe/maindir/valve/models/player/hgrunt/hgrunt.bmp" \ No newline at end of file diff --git a/start.sh b/start.sh index e19a524..916c481 100755 --- a/start.sh +++ b/start.sh @@ -1,5 +1,29 @@ #!/bin/sh set -e + +# some sanity checks before we continue +if [ ! -x "$(command -v make)" ]; then + echo "make not found. Please install GNU make." + exit 2 +fi + +if [ ! -x "$(command -v cc)" ]; then + echo "cc not found. Please install a C compiler." + exit 2 +fi + +if [ ! -x "$(command -v wget)" ]; then + echo "wget not found. Please install wget." + exit 2 +fi + +if [ ! -x "$(command -v magick)" ]; then + if [ ! -x "$(command -v convert)" ]; then + echo "magick/convert not found. Please install ImageMagick or higher." + exit 2 + fi +fi + ./build_tools.sh ./dl_sources.sh ./rip_sources.sh