Exemple #1
0
void curse_write(const attrib * a, const void *owner, struct storage *store)
{
  unsigned int flags;
  curse *c = (curse *) a->data.v;
  const curse_type *ct = c->type;
  unit *mage = (c->magician && c->magician->number) ? c->magician : NULL;

  /* copied from c_clearflag */
  flags = (c->flags & ~CURSE_ISNEW) | (c->type->flags & CURSE_ISNEW);

  WRITE_INT(store, c->no);
  WRITE_TOK(store, ct->cname);
  WRITE_INT(store, flags);
  WRITE_INT(store, c->duration);
  WRITE_FLT(store, (float)c->vigour);
  write_unit_reference(mage, store);
  WRITE_FLT(store, (float)c->effect);

  if (c->type->write)
    c->type->write(store, c, owner);
  else if (c->type->typ == CURSETYP_UNIT) {
    WRITE_INT(store, c->data.i);
  }
  if (c->type->typ == CURSETYP_REGION) {
    write_region_reference((region *) c->data.v, store);
  }
}
Exemple #2
0
static void createunit_write(const trigger * t, struct storage *store)
{
    createunit_data *td = (createunit_data *)t->data.v;
    write_faction_reference(td->f, store);
    write_region_reference(td->r, store);
    write_race_reference(td->race, store);
    WRITE_INT(store, td->number);
}
Exemple #3
0
static void gate_write(const trigger * t, struct storage *store)
{
  gate_data *gd = (gate_data *) t->data.v;
  building *b = gd->gate;
  region *r = gd->target;

  write_building_reference(b, store);
  write_region_reference(r, store);
}
Exemple #4
0
static void
object_write(const attrib * a, const void *owner, struct storage *store)
{
  const object_data *data = (object_data *) a->data.v;
  int type = (int)data->type;
  WRITE_TOK(store, data->name);
  WRITE_INT(store, type);
  switch (data->type) {
    case TINTEGER:
      WRITE_INT(store, data->data.i);
      break;
    case TREAL:
      WRITE_FLT(store, (float)data->data.real);
      break;
    case TSTRING:
      WRITE_STR(store, data->data.str);
      break;
    case TUNIT:
      write_unit_reference(data->data.u, store);
      break;
    case TFACTION:
      write_faction_reference(data->data.f, store);
      break;
    case TBUILDING:
      write_building_reference(data->data.b, store);
      break;
    case TSHIP:
      /* write_ship_reference(data->data.sh, store); */
      assert(!"not implemented");
      break;
    case TREGION:
      write_region_reference(data->data.r, store);
      break;
    case TNONE:
      break;
    default:
      assert(!"illegal type in object-attribute");
  }
}
Exemple #5
0
static void
write_targetregion(const variant *var, const void *owner, struct storage *store)
{
    write_region_reference((region *)var->v, store);
}
Exemple #6
0
static void wormhole_write(const struct attrib *a, const void *owner, struct storage *store)
{
    wormhole_data *data = (wormhole_data *)a->data.v;
    write_building_reference(data->entry, store);
    write_region_reference(data->exit, store);
}