Ejemplo n.º 1
0
overmap &overmapbuffer::get( const int x, const int y )
{
    const point p { x, y };

    if( last_requested_overmap != nullptr && last_requested_overmap->pos() == p ) {
        return *last_requested_overmap;
    }

    const auto it = overmaps.find( p );
    if( it != overmaps.end() ) {
        return *( last_requested_overmap = it->second.get() );
    }

    // That constructor loads an existing overmap or creates a new one.
    overmap *new_om = new overmap( x, y );
    overmaps[ p ] = std::unique_ptr<overmap>( new_om );
    new_om->populate();
    // Note: fix_mongroups might load other overmaps, so overmaps.back() is not
    // necessarily the overmap at (x,y)
    fix_mongroups( *new_om );
    fix_npcs( *new_om );

    last_requested_overmap = new_om;
    return *new_om;
}
Ejemplo n.º 2
0
overmap &overmapbuffer::get( const int x, const int y )
{
    auto it = overmaps.find( point( x, y ) );
    if( it != overmaps.end() ) {
        return *(it->second);
    }
    // That constructor loads an existing overmap or creates a new one.
    std::unique_ptr<overmap> new_om( new overmap( x, y ) );
    overmap &result = *new_om;
    overmaps[ new_om->pos() ] = std::move( new_om );
    // Note: fix_mongroups might load other overmaps, so overmaps.back() is not
    // necessarily the overmap at (x,y)
    fix_mongroups( result );
    return result;
}
Ejemplo n.º 3
0
overmap &overmapbuffer::get( const int x, const int y )
{
    point const p {x, y};

    if (last_requested_overmap && last_requested_overmap->pos() == p) {
        return *last_requested_overmap;
    }

    auto const it = overmaps.find( p );
    if( it != overmaps.end() ) {
        return *(last_requested_overmap = it->second.get());
    }

    // That constructor loads an existing overmap or creates a new one.
    std::unique_ptr<overmap> new_om( new overmap( x, y ) );
    overmap &result = *new_om;
    overmaps[ new_om->pos() ] = std::move( new_om );
    // Note: fix_mongroups might load other overmaps, so overmaps.back() is not
    // necessarily the overmap at (x,y)
    fix_mongroups( result );

    last_requested_overmap = &result;
    return result;
}