From 2f9d761cbd8b0f76b65b807a47983482779de715 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 24 May 2025 17:22:43 +0300
Subject: [PATCH 79/79] tiledef: Add tile_matches_tiledef() function

See RM #1444

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/tiledef.c | 14 ++++++++++++++
 common/tiledef.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/common/tiledef.c b/common/tiledef.c
index f6bdf4a033..e91eeacf18 100644
--- a/common/tiledef.c
+++ b/common/tiledef.c
@@ -142,3 +142,17 @@ struct tiledef *tiledef_by_translated_name(const char *name)
 
   return nullptr;
 }
+
+/************************************************************************//**
+  Check if tile matches tiledef
+****************************************************************************/
+bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile)
+{
+  extra_type_list_iterate(td->extras, pextra) {
+    if (!tile_has_extra(ptile, pextra)) {
+      return FALSE;
+    }
+  } extra_type_list_iterate_end;
+
+  return TRUE;
+}
diff --git a/common/tiledef.h b/common/tiledef.h
index 418f7e5a0c..d394d2d90a 100644
--- a/common/tiledef.h
+++ b/common/tiledef.h
@@ -55,6 +55,9 @@ struct tiledef *tiledef_by_translated_name(const char *name);
   }                                               \
 }
 
+bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile)
+  fc__attribute((nonnull (1, 2)));
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
-- 
2.47.2

