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

This commit is contained in:
Enno Rehling 2018-07-21 05:38:56 +02:00
commit 85167983af
24 changed files with 420 additions and 236 deletions

View File

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

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

View File

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

View File

@ -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'] = {

View File

@ -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')

View File

@ -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%)"))

View File

@ -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;

View File

@ -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);

View File

@ -1,6 +1,8 @@
#include <platform.h>
#include "battle.h"
#include "reports.h"
#include "skill.h"
#include <kernel/config.h>
@ -16,6 +18,8 @@
#include <spells/buildingcurse.h>
#include <util/functions.h>
#include <util/language.h>
#include <util/message.h>
#include <util/rand.h>
#include <util/rng.h>
#include <util/strings.h>
@ -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);

View File

@ -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;
}

View File

@ -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<73>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;

View File

@ -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);
}

View File

@ -19,72 +19,94 @@ attrib_type at_lighthouse = {
/* Rest ist NULL; tempor<6F>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
* 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)
{
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);
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;
}
}
}
}
}
int lighthouse_range(const building * b, const faction * f, const unit *u)
{
if (fval(b, BLD_MAINTAINED) && b->size >= 10) {
int maxd = (int)log10(b->size) + 1;
void remove_lighthouse(const building *lh) {
building *b;
region * r = lh->region;
if (u && skill_enabled(SK_PERCEPTION)) {
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)
{
if (b->size >= 10 && (b->flags & BLD_MAINTAINED)) {
return (int)log10(b->size) + 1;
}
return 0;
}
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;
}
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 +114,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;
}
}

View File

@ -29,15 +29,18 @@ 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);
int lighthouse_range(const struct building *b, const struct faction *f,
const struct unit *u);
void remove_lighthouse(const struct building *lh);
int lighthouse_range(const struct building *b);
int lighthouse_view_distance(const struct building *b, const struct unit *u);
#ifdef __cplusplus

View File

@ -26,35 +26,39 @@ 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();
}
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 +68,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 +95,39 @@ 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));
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));
b->size = 1; /* size can go down in destroy_cmd */
CuAssertIntEquals(tc, false, lighthouse_guarded(r2));
CuAssertIntEquals(tc, false, lighthouse_guarded(r3));
test_teardown();
}
@ -96,5 +136,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;
}

View File

@ -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)) {

View File

@ -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 {

View File

@ -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,8 +1595,8 @@ 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 */
int lhr = lighthouse_range(b, NULL, NULL);
/* region owners get maximum range */
int lhr = lighthouse_view_distance(b, NULL);
if (lhr > range) range = lhr;
}
}
@ -1610,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;
}
}
@ -1630,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(u->building, f, u);
}
if (br > range) {
range = br;
br = lighthouse_view_distance(b, u);
if (br > range) {
range = br;
}
}
}
}
@ -2193,10 +2196,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);
}

View File

@ -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;
@ -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();
}
@ -595,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);

@ -1 +1 @@
Subproject commit 6eea7695285f9c9f1d25421897ca55f466ef7566
Subproject commit 0ef4b39e39d8146d6ca323500a285c53843db988

View File

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

View File

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