From 6403c75c858a8becfed7ece8aecdcd2bae805f2c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 2 Jul 2018 19:58:26 +0200 Subject: [PATCH 01/11] monsters should not be anonymous. --- src/kernel/faction.c | 30 ------------------------------ src/monsters.c | 5 +++++ 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 16c0c789c..b4dfe51ca 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -492,36 +492,6 @@ void destroyfaction(faction ** fp) } handle_event(f->attribs, "destroy", f); -#if 0 - faction *ff; - for (ff = factions; ff; ff = ff->next) { - group *g; - ally *sf, **sfp; - - for (sfp = &ff->allies; *sfp;) { - sf = *sfp; - if (sf->faction == f || sf->faction == NULL) { - *sfp = sf->next; - free(sf); - } - else - sfp = &(*sfp)->next; - } - for (g = ff->groups; g; g = g->next) { - for (sfp = &g->allies; *sfp; ) { - sf = *sfp; - if (sf->faction == f || sf->faction == NULL) { - *sfp = sf->next; - free(sf); - } - else { - sfp = &(*sfp)->next; - } - } - } - } -#endif - if (f->alliance) { setalliance(f, 0); } diff --git a/src/monsters.c b/src/monsters.c index 181615a40..bbeb483b8 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -755,6 +755,11 @@ void plan_monsters(faction * f) if (u->faction!=f) continue; + /* Parteitarnung von Monstern ist doof: */ + if (fval(u, UFL_ANON_FACTION)) { + u->flags &= ~UFL_ANON_FACTION; + } + /* Befehle m�ssen jede Runde neu gegeben werden: */ free_orders(&u->orders); if (skill_enabled(SK_PERCEPTION)) { From 68f241ad7df8c22b4d803daaf8122e384a1c9e72 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 11 Jun 2018 21:00:01 +0200 Subject: [PATCH 02/11] redirect cron output to a logfile --- process/cron/preview.cron | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/process/cron/preview.cron b/process/cron/preview.cron index 71ebd0571..eb39fd8f8 100755 --- a/process/cron/preview.cron +++ b/process/cron/preview.cron @@ -1,5 +1,5 @@ #!/bin/bash - +( [ "$PREVIEW" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -13,3 +13,5 @@ for game in 2 3 4 ; do ${SRC}/s/preview -g ${game} run && \ ${SRC}/s/preview -g ${game} send done +) | tee -a $HOME/log/preview.cron.log + From e2c2f61927f43777888852cbf79b6d5b0540ba25 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jul 2018 10:45:11 +0200 Subject: [PATCH 03/11] pipe cron output to logfile, fix sendreport script --- process/Makefile | 3 +-- process/cron/run-eressea.cron | 4 +++- process/functions.sh | 10 -------- process/sendreport.sh | 45 ++++++++++++++++++++--------------- 4 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 process/functions.sh diff --git a/process/Makefile b/process/Makefile index 8edfed0b8..0d84bdae2 100644 --- a/process/Makefile +++ b/process/Makefile @@ -1,6 +1,5 @@ SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \ -run-turn sendreports.sh -IGNORE=sendreport.sh +run-turn sendreports.sh sendreport.sh shellcheck: $(SCRIPTS) shellcheck $(SCRIPTS) diff --git a/process/cron/run-eressea.cron b/process/cron/run-eressea.cron index 4ea38184c..ecd4c6b11 100755 --- a/process/cron/run-eressea.cron +++ b/process/cron/run-eressea.cron @@ -1,6 +1,6 @@ #!/bin/bash GAME=$1 - +( [ "$ENABLED" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -58,3 +58,5 @@ $BIN/compress.sh $GAME $TURN $BIN/sendreports.sh $GAME $BIN/backup-eressea $GAME $TURN rm -f test/execute.lock +) | tee -a $HOME/log/eressea.cron.log + diff --git a/process/functions.sh b/process/functions.sh deleted file mode 100644 index 859fd302a..000000000 --- a/process/functions.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -PATH=$ERESSEA/bin:$PATH - -function abort() { - if [ $# -gt 0 ]; then - echo $@ - fi - exit -1 -} diff --git a/process/sendreport.sh b/process/sendreport.sh index be643ef56..d98ed505e 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -1,11 +1,17 @@ #!/bin/bash -if [ -z $ERESSEA ]; then +if [ -z "$ERESSEA" ]; then echo "You have to define the \$ERESSEA environment variable to run $0" exit -2 fi -source $HOME/bin/functions.sh + +function abort() { + if [ $# -gt 0 ]; then + echo "$@" + fi + exit -1 +} GAME=$1 EMAIL=$2 @@ -14,32 +20,33 @@ PASSWD=$4 #echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log function reply() { - echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL - abort $@ + echo "$@" | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" + abort "$@" } -LOCKFILE=$ERESSEA/.report.lock -[ -e $LOCKFILE ] && reply "lockfile exists. wait for mail delivery to finish." +LOCKFILE="$ERESSEA/.report.lock" +[ -e "$LOCKFILE" ] && reply "lockfile exists. wait for mail delivery to finish." -REPLYTO='accounts@eressea.de' +echo "$(date):report:$GAME:$EMAIL:$FACTION:$PASSWD" >> "$ERESSEA/request.log" -echo `date`:report:$GAME:$EMAIL:$FACTION:$PASSWD >> $ERESSEA/request.log +cd "$ERESSEA" || exit +checkpasswd.py "game-$GAME/passwd" "$FACTION" "$PASSWD" || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" -cd $ERESSEA -checkpasswd.py game-$GAME/passwd $FACTION $PASSWD || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" - -cd $ERESSEA/game-$GAME/reports -if [ ! -e ${FACTION}.sh ]; then +cd "$ERESSEA/game-$GAME/reports" || exit +if [ ! -e "${FACTION}.sh" ]; then echo "Der Report für Partei $FACTION kann wegen technischer Probleme leider nicht nachgefordert werden: No such file ${FACTION}.sh" \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL + | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" exit fi -source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" +bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION" -if [ -e $ERESSEA/game-$GAME/eressea.db ]; then +if [ -e "$ERESSEA/game-$GAME/eressea.db" ]; then SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" - OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") - echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER + OWNER=$(sqlite3 "$ERESSEA/game-$GAME/eressea.db" "$SQL") + if [ ! -z "$OWNER" ]; then + echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ + | mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER" + fi fi + From b1b4654b0eb0736497dcd82c192a7ca34f1e4b63 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jul 2018 12:21:42 +0200 Subject: [PATCH 04/11] Bug 2445: duplicate strings warnings. --- conf/e2/locales.json | 2 ++ res/translations/strings-e2.de.po | 49 +++++++++++++++++++++++++++++++ res/translations/strings-e2.en.po | 49 +++++++++++++++++++++++++++++++ res/translations/strings.de.po | 36 ----------------------- res/translations/strings.en.po | 36 ----------------------- 5 files changed, 100 insertions(+), 72 deletions(-) create mode 100644 res/translations/strings-e2.de.po create mode 100644 res/translations/strings-e2.en.po diff --git a/conf/e2/locales.json b/conf/e2/locales.json index 21e91755f..3376cfedc 100644 --- a/conf/e2/locales.json +++ b/conf/e2/locales.json @@ -1,7 +1,9 @@ { "include": [ "config://res/translations/strings.de.po", + "config://res/translations/strings-e2.de.po", "config://res/translations/strings.en.po", + "config://res/translations/strings-e2.en.po", "config://res/translations/messages.de.po", "config://res/translations/messages.en.po", "config://res/core/messages.xml" diff --git a/res/translations/strings-e2.de.po b/res/translations/strings-e2.de.po new file mode 100644 index 000000000..fde4244af --- /dev/null +++ b/res/translations/strings-e2.de.po @@ -0,0 +1,49 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de\n" +"X-Generator: Poedit 2.0.7\n" + +msgctxt "spellinfo" +msgid "concealing_aura" +msgstr "Dieser Zauber wird die gesamte Ausrüstung der Zieleinheit für einige Zeit vor den Blicken anderer verschleiern." + +msgctxt "spellinfo" +msgid "raindance" +msgstr "Dieses uralte Tanzritual ruft die Kräfte des Lebens und der Fruchtbarkeit. Die Erträge der Bauern werden für einige Wochen deutlich besser ausfallen." + +msgctxt "spellinfo" +msgid "earn_silver#gwyrrd" +msgstr "Die Fähigkeiten der Gwyrrd-Magier in der Viehzucht und Heilung sind bei den Bauern sehr begehrt. Gerade auf Märkten sind ihre Dienste häufig sehr gefragt. Manch einer mag auch sein Talent dazu nutzen, ein Tier für einen besseren Preis zu verkaufen. Pro Stufe kann der Magier so 50 Silber verdienen." + +msgctxt "spellinfo" +msgid "earn_silver#draig" +msgstr "In den dunkleren Gassen gibt es sie, die Flüche und Verhexungen auf Bestellung. Aber auch Gegenzauber hat der Jünger des Draigs natürlich im Angebot. Ob nun der Sohn des Nachbarn in einen Liebesbann gezogen werden soll oder die Nebenbuhlerin Pickel und Warzen bekommen soll, niemand gibt gerne zu, zu solchen Mitteln gegriffen zu haben. Für diese Dienstleistung streicht der Magier 50 Silber pro Stufe ein." + +msgctxt "spellinfo" +msgid "earn_silver#cerddor" +msgstr "Cerddormagier sind die führenden Gaukler unter den Magiern, sie lieben es das Volk zu unterhalten und im Mittelpunkt zu stehen. Schon Anfänger lernen die kleinen Kunststücke und magischen Tricks, mit denen man das Volk locken und verführen kann, den Geldbeutel ganz weit zu öffnen, und am Ende der Woche wird der Gaukler 50 Silber pro Stufe verdient haben." + +msgctxt "spellinfo" +msgid "earn_silver#tybied" +msgstr "Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen alles, was man sonst nicht bekommen kann. Ob nun die kryptische Formel unter dem Holzschuh des untreuen Ehemannes wirklich geholfen hat - nun, der des Lesens nicht mächtige Bauer wird es nie wissen. Dem Magier hilft es auf jeden Fall... beim Füllen seines Geldbeutels. 50 Silber pro Stufe lassen sich so in einer Woche verdienen." + +msgctxt "spellinfo" +msgid "earn_silver#illaun" +msgstr "Niemand kann so gut die Träume deuten wie ein Magier des Illaun. Auch die Kunst der Wahrsagerei, des Kartenlegens und des Handlesens sind ihm geläufig. Dafür zahlen ihm die Bauern 50 Silber pro Stufe." + +msgctxt "describe" +msgid "lifepotion" +msgstr "Das 'Wasser des Lebens' ist in der Lage, aus gefällten Baumstämmen wieder lebende Bäume zu machen. Dazu wird ein knotiger Saugwurz zusammen mit einem Elfenlieb erwärmt, so dass man gerade noch den Finger reinhalten kann. Dies gieße man in ein Gefäß und lasse es langsam abkühlen. Der Extrakt reicht für 10 Holzstämme." + +msgctxt "spellinfo" +msgid "blessedharvest" +msgstr "Dieses Ernteritual verbessert die Erträge der arbeitenden Bauern in der Region um ein Silberstück. Je mehr Kraft der Druide investiert, desto länger wirkt der Zauber." + diff --git a/res/translations/strings-e2.en.po b/res/translations/strings-e2.en.po new file mode 100644 index 000000000..3867de0f7 --- /dev/null +++ b/res/translations/strings-e2.en.po @@ -0,0 +1,49 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"X-Generator: Poedit 2.0.7\n" + +msgctxt "spellinfo" +msgid "earn_silver#gwyrrd" +msgstr "The abilities of the mages of Gwyrrd concerning the breeding and healing of cattle are highly appreciated among the peasants. Especially at the markets, their services are demanded frequently. Some of them also use their talents to sell an animal at a higher price. A magician can earn 50 silver pieces per level in this way." + +msgctxt "spellinfo" +msgid "earn_silver#draig" +msgstr "In the dark alleys you can find those who sell curses and hexes on demand - but you can buy the apropriate counterspells from the followers of Draig as well. May it be a love spell for the son of a neighbour or a wart in the face of a rival. For offering these services, the sorcerer charges 50 silver pieces per level." + +msgctxt "spellinfo" +msgid "earn_silver#cerddor" +msgstr "The mages of Cerddor truly are the bards of the wizards; they love to use their sorcery to entertain the crowds and to be the center of attention. Even the apprentices study those little magic tricks, which attract and fascinate the people and thus ensnare them into leaving a few coins or more for the artist. By the end of the week, the bard will have earned 50 silver per level." + +msgctxt "spellinfo" +msgid "earn_silver#illaun" +msgstr "No one can read dreams as well as the mages of Illaun. Furthermore, they are also familiar with all other common means of foretelling the future like crystal balls, tarot cards or palms. A mentalist can earn 50 silver pieces per level and week for offering these services to peasants." + +msgctxt "spellinfo" +msgid "earn_silver#tybied" +msgstr "If the local alchemist could not help you, you should visit a scholar of Tybied. His potions and tinctures may help when nothing else does. If the cryptic formula under the wooden shoes of the unfaithful husband really helped? - well, the peasant, who isn't capable of reading, will never know. At least it helped the magician... to fill his purse. In one week he can earn 50 silver per level that way." + +msgctxt "spellinfo" +msgid "blessedharvest" +msgstr "This ritual increases the output of the local farms. Peasants in the region produce an extra silverpiece. The stronger the druid's spell is, the longer the effect will last." + +msgctxt "spellinfo" +msgid "raindance" +msgstr "This ancient rite calls upon the forces of life and fertility. For the next few weeks, the peasant's harvest will be extraordinary good." + +msgctxt "spellinfo" +msgid "concealing_aura" +msgstr "This spell will hide the whole equipment of a target unit from the looks of others." + +msgctxt "describe" +msgid "lifepotion" +msgstr "The \"Water of Life\" allows living trees to be created from logs. A Knotroot and Elvendear are heated until one can just still keep one's finger in. This is then poured into a jar and allowed to cool slowly. The extract is sufficient for 10 pieces of wood." + diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index afcceb94b..1731fa10e 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -327,10 +327,6 @@ msgctxt "spell" msgid "clone" msgstr "Seelenkopie" -msgctxt "spellinfo" -msgid "concealing_aura" -msgstr "Dieser Zauber wird die gesamte Ausrüstung der Zieleinheit für einige Zeit vor den Blicken anderer verschleiern." - msgctxt "shipinfo" msgid "balloon" msgstr "Der Sumpfgasballon besteht aus einem großen Weidenkorb, welcher Platz für maximal 5 Personen oder 500 Gewichtseinheiten bietet, und einer großen, mit Sumpfgas gefüllten Wyrmblase. Bei guten Winden kann sich der Ballon zwei Regionen pro Woche fortbewegen. Das Führen eines Ballons ist nicht einfach, und der Kapitän muss mindestens ein Segeltalent von 6 besitzen. Diese neue Entwicklung auf Eressea wird ausschließlich für den Xontormia-Expreß hergestellt und die Baupläne sind streng geheim. So ist es auch bisher noch niemandem gelungen, ein Exemplar nachzubauen." @@ -908,10 +904,6 @@ msgctxt "spellinfo" msgid "disturbingdreams" msgstr "Dieser Zauber führt in der betroffenen Region für einige Wochen zu Schlaflosigkeit und Unruhe. Den Betroffenen fällt das Lernen deutlich schwerer." -msgctxt "spellinfo" -msgid "raindance" -msgstr "Dieses uralte Tanzritual ruft die Kräfte des Lebens und der Fruchtbarkeit. Die Erträge der Bauern werden für einige Wochen deutlich besser ausfallen." - msgid "wdw_pyramid" msgstr "Pyramide" @@ -1459,10 +1451,6 @@ msgctxt "race" msgid "goblin_x" msgstr "Goblin" -msgctxt "spellinfo" -msgid "earn_silver#gwyrrd" -msgstr "Die Fähigkeiten der Gwyrrd-Magier in der Viehzucht und Heilung sind bei den Bauern sehr begehrt. Gerade auf Märkten sind ihre Dienste häufig sehr gefragt. Manch einer mag auch sein Talent dazu nutzen, ein Tier für einen besseren Preis zu verkaufen. Pro Stufe kann der Magier so 50 Silber verdienen." - msgctxt "spell" msgid "raindance" msgstr "Regentanz" @@ -1494,10 +1482,6 @@ msgstr "Mallorn" msgid "mallorn_p" msgstr "Mallorn" -msgctxt "describe" -msgid "lifepotion" -msgstr "Das 'Wasser des Lebens' ist in der Lage, aus gefällten Baumstämmen wieder lebende Bäume zu machen. Dazu wird ein knotiger Saugwurz zusammen mit einem Elfenlieb erwärmt, so dass man gerade noch den Finger reinhalten kann. Dies gieße man in ein Gefäß und lasse es langsam abkühlen. Der Extrakt reicht für 10 Holzstämme." - msgctxt "spell" msgid "homestone" msgstr "Heimstein" @@ -1740,10 +1724,6 @@ msgstr "Beschwörung eines Wasserelementares" msgid "GEBAEUDE" msgstr "GEBÄUDE" -msgctxt "spellinfo" -msgid "blessedharvest" -msgstr "Dieses Ernteritual verbessert die Erträge der arbeitenden Bauern in der Region um ein Silberstück. Je mehr Kraft der Druide investiert, desto länger wirkt der Zauber." - msgid "KRAEUTER" msgstr "KRÄUTER" @@ -3147,10 +3127,6 @@ msgctxt "spellinfo" msgid "create_focus" msgstr "Erzeugt einen Aurafokus." -msgctxt "spellinfo" -msgid "earn_silver#draig" -msgstr "In den dunkleren Gassen gibt es sie, die Flüche und Verhexungen auf Bestellung. Aber auch Gegenzauber hat der Jünger des Draigs natürlich im Angebot. Ob nun der Sohn des Nachbarn in einen Liebesbann gezogen werden soll oder die Nebenbuhlerin Pickel und Warzen bekommen soll, niemand gibt gerne zu, zu solchen Mitteln gegriffen zu haben. Für diese Dienstleistung streicht der Magier 50 Silber pro Stufe ein." - msgctxt "spell" msgid "song_of_slavery" msgstr "Gesang der Versklavung" @@ -4910,10 +4886,6 @@ msgstr "Elixier der Macht" msgid "wand_p" msgstr "Zauberstäbe" -msgctxt "spellinfo" -msgid "earn_silver#cerddor" -msgstr "Cerddormagier sind _die_ Gaukler unter den Magiern, sie lieben es das Volk zu unterhalten und im Mittelpunkt zu stehen. Schon Anfänger lernen die kleinen Kunststücke und magischen Tricks, mit denen man das Volk locken und verführen kann, den Geldbeutel ganz weit zu öffnen, und am Ende der Woche wird der Gaukler 50 Silber pro Stufe verdient haben." - msgctxt "spell" msgid "strength" msgstr "Unbekannter Effekt" @@ -4996,10 +4968,6 @@ msgstr "Myrrhe" msgid "skeleton_prefix_9" msgstr "Dunkle" -msgctxt "spellinfo" -msgid "earn_silver#illaun" -msgstr "Niemand kann so gut die Träume deuten wie ein Magier des Illaun. Auch die Kunst der Wahrsagerei, des Kartenlegens und des Handlesens sind ihm geläufig. Dafür zahlen ihm die Bauern 50 Silber pro Stufe." - msgctxt "spell" msgid "big_recruit" msgstr "Hohe Kunst der Überzeugung" @@ -5913,10 +5881,6 @@ msgctxt "spell" msgid "cerddorfumbleshield" msgstr "Bannlied" -msgctxt "spellinfo" -msgid "earn_silver#tybied" -msgstr "Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen alles, was man sonst nicht bekommen kann. Ob nun die kryptische Formel unter dem Holzschuh des untreuen Ehemannes wirklich geholfen hat - nun, der des Lesens nicht mächtige Bauer wird es nie wissen. Dem Magier hilft es auf jeden Fall... beim Füllen seines Geldbeutels. 50 Silber pro Stufe lassen sich so in einer Woche verdienen." - msgid "ANZAHL" msgstr "ANZAHL" diff --git a/res/translations/strings.en.po b/res/translations/strings.en.po index c8bd637db..0d64e9f99 100644 --- a/res/translations/strings.en.po +++ b/res/translations/strings.en.po @@ -273,10 +273,6 @@ msgctxt "spell" msgid "clone" msgstr "Doppelganger" -msgctxt "spellinfo" -msgid "concealing_aura" -msgstr "This spell will hide the whole equipment of a target unit from the looks of others." - msgctxt "spell" msgid "bloodsacrifice" msgstr "Lesser Sacrifice" @@ -695,10 +691,6 @@ msgctxt "spellinfo" msgid "disturbingdreams" msgstr "This spell causes insomnia and restlessness in a whole region for several weeks. All affected persons will learn much slower than normal." -msgctxt "spellinfo" -msgid "raindance" -msgstr "This ancient rite calls upon the forces of life and fertility. For the next few weeks, the peasant's harvest will be extraordinary good." - msgid "wdw_pyramid" msgstr "pyramid" @@ -1221,10 +1213,6 @@ msgctxt "race" msgid "goblin_x" msgstr "goblin" -msgctxt "spellinfo" -msgid "earn_silver#gwyrrd" -msgstr "The abilities of the mages of Gwyrrd concerning the breeding and healing of cattle are highly appreciated among the peasants. Especially at the markets, their services are demanded frequently. Some of them also use their talents to sell an animal at a higher price. A magician can earn 50 silver pieces per level in this way." - msgctxt "spell" msgid "raindance" msgstr "Rain Dance" @@ -1252,10 +1240,6 @@ msgstr "mallorn" msgid "mallorn_p" msgstr "mallorn" -msgctxt "describe" -msgid "lifepotion" -msgstr "The \"Water of Life\" allows living trees to be created from logs. A Knotroot and Elvendear are heated until one can just still keep one's finger in. This is then poured into a jar and allowed to cool slowly. The extract is sufficient for 10 pieces of wood." - msgid "thickfog_trail" msgstr "%s" @@ -1490,10 +1474,6 @@ msgctxt "spell" msgid "goodwinds" msgstr "Summon Water Elemental" -msgctxt "spellinfo" -msgid "blessedharvest" -msgstr "This ritual increases the output of the local farms. Peasants in the region produce an extra silverpiece. The stronger the druid's spell is, the longer the effect will last." - msgid "KRAEUTER" msgstr "HERBS" @@ -2732,10 +2712,6 @@ msgctxt "spellinfo" msgid "create_focus" msgstr "Creates an aurafocus crystal." -msgctxt "spellinfo" -msgid "earn_silver#draig" -msgstr "In the dark alleys you can find those who sell curses and hexes on demand - but you can buy the apropriate counterspells from the followers of Draig as well. May it be a love spell for the son of a neighbour or a wart in the face of a rival. For offering these services, the sorcerer charges 50 silver pieces per level." - msgctxt "spell" msgid "song_of_slavery" msgstr "Song of Slavery" @@ -4370,10 +4346,6 @@ msgstr "elixir of power" msgid "wand_p" msgstr "wands" -msgctxt "spellinfo" -msgid "earn_silver#cerddor" -msgstr "The mages of Cerddor truly are the bards of the wizards; they love to use their sorcery to entertain the crowds and to be the center of attention. Even the apprentices study those little magic tricks, which attract and fascinate the people and thus ensnare them into leaving a few coins or more for the artist. By the end of the week, the bard will have earned 50 silver per level." - msgctxt "spell" msgid "strength" msgstr "Unknown Effect" @@ -4426,10 +4398,6 @@ msgstr "trees" msgid "myrrh_p" msgstr "myrrh" -msgctxt "spellinfo" -msgid "earn_silver#illaun" -msgstr "No one can read dreams as well as the mages of Illaun. Furthermore, they are also familiar with all other common means of foretelling the future like crystal balls, tarot cards or palms. A mentalist can earn 50 silver pieces per level and week for offering these services to peasants." - msgctxt "spell" msgid "big_recruit" msgstr "High art of persuasion" @@ -5222,10 +5190,6 @@ msgctxt "spell" msgid "cerddorfumbleshield" msgstr "Countersong" -msgctxt "spellinfo" -msgid "earn_silver#tybied" -msgstr "If the local alchemist could not help you, you should visit a scholar of Tybied. His potions and tinctures may help when nothing else does. If the cryptic formula under the wooden shoes of the unfaithful husband really helped? - well, the peasant, who isn't capable of reading, will never know. At least it helped the magician... to fill his purse. In one week he can earn 50 silver per level that way." - msgctxt "keyword" msgid "teach" msgstr "TEACH" From 64eb545b4a864f2be65f03c5590f57ecb7784b0f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Jul 2018 20:24:23 +0200 Subject: [PATCH 05/11] Bug 2460: Startgeschenke --- scripts/eressea/equipment.lua | 15 +++++++++++---- scripts/tests/config.lua | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/eressea/equipment.lua b/scripts/eressea/equipment.lua index 6e4ccfc9b..8852dfb27 100644 --- a/scripts/eressea/equipment.lua +++ b/scripts/eressea/equipment.lua @@ -1,13 +1,20 @@ --- forward declaration required: - +-- forward declarations required: local self = {} + +local function equip_first(u) + equip_newunits(u) + name = 'seed_' .. u.race + equip_unit(u, name, 255) +end + local mysets = { ['first_unit'] = { ['items'] = { ['money'] = 2500, ['log'] = 10, ['stone'] = 4 - } + }, + ['callback'] = equip_first }, ['seed_unit'] = { ['items'] = { @@ -75,7 +82,7 @@ local mysets = { }, ['seed_insect'] = { ['items'] = { - ['nestwarmth'] =9 + ['nestwarmth'] = 9 } }, ['seed_halfling'] = { diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index a3104a6b6..316a8ccca 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -14,6 +14,22 @@ function test_read_race() assert_not_nil(f) end +function test_first_insect() + local f = faction.create('insect') + local r = region.create(0, 0, "plain") + local u = unit.create(f, r, 1) + u:equip('first_unit') + assert_equal(9, u:get_item('nestwarmth')) +end + +function test_first_troll() + local f = faction.create('troll') + local r = region.create(0, 0, "plain") + local u = unit.create(f, r, 1) + u:equip('first_unit') + assert_equal(2, u:eff_skill('perception')) +end + function test_seed_unit() local r = region.create(0, 0, "plain") local f = faction.create('human') From 21cbff0740a827fd7aff8af77c1c772ef79fed98 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Jul 2018 20:54:28 +0200 Subject: [PATCH 06/11] update submodules --- storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage b/storage index 6eea76952..0ef4b39e3 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 6eea7695285f9c9f1d25421897ca55f466ef7566 +Subproject commit 0ef4b39e39d8146d6ca323500a285c53843db988 From 820264aa8214af81ce5bdb8c7e252af5079fbe55 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Jul 2018 13:39:23 +0200 Subject: [PATCH 07/11] BUG 2461: Liste der Angreifer zeigt nicht alle Parteien. --- src/battle.c | 2 +- src/battle.h | 1 + src/battle.test.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++ src/reports.c | 10 +++-- 4 files changed, 112 insertions(+), 5 deletions(-) diff --git a/src/battle.c b/src/battle.c index be950af7f..38590b8a6 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3323,7 +3323,7 @@ fighter * get_fighter(battle * b, const struct unit * u) return 0; } -static int join_battle(battle * b, unit * u, bool attack, fighter ** cp) +int join_battle(battle * b, unit * u, bool attack, fighter ** cp) { side *s; fighter *fc = NULL; diff --git a/src/battle.h b/src/battle.h index c9429a6b3..48fa7c63a 100644 --- a/src/battle.h +++ b/src/battle.h @@ -261,6 +261,7 @@ extern "C" { void free_battle(struct battle * b); struct fighter *make_fighter(struct battle *b, struct unit *u, struct side * s, bool attack); + int join_battle(struct battle * b, struct unit * u, bool attack, struct fighter ** cp); struct side *make_side(struct battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction); diff --git a/src/battle.test.c b/src/battle.test.c index 56ca24ac4..7c7012e77 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -1,6 +1,8 @@ #include #include "battle.h" + +#include "reports.h" #include "skill.h" #include @@ -16,6 +18,8 @@ #include #include +#include +#include #include #include #include @@ -552,6 +556,103 @@ static void test_battle_skilldiff(CuTest *tc) test_teardown(); } +static void test_battle_report_one(CuTest *tc) +{ + battle * b = NULL; + region *r; + unit *u1, *u2; + message *m; + const char *expect; + fighter *fig; + + test_setup(); + mt_create_va(mt_new("start_battle", NULL), "factions:string", MT_NEW_END); + r = test_create_plain(0, 0); + u1 = test_create_unit(test_create_faction(NULL), r); + u2 = test_create_unit(test_create_faction(NULL), r); + b = make_battle(r); + join_battle(b, u1, true, &fig); + join_battle(b, u2, false, &fig); + faction_setname(u1->faction, "Monster"); + expect = factionname(u1->faction); + + report_battle_start(b); + CuAssertPtrNotNull(tc, m = test_find_messagetype(u1->faction->battles->msgs, "start_battle")); + CuAssertStrEquals(tc, expect, (const char *)m->parameters[0].v); + + free_battle(b); + test_teardown(); +} + +static void test_battle_report_two(CuTest *tc) +{ + battle * b = NULL; + region *r; + unit *u1, *u2; + message *m; + char expect[64]; + fighter *fig; + struct locale *lang; + + test_setup(); + lang = test_create_locale(); + locale_setstring(lang, "and", "and"); + mt_create_va(mt_new("start_battle", NULL), "factions:string", MT_NEW_END); + r = test_create_plain(0, 0); + u1 = test_create_unit(test_create_faction(NULL), r); + u1->faction->locale = lang; + u2 = test_create_unit(test_create_faction(NULL), r); + u2->faction->locale = lang; + + str_slprintf(expect, sizeof(expect), "%s and %s", factionname(u1->faction), factionname(u2->faction)); + b = make_battle(r); + join_battle(b, u1, true, &fig); + join_battle(b, u2, true, &fig); + report_battle_start(b); + + CuAssertPtrNotNull(tc, m = test_find_messagetype(u1->faction->battles->msgs, "start_battle")); + CuAssertStrEquals(tc, expect, (const char *)m->parameters[0].v); + + free_battle(b); + test_teardown(); +} + +static void test_battle_report_three(CuTest *tc) +{ + battle * b = NULL; + region *r; + unit *u1, *u2, *u3; + message *m; + char expect[64]; + fighter *fig; + struct locale *lang; + + test_setup(); + lang = test_create_locale(); + locale_setstring(lang, "and", "and"); + mt_create_va(mt_new("start_battle", NULL), "factions:string", MT_NEW_END); + r = test_create_plain(0, 0); + u1 = test_create_unit(test_create_faction(NULL), r); + u1->faction->locale = lang; + u2 = test_create_unit(test_create_faction(NULL), r); + u2->faction->locale = lang; + u3 = test_create_unit(test_create_faction(NULL), r); + u3->faction->locale = lang; + + str_slprintf(expect, sizeof(expect), "%s, %s and %s", factionname(u1->faction), factionname(u2->faction), factionname(u3->faction)); + b = make_battle(r); + join_battle(b, u1, true, &fig); + join_battle(b, u2, true, &fig); + join_battle(b, u3, true, &fig); + report_battle_start(b); + + CuAssertPtrNotNull(tc, m = test_find_messagetype(u1->faction->battles->msgs, "start_battle")); + CuAssertStrEquals(tc, expect, (const char *)m->parameters[0].v); + + free_battle(b); + test_teardown(); +} + static void test_battle_skilldiff_building(CuTest *tc) { troop ta, td; @@ -690,6 +791,9 @@ CuSuite *get_battle_suite(void) SUITE_ADD_TEST(suite, test_select_armor); SUITE_ADD_TEST(suite, test_battle_skilldiff); SUITE_ADD_TEST(suite, test_battle_skilldiff_building); + SUITE_ADD_TEST(suite, test_battle_report_one); + SUITE_ADD_TEST(suite, test_battle_report_two); + SUITE_ADD_TEST(suite, test_battle_report_three); SUITE_ADD_TEST(suite, test_defenders_get_building_bonus); SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus); SUITE_ADD_TEST(suite, test_building_bonus_respects_size); diff --git a/src/reports.c b/src/reports.c index d240ee86d..5355a1db9 100644 --- a/src/reports.c +++ b/src/reports.c @@ -2193,10 +2193,12 @@ void report_battle_start(battle * b) } } } - if (first && lastf) { - sbs_strcat(&sbs, " "); - sbs_strcat(&sbs, LOC(f->locale, "and")); - sbs_strcat(&sbs, " "); + if (lastf) { + if (first) { + sbs_strcat(&sbs, " "); + sbs_strcat(&sbs, LOC(f->locale, "and")); + sbs_strcat(&sbs, " "); + } sbs_strcat(&sbs, lastf); } From fc80e4b83eb4015de12546240667836ac4f7fc43 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 17 Jul 2018 20:53:34 +0200 Subject: [PATCH 08/11] =?UTF-8?q?BUG=202462:=20Leuchtturm=20meldet=20keine?= =?UTF-8?q?=20Landregionen,=20besch=C3=BCtzt=20Schiffe=20erst=20ab=20Gr?= =?UTF-8?q?=C3=B6=C3=9Fe=2010.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/report.lua | 6 +-- src/kernel/build.c | 4 +- src/kernel/building.c | 12 +++-- src/lighthouse.c | 114 ++++++++++++++++++--------------------- src/lighthouse.h | 5 +- src/lighthouse.test.c | 43 +++++++++++++-- src/move.c | 4 +- src/reports.c | 19 ++++--- src/reports.test.c | 4 +- 9 files changed, 125 insertions(+), 86 deletions(-) diff --git a/scripts/tests/report.lua b/scripts/tests/report.lua index 12d1538c3..b65bcc279 100644 --- a/scripts/tests/report.lua +++ b/scripts/tests/report.lua @@ -93,11 +93,11 @@ end function test_lighthouse() eressea.free_game() local r = region.create(0, 0, "mountain") - local f = faction.create("human", "noreply@eressea.de", "de") + local f = faction.create("human", "human@example.com") region.create(1, 0, "mountain") region.create(2, 0, "ocean") region.create(0, 1, "firewall") - region.create(3, 0, "mountain") + region.create(3, 0, "ocean") region.create(4, 0, "plain") local u = unit.create(f, r, 1) local b = building.create(r, "lighthouse") @@ -110,7 +110,7 @@ function test_lighthouse() init_reports() write_report(f) - assert_true(find_in_report(f, " %(1,0%) %(vom Turm erblickt%)")) + assert_false(find_in_report(f, " %(1,0%) %(vom Turm erblickt%)")) assert_true(find_in_report(f, " %(2,0%) %(vom Turm erblickt%)")) assert_true(find_in_report(f, " %(3,0%) %(vom Turm erblickt%)")) diff --git a/src/kernel/build.c b/src/kernel/build.c index 310e4bd43..11324f752 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -895,7 +895,9 @@ build_building(unit * u, const building_type * btype, int id, int want, order * } fset(b, BLD_EXPANDED); - update_lighthouse(b); + if (is_lighthouse(btype)) { + update_lighthouse(b); + } return built; } diff --git a/src/kernel/building.c b/src/kernel/building.c index f3f01905f..75cad30f7 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -377,7 +377,9 @@ building *new_building(const struct building_type * btype, region * r, bptr = &(*bptr)->next; *bptr = b; - update_lighthouse(b); + if (is_lighthouse(b->type)) { + update_lighthouse(b); + } bname = LOC(lang, btype->_name); if (!bname) { bname = LOC(lang, parameters[P_GEBAEUDE]); @@ -399,6 +401,7 @@ static building *deleted_buildings; void remove_building(building ** blist, building * b) { unit *u; + region *r = b->region; static const struct building_type *bt_caravan, *bt_dam, *bt_tunnel; static int btypes; @@ -410,18 +413,19 @@ void remove_building(building ** blist, building * b) bt_tunnel = bt_find("tunnel"); } handle_event(b->attribs, "destroy", b); - for (u = b->region->units; u; u = u->next) { + for (u = r->units; u; u = u->next) { if (u->building == b) leave(u, true); } + if (is_lighthouse(b->type)) { + remove_lighthouse(b); + } b->size = 0; - update_lighthouse(b); bunhash(b); /* Falls Karawanserei, Damm oder Tunnel einst�rzen, wird die schon * gebaute Strasse zur Haelfte vernichtet */ if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) { - region *r = b->region; int d; for (d = 0; d != MAXDIRECTIONS; ++d) { direction_t dir = (direction_t)d; diff --git a/src/lighthouse.c b/src/lighthouse.c index fbf950fb1..2ff1c6191 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -19,6 +19,11 @@ attrib_type at_lighthouse = { /* Rest ist NULL; tempor�res, nicht alterndes Attribut */ }; +bool is_lighthouse(const building_type *btype) +{ + return is_building_type(btype, "lighthouse"); +} + /* update_lighthouse: call this function whenever the size of a lighthouse changes * it adds temporary markers to the surrounding regions. * The existence of markers says nothing about the quality of the observer in @@ -26,46 +31,57 @@ attrib_type at_lighthouse = { */ void update_lighthouse(building * lh) { - if (is_building_type(lh->type, "lighthouse")) { - region *r = lh->region; + region *r = lh->region; + assert(is_lighthouse(lh->type)); - r->flags |= RF_LIGHTHOUSE; - if (lh->size > 0) { - int d = (int)log10(lh->size) + 1; - int x; - for (x = -d; x <= d; ++x) { - int y; - for (y = -d; y <= d; ++y) { - attrib *a; - region *r2; - int px = r->x + x, py = r->y + y; + r->flags |= RF_LIGHTHOUSE; + if (lh->size >= 10) { + int d = lighthouse_range(lh, NULL, NULL); + int x; + for (x = -d; x <= d; ++x) { + int y; + for (y = -d; y <= d; ++y) { + attrib *a; + region *r2; + int px = r->x + x, py = r->y + y; - pnormalize(&px, &py, rplane(r)); - r2 = findregion(px, py); - if (!r2 || !fval(r2->terrain, SEA_REGION)) - continue; - if (distance(r, r2) > d) - continue; - a = a_find(r2->attribs, &at_lighthouse); - while (a && a->type == &at_lighthouse) { - building *b = (building *)a->data.v; - if (b == lh) - break; - a = a->next; - } - if (!a) { - a = a_add(&r2->attribs, a_new(&at_lighthouse)); - a->data.v = (void *)lh; - } + pnormalize(&px, &py, rplane(r)); + r2 = findregion(px, py); + if (!r2 || !fval(r2->terrain, SEA_REGION)) + continue; + if (distance(r, r2) > d) + continue; + a = a_find(r2->attribs, &at_lighthouse); + while (a && a->type == &at_lighthouse) { + building *b = (building *)a->data.v; + if (b == lh) + break; + a = a->next; + } + if (!a) { + a = a_add(&r2->attribs, a_new(&at_lighthouse)); + a->data.v = (void *)lh; } } } } } +void remove_lighthouse(const building *lh) { + building *b; + region * r = lh->region; + + r->flags &= ~RF_LIGHTHOUSE; + for (b = r->buildings; b; b = b->next) { + if (b != lh && is_lighthouse(b->type)) { + update_lighthouse(b); + } + } +} + int lighthouse_range(const building * b, const faction * f, const unit *u) { - if (fval(b, BLD_MAINTAINED) && b->size >= 10) { + if (b->size >= 10 && (b->flags & BLD_MAINTAINED)) { int maxd = (int)log10(b->size) + 1; if (u && skill_enabled(SK_PERCEPTION)) { @@ -80,11 +96,11 @@ int lighthouse_range(const building * b, const faction * f, const unit *u) return 0; } -bool check_leuchtturm(region * r, faction * f) +bool lighthouse_guarded(const region * r) { attrib *a; - if (!fval(r->terrain, SEA_REGION)) { + if (!r->attribs || !(r->terrain->flags & SEA_REGION)) { return false; } for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse; @@ -92,37 +108,11 @@ bool check_leuchtturm(region * r, faction * f) building *b = (building *)a->data.v; assert(is_building_type(b->type, "lighthouse")); - if (fval(b, BLD_MAINTAINED) && b->size >= 10) { + if ((b->flags & BLD_MAINTAINED) && b->size >= 10) { int maxd = (int)log10(b->size) + 1; - - if (skill_enabled(SK_PERCEPTION) && f) { - region *r2 = b->region; - unit *u; - int c = 0; - int d = 0; - - for (u = r2->units; u; u = u->next) { - if (u->building == b) { - c += u->number; - if (c > buildingcapacity(b)) - break; - if (u->faction == f) { - if (!d) - d = distance(r, r2); - if (maxd < d) - break; - if (effskill(u, SK_PERCEPTION, 0) >= d * 3) - return true; - } - } - else if (c) - break; /* first unit that's no longer in the house ends the search */ - } - } - else { - /* E3A rule: no perception req'd */ - return true; - } + int d = distance(r, b->region); + assert(maxd >= d); + return true; } } diff --git a/src/lighthouse.h b/src/lighthouse.h index 2eacfb7d8..cd5a02d04 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -29,13 +29,16 @@ extern "C" { struct faction; struct region; struct building; + struct building_type; struct unit; struct attrib; extern struct attrib_type at_lighthouse; /* leuchtturm */ - bool check_leuchtturm(struct region *r, struct faction *f); + bool is_lighthouse(const struct building_type *btype); + bool lighthouse_guarded(const struct region *r); void update_lighthouse(struct building *b); + void remove_lighthouse(const struct building *lh); int lighthouse_range(const struct building *b, const struct faction *f, const struct unit *u); diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index e0c57ec1a..bcc7c0ab7 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -36,6 +36,7 @@ static void test_lighthouse_range(CuTest * tc) set_level(u1, SK_PERCEPTION, 3); set_level(u2, SK_PERCEPTION, 3); CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL, NULL)); + b->flags |= BLD_MAINTAINED; CuAssertIntEquals(tc, 1, lighthouse_range(b, u1->faction, u1)); set_level(u1, SK_PERCEPTION, 6); @@ -54,7 +55,7 @@ static void test_lighthouse_range(CuTest * tc) static void test_lighthouse_update(CuTest * tc) { - region *r1, *r2, *r3; + region *r1, *r2, *r3, *r4; building *b; const struct terrain_type *t_ocean, *t_plain; @@ -64,20 +65,23 @@ static void test_lighthouse_update(CuTest * tc) r1 = test_create_region(0, 0, t_plain); r2 = test_create_region(1, 0, t_ocean); r3 = test_create_region(2, 0, t_ocean); + r4 = test_create_region(0, 1, t_plain); b = test_create_building(r1, test_create_buildingtype("lighthouse")); + b->flags |= BLD_MAINTAINED; CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); CuAssertPtrEquals(tc, NULL, r1->attribs); CuAssertPtrEquals(tc, NULL, r2->attribs); CuAssertPtrEquals(tc, NULL, r3->attribs); + CuAssertPtrEquals(tc, NULL, r4->attribs); r1->flags = 0; - b->size = 1; + b->size = 9; /* minimum size for any effect is 10 */ update_lighthouse(b); CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); - CuAssertPtrNotNull(tc, r2->attribs); - CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r2->attribs->type); CuAssertPtrEquals(tc, NULL, r1->attribs); + CuAssertPtrEquals(tc, NULL, r2->attribs); CuAssertPtrEquals(tc, NULL, r3->attribs); + CuAssertPtrEquals(tc, NULL, r4->attribs); a_removeall(&r2->attribs, NULL); r1->flags = 0; @@ -88,6 +92,36 @@ static void test_lighthouse_update(CuTest * tc) CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r2->attribs->type); CuAssertPtrNotNull(tc, r3->attribs); CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r3->attribs->type); + CuAssertPtrEquals(tc, NULL, r4->attribs); + test_teardown(); +} + +static void test_lighthouse_guard(CuTest * tc) { + region *r1, *r2, *r3, *r4; + building *b; + const struct terrain_type *t_ocean, *t_plain; + + test_setup(); + t_ocean = test_create_terrain("ocean", SEA_REGION); + t_plain = test_create_terrain("plain", LAND_REGION); + r1 = test_create_region(0, 0, t_plain); + r2 = test_create_region(1, 0, t_ocean); + r3 = test_create_region(2, 0, t_ocean); + r4 = test_create_region(0, 1, t_plain); + b = test_create_building(r1, test_create_buildingtype("lighthouse")); + b->flags |= BLD_MAINTAINED; + b->size = 10; + CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL, NULL)); + update_lighthouse(b); + CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); + CuAssertPtrEquals(tc, NULL, r1->attribs); + CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r2->attribs->type); + CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r3->attribs->type); + CuAssertPtrEquals(tc, NULL, r4->attribs); + CuAssertIntEquals(tc, false, lighthouse_guarded(r1)); + CuAssertIntEquals(tc, true, lighthouse_guarded(r2)); + CuAssertIntEquals(tc, true, lighthouse_guarded(r3)); + CuAssertIntEquals(tc, false, lighthouse_guarded(r4)); test_teardown(); } @@ -96,5 +130,6 @@ CuSuite *get_lighthouse_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_lighthouse_range); SUITE_ADD_TEST(suite, test_lighthouse_update); + SUITE_ADD_TEST(suite, test_lighthouse_guard); return suite; } diff --git a/src/move.c b/src/move.c index 990d6fc14..205b52416 100644 --- a/src/move.c +++ b/src/move.c @@ -1779,7 +1779,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) /* storms should be the first thing we do. */ stormchance = stormyness / shipspeed(sh, u); - if (check_leuchtturm(next_point, NULL)) { + if (lighthouse_guarded(next_point)) { if (lighthouse_div > 0) { stormchance /= lighthouse_div; } @@ -1867,7 +1867,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) if (reason == SA_NO_INSECT) { ADDMSG(&f->msgs, msg_message("detectforbidden", "unit region", u, sh->region)); } - else if (check_leuchtturm(current_point, NULL)) { + else if (lighthouse_guarded(current_point)) { ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point)); } else { diff --git a/src/reports.c b/src/reports.c index 5355a1db9..5d22636e8 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1353,6 +1353,13 @@ static void add_seen_nb(faction *f, region *r, seen_mode mode) { update_interval(f, last); } +static void add_seen_lighthouse(region *r, faction *f) +{ + if (r->terrain->flags & SEA_REGION) { + add_seen_nb(f, r, seen_lighthouse); + } +} + /** mark all regions seen by the lighthouse. */ static void prepare_lighthouse_ql(faction *f, selist *rlist) { @@ -1361,9 +1368,7 @@ static void prepare_lighthouse_ql(faction *f, selist *rlist) { for (ql = rlist, qi = 0; ql; selist_advance(&ql, &qi, 1)) { region *rl = (region *)selist_get(ql, qi); - if (!fval(rl->terrain, FORBIDDEN_REGION)) { - add_seen_nb(f, rl, seen_lighthouse); - } + add_seen_lighthouse(rl, f); } } @@ -1382,9 +1387,7 @@ static void prepare_lighthouse(faction *f, region *r, int range) assert(n > 0 && n <= 64); for (i = 0; i != n; ++i) { region *rl = result[i]; - if (!fval(rl->terrain, FORBIDDEN_REGION)) { - add_seen_nb(f, rl, seen_lighthouse); - } + add_seen_lighthouse(rl, f); } } } @@ -1592,7 +1595,7 @@ void prepare_report(report_context *ctx, faction *f) if (rule_region_owners && f == region_get_owner(r)) { for (b = rbuildings(r); b; b = b->next) { if (b && b->type == bt_lighthouse) { - /* region owners get maximm range */ + /* region owners get maximum range */ int lhr = lighthouse_range(b, NULL, NULL); if (lhr > range) range = lhr; } @@ -1630,7 +1633,7 @@ void prepare_report(report_context *ctx, faction *f) /* unit is one of ours, and inside the current lighthouse */ if (br == 0) { /* lazy-calculate the range */ - br = lighthouse_range(u->building, f, u); + br = lighthouse_range(b, f, u); } if (br > range) { range = br; diff --git a/src/reports.test.c b/src/reports.test.c index 2b22782ae..6d7a7961f 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -530,7 +530,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) { static void test_prepare_lighthouse(CuTest *tc) { report_context ctx; faction *f; - region *r1, *r2, *r3; + region *r1, *r2, *r3, *r4; unit *u; building *b; building_type *btype; @@ -543,6 +543,7 @@ static void test_prepare_lighthouse(CuTest *tc) { r1 = test_create_region(0, 0, t_plain); r2 = test_create_region(1, 0, t_ocean); r3 = test_create_region(2, 0, t_ocean); + r4 = test_create_region(0, 1, t_plain); btype = test_create_buildingtype("lighthouse"); b = test_create_building(r1, btype); b->flags |= BLD_MAINTAINED; @@ -557,6 +558,7 @@ static void test_prepare_lighthouse(CuTest *tc) { CuAssertIntEquals(tc, seen_unit, r1->seen.mode); CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode); CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode); + CuAssertIntEquals(tc, seen_neighbour, r4->seen.mode); finish_reports(&ctx); test_teardown(); } From 7b7d3cb7597440d19722c56ac631e7392a414f26 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 17 Jul 2018 21:34:22 +0200 Subject: [PATCH 09/11] test: lighhouse size reduction reduces effectiveness --- src/lighthouse.c | 8 ++++---- src/lighthouse.test.c | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index 2ff1c6191..ff1cc5b84 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -25,10 +25,10 @@ bool is_lighthouse(const building_type *btype) } /* update_lighthouse: call this function whenever the size of a lighthouse changes -* it adds temporary markers to the surrounding regions. -* The existence of markers says nothing about the quality of the observer in -* the lighthouse, for this may change more frequently. -*/ + * it adds temporary markers to the surrounding regions. + * The existence of markers says nothing about the quality of the observer in + * the lighthouse, since this may change more frequently. + */ void update_lighthouse(building * lh) { region *r = lh->region; diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index bcc7c0ab7..f85b5ce99 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -122,6 +122,9 @@ static void test_lighthouse_guard(CuTest * tc) { CuAssertIntEquals(tc, true, lighthouse_guarded(r2)); CuAssertIntEquals(tc, true, lighthouse_guarded(r3)); CuAssertIntEquals(tc, false, lighthouse_guarded(r4)); + b->size = 1; /* size can go down in destroy_cmd */ + CuAssertIntEquals(tc, false, lighthouse_guarded(r2)); + CuAssertIntEquals(tc, false, lighthouse_guarded(r3)); test_teardown(); } From 228216091619a9837fe3a0e6b25291a60419ca71 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 18 Jul 2018 20:49:17 +0200 Subject: [PATCH 10/11] separate lighthouse_view_distance from lighthouse_range. --- src/lighthouse.c | 18 ++++++++++++------ src/lighthouse.h | 4 ++-- src/lighthouse.test.c | 31 +++++++++++++++++-------------- src/reports.c | 12 ++++++------ src/reports.test.c | 4 ++-- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index ff1cc5b84..4ef830cfc 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -36,7 +36,7 @@ void update_lighthouse(building * lh) r->flags |= RF_LIGHTHOUSE; if (lh->size >= 10) { - int d = lighthouse_range(lh, NULL, NULL); + int d = lighthouse_range(lh); int x; for (x = -d; x <= d; ++x) { int y; @@ -79,18 +79,24 @@ void remove_lighthouse(const building *lh) { } } -int lighthouse_range(const building * b, const faction * f, const unit *u) +int lighthouse_range(const building * b) { if (b->size >= 10 && (b->flags & BLD_MAINTAINED)) { - int maxd = (int)log10(b->size) + 1; + return (int)log10(b->size) + 1; + } + return 0; +} - if (u && skill_enabled(SK_PERCEPTION)) { +int lighthouse_view_distance(const building * b, const unit *u) +{ + if (b->size >= 10 && (b->flags & BLD_MAINTAINED)) { + int maxd = lighthouse_range(b); + + if (maxd > 0 && u && skill_enabled(SK_PERCEPTION)) { int sk = effskill(u, SK_PERCEPTION, 0) / 3; assert(u->building == b); - assert(u->faction == f); if (maxd > sk) maxd = sk; } - /* E3A rule: no perception req'd */ return maxd; } return 0; diff --git a/src/lighthouse.h b/src/lighthouse.h index cd5a02d04..cd0e055fd 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -39,8 +39,8 @@ extern "C" { bool lighthouse_guarded(const struct region *r); void update_lighthouse(struct building *b); void remove_lighthouse(const struct building *lh); - int lighthouse_range(const struct building *b, const struct faction *f, - const struct unit *u); + int lighthouse_range(const struct building *b); + int lighthouse_view_distance(const struct building *b, const struct unit *u); #ifdef __cplusplus diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index f85b5ce99..d9accd49e 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -26,30 +26,33 @@ static void test_lighthouse_range(CuTest * tc) u1 = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(test_create_faction(NULL), r); b = test_create_building(r, test_create_buildingtype("lighthouse")); - CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL, NULL)); - CuAssertIntEquals(tc, 0, lighthouse_range(b, u1->faction, NULL)); + CuAssertIntEquals(tc, 0, lighthouse_range(b)); + b->size = 9; + CuAssertIntEquals(tc, 0, lighthouse_range(b)); b->size = 10; - CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL, NULL)); + CuAssertIntEquals(tc, 0, lighthouse_range(b)); + b->flags |= BLD_MAINTAINED; + CuAssertIntEquals(tc, 2, lighthouse_range(b)); u1->building = b; u2->building = b; u1->number = 10; set_level(u1, SK_PERCEPTION, 3); set_level(u2, SK_PERCEPTION, 3); - CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL, NULL)); - b->flags |= BLD_MAINTAINED; - CuAssertIntEquals(tc, 1, lighthouse_range(b, u1->faction, u1)); + CuAssertIntEquals(tc, 1, lighthouse_view_distance(b, u1)); set_level(u1, SK_PERCEPTION, 6); - CuAssertIntEquals(tc, 2, lighthouse_range(b, u1->faction, u1)); - /* lighthouse_range does not check inside_building */ - CuAssertIntEquals(tc, 1, lighthouse_range(b, u2->faction, u2)); + CuAssertIntEquals(tc, 1, lighthouse_view_distance(b, u2)); + CuAssertIntEquals(tc, 2, lighthouse_view_distance(b, u1)); b->size = 100; update_lighthouse(b); - CuAssertIntEquals(tc, 3, lighthouse_range(b, NULL, NULL)); - CuAssertIntEquals(tc, 2, lighthouse_range(b, u1->faction, u1)); + CuAssertIntEquals(tc, 3, lighthouse_range(b)); + CuAssertIntEquals(tc, 2, lighthouse_view_distance(b, u1)); set_level(u1, SK_PERCEPTION, 9); - CuAssertIntEquals(tc, 3, lighthouse_range(b, u1->faction, u1)); - CuAssertIntEquals(tc, 1, lighthouse_range(b, u2->faction, u2)); + CuAssertIntEquals(tc, 3, lighthouse_view_distance(b, u1)); + CuAssertIntEquals(tc, 1, lighthouse_view_distance(b, u2)); + b->size = 99; + CuAssertIntEquals(tc, 2, lighthouse_view_distance(b, u1)); + test_teardown(); } @@ -111,7 +114,7 @@ static void test_lighthouse_guard(CuTest * tc) { b = test_create_building(r1, test_create_buildingtype("lighthouse")); b->flags |= BLD_MAINTAINED; b->size = 10; - CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL, NULL)); + CuAssertIntEquals(tc, 2, lighthouse_range(b)); update_lighthouse(b); CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); CuAssertPtrEquals(tc, NULL, r1->attribs); diff --git a/src/reports.c b/src/reports.c index 5d22636e8..711d09874 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1596,7 +1596,7 @@ void prepare_report(report_context *ctx, faction *f) for (b = rbuildings(r); b; b = b->next) { if (b && b->type == bt_lighthouse) { /* region owners get maximum range */ - int lhr = lighthouse_range(b, NULL, NULL); + int lhr = lighthouse_view_distance(b, NULL); if (lhr > range) range = lhr; } } @@ -1613,7 +1613,7 @@ void prepare_report(report_context *ctx, faction *f) */ if (!fval(r, RF_LIGHTHOUSE)) { /* it's enough to add the region once, and if there are - * no lighthouses, there is no need to look at more units */ + * no lighthouses here, there is no need to look at more units */ break; } } @@ -1633,10 +1633,10 @@ void prepare_report(report_context *ctx, faction *f) /* unit is one of ours, and inside the current lighthouse */ if (br == 0) { /* lazy-calculate the range */ - br = lighthouse_range(b, f, u); - } - if (br > range) { - range = br; + br = lighthouse_view_distance(b, u); + if (br > range) { + range = br; + } } } } diff --git a/src/reports.test.c b/src/reports.test.c index 6d7a7961f..5a6e1fd9e 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -495,7 +495,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) { u1->number = 4; u1->building = b; set_level(u1, SK_PERCEPTION, 3); - CuAssertIntEquals(tc, 1, lighthouse_range(b, u1->faction, u1)); + CuAssertIntEquals(tc, 1, lighthouse_view_distance(b, u1)); CuAssertPtrEquals(tc, b, inside_building(u1)); u2 = test_create_unit(f, r1); u2->building = b; @@ -597,7 +597,7 @@ static void test_prepare_lighthouse_owners(CuTest *tc) u = test_create_unit(test_create_faction(NULL), r1); u->building = b; region_set_owner(b->region, f, 0); - CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL, NULL)); + CuAssertIntEquals(tc, 2, lighthouse_view_distance(b, NULL)); prepare_report(&ctx, f); CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, NULL, ctx.last); From e62b5c580dd283f2533f9049b316c2ee59a9e934 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 19 Jul 2018 04:57:33 +0200 Subject: [PATCH 11/11] update tests to reflect new lighthouse rules --- tests/run-turn.sh | 10 +++++----- tests/write-reports.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/run-turn.sh b/tests/run-turn.sh index ad2e0e6b8..470cb6e2b 100755 --- a/tests/run-turn.sh +++ b/tests/run-turn.sh @@ -54,11 +54,11 @@ assert_grep_count reports/$CRFILE '^EINHEIT' 2 assert_grep_count reports/$CRFILE '^GEGENSTAENDE' 2 assert_grep_count reports/185-heg.cr '185;Runde' 1 -assert_grep_count reports/185-heg.cr ';Baeume' 4 -assert_grep_count reports/185-heg.cr '"B.ume";type' 4 -assert_grep_count reports/185-heg.cr '"Pferde";type' 6 -assert_grep_count reports/185-heg.nr 'erblickt' 6 -assert_grep_count reports/185-heg.cr '"lighthouse";visibility' 6 +assert_grep_count reports/185-heg.cr ';Baeume' 2 +assert_grep_count reports/185-heg.cr '"B.ume";type' 2 +assert_grep_count reports/185-heg.cr '"Pferde";type' 2 +assert_grep_count reports/185-heg.nr 'erblickt' 2 +assert_grep_count reports/185-heg.cr '"lighthouse";visibility' 2 assert_grep_count reports/185-heg.cr '"neighbour";visibility' 11 assert_grep_count reports/185-6rLo.cr '^EINHEIT' 2 assert_grep_count reports/185-6rLo.cr '^REGION' 13 diff --git a/tests/write-reports.sh b/tests/write-reports.sh index 5621e84a9..c3d1066e3 100755 --- a/tests/write-reports.sh +++ b/tests/write-reports.sh @@ -19,7 +19,7 @@ done #set -e cd $ROOT/tests setup -#cleanup +cleanup VALGRIND=`which valgrind` TESTS=../Debug/eressea/test_eressea SERVER=../Debug/eressea/eressea