diff --git a/res/core/messages.xml b/res/core/messages.xml
index 4de8b0299..fb6cd45bd 100644
--- a/res/core/messages.xml
+++ b/res/core/messages.xml
@@ -5196,6 +5196,12 @@
+
+
+
+
+
+
diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po
index 5623069d4..21586ac31 100644
--- a/res/translations/messages.de.po
+++ b/res/translations/messages.de.po
@@ -38,6 +38,9 @@ msgstr "\"$unit($mage) verwandelt $unit($target) in $race($race,0).\""
msgid "give_person"
msgstr "\"$unit($unit) übergibt $int($amount) Person$if($eq($amount,1),\"\",\"en\") an $unit($target).\""
+msgid "transfer_unit"
+msgstr "\"$unit($unit) schließt sich unserer Partei an.\""
+
msgid "rust_effect_2"
msgstr "\"$unit($mage) ruft ein fürchterliches Unwetter über seine Feinde. Der magischen Regen lässt alles Eisen rosten.\""
diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po
index 1f1db551c..095a83212 100644
--- a/res/translations/messages.en.po
+++ b/res/translations/messages.en.po
@@ -38,6 +38,9 @@ msgstr "\"$unit($mage) tranforms $unit($target) to $race($race,0).\""
msgid "give_person"
msgstr "\"$unit($unit) transfers $int($amount) person$if($eq($amount,1),\"\",\"s\") to $unit($target).\""
+msgid "transfer_unit"
+msgstr "\"$unit($unit) joins our faction.\""
+
msgid "rust_effect_2"
msgstr "\"$unit($mage) calls forth a terrible torment over the enemy. The magical rain makes all iron rusty.\""
diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua
index fde840f98..a7f6d8033 100644
--- a/scripts/tests/e2/init.lua
+++ b/scripts/tests/e2/init.lua
@@ -1,3 +1,4 @@
+-- require 'tests.e2.quit'
require 'tests.e2.movement'
require 'tests.e2.astral'
require 'tests.e2.spells'
diff --git a/scripts/tests/e2/quit.lua b/scripts/tests/e2/quit.lua
new file mode 100644
index 000000000..437494833
--- /dev/null
+++ b/scripts/tests/e2/quit.lua
@@ -0,0 +1,21 @@
+require "lunit"
+
+module("tests.e2.quit", package.seeall, lunit.testcase)
+
+function test_quit_faction()
+ local r = region.create(0, 0, "plain")
+ local f1 = faction.create("human")
+ f1.password = "steamedhams"
+ local f2 = faction.create("human")
+ local u1 = unit.create(f1, r, 10)
+ local u2 = unit.create(f2, r, 10)
+ local u3 = unit.create(f1, r, 10)
+ u1:clear_orders()
+ u2:clear_orders()
+ u1:add_order("STIRB steamedhams PARTEI " .. itoa36(f2.id))
+ u2:add_order("KONTAKTIERE " .. itoa36(u1.id))
+ process_orders()
+ assert_equal(f2, u1.faction)
+ assert_equal(f2, u2.faction)
+ assert_equal(f2, u3.faction)
+end
diff --git a/scripts/tests/init.lua b/scripts/tests/init.lua
index a01e1c75c..2c0786347 100644
--- a/scripts/tests/init.lua
+++ b/scripts/tests/init.lua
@@ -1,4 +1,5 @@
-- new tests 2014-06-11
+require 'tests.laws'
require 'tests.faction'
require 'tests.locale'
require 'tests.movement'
@@ -6,6 +7,5 @@ require 'tests.pool'
require 'tests.regions'
require 'tests.settings'
require 'tests.study'
-require 'tests.laws'
require 'tests.bindings'
require 'tests.hunger'
diff --git a/src/kernel/faction.c b/src/kernel/faction.c
index 86f74dc03..460eb519e 100755
--- a/src/kernel/faction.c
+++ b/src/kernel/faction.c
@@ -216,6 +216,7 @@ faction *addfaction(const char *email, const char *password,
const struct race * frace, const struct locale * loc)
{
faction *f = calloc(1, sizeof(faction));
+ const char *fname;
char buf[128];
if (!f) abort();
@@ -255,7 +256,8 @@ faction *addfaction(const char *email, const char *password,
addlist(&factions, f);
fhash(f);
- slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no));
+ fname = LOC(loc, "factiondefault");
+ slprintf(buf, sizeof(buf), "%s %s", fname ? fname : "faction", itoa36(f->no));
f->name = str_strdup(buf);
if (!f->race) {
diff --git a/src/laws.c b/src/laws.c
index 1041d72a8..a07c7d517 100644
--- a/src/laws.c
+++ b/src/laws.c
@@ -947,6 +947,8 @@ void transfer_faction(faction *fsrc, faction *fdst) {
int skill_count[MAXSKILLS];
int skill_limit[MAXSKILLS];
+ assert(fsrc != fdst);
+
for (sk = 0; sk != MAXSKILLS; ++sk) {
skill_limit[sk] = faction_skill_limit(fdst, sk);
}
@@ -985,6 +987,7 @@ void transfer_faction(faction *fsrc, faction *fdst) {
continue;
}
}
+ ADDMSG(&fdst->msgs, msg_message("transfer_unit", "unit", u));
u_setfaction(u, fdst);
}
}
@@ -1008,6 +1011,7 @@ int quit_cmd(unit * u, struct order *ord)
param_t p;
p = getparam(f->locale);
if (p == P_FACTION) {
+#ifdef QUIT_WITH_TRANSFER
faction *f2 = getfaction();
if (f2 == NULL) {
cmistake(u, ord, 66, MSG_EVENT);
@@ -1033,6 +1037,10 @@ int quit_cmd(unit * u, struct order *ord)
flags = 0;
}
}
+#else
+ log_error("faction %s: QUIT FACTION is disabled.", factionname(f));
+ flags = 0;
+#endif
}
}
f->flags |= flags;
diff --git a/src/laws.test.c b/src/laws.test.c
index 3e6d1a4fb..f74728816 100644
--- a/src/laws.test.c
+++ b/src/laws.test.c
@@ -1915,6 +1915,7 @@ static void test_quit_transfer(CuTest *tc) {
test_teardown();
}
+#ifdef QUIT_WITH_TRANSFER
/**
* Gifting units with limited skills to another faction.
*
@@ -2034,6 +2035,7 @@ static void test_transfer_faction(CuTest *tc) {
test_teardown();
}
+#endif
CuSuite *get_laws_suite(void)
{
@@ -2111,11 +2113,13 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_long_orders);
SUITE_ADD_TEST(suite, test_long_order_on_ocean);
SUITE_ADD_TEST(suite, test_quit);
+#ifdef QUIT_WITH_TRANSFER
SUITE_ADD_TEST(suite, test_quit_transfer);
SUITE_ADD_TEST(suite, test_quit_transfer_limited);
SUITE_ADD_TEST(suite, test_quit_transfer_migrants);
SUITE_ADD_TEST(suite, test_quit_transfer_hero);
SUITE_ADD_TEST(suite, test_transfer_faction);
+#endif
return suite;
}