Merge branch 'master' of github.com:eressea/server

This commit is contained in:
Enno Rehling 2014-12-11 10:13:59 +00:00
commit d91cf538cf
8 changed files with 80 additions and 17 deletions

View File

@ -7112,6 +7112,15 @@
<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"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) ertränkt $int($amount) Person$if($eq($amount,1),"","en")."</text>
<text locale="en">"$unit($unit) drowns $int($amount)."</text>
</message>
<message name="give_person_peasants" section="economy">
<type>
<arg name="unit" type="unit"/>

View File

@ -23,6 +23,7 @@ local eternath = {}
function eternath.update()
if b1 and b2 then
local size = 5
local units1 = gates.units(b1, size)
local units2 = gates.units(b2, size)

View File

@ -13,7 +13,7 @@ function gates.travel(b, units)
end
function gates.units(b, maxsize)
local size = maxsize
local size = maxsize or 1
local units = {}
local u

View File

@ -1523,7 +1523,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
fprintf(F, "%d;Basis\n", 36);
fprintf(F, "%d;Runde\n", turn);
fprintf(F, "%d;Zeitalter\n", era);
fprintf(F, "%d;Build\n", VERSION_BUILD);
fprintf(F, "%d.%d.%d;Build\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
if (mailto != NULL) {
fprintf(F, "\"%s\";mailto\n", mailto);
fprintf(F, "\"%s\";mailcmd\n", locale_string(f->locale, "mailcmd"));

View File

@ -393,6 +393,9 @@ message * disband_men(int n, unit * u, struct order *ord) {
a->data.i += n;
}
#endif
if (fval(u->region->terrain, SEA_REGION)) {
return msg_message("give_person_ocean", "unit amount", u, n);
}
return msg_message("give_person_peasants", "unit amount", u, n);
}
@ -421,12 +424,19 @@ void give_unit(unit * u, unit * u2, order * ord)
}
if (u2 == NULL) {
message *msg;
if (fval(r->terrain, SEA_REGION)) {
cmistake(u, ord, 152, MSG_COMMERCE);
/* TODO: why is this here, but the unit does not actually seem to lose any men? */
msg = disband_men(u->number, u, ord);
if (msg) {
ADDMSG(&u->faction->msgs, msg);
}
else {
cmistake(u, ord, 152, MSG_COMMERCE);
}
}
else if (getunitpeasants) {
unit *u3;
message *msg;
for (u3 = r->units; u3; u3 = u3->next)
if (u3->faction == u->faction && u != u3)
@ -596,12 +606,10 @@ void give_cmd(unit * u, order * ord)
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
return;
}
if (!u2) {
if (!getunitpeasants) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
"feedback_unit_not_found", ""));
return;
}
if (!u2 && !getunitpeasants) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
"feedback_unit_not_found", ""));
return;
}
if (u->items) {
item **itmp = &u->items;
@ -691,7 +699,7 @@ void give_cmd(unit * u, order * ord)
}
else {
message * msg;
msg = getunitpeasants ? disband_men(u->number, u, ord) : give_men(u->number, u, u2, ord);
msg = u2 ? give_men(u->number, u, u2, ord) : disband_men(u->number, u, ord);
if (msg) {
ADDMSG(&u->faction->msgs, msg);
}
@ -747,7 +755,7 @@ void give_cmd(unit * u, order * ord)
msg_feedback(u, ord, "race_noregroup", "race", u_race(u)));
return;
}
msg = getunitpeasants ? disband_men(u->number, u, ord) : give_men(u->number, u, u2, ord);
msg = u2 ? give_men(u->number, u, u2, ord) : disband_men(u->number, u, ord);
if (msg) {
ADDMSG(&u->faction->msgs, msg);
}

View File

@ -36,6 +36,33 @@ static void setup_give(struct give *env) {
env->itype->flags |= ITF_HERB;
}
static void test_give_unit_to_peasants(CuTest * tc) {
struct give env;
test_cleanup();
env.f1 = test_create_faction(0);
env.f2 = 0;
setup_give(&env);
rsetpeasants(env.r, 0);
getunitpeasants = true;
give_unit(env.src, NULL, NULL);
CuAssertIntEquals(tc, 0, env.src->number);
CuAssertIntEquals(tc, 1, env.r->land->peasants);
test_cleanup();
}
static void test_give_unit_in_ocean(CuTest * tc) {
struct give env;
test_cleanup();
env.f1 = test_create_faction(0);
env.f2 = 0;
setup_give(&env);
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
getunitpeasants = true;
give_unit(env.src, NULL, NULL);
CuAssertIntEquals(tc, 0, env.src->number);
test_cleanup();
}
static void test_give_men(CuTest * tc) {
struct give env;
test_cleanup();
@ -47,6 +74,21 @@ static void test_give_men(CuTest * tc) {
test_cleanup();
}
static void test_give_men_in_ocean(CuTest * tc) {
struct give env;
message * msg;
test_cleanup();
env.f1 = test_create_faction(0);
env.f2 = 0;
setup_give(&env);
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
msg = disband_men(1, env.src, NULL);
CuAssertStrEquals(tc, "give_person_ocean", (const char *)msg->parameters[0].v);
CuAssertIntEquals(tc, 0, env.src->number);
test_cleanup();
}
static void test_give_men_too_many(CuTest * tc) {
struct give env;
test_cleanup();
@ -118,16 +160,16 @@ static void test_give_men_not_to_self(CuTest * tc) {
static void test_give_peasants(CuTest * tc) {
struct give env;
message * msg;
int peasants;
test_cleanup();
env.f1 = test_create_faction(0);
env.f2 = 0;
setup_give(&env);
peasants = env.r->land->peasants;
rsetpeasants(env.r, 0);
msg = disband_men(1, env.src, NULL);
CuAssertStrEquals(tc, "give_person_peasants", (const char*)msg->parameters[0].v);
CuAssertIntEquals(tc, 0, env.src->number);
CuAssertIntEquals(tc, peasants+1, env.r->land->peasants);
CuAssertIntEquals(tc, 1, env.r->land->peasants);
test_cleanup();
}
@ -207,11 +249,14 @@ CuSuite *get_give_suite(void)
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_give);
SUITE_ADD_TEST(suite, test_give_men);
SUITE_ADD_TEST(suite, test_give_men_in_ocean);
SUITE_ADD_TEST(suite, test_give_men_none);
SUITE_ADD_TEST(suite, test_give_men_too_many);
SUITE_ADD_TEST(suite, test_give_men_other_faction);
SUITE_ADD_TEST(suite, test_give_men_requires_contact);
SUITE_ADD_TEST(suite, test_give_men_not_to_self);
SUITE_ADD_TEST(suite, test_give_unit_in_ocean);
SUITE_ADD_TEST(suite, test_give_unit_to_peasants);
SUITE_ADD_TEST(suite, test_give_peasants);
SUITE_ADD_TEST(suite, test_give_herbs);
SUITE_ADD_TEST(suite, test_give_okay);

View File

@ -4385,6 +4385,7 @@ void init_processor(void)
p += 10; /* rest rng again before economics */
add_proc_region(p, &economics, "Zerstoeren, Geben, Rekrutieren, Vergessen");
add_proc_order(p, K_PROMOTION, &promotion_cmd, 0, "Heldenbefoerderung");
p += 10;
if (!keyword_disabled(K_PAY)) {
@ -4456,7 +4457,6 @@ void init_processor(void)
p += 10;
add_proc_global(p, restack_units, "Einheiten sortieren");
}
add_proc_order(p, K_PROMOTION, &promotion_cmd, 0, "Heldenbefoerderung");
if (!keyword_disabled(K_NUMBER)) {
add_proc_order(p, K_NUMBER, &renumber_cmd, 0, "Neue Nummern (Einheiten)");
p += 10;

@ -1 +1 @@
Subproject commit 6acf2b4fec360d7f681275ea3be77002fd2573c7
Subproject commit bcc2874cf289a1d0fc9cc79ff3ed271403b2e24c