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