Confusing message when receiving items through GIVE
This commit is contained in:
Enno Rehling 2009-10-15 21:03:44 +00:00
parent 50c0475823
commit 2efe55c285
2 changed files with 30 additions and 13 deletions

View File

@ -46,7 +46,7 @@
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */ /* Wieviel Fremde eine Partei pro Woche aufnehmen kangiven */
#define MAXNEWBIES 5 #define MAXNEWBIES 5
#define RESERVE_DONATIONS /* shall we reserve objects given to us by other factions? */ #define RESERVE_DONATIONS /* shall we reserve objects given to us by other factions? */
#define RESERVE_GIVE /* reserve anything that's given from one unit to another? */ #define RESERVE_GIVE /* reserve anything that's given from one unit to another? */
@ -63,7 +63,7 @@ GiveRestriction(void) {
} }
static void static void
add_give(unit * u, unit * u2, int n, const resource_type * rtype, struct order * ord, int error) add_give(unit * u, unit * u2, int given, int received, const resource_type * rtype, struct order * ord, int error)
{ {
if (error) { if (error) {
cmistake(u, ord, error, MSG_COMMERCE); cmistake(u, ord, error, MSG_COMMERCE);
@ -71,10 +71,15 @@ add_give(unit * u, unit * u2, int n, const resource_type * rtype, struct order *
else if (u2==NULL) { else if (u2==NULL) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_message("give_peasants", "unit resource amount", msg_message("give_peasants", "unit resource amount",
u, rtype, n)); u, rtype, given));
} else if (u2->faction!=u->faction) { } else if (u2->faction!=u->faction) {
message * msg = msg_message("give", "unit target resource amount", u, u2, rtype, n); message * msg;
msg = msg_message("give", "unit target resource amount", u, u2, rtype, given);
add_message(&u->faction->msgs, msg); add_message(&u->faction->msgs, msg);
msg_release(msg);
msg = msg_message("receive", "unit target resource amount", u, u2, rtype, received);
add_message(&u2->faction->msgs, msg); add_message(&u2->faction->msgs, msg);
msg_release(msg); msg_release(msg);
} }
@ -114,11 +119,12 @@ int
give_item(int want, const item_type * itype, unit * src, unit * dest, struct order * ord) give_item(int want, const item_type * itype, unit * src, unit * dest, struct order * ord)
{ {
short error = 0; short error = 0;
int n; int n, r;
assert(itype!=NULL); assert(itype!=NULL);
n = get_pooled(src, item2resource(itype), GET_DEFAULT, want); n = get_pooled(src, item2resource(itype), GET_DEFAULT, want);
n = MIN(want, n); n = MIN(want, n);
r = n;
if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) {
if (ord!=NULL) { if (ord!=NULL) {
ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "giverestriction", ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "giverestriction",
@ -139,28 +145,28 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
int use = use_pooled(src, item2resource(itype), GET_SLACK, n); int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
if (use<n) use += use_pooled(src, item2resource(itype), GET_RESERVE|GET_POOLED_SLACK, n-use); if (use<n) use += use_pooled(src, item2resource(itype), GET_RESERVE|GET_POOLED_SLACK, n-use);
if (dest) { if (dest) {
int q = give_quota(src, dest, itype, n); r = give_quota(src, dest, itype, n);
i_change(&dest->items, itype, q); i_change(&dest->items, itype, r);
#ifdef RESERVE_GIVE #ifdef RESERVE_GIVE
#ifdef RESERVE_DONATIONS #ifdef RESERVE_DONATIONS
change_reservation(dest, item2resource(itype), q); change_reservation(dest, item2resource(itype), r);
#else #else
if (src->faction==dest->faction) { if (src->faction==dest->faction) {
change_reservation(dest, item2resource(itype), q); change_reservation(dest, item2resource(itype), r);
} }
#endif #endif
#endif #endif
#if MUSEUM_MODULE && defined(TODO) #if MUSEUM_MODULE && defined(TODO)
/* TODO: use a trigger for the museum warden! */ /* TODO: use a trigger for the museum warden! */
if (a_find(dest->attribs, &at_warden)) { if (a_find(dest->attribs, &at_warden)) {
warden_add_give(src, dest, itype, q); warden_add_give(src, dest, itype, r);
} }
#endif #endif
handle_event(dest->attribs, "receive", src); handle_event(dest->attribs, "receive", src);
} }
handle_event(src->attribs, "give", dest); handle_event(src->attribs, "give", dest);
} }
add_give(src, dest, n, item2resource(itype), ord, error); add_give(src, dest, n, r, item2resource(itype), ord, error);
if (error) return -1; if (error) return -1;
return 0; return 0;
} }
@ -421,7 +427,7 @@ give_unit(unit * u, unit * u2, order * ord)
cmistake(u, ord, 156, MSG_COMMERCE); cmistake(u, ord, 156, MSG_COMMERCE);
return; return;
} }
add_give(u, u2, 1, r_unit, ord, 0); add_give(u, u2, 1, 1, r_unit, ord, 0);
u_setfaction(u, u2->faction); u_setfaction(u, u2->faction);
u2->faction->newbies += n; u2->faction->newbies += n;
} }

View File

@ -7089,7 +7089,18 @@
</type> </type>
<text locale="de">"$unit($unit) übergibt $int($amount) $resource($resource,$amount) an $unit($target)."</text> <text locale="de">"$unit($unit) übergibt $int($amount) $resource($resource,$amount) an $unit($target)."</text>
<text locale="en">"$unit($unit) gives $int($amount) $resource($resource,$amount) to $unit($target)."</text> <text locale="en">"$unit($unit) gives $int($amount) $resource($resource,$amount) to $unit($target)."</text>
</message> </message>
<message name="receive" section="economy">
<type>
<arg name="unit" type="unit"/>
<arg name="amount" type="int"/>
<arg name="resource" type="resource"/>
<arg name="target" type="unit"/>
</type>
<text locale="de">"$unit($target) erhält $int($amount) $resource($resource,$amount) von $unit($unit)."</text>
<text locale="en">"$unit($target) receives $int($amount) $resource($resource,$amount) from $unit($unit)."</text>
</message>
<message name="give_person_peasants" section="economy"> <message name="give_person_peasants" section="economy">
<type> <type>