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)
{
int n, i, skill, planted = 0;
const item_type * itype;
const resource_type * rtype;
if (!fval(r->terrain, LAND_REGION)) {
return;
@ -2393,9 +2393,9 @@ planttrees(region *r, unit *u, int raw)
/* Mallornbäume kann man nur in Mallornregionen züchten */
if (fval(r, RF_MALLORN)) {
itype = &it_mallornseed;
rtype = rt_mallornseed;
} else {
itype = &it_seed;
rtype = rt_seed;
}
/* Skill prüfen */
@ -2403,22 +2403,21 @@ planttrees(region *r, unit *u, int raw)
if (skill < 6) {
add_message(&u->faction->msgs,
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;
}
if (fval(r, RF_MALLORN) && skill < 7 ) {
add_message(&u->faction->msgs,
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;
}
n = new_get_pooled(u, itype->rtype, GET_DEFAULT);
n = new_get_pooled(u, rtype, GET_DEFAULT);
/* Samen prüfen */
if (n==0) {
add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing",
itype->rtype));
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
return;
}
@ -2434,10 +2433,10 @@ planttrees(region *r, unit *u, int raw)
/* Alles ok. Abziehen. */
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",
"unit region amount herb", u, r, planted, itype->rtype));
"unit region amount herb", u, r, planted, rtype));
}
/* züchte bäume */
@ -2445,7 +2444,7 @@ static void
breedtrees(region *r, unit *u, int raw)
{
int n, i, skill, planted = 0;
const item_type * itype;
const resource_type * rtype;
static int current_season = -1;
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 */
if (fval(r, RF_MALLORN)) {
itype = &it_mallornseed;
rtype = rt_mallornseed;
} else {
itype = &it_seed;
rtype = rt_seed;
}
/* Skill prüfen */
@ -2473,12 +2472,11 @@ breedtrees(region *r, unit *u, int raw)
planttrees(r, u, raw);
return;
}
n = new_get_pooled(u, itype->rtype, GET_DEFAULT);
n = new_get_pooled(u, rtype, GET_DEFAULT);
/* Samen prüfen */
if (n==0) {
add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing",
itype->rtype));
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
return;
}
@ -2494,10 +2492,10 @@ breedtrees(region *r, unit *u, int raw)
/* Alles ok. Abziehen. */
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,
"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
@ -2507,7 +2505,7 @@ plant_cmd(unit *u, struct order * ord)
int m;
const char *s;
param_t p;
const item_type * itype = NULL;
const resource_type * rtype = NULL;
if (r->land==NULL) {
/* TODO: error message here */
@ -2531,7 +2529,7 @@ plant_cmd(unit *u, struct order * ord)
p = P_ANY;
} else {
p = findparam(s, u->faction->locale);
itype = finditemtype(s, u->faction->locale);
rtype = findresourcetype(s, u->faction->locale);
}
if (p==P_HERBS){
@ -2542,8 +2540,8 @@ plant_cmd(unit *u, struct order * ord)
breedtrees(r, u, m);
return;
}
else if (itype!=NULL){
if (itype==&it_mallornseed || itype==&it_seed) {
else if (rtype!=NULL){
if (rtype==rt_mallornseed || rtype==rt_seed) {
breedtrees(r, u, m);
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_IRON]), 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_mallornseed, attrib_allocation));
add_allocator(make_allocator(rt_seed, attrib_allocation));
add_allocator(make_allocator(rt_mallornseed, attrib_allocation));
}

View File

@ -27,37 +27,20 @@
/* libc includes */
#include <assert.h>
resource_type rt_seed = {
{ "seed", "seed_p" },
{ "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 */
};
resource_type * rt_seed = 0;
resource_type * rt_mallornseed = 0;
static void
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;
}
static int
limit_seeds(const region * r, const resource_type * rtype)
{
assert(rtype==&rt_seed);
assert(rtype==rt_seed);
if(fval(r, RF_MALLORN)) return 0;
return r->land?r->land->trees[0]:0;
}
@ -66,46 +49,24 @@ void
register_seed(void)
{
attrib * a;
resource_limit * rdata;
it_register(&it_seed);
it_seed.rtype->flags |= RTF_LIMITED;
it_seed.rtype->itype->flags |= ITF_NOBUILDBESIEGED;
it_seed.rtype->flags |= RTF_POOLED;
rt_seed = rt_find("seed");
assert(rt_seed!=NULL);
rt_seed->itype->flags |= ITF_NOBUILDBESIEGED;
a = a_add(&it_seed.rtype->attribs, a_new(&at_resourcelimit));
{
resource_limit * rdata = (resource_limit*)a->data.v;
a = a_add(&rt_seed->attribs, a_new(&at_resourcelimit));
rdata = (resource_limit*)a->data.v;
rdata->limit = limit_seeds;
rdata->use = produce_seeds;
}
}
/* 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
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));
r->land->trees[0] -= norders;
}
@ -113,7 +74,7 @@ produce_mallornseeds(region * r, const resource_type * rtype, int norders)
static int
limit_mallornseeds(const region * r, const resource_type * rtype)
{
assert(rtype==&rt_mallornseed);
assert(rtype==rt_mallornseed);
if (!fval(r, RF_MALLORN)) {
return 0;
}
@ -124,20 +85,16 @@ void
register_mallornseed(void)
{
attrib * a;
resource_limit * rdata;
it_register(&it_mallornseed);
it_mallornseed.rtype->flags |= RTF_LIMITED;
it_mallornseed.rtype->itype->flags |= ITF_NOBUILDBESIEGED;
it_mallornseed.rtype->flags |= RTF_POOLED;
register_function((pf_generic)limit_seeds, "limit_seeds");
register_function((pf_generic)produce_seeds, "produce_seeds");
register_function((pf_generic)limit_mallornseeds, "limit_mallornseeds");
register_function((pf_generic)produce_mallornseeds, "produce_mallornseeds");
rt_mallornseed = rt_find("mallornseed");
assert(rt_mallornseed!=NULL);
rt_mallornseed->flags |= RTF_LIMITED;
rt_mallornseed->itype->flags |= ITF_NOBUILDBESIEGED;
rt_mallornseed->flags |= RTF_POOLED;
a = a_add(&it_mallornseed.rtype->attribs, a_new(&at_resourcelimit));
{
resource_limit * rdata = (resource_limit*)a->data.v;
a = a_add(&rt_mallornseed->attribs, a_new(&at_resourcelimit));
rdata = (resource_limit*)a->data.v;
rdata->limit = limit_mallornseeds;
rdata->use = produce_mallornseeds;
}
}

View File

@ -19,12 +19,10 @@ extern "C" {
#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 struct item_type it_mallornseed;
extern struct resource_type rt_mallornseed;
extern struct resource_type * rt_mallornseed;
extern void register_mallornseed(void);
#ifdef __cplusplus

View File

@ -821,6 +821,7 @@ parse_resources(xmlDocPtr doc)
int k;
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;
name = xmlGetProp(node, BAD_CAST "name");

View File

@ -7,6 +7,16 @@
</item>
</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">
<item weight="0" score="2000">
<function name="use" value="use_antimagiccrystal"/>

View File

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