In the documentation it indicates that:
Quote
Get list of all tiles occupied by buildings belonging to this factory.
Returns array of tile_x (http://dwachs.github.io/simutrans-sqapi-doc/classtile__x.html) objects
But this is not true since what is obtained is an array of coordinates.
So, wouldn't it be better to change to get_coord_list ()?.
Also, I think it would be more useful to get a "coord3d" than a "coord" in my humble opinion, as @prissi did here: https://forum.simutrans.com/index.php/topic,21093.msg196741.html#msg196741
void fabrik_t::get_tile_list( vector_tpl<koord> &tile_list ) const
{
tile_list.clear();
koord pos_2d = pos.get_2d();
koord size = this->get_desc()->get_building()->get_size(this->get_rotate());
koord test;
// Which tiles belong to the fab?
for( test.x = 0; test.x < size.x; test.x++ ) {
for( test.y = 0; test.y < size.y; test.y++ ) {
if( fabrik_t::get_fab( pos_2d+test ) == this ) {
tile_list.append( pos_2d+test );
}
}
}
}
Since factories are building, the factory version would be no longer needed.
Quote from: prissi on August 26, 2021, 08:01:26 AM
Since factories are building, the factory version would be no longer needed.
I have no problem getting rid of this, but we need @Dwachs opinion here.
Versions for both factory and buildings are needed, as the factory squirrel class is not derived from the building class.
I wonder why it's called "get_tile_list", shouldn't it be better to call it get_coord_list?.
I submitted the tile list in r10094. I strongly suggest only using the tile list for buildings, even for factories, because of returning koord3d.
Sounds reasonable to me, thanks for implementing @prissi . :D