removing seeds and mallornseeds from the source (less warnings, too).

This commit is contained in:
Enno Rehling 2005-10-25 21:24:15 +00:00
parent ac30257333
commit abcaac8f97
6 changed files with 62 additions and 97 deletions

View File

@ -2385,7 +2385,7 @@ static void
planttrees(region *r, unit *u, int raw) planttrees(region *r, unit *u, int raw)
{ {
int n, i, skill, planted = 0; int n, i, skill, planted = 0;
const item_type * itype; const resource_type * rtype;
if (!fval(r->terrain, LAND_REGION)) { if (!fval(r->terrain, LAND_REGION)) {
return; return;
@ -2393,9 +2393,9 @@ planttrees(region *r, unit *u, int raw)
/* Mallornbäume kann man nur in Mallornregionen züchten */ /* Mallornbäume kann man nur in Mallornregionen züchten */
if (fval(r, RF_MALLORN)) { if (fval(r, RF_MALLORN)) {
itype = &it_mallornseed; rtype = rt_mallornseed;
} else { } else {
itype = &it_seed; rtype = rt_seed;
} }
/* Skill prüfen */ /* Skill prüfen */
@ -2403,22 +2403,21 @@ planttrees(region *r, unit *u, int raw)
if (skill < 6) { if (skill < 6) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "plant_skills", msg_feedback(u, u->thisorder, "plant_skills",
"skill minskill product", SK_HERBALISM, 6, itype->rtype, 1)); "skill minskill product", SK_HERBALISM, 6, rtype, 1));
return; return;
} }
if (fval(r, RF_MALLORN) && skill < 7 ) { if (fval(r, RF_MALLORN) && skill < 7 ) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "plant_skills", msg_feedback(u, u->thisorder, "plant_skills",
"skill minskill product", SK_HERBALISM, 7, itype->rtype, 1)); "skill minskill product", SK_HERBALISM, 7, rtype, 1));
return; return;
} }
n = new_get_pooled(u, itype->rtype, GET_DEFAULT); n = new_get_pooled(u, rtype, GET_DEFAULT);
/* Samen prüfen */ /* Samen prüfen */
if (n==0) { if (n==0) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing", msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
itype->rtype));
return; return;
} }
@ -2434,10 +2433,10 @@ planttrees(region *r, unit *u, int raw)
/* Alles ok. Abziehen. */ /* Alles ok. Abziehen. */
produceexp(u, SK_HERBALISM, u->number); produceexp(u, SK_HERBALISM, u->number);
new_use_pooled(u, itype->rtype, GET_DEFAULT, n); new_use_pooled(u, rtype, GET_DEFAULT, n);
ADDMSG(&u->faction->msgs, msg_message("plant", ADDMSG(&u->faction->msgs, msg_message("plant",
"unit region amount herb", u, r, planted, itype->rtype)); "unit region amount herb", u, r, planted, rtype));
} }
/* züchte bäume */ /* züchte bäume */
@ -2445,7 +2444,7 @@ static void
breedtrees(region *r, unit *u, int raw) breedtrees(region *r, unit *u, int raw)
{ {
int n, i, skill, planted = 0; int n, i, skill, planted = 0;
const item_type * itype; const resource_type * rtype;
static int current_season = -1; static int current_season = -1;
if (current_season<0) current_season = get_gamedate(turn, NULL)->season; if (current_season<0) current_season = get_gamedate(turn, NULL)->season;
@ -2462,9 +2461,9 @@ breedtrees(region *r, unit *u, int raw)
/* Mallornbäume kann man nur in Mallornregionen züchten */ /* Mallornbäume kann man nur in Mallornregionen züchten */
if (fval(r, RF_MALLORN)) { if (fval(r, RF_MALLORN)) {
itype = &it_mallornseed; rtype = rt_mallornseed;
} else { } else {
itype = &it_seed; rtype = rt_seed;
} }
/* Skill prüfen */ /* Skill prüfen */
@ -2473,12 +2472,11 @@ breedtrees(region *r, unit *u, int raw)
planttrees(r, u, raw); planttrees(r, u, raw);
return; return;
} }
n = new_get_pooled(u, itype->rtype, GET_DEFAULT); n = new_get_pooled(u, rtype, GET_DEFAULT);
/* Samen prüfen */ /* Samen prüfen */
if (n==0) { if (n==0) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing", msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
itype->rtype));
return; return;
} }
@ -2494,10 +2492,10 @@ breedtrees(region *r, unit *u, int raw)
/* Alles ok. Abziehen. */ /* Alles ok. Abziehen. */
produceexp(u, SK_HERBALISM, u->number); produceexp(u, SK_HERBALISM, u->number);
new_use_pooled(u, itype->rtype, GET_DEFAULT, n); new_use_pooled(u, rtype, GET_DEFAULT, n);
add_message(&u->faction->msgs, new_message(u->faction, add_message(&u->faction->msgs, new_message(u->faction,
"plant%u:unit%r:region%i:amount%X:herb", u, r, planted, itype->rtype)); "plant%u:unit%r:region%i:amount%X:herb", u, r, planted, rtype));
} }
static void static void
@ -2507,7 +2505,7 @@ plant_cmd(unit *u, struct order * ord)
int m; int m;
const char *s; const char *s;
param_t p; param_t p;
const item_type * itype = NULL; const resource_type * rtype = NULL;
if (r->land==NULL) { if (r->land==NULL) {
/* TODO: error message here */ /* TODO: error message here */
@ -2531,7 +2529,7 @@ plant_cmd(unit *u, struct order * ord)
p = P_ANY; p = P_ANY;
} else { } else {
p = findparam(s, u->faction->locale); p = findparam(s, u->faction->locale);
itype = finditemtype(s, u->faction->locale); rtype = findresourcetype(s, u->faction->locale);
} }
if (p==P_HERBS){ if (p==P_HERBS){
@ -2542,8 +2540,8 @@ plant_cmd(unit *u, struct order * ord)
breedtrees(r, u, m); breedtrees(r, u, m);
return; return;
} }
else if (itype!=NULL){ else if (rtype!=NULL){
if (itype==&it_mallornseed || itype==&it_seed) { if (rtype==rt_mallornseed || rtype==rt_seed) {
breedtrees(r, u, m); breedtrees(r, u, m);
return; return;
} }
@ -3240,6 +3238,6 @@ init_economy(void)
add_allocator(make_allocator(item2resource(olditemtype[I_STONE]), leveled_allocation)); add_allocator(make_allocator(item2resource(olditemtype[I_STONE]), leveled_allocation));
add_allocator(make_allocator(item2resource(olditemtype[I_IRON]), leveled_allocation)); add_allocator(make_allocator(item2resource(olditemtype[I_IRON]), leveled_allocation));
add_allocator(make_allocator(item2resource(olditemtype[I_LAEN]), leveled_allocation)); add_allocator(make_allocator(item2resource(olditemtype[I_LAEN]), leveled_allocation));
add_allocator(make_allocator(&rt_seed, attrib_allocation)); add_allocator(make_allocator(rt_seed, attrib_allocation));
add_allocator(make_allocator(&rt_mallornseed, attrib_allocation)); add_allocator(make_allocator(rt_mallornseed, attrib_allocation));
} }

View File

@ -27,37 +27,20 @@
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
resource_type rt_seed = { resource_type * rt_seed = 0;
{ "seed", "seed_p" }, resource_type * rt_mallornseed = 0;
{ "seed", "seed_p" },
RTF_ITEM|RTF_LIMITED,
&res_changeitem
};
static construction con_seed = {
SK_HERBALISM, 3, /* skill, minskill */
-1, 1 /* maxsize, reqsize [,materials] */
};
item_type it_seed = {
&rt_seed, /* resourcetype */
0, 10, 0, /* flags, weight, capacity */
&con_seed, /* construction */
NULL, /* use */
NULL /* give */
};
static void static void
produce_seeds(region * r, const resource_type * rtype, int norders) produce_seeds(region * r, const resource_type * rtype, int norders)
{ {
assert(rtype==&rt_seed && r->land && r->land->trees[0] >= norders); assert(rtype==rt_seed && r->land && r->land->trees[0] >= norders);
r->land->trees[0] -= norders; r->land->trees[0] -= norders;
} }
static int static int
limit_seeds(const region * r, const resource_type * rtype) limit_seeds(const region * r, const resource_type * rtype)
{ {
assert(rtype==&rt_seed); assert(rtype==rt_seed);
if(fval(r, RF_MALLORN)) return 0; if(fval(r, RF_MALLORN)) return 0;
return r->land?r->land->trees[0]:0; return r->land?r->land->trees[0]:0;
} }
@ -66,46 +49,24 @@ void
register_seed(void) register_seed(void)
{ {
attrib * a; attrib * a;
resource_limit * rdata;
it_register(&it_seed); rt_seed = rt_find("seed");
it_seed.rtype->flags |= RTF_LIMITED; assert(rt_seed!=NULL);
it_seed.rtype->itype->flags |= ITF_NOBUILDBESIEGED; rt_seed->itype->flags |= ITF_NOBUILDBESIEGED;
it_seed.rtype->flags |= RTF_POOLED;
a = a_add(&it_seed.rtype->attribs, a_new(&at_resourcelimit)); a = a_add(&rt_seed->attribs, a_new(&at_resourcelimit));
{ rdata = (resource_limit*)a->data.v;
resource_limit * rdata = (resource_limit*)a->data.v;
rdata->limit = limit_seeds; rdata->limit = limit_seeds;
rdata->use = produce_seeds; rdata->use = produce_seeds;
} }
}
/* mallorn */ /* mallorn */
resource_type rt_mallornseed = {
{ "mallornseed", "mallornseed_p" },
{ "mallornseed", "mallornseed_p" },
RTF_ITEM|RTF_LIMITED,
&res_changeitem
};
static construction con_mallornseed = {
SK_HERBALISM, 4, /* skill, minskill */
-1, 1 /* maxsize, reqsize [,materials] */
};
item_type it_mallornseed = {
&rt_mallornseed, /* resourcetype */
0, 10, 0, /* flags, weight, capacity */
&con_mallornseed, /* construction */
NULL, /* use */
NULL /* give */
};
static void static void
produce_mallornseeds(region * r, const resource_type * rtype, int norders) produce_mallornseeds(region * r, const resource_type * rtype, int norders)
{ {
assert(rtype==&rt_mallornseed && r->land && r->land->trees[0] >= norders); assert(rtype==rt_mallornseed && r->land && r->land->trees[0] >= norders);
assert(fval(r, RF_MALLORN)); assert(fval(r, RF_MALLORN));
r->land->trees[0] -= norders; r->land->trees[0] -= norders;
} }
@ -113,7 +74,7 @@ produce_mallornseeds(region * r, const resource_type * rtype, int norders)
static int static int
limit_mallornseeds(const region * r, const resource_type * rtype) limit_mallornseeds(const region * r, const resource_type * rtype)
{ {
assert(rtype==&rt_mallornseed); assert(rtype==rt_mallornseed);
if (!fval(r, RF_MALLORN)) { if (!fval(r, RF_MALLORN)) {
return 0; return 0;
} }
@ -124,20 +85,16 @@ void
register_mallornseed(void) register_mallornseed(void)
{ {
attrib * a; attrib * a;
resource_limit * rdata;
it_register(&it_mallornseed); rt_mallornseed = rt_find("mallornseed");
it_mallornseed.rtype->flags |= RTF_LIMITED; assert(rt_mallornseed!=NULL);
it_mallornseed.rtype->itype->flags |= ITF_NOBUILDBESIEGED; rt_mallornseed->flags |= RTF_LIMITED;
it_mallornseed.rtype->flags |= RTF_POOLED; rt_mallornseed->itype->flags |= ITF_NOBUILDBESIEGED;
register_function((pf_generic)limit_seeds, "limit_seeds"); rt_mallornseed->flags |= RTF_POOLED;
register_function((pf_generic)produce_seeds, "produce_seeds");
register_function((pf_generic)limit_mallornseeds, "limit_mallornseeds");
register_function((pf_generic)produce_mallornseeds, "produce_mallornseeds");
a = a_add(&it_mallornseed.rtype->attribs, a_new(&at_resourcelimit)); a = a_add(&rt_mallornseed->attribs, a_new(&at_resourcelimit));
{ rdata = (resource_limit*)a->data.v;
resource_limit * rdata = (resource_limit*)a->data.v;
rdata->limit = limit_mallornseeds; rdata->limit = limit_mallornseeds;
rdata->use = produce_mallornseeds; rdata->use = produce_mallornseeds;
} }
}

View File

@ -19,12 +19,10 @@ extern "C" {
#endif #endif
extern struct item_type it_seed; extern struct resource_type * rt_seed;
extern struct resource_type rt_seed;
extern void register_seed(void); extern void register_seed(void);
extern struct item_type it_mallornseed; extern struct resource_type * rt_mallornseed;
extern struct resource_type rt_mallornseed;
extern void register_mallornseed(void); extern void register_mallornseed(void);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -821,6 +821,7 @@ parse_resources(xmlDocPtr doc)
int k; int k;
if (xml_bvalue(node, "pooled", true)) flags |= RTF_POOLED; if (xml_bvalue(node, "pooled", true)) flags |= RTF_POOLED;
if (xml_bvalue(node, "limited", false)) flags |= RTF_LIMITED;
if (xml_bvalue(node, "sneak", true)) flags |= RTF_SNEAK; if (xml_bvalue(node, "sneak", true)) flags |= RTF_SNEAK;
name = xmlGetProp(node, BAD_CAST "name"); name = xmlGetProp(node, BAD_CAST "name");

View File

@ -7,6 +7,16 @@
</item> </item>
</resource> </resource>
<resource name="seed" limited="yes">
<item weight="10" score="50"/>
<construction skill="herbalism" minskill="3" reqsize="1"/>
</resource>
<resource name="mallornseed" limited="yes">
<item weight="10" score="100"/>
<construction skill="herbalism" minskill="4" reqsize="1"/>
</resource>
<resource name="antimagic" appearance="amulet"> <resource name="antimagic" appearance="amulet">
<item weight="0" score="2000"> <item weight="0" score="2000">
<function name="use" value="use_antimagiccrystal"/> <function name="use" value="use_antimagiccrystal"/>

View File

@ -16,6 +16,7 @@ Code cleanup:
- age branch (store birthdate instead of age) - age branch (store birthdate instead of age)
- give monsters name with lua - give monsters name with lua
- kick init_oldherbs out (good for terrain) - kick init_oldherbs out (good for terrain)
- allocators aus economy nach XML
Larger Features: Larger Features:
- eressea (b/g)zip reports? - eressea (b/g)zip reports?