forked from github/server
Add a message that contains the password in the first report, so Magellan can pick it up.
Fix a bad type conversion when setting skills.
This commit is contained in:
parent
16e922c334
commit
47dccc667b
|
@ -206,8 +206,8 @@ int level(int days)
|
||||||
void sk_set(skill * sv, int level)
|
void sk_set(skill * sv, int level)
|
||||||
{
|
{
|
||||||
assert(level != 0);
|
assert(level != 0);
|
||||||
sv->weeks = (unsigned char)skill_weeks(level);
|
sv->weeks = skill_weeks(level);
|
||||||
sv->level = (unsigned char)level;
|
sv->level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rule_random_progress(void)
|
static int rule_random_progress(void)
|
||||||
|
|
|
@ -725,11 +725,14 @@ void immigration(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nmr_warnings(void)
|
void nmr_warnings(void)
|
||||||
{
|
{
|
||||||
faction *f, *fa;
|
faction *f, *fa;
|
||||||
#define FRIEND (HELP_GUARD|HELP_MONEY)
|
#define FRIEND (HELP_GUARD|HELP_MONEY)
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
|
if (f->age <= 1) {
|
||||||
|
ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->passw));
|
||||||
|
}
|
||||||
if (!fval(f, FFL_NOIDLEOUT) && turn > f->lastorders) {
|
if (!fval(f, FFL_NOIDLEOUT) && turn > f->lastorders) {
|
||||||
ADDMSG(&f->msgs, msg_message("nmr_warning", ""));
|
ADDMSG(&f->msgs, msg_message("nmr_warning", ""));
|
||||||
if (turn - f->lastorders == NMRTimeout() - 1) {
|
if (turn - f->lastorders == NMRTimeout() - 1) {
|
||||||
|
|
69
src/laws.h
69
src/laws.h
|
@ -32,6 +32,10 @@ extern "C" {
|
||||||
struct order;
|
struct order;
|
||||||
struct attrib_type;
|
struct attrib_type;
|
||||||
|
|
||||||
|
extern struct attrib_type at_germs;
|
||||||
|
extern int dropouts[2];
|
||||||
|
extern int *age;
|
||||||
|
|
||||||
int writepasswd(void);
|
int writepasswd(void);
|
||||||
void demographics(void);
|
void demographics(void);
|
||||||
void immigration(void);
|
void immigration(void);
|
||||||
|
@ -50,11 +54,6 @@ extern "C" {
|
||||||
|
|
||||||
/* eressea-specific. put somewhere else, please. */
|
/* eressea-specific. put somewhere else, please. */
|
||||||
void processorders(void);
|
void processorders(void);
|
||||||
extern struct attrib_type at_germs;
|
|
||||||
|
|
||||||
extern int dropouts[2];
|
|
||||||
extern int *age;
|
|
||||||
|
|
||||||
|
|
||||||
void new_units(void);
|
void new_units(void);
|
||||||
void defaultorders(void);
|
void defaultorders(void);
|
||||||
|
@ -66,35 +65,37 @@ extern "C" {
|
||||||
void sinkships(struct region * r);
|
void sinkships(struct region * r);
|
||||||
void do_enter(struct region *r, bool is_final_attempt);
|
void do_enter(struct region *r, bool is_final_attempt);
|
||||||
|
|
||||||
extern int password_cmd(struct unit *u, struct order *ord);
|
int password_cmd(struct unit *u, struct order *ord);
|
||||||
extern int banner_cmd(struct unit *u, struct order *ord);
|
int banner_cmd(struct unit *u, struct order *ord);
|
||||||
extern int email_cmd(struct unit *u, struct order *ord);
|
int email_cmd(struct unit *u, struct order *ord);
|
||||||
extern int send_cmd(struct unit *u, struct order *ord);
|
int send_cmd(struct unit *u, struct order *ord);
|
||||||
extern int ally_cmd(struct unit* u, struct order *ord);
|
int ally_cmd(struct unit* u, struct order *ord);
|
||||||
extern int prefix_cmd(struct unit *u, struct order *ord);
|
int prefix_cmd(struct unit *u, struct order *ord);
|
||||||
extern int setstealth_cmd(struct unit *u, struct order *ord);
|
int setstealth_cmd(struct unit *u, struct order *ord);
|
||||||
extern int status_cmd(struct unit *u, struct order *ord);
|
int status_cmd(struct unit *u, struct order *ord);
|
||||||
extern int display_cmd(struct unit *u, struct order *ord);
|
int display_cmd(struct unit *u, struct order *ord);
|
||||||
extern int group_cmd(struct unit *u, struct order *ord);
|
int group_cmd(struct unit *u, struct order *ord);
|
||||||
extern int origin_cmd(struct unit *u, struct order *ord);
|
int origin_cmd(struct unit *u, struct order *ord);
|
||||||
extern int quit_cmd(struct unit *u, struct order *ord);
|
int quit_cmd(struct unit *u, struct order *ord);
|
||||||
extern int name_cmd(struct unit *u, struct order *ord);
|
int name_cmd(struct unit *u, struct order *ord);
|
||||||
extern int use_cmd(struct unit *u, struct order *ord);
|
int use_cmd(struct unit *u, struct order *ord);
|
||||||
extern int siege_cmd(struct unit *u, struct order *ord);
|
int siege_cmd(struct unit *u, struct order *ord);
|
||||||
extern int leave_cmd(struct unit *u, struct order *ord);
|
int leave_cmd(struct unit *u, struct order *ord);
|
||||||
extern int pay_cmd(struct unit *u, struct order *ord);
|
int pay_cmd(struct unit *u, struct order *ord);
|
||||||
extern int promotion_cmd(struct unit *u, struct order *ord);
|
int promotion_cmd(struct unit *u, struct order *ord);
|
||||||
extern int renumber_cmd(struct unit *u, struct order *ord);
|
int renumber_cmd(struct unit *u, struct order *ord);
|
||||||
extern int combatspell_cmd(struct unit *u, struct order *ord);
|
int combatspell_cmd(struct unit *u, struct order *ord);
|
||||||
extern int contact_cmd(struct unit *u, struct order *ord);
|
int contact_cmd(struct unit *u, struct order *ord);
|
||||||
extern int guard_on_cmd(struct unit *u, struct order *ord);
|
int guard_on_cmd(struct unit *u, struct order *ord);
|
||||||
extern int guard_off_cmd(struct unit *u, struct order *ord);
|
int guard_off_cmd(struct unit *u, struct order *ord);
|
||||||
extern int reshow_cmd(struct unit *u, struct order *ord);
|
int reshow_cmd(struct unit *u, struct order *ord);
|
||||||
extern int mail_cmd(struct unit *u, struct order *ord);
|
int mail_cmd(struct unit *u, struct order *ord);
|
||||||
extern int reserve_cmd(struct unit *u, struct order *ord);
|
int reserve_cmd(struct unit *u, struct order *ord);
|
||||||
extern int reserve_self(struct unit *u, struct order *ord);
|
int reserve_self(struct unit *u, struct order *ord);
|
||||||
extern int claim_cmd(struct unit *u, struct order *ord);
|
int claim_cmd(struct unit *u, struct order *ord);
|
||||||
extern int follow_cmd(struct unit *u, struct order *ord);
|
int follow_cmd(struct unit *u, struct order *ord);
|
||||||
|
|
||||||
|
void nmr_warnings(void);
|
||||||
|
|
||||||
bool cansee(const struct faction *f, const struct region *r,
|
bool cansee(const struct faction *f, const struct region *r,
|
||||||
const struct unit *u, int modifier);
|
const struct unit *u, int modifier);
|
||||||
|
|
|
@ -845,7 +845,7 @@ static void test_long_order_multi_long(CuTest *tc) {
|
||||||
update_long_order(u);
|
update_long_order(u);
|
||||||
CuAssertPtrNotNull(tc, u->thisorder);
|
CuAssertPtrNotNull(tc, u->thisorder);
|
||||||
CuAssertPtrNotNull(tc, u->orders);
|
CuAssertPtrNotNull(tc, u->orders);
|
||||||
CuAssertStrEquals(tc, "error52", test_get_messagetype(u->faction->msgs->begin->msg));
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error52"));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +860,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
|
||||||
update_long_order(u);
|
update_long_order(u);
|
||||||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||||
CuAssertPtrNotNull(tc, u->orders);
|
CuAssertPtrNotNull(tc, u->orders);
|
||||||
CuAssertStrEquals(tc, "error52", test_get_messagetype(u->faction->msgs->begin->msg));
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error52"));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ static void test_long_order_buy_cast(CuTest *tc) {
|
||||||
update_long_order(u);
|
update_long_order(u);
|
||||||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||||
CuAssertPtrNotNull(tc, u->orders);
|
CuAssertPtrNotNull(tc, u->orders);
|
||||||
CuAssertStrEquals(tc, "error52", test_get_messagetype(u->faction->msgs->begin->msg));
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error52"));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,7 +927,7 @@ static void test_ally_cmd_errors(CuTest *tc) {
|
||||||
|
|
||||||
ord = create_order(K_ALLY, u->faction->locale, itoa36(fid));
|
ord = create_order(K_ALLY, u->faction->locale, itoa36(fid));
|
||||||
ally_cmd(u, ord);
|
ally_cmd(u, ord);
|
||||||
CuAssertStrEquals(tc, "error66", test_get_messagetype(u->faction->msgs->begin->msg));
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error66"));
|
||||||
free_order(ord);
|
free_order(ord);
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
@ -974,9 +974,29 @@ static void test_ally_cmd(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_nmr_warnings(CuTest *tc) {
|
||||||
|
faction *f1, *f2;
|
||||||
|
test_cleanup();
|
||||||
|
set_param(&global.parameters, "nmr.timeout", "3");
|
||||||
|
f1 = test_create_faction(0);
|
||||||
|
f2 = test_create_faction(0);
|
||||||
|
f2->age = 2;
|
||||||
|
f2->lastorders = 1;
|
||||||
|
turn = 3;
|
||||||
|
CuAssertIntEquals(tc, 0, f1->age);
|
||||||
|
nmr_warnings();
|
||||||
|
CuAssertPtrNotNull(tc, f1->msgs);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f1->msgs, "changepasswd"));
|
||||||
|
CuAssertPtrNotNull(tc, f2->msgs);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f2->msgs, "nmr_warning"));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f2->msgs, "nmr_warning_final"));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_laws_suite(void)
|
CuSuite *get_laws_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_nmr_warnings);
|
||||||
SUITE_ADD_TEST(suite, test_ally_cmd);
|
SUITE_ADD_TEST(suite, test_ally_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_ally_cmd_errors);
|
SUITE_ADD_TEST(suite, test_ally_cmd_errors);
|
||||||
SUITE_ADD_TEST(suite, test_long_order_normal);
|
SUITE_ADD_TEST(suite, test_long_order_normal);
|
||||||
|
|
|
@ -2059,9 +2059,6 @@ const char *charset)
|
||||||
|
|
||||||
if (f->age <= 2) {
|
if (f->age <= 2) {
|
||||||
const char *s;
|
const char *s;
|
||||||
if (f->age <= 1) {
|
|
||||||
ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->passw));
|
|
||||||
}
|
|
||||||
RENDER(f, buf, sizeof(buf), ("newbie_password", "password", f->passw));
|
RENDER(f, buf, sizeof(buf), ("newbie_password", "password", f->passw));
|
||||||
newline(out);
|
newline(out);
|
||||||
centre(out, buf, true);
|
centre(out, buf, true);
|
||||||
|
|
11
src/tests.c
11
src/tests.c
|
@ -244,6 +244,17 @@ const char * test_get_messagetype(const message *msg) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct message * test_find_messagetype(struct message_list *msgs, const char *name) {
|
||||||
|
struct mlist *ml;
|
||||||
|
assert(msgs);
|
||||||
|
for (ml = msgs->begin; ml; ml = ml->next) {
|
||||||
|
if (strcmp(name, test_get_messagetype(ml->msg)) == 0) {
|
||||||
|
return ml->msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const message_type *register_msg(const char *type, int n_param, ...) {
|
const message_type *register_msg(const char *type, int n_param, ...) {
|
||||||
char **argv;
|
char **argv;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
|
@ -41,6 +41,7 @@ extern "C" {
|
||||||
int RunAllTests(void);
|
int RunAllTests(void);
|
||||||
void test_translate_param(const struct locale *lang, param_t param, const char *text);
|
void test_translate_param(const struct locale *lang, param_t param, const char *text);
|
||||||
const char * test_get_messagetype(const struct message *msg);
|
const char * test_get_messagetype(const struct message *msg);
|
||||||
|
struct message * test_find_messagetype(struct message_list *msgs, const char *name);
|
||||||
struct message * test_get_last_message(struct message_list *mlist);
|
struct message * test_get_last_message(struct message_list *mlist);
|
||||||
|
|
||||||
const struct message_type *register_msg(const char *type, int n_param, ...);
|
const struct message_type *register_msg(const char *type, int n_param, ...);
|
||||||
|
|
Loading…
Reference in New Issue