From 958d7217a66345840a8ddcdabe45ab88a8d576bc Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 21 Nov 2024 21:24:20 +0200
Subject: [PATCH 81/81] Animate "3Layer" extras middleground

See RM #1154

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/tilespec.c             | 15 +++++++--------
 data/amplio/moderncities.spec |  8 ++++----
 data/amplio2/bases.spec       | 10 +++++-----
 data/hex2t/items.spec         |  8 ++++----
 data/hexemplio/bases.spec     |  8 ++++----
 data/isotrident/cities.spec   |  8 ++++----
 data/trident/tiles.spec       | 10 +++++-----
 7 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/client/tilespec.c b/client/tilespec.c
index 56e158175f..1fe328e950 100644
--- a/client/tilespec.c
+++ b/client/tilespec.c
@@ -370,10 +370,10 @@ struct named_sprites {
       struct sprite *cardinals[MAX_INDEX_CARDINAL];
       struct {
         struct sprite
-          *background,
-          *middleground;
+          *background;
         struct anim
-          *foreground;
+          *foreground,
+          *middleground;
       } bmf;
       struct {
         struct sprite
@@ -4305,8 +4305,7 @@ static void tileset_setup_base(struct tileset *t,
 
   sz_strlcpy(full_tag_name, tag);
   strcat(full_tag_name, "_mg");
-  t->sprites.extras[id].u.bmf.middleground = load_sprite(t, full_tag_name,
-                                                         TRUE, TRUE, FALSE);
+  t->sprites.extras[id].u.bmf.middleground = anim_load(t, full_tag_name, 0);
 
   sz_strlcpy(full_tag_name, tag);
   strcat(full_tag_name, "_fg");
@@ -6323,7 +6322,7 @@ int fill_sprite_array(struct tileset *t,
         extra_type_list_iterate(t->style_lists[ESTYLE_3LAYER], pextra) {
           if (tile_has_extra(ptile, pextra)
               && is_extra_drawing_enabled(pextra)
-              && t->sprites.extras[extra_index(pextra)].u.bmf.middleground) {
+              && t->sprites.extras[extra_index(pextra)].u.bmf.middleground != nullptr) {
             bool hidden = FALSE;
 
             extra_type_list_iterate(pextra->hiders, phider) {
@@ -6334,7 +6333,7 @@ int fill_sprite_array(struct tileset *t,
             } extra_type_list_iterate_end;
 
             if (!hidden) {
-              ADD_SPRITE_FULL(t->sprites.extras[extra_index(pextra)].u.bmf.middleground);
+              ADD_ANIM_FULL(t->sprites.extras[extra_index(pextra)].u.bmf.middleground);
             }
           }
         } extra_type_list_iterate_end;
@@ -7542,7 +7541,7 @@ int fill_basic_base_sprite_array(const struct tileset *t,
 
   /* Corresponds to LAYER_SPECIAL{1,2,3} order. */
   ADD_SPRITE_IF_NOT_NULL(t->sprites.extras[idx].u.bmf.background);
-  ADD_SPRITE_IF_NOT_NULL(t->sprites.extras[idx].u.bmf.middleground);
+  ADD_FRAME0_IF_NOT_NULL(t->sprites.extras[idx].u.bmf.middleground);
   ADD_FRAME0_IF_NOT_NULL(t->sprites.extras[idx].u.bmf.foreground);
 
 #undef ADD_SPRITE_IF_NOT_NULL
diff --git a/data/amplio/moderncities.spec b/data/amplio/moderncities.spec
index 395b7b0984..5ab00349ee 100644
--- a/data/amplio/moderncities.spec
+++ b/data/amplio/moderncities.spec
@@ -61,17 +61,17 @@ tiles = { "row", "column", "tag"
 ; used by all city styles
 
  0,  0, "city.disorder"
- 0,  1, "base.airbase_mg"
+ 0,  1, "base.airbase_mg_0"
  0,  2, "tx.airbase_full"
  0,  4, "base.outpost_fg_0"
  0,  5, "base.outpost_bg"
  0,  6, "city.electricage_occupied_0"
  0,  6, "city.modern_occupied_0"
  0,  6, "city.postmodern_occupied_0"
- 0,  8, "base.buoy_mg"
- 0,  9, "extra.ruins_mg"
+ 0,  8, "base.buoy_mg_0"
+ 0,  9, "extra.ruins_mg_0"
 
- 1,  1, "base.airstrip_mg"
+ 1,  1, "base.airstrip_mg_0"
  1,  4, "base.fortress_fg_0"
  1,  5, "base.fortress_bg"
 ;
diff --git a/data/amplio2/bases.spec b/data/amplio2/bases.spec
index ecbe6f49f4..3c82a51f94 100644
--- a/data/amplio2/bases.spec
+++ b/data/amplio2/bases.spec
@@ -27,22 +27,22 @@ pixel_border = 1
 
 tiles = { "row", "column", "tag"
 ;[HH][GS]
- 0,  0, "base.airbase_mg"
+ 0,  0, "base.airbase_mg_0"
  0,  1, "tx.airbase_full"
 ;[HH]
  0,  3, "base.fortress_fg_0"
  0,  4, "base.fortress_bg"
 ;[HH][GS]
- 1,  0, "base.airstrip_mg"
+ 1,  0, "base.airstrip_mg_0"
 ;[El]
- 1,  1, "base.buoy_mg"
+ 1,  1, "base.buoy_mg_0"
 ;[VC]
- 1,  2, "extra.ruins_mg"
+ 1,  2, "extra.ruins_mg_0"
 ;[HH][GS]
  1,  3, "base.outpost_fg_0"
  1,  4, "base.outpost_bg"
 ; [SK]
- 1,  5, "extra.transport_hub_mg"
+ 1,  5, "extra.transport_hub_mg_0"
  ;[Lexxie]
  2,  2, "base.castle2_fg_0"      ; Alternate castle (larger 'closed' version which makes hidden units more plausible ...
  2,  3, "base.castle2_bg"        ; ... but also hides the terrain graphics)
diff --git a/data/hex2t/items.spec b/data/hex2t/items.spec
index c5aab7a31b..30672a774e 100644
--- a/data/hex2t/items.spec
+++ b/data/hex2t/items.spec
@@ -36,11 +36,11 @@ tiles = { "row", "column", "tag"
 ; used by all city styles
 
  1,  0, "city.disorder"
- 1,  1, "base.airbase_mg"
+ 1,  1, "base.airbase_mg_0"
  1,  2, "tx.airbase_full"
- 1,  3, "base.airstrip_mg"
- 1,  5, "base.buoy_mg"
- 1,  6, "extra.ruins_mg"
+ 1,  3, "base.airstrip_mg_0"
+ 1,  5, "base.buoy_mg_0"
+ 1,  6, "extra.ruins_mg_0"
  3,  8, "base.outpost_fg_0"
  3,  9, "base.outpost_bg"
  4,  8, "base.fortress_fg_0"
diff --git a/data/hexemplio/bases.spec b/data/hexemplio/bases.spec
index 18fdf0fb5a..2b528aa737 100644
--- a/data/hexemplio/bases.spec
+++ b/data/hexemplio/bases.spec
@@ -51,10 +51,10 @@ pixel_border = 1
 tiles = { "row", "column", "tag"
 
 ;[HH][GS]
- 0,  0, "base.airstrip_mg"
+ 0,  0, "base.airstrip_mg_0"
  1,  0, "tx.airstrip_full"
 ;[HH][GS]
- 0,  1, "base.airbase_mg"
+ 0,  1, "base.airbase_mg_0"
  1,  1, "tx.airbase_full"
 ;[HH][GS]
  1,  2, "base.outpost_fg_0"
@@ -65,9 +65,9 @@ tiles = { "row", "column", "tag"
 ;[HH]
  0,  4, "city.disorder"
 ;[El]
- 1,  4, "base.buoy_mg"
+ 1,  4, "base.buoy_mg_0"
 ;[VC]
- 0,  5, "extra.ruins_mg"
+ 0,  5, "extra.ruins_mg_0"
 ;[HH]
  1,  5, "city.european_occupied_0"
  1,  5, "city.classical_occupied_0"
diff --git a/data/isotrident/cities.spec b/data/isotrident/cities.spec
index 777168982f..35f2cff845 100644
--- a/data/isotrident/cities.spec
+++ b/data/isotrident/cities.spec
@@ -62,13 +62,13 @@ tiles = { "row", "column", "tag"
 ; used by all city styles
 
  0,  0, "city.disorder"
- 0,  1, "base.airbase_mg"
+ 0,  1, "base.airbase_mg_0"
  0,  2, "tx.airbase_full"
- 0,  3, "base.airstrip_mg"
+ 0,  3, "base.airstrip_mg_0"
  0,  4, "base.fortress_fg_0"
  0,  5, "base.fortress_bg"
- 0,  6, "extra.ruins_mg"
- 0,  7, "base.buoy_mg"
+ 0,  6, "extra.ruins_mg_0"
+ 0,  7, "base.buoy_mg_0"
  0,  8, "base.outpost_fg_0"
  0,  9, "base.outpost_bg"
 
diff --git a/data/trident/tiles.spec b/data/trident/tiles.spec
index 85f4b8cc73..34257564fe 100644
--- a/data/trident/tiles.spec
+++ b/data/trident/tiles.spec
@@ -498,12 +498,12 @@ tiles = { "row", "column", "tag"
  16, 14, "tx.nets_0"
 
 ; Bases
- 16,  6, "base.buoy_mg"
- 16,  7, "extra.ruins_mg"
+ 16,  6, "base.buoy_mg_0"
+ 16,  7, "extra.ruins_mg_0"
  16,  8, "tx.village_0"
- 16,  9, "base.airstrip_mg"
- 16, 10, "base.airbase_mg"
- 16, 11, "base.outpost_mg"
+ 16,  9, "base.airstrip_mg_0"
+ 16, 10, "base.airbase_mg_0"
+ 16, 11, "base.outpost_mg_0"
  16, 12, "base.fortress_bg"
 
 ; Numbers: city size: (also used for goto)
-- 
2.45.2

