From 75da13f77d608d65c83763ab7fee23f9a7e37ce5 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 24 Nov 2024 09:59:39 +0200
Subject: [PATCH 74/74] Animate "3Layer" extras background

See RM #1157

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/tilespec.c             | 21 ++++++---------------
 data/alio/fortresses.spec     |  4 ++--
 data/amplio/moderncities.spec |  4 ++--
 data/amplio2/bases.spec       |  8 ++++----
 data/hex2t/items.spec         |  4 ++--
 data/hexemplio/bases.spec     |  4 ++--
 data/isotrident/cities.spec   |  4 ++--
 data/trident/tiles.spec       |  2 +-
 8 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/client/tilespec.c b/client/tilespec.c
index 1fe328e950..f9928cf676 100644
--- a/client/tilespec.c
+++ b/client/tilespec.c
@@ -369,11 +369,10 @@ struct named_sprites {
       struct anim *single;
       struct sprite *cardinals[MAX_INDEX_CARDINAL];
       struct {
-        struct sprite
-          *background;
         struct anim
           *foreground,
-          *middleground;
+          *middleground,
+          *background;
       } bmf;
       struct {
         struct sprite
@@ -4300,8 +4299,7 @@ static void tileset_setup_base(struct tileset *t,
 
   sz_strlcpy(full_tag_name, tag);
   strcat(full_tag_name, "_bg");
-  t->sprites.extras[id].u.bmf.background = load_sprite(t, full_tag_name,
-                                                       TRUE, TRUE, FALSE);
+  t->sprites.extras[id].u.bmf.background = anim_load(t, full_tag_name, 0);
 
   sz_strlcpy(full_tag_name, tag);
   strcat(full_tag_name, "_mg");
@@ -6207,7 +6205,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.background) {
+              && t->sprites.extras[extra_index(pextra)].u.bmf.background != nullptr) {
             bool hidden = FALSE;
 
             extra_type_list_iterate(pextra->hiders, phider) {
@@ -6218,7 +6216,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.background);
+              ADD_ANIM_FULL(t->sprites.extras[extra_index(pextra)].u.bmf.background);
             }
           }
         } extra_type_list_iterate_end;
@@ -7527,12 +7525,6 @@ int fill_basic_base_sprite_array(const struct tileset *t,
     return 0;
   }
 
-#define ADD_SPRITE_IF_NOT_NULL(x) do {\
-  if ((x) != NULL) {\
-    ADD_SPRITE_FULL(x);\
-  }\
-} while (FALSE)
-
 #define ADD_FRAME0_IF_NOT_NULL(x) do {\
   if ((x) != nullptr) {\
     ADD_FRAME0_FULL(x);\
@@ -7540,11 +7532,10 @@ int fill_basic_base_sprite_array(const struct tileset *t,
 } while (FALSE)
 
   /* Corresponds to LAYER_SPECIAL{1,2,3} order. */
-  ADD_SPRITE_IF_NOT_NULL(t->sprites.extras[idx].u.bmf.background);
+  ADD_FRAME0_IF_NOT_NULL(t->sprites.extras[idx].u.bmf.background);
   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
 #undef ADD_FRAME0_IF_NOT_NULL
 
   return sprs - saved_sprs;
diff --git a/data/alio/fortresses.spec b/data/alio/fortresses.spec
index c7f34b4086..59f9000a60 100644
--- a/data/alio/fortresses.spec
+++ b/data/alio/fortresses.spec
@@ -24,9 +24,9 @@ pixel_border = 1
 
 tiles = { "row", "column", "tag"
 
- 0,  0, "base.force_fortress_bg"
+ 0,  0, "base.force_fortress_bg_0"
  1,  0, "base.force_fortress_fg_0"
 
- 0,  1, "base.tower_bg"
+ 0,  1, "base.tower_bg_0"
  1,  1, "base.tower_fg_0"
 }
diff --git a/data/amplio/moderncities.spec b/data/amplio/moderncities.spec
index 5ab00349ee..ef0b64ae49 100644
--- a/data/amplio/moderncities.spec
+++ b/data/amplio/moderncities.spec
@@ -64,7 +64,7 @@ tiles = { "row", "column", "tag"
  0,  1, "base.airbase_mg_0"
  0,  2, "tx.airbase_full"
  0,  4, "base.outpost_fg_0"
- 0,  5, "base.outpost_bg"
+ 0,  5, "base.outpost_bg_0"
  0,  6, "city.electricage_occupied_0"
  0,  6, "city.modern_occupied_0"
  0,  6, "city.postmodern_occupied_0"
@@ -73,7 +73,7 @@ tiles = { "row", "column", "tag"
 
  1,  1, "base.airstrip_mg_0"
  1,  4, "base.fortress_fg_0"
- 1,  5, "base.fortress_bg"
+ 1,  5, "base.fortress_bg_0"
 ;
 ; city tiles
 ;
diff --git a/data/amplio2/bases.spec b/data/amplio2/bases.spec
index 3c82a51f94..b83f62db49 100644
--- a/data/amplio2/bases.spec
+++ b/data/amplio2/bases.spec
@@ -31,7 +31,7 @@ tiles = { "row", "column", "tag"
  0,  1, "tx.airbase_full"
 ;[HH]
  0,  3, "base.fortress_fg_0"
- 0,  4, "base.fortress_bg"
+ 0,  4, "base.fortress_bg_0"
 ;[HH][GS]
  1,  0, "base.airstrip_mg_0"
 ;[El]
@@ -40,14 +40,14 @@ tiles = { "row", "column", "tag"
  1,  2, "extra.ruins_mg_0"
 ;[HH][GS]
  1,  3, "base.outpost_fg_0"
- 1,  4, "base.outpost_bg"
+ 1,  4, "base.outpost_bg_0"
 ; [SK]
  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)
+ 2,  3, "base.castle2_bg_0"      ; ... but also hides the terrain graphics)
  2,  4, "base.castle_fg_0"
- 2,  5, "base.castle_bg"
+ 2,  5, "base.castle_bg_0"
 ;[HH]
  0,  2, "cd.occupied",
       "city.european_occupied_0",
diff --git a/data/hex2t/items.spec b/data/hex2t/items.spec
index 30672a774e..88a4a07285 100644
--- a/data/hex2t/items.spec
+++ b/data/hex2t/items.spec
@@ -42,9 +42,9 @@ tiles = { "row", "column", "tag"
  1,  5, "base.buoy_mg_0"
  1,  6, "extra.ruins_mg_0"
  3,  8, "base.outpost_fg_0"
- 3,  9, "base.outpost_bg"
+ 3,  9, "base.outpost_bg_0"
  4,  8, "base.fortress_fg_0"
- 4,  9, "base.fortress_bg"
+ 4,  9, "base.fortress_bg_0"
 
 ; default city tiles
  2,  2, "cd.city"
diff --git a/data/hexemplio/bases.spec b/data/hexemplio/bases.spec
index 2b528aa737..40fa1fd923 100644
--- a/data/hexemplio/bases.spec
+++ b/data/hexemplio/bases.spec
@@ -58,10 +58,10 @@ tiles = { "row", "column", "tag"
  1,  1, "tx.airbase_full"
 ;[HH][GS]
  1,  2, "base.outpost_fg_0"
- 0,  2, "base.outpost_bg"
+ 0,  2, "base.outpost_bg_0"
 ;[HH]
  1,  3, "base.fortress_fg_0"
- 0,  3, "base.fortress_bg"
+ 0,  3, "base.fortress_bg_0"
 ;[HH]
  0,  4, "city.disorder"
 ;[El]
diff --git a/data/isotrident/cities.spec b/data/isotrident/cities.spec
index 35f2cff845..1565bb160b 100644
--- a/data/isotrident/cities.spec
+++ b/data/isotrident/cities.spec
@@ -66,11 +66,11 @@ tiles = { "row", "column", "tag"
  0,  2, "tx.airbase_full"
  0,  3, "base.airstrip_mg_0"
  0,  4, "base.fortress_fg_0"
- 0,  5, "base.fortress_bg"
+ 0,  5, "base.fortress_bg_0"
  0,  6, "extra.ruins_mg_0"
  0,  7, "base.buoy_mg_0"
  0,  8, "base.outpost_fg_0"
- 0,  9, "base.outpost_bg"
+ 0,  9, "base.outpost_bg_0"
 
 ;
 ; city tiles
diff --git a/data/trident/tiles.spec b/data/trident/tiles.spec
index 34257564fe..fe37e5a762 100644
--- a/data/trident/tiles.spec
+++ b/data/trident/tiles.spec
@@ -504,7 +504,7 @@ tiles = { "row", "column", "tag"
  16,  9, "base.airstrip_mg_0"
  16, 10, "base.airbase_mg_0"
  16, 11, "base.outpost_mg_0"
- 16, 12, "base.fortress_bg"
+ 16, 12, "base.fortress_bg_0"
 
 ; Numbers: city size: (also used for goto)
 
-- 
2.45.2

