From 911644350c54c72c243a774ee39f9673c01eb134 Mon Sep 17 00:00:00 2001
From: Yona-TYT <yonatan.el.amigo@gmail.com>
Date: Mon, 28 Nov 2022 00:21:34 -0400
Subject: [PATCH] CHG Get tile list in factory_x

---
 src/simutrans/script/api/api_factory.cc              | 12 ++++++++++--
 src/simutrans/script/api/squirrel_types_scenario.awk |  2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/simutrans/script/api/api_factory.cc b/src/simutrans/script/api/api_factory.cc
index dc2688ba0..0ef37a168 100644
--- a/src/simutrans/script/api/api_factory.cc
+++ b/src/simutrans/script/api/api_factory.cc
@@ -99,11 +99,19 @@ uint32 get_consumption_factor(const factory_supplier_desc_t *desc)
 }
 
 
-vector_tpl<koord> const& factory_get_tile_list(fabrik_t *fab)
+vector_tpl<grund_t*> const& factory_get_tile_list(fabrik_t *fab)
 {
 	static vector_tpl<koord> list;
 	fab->get_tile_list(list);
-	return list;
+
+	static vector_tpl<grund_t*> tile_list;
+	tile_list.clear();
+	for(  uint32 i=0;  i<list.get_count();  i++  ) {
+		const koord k = list[i];
+		grund_t *gr=welt->lookup_kartenboden(k);
+		tile_list.append( gr );
+	}
+	return tile_list;
 }
 
 vector_tpl<grund_t*> const& factory_get_fields_list(fabrik_t *fab)
diff --git a/src/simutrans/script/api/squirrel_types_scenario.awk b/src/simutrans/script/api/squirrel_types_scenario.awk
index 264b7da07..7ccebccee 100644
--- a/src/simutrans/script/api/squirrel_types_scenario.awk
+++ b/src/simutrans/script/api/squirrel_types_scenario.awk
@@ -89,7 +89,7 @@ BEGIN {
 	export_types_scenario["factory_x::get_mail_generated"] = "array<integer>()"
 	export_types_scenario["factory_x::get_mail_departed"] = "array<integer>()"
 	export_types_scenario["factory_x::get_mail_arrived"] = "array<integer>()"
-	export_types_scenario["factory_x::get_tile_list"] = "array<coord>()"
+	export_types_scenario["factory_x::get_tile_list"] = "array<tile_x>()"
 	export_types_scenario["factory_x::get_tile_fields_list"] = "array<tile_x>()"
 	export_types_scenario["factory_x::get_halt_list"] = "array<halt_x>()"
 	export_types_scenario["factory_x::is_transformer_connected"] = "bool()"
-- 
2.38.1

