News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

factory_x :: get_tile_list () Has a misleading name

Started by Yona-TYT, August 25, 2021, 06:32:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

In the documentation it indicates that:
Quote
Get list of all tiles occupied by buildings belonging to this factory.
      Returns array of tile_x 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 );
            }
        }
    }
}


prissi

Since factories are building, the factory version would be no longer needed.

Yona-TYT

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.

Dwachs

Versions for both factory and buildings are needed, as the factory squirrel class is not derived from the building class.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

I wonder why it's called "get_tile_list", shouldn't it be better to call it get_coord_list?.

prissi

I submitted the tile list in r10094. I strongly suggest only using the tile list for buildings, even for factories, because of returning koord3d.

Yona-TYT

Sounds reasonable to me, thanks for implementing @prissi . :D