From cd28f3aee44f9630fe213dfa7723790c99c0ff46 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 May 2019 11:11:30 +0200 Subject: [PATCH] heroes lose their status when gifted. --- src/laws.c | 1 + src/laws.test.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/laws.c b/src/laws.c index 2f86e79a6..e8200c262 100644 --- a/src/laws.c +++ b/src/laws.c @@ -965,6 +965,7 @@ void transfer_faction(faction *fsrc, faction *fdst) { for (u = fsrc->units; u != NULL; u = u->nextF) { if (u_race(u) == fdst->race) { + u->flags &= ~UFL_HERO; if (give_unit_allowed(u) == 0) { if (u->skills) { int i; diff --git a/src/laws.test.c b/src/laws.test.c index c5dafd851..33742f427 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1984,7 +1984,7 @@ static void test_quit_transfer_migrants(CuTest *tc) { } /** - * Heroes cannot be gifted to another faction. + * A hero that is gifted to another faction loses their status. */ static void test_quit_transfer_hero(CuTest *tc) { faction *f1, *f2; @@ -2006,7 +2006,8 @@ static void test_quit_transfer_hero(CuTest *tc) { quit_cmd(u1, u1->thisorder); CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT); - CuAssertPtrEquals(tc, f1, u1->faction); + CuAssertPtrEquals(tc, f2, u1->faction); + CuAssertIntEquals(tc, 0, u1->flags & UFL_HERO); test_teardown(); }