Last active
June 27, 2024 19:20
-
-
Save Vorschreibung/0e77b1cdbca6c38456ad29bfaa3fb7c6 to your computer and use it in GitHub Desktop.
Enemy Territory - Map Environment Setup Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# setup-et-mapenv.sh v0.7 (2024-06-27) (49f26e14d9e11555) | |
# | |
# Sets up a separate basepath/environment for Wolfenstein: Enemy Territory map | |
# editing below directory where script is placed. | |
# | |
# The mapenv aims to be able to successfully and fully rebuild all official | |
# maps. | |
# | |
# KNOWN ISSUES: | |
# [1] | |
# filesystem crossplatform case sensitivity discrepancies | |
# | |
# [2] | |
# 'skin' entries of models are not displayed correctly in Radiant, however | |
# they are still displayed correctly ingame | |
# | |
# REQUIRES: git unzip | |
set -eo pipefail | |
die() { | |
printf '%b\n' "$1" >&2 | |
exit "${2:-1}" | |
} | |
# === Input Basepaths === | |
ET="${ET:-/usr/share/enemy-territory/}" | |
if [[ ! -e "${ET}/etmain/pak0.pk3" ]]; then | |
die "> Invalid ET basepath: '${ET}', set 'ET' env var correctly." | |
fi | |
# === Setup Env === | |
# cd to parent dir of current script | |
cd "$(dirname "${BASH_SOURCE[0]}")" | |
# determine working paths | |
cached=$(realpath .)/cache | |
envd=$(realpath .)/basepath | |
envbased=${envd}/etmain | |
self_sha256sum=$(sha256sum "$0" | awk '{print $1}') | |
# remove pre-existing env dir if there was either an unsuccessful or outdated previous run | |
if [[ ! -e "${envd}/.mapenv" ]] || [[ "$(cat "${envd}/.mapenv")" != "$self_sha256sum" ]]; then | |
rm -rf "$envd" | |
else # we already are successfully set up | |
exit 0 | |
fi | |
mkdir -p "$envd" | |
mkdir -p "$cached" | |
source_subdir() { | |
pushd "$1" 2>/dev/null | |
cp -fbvR "$2" "${envbased}" | |
popd 2>/dev/null | |
} | |
source_file() { | |
cp -fbv "$1/$2" ./env/"$2" | |
} | |
source_pk3() { | |
unzip -B "$1" -d "$envbased" | |
} | |
source_git() { | |
uri_hash=$(echo "$1" | sha256sum | awk '{print $1}') | |
gitd=${cached}/git-${uri_hash} | |
if [[ ! -d "$gitd" ]]; then | |
git clone "$1" "$gitd" | |
fi | |
git -C "$gitd" fetch | |
git -C "$gitd" checkout "$2" | |
git -C "$gitd" clean -xdf | |
cp -fbvR "${gitd}/"* "$envbased/" | |
} | |
source_dir() { | |
cp -fbvR "$1/"* "$envbased" | |
} | |
# source ET client assets | |
source_pk3 "${ET}/etmain/pak0.pk3" | |
source_pk3 "${ET}/etmain/pak1.pk3" | |
source_pk3 "${ET}/etmain/pak2.pk3" | |
# source ET gamepack | |
etpd="${cached}/etpack-1.5" | |
if [[ ! -d "$etpd" ]]; then | |
git svn clone "svn:https://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/" "$etpd" | |
fi | |
source_pk3 "${etpd}/astro-skies.pk3" | |
source_pk3 "${etpd}/common.pk3" | |
source_pk3 "${etpd}/lights.pk3" | |
source_pk3 "${etpd}/mapmedia.pk3" | |
source_subdir "${etpd}" "models" | |
source_subdir "${etpd}" "scripts" | |
# source ET extra assets (from the official maps) | |
source_git https://github.com/Vorschreibung/ET-extra-assets.git 82fae628ff926cd750727518cb6e5923234adb0e | |
# write shaderlist | |
cat <<EOF > "${envbased}/scripts/shaderlist.txt" | |
_unsorted | |
alpha | |
alpha_sd | |
assault | |
assault_rock | |
awf_props | |
battery | |
battery_wall | |
bbmodels_mapobjects | |
blimp | |
bunker_sd | |
castle_door | |
castle_floor | |
castle_window | |
castle_wood | |
chat | |
chat_window | |
chat_wood | |
chateau | |
common | |
decals | |
doors | |
eerie | |
egypt_door_sd | |
egypt_floor_sd | |
egypt_props_sd | |
egypt_rock_sd | |
egypt_trim_sd | |
egypt_walls_sd | |
egypt_windows_sd | |
egypt_wood_sd | |
factory_sd | |
fueldump | |
gfx_2d | |
gfx_clipboard | |
gfx_damage | |
gfx_hud | |
gfx_limbo | |
gfx_misc | |
goldrush | |
icons | |
levelshots | |
lights | |
liquids | |
liquids_sd | |
mapfx | |
metal_misc | |
metals_sd | |
miltary_door | |
miltary_trim | |
miltary_wall | |
models_ammo | |
models_foliage | |
models_furniture | |
models_mapobjects | |
models_multiplayer | |
models_players | |
models_shards | |
models_weapons2 | |
mp_goldrush | |
mp_guns | |
mp_railgun | |
mp_rocket | |
mp_seawall | |
mp_siwa | |
mp_wurzburg | |
props | |
props_sd | |
radar | |
railgun_props | |
railway_sd | |
rock | |
rubble | |
seawall_wall | |
sfx | |
shadows | |
siwa_fx_sd | |
siwa_props_sd | |
siwa_skyboxes_sd | |
skies | |
skies_sd | |
snow | |
snow_sd | |
sprites | |
stone | |
swf | |
temperate_sd | |
terrain | |
textures | |
tobruk_wall_sd | |
tobruk_windows_sd | |
town_props | |
town_roof | |
town_wall | |
town_window | |
town_wood | |
tree | |
ui_assets | |
ui_assets2 | |
villa_sd | |
village | |
wood | |
xlab_door | |
xlab_props | |
xlab_wall | |
blitz_sd_mm | |
EOF | |
# @XXX fixups | |
sed -i 's@qer_editorimage models/mapobjects/props_sd/snowrock_clip.tga@qer_editorimage models/mapobjects/rocks_sd/rock_snow_big.tga@' "${envbased}"/scripts/models_mapobjects.shader | |
# @XXX workaround, for cross-compat reasons lowercase resources as some tools do | |
# not handle FS sensitivity differences between Windows and Linux | |
find basepath -type f -name "*.MD3" -exec bash -c 'set -x; mv ${1} ${1,,}' -- {} \; | |
# cleanup unused parts | |
[[ -n "${envbased}" ]] || die "> Safety breach" | |
rm -rf "${envbased}/"{animations,botfiles,cameras,characters,fonts,maps,menu,script,text,translations,ui,ui_mp,video}/ | |
find "${envbased}" -maxdepth 1 -type f -delete | |
mkdir -p "${envbased}/maps" | |
# write sha256sum of script itself on success | |
echo "$self_sha256sum" > "${envd}"/.mapenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment