Пример #1
0
static void wall_vigour(curse * c, double delta)
{
    wallcurse *wc = (wallcurse *)c->data.v;
    assert(wc->buddy->vigour == c->vigour);
    wc->buddy->vigour += delta;
    if (wc->buddy->vigour <= 0) {
        erase_border(wc->wall);
        wc->wall = NULL;
        ((wallcurse *)wc->buddy->data.v)->wall = NULL;
    }
}
Пример #2
0
void age_borders(void)
{
    quicklist *deleted = NULL, *ql;
    int i;

    for (i = 0; i != BORDER_MAXHASH; ++i) {
        connection *bhash = borders[i];
        for (; bhash; bhash = bhash->nexthash) {
            connection *b = bhash;
            for (; b; b = b->next) {
                if (b->type->age) {
                    if (b->type->age(b) == AT_AGE_REMOVE) {
                        ql_push(&deleted, b);
                    }
                }
            }
        }
    }
    for (ql = deleted, i = 0; ql; ql_advance(&ql, &i, 1)) {
        connection *b = (connection *)ql_get(ql, i);
        erase_border(b);
    }
    ql_free(deleted);
}
Пример #3
0
int read_borders(struct storage *store)
{
  for (;;) {
    int bid = 0;
    char zText[32];
    connection *b;
    region *from, *to;
    border_type *type;

    READ_TOK(store, zText, sizeof(zText));
    if (!strcmp(zText, "end"))
      break;
    READ_INT(store, &bid);
    if (global.data_version < UIDHASH_VERSION) {
      int fx, fy, tx, ty;
      READ_INT(store, &fx);
      READ_INT(store, &fy);
      READ_INT(store, &tx);
      READ_INT(store, &ty);
      from = findregion(fx, fy);
      to = findregion(tx, ty);
    } else {
      int fid, tid;
      READ_INT(store, &fid);
      READ_INT(store, &tid);
      from = findregionbyid(fid);
      to = findregionbyid(tid);
    }

    type = find_bordertype(zText);
    if (type == NULL) {
      log_error("[read_borders] unknown connection type '%s' in %s\n", zText, regionname(from, NULL));
      assert(type || !"connection type not registered");
    }

    if (to == from && type && from) {
      direction_t dir = (direction_t) (rng_int() % MAXDIRECTIONS);
      region *r = rconnect(from, dir);
      log_error("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL));
      if (r != NULL)
        to = r;
    }
    b = new_border(type, from, to);
    nextborder--;               /* new_border erhöht den Wert */
    b->id = bid;
    assert(bid <= nextborder);
    if (type->read)
      type->read(b, store);
    if (global.data_version < NOBORDERATTRIBS_VERSION) {
      attrib *a = NULL;
      int result = a_read(store, &a, b);
      if (border_convert_cb)
        border_convert_cb(b, a);
      while (a) {
        a_remove(&a, a);
      }
      if (result < 0)
        return result;
    }
    if ((type->read && !type->write) || !to || !from) {
      log_warning("erase invalid border '%s' between '%s' and '%s'\n", type->__name, regionname(from, 0), regionname(to, 0));
      erase_border(b);
    }
  }
  return 0;
}