Ejemplo n.º 1
0
bool overmapbuffer::has_horde(int const x, int const y, int const z) {
    for (auto const &m : overmap_buffer.monsters_at(x, y, z)) {
        if (m->horde) {
            return true;
        }
    }

    return false;
}
Ejemplo n.º 2
0
bool overmapbuffer::has_horde( const int x, const int y, const int z )
{
    for( const auto &m : overmap_buffer.monsters_at( x, y, z ) ) {
        if( m->horde ) {
            return true;
        }
    }

    return false;
}
Ejemplo n.º 3
0
int overmapbuffer::get_horde_size( const int x, const int y, const int z )
{
    int horde_size = 0;
    for( const auto &m : overmap_buffer.monsters_at( x, y, z ) ) {
        if( m->horde ) {
            if( !m->monsters.empty() ) {
                horde_size += m->monsters.size();
            } else {
                // We don't know how large this will actually be, because
                // population "1" can still result in a zombie pack.
                // So we double the population as an estimate to make
                // hordes more likely to be visible on the overmap.
                horde_size += m->population * 2;
            }
        }
    }

    return horde_size;
}
Ejemplo n.º 4
0
const overmap *overmapbuffer::get_existing(int x, int y) const
{
    if (last_requested_overmap != NULL && last_requested_overmap->pos().x == x && last_requested_overmap->pos().y == y) {
        return last_requested_overmap;
    }
    for(std::list<overmap>::const_iterator candidate = overmap_list.begin();
        candidate != overmap_list.end(); ++candidate)
    {
        if(candidate->pos().x == x && candidate->pos().y == y)
        {
            return last_requested_overmap = &*candidate;
        }
    }
    if (known_non_existing.count(point(x, y)) > 0) {
        // This overmap does not exist on disk (this has already been
        // checked in a previous call of this function).
        return NULL;
    }
    // Check if the overmap exist on disk,
    // overmap(0,0) should always exist, we need it for the proper
    // overmap file name.
    overmap &om = overmap_buffer.get(0, 0);
    const std::string filename = om.terrain_filename(x, y);
    std::ifstream tmp(filename.c_str(), std::ios::in);
    if(tmp) {
        // File exists, load it normally (the get function
        // indirectly call overmap::open to do so).
        tmp.close();
        return &const_cast<overmapbuffer*>(this)->get(x, y);
    }
    // File does not exist (or not readable which is essentially
    // the same for our usage). A second call of this function with
    // the same coordinates will not check the file system, and
    // return early.
    // If the overmap had been created in the mean time, the previous
    // loop would have found and returned it.
    known_non_existing.insert(point(x, y));
    return NULL;
}
Ejemplo n.º 5
0
std::vector<mongroup*> overmapbuffer::monsters_at(int x, int y, int z)
{
    const overmap* om = overmap_buffer.get_existing_om_global(x, y);
    point p = omt_to_sm_copy(x, y);
    return const_cast<overmap*>(om)->monsters_at(p.x, p.y, z);
}