示例#1
0
    item_on_vehicle( vehicle &v, const point &where, const item *which )
    {
        veh = &v;
        local_coords = where;
        for( const int i : v.parts_at_relative( where.x, where.y ) ) {
            for( item &it : v.get_items( i ) ) {
                if( &it == which ) {
                    partnum = i;
                    what = ⁢
                    return;
                }
            }
        }

        debugmsg( "Tried to find an item on vehicle %s, tile %d:%d, but it wasn't there",
                  veh->name.c_str(), local_coords.x, local_coords.y );
        what = nullptr;
    }
示例#2
0
    item *get_item() override
    {
        if( what == nullptr ) {
            return nullptr;
        }

        const auto parts = veh->parts_at_relative( local_coords.x, local_coords.y );
        for( const int i : parts ) {
            for( item &it : veh->get_items( i ) ) {
                if( &it == what ) {
                    return ⁢
                }
            }
        }

        debugmsg( "Tried to find an item on vehicle %s, tile %d:%d, but it wasn't there",
                  veh->name.c_str(), local_coords.x, local_coords.y );
        what = nullptr;
        return nullptr;
    }