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 883fc7a
Show file tree
Hide file tree
Showing 9 changed files with 55 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, PR #8435)
4 changes: 4 additions & 0 deletions copyrights.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11854,6 +11854,7 @@ Date,File,License,Author - Real Name(other name);Real Name(other name);etc,Notes
2022/12/25,data/core/images/units/human-loyalists/general-crossbow.png,GNU GPL v2+,Richard Kettering(Jetrel);(doofus-01),,,10f5c6e5f57f9128a3f299fd516d6498
2022/12/25,data/core/images/units/human-loyalists/general-defend-1.png,GNU GPL v2+,Richard Kettering(Jetrel);(doofus-01),,,143533c9e471ea1c8a6262898d45221e
2022/12/25,data/core/images/units/human-loyalists/general-defend-2.png,GNU GPL v2+,Richard Kettering(Jetrel);(doofus-01),,,7aa8ad35cea9011f29bf76625dcee14a
2022/06/04,data/core/images/units/human-loyalists/general-idle-5.png,GNU GPL v2+,(doofus-01),,,a7580f2bd4824ab0651de2db7666454d
2022/12/25,data/core/images/units/human-loyalists/general-leading1.png,CC BY-SA 4.0,(doofus-01),,,32aa22068e91142ae0a275709ae2f326
2022/12/25,data/core/images/units/human-loyalists/general-leading2.png,CC BY-SA 4.0,(doofus-01),,,19af75125c812e46efd15a6448845c5f
2022/12/25,data/core/images/units/human-loyalists/general-leading3.png,CC BY-SA 4.0,(doofus-01),,,b036c2aa31f7d2e5ec085e593cddb1f2
Expand Down Expand Up @@ -12408,9 +12409,12 @@ Date,File,License,Author - Real Name(other name);Real Name(other name);etc,Notes
2022/12/25,data/core/images/units/human-loyalists/spearman-attack-ranged3.png,CC BY-SA 4.0,(doofus-01),,,6db009e1b2458384aafa45c25f0787e5
2022/12/25,data/core/images/units/human-loyalists/spearman-attack-s-2.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,1e5be30975de3fde158fef66fd820e3a
2022/12/25,data/core/images/units/human-loyalists/spearman-attack-s-3.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,2c225d8fcc8bae859cc58eb4ad34bcce
2022/06/04,data/core/images/units/human-loyalists/spearman-attack-s-6.png,GNU GPL v2+,(doofus-01),,,697f6e410c2f74b2cfa1da0d65891922
2022/12/25,data/core/images/units/human-loyalists/spearman-attack-se-1.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,1dee259ebbd8e96dbb447310fe4828bb
2022/06/04,data/core/images/units/human-loyalists/spearman-attack-se-10.png,GNU GPL v2+,(doofus-01),,,8290b400836be68cae4ae3a34f2480f9
2022/12/25,data/core/images/units/human-loyalists/spearman-attack-se-2.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,c9287dfb7b711c0935332903aa1684f6
2022/12/25,data/core/images/units/human-loyalists/spearman-attack-se-3.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,b94afe478a49a403a358dacbda7acb13
2022/06/04,data/core/images/units/human-loyalists/spearman-attack-se-9.png,GNU GPL v2+,(doofus-01),,,2c5f0b14f8aeafb3c81283fe15a515a0
2022/12/25,data/core/images/units/human-loyalists/spearman-bob-n-1.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,efc21424aa3c5dc3efbf70ba9bd2b3c2
2022/12/25,data/core/images/units/human-loyalists/spearman-bob-n-2.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,e66e6cb4c345d473924365028fc6087d
2022/12/25,data/core/images/units/human-loyalists/spearman-bob-n-3.png,GNU GPL v2+,Adrian Sheehy(Major);(doofus-01),,,9c1dd8f7a8fec85729864ff289f5e98b
Expand Down
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 883fc7a

Please sign in to comment.