Skip to content

Commit

Permalink
Add support for Cataclysm Classic
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Mar 8, 2024
1 parent a8acbfa commit ee3152a
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if [[ ${BASH_VERSINFO[0]} -lt 4 ]] || [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VER
fi

# Game versions for uploading
declare -A game_flavor=( ["retail"]="retail" ["classic"]="classic" ["bcc"]="bcc" ["mainline"]="retail" ["tbc"]="bcc" ["vanilla"]="classic" ["wrath"]="wrath" ["wotlkc"]="wrath" )
declare -A game_flavor=( ["retail"]="retail" ["classic"]="classic" ["bcc"]="bcc" ["mainline"]="retail" ["tbc"]="bcc" ["vanilla"]="classic" ["wrath"]="wrath" ["wotlkc"]="wrath" ["cata"]="cata" )

declare -A game_type_version=() # type -> version
declare -A game_type_interface=() # type -> toc
Expand Down Expand Up @@ -120,7 +120,8 @@ filename_filter() {
if [[ -n $game_type ]] && [[ "$game_type" != "retail" ]] && \
[[ "$game_type" != "classic" || "${si_project_version,,}" != *"-classic"* ]] &&\
[[ "$game_type" != "bcc" || "${si_project_version,,}" != *"-bcc"* ]] &&\
[[ "$game_type" != "wrath" || "${si_project_version,,}" != *"-wrath"* ]]
[[ "$game_type" != "wrath" || "${si_project_version,,}" != *"-wrath"* ]] &&\
[[ "$game_type" != "cata" || "${si_project_version,,}" != *"-cata"* ]]
then
# only append the game type if the tag doesn't include it
classic="-$game_type"
Expand Down Expand Up @@ -171,6 +172,7 @@ toc_to_type() {
11???) game_type="classic" ;;
20???) game_type="bcc" ;;
30???) game_type="wrath" ;;
40???) game_type="cata" ;;
*) game_type="retail"
esac
# return game_type
Expand Down Expand Up @@ -233,7 +235,7 @@ while getopts ":celLzusSop:dw:a:r:t:g:m:n:" opt; do
g) # Set the game type or version
OPTARG="${OPTARG,,}"
case "$OPTARG" in
retail|classic|bcc|wrath) game_type="$OPTARG" ;; # game_version from toc
retail|classic|bcc|wrath|cata) game_type="$OPTARG" ;; # game_version from toc
mainline) game_type="retail" ;;
*)
# Set game version (x.y.z)
Expand All @@ -251,6 +253,8 @@ while getopts ":celLzusSop:dw:a:r:t:g:m:n:" opt; do
game_type="bcc"
elif [[ ${BASH_REMATCH[1]} == "3" ]]; then
game_type="wrath"
elif [[ ${BASH_REMATCH[1]} == "4" ]]; then
game_type="cata"
else
game_type="retail"
fi
Expand Down Expand Up @@ -1107,7 +1111,7 @@ do_toc() {

root_toc_version="$toc_version"

if [[ ${toc_name} =~ "$package_name"[-_](Mainline|Classic|Vanilla|BCC|TBC|Wrath|WOTLKC)\.toc$ ]]; then
if [[ ${toc_name} =~ "$package_name"[-_](Mainline|Classic|Vanilla|BCC|TBC|Wrath|WOTLKC|Cata)\.toc$ ]]; then
# Flavored
if [[ -z "$toc_version" ]]; then
echo "$toc_name is missing an interface version." >&2
Expand Down Expand Up @@ -1145,6 +1149,7 @@ do_toc() {
classic) toc_version=$( sed -n '/@non-[-a-z]*@/,/@end-non-[-a-z]*@/{//b;p}' <<< "$toc_file" | awk '/#[[:blank:]]*## Interface:[[:blank:]]*(11)/ { print $NF; exit }' ) ;;
bcc) toc_version=$( sed -n '/@non-[-a-z]*@/,/@end-non-[-a-z]*@/{//b;p}' <<< "$toc_file" | awk '/#[[:blank:]]*## Interface:[[:blank:]]*(20)/ { print $NF; exit }' ) ;;
wrath) toc_version=$( sed -n '/@non-[-a-z]*@/,/@end-non-[-a-z]*@/{//b;p}' <<< "$toc_file" | awk '/#[[:blank:]]*## Interface:[[:blank:]]*(30)/ { print $NF; exit }' ) ;;
cata) toc_version=$( sed -n '/@non-[-a-z]*@/,/@end-non-[-a-z]*@/{//b;p}' <<< "$toc_file" | awk '/#[[:blank:]]*## Interface:[[:blank:]]*(40)/ { print $NF; exit }' ) ;;
esac
# This becomes the actual interface version after replacements
root_toc_version="$toc_version"
Expand Down Expand Up @@ -1235,14 +1240,14 @@ if [[ -z "$package" ]]; then
exit 1
fi
package=${package%.toc}
if [[ $package =~ ^(.*)([-_](Mainline|Classic|Vanilla|BCC|TBC|Wrath|WOTLKC))$ ]]; then
if [[ $package =~ ^(.*)([-_](Mainline|Classic|Vanilla|BCC|TBC|Wrath|WOTLKC|Cata))$ ]]; then
echo "Ambiguous addon name. No fallback TOC file or addon name includes an expansion suffix (${BASH_REMATCH[2]}). Set 'package-as' in .pkgmeta" >&2
exit 1
fi
fi

# Parse the project root TOC files for info first
for toc_path in "$topdir/$package"{,-Mainline,_Mainline,-Classic,_Classic,-Vanilla,_Vanilla,-BCC,_BCC,-TBC,_TBC,-Wrath,_Wrath,-WOTLKC,_WOTLKC}.toc; do
for toc_path in "$topdir/$package"{,-Mainline,_Mainline,-Classic,_Classic,-Vanilla,_Vanilla,-BCC,_BCC,-TBC,_TBC,-Wrath,_Wrath,-WOTLKC,_WOTLKC,-Cata,_Cata}.toc; do
if [[ -f "$toc_path" ]]; then
set_toc_project_info "$toc_path"
toc_paths+=("$toc_path")
Expand All @@ -1258,7 +1263,7 @@ done

# Parse project TOC files
for path in "${!toc_root_paths[@]}"; do
for toc_path in "$path/${toc_root_paths[$path]}"{,-Mainline,_Mainline,-Classic,_Classic,-Vanilla,_Vanilla,-BCC,_BCC,-TBC,_TBC,-Wrath,_Wrath,-WOTLKC,_WOTLKC}.toc; do
for toc_path in "$path/${toc_root_paths[$path]}"{,-Mainline,_Mainline,-Classic,_Classic,-Vanilla,_Vanilla,-BCC,_BCC,-TBC,_TBC,-Wrath,_Wrath,-WOTLKC,_WOTLKC,-Cata,_Cata}.toc; do
if [[ -f "$toc_path" ]]; then
set_toc_project_info "$toc_path"
do_toc "$toc_path" "${toc_root_paths[$path]}"
Expand Down Expand Up @@ -1729,6 +1734,7 @@ copy_directory_tree() {
[ "$_cdt_file_gametype" != "classic" ] && _cdt_filters+="|lua_filter version-classic"
[ "$_cdt_file_gametype" != "bcc" ] && _cdt_filters+="|lua_filter version-bcc"
[ "$_cdt_file_gametype" != "wrath" ] && _cdt_filters+="|lua_filter version-wrath"
[ "$_cdt_file_gametype" != "cata" ] && _cdt_filters+="|lua_filter version-cata"
[ -n "$_cdt_localization" ] && grep -q "@localization" "$_cdt_source_file" && _cdt_filters+="|localization_filter"
;;
*.xml)
Expand All @@ -1740,6 +1746,7 @@ copy_directory_tree() {
[ "$_cdt_file_gametype" != "classic" ] && _cdt_filters+="|xml_filter version-classic"
[ "$_cdt_file_gametype" != "bcc" ] && _cdt_filters+="|xml_filter version-bcc"
[ "$_cdt_file_gametype" != "wrath" ] && _cdt_filters+="|xml_filter version-wrath"
[ "$_cdt_file_gametype" != "cata" ] && _cdt_filters+="|xml_filter version-cata"
;;
*.toc)
# We only care about processing project TOC files
Expand All @@ -1759,6 +1766,7 @@ copy_directory_tree() {
_cdt_filters+="|toc_filter version-classic $([[ "$_cdt_file_gametype" != "classic" ]] && echo "true")"
_cdt_filters+="|toc_filter version-bcc $([[ "$_cdt_file_gametype" != "bcc" ]] && echo "true")"
_cdt_filters+="|toc_filter version-wrath $([[ "$_cdt_file_gametype" != "wrath" ]] && echo "true")"
_cdt_filters+="|toc_filter version-cata $([[ "$_cdt_file_gametype" != "cata" ]] && echo "true")"
_cdt_filters+="|toc_interface_filter '${si_game_type_interface_all[${_cdt_file_gametype:- }]}' '${toc_root_interface["$_cdt_source_file"]}'"
[ -n "$_cdt_localization" ] && grep -q "@localization" "$_cdt_source_file" && _cdt_filters+="|localization_filter"
fi
Expand All @@ -1774,10 +1782,10 @@ copy_directory_tree() {
echo " Copying: $file${_cdt_external_slug:+ (embedded: "$_cdt_external_slug")}"

# Make sure we're not causing any surprises
if [[ -z $_cdt_file_gametype && ( $file == *".lua" || $file == *".xml" || ( -z $_cdt_external && $file == *".toc" ) ) ]] && grep -q '@\(non-\)\?version-\(retail\|classic\|bcc\|wrath\)@' "$_cdt_source_file"; then
if [[ -z $_cdt_file_gametype && ( $file == *".lua" || $file == *".xml" || ( -z $_cdt_external && $file == *".toc" ) ) ]] && grep -q '@\(non-\)\?version-\(retail\|classic\|bcc\|wrath\|cata\)@' "$_cdt_source_file"; then
echo " Error! Build type version keywords are not allowed in a multi-version build." >&2
echo " These should be replaced with lua conditional statements:" >&2
grep -n '@\(non-\)\?version-\(retail\|classic\|bcc\|wrath\)@' "$_cdt_source_file" | sed 's/^/ /' >&2
grep -n '@\(non-\)\?version-\(retail\|classic\|bcc\|wrath\|cata\)@' "$_cdt_source_file" | sed 's/^/ /' >&2
echo " See https://wowpedia.fandom.com/wiki/WOW_PROJECT_ID" >&2
exit 1
fi
Expand All @@ -1797,6 +1805,7 @@ copy_directory_tree() {
classic) new_file+="_Vanilla.toc" ;;
bcc) new_file+="_TBC.toc" ;;
wrath) new_file+="_Wrath.toc" ;;
cata) new_file+="_Cata.toc" ;;
esac

echo " Creating $new_file [$toc_version]"
Expand All @@ -1811,6 +1820,7 @@ copy_directory_tree() {
_cdt_filters+="|toc_filter version-classic $([[ "$type" != "classic" ]] && echo "true")"
_cdt_filters+="|toc_filter version-bcc $([[ "$type" != "bcc" ]] && echo "true")"
_cdt_filters+="|toc_filter version-wrath $([[ "$type" != "wrath" ]] && echo "true")"
_cdt_filters+="|toc_filter version-cata $([[ "$type" != "cata" ]] && echo "true")"
_cdt_filters+="|toc_interface_filter '$toc_version' '$root_toc_version'"
_cdt_filters+="|line_ending_filter"

Expand Down Expand Up @@ -2575,13 +2585,14 @@ upload_curseforge() {
_cf_game_version_id=
_cf_game_version=
local version_name version_id game_id
for type in "classic" "bcc" "wrath" "retail"; do # sort order (last id is show as the version on the project's files page apparently)
for type in "classic" "bcc" "wrath" "cata" "retail"; do # sort order (last id is show as the version on the project's files page apparently)
version_name="${game_type_version[$type]}"
[[ -z $version_name ]] && continue
case $type in
classic) game_id=67408 ;;
bcc) game_id=73246 ;;
wrath) game_id=73713 ;;
cata) game_id=77522 ;;
*) game_id=517
esac

Expand Down Expand Up @@ -2691,18 +2702,21 @@ upload_wowinterface() {
classic) wowi_type="Classic" ;;
bcc) wowi_type="TBC-Classic" ;;
wrath) wowi_type="WOTLK-Classic" ;;
cata) wowi_type="Cata-Classic" ;;
*) wowi_type="Retail"
esac
# check the version
if ! jq -e --arg v "$version" 'map(select(.id == $v)) | length > 0' <<< "$_wowi_versions" &>/dev/null; then
# use the next highest version (try to avoid testing versions)
version=$( echo "$_wowi_versions" | jq -r --arg v "$version" --arg t "$wowi_type" 'map(select(.game == $t and .id < $v)) | max_by(.id) | .id // empty' )
if [[ -z $version ]]; then
# now that .game exists, maybe default per type is in the future?
version=$( echo "$_wowi_versions" | jq -r --arg t "$wowi_type" '.[] | select(.game == $t and .default == true ) | .id // empty' )
if [[ -z $version ]]; then # just grab the highest version
version=$( echo "$_wowi_versions" | jq -r --arg t "$wowi_type" 'map(select(.game == $t)) | max_by(.id) | .id' )
# now that .game exists, maybe default per type is in the future? (future me: nope, default is just the latest retail)
# version=$( echo "$_wowi_versions" | jq -r --arg t "$wowi_type" '.[] | select(.game == $t and .default == true ) | .id // empty' )
if [[ $wowi_type == "Cata-Classic" ]]; then # XXX compat: not supported or I guessed the wrong name
wowi_type="WOTLK-Classic"
fi
# just grab the highest version
version=$( echo "$_wowi_versions" | jq -r --arg t "$wowi_type" 'map(select(.game == $t)) | max_by(.id) | .id' )
fi
echo "WARNING: No WoWInterface game version match for \"${game_type_version[$type]}\", using \"$version\"" >&2
fi
Expand Down

0 comments on commit ee3152a

Please sign in to comment.