From dfc89b163d253191238c4191588f6e4304d768ea Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 22 May 2007 17:09:23 +0000 Subject: [PATCH] =?UTF-8?q?http://eressea.upb.de/mantis/view.php=3Fid=3D11?= =?UTF-8?q?89=20"Kein=20Anpflanzen=20von=20Kr=C3=A4utern"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bessere Fehlermeldungen fuer PFLANZE/ZUECHTE, und beide Funktionen zu einer zusammengefuehrt. --- src/common/gamecode/economy.c | 92 +++++++++++------------------------ src/common/gamecode/items.c | 4 +- src/common/gamecode/laws.c | 3 +- src/res/messages.xml | 4 +- 4 files changed, 33 insertions(+), 70 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 8a9dc9104..6147bd819 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -1169,7 +1169,7 @@ manufacture(unit * u, const item_type * itype, int want) ADDMSG(&u->faction->msgs, msg_message("manufacture", "unit region amount wanted resource", u, u->region, n, want, itype->rtype)); } 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); if (ptype!=NULL) create_potion(u, ptype, 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) { create_item(u, itype, m); } else { - cmistake(u, ord, 125, MSG_PRODUCE); + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", "")); } return 0; @@ -2495,56 +2497,6 @@ breedtrees(region *r, unit *u, int raw) "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 [] */ - 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 */ static void breedhorses(region *r, unit *u) @@ -2584,6 +2536,12 @@ breed_cmd(unit *u, struct order * ord) const char *s; param_t p; 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 [] */ init_tokens(ord); @@ -2591,15 +2549,14 @@ breed_cmd(unit *u, struct order * ord) s = getstrtoken(); m = atoi(s); - sprintf(buf, "%d", m); - if (!strcmp(buf, s)) { + if (m!=0) { /* first came a want-paramter */ s = getstrtoken(); } else { m = INT_MAX; } - if(!s[0]){ + if (!s[0]) { p = P_ANY; } else { p = findparam(s, u->faction->locale); @@ -2608,13 +2565,23 @@ breed_cmd(unit *u, struct order * ord) switch (p) { case P_HERBS: plant(r, u, m); - return; + break; case P_TREES: breedtrees(r, u, m); - return; + break; 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); - 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]) { - cmistake(u, ord, 242, MSG_INCOME); + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); return; } @@ -3162,14 +3129,11 @@ produce(void) sabotage_cmd(u, u->thisorder); break; + case K_PLANT: case K_BREED: breed_cmd(u, u->thisorder); break; - case K_PLANT: - plant_cmd(u, u->thisorder); - break; - case K_RESEARCH: research_cmd(u, u->thisorder); break; diff --git a/src/common/gamecode/items.c b/src/common/gamecode/items.c index 9bd4add3b..07ae6b4fe 100644 --- a/src/common/gamecode/items.c +++ b/src/common/gamecode/items.c @@ -162,7 +162,7 @@ use_instantartsculpture(struct unit * u, const struct item_type * itype, building *b; if(u->region->land == NULL) { - cmistake(u, ord, 242, MSG_MAGIC); + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); return -1; } @@ -186,7 +186,7 @@ use_instantartacademy(struct unit * u, const struct item_type * itype, building *b; if(u->region->land == NULL) { - cmistake(u, ord, 242, MSG_MAGIC); + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); return -1; } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 4d626e332..55f916c16 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -991,7 +991,7 @@ restart_cmd(unit * u, struct order * ord) skip_token(); /* skip keyword */ if (!fval(u->region->terrain, LAND_REGION)) { - cmistake(u, ord, 242, MSG_EVENT); + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", "")); } else { const char * s_race = getstrtoken(), * s_pass; const race * frace = findrace(s_race, u->faction->locale); @@ -3848,7 +3848,6 @@ process(void) ord = NULL; } else if (fval(r->terrain, SEA_REGION) && u->race != new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) { /* error message disabled by popular demand */ - /* cmistake(u, ord, 242, MSG_INCOME); */ ord = NULL; } } diff --git a/src/res/messages.xml b/src/res/messages.xml index 5eeb0f145..e2d106fdd 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -3839,7 +3839,7 @@ "$unit($unit) in $region($region): '$order($command)' - Keine gültige Rasse angegeben." "$unit($unit) in $region($region): '$order($command)' - You did not specify a valid race." - + @@ -5025,7 +5025,7 @@ "$unit($unit) in $region($region): '$order($command)' - You cannot sell this." "$unit($unit) in $region($region): '$order($command)' - You cannot sell this." - +