From e36f607fedec70bd7ea1ce8b53e8345d8405580d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Sep 2017 11:32:20 +0200 Subject: [PATCH 1/5] send bz2 report with new mail text location --- process/send-bz2-report | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/send-bz2-report b/process/send-bz2-report index 983564bea..f4b2ad6ea 100755 --- a/process/send-bz2-report +++ b/process/send-bz2-report @@ -26,4 +26,4 @@ addr=$1 subj=$2 shift 2 -cat $ERESSEA/etc/$TEMPLATE | mutt -F $ERESSEA/etc/muttrc -s "$subj" -a $* -- $addr +cat $ERESSEA/server/etc/$TEMPLATE | mutt -F $ERESSEA/etc/muttrc -s "$subj" -a $* -- $addr From 0386aafa7b6850d1c89935e6312ad9f60eb87ef1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Sep 2017 20:28:27 +0200 Subject: [PATCH 2/5] new template file location --- process/send-zip-report | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/send-zip-report b/process/send-zip-report index 7926de8f7..6ea2ea8e7 100755 --- a/process/send-zip-report +++ b/process/send-zip-report @@ -27,7 +27,7 @@ fi if [ -e $GAME/$TEMPLATE ]; then TEMPLATE=$GAME/$TEMPLATE else -TEMPLATE=$ERESSEA/etc/$TEMPLATE +TEMPLATE=$ERESSEA/server/etc/$TEMPLATE fi if [ ! -e $TEMPLATE ]; then From 9ff98b5b23d75df196d325fbd01ea04312fc2f5d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 13 Oct 2017 19:32:31 +0200 Subject: [PATCH 3/5] more fine-grained testing for cansee --- src/laws.test.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/laws.test.c b/src/laws.test.c index 87d5838b9..ec14ac4cc 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1590,12 +1590,28 @@ static void test_cansee(CuTest *tc) { set_level(u2, SK_STEALTH, 1); CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0, seen_unit)); - CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0, seen_spell)); - CuAssertTrue(tc, cansee(u->faction, u->region, u2, 1, seen_spell)); set_level(u, SK_PERCEPTION, 1); CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0, seen_unit)); - CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0, seen_spell)); + + test_cleanup(); +} + +static void test_cansee_spell(CuTest *tc) { + unit *u2; + faction *f; + + test_setup(); + f = test_create_faction(0); + u2 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + + CuAssertTrue(tc, cansee(f, u2->region, u2, 0, seen_spell)); + CuAssertTrue(tc, cansee(f, u2->region, u2, 0, seen_battle)); + + set_level(u2, SK_STEALTH, 1); + CuAssertTrue(tc, !cansee(f, u2->region, u2, 0, seen_spell)); + CuAssertTrue(tc, cansee(f, u2->region, u2, 1, seen_spell)); + CuAssertTrue(tc, cansee(f, u2->region, u2, 1, seen_battle)); test_cleanup(); } @@ -1738,6 +1754,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_demon_hunger); SUITE_ADD_TEST(suite, test_armedmen); SUITE_ADD_TEST(suite, test_cansee); + SUITE_ADD_TEST(suite, test_cansee_spell); SUITE_ADD_TEST(suite, test_cansee_items); return suite; From a0a39124f0baf6f097c0d80b149fe939785bf0e0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Oct 2017 20:20:43 +0200 Subject: [PATCH 4/5] additional tests for cansee, to support fixing bug 2374 --- clibs | 2 +- src/laws.test.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/clibs b/clibs index d286006a2..147584ad7 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit d286006a28c8aa7cd70ed7fd4cd172b50ade9727 +Subproject commit 147584ad70b220abf6a4e97ca76e785729b9ac32 diff --git a/src/laws.test.c b/src/laws.test.c index 4d6adbfe9..0d0e66eea 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1552,6 +1552,90 @@ static void test_armedmen(CuTest *tc) { test_cleanup(); } +static void test_cansee(CuTest *tc) { + unit *u, *u2; + + test_setup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u2 = test_create_unit(test_create_faction(0), u->region); + + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + set_level(u2, SK_STEALTH, 1); + CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0)); + + set_level(u, SK_PERCEPTION, 1); + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + test_cleanup(); +} + +static void test_cansee_ring(CuTest *tc) { + unit *u, *u2; + item_type *itype[2]; + + test_setup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u2 = test_create_unit(test_create_faction(0), u->region); + scale_number(u2, 2); + + itype[0] = test_create_itemtype("roi"); + itype[1] = test_create_itemtype("aots"); + CuAssertPtrNotNull(tc, get_resourcetype(R_RING_OF_INVISIBILITY)); + CuAssertPtrEquals(tc, itype[0]->rtype, (void *)get_resourcetype(R_RING_OF_INVISIBILITY)); + CuAssertPtrNotNull(tc, get_resourcetype(R_AMULET_OF_TRUE_SEEING)); + CuAssertPtrEquals(tc, itype[1]->rtype, (void *)get_resourcetype(R_AMULET_OF_TRUE_SEEING)); + + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + /* a single ring is not enough to hide two people */ + i_change(&u2->items, itype[0], 1); + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + /* two rings can hide two people */ + i_change(&u2->items, itype[0], 1); + CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0)); + + /* one amulet negates one of the two rings */ + i_change(&u->items, itype[1], 1); + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + test_cleanup(); +} + +static void test_cansee_sphere(CuTest *tc) { + unit *u, *u2; + item_type *itype[2]; + + test_setup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u2 = test_create_unit(test_create_faction(0), u->region); + + itype[0] = test_create_itemtype("sphereofinv"); + itype[1] = test_create_itemtype("aots"); + CuAssertPtrNotNull(tc, get_resourcetype(R_SPHERE_OF_INVISIBILITY)); + CuAssertPtrEquals(tc, itype[0]->rtype, (void *)get_resourcetype(R_SPHERE_OF_INVISIBILITY)); + CuAssertPtrNotNull(tc, get_resourcetype(R_AMULET_OF_TRUE_SEEING)); + CuAssertPtrEquals(tc, itype[1]->rtype, (void *)get_resourcetype(R_AMULET_OF_TRUE_SEEING)); + + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + /* a single sphere can hide 100 people */ + scale_number(u2, 100); + i_change(&u2->items, itype[0], 1); + CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0)); + + /* one single amulet negates it? */ + i_change(&u->items, itype[1], 1); + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + /* number of people inside the sphere does not matter? */ + scale_number(u2, 99); + CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0)); + + test_cleanup(); +} + CuSuite *get_laws_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -1618,6 +1702,9 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_immigration); SUITE_ADD_TEST(suite, test_demon_hunger); SUITE_ADD_TEST(suite, test_armedmen); - + SUITE_ADD_TEST(suite, test_cansee); + SUITE_ADD_TEST(suite, test_cansee_ring); + SUITE_ADD_TEST(suite, test_cansee_sphere); + return suite; } From b337373bc94f8c838b33a3be476b1d16e2110a80 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 16 Oct 2017 20:38:52 +0200 Subject: [PATCH 5/5] shorten some names, too many messages with the same prefix are inefficient. --- res/core/messages.xml | 34 +++++++++++++++++----------------- src/battle.c | 26 +++++++++++++------------- src/items/weapons.c | 4 ++-- src/report.c | 2 +- src/spells/combatspells.c | 32 ++++++++++++++++---------------- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index a500a41ac..9b06b3f48 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -7154,7 +7154,7 @@ "Das Wurmloch in $region($region) schließt sich." "The wormhole in $region($region) disappears." - + @@ -7162,7 +7162,7 @@ "$int($amount) Krieger von $unit($unit) benutzen ihre Flammenschwerter." "$int($amount) fighters of $unit($unit) are using their flaming sword." - + @@ -7170,35 +7170,35 @@ "$int($amount) Krieger von $unit($unit) feuern ihre Katapulte ab." "$int($amount) fighters of $unit($unit) launch their catapults." - + "Der Kampf wurde ausgelöst von ${factions}." "The battle was initiated by ${factions}." - + "Eine Person von $unit($unit) konnte durch einen Heiltrank überleben." "A fighter of $unit($unit) was saved by a healing potion." - + "$unit($unit) konnte dem Gegner eine Falle stellen." "$unit($unit) lured the enemy into an ambush." - + "$unit($unit) überrascht den Gegner." "$unit($unit) surprises the enemies." - + @@ -7206,20 +7206,20 @@ "$unit($unit) versucht $spell($spell) zu zaubern, doch der Zauber schlägt fehl!" "$unit($unit) tries to cast $spell($spell), but the spell fails!" - + "Der Kampf wurde abgebrochen, da alle Verteidiger flohen." "The battle was aborted because all enemies escaped." - + "... in der $int($row). Kampflinie:" "... in combat rank $int($row):" - + @@ -7228,14 +7228,14 @@ "$unit($mage) casts $spell($spell), but nobody was in range." - + "Einheiten nach dem Kampf:" "Units after the battle:" - + "" @@ -7301,21 +7301,21 @@ "$unit($mage) causes the walls of $building($building) to glow in an eerie magic light." - + "Einheiten vor der $int($turn). Runde:" "Units before turn $int($turn):" - + "In $region($region) findet ein Kampf statt." "There is a battle in $region($region)." - + @@ -7516,7 +7516,7 @@ "$unit($mage) casts $spell($spell). $int($amount) fighters are temporarily losing some of their memories." - + @@ -7524,7 +7524,7 @@ "$unit($unit) tötete $int($dead) Krieger." "$unit($unit) killed $int($dead) opponents." - + diff --git a/src/battle.c b/src/battle.c index ad1c0f8da..a63caa291 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1295,7 +1295,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) if (oldpotiontype[P_HEAL] && !fval(&df->person[dt.index], FL_HEALING_USED)) { if (i_get(du->items, oldpotiontype[P_HEAL]->itype) > 0) { - message *m = msg_message("battle::potionsave", "unit", du); + message *m = msg_message("potionsave", "unit", du); message_faction(b, du->faction, m); msg_release(m); i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1); @@ -1630,7 +1630,7 @@ selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask) static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp) { - message *m = msg_message("battle::spell_failed", "unit spell", mage, sp); + message *m = msg_message("spell_failed", "unit spell", mage, sp); message_all(b, m); msg_release(m); } @@ -2277,7 +2277,7 @@ void do_attack(fighter * af) * Ladezeit neu und generiert die Meldung. */ if (af->catmsg >= 0) { struct message *m = - msg_message("battle::killed", "unit dead", au, af->catmsg); + msg_message("killed_battle", "unit dead", au, af->catmsg); message_all(b, m); msg_release(m); af->catmsg = -1; @@ -2752,10 +2752,10 @@ static void aftermath(battle * b) battle_effects(b, dead_players); for (s = b->sides; s != b->sides + b->nsides; ++s) { - message *seen = msg_message("battle::army_report", + message *seen = msg_message("army_report", "index abbrev dead fled survived", army_index(s), sideabkz(s, false), s->dead, s->flee, s->alive); - message *unseen = msg_message("battle::army_report", + message *unseen = msg_message("army_report", "index abbrev dead fled survived", army_index(s), "-?-", s->dead, s->flee, s->alive); @@ -2864,7 +2864,7 @@ static void print_fighters(battle * b, const side * s) if (row == thisrow) { if (m == NULL) { - m = msg_message("battle::row_header", "row", row); + m = msg_message("battle_row", "row", row); message_all(b, m); } battle_punit(du, b); @@ -2927,7 +2927,7 @@ static void print_header(battle * b) bufp = STRLCPY(bufp, lastf, size); } - m = msg_message("battle::starters", "factions", zText); + m = msg_message("start_battle", "factions", zText); message_faction(b, f, m); msg_release(m); } @@ -3049,10 +3049,10 @@ static void print_stats(battle * b) unit *u = tf->unit; message *m = NULL; if (!is_attacker(tf)) { - m = msg_message("battle::tactics_lost", "unit", u); + m = msg_message("tactics_lost", "unit", u); } else { - m = msg_message("battle::tactics_won", "unit", u); + m = msg_message("tactics_won", "unit", u); } message_all(b, m); msg_release(m); @@ -3579,9 +3579,9 @@ static int battle_report(battle * b) message_faction(b, fac, msg_separator); if (cont) - m = msg_message("battle::lineup", "turn", b->turn); + m = msg_message("lineup_battle", "turn", b->turn); else - m = msg_message("battle::after", ""); + m = msg_message("after_battle", ""); message_faction(b, fac, m); msg_release(m); @@ -4073,7 +4073,7 @@ void do_battle(region * r) bool fighting = false; ship *sh; if (msg_separator == NULL) { - msg_separator = msg_message("battle::section", ""); + msg_separator = msg_message("section_battle", ""); } fighting = start_battle(r, &b); @@ -4087,7 +4087,7 @@ void do_battle(region * r) print_header(b); if (!fighting) { /* Niemand mehr da, Kampf kann nicht stattfinden. */ - message *m = msg_message("battle::aborted", ""); + message *m = msg_message("aborted_battle", ""); message_all(b, m); msg_release(m); free_battle(b); diff --git a/src/items/weapons.c b/src/items/weapons.c index a23110a81..acb47f0e0 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -63,7 +63,7 @@ int *casualties) if (wp != NULL && wp->type == wtype) ++k; } - msg = msg_message("battle::useflamingsword", "amount unit", k, fi->unit); + msg = msg_message("useflamingsword", "amount unit", k, fi->unit); message_all(fi->side->battle, msg); msg_release(msg); fi->catmsg = 0; @@ -119,7 +119,7 @@ int *casualties) if (af->person[i].reload == 0 && af->person[i].missile == wp) ++k; } - msg = msg_message("battle::usecatapult", "amount unit", k, au); + msg = msg_message("usecatapult", "amount unit", k, au); message_all(b, msg); msg_release(msg); af->catmsg = 0; diff --git a/src/report.c b/src/report.c index d9cafb4c7..4e5eef98b 100644 --- a/src/report.c +++ b/src/report.c @@ -768,7 +768,7 @@ static void rp_battles(struct stream *out, faction * f) while (bm) { char buf[256]; - RENDER(f, buf, sizeof(buf), ("battle::header", "region", bm->r)); + RENDER(f, buf, sizeof(buf), ("header_battle", "region", bm->r)); newline(out); centre(out, buf, true); newline(out); diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index da2d52182..8eb240cf7 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -131,7 +131,7 @@ int damage_spell(struct castorder * co, int dmg, int strength) enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE); if (enemies == 0) { message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -144,7 +144,7 @@ int damage_spell(struct castorder * co, int dmg, int strength) killed += terminate(dt, at, AT_COMBATSPELL, damage, false); } - m = msg_message("battle::combatspell", "mage spell dead", + m = msg_message("cast_combatspell", "mage spell dead", fi->unit, sp, killed); message_all(b, m); msg_release(m); @@ -171,7 +171,7 @@ int sp_petrify(struct castorder * co) enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); if (!enemies) { message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -218,7 +218,7 @@ int sp_stun(struct castorder * co) enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); if (!enemies) { message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -366,7 +366,7 @@ int sp_sleep(struct castorder * co) enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); if (!enemies) { - m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -485,7 +485,7 @@ int sp_mindblast_temp(struct castorder * co) int enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); if (!enemies) { - m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -551,7 +551,7 @@ int sp_mindblast(struct castorder * co) int enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); if (!enemies) { - m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -634,7 +634,7 @@ int sp_dragonodem(struct castorder * co) if (!enemies) { struct message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -653,7 +653,7 @@ int sp_dragonodem(struct castorder * co) } m = - msg_message("battle::combatspell", "mage spell dead", fi->unit, sp, + msg_message("cast_combatspell", "mage spell dead", fi->unit, sp, killed); message_all(b, m); msg_release(m); @@ -682,7 +682,7 @@ int sp_immolation(struct castorder * co) if (!count_enemies(b, fi, FIGHT_ROW, AVOID_ROW, SELECT_ADVANCE | SELECT_FIND)) { message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -710,7 +710,7 @@ int sp_immolation(struct castorder * co) selist_free(fgs); m = - msg_message("battle::combatspell", "mage spell killed", fi->unit, sp, + msg_message("cast_combatspell", "mage spell killed", fi->unit, sp, killed); message_all(b, m); msg_release(m); @@ -736,7 +736,7 @@ int sp_drainodem(fighter * fi, int level, double power, spell * sp) enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE); if (!enemies) { - m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -917,7 +917,7 @@ int sp_chaosrow(struct castorder * co) bool chaosrow = strcmp(sp->sname, "chaosrow") == 0; if (!count_enemies(b, fi, FIGHT_ROW, NUMROWS, SELECT_ADVANCE | SELECT_FIND)) { - m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -1167,7 +1167,7 @@ int sp_frighten(struct castorder * co) enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE); if (!enemies) { message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -1217,7 +1217,7 @@ int sp_tiredsoldiers(struct castorder * co) if (!count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE | SELECT_FIND)) { message *m = - msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0; @@ -1263,7 +1263,7 @@ int sp_windshield(struct castorder * co) enemies = count_enemies(b, fi, BEHIND_ROW, BEHIND_ROW, SELECT_ADVANCE); if (!enemies) { - m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); + m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return 0;