static int useonother_trappedairelemental(struct unit *u, int shipId, const struct item_type *itype, int amount, struct order *ord) { curse *c; ship *sh; if (shipId <= 0) { cmistake(u, ord, 20, MSG_MOVE); return -1; } sh = findshipr(u->region, shipId); if (!sh) { cmistake(u, ord, 20, MSG_MOVE); return -1; } c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, SPEEDUP, 0); c_setflag(c, CURSE_NOAGE); ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success", "unit region command ship", u, u->region, ord, sh)); use_pooled(u, itype->rtype, GET_DEFAULT, 1); return 0; }
int curse_read(attrib * a, void *owner, struct storage *store) { curse *c = (curse *) a->data.v; int ur; char cursename[64]; int n; int flags; float flt; READ_INT(store, &c->no); chash(c); READ_TOK(store, cursename, sizeof(cursename)); READ_INT(store, &flags); READ_INT(store, &c->duration); if (global.data_version >= CURSEVIGOURISFLOAT_VERSION) { READ_FLT(store, &flt); c->vigour = flt; } else { READ_INT(store, &n); c->vigour = (float)n; } if (global.data_version < INTPAK_VERSION) { ur = read_reference(&c->magician, store, read_int, resolve_unit); } else { ur = read_reference(&c->magician, store, read_unit_reference, resolve_unit); } if (global.data_version < CURSEFLOAT_VERSION) { READ_INT(store, &n); c->effect = (float)n; } else { READ_FLT(store, &flt); c->effect = flt; } c->type = ct_find(cursename); if (c->type == NULL) { int result = read_ccompat(cursename, store); if (result != 0) { log_error("missing curse %s, no compatibility code either.\n", cursename); } assert(result == 0); return AT_READ_FAIL; } if (global.data_version < CURSEFLAGS_VERSION) { c_setflag(c, flags); } else { c->flags = flags; } c_clearflag(c, CURSE_ISNEW); if (c->type->read) c->type->read(store, c, owner); else if (c->type->typ == CURSETYP_UNIT) { READ_INT(store, &c->data.i); } if (c->type->typ == CURSETYP_REGION) { int rr = read_reference(&c->data.v, store, read_region_reference, RESOLVE_REGION(global.data_version)); if (ur == 0 && rr == 0 && !c->data.v) { return AT_READ_FAIL; } } return AT_READ_OK; }