Merge branch 'develop' of github.com:ennorehling/eressea into develop

This commit is contained in:
Enno Rehling 2018-07-16 10:51:09 +02:00
commit 00459782b9
38 changed files with 456 additions and 421 deletions

2
clibs

@ -1 +1 @@
Subproject commit f9842e07a442c5453c270badf25ab72633b4edf5 Subproject commit 9b6e34959f77d7ca3a4ce3826cb487487f557441

View File

@ -39,7 +39,7 @@
"entertain.perlevel": 20, "entertain.perlevel": 20,
"taxing.perlevel": 20, "taxing.perlevel": 20,
"nmr.timeout": 5, "nmr.timeout": 5,
"nmr.removenewbie": 0, "nmr.removenewbie": false,
"GiveRestriction": 3, "GiveRestriction": 3,
"hunger.long": true, "hunger.long": true,
"init_spells": 0, "init_spells": 0,

View File

@ -1,7 +1,9 @@
{ {
"include": [ "include": [
"config://res/translations/strings.de.po", "config://res/translations/strings.de.po",
"config://res/translations/strings-e2.de.po",
"config://res/translations/strings.en.po", "config://res/translations/strings.en.po",
"config://res/translations/strings-e2.en.po",
"config://res/translations/messages.de.po", "config://res/translations/messages.de.po",
"config://res/translations/messages.en.po", "config://res/translations/messages.en.po",
"config://res/core/messages.xml" "config://res/core/messages.xml"

View File

@ -58,7 +58,7 @@
"entertain.base": 0, "entertain.base": 0,
"entertain.perlevel": 20, "entertain.perlevel": 20,
"nmr.timeout": 5, "nmr.timeout": 5,
"nmr.removenewbie": 0, "nmr.removenewbie": false,
"GiveRestriction": 3, "GiveRestriction": 3,
"healing.forest": 2.0, "healing.forest": 2.0,
"hunger.long": false, "hunger.long": false,

View File

@ -1,6 +1,5 @@
SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \ SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \
run-turn sendreports.sh run-turn sendreports.sh sendreport.sh
IGNORE=sendreport.sh
shellcheck: $(SCRIPTS) shellcheck: $(SCRIPTS)
shellcheck $(SCRIPTS) shellcheck $(SCRIPTS)

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
(
[ "$PREVIEW" != "yes" ] && exit [ "$PREVIEW" != "yes" ] && exit
[ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea [ -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} run && \
${SRC}/s/preview -g ${game} send ${SRC}/s/preview -g ${game} send
done done
) | tee -a $HOME/log/preview.cron.log

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
GAME=$1 GAME=$1
(
[ "$ENABLED" != "yes" ] && exit [ "$ENABLED" != "yes" ] && exit
[ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea
@ -58,3 +58,5 @@ $BIN/compress.sh $GAME $TURN
$BIN/sendreports.sh $GAME $BIN/sendreports.sh $GAME
$BIN/backup-eressea $GAME $TURN $BIN/backup-eressea $GAME $TURN
rm -f test/execute.lock rm -f test/execute.lock
) | tee -a $HOME/log/eressea.cron.log

View File

@ -1,10 +0,0 @@
#!/bin/bash
PATH=$ERESSEA/bin:$PATH
function abort() {
if [ $# -gt 0 ]; then
echo $@
fi
exit -1
}

View File

@ -1,11 +1,17 @@
#!/bin/bash #!/bin/bash
if [ -z $ERESSEA ]; then if [ -z "$ERESSEA" ]; then
echo "You have to define the \$ERESSEA environment variable to run $0" echo "You have to define the \$ERESSEA environment variable to run $0"
exit -2 exit -2
fi fi
source $HOME/bin/functions.sh
function abort() {
if [ $# -gt 0 ]; then
echo "$@"
fi
exit -1
}
GAME=$1 GAME=$1
EMAIL=$2 EMAIL=$2
@ -14,32 +20,33 @@ PASSWD=$4
#echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log #echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log
function reply() { function reply() {
echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL echo "$@" | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL"
abort $@ abort "$@"
} }
LOCKFILE=$ERESSEA/.report.lock LOCKFILE="$ERESSEA/.report.lock"
[ -e $LOCKFILE ] && reply "lockfile exists. wait for mail delivery to finish." [ -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 cd "$ERESSEA/game-$GAME/reports" || exit
checkpasswd.py game-$GAME/passwd $FACTION $PASSWD || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" if [ ! -e "${FACTION}.sh" ]; then
cd $ERESSEA/game-$GAME/reports
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" \ 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 exit
fi 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)" 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") OWNER=$(sqlite3 "$ERESSEA/game-$GAME/eressea.db" "$SQL")
echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ if [ ! -z "$OWNER" ]; then
| mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \
| mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER"
fi
fi fi

View File

@ -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."

View File

@ -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."

View File

@ -327,10 +327,6 @@ msgctxt "spell"
msgid "clone" msgid "clone"
msgstr "Seelenkopie" 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" msgctxt "shipinfo"
msgid "balloon" 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." 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" 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." 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" msgid "wdw_pyramid"
msgstr "Pyramide" msgstr "Pyramide"
@ -1459,10 +1451,6 @@ msgctxt "race"
msgid "goblin_x" msgid "goblin_x"
msgstr "Goblin" 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" msgctxt "spell"
msgid "raindance" msgid "raindance"
msgstr "Regentanz" msgstr "Regentanz"
@ -1494,10 +1482,6 @@ msgstr "Mallorn"
msgid "mallorn_p" msgid "mallorn_p"
msgstr "Mallorn" 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" msgctxt "spell"
msgid "homestone" msgid "homestone"
msgstr "Heimstein" msgstr "Heimstein"
@ -1740,10 +1724,6 @@ msgstr "Beschwörung eines Wasserelementares"
msgid "GEBAEUDE" msgid "GEBAEUDE"
msgstr "GEBÄUDE" 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" msgid "KRAEUTER"
msgstr "KRÄUTER" msgstr "KRÄUTER"
@ -3147,10 +3127,6 @@ msgctxt "spellinfo"
msgid "create_focus" msgid "create_focus"
msgstr "Erzeugt einen Aurafokus." 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" msgctxt "spell"
msgid "song_of_slavery" msgid "song_of_slavery"
msgstr "Gesang der Versklavung" msgstr "Gesang der Versklavung"
@ -4910,10 +4886,6 @@ msgstr "Elixier der Macht"
msgid "wand_p" msgid "wand_p"
msgstr "Zauberstäbe" 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" msgctxt "spell"
msgid "strength" msgid "strength"
msgstr "Unbekannter Effekt" msgstr "Unbekannter Effekt"
@ -4996,10 +4968,6 @@ msgstr "Myrrhe"
msgid "skeleton_prefix_9" msgid "skeleton_prefix_9"
msgstr "Dunkle" 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" msgctxt "spell"
msgid "big_recruit" msgid "big_recruit"
msgstr "Hohe Kunst der Überzeugung" msgstr "Hohe Kunst der Überzeugung"
@ -5913,10 +5881,6 @@ msgctxt "spell"
msgid "cerddorfumbleshield" msgid "cerddorfumbleshield"
msgstr "Bannlied" 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" msgid "ANZAHL"
msgstr "ANZAHL" msgstr "ANZAHL"

View File

@ -273,10 +273,6 @@ msgctxt "spell"
msgid "clone" msgid "clone"
msgstr "Doppelganger" 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" msgctxt "spell"
msgid "bloodsacrifice" msgid "bloodsacrifice"
msgstr "Lesser Sacrifice" msgstr "Lesser Sacrifice"
@ -695,10 +691,6 @@ msgctxt "spellinfo"
msgid "disturbingdreams" 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." 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" msgid "wdw_pyramid"
msgstr "pyramid" msgstr "pyramid"
@ -1221,10 +1213,6 @@ msgctxt "race"
msgid "goblin_x" msgid "goblin_x"
msgstr "goblin" 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" msgctxt "spell"
msgid "raindance" msgid "raindance"
msgstr "Rain Dance" msgstr "Rain Dance"
@ -1252,10 +1240,6 @@ msgstr "mallorn"
msgid "mallorn_p" msgid "mallorn_p"
msgstr "mallorn" 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" msgid "thickfog_trail"
msgstr "%s" msgstr "%s"
@ -1490,10 +1474,6 @@ msgctxt "spell"
msgid "goodwinds" msgid "goodwinds"
msgstr "Summon Water Elemental" 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" msgid "KRAEUTER"
msgstr "HERBS" msgstr "HERBS"
@ -2732,10 +2712,6 @@ msgctxt "spellinfo"
msgid "create_focus" msgid "create_focus"
msgstr "Creates an aurafocus crystal." 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" msgctxt "spell"
msgid "song_of_slavery" msgid "song_of_slavery"
msgstr "Song of Slavery" msgstr "Song of Slavery"
@ -4370,10 +4346,6 @@ msgstr "elixir of power"
msgid "wand_p" msgid "wand_p"
msgstr "wands" 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" msgctxt "spell"
msgid "strength" msgid "strength"
msgstr "Unknown Effect" msgstr "Unknown Effect"
@ -4426,10 +4398,6 @@ msgstr "trees"
msgid "myrrh_p" msgid "myrrh_p"
msgstr "myrrh" 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" msgctxt "spell"
msgid "big_recruit" msgid "big_recruit"
msgstr "High art of persuasion" msgstr "High art of persuasion"
@ -5222,10 +5190,6 @@ msgctxt "spell"
msgid "cerddorfumbleshield" msgid "cerddorfumbleshield"
msgstr "Countersong" 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" msgctxt "keyword"
msgid "teach" msgid "teach"
msgstr "TEACH" msgstr "TEACH"

View File

@ -4,6 +4,7 @@ eressea.log.debug('rules for game E2')
math.randomseed(rng.random()) math.randomseed(rng.random())
local equipment = require('eressea.equipment') local equipment = require('eressea.equipment')
local sets = { local sets = {
['seed_faction'] = { ['seed_faction'] = {
['items'] = { ['items'] = {

View File

@ -1,13 +1,20 @@
-- forward declaration required: -- forward declarations required:
local self = {} local self = {}
local function equip_first(u)
equip_newunits(u)
name = 'seed_' .. u.race
equip_unit(u, name, 255)
end
local mysets = { local mysets = {
['first_unit'] = { ['first_unit'] = {
['items'] = { ['items'] = {
['money'] = 2500, ['money'] = 2500,
['log'] = 10, ['log'] = 10,
['stone'] = 4 ['stone'] = 4
} },
['callback'] = equip_first
}, },
['seed_unit'] = { ['seed_unit'] = {
['items'] = { ['items'] = {
@ -75,7 +82,7 @@ local mysets = {
}, },
['seed_insect'] = { ['seed_insect'] = {
['items'] = { ['items'] = {
['nestwarmth'] =9 ['nestwarmth'] = 9
} }
}, },
['seed_halfling'] = { ['seed_halfling'] = {

View File

@ -1,5 +1,6 @@
require 'eressea.path' require 'eressea.path'
require 'eressea.resources' require 'eressea.resources'
require 'eressea.equipment'
require 'eressea.spells' require 'eressea.spells'
local self = {} local self = {}

View File

@ -6,5 +6,6 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
require 'eressea.path' require 'eressea.path'
require 'eressea' require 'eressea'
require 'eressea.xmlconf' require 'eressea.xmlconf'
eressea.read_game(get_turn() .. ".dat") eressea.read_game(get_turn() .. ".dat")
gmtool.editor() gmtool.editor()

View File

@ -14,6 +14,22 @@ function test_read_race()
assert_not_nil(f) assert_not_nil(f)
end 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() function test_seed_unit()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create('human') local f = faction.create('human')

View File

@ -209,6 +209,7 @@ void register_attributes(void)
at_deprecate("maxmagicians", a_readint); /* factions with differnt magician limits, probably unused */ at_deprecate("maxmagicians", a_readint); /* factions with differnt magician limits, probably unused */
at_deprecate("hurting", a_readint); /* an old arena attribute */ at_deprecate("hurting", a_readint); /* an old arena attribute */
at_deprecate("chaoscount", a_readint); /* used to increase the chance of monster spawns */
at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */
at_deprecate("orcification", a_readint); /* required for old datafiles */ at_deprecate("orcification", a_readint); /* required for old datafiles */
at_deprecate("lua", read_ext); /* required for old datafiles */ at_deprecate("lua", read_ext); /* required for old datafiles */

View File

@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include "battle.h" #include "battle.h"
#include "alchemy.h" #include "alchemy.h"
#include "chaos.h"
#include "guard.h" #include "guard.h"
#include "laws.h" #include "laws.h"
#include "monsters.h" #include "monsters.h"
@ -2531,7 +2530,6 @@ static void battle_effects(battle * b, int dead_players)
} }
if (dead_peasants) { if (dead_peasants) {
deathcounts(r, dead_peasants + dead_players); deathcounts(r, dead_peasants + dead_players);
add_chaoscount(r, dead_peasants / 2);
rsetpeasants(r, rp - dead_peasants); rsetpeasants(r, rp - dead_peasants);
} }
} }
@ -3325,7 +3323,7 @@ fighter * get_fighter(battle * b, const struct unit * u)
return 0; 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; side *s;
fighter *fc = NULL; fighter *fc = NULL;

View File

@ -261,6 +261,7 @@ extern "C" {
void free_battle(struct battle * b); void free_battle(struct battle * b);
struct fighter *make_fighter(struct battle *b, struct unit *u, struct fighter *make_fighter(struct battle *b, struct unit *u,
struct side * s, bool attack); 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, struct side *make_side(struct battle * b, const struct faction * f,
const struct group * g, unsigned int flags, const struct group * g, unsigned int flags,
const struct faction * stealthfaction); const struct faction * stealthfaction);

View File

@ -1,6 +1,8 @@
#include <platform.h> #include <platform.h>
#include "battle.h" #include "battle.h"
#include "reports.h"
#include "skill.h" #include "skill.h"
#include <kernel/config.h> #include <kernel/config.h>
@ -16,6 +18,8 @@
#include <spells/buildingcurse.h> #include <spells/buildingcurse.h>
#include <util/functions.h> #include <util/functions.h>
#include <util/language.h>
#include <util/message.h>
#include <util/rand.h> #include <util/rand.h>
#include <util/rng.h> #include <util/rng.h>
#include <util/strings.h> #include <util/strings.h>
@ -552,6 +556,103 @@ static void test_battle_skilldiff(CuTest *tc)
test_teardown(); 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) static void test_battle_skilldiff_building(CuTest *tc)
{ {
troop ta, td; troop ta, td;
@ -690,6 +791,9 @@ CuSuite *get_battle_suite(void)
SUITE_ADD_TEST(suite, test_select_armor); SUITE_ADD_TEST(suite, test_select_armor);
SUITE_ADD_TEST(suite, test_battle_skilldiff); SUITE_ADD_TEST(suite, test_battle_skilldiff);
SUITE_ADD_TEST(suite, test_battle_skilldiff_building); 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_defenders_get_building_bonus);
SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus); SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus);
SUITE_ADD_TEST(suite, test_building_bonus_respects_size); SUITE_ADD_TEST(suite, test_building_bonus_respects_size);

View File

@ -7,7 +7,6 @@
#include "bind_ship.h" #include "bind_ship.h"
#include "bind_building.h" #include "bind_building.h"
#include "chaos.h"
#include "teleport.h" #include "teleport.h"
#include <kernel/calendar.h> #include <kernel/calendar.h>
@ -356,7 +355,7 @@ static int tolua_region_get_resourcelevel(lua_State * L)
#define LUA_ASSERT(c, s) if (!(c)) { log_error("%s(%d): %s\n", __FILE__, __LINE__, (s)); return 0; } #define LUA_ASSERT(c, s) if (!(c)) { log_error("%s(%d): %s\n", __FILE__, __LINE__, (s)); return 0; }
static int special_resource(const char *type) { static int special_resource(const char *type) {
const char * special[] = { "seed", "sapling", "tree", "grave", "chaos", 0 }; const char * special[] = { "seed", "sapling", "tree", "grave", NULL };
int i; int i;
for (i = 0; special[i]; ++i) { for (i = 0; special[i]; ++i) {
@ -389,9 +388,6 @@ static int tolua_region_get_resource(lua_State * L)
case 3: case 3:
result = deathcount(r); result = deathcount(r);
break; break;
case 4:
result = get_chaoscount(r);
break;
default: default:
rtype = rt_find(type); rtype = rt_find(type);
if (rtype) { if (rtype) {
@ -423,9 +419,6 @@ static int tolua_region_set_resource(lua_State * L)
case 3: case 3:
deathcounts(r, value - deathcount(r)); deathcounts(r, value - deathcount(r));
break; break;
case 4:
add_chaoscount(r, value - get_chaoscount(r));
break;
default: default:
rtype = rt_find(type); rtype = rt_find(type);
if (rtype != NULL) { if (rtype != NULL) {

View File

@ -39,57 +39,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
/*********************/
/* at_chaoscount */
/*********************/
attrib_type at_chaoscount = {
"chaoscount",
DEFAULT_INIT,
DEFAULT_FINALIZE,
DEFAULT_AGE,
a_writeint,
a_readint,
NULL,
ATF_UNIQUE
};
void set_chaoscount(struct region *r, int deaths)
{
if (deaths==0) {
a_removeall(&r->attribs, &at_chaoscount);
} else {
attrib *a = a_find(r->attribs, &at_chaoscount);
if (!a) {
a = a_add(&r->attribs, a_new(&at_chaoscount));
}
a->data.i = deaths;
}
}
int get_chaoscount(const region * r)
{
attrib *a = a_find(r->attribs, &at_chaoscount);
if (!a)
return 0;
return a->data.i;
}
void add_chaoscount(region * r, int fallen)
{
attrib *a;
if (fallen == 0)
return;
a = a_find(r->attribs, &at_chaoscount);
if (!a)
a = a_add(&r->attribs, a_new(&at_chaoscount));
a->data.i += fallen;
if (a->data.i <= 0)
a_remove(&r->attribs, a);
}
static const terrain_type *chaosterrain(void) static const terrain_type *chaosterrain(void)
{ {
static const terrain_type **types; static const terrain_type **types;
@ -248,18 +197,8 @@ void chaos_update(void) {
region *r; region *r;
/* Chaos */ /* Chaos */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
int i;
if ((r->flags & RF_CHAOTIC)) { if ((r->flags & RF_CHAOTIC)) {
chaos(r); chaos(r);
} }
i = get_chaoscount(r);
if (i) {
add_chaoscount(r, -(int)(i * ((double)(rng_int() % 10)) / 100.0));
}
} }
} }
void chaos_register(void) {
at_register(&at_chaoscount);
}

View File

@ -24,15 +24,8 @@ extern "C" {
struct region; struct region;
extern struct attrib_type at_chaoscount;
void chaos_register(void);
void chaos_update(void); void chaos_update(void);
void set_chaoscount(struct region *r, int deaths);
int get_chaoscount(const struct region * r);
void add_chaoscount(struct region * r, int deaths);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -24,7 +24,6 @@
#include "attributes/attributes.h" #include "attributes/attributes.h"
#include "races/races.h" #include "races/races.h"
#include "chaos.h"
#include "items.h" #include "items.h"
#include "creport.h" #include "creport.h"
#include "report.h" #include "report.h"
@ -82,5 +81,4 @@ void game_init(void)
register_attributes(); register_attributes();
register_gmcmd(); register_gmcmd();
chaos_register();
} }

View File

@ -50,7 +50,6 @@
#include <util/unicode.h> #include <util/unicode.h>
#include "gmtool_structs.h" #include "gmtool_structs.h"
#include "chaos.h"
#include "console.h" #include "console.h"
#include "listbox.h" #include "listbox.h"
#include "wormhole.h" #include "wormhole.h"
@ -531,7 +530,6 @@ static void statusline(WINDOW * win, const char *str)
} }
static void reset_region(region *r) { static void reset_region(region *r) {
set_chaoscount(r, 0);
r->flags = 0; r->flags = 0;
a_removeall(&r->attribs, NULL); a_removeall(&r->attribs, NULL);
while (r->units) { while (r->units) {

View File

@ -631,28 +631,24 @@ void kernel_init(void)
translation_init(); translation_init();
} }
static order * defaults[MAXLOCALES];
order *default_order(const struct locale *lang) order *default_order(const struct locale *lang)
{ {
int i = locale_index(lang); int i = locale_index(lang);
keyword_t kwd;
const char * str;
order *result = 0; order *result = 0;
assert(i < MAXLOCALES);
result = defaults[i]; assert(i < MAXLOCALES);
if (!result) { kwd = keyword_disabled(K_WORK) ? NOKEYWORD : K_WORK;
const char * str; str = config_get("orders.default");
keyword_t kwd = NOKEYWORD; if (str) {
str = config_get("orders.default"); kwd = findkeyword(str);
if (str) {
kwd = findkeyword(str);
}
if (kwd != NOKEYWORD) {
result = create_order(kwd, lang, NULL);
defaults[i] = result;
}
} }
return result ? copy_order(result) : 0; if (kwd != NOKEYWORD) {
result = create_order(kwd, lang, NULL);
return copy_order(result);
}
return NULL;
} }
int rule_give(void) int rule_give(void)
@ -760,14 +756,6 @@ void free_config(void) {
*/ */
void free_gamedata(void) void free_gamedata(void)
{ {
int i;
for (i = 0; i != MAXLOCALES; ++i) {
if (defaults[i]) {
free_order(defaults[i]);
defaults[i] = 0;
}
}
free(forbidden_ids); free(forbidden_ids);
forbidden_ids = NULL; forbidden_ids = NULL;

View File

@ -180,15 +180,22 @@ static void test_default_order(CuTest *tc) {
test_setup(); test_setup();
loc = test_create_locale(); loc = test_create_locale();
ord = default_order(loc);
CuAssertPtrEquals(tc, 0, ord);
free_order(ord);
config_set("orders.default", "work");
ord = default_order(loc); ord = default_order(loc);
CuAssertPtrNotNull(tc, ord); CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_WORK, getkeyword(ord)); CuAssertIntEquals(tc, K_WORK, getkeyword(ord));
free_order(ord); free_order(ord);
enable_keyword(K_WORK, false);
ord = default_order(loc);
CuAssertPtrEquals(tc, NULL, ord);
free_order(ord);
config_set("orders.default", "entertain");
ord = default_order(loc);
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_ENTERTAIN, getkeyword(ord));
free_order(ord);
test_teardown(); test_teardown();
} }

View File

@ -29,6 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "group.h" #include "group.h"
#include "item.h" #include "item.h"
#include "messages.h" #include "messages.h"
#include "order.h"
#include "plane.h" #include "plane.h"
#include "race.h" #include "race.h"
#include "region.h" #include "region.h"
@ -294,8 +295,13 @@ unit *addplayer(region * r, faction * f)
assert(f->units == NULL); assert(f->units == NULL);
faction_setorigin(f, 0, r->x, r->y); faction_setorigin(f, 0, r->x, r->y);
u = create_unit(r, f, 1, f->race, 0, NULL, NULL); u = create_unit(r, f, 1, f->race, 0, NULL, NULL);
u->thisorder = default_order(f->locale);
unit_addorder(u, copy_order(u->thisorder));
name = config_get("rules.equip_first"); name = config_get("rules.equip_first");
equip_unit(u, name ? name : "first_unit"); if (!equip_unit(u, name ? name : "first_unit")) {
/* give every unit enough money to survive the first turn */
i_change(&u->items, get_resourcetype(R_SILVER)->itype, maintenance_cost(u));
}
u->hp = unit_max_hp(u) * u->number; u->hp = unit_max_hp(u) * u->number;
fset(u, UFL_ISNEW); fset(u, UFL_ISNEW);
if (f->race == get_race(RC_DAEMON)) { if (f->race == get_race(RC_DAEMON)) {
@ -486,36 +492,6 @@ void destroyfaction(faction ** fp)
} }
handle_event(f->attribs, "destroy", f); 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) { if (f->alliance) {
setalliance(f, 0); setalliance(f, 0);
} }

View File

@ -3,8 +3,10 @@
#include <kernel/ally.h> #include <kernel/ally.h>
#include <kernel/alliance.h> #include <kernel/alliance.h>
#include <kernel/calendar.h> #include <kernel/calendar.h>
#include <kernel/callbacks.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
@ -298,9 +300,30 @@ static void test_save_special_items(CuTest *tc) {
test_teardown(); test_teardown();
} }
static void test_addplayer(CuTest *tc) {
unit *u;
region *r;
faction *f;
item_type *itype;
test_setup();
callbacks.equip_unit = NULL;
itype = test_create_silver();
r = test_create_plain(0, 0);
f = test_create_faction(NULL);
u = addplayer(r, f);
CuAssertPtrNotNull(tc, u);
CuAssertPtrEquals(tc, r, u->region);
CuAssertPtrEquals(tc, f, u->faction);
CuAssertIntEquals(tc, i_get(u->items, itype), 10);
CuAssertPtrNotNull(tc, u->orders);
CuAssertIntEquals(tc, K_WORK, getkeyword(u->orders));
test_teardown();
}
CuSuite *get_faction_suite(void) CuSuite *get_faction_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_addplayer);
SUITE_ADD_TEST(suite, test_max_migrants); SUITE_ADD_TEST(suite, test_max_migrants);
SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_addfaction);
SUITE_ADD_TEST(suite, test_remove_empty_factions); SUITE_ADD_TEST(suite, test_remove_empty_factions);

View File

@ -512,6 +512,7 @@ static void test_create_order_long(CuTest *tc) {
stream_order(&out, ord, lang, true); stream_order(&out, ord, lang, true);
out.api->rewind(out.handle); out.api->rewind(out.handle);
out.api->readln(out.handle, buffer, sizeof(buffer)); out.api->readln(out.handle, buffer, sizeof(buffer));
CuAssertIntEquals(tc, 1026, strlen(buffer));
mstream_done(&out); mstream_done(&out);
free_order(ord); free_order(ord);
test_teardown(); test_teardown();

View File

@ -24,7 +24,6 @@
#include "monsters.h" #include "monsters.h"
#include "economy.h" #include "economy.h"
#include "chaos.h"
#include "give.h" #include "give.h"
#include "guard.h" #include "guard.h"
#include "laws.h" #include "laws.h"
@ -756,6 +755,11 @@ void plan_monsters(faction * f)
if (u->faction!=f) if (u->faction!=f)
continue; 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: */ /* Befehle m<>ssen jede Runde neu gegeben werden: */
free_orders(&u->orders); free_orders(&u->orders);
if (skill_enabled(SK_PERCEPTION)) { if (skill_enabled(SK_PERCEPTION)) {
@ -843,18 +847,14 @@ void plan_monsters(faction * f)
pathfinder_cleanup(); pathfinder_cleanup();
} }
static double chaosfactor(region * r)
{
return fval(r, RF_CHAOTIC) ? ((double)(1 + get_chaoscount(r)) / 1000.0) : 0.0;
}
static int nrand(int handle_start, int sub) static int nrand(int handle_start, int sub)
{ {
int res = 0; int res = 0;
do { do {
if (rng_int() % 100 < handle_start) if (rng_int() % 100 < handle_start) {
res++; res++;
}
handle_start -= sub; handle_start -= sub;
} while (handle_start > 0); } while (handle_start > 0);
@ -876,7 +876,7 @@ void spawn_dragons(void)
region *r; region *r;
faction *monsters = get_or_create_monsters(); faction *monsters = get_or_create_monsters();
int minage = config_get_int("monsters.spawn.min_age", 100); int minage = config_get_int("monsters.spawn.min_age", 100);
int spawn_chance = 100 * config_get_int("monsters.spawn.chance", 100); int spawn_chance = config_get_int("monsters.spawn.chance", 100);
if (spawn_chance <= 0) { if (spawn_chance <= 0) {
/* monster spawning disabled */ /* monster spawning disabled */
@ -895,7 +895,8 @@ void spawn_dragons(void)
else if ((r->terrain == newterrain(T_GLACIER) else if ((r->terrain == newterrain(T_GLACIER)
|| r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_SWAMP)
|| r->terrain == newterrain(T_DESERT)) || r->terrain == newterrain(T_DESERT))
&& rng_int() % spawn_chance < (5 + 100 * chaosfactor(r))) { && rng_int() % spawn_chance < 6)
{
if (chance(0.80)) { if (chance(0.80)) {
u = create_unit(r, monsters, nrand(60, 20) + 1, get_race(RC_FIREDRAGON), 0, NULL, NULL); u = create_unit(r, monsters, nrand(60, 20) + 1, get_race(RC_FIREDRAGON), 0, NULL, NULL);
} }
@ -907,7 +908,7 @@ void spawn_dragons(void)
log_debug("spawning %d %s in %s.\n", u->number, log_debug("spawning %d %s in %s.\n", u->number,
LOC(default_locale, LOC(default_locale,
rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL));
name_unit(u); name_unit(u);
@ -932,9 +933,9 @@ void spawn_undead(void)
continue; continue;
} }
} }
/* Chance 0.1% * chaosfactor */
if (r->land && unburied > rpeasants(r) / 20 if (r->land && unburied > rpeasants(r) / 20
&& rng_int() % 10000 < (100 + 100 * chaosfactor(r))) { && rng_int() % 10000 < 200) {
message *msg; message *msg;
unit *u; unit *u;
/* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen. /* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen.

View File

@ -79,7 +79,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/bsdstring.h> #include "util/bsdstring.h"
#include <util/goodies.h> #include <util/goodies.h>
#include <util/language.h> #include <util/language.h>
#include <util/lists.h> #include <util/lists.h>
@ -243,39 +243,44 @@ static size_t write_spell_modifier(const spell * sp, int flag, const char * str,
return 0; return 0;
} }
void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct locale *lang) void nr_spell_syntax(char *buf, size_t size, spellbook_entry * sbe, const struct locale *lang)
{ {
int bytes;
char buf[4096];
char *bufp = buf;
size_t size = sizeof(buf) - 1;
const spell *sp = spellref_get(&sbe->spref); const spell *sp = spellref_get(&sbe->spref);
const char *params = sp->parameter; const char *params = sp->parameter;
const char *spname;
sbstring sbs;
sbs_init(&sbs, buf, size);
if (sp->sptyp & ISCOMBATSPELL) { if (sp->sptyp & ISCOMBATSPELL) {
bytes = (int)str_strlcpy(bufp, LOC(lang, keyword(K_COMBATSPELL)), size); sbs_strcpy(&sbs, LOC(lang, keyword(K_COMBATSPELL)));
} }
else { else {
bytes = (int)str_strlcpy(bufp, LOC(lang, keyword(K_CAST)), size); sbs_strcpy(&sbs, LOC(lang, keyword(K_CAST)));
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
/* Reihenfolge beachten: Erst REGION, dann STUFE! */ /* Reihenfolge beachten: Erst REGION, dann STUFE! */
if (sp->sptyp & FARCASTING) { if (sp->sptyp & FARCASTING) {
bytes = snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION])); sbs_strcat(&sbs, " [");
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, LOC(lang, parameters[P_REGION]));
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, " x y]");
} }
if (sp->sptyp & SPELLLEVEL) { if (sp->sptyp & SPELLLEVEL) {
bytes = snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL])); sbs_strcat(&sbs, " [");
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, LOC(lang, parameters[P_LEVEL]));
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, " n]");
} }
bytes = (int)snprintf(bufp, size, " \"%s\"", spell_name(sp, lang)); spname = spell_name(sp, lang);
if (wrptr(&bufp, &size, bytes) != 0) if (strchr(spname, ' ') != NULL) {
WARN_STATIC_BUFFER(); /* contains spaces, needs quotes */
sbs_strcat(&sbs, " '");
sbs_strcat(&sbs, spname);
sbs_strcat(&sbs, "'");
}
else {
sbs_strcat(&sbs, " ");
sbs_strcat(&sbs, spname);
}
while (params && *params) { while (params && *params) {
typedef struct starget { typedef struct starget {
@ -298,52 +303,48 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
if (cp == 'u') { if (cp == 'u') {
targetp = targets + 1; targetp = targets + 1;
locp = LOC(lang, targetp->vars); locp = LOC(lang, targetp->vars);
bytes = (int)snprintf(bufp, size, " <%s>", locp); sbs_strcat(&sbs, " <");
sbs_strcat(&sbs, locp);
sbs_strcat(&sbs, ">");
if (*params == '+') { if (*params == '+') {
++params; ++params;
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, " [<");
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, locp);
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); sbs_strcat(&sbs, "> ...]");
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
else if (cp == 's') { else if (cp == 's') {
targetp = targets + 2; targetp = targets + 2;
locp = LOC(lang, targetp->vars); locp = LOC(lang, targetp->vars);
bytes = (int)snprintf(bufp, size, " <%s>", locp); sbs_strcat(&sbs, " <");
sbs_strcat(&sbs, locp);
sbs_strcat(&sbs, ">");
if (*params == '+') { if (*params == '+') {
++params; ++params;
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, " [<");
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, locp);
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); sbs_strcat(&sbs, "> ...]");
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
else if (cp == 'r') { else if (cp == 'r') {
bytes = (int)str_strlcpy(bufp, " <x> <y>", size); sbs_strcat(&sbs, " <x> <y>");
if (*params == '+') { if (*params == '+') {
++params; ++params;
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, " [<x> <y> ...]");
WARN_STATIC_BUFFER();
bytes = (int)str_strlcpy(bufp, " [<x> <y> ...]", size);
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
else if (cp == 'b') { else if (cp == 'b') {
targetp = targets + 3; targetp = targets + 3;
locp = LOC(lang, targetp->vars); locp = LOC(lang, targetp->vars);
bytes = (int)snprintf(bufp, size, " <%s>", locp); sbs_strcat(&sbs, " <");
sbs_strcat(&sbs, locp);
sbs_strcat(&sbs, ">");
if (*params == '+') { if (*params == '+') {
++params; ++params;
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, " [<");
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, locp);
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); sbs_strcat(&sbs, "> ...]");
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
else if (cp == 'k') { else if (cp == 'k') {
int i, maxparam = 0; int i, maxparam = 0;
@ -361,41 +362,35 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
++maxparam; ++maxparam;
} }
if (!maxparam || maxparam > 1) { if (!maxparam || maxparam > 1) {
bytes = (int)str_strlcpy(bufp, " (", size); sbs_strcat(&sbs, " (");
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
i = 0; i = 0;
for (targetp = targets; targetp->flag; ++targetp) { for (targetp = targets; targetp->flag; ++targetp) {
if (!maxparam || sp->sptyp & targetp->flag) { if (!maxparam || sp->sptyp & targetp->flag) {
if (i++ != 0) { if (i++ != 0) {
bytes = (int)str_strlcpy(bufp, " |", size); sbs_strcat(&sbs, " |");
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
if (targetp->param && targetp->vars) { if (targetp->param && targetp->vars) {
locp = LOC(lang, targetp->vars); locp = LOC(lang, targetp->vars);
bytes = sbs_strcat(&sbs, " ");
(int)snprintf(bufp, size, " %s <%s>", parameters[targetp->param], sbs_strcat(&sbs, parameters[targetp->param]);
locp); sbs_strcat(&sbs, " <");
sbs_strcat(&sbs, locp);
sbs_strcat(&sbs, ">");
if (multi) { if (multi) {
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, " [<");
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, locp);
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); sbs_strcat(&sbs, "> ...]");
} }
} }
else { else {
bytes = sbs_strcat(&sbs, " ");
(int)snprintf(bufp, size, " %s", parameters[targetp->param]); sbs_strcat(&sbs, parameters[targetp->param]);
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
} }
if (!maxparam || maxparam > 1) { if (!maxparam || maxparam > 1) {
bytes = (int)str_strlcpy(bufp, " )", size); sbs_strcat(&sbs, " )");
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
} }
else if (cp == 'i' || cp == 'c') { else if (cp == 'i' || cp == 'c') {
@ -416,21 +411,20 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
} }
if (*params == '?') { if (*params == '?') {
++params; ++params;
bytes = (int)snprintf(bufp, size, " [<%s>]", locp); sbs_strcat(&sbs, " [<");
sbs_strcat(&sbs, locp);
sbs_strcat(&sbs, ">]");
} }
else { else {
bytes = (int)snprintf(bufp, size, " <%s>", locp); sbs_strcat(&sbs, " <");
sbs_strcat(&sbs, locp);
sbs_strcat(&sbs, ">");
} }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
else { else {
log_error("unknown spell parameter %c for spell %s", cp, sp->sname); log_error("unknown spell parameter %c for spell %s", cp, sp->sname);
} }
} }
*bufp = 0;
paragraph(out, buf, 2, 0, 0);
} }
void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang) void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang)
@ -542,10 +536,8 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la
paragraph(out, buf, 0, 0, 0); paragraph(out, buf, 0, 0, 0);
paragraph(out, LOC(lang, "nr_spell_syntax"), 0, 0, 0); paragraph(out, LOC(lang, "nr_spell_syntax"), 0, 0, 0);
bufp = buf; nr_spell_syntax(buf, sizeof(buf), sbe, lang);
size = sizeof(buf) - 1; paragraph(out, buf, 2, 0, 0);
nr_spell_syntax(out, sbe, lang);
newline(out); newline(out);
} }
@ -1825,72 +1817,61 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f,
static void static void
nr_building(struct stream *out, const region *r, const building *b, const faction *f) nr_building(struct stream *out, const region *r, const building *b, const faction *f)
{ {
int i, bytes; int i;
const char *name, *bname, *billusion = NULL; const char *name, *bname, *billusion = NULL;
const struct locale *lang; const struct locale *lang;
char buffer[8192], *bufp = buffer; char buffer[8192];
message *msg; message *msg;
size_t size = sizeof(buffer) - 1; size_t size;
sbstring sbs;
assert(f); assert(f);
lang = f->locale; lang = f->locale;
newline(out); newline(out);
bytes = sbs_init(&sbs, buffer, sizeof(buffer));
snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang,
"nr_size"), b->size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
report_building(b, &bname, &billusion); report_building(b, &bname, &billusion);
size = str_slprintf(buffer, sizeof(buffer), "%s, %s %d, ", buildingname(b),
LOC(lang, "nr_size"), b->size);
sbs.end += size;
name = LOC(lang, billusion ? billusion : bname); name = LOC(lang, billusion ? billusion : bname);
bytes = (int)str_strlcpy(bufp, name, size); sbs_strcat(&sbs, name);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (billusion) { if (billusion) {
unit *owner = building_owner(b); unit *owner = building_owner(b);
if (owner && owner->faction == f) { if (owner && owner->faction == f) {
/* illusion. report real type */ /* illusion. report real type */
name = LOC(lang, bname); sbs_strcat(&sbs, " (");
bytes = snprintf(bufp, size, " (%s)", name); sbs_strcat(&sbs, LOC(lang, bname));
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, ")");
WARN_STATIC_BUFFER();
} }
} }
if (!building_finished(b)) { if (!building_finished(b)) {
bytes = (int)str_strlcpy(bufp, " ", size); sbs_strcat(&sbs, " ");
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, LOC(lang, "nr_building_inprogress"));
WARN_STATIC_BUFFER();
bytes = (int)str_strlcpy(bufp, LOC(lang, "nr_building_inprogress"), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) { if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) {
msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged,
b->besieged - b->size * SIEGEFACTOR); b->besieged - b->size * SIEGEFACTOR);
bytes = (int)nr_render(msg, lang, bufp, size, f);
if (wrptr(&bufp, &size, bytes) != 0) size = nr_render(msg, lang, sbs.end, sbs.size - (sbs.end - sbs.begin), f);
WARN_STATIC_BUFFER(); sbs.end += size;
msg_release(msg); msg_release(msg);
} }
i = 0; i = 0;
if (b->display && b->display[0]) { if (b->display && b->display[0]) {
bytes = (int)str_strlcpy(bufp, "; ", size); sbs_strcat(&sbs, "; ");
if (wrptr(&bufp, &size, bytes) != 0) sbs_strcat(&sbs, b->display);
WARN_STATIC_BUFFER();
bytes = (int)str_strlcpy(bufp, b->display, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
i = b->display[strlen(b->display) - 1]; i = b->display[strlen(b->display) - 1];
} }
if (i != '!' && i != '?' && i != '.') { if (i != '!' && i != '?' && i != '.') {
bytes = (int)str_strlcpy(bufp, ".", size); sbs_strcat(&sbs, ".");
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
*bufp = 0;
paragraph(out, buffer, 2, 0, 0); paragraph(out, buffer, 2, 0, 0);
if (r->seen.mode >= seen_lighthouse) { if (r->seen.mode >= seen_lighthouse) {
@ -1900,14 +1881,10 @@ nr_building(struct stream *out, const region *r, const building *b, const factio
static void nr_paragraph(struct stream *out, message * m, faction * f) static void nr_paragraph(struct stream *out, message * m, faction * f)
{ {
int bytes; char buf[4096];
char buf[4096], *bufp = buf;
size_t size = sizeof(buf) - 1;
assert(f); assert(f);
bytes = (int)nr_render(m, f->locale, bufp, size, f); nr_render(m, f->locale, buf, sizeof(buf), f);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
msg_release(m); msg_release(m);
paragraph(out, buf, 0, 0, 0); paragraph(out, buf, 0, 0, 0);
@ -2011,6 +1988,8 @@ void report_travelthru(struct stream *out, region *r, const faction *f)
} }
} }
#include "util/bsdstring.h"
int int
report_plaintext(const char *filename, report_context * ctx, report_plaintext(const char *filename, report_context * ctx,
const char *bom) const char *bom)

View File

@ -30,7 +30,7 @@ extern "C" {
void report_travelthru(struct stream *out, struct region * r, const struct faction * f); void report_travelthru(struct stream *out, struct region * r, const struct faction * f);
void report_region(struct stream *out, const struct region * r, struct faction * f); void report_region(struct stream *out, const struct region * r, struct faction * f);
void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); void nr_spell_syntax(char *buf, size_t size, struct spellbook_entry * sbe, const struct locale *lang);
void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -228,32 +228,11 @@ static void set_parameter(spell_fixture spell, char *value) {
} }
static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) { static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) {
stream strm;
char buf[1024]; char buf[1024];
char *linestart, *newline;
size_t len;
mstream_init(&strm); nr_spell_syntax(buf, sizeof(buf), spell->sbe, spell->lang);
nr_spell_syntax(&strm, spell->sbe, spell->lang);
strm.api->rewind(strm.handle);
len = strm.api->read(strm.handle, buf, sizeof(buf));
buf[len] = '\0';
linestart = strtok(buf, "\n"); CuAssertStrEquals_Msg(tc, msg, syntax, buf);
while (linestart && !strstr(linestart, "ZAUBERE"))
linestart = strtok(NULL, "\n");
CuAssertPtrNotNull(tc, linestart);
newline = strtok(NULL, "\n");
while (newline) {
*(newline - 1) = '\n';
newline = strtok(NULL, "\n");
}
CuAssertStrEquals_Msg(tc, msg, syntax, linestart);
mstream_done(&strm);
} }
static void test_write_spell_syntax(CuTest *tc) { static void test_write_spell_syntax(CuTest *tc) {
@ -262,54 +241,54 @@ static void test_write_spell_syntax(CuTest *tc) {
test_setup(); test_setup();
setup_spell_fixture(&spell); setup_spell_fixture(&spell);
check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\""); check_spell_syntax(tc, "vanilla", &spell, "ZAUBERE Testzauber");
spell.sp->sptyp |= FARCASTING; spell.sp->sptyp |= FARCASTING;
check_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\""); check_spell_syntax(tc, "far", &spell, "ZAUBERE [REGION x y] Testzauber");
spell.sp->sptyp |= SPELLLEVEL; spell.sp->sptyp |= SPELLLEVEL;
check_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\""); check_spell_syntax(tc, "farlevel", &spell, "ZAUBERE [REGION x y] [STUFE n] Testzauber");
spell.sp->sptyp = 0; spell.sp->sptyp = 0;
set_parameter(spell, "kc"); set_parameter(spell, "kc");
check_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT <enr> | SCHIFF <snr> | BURG <bnr> )"); check_spell_syntax(tc, "kc", &spell, "ZAUBERE Testzauber ( REGION | EINHEIT <enr> | SCHIFF <snr> | BURG <bnr> )");
spell.sp->sptyp |= BUILDINGSPELL; spell.sp->sptyp |= BUILDINGSPELL;
check_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG <bnr>"); check_spell_syntax(tc, "kc typed", &spell, "ZAUBERE Testzauber BURG <bnr>");
spell.sp->sptyp = 0; spell.sp->sptyp = 0;
set_parameter(spell, "b"); set_parameter(spell, "b");
check_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" <bnr>"); check_spell_syntax(tc, "b", &spell, "ZAUBERE Testzauber <bnr>");
set_parameter(spell, "s"); set_parameter(spell, "s");
check_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" <snr>"); check_spell_syntax(tc, "s", &spell, "ZAUBERE Testzauber <snr>");
set_parameter(spell, "s+"); set_parameter(spell, "s+");
check_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" <snr> [<snr> ...]"); check_spell_syntax(tc, "s+", &spell, "ZAUBERE Testzauber <snr> [<snr> ...]");
set_parameter(spell, "u"); set_parameter(spell, "u");
check_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" <enr>"); check_spell_syntax(tc, "u", &spell, "ZAUBERE Testzauber <enr>");
set_parameter(spell, "r"); set_parameter(spell, "r");
check_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" <x> <y>"); check_spell_syntax(tc, "r", &spell, "ZAUBERE Testzauber <x> <y>");
set_parameter(spell, "bc"); set_parameter(spell, "bc");
free(spell.sp->syntax); free(spell.sp->syntax);
spell.sp->syntax = str_strdup("hodor"); spell.sp->syntax = str_strdup("hodor");
check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" <bnr> <Hodor>"); check_spell_syntax(tc, "bc hodor", &spell, "ZAUBERE Testzauber <bnr> <Hodor>");
free(spell.sp->syntax); free(spell.sp->syntax);
spell.sp->syntax = 0; spell.sp->syntax = 0;
set_parameter(spell, "c?"); set_parameter(spell, "c?");
free(spell.sp->syntax); free(spell.sp->syntax);
spell.sp->syntax = str_strdup("hodor"); spell.sp->syntax = str_strdup("hodor");
check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" [<Hodor>]"); check_spell_syntax(tc, "c?", &spell, "ZAUBERE Testzauber [<Hodor>]");
free(spell.sp->syntax); free(spell.sp->syntax);
spell.sp->syntax = 0; spell.sp->syntax = 0;
set_parameter(spell, "kc+"); set_parameter(spell, "kc+");
check_spell_syntax(tc, "kc+", &spell, check_spell_syntax(tc, "kc+", &spell,
" ZAUBERE \"Testzauber\" ( REGION | EINHEIT <enr> [<enr> ...] | SCHIFF <snr>\n [<snr> ...] | BURG <bnr> [<bnr> ...] )"); "ZAUBERE Testzauber ( REGION | EINHEIT <enr> [<enr> ...] | SCHIFF <snr> [<snr> ...] | BURG <bnr> [<bnr> ...] )");
cleanup_spell_fixture(&spell); cleanup_spell_fixture(&spell);
test_teardown(); test_teardown();

View File

@ -2193,10 +2193,12 @@ void report_battle_start(battle * b)
} }
} }
} }
if (first && lastf) { if (lastf) {
sbs_strcat(&sbs, " "); if (first) {
sbs_strcat(&sbs, LOC(f->locale, "and")); sbs_strcat(&sbs, " ");
sbs_strcat(&sbs, " "); sbs_strcat(&sbs, LOC(f->locale, "and"));
sbs_strcat(&sbs, " ");
}
sbs_strcat(&sbs, lastf); sbs_strcat(&sbs, lastf);
} }

@ -1 +1 @@
Subproject commit 5623ee6527e97af20c7d8efc03800b6fe1579744 Subproject commit 0ef4b39e39d8146d6ca323500a285c53843db988