diff --git a/src/buildno.h b/src/buildno.h index 3a7947aaa..1b97adf8b 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 7 +#define VERSION_BUILD 8 diff --git a/src/kernel/faction.c b/src/kernel/faction.c index edb8a9e2f..2699e1b09 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -74,9 +74,6 @@ faction *factions; static void free_faction(faction * f) { funhash(f); - if (f->alliance && f->alliance->_leader == f) { - setalliance(f, 0); - } if (f->msgs) { free_messagelist(f->msgs->begin); free(f->msgs); @@ -454,7 +451,7 @@ void destroyfaction(faction ** fp) } #endif - if (f->alliance && f->alliance->_leader == f) { + if (f->alliance) { setalliance(f, 0); } @@ -681,8 +678,6 @@ void remove_empty_factions(void) if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) { log_debug("dead: %s", factionname(f)); destroyfaction(fp); - free_faction(f); - free(f); } else { fp = &(*fp)->next; diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 19b4da883..10bc0683b 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -13,6 +13,7 @@ #include "monster.h" #include #include +#include #include #include @@ -46,8 +47,10 @@ static void test_remove_empty_factions_alliance(CuTest *tc) { al = makealliance(0, "Hodor"); setalliance(f, al); CuAssertPtrEquals(tc, f, alliance_get_leader(al)); + CuAssertIntEquals(tc, 1, ql_length(al->members)); remove_empty_factions(); CuAssertPtrEquals(tc, 0, al->_leader); + CuAssertIntEquals(tc, 0, ql_length(al->members)); test_cleanup(); } @@ -61,6 +64,9 @@ static void test_remove_empty_factions(CuTest *tc) { f = test_create_faction(0); fno = f->no; remove_empty_factions(); + CuAssertIntEquals(tc, false, f->_alive); + CuAssertPtrEquals(tc, fm, factions); + CuAssertPtrEquals(tc, NULL, fm->next); CuAssertPtrEquals(tc, 0, findfaction(fno)); CuAssertPtrEquals(tc, fm, get_monsters()); test_cleanup();