The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Yona-TYT on August 25, 2021, 06:32:32 PM

Title: factory_x :: get_tile_list () Has a misleading name
Post by: Yona-TYT on August 25, 2021, 06:32:32 PM
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 );
            }
        }
    }
}

Title: Re: factory_x :: get_tile_list () Has a misleading name
Post by: prissi on August 26, 2021, 08:01:26 AM
Since factories are building, the factory version would be no longer needed.
Title: Re: factory_x :: get_tile_list () Has a misleading name
Post by: Yona-TYT on August 27, 2021, 06:48:55 PM
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.
Title: Re: factory_x :: get_tile_list () Has a misleading name
Post by: Dwachs on September 03, 2021, 12:23:55 PM
Versions for both factory and buildings are needed, as the factory squirrel class is not derived from the building class.
Title: Re: factory_x :: get_tile_list () Has a misleading name
Post by: Yona-TYT on September 04, 2021, 02:25:17 PM
I wonder why it's called "get_tile_list", shouldn't it be better to call it get_coord_list?.
Title: Re: factory_x :: get_tile_list () Has a misleading name
Post by: prissi on September 12, 2021, 01:29:15 AM
I submitted the tile list in r10094. I strongly suggest only using the tile list for buildings, even for factories, because of returning koord3d.
Title: Re: factory_x :: get_tile_list () Has a misleading name
Post by: Yona-TYT on September 12, 2021, 01:38:52 AM
Sounds reasonable to me, thanks for implementing @prissi . :D