forked from github/server
emit a password message for newbie factions
This commit is contained in:
parent
8d4a83d1b4
commit
1c7f3fab44
|
@ -249,6 +249,7 @@ faction *addfaction(const char *email, const char *password,
|
||||||
if (!password) password = itoa36(rng_int());
|
if (!password) password = itoa36(rng_int());
|
||||||
faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT));
|
faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT));
|
||||||
ADDMSG(&f->msgs, msg_message("changepasswd", "value", password));
|
ADDMSG(&f->msgs, msg_message("changepasswd", "value", password));
|
||||||
|
f->flags |= FFL_PWMSG;
|
||||||
|
|
||||||
f->alliance_joindate = turn;
|
f->alliance_joindate = turn;
|
||||||
f->lastorders = turn;
|
f->lastorders = turn;
|
||||||
|
|
|
@ -37,10 +37,11 @@ extern "C" {
|
||||||
extern struct attrib_type at_maxmagicians;
|
extern struct attrib_type at_maxmagicians;
|
||||||
|
|
||||||
/* faction flags */
|
/* faction flags */
|
||||||
#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */
|
#define FFL_NEWID (1<<0) // Die Partei hat bereits einmal ihre no gewechselt
|
||||||
#define FFL_ISNEW (1<<1)
|
#define FFL_ISNEW (1<<1)
|
||||||
|
#define FFL_PWMSG (1<<2) // received a "new password" message
|
||||||
#define FFL_QUIT (1<<3)
|
#define FFL_QUIT (1<<3)
|
||||||
#define FFL_CURSED (1<<4) /* you're going to have a bad time */
|
#define FFL_CURSED (1<<4) // you're going to have a bad time
|
||||||
#define FFL_DEFENDER (1<<10)
|
#define FFL_DEFENDER (1<<10)
|
||||||
#define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
|
#define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
|
||||||
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
|
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
|
||||||
|
|
|
@ -2214,6 +2214,7 @@ int password_cmd(unit * u, struct order *ord)
|
||||||
faction_setpassword(u->faction, password_encode(pwbuf, PASSWORD_DEFAULT));
|
faction_setpassword(u->faction, password_encode(pwbuf, PASSWORD_DEFAULT));
|
||||||
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
||||||
"value", pwbuf));
|
"value", pwbuf));
|
||||||
|
u->faction->flags |= FFL_PWMSG;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1336,6 +1336,14 @@ void prepare_report(report_context *ctx, faction *f)
|
||||||
rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name);
|
rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (f->age<=2) {
|
||||||
|
if ((f->flags&FFL_PWMSG)==0) {
|
||||||
|
// TODO: this assumes unencrypted passwords
|
||||||
|
f->flags |= FFL_PWMSG;
|
||||||
|
ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->_password));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx->f = f;
|
ctx->f = f;
|
||||||
ctx->report_time = time(NULL);
|
ctx->report_time = time(NULL);
|
||||||
ctx->addresses = NULL;
|
ctx->addresses = NULL;
|
||||||
|
|
|
@ -226,6 +226,23 @@ static void test_arg_resources(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_newbie_password_message(CuTest *tc) {
|
||||||
|
report_context ctx;
|
||||||
|
faction *f;
|
||||||
|
test_setup();
|
||||||
|
f = test_create_faction(0);
|
||||||
|
f->age = 5;
|
||||||
|
CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG);
|
||||||
|
prepare_report(&ctx, f);
|
||||||
|
CuAssertIntEquals(tc, 0, f->flags&FFL_PWMSG);
|
||||||
|
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "changepasswd"));
|
||||||
|
f->age=2;
|
||||||
|
prepare_report(&ctx, f);
|
||||||
|
CuAssertIntEquals(tc, FFL_PWMSG, f->flags&FFL_PWMSG);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd"));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_prepare_travelthru(CuTest *tc) {
|
static void test_prepare_travelthru(CuTest *tc) {
|
||||||
report_context ctx;
|
report_context ctx;
|
||||||
faction *f, *f2;
|
faction *f, *f2;
|
||||||
|
@ -465,6 +482,7 @@ static void test_seen_travelthru(CuTest *tc) {
|
||||||
CuSuite *get_reports_suite(void)
|
CuSuite *get_reports_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_newbie_password_message);
|
||||||
SUITE_ADD_TEST(suite, test_prepare_report);
|
SUITE_ADD_TEST(suite, test_prepare_report);
|
||||||
SUITE_ADD_TEST(suite, test_seen_neighbours);
|
SUITE_ADD_TEST(suite, test_seen_neighbours);
|
||||||
SUITE_ADD_TEST(suite, test_seen_travelthru);
|
SUITE_ADD_TEST(suite, test_seen_travelthru);
|
||||||
|
|
Loading…
Reference in New Issue