diff --git a/res/core/messages.xml b/res/core/messages.xml index e312fcc7c..32d8e35a6 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -6882,6 +6882,7 @@ "$string" "$string" + @@ -6892,6 +6893,16 @@ "$unit($unit) transfers $int($amount) person$if($eq($amount,1),"","s") to $unit($target)." + + + + + + + "$unit($target) erhält $int($amount) Person$if($eq($amount,1),"","en") von $unit($unit)." + "$unit($target) receives $int($amount) person$if($eq($amount,1),"","s") from $unit($unit)." + + @@ -6913,6 +6924,7 @@ "$unit($target) erhält $int($amount) $resource($resource,$amount) von $unit($unit)." "$unit($target) receives $int($amount) $resource($resource,$amount) from $unit($unit)." + diff --git a/src/give.c b/src/give.c index 5abb950a6..eeb641665 100644 --- a/src/give.c +++ b/src/give.c @@ -121,6 +121,28 @@ const resource_type * rtype, struct order *ord, int error) } } +static void add_give_person(unit * u, unit * u2, int given, + struct order *ord, int error) +{ + assert(u2); + if (error) { + cmistake(u, ord, error, MSG_COMMERCE); + } + else if (u2->faction != u->faction) { + message *msg; + + msg = msg_message("give_person", "unit target resource amount", + u, u2, given); + add_message(&u->faction->msgs, msg); + msg_release(msg); + + msg = msg_message("receive_person", "unit target resource amount", + u, u2, given); + add_message(&u2->faction->msgs, msg); + msg_release(msg); + } +} + static bool limited_give(const item_type * type) { /* trade only money 2:1, if at all */ @@ -531,7 +553,7 @@ void give_unit(unit * u, unit * u2, order * ord) cmistake(u, ord, 156, MSG_COMMERCE); return; } - add_give(u, u2, u->number, u->number, get_resourcetype(R_PERSON), ord, 0); + add_give_person(u, u2, u->number, ord, 0); u_setfaction(u, u2->faction); u2->faction->newbies += u->number; } diff --git a/src/give.test.c b/src/give.test.c index fbb71cf3c..33f70fb90 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -83,6 +83,8 @@ static void test_give_unit(CuTest * tc) { CuAssertPtrEquals(tc, env.f2, env.src->faction); CuAssertIntEquals(tc, 1, env.f2->newbies); CuAssertPtrEquals(tc, 0, env.f1->units); + CuAssertPtrNotNull(tc, test_find_messagetype(env.f1->msgs, "give_person")); + CuAssertPtrNotNull(tc, test_find_messagetype(env.f2->msgs, "receive_person")); test_cleanup(); } diff --git a/src/kernel/item.c b/src/kernel/item.c index 58e3326a2..6c96cb0b0 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -622,7 +622,7 @@ const potion_type *oldpotiontype[MAX_POTIONS + 1]; static const char *resourcenames[MAX_RESOURCES] = { "money", "aura", "permaura", - "hp", "peasant", "person", + "hp", "peasant", "sapling", "mallornsapling", "tree", "mallorntree", "seed", "mallornseed", @@ -982,8 +982,6 @@ void init_resources(void) * which can be used in a construction recipe or as a spell ingredient. */ - rt_get_or_create(resourcenames[R_PERSON]); /* lousy hack */ - rtype = rt_get_or_create(resourcenames[R_PEASANT]); rtype->uchange = res_changepeasants; diff --git a/src/kernel/item.h b/src/kernel/item.h index c08c676be..bb114c8ac 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -265,7 +265,6 @@ extern "C" { R_PERMAURA, /* Permanente Aura */ R_LIFE, R_PEASANT, - R_PERSON, R_SAPLING, R_MALLORN_SAPLING, R_TREE, diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index 52e7d9917..c824d082a 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -165,8 +165,6 @@ static void test_core_resources(CuTest *tc) { CuAssertPtrNotNull(tc, rtype->itype->give); CuAssertPtrNotNull(tc, rtype = rt_find("peasant")); CuAssertPtrEquals(tc, 0, rtype->itype); - CuAssertPtrNotNull(tc, rtype = rt_find("person")); - CuAssertPtrEquals(tc, 0, rtype->itype); CuAssertPtrNotNull(tc, rtype = rt_find("permaura")); CuAssertPtrEquals(tc, 0, rtype->itype); CuAssertPtrNotNull(tc, rtype = rt_find("hp"));