--- /home/yonatyt/simu-git/simutrans-master/obj/gebaeude.cc 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/gebaeude.cc 2021-08-22 23:19:11.152127000 -0400 @@ -1041,3 +1041,22 @@ mark_image_dirty( img, -(i*get_tile_raster_width()) ); } } + +void gebaeude_t::get_tile_list( vector_tpl &tile_list, koord3d pos) const +{ + tile_list.clear(); + + if (const building_desc_t* desc = this->get_tile()->get_desc()) { + koord pos_2d = pos.get_2d(); + koord size = desc->get_size(desc->get_all_layouts()); + koord test; + + for( test.x = 0; test.x < size.x; test.x++ ) { + for( test.y = 0; test.y < size.y; test.y++ ) { + if( desc->get_tile(desc->get_all_layouts(), test.x + pos_2d.x, test.y + pos_2d.y)->get_desc() == desc ) { + tile_list.append( test ); + } + } + } + } +} --- /home/yonatyt/simu-git/simutrans-master/obj/gebaeude.h 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/gebaeude.h 2021-08-22 23:20:29.232150000 -0400 @@ -167,6 +167,8 @@ * @returns true if both building tiles are part of one (multi-tile) building. */ bool is_same_building(const gebaeude_t* other) const; + + void get_tile_list( vector_tpl &tile_list, koord3d pos) const; }; --- /home/yonatyt/simu-git/simutrans-master/script/api/api_map_objects.cc 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/api_map_objects.cc 2021-08-22 23:17:54.156153000 -0400 @@ -447,6 +447,17 @@ return v; } +vector_tpl const& build_get_tile_list(koord3d pos) +{ + static vector_tpl list; + + if( grund_t* gr = welt->lookup( pos ) ) { + gebaeude_t *gb = gr->find(); + gb->get_tile_list( list, pos ); + } + return list; +} + void export_map_objects(HSQUIRRELVM vm) { /** @@ -568,6 +579,11 @@ * @returns true if both building tiles are part of one (multi-tile) building */ register_method(vm, &gebaeude_t::is_same_building, "is_same_building"); + /** + * Get list of all tiles occupied by buildings. + * @returns array of tile_x objects + */ + register_method(vm, &build_get_tile_list, "get_tile_list", true); end_class(vm); --- /home/yonatyt/simu-git/simutrans-master/script/api/squirrel_types_scenario.awk 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/squirrel_types_scenario.awk 2021-08-22 22:53:19.044575000 -0400 @@ -234,6 +234,7 @@ export_types["building_x::get_mail_level"] = "integer()" export_types["building_x::get_desc"] = "building_desc_x()" export_types["building_x::is_same_building"] = "bool(building_x)" + export_types["building_x::get_tile_list"] = "array()" export_types["depot_x::append_vehicle"] = "void(player_x, convoy_x, vehicle_desc_x)" export_types["depot_x::start_convoy"] = "void(player_x, convoy_x)" export_types["depot_x::start_all_convoys"] = "void(player_x)"