forked from github/server
BUG 2458: fix insect recruit warnings.
This commit is contained in:
parent
2697d78c07
commit
3880960acf
5 changed files with 52 additions and 30 deletions
|
@ -1773,7 +1773,7 @@ msgid "storm"
|
||||||
msgstr "\"Die $ship($ship) wird in $region($region) von Stürmen abgetrieben$if($sink,\" und sinkt\",\"\").\""
|
msgstr "\"Die $ship($ship) wird in $region($region) von Stürmen abgetrieben$if($sink,\" und sinkt\",\"\").\""
|
||||||
|
|
||||||
msgid "nr_insectwinter"
|
msgid "nr_insectwinter"
|
||||||
msgstr "Es ist Winter, und Insekten können nur in Wüsten oder mit Hilfe des Nestwärme-Tranks Personen rekrutieren."
|
msgstr "Insekten können wegen des Winterwetters in der kommenden Woche nur in Wüsten oder mit Hilfe des Nestwärme-Tranks Personen rekrutieren."
|
||||||
|
|
||||||
msgid "spellfail_nomonsters"
|
msgid "spellfail_nomonsters"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Dieser Zauber kann nicht auf Monster gezaubert werden.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Dieser Zauber kann nicht auf Monster gezaubert werden.\""
|
||||||
|
@ -2727,7 +2727,7 @@ msgid "volcanostartsmoke"
|
||||||
msgstr "\"Aus dem Vulkankrater von $region($region) steigt plötzlich Rauch.\""
|
msgstr "\"Aus dem Vulkankrater von $region($region) steigt plötzlich Rauch.\""
|
||||||
|
|
||||||
msgid "nr_insectfall"
|
msgid "nr_insectfall"
|
||||||
msgstr "Es ist Spätherbst, und diese Woche ist die letzte vor dem Winter, in der Insekten rekrutieren können."
|
msgstr "Es ist Spätherbst, und die kommende Woche ist die letzte vor dem Winter, in der Insekten rekrutieren können."
|
||||||
|
|
||||||
msgid "error296"
|
msgid "error296"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Hier werden niemals Bäume wachsen.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Hier werden niemals Bäume wachsen.\""
|
||||||
|
|
|
@ -477,7 +477,7 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders)
|
||||||
if (rc == get_race(RC_INSECT)) {
|
if (rc == get_race(RC_INSECT)) {
|
||||||
gamedate date;
|
gamedate date;
|
||||||
get_gamedate(turn, &date);
|
get_gamedate(turn, &date);
|
||||||
if (date.season == 0 && r->terrain != newterrain(T_DESERT)) {
|
if (date.season == SEASON_WINTER && r->terrain != newterrain(T_DESERT)) {
|
||||||
bool usepotion = false;
|
bool usepotion = false;
|
||||||
unit *u2;
|
unit *u2;
|
||||||
|
|
||||||
|
|
|
@ -1517,28 +1517,27 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_warnings(faction *f, const gamedate *date)
|
void report_warnings(faction *f, int now)
|
||||||
{
|
{
|
||||||
if (f->age < NewbieImmunity()) {
|
if (f->age < NewbieImmunity()) {
|
||||||
ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns",
|
ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns",
|
||||||
NewbieImmunity() - f->age));
|
NewbieImmunity() - f->age));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date) {
|
|
||||||
if (f->race == get_race(RC_INSECT)) {
|
if (f->race == get_race(RC_INSECT)) {
|
||||||
if (date->season == 0) {
|
gamedate date;
|
||||||
|
get_gamedate(now + 1, &date);
|
||||||
|
|
||||||
|
if (date.season == SEASON_WINTER) {
|
||||||
ADDMSG(&f->msgs, msg_message("nr_insectwinter", ""));
|
ADDMSG(&f->msgs, msg_message("nr_insectwinter", ""));
|
||||||
}
|
}
|
||||||
else {
|
else if (date.season == SEASON_AUTUMN) {
|
||||||
gamedate next;
|
if (get_gamedate(now + 2 + 2, &date)->season == SEASON_WINTER) {
|
||||||
get_gamedate(date->turn + 1, &next);
|
|
||||||
if (next.season == 0) {
|
|
||||||
ADDMSG(&f->msgs, msg_message("nr_insectfall", ""));
|
ADDMSG(&f->msgs, msg_message("nr_insectfall", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** set region.seen based on visibility by one faction.
|
/** set region.seen based on visibility by one faction.
|
||||||
*
|
*
|
||||||
|
@ -1552,11 +1551,9 @@ void prepare_report(report_context *ctx, faction *f)
|
||||||
static bool rule_region_owners;
|
static bool rule_region_owners;
|
||||||
static bool rule_lighthouse_units;
|
static bool rule_lighthouse_units;
|
||||||
const struct building_type *bt_lighthouse = bt_find("lighthouse");
|
const struct building_type *bt_lighthouse = bt_find("lighthouse");
|
||||||
gamedate now;
|
|
||||||
|
|
||||||
/* Insekten-Winter-Warnung */
|
/* Insekten-Winter-Warnung */
|
||||||
get_gamedate(turn, &now);
|
report_warnings(f, turn);
|
||||||
report_warnings(f, &now);
|
|
||||||
|
|
||||||
if (bt_lighthouse && config_changed(&config)) {
|
if (bt_lighthouse && config_changed(&config)) {
|
||||||
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);
|
||||||
|
|
|
@ -115,7 +115,7 @@ extern "C" {
|
||||||
int size, const struct faction *viewer, bool see_unit);
|
int size, const struct faction *viewer, bool see_unit);
|
||||||
int report_items(const struct unit *u, struct item *result, int size,
|
int report_items(const struct unit *u, struct item *result, int size,
|
||||||
const struct unit *owner, const struct faction *viewer);
|
const struct unit *owner, const struct faction *viewer);
|
||||||
void report_warnings(struct faction *f, const struct gamedate *date);
|
void report_warnings(struct faction *f, int now);
|
||||||
void report_raceinfo(const struct race *rc, const struct locale *lang, char *buf, size_t length);
|
void report_raceinfo(const struct race *rc, const struct locale *lang, char *buf, size_t length);
|
||||||
void report_race_skills(const struct race *rc, char *zText, size_t length, const struct locale *lang);
|
void report_race_skills(const struct race *rc, char *zText, size_t length, const struct locale *lang);
|
||||||
void report_item(const struct unit *owner, const struct item *i,
|
void report_item(const struct unit *owner, const struct item *i,
|
||||||
|
|
|
@ -785,23 +785,48 @@ static void test_stealth_modifier(CuTest *tc) {
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_calendar(void) {
|
||||||
|
months_per_year = 9;
|
||||||
|
month_season = malloc(sizeof(int) * months_per_year);
|
||||||
|
month_season[0] = SEASON_SUMMER;
|
||||||
|
month_season[1] = SEASON_AUTUMN;
|
||||||
|
month_season[2] = SEASON_AUTUMN;
|
||||||
|
month_season[3] = SEASON_WINTER;
|
||||||
|
month_season[4] = SEASON_WINTER;
|
||||||
|
month_season[5] = SEASON_WINTER;
|
||||||
|
month_season[6] = SEASON_SPRING;
|
||||||
|
month_season[7] = SEASON_SPRING;
|
||||||
|
month_season[8] = SEASON_SUMMER;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_insect_warnings(CuTest *tc) {
|
static void test_insect_warnings(CuTest *tc) {
|
||||||
faction *f;
|
faction *f;
|
||||||
gamedate gd;
|
gamedate gd;
|
||||||
|
|
||||||
/* OBS: in unit tests, get_gamedate always returns season = 0 */
|
|
||||||
test_setup();
|
test_setup();
|
||||||
|
setup_calendar();
|
||||||
|
config_set_int("game.start", 184);
|
||||||
test_inject_messagetypes();
|
test_inject_messagetypes();
|
||||||
f = test_create_faction(test_create_race("insect"));
|
f = test_create_faction(test_create_race("insect"));
|
||||||
|
|
||||||
gd.turn = 0;
|
CuAssertIntEquals(tc, SEASON_AUTUMN, get_gamedate(1083, &gd)->season);
|
||||||
gd.season = 3;
|
report_warnings(f, gd.turn);
|
||||||
report_warnings(f, &gd);
|
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "nr_insectfall"));
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "nr_insectfall"));
|
|
||||||
|
|
||||||
gd.season = 0;
|
|
||||||
report_warnings(f, &gd);
|
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "nr_insectwinter"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "nr_insectwinter"));
|
||||||
|
test_clear_messages(f);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, SEASON_AUTUMN, get_gamedate(1082, &gd)->season);
|
||||||
|
report_warnings(f, gd.turn);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "nr_insectfall"));
|
||||||
|
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "nr_insectwinter"));
|
||||||
|
test_clear_messages(f);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, SEASON_WINTER, get_gamedate(1084, &gd)->season);
|
||||||
|
report_warnings(f, gd.turn);
|
||||||
|
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "nr_insectfall"));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "nr_insectwinter"));
|
||||||
|
test_clear_messages(f);
|
||||||
|
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,16 +835,16 @@ static void test_newbie_warning(CuTest *tc) {
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
test_inject_messagetypes();
|
test_inject_messagetypes();
|
||||||
f = test_create_faction(test_create_race("insect"));
|
f = test_create_faction(NULL);
|
||||||
config_set_int("NewbieImmunity", 3);
|
config_set_int("NewbieImmunity", 3);
|
||||||
|
|
||||||
f->age = 2;
|
f->age = 2;
|
||||||
report_warnings(f, NULL);
|
report_warnings(f, 0);
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "newbieimmunity"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "newbieimmunity"));
|
||||||
test_clear_messages(f);
|
test_clear_messages(f);
|
||||||
|
|
||||||
f->age = 3;
|
f->age = 3;
|
||||||
report_warnings(f, NULL);
|
report_warnings(f, 0);
|
||||||
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunity"));
|
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunity"));
|
||||||
test_clear_messages(f);
|
test_clear_messages(f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue