"Kein Anpflanzen von Kräutern"

Bessere Fehlermeldungen fuer PFLANZE/ZUECHTE, und beide Funktionen zu einer zusammengefuehrt.
This commit is contained in:
Enno Rehling 2007-05-22 17:09:23 +00:00
parent 425a1eb390
commit dfc89b163d
4 changed files with 33 additions and 70 deletions

View File

@ -1169,7 +1169,7 @@ manufacture(unit * u, const item_type * itype, int want)
ADDMSG(&u->faction->msgs, msg_message("manufacture", ADDMSG(&u->faction->msgs, msg_message("manufacture",
"unit region amount wanted resource", u, u->region, n, want, itype->rtype)); "unit region amount wanted resource", u, u->region, n, want, itype->rtype));
} else { } else {
cmistake(u, u->thisorder, 125, MSG_PRODUCE); ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_cannotmake", ""));
} }
} }
@ -1616,7 +1616,9 @@ create_item(unit * u, const item_type * itype, int want)
const potion_type * ptype = resource2potion(itype->rtype); const potion_type * ptype = resource2potion(itype->rtype);
if (ptype!=NULL) create_potion(u, ptype, want); if (ptype!=NULL) create_potion(u, ptype, want);
else if (itype->construction && itype->construction->materials) manufacture(u, itype, want); else if (itype->construction && itype->construction->materials) manufacture(u, itype, want);
else cmistake(u, u->thisorder, 125, MSG_PRODUCE); else {
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_cannotmake", ""));
}
} }
} }
@ -1728,7 +1730,7 @@ make_cmd(unit * u, struct order * ord)
else if (itype!=NULL) { else if (itype!=NULL) {
create_item(u, itype, m); create_item(u, itype, m);
} else { } else {
cmistake(u, ord, 125, MSG_PRODUCE); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
} }
return 0; return 0;
@ -2495,56 +2497,6 @@ breedtrees(region *r, unit *u, int raw)
"unit region amount herb", u, r, planted, rtype)); "unit region amount herb", u, r, planted, rtype));
} }
static void
plant_cmd(unit *u, struct order * ord)
{
region * r = u->region;
int m;
const char *s;
param_t p;
const resource_type * rtype = NULL;
if (r->land==NULL) {
/* TODO: error message here */
return;
}
/* pflanze [<anzahl>] <parameter> */
init_tokens(ord);
skip_token();
s = getstrtoken();
m = atoi(s);
sprintf(buf, "%d", m);
if (!strcmp(buf, s)) {
/* first came a want-paramter */
s = getstrtoken();
} else {
m = INT_MAX;
}
if (!s[0]) {
p = P_ANY;
} else {
p = findparam(s, u->faction->locale);
rtype = findresourcetype(s, u->faction->locale);
}
if (p==P_HERBS){
plant(r, u, m);
return;
}
else if (p==P_TREES){
breedtrees(r, u, m);
return;
}
else if (rtype!=NULL){
if (rtype==rt_mallornseed || rtype==rt_seed) {
breedtrees(r, u, m);
return;
}
}
}
/* züchte pferde */ /* züchte pferde */
static void static void
breedhorses(region *r, unit *u) breedhorses(region *r, unit *u)
@ -2584,6 +2536,12 @@ breed_cmd(unit *u, struct order * ord)
const char *s; const char *s;
param_t p; param_t p;
region *r = u->region; region *r = u->region;
const resource_type * rtype = NULL;
if (r->land==NULL) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
return;
}
/* züchte [<anzahl>] <parameter> */ /* züchte [<anzahl>] <parameter> */
init_tokens(ord); init_tokens(ord);
@ -2591,15 +2549,14 @@ breed_cmd(unit *u, struct order * ord)
s = getstrtoken(); s = getstrtoken();
m = atoi(s); m = atoi(s);
sprintf(buf, "%d", m); if (m!=0) {
if (!strcmp(buf, s)) {
/* first came a want-paramter */ /* first came a want-paramter */
s = getstrtoken(); s = getstrtoken();
} else { } else {
m = INT_MAX; m = INT_MAX;
} }
if(!s[0]){ if (!s[0]) {
p = P_ANY; p = P_ANY;
} else { } else {
p = findparam(s, u->faction->locale); p = findparam(s, u->faction->locale);
@ -2608,13 +2565,23 @@ breed_cmd(unit *u, struct order * ord)
switch (p) { switch (p) {
case P_HERBS: case P_HERBS:
plant(r, u, m); plant(r, u, m);
return; break;
case P_TREES: case P_TREES:
breedtrees(r, u, m); breedtrees(r, u, m);
return; break;
default: default:
if (p!=P_ANY) {
rtype = findresourcetype(s, u->faction->locale);
if (rtype==rt_mallornseed || rtype==rt_seed) {
breedtrees(r, u, m);
break;
} else if (rtype!=oldresourcetype[R_HORSE]) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
break;
}
}
breedhorses(r, u); breedhorses(r, u);
return; break;
} }
} }
@ -2705,7 +2672,7 @@ steal_cmd(unit * u, struct order * ord, request ** stealorders)
} }
if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN]) { if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN]) {
cmistake(u, ord, 242, MSG_INCOME); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
return; return;
} }
@ -3162,14 +3129,11 @@ produce(void)
sabotage_cmd(u, u->thisorder); sabotage_cmd(u, u->thisorder);
break; break;
case K_PLANT:
case K_BREED: case K_BREED:
breed_cmd(u, u->thisorder); breed_cmd(u, u->thisorder);
break; break;
case K_PLANT:
plant_cmd(u, u->thisorder);
break;
case K_RESEARCH: case K_RESEARCH:
research_cmd(u, u->thisorder); research_cmd(u, u->thisorder);
break; break;

View File

@ -162,7 +162,7 @@ use_instantartsculpture(struct unit * u, const struct item_type * itype,
building *b; building *b;
if(u->region->land == NULL) { if(u->region->land == NULL) {
cmistake(u, ord, 242, MSG_MAGIC); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
return -1; return -1;
} }
@ -186,7 +186,7 @@ use_instantartacademy(struct unit * u, const struct item_type * itype,
building *b; building *b;
if(u->region->land == NULL) { if(u->region->land == NULL) {
cmistake(u, ord, 242, MSG_MAGIC); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
return -1; return -1;
} }

View File

@ -991,7 +991,7 @@ restart_cmd(unit * u, struct order * ord)
skip_token(); /* skip keyword */ skip_token(); /* skip keyword */
if (!fval(u->region->terrain, LAND_REGION)) { if (!fval(u->region->terrain, LAND_REGION)) {
cmistake(u, ord, 242, MSG_EVENT); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
} else { } else {
const char * s_race = getstrtoken(), * s_pass; const char * s_race = getstrtoken(), * s_pass;
const race * frace = findrace(s_race, u->faction->locale); const race * frace = findrace(s_race, u->faction->locale);
@ -3848,7 +3848,6 @@ process(void)
ord = NULL; ord = NULL;
} else if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) { } else if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) {
/* error message disabled by popular demand */ /* error message disabled by popular demand */
/* cmistake(u, ord, 242, MSG_INCOME); */
ord = NULL; ord = NULL;
} }
} }

View File

@ -3839,7 +3839,7 @@
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Keine gültige Rasse angegeben."</text> <text locale="de">"$unit($unit) in $region($region): '$order($command)' - Keine gültige Rasse angegeben."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - You did not specify a valid race."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - You did not specify a valid race."</text>
</message> </message>
<message name="error242" section="errors"> <message name="error_onlandonly" section="errors">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>
@ -5025,7 +5025,7 @@
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - You cannot sell this."</text> <text locale="fr">"$unit($unit) in $region($region): '$order($command)' - You cannot sell this."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - You cannot sell this."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - You cannot sell this."</text>
</message> </message>
<message name="error125" section="errors"> <message name="error_cannotmake" section="errors">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>