Skip to content

Commit

Permalink
Fix renamed/removed unit images in MP Aethermaw (wesnoth#8432)
Browse files Browse the repository at this point in the history
Playing the multiplayer scenario Aethermaw as Loyalists vs. Undead
revealed some image errors:

    20240219 06:50:21 error image: could not open image 'units/undead/shadow-s-attack-1.png'
    20240219 06:50:21 error image: could not open image 'units/undead/shadow-s-attack-4.png'
    20240219 06:50:21 error image: could not open image 'units/undead/shadow-n-3.png'
    20240219 06:50:22 error image: could not open image 'units/undead/shadow-n-attack-2.png'
    20240219 06:50:26 error image: could not open image 'units/human-loyalists/spearman-attack-se-9.png'
    20240219 06:50:26 error image: could not open image 'units/human-loyalists/spearman-attack-se-10.png'
    20240219 06:50:26 error image: could not open image 'units/human-loyalists/spearman-attack-s-6.png'
    20240219 06:50:26 error image: could not open image 'units/human-loyalists/general-idle-5.png'

units/undead/shadow-* images were moved to units/undead-spirit/shadow-*
in 1.17.4 commit a2ad3ae, specifically the "1.17 undead sprite
cleanup" commit 961b8a3 of PR wesnoth#6655.  This was documented on the
forums:
https://forums.wesnoth.org/viewtopic.php?p=684291&hilit=units%2Fundead-spirit%2F#p684291

wmllint handles renamed images, but it also makes an enormous number of
other (often questionable at best) changes (issue wesnoth#5799).  So for now,
instead of using wmllint, just update Aethermaw for these renamed images
as follows (requires GNU sed):

    git grep -Fl -- 'units/undead/shadow-' \
        | grep -v '^data/tools/wmllint$' \
        | xargs sed -i 's|units/undead/shadow-|units/undead-spirit/shadow-|'

These units/human-loyalists/ images were removed in 1.17.12 commit
8e38cfd, specifically the "spearman image cleanup" commit 775e7f8
and the "remove left-over old general frames" commit e07d554 in
PR wesnoth#7208.  But Aethermaw still uses them.

Restore the removed images that are still used:

    git grep -EIh -- '^[^#]*[{]PLACE_IMAGE[^ ]* +[(]?"?[^{}$ ~")]+[ ~")].*$' data/ \
        | sed -E 's|^.*[{]PLACE_IMAGE[^ ]* +[(]?"?([^{}$ ~")]+)[ ~")].*$|\1|' \
        | while read -r img; do
            [ -e data/core/images/${img} ] && continue
            [ -e data/campaigns/*/images/${img} ] && continue
            [ -e ${img} ] && continue
            git show 8e38cfd~1:data/core/images/${img} 1>data/core/images/${img}
        done

Also add a CI check to prevent this from happening in the future.
Example output without these Aethermaw fixes:

    data/multiplayer/scenarios/2p_Aethermaw.cfg:134: missing image: units/undead/shadow-s-attack-1.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:135: missing image: units/undead/shadow-n-attack-2.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:147: missing image: units/undead/shadow-n-3.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:149: missing image: units/undead/shadow-s-attack-4.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:196: missing image: units/human-loyalists/spearman-attack-se-10.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:197: missing image: units/human-loyalists/spearman-attack-s-6.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:198: missing image: units/human-loyalists/spearman-attack-se-9.png
    data/multiplayer/scenarios/2p_Aethermaw.cfg:203: missing image: units/human-loyalists/general-idle-5.png
  • Loading branch information
pehjota committed Feb 20, 2024
1 parent 8cebaf5 commit 10501ec
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
- name: Whitespace and WML indentation check
if: success() || failure()
run: ./utils/CI/fix_whitespace.sh; git status; git diff --exit-code
- name: WML missing images check
if: success() || failure()
run: utils/CI/check_wml_images.sh
- name: Run luacheck
if: success() || failure()
run: luacheck .
Expand Down
2 changes: 2 additions & 0 deletions changelog_entries/aethermaw_image_errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Multiplayer
* Fix renamed Undead images and removed Loyalist images in Aethermaw (issue #8432)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions data/multiplayer/scenarios/2p_Aethermaw.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
{PLACE_IMAGE "units/goblins/wolf-rider-moving.png~FL()~RC(magenta>1)" 48 2}
{PLACE_IMAGE "units/goblins/wolf-rider-moving.png~FL()~RC(magenta>1)" 46 2}

{PLACE_IMAGE "units/undead/shadow-s-attack-1.png~RC(magenta>5)" 44 18}
{PLACE_IMAGE "units/undead/shadow-n-attack-2.png~RC(magenta>5)" 45 24}
{PLACE_IMAGE "units/undead-spirit/shadow-s-attack-1.png~RC(magenta>5)" 44 18}
{PLACE_IMAGE "units/undead-spirit/shadow-n-attack-2.png~RC(magenta>5)" 45 24}
{PLACE_IMAGE "units/undead-skeletal/revenant/revenant-attack-4.png~RC(magenta>5)" 45 21}
{PLACE_IMAGE "units/undead-skeletal/chocobone-attack-2.png~RC(magenta>5)" 45 18}
{PLACE_IMAGE "units/undead-skeletal/chocobone-attack-2.png~RC(magenta>5)" 43 22}
Expand All @@ -144,9 +144,9 @@
{PLACE_IMAGE "units/undead-necromancers/ancient-lich-magic-1.png~FL()~RC(magenta>5)" 48 17}
{PLACE_IMAGE "units/undead/zombie-troll-attack.png~RC(magenta>5)" 45 19}
{PLACE_IMAGE "units/undead/zombie-troll-attack-n.png~RC(magenta>5)" 49 25}
{PLACE_IMAGE "units/undead/shadow-n-3.png~FL()~RC(magenta>5)" 49 23}
{PLACE_IMAGE "units/undead-spirit/shadow-n-3.png~FL()~RC(magenta>5)" 49 23}
{PLACE_IMAGE "units/undead/ghoul-attack-2.png~RC(magenta>5)" 46 22}
{PLACE_IMAGE "units/undead/shadow-s-attack-4.png~RC(magenta>5)" 43 21}
{PLACE_IMAGE "units/undead-spirit/shadow-s-attack-4.png~RC(magenta>5)" 43 21}
{PLACE_IMAGE "units/undead/zombie-dwarf-attack-n.png~RC(magenta>5)" 48 24}
{PLACE_IMAGE "units/undead/zombie-dwarf-attack-n.png~RC(magenta>5)" 48 23}
{PLACE_IMAGE "units/undead/zombie-dwarf-attack-n.png~RC(magenta>5)" 47 25}
Expand Down
42 changes: 42 additions & 0 deletions utils/CI/check_wml_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
#
# Find missing images referenced by WML (as in issue #8432)
#
# Requires sort with -s option (stable sort, disable further byte-by-byte
# comparison of lines that collate equally by specified sort key), e.g. from
# GNU coreutils
#
# Example output:
# data/multiplayer/scenarios/2p_Aethermaw.cfg:134: missing image: units/undead/shadow-s-attack-1.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:135: missing image: units/undead/shadow-n-attack-2.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:147: missing image: units/undead/shadow-n-3.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:149: missing image: units/undead/shadow-s-attack-4.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:196: missing image: units/human-loyalists/spearman-attack-se-10.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:197: missing image: units/human-loyalists/spearman-attack-s-6.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:198: missing image: units/human-loyalists/spearman-attack-se-9.png
# data/multiplayer/scenarios/2p_Aethermaw.cfg:203: missing image: units/human-loyalists/general-idle-5.png

set -eu

# Parsing WML with a regular expression isn't ideal, but it's easy and it works.
IMG_RE='^[^#]*[{]PLACE_IMAGE[^ ]* +[(]?"?([^{}$ ~")]+)[ ~")].*$'

# In `! { COMMANDS | grep -- '.'; }` below, `grep -- '.'` returns a successful
# exit status if `COMMANDS` produce output, and `!` inverts it into an error
# status. A less clever/obscure solution would be `es=true` before the loop,
# `es=false` inside the loop after all the `continue`s, and `${es}` at the end;
# but that won't work because all commands in pipelines run in subshells that
# can't affect variables in the parent shell.

! { git grep -EIn -- "${IMG_RE}" data/ | while IFS=':' read -r wml ln img; do
img="$(printf '%s' "${img}" | sed -E "s|${IMG_RE}|\\1|")"
[ -e "data/core/images/${img}" ] && continue
[ -e "${img}" ] && continue
case "${wml}" in
data/campaigns/*)
sfx="${wml#data/campaigns/*/}"
[ -e "${wml%/${sfx}}/images/${img}" ] && continue
;;
esac
printf '%s:%d: missing image: %s\n' "${wml}" "${ln}" "${img}"
done | sort -t ':' -k 2n,2n | sort -t ':' -k 1,1 -s | grep -- '.'; }

0 comments on commit 10501ec

Please sign in to comment.