forked from github/server
eliminate R_PERSON hack.
This commit is contained in:
parent
5675ef6091
commit
aa662e65d2
|
@ -6882,6 +6882,7 @@
|
|||
<text locale="de">"$string"</text>
|
||||
<text locale="en">"$string"</text>
|
||||
</message>
|
||||
|
||||
<message name="give_person" section="economy">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
@ -6892,6 +6893,16 @@
|
|||
<text locale="en">"$unit($unit) transfers $int($amount) person$if($eq($amount,1),"","s") to $unit($target)."</text>
|
||||
</message>
|
||||
|
||||
<message name="receive_person" section="economy">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="amount" type="int"/>
|
||||
<arg name="target" type="unit"/>
|
||||
</type>
|
||||
<text locale="de">"$unit($target) erhält $int($amount) Person$if($eq($amount,1),"","en") von $unit($unit)."</text>
|
||||
<text locale="en">"$unit($target) receives $int($amount) person$if($eq($amount,1),"","s") from $unit($unit)."</text>
|
||||
</message>
|
||||
|
||||
<message name="give" section="economy">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
@ -6913,6 +6924,7 @@
|
|||
<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_ocean" section="economy">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
|
24
src/give.c
24
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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -265,7 +265,6 @@ extern "C" {
|
|||
R_PERMAURA, /* Permanente Aura */
|
||||
R_LIFE,
|
||||
R_PEASANT,
|
||||
R_PERSON,
|
||||
R_SAPLING,
|
||||
R_MALLORN_SAPLING,
|
||||
R_TREE,
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in New Issue