forked from github/server
strip rawmaterial_type to just the funpointers
This commit is contained in:
parent
1498f2e1d7
commit
f4dc88c3be
|
@ -1242,6 +1242,9 @@ void free_rtype(resource_type *rtype) {
|
|||
if (rtype->itype) {
|
||||
free_itype(rtype->itype);
|
||||
}
|
||||
if (rtype->raw) {
|
||||
free(rtype->raw);
|
||||
}
|
||||
free(rtype->_name);
|
||||
free(rtype);
|
||||
}
|
||||
|
|
|
@ -183,14 +183,13 @@ struct rawmaterial *rm_get(region * r, const struct resource_type *rtype)
|
|||
return rm;
|
||||
}
|
||||
|
||||
struct rawmaterial_type *rawmaterialtypes = 0;
|
||||
|
||||
struct rawmaterial_type *rmt_find(const char *str)
|
||||
{
|
||||
rawmaterial_type *rmt = rawmaterialtypes;
|
||||
while (rmt && strcmp(rmt->name, str) != 0)
|
||||
rmt = rmt->next;
|
||||
return rmt;
|
||||
resource_type *rtype = rt_find(str);
|
||||
if (!rtype && strncmp(str, "rm_", 3) == 0) {
|
||||
rtype = rt_find(str+3);
|
||||
}
|
||||
return rtype ? rtype->raw : NULL;
|
||||
}
|
||||
|
||||
struct rawmaterial_type *rmt_get(const struct resource_type *rtype)
|
||||
|
@ -205,13 +204,10 @@ struct rawmaterial_type *rmt_create(struct resource_type *rtype,
|
|||
|
||||
assert(!rtype->raw);
|
||||
rmtype = rtype->raw = malloc(sizeof(rawmaterial_type));
|
||||
rmtype->name = strdup(name);
|
||||
rmtype->rtype = rtype;
|
||||
rmtype->terraform = terraform_default;
|
||||
rmtype->update = NULL;
|
||||
rmtype->use = use_default;
|
||||
rmtype->visible = visible_default;
|
||||
rmtype->next = rawmaterialtypes;
|
||||
rawmaterialtypes = rmtype;
|
||||
return rmtype;
|
||||
}
|
||||
|
|
|
@ -63,16 +63,12 @@ extern "C" {
|
|||
} resource_limit;
|
||||
|
||||
typedef struct rawmaterial_type {
|
||||
char *name;
|
||||
const struct resource_type *rtype;
|
||||
|
||||
void(*terraform) (struct rawmaterial *, const struct region *);
|
||||
void(*update) (struct rawmaterial *, const struct region *);
|
||||
void(*use) (struct rawmaterial *, const struct region *, int amount);
|
||||
int(*visible) (const struct rawmaterial *, int skilllevel);
|
||||
|
||||
/* no initialization required */
|
||||
struct rawmaterial_type *next;
|
||||
} rawmaterial_type;
|
||||
|
||||
extern struct rawmaterial_type *rawmaterialtypes;
|
||||
|
|
|
@ -1068,7 +1068,7 @@ void writeregion(struct gamedata *data, const region * r)
|
|||
WRITE_INT(data->store, rhorses(r));
|
||||
|
||||
while (res) {
|
||||
WRITE_TOK(data->store, res->type->name);
|
||||
WRITE_TOK(data->store, res->type->rtype->_name);
|
||||
WRITE_INT(data->store, res->level);
|
||||
WRITE_INT(data->store, res->amount);
|
||||
WRITE_INT(data->store, res->startlevel);
|
||||
|
|
|
@ -412,32 +412,32 @@ const faction * viewer, bool see_unit)
|
|||
if (money) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, "rm_money", money, -1);
|
||||
report_resource(result + n, "money", money, -1);
|
||||
++n;
|
||||
}
|
||||
if (peasants) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, "rm_peasant", peasants, -1);
|
||||
report_resource(result + n, "peasant", peasants, -1);
|
||||
++n;
|
||||
}
|
||||
if (horses) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, "rm_horse", horses, -1);
|
||||
report_resource(result + n, "horse", horses, -1);
|
||||
++n;
|
||||
}
|
||||
if (saplings) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, mallorn ? "rm_mallornsapling" : "rm_sapling",
|
||||
report_resource(result + n, mallorn ? "mallornsapling" : "sapling",
|
||||
saplings, -1);
|
||||
++n;
|
||||
}
|
||||
if (trees) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, mallorn ? "rm_mallorn" : "rm_tree", trees,
|
||||
report_resource(result + n, mallorn ? "mallorn" : "tree", trees,
|
||||
-1);
|
||||
++n;
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ const faction * viewer, bool see_unit)
|
|||
if (level >= 0 && visible >= 0) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, res->type->name, visible, level);
|
||||
report_resource(result + n, res->type->rtype->_name, visible, level);
|
||||
n++;
|
||||
}
|
||||
res = res->next;
|
||||
|
|
Loading…
Reference in New Issue