diff --git a/scripts/tests/faction.lua b/scripts/tests/faction.lua index 38fdc4eb7..87a6b5100 100644 --- a/scripts/tests/faction.lua +++ b/scripts/tests/faction.lua @@ -17,7 +17,7 @@ function setup() end function test_faction_flags() - assert_equal(2, f.flags) -- FFL_ISNEW + assert_equal(6, f.flags) -- FFL_ISNEW|FFL_PWMSG f.flags = 42 assert_equal(42, f.flags) end diff --git a/src/kernel/faction.c b/src/kernel/faction.c index d67619752..6b601f002 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -247,11 +247,6 @@ faction *addfaction(const char *email, const char *password, log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email); } - if (!password) password = itoa36(rng_int()); - faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); - ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); - f->flags |= FFL_PWMSG; - f->alliance_joindate = turn; f->lastorders = turn; f->_alive = true; @@ -260,7 +255,11 @@ faction *addfaction(const char *email, const char *password, f->magiegebiet = 0; f->locale = loc; f->subscription = subscription; - f->flags = FFL_ISNEW; + f->flags = FFL_ISNEW|FFL_PWMSG; + + if (!password) password = itoa36(rng_int()); + faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT)); + ADDMSG(&f->msgs, msg_message("changepasswd", "value", password)); f->options = want(O_REPORT) | want(O_ZUGVORLAGE) | want(O_COMPUTER) | want(O_COMPRESS) | diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 3d81b5d3c..441ca5038 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -117,7 +117,7 @@ static void test_addfaction(CuTest *tc) { CuAssertTrue(tc, checkpasswd(f, "hurrdurr")); CuAssertPtrEquals(tc, (void *)lang, (void *)f->locale); CuAssertIntEquals(tc, 1234, f->subscription); - CuAssertIntEquals(tc, FFL_ISNEW, f->flags); + CuAssertIntEquals(tc, FFL_ISNEW|FFL_PWMSG, f->flags); CuAssertIntEquals(tc, 0, f->age); CuAssertTrue(tc, faction_alive(f)); CuAssertIntEquals(tc, M_GRAY, f->magiegebiet); diff --git a/src/reports.test.c b/src/reports.test.c index 389d9c130..728145758 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -232,7 +232,7 @@ static void test_newbie_password_message(CuTest *tc) { test_setup(); f = test_create_faction(0); f->age = 5; - CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); + f->flags = 0; prepare_report(&ctx, f); CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "changepasswd"));