From 4a31bea3b9e138e285c92af405cff1c270c5b77e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 09:46:07 +0200 Subject: [PATCH 1/3] increase build number, new version installed --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 0ffd496d9..d1f3c3fcf 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 5 -#define VERSION_BUILD 1 +#define VERSION_BUILD 2 From 04bf7153f09211ef0101b33c043d6e2fec952acb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Jun 2015 17:49:22 +0200 Subject: [PATCH 2/3] remove a faction from its alliance when it is dead. --- src/kernel/alliance.test.c | 3 +++ src/kernel/faction.c | 3 +++ src/kernel/faction.test.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/kernel/alliance.test.c b/src/kernel/alliance.test.c index ad936fac9..98e60e943 100644 --- a/src/kernel/alliance.test.c +++ b/src/kernel/alliance.test.c @@ -55,6 +55,9 @@ static void test_alliance_join(CuTest *tc) { setalliance(fix.f2, al); CuAssertPtrEquals(tc, fix.f1, alliance_get_leader(al)); CuAssertTrue(tc, is_allied(fix.f1, fix.f2)); + setalliance(fix.f1, 0); + CuAssertPtrEquals(tc, fix.f2, alliance_get_leader(al)); + CuAssertTrue(tc, !is_allied(fix.f1, fix.f2)); test_cleanup(); } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 72643c3cb..95d3b7392 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -651,6 +651,9 @@ void remove_empty_factions(void) *fp = f->next; funhash(f); free_faction(f); + if (f->alliance && f->alliance->_leader == f) { + setalliance(f, 0); + } free(f); } else diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 4852b08dc..ef22b40cd 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,22 @@ static void test_remove_empty_factions_allies(CuTest *tc) { test_cleanup(); } +static void test_remove_empty_factions_alliance(CuTest *tc) { + faction *f; + struct alliance *al; + region *r; + + test_cleanup(); + r = test_create_region(0, 0, 0); + f = test_create_faction(0); + al = makealliance(0, "Hodor"); + setalliance(f, al); + CuAssertPtrEquals(tc, f, alliance_get_leader(al)); + remove_empty_factions(); + CuAssertPtrEquals(tc, 0, al->_leader); + test_cleanup(); +} + static void test_remove_empty_factions(CuTest *tc) { faction *f, *fm; int fno; @@ -130,6 +147,7 @@ CuSuite *get_faction_suite(void) SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_remove_empty_factions); SUITE_ADD_TEST(suite, test_remove_empty_factions_allies); + SUITE_ADD_TEST(suite, test_remove_empty_factions_alliance); SUITE_ADD_TEST(suite, test_remove_dead_factions); SUITE_ADD_TEST(suite, test_get_monsters); SUITE_ADD_TEST(suite, test_set_origin); From a085442b8f03264e0cc9a396560d394d2a271023 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Jun 2015 17:54:39 +0200 Subject: [PATCH 3/3] eliminate unused variable. --- src/kernel/faction.test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index ef22b40cd..8b3c7e0af 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -34,10 +34,8 @@ static void test_remove_empty_factions_allies(CuTest *tc) { static void test_remove_empty_factions_alliance(CuTest *tc) { faction *f; struct alliance *al; - region *r; test_cleanup(); - r = test_create_region(0, 0, 0); f = test_create_faction(0); al = makealliance(0, "Hodor"); setalliance(f, al);