From 062abe81026a6afd03950980764dda45184eb023 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Sep 2018 17:10:18 +0200 Subject: [PATCH 01/11] refactor siege property w. getter/setter --- src/battle.c | 6 ++---- src/creport.c | 8 ++++++-- src/economy.c | 2 ++ src/kernel/building.c | 11 +++++++++++ src/kernel/building.h | 5 ++++- src/kernel/unit.c | 8 +++++--- src/laws.c | 9 +++++++-- src/laws.test.c | 3 ++- src/report.c | 16 +++++++++------- src/settings.h | 12 ------------ src/study.h | 1 + src/wormhole.c | 1 - 12 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/battle.c b/src/battle.c index 9e2f841c0..3f61269a0 100644 --- a/src/battle.c +++ b/src/battle.c @@ -100,9 +100,7 @@ typedef enum combatmagic { #define MINSPELLRANGE 1 #define MAXSPELLRANGE 7 -#ifndef ROW_FACTOR -# define ROW_FACTOR 10 -#endif +#define ROW_FACTOR 3 /* factor for combat row advancement rule */ #define EFFECT_PANIC_SPELL 0.25 #define TROLL_REGENERATION 0.10 @@ -161,7 +159,7 @@ static void init_rules(void) skill_formula = config_get_int("rules.combat.skill_formula", FORMULA_ORIG); /* maximum number of combat turns */ - max_turns = config_get_int("rules.combat.turns", COMBAT_TURNS); + max_turns = config_get_int("rules.combat.turns", 5); /* damage calculation */ if (config_get_int("rules.combat.critical", 1)) { rule_damage |= DAMAGE_CRITICAL; diff --git a/src/creport.c b/src/creport.c index 91d56ca3b..137259083 100644 --- a/src/creport.c +++ b/src/creport.c @@ -645,6 +645,7 @@ static void cr_output_building(struct stream *out, building *b, const unit *owner, int fno, faction *f) { const char *bname, *billusion; + int i; stream_printf(out, "BURG %d\n", b->no); @@ -673,9 +674,12 @@ static void cr_output_building(struct stream *out, building *b, if (fno >= 0) { stream_printf(out, "%d;Partei\n", fno); } - if (b->besieged) { - stream_printf(out, "%d;Belagerer\n", b->besieged); + + i = building_get_siege(b); + if (i) { + stream_printf(out, "%d;Belagerer\n", i); } + cr_output_curses(out, f, b, TYP_BUILDING); } diff --git a/src/economy.c b/src/economy.c index baba6c1ac..cc611d49d 100644 --- a/src/economy.c +++ b/src/economy.c @@ -103,6 +103,8 @@ static void recruit_init(void) } } +#define ENTERTAINFRACTION 20 + int entertainmoney(const region * r) { double n; diff --git a/src/kernel/building.c b/src/kernel/building.c index 75cad30f7..9dfc7db35 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -870,3 +870,14 @@ int cmp_current_owner(const building * b, const building * a) } return 0; } + +int building_get_siege(const struct building *b) +{ + return b->_besieged; +} + +int building_add_siege(struct building *b, int delta) +{ + b->_besieged += delta; + return b->_besieged; +} diff --git a/src/kernel/building.h b/src/kernel/building.h index eacf42942..319304d79 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -118,7 +118,7 @@ extern "C" { int no; int size; int sizeleft; /* is only used during battle. should be a temporary attribute */ - int besieged; /* should be an attribute */ + int _besieged; /* should be an attribute */ int flags; } building; @@ -134,6 +134,9 @@ extern "C" { int id, int size, struct order *ord); bool building_finished(const struct building *b); + int building_get_siege(const struct building *b); + int building_add_siege(struct building *b, int delta); + int wage(const struct region *r, const struct faction *f, const struct race *rc, int in_turn); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 770723bea..146761f05 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1917,9 +1917,11 @@ int getunit(const region * r, const faction * f, unit **uresult) int besieged(const unit * u) { /* belagert kann man in schiffen und burgen werden */ - return (u && !keyword_disabled(K_BESIEGE) - && u->building && u->building->besieged - && u->building->besieged >= u->building->size * SIEGEFACTOR); + if (u && !keyword_disabled(K_BESIEGE) && u->building) { + building * b = u->building; + return building_get_siege(b) >= b->size * SIEGEFACTOR; + } + return false; } bool has_horses(const unit * u) diff --git a/src/laws.c b/src/laws.c index 68f2894b3..67a44c673 100644 --- a/src/laws.c +++ b/src/laws.c @@ -306,6 +306,11 @@ static void calculate_emigration(region * r) } } +/* Vermehrungsrate Bauern in 1/10000. +* TODO: Evt. Berechnungsfehler, reale Vermehrungsraten scheinen hoeher. */ +#define PEASANTGROWTH 10 +#define PEASANTLUCK 10 +#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */ static double peasant_growth_factor(void) { @@ -908,7 +913,7 @@ static int slipthru(const region * r, const unit * u, const building * b) int n, o; /* b ist die burg, in die man hinein oder aus der man heraus will. */ - if (b == NULL || b->besieged < b->size * SIEGEFACTOR) { + if (b == NULL || building_get_siege(b) < b->size * SIEGEFACTOR) { return 1; } @@ -3857,7 +3862,7 @@ int siege_cmd(unit * u, order * ord) usetsiege(u, b); if (katapultiere < bewaffnete) katapultiere = bewaffnete; - b->besieged += katapultiere; + building_add_siege(b, katapultiere); /* definitiver schaden eingeschraenkt */ if (d > b->size - 1) d = b->size - 1; diff --git a/src/laws.test.c b/src/laws.test.c index c7c7a6682..fb644dc90 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -113,7 +113,8 @@ static void test_contact(CuTest * tc) u3 = test_create_unit(test_create_faction(NULL), r); set_level(u3, SK_PERCEPTION, 2); usetsiege(u3, b); - b->besieged = 1; + building_add_siege(b, 1); + CuAssertIntEquals(tc, 1, building_get_siege(b)); CuAssertIntEquals(tc, 1, can_contact(r, u1, u2)); u_set_building(u1, b); diff --git a/src/report.c b/src/report.c index 9f1bfa4bd..7de2550a4 100644 --- a/src/report.c +++ b/src/report.c @@ -1853,14 +1853,16 @@ nr_building(struct stream *out, const region *r, const building *b, const factio sbs_strcat(&sbs, LOC(lang, "nr_building_inprogress")); } - if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) { - msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, - b->besieged - b->size * SIEGEFACTOR); + if (!keyword_disabled(K_BESIEGE) && r->seen.mode >= seen_lighthouse) { + int s = building_get_siege(b); + if (s > 0) { + msg = msg_message("nr_building_besieged", "soldiers diff", s, + s - b->size * SIEGEFACTOR); + size = nr_render(msg, lang, sbs.end, sbs.size - (sbs.end - sbs.begin), f); + sbs.end += size; - size = nr_render(msg, lang, sbs.end, sbs.size - (sbs.end - sbs.begin), f); - sbs.end += size; - - msg_release(msg); + msg_release(msg); + } } i = 0; if (b->display && b->display[0]) { diff --git a/src/settings.h b/src/settings.h index 57edb1566..498786be9 100644 --- a/src/settings.h +++ b/src/settings.h @@ -10,23 +10,11 @@ without prior permission by the authors of Eressea. */ -#define ENTERTAINFRACTION 20 -#define TEACHDIFFERENCE 2 #define RESOURCE_QUANTITY 0.5 #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ -#define COMBAT_TURNS 5 -#undef NEWATSROI - -/* Vermehrungsrate Bauern in 1/10000. -* TODO: Evt. Berechnungsfehler, reale Vermehrungsraten scheinen hoeher. */ -#define PEASANTGROWTH 10 -#define PEASANTLUCK 10 - -#define ROW_FACTOR 3 /* factor for combat row advancement rule */ /* TODO: move these settings to settings.h or into configuration files */ #define TREESIZE (8) /* space used by trees (in #peasants) */ -#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */ /* Gebaeudegroesse = Minimalbelagerer */ #define SIEGEFACTOR 2 diff --git a/src/study.h b/src/study.h index cca0428b7..686677064 100644 --- a/src/study.h +++ b/src/study.h @@ -31,6 +31,7 @@ extern "C" { #define STUDYDAYS 30 #define TEACHNUMBER 10 +#define TEACHDIFFERENCE 2 typedef struct teaching_info { struct selist *teachers; diff --git a/src/wormhole.c b/src/wormhole.c index 197fc346d..2000018ab 100644 --- a/src/wormhole.c +++ b/src/wormhole.c @@ -12,7 +12,6 @@ #include #include -#include "settings.h" #include "wormhole.h" From 2e5e8347aca8b3643139dc3d6a1ad2e16d2fcdd1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Sep 2018 21:01:10 +0200 Subject: [PATCH 02/11] Bug 2489: Kill the SIEGE command, forever. --- conf/e3/config.json | 1 - conf/keywords.json | 1 - res/core/messages.xml | 55 ---------- res/translations/messages.de.po | 24 ----- res/translations/messages.en.po | 24 ----- res/translations/strings.de.po | 4 - res/translations/strings.en.po | 4 - scripts/tests/bindings.lua | 1 - src/attributes/attributes.c | 9 +- src/battle.c | 11 -- src/bind_process.c | 4 - src/creport.c | 10 -- src/economy.c | 33 ------ src/guard.c | 2 - src/jsonconf.test.c | 6 +- src/kernel/build.c | 13 --- src/kernel/building.c | 11 -- src/kernel/building.h | 4 - src/kernel/order.c | 3 - src/kernel/unit.c | 64 ------------ src/kernel/unit.h | 5 - src/keyword.c | 2 +- src/keyword.h | 2 +- src/laws.c | 177 +------------------------------- src/laws.h | 2 - src/laws.test.c | 33 ------ src/process.pkg | 1 - src/process.pkg.c | 25 ----- src/report.c | 12 --- src/reports.c | 6 -- src/spy.c | 4 - src/spy.test.c | 6 +- src/steal.c | 4 - 33 files changed, 16 insertions(+), 547 deletions(-) diff --git a/conf/e3/config.json b/conf/e3/config.json index b4b6d0e48..dcc3e9f53 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -28,7 +28,6 @@ "stealth", "taxation", "trade", - "besiege", "steal", "buy", "teach", diff --git a/conf/keywords.json b/conf/keywords.json index 4f8f27f5b..11376ea95 100644 --- a/conf/keywords.json +++ b/conf/keywords.json @@ -12,7 +12,6 @@ "work": [ "ARBEITE", "ARBEITEN" ], "attack": ["ATTACKIERE", "ATTACKIEREN"], "steal": [ "BEKLAUE", "BEKLAUEN" ], - "besiege": ["BELAGERE", "BELAGERN" ], "name": [ "BENENNE", "BENENNEN" ], "use": [ "BENUTZE", "BENUTZEN" ], "describe": [ "BESCHREIBE", "BESCHREIBEN" ], diff --git a/res/core/messages.xml b/res/core/messages.xml index 1e4e977e0..d2c40f9b3 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -710,12 +710,6 @@ - - - - - - @@ -2684,19 +2678,6 @@ - - - - - - - - - - - - - @@ -3351,14 +3332,6 @@ - - - - - - - - @@ -3890,13 +3863,6 @@ - - - - - - - @@ -4002,13 +3968,6 @@ - - - - - - - @@ -4993,20 +4952,6 @@ - - - - - - - - - - - - - - diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 507f0e39d..76ff0afc9 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -257,9 +257,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Hier kann man k msgid "error165" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Trank bekommt der Einheit nicht.\"" -msgid "siege_catapults" -msgstr "\"$unit($unit) belagert $building($building). Dabei richten die Katapulte Zerstörungen von $int($destruction) Größenpunkten an.\"" - msgid "curseinfo::magicstreet" msgstr "\"Die Straßen sind erstaunlich trocken und gut begehbar. ($int36($id))\"" @@ -638,9 +635,6 @@ msgstr "\"$unit($unit) erscheint plötzlich.\"" msgid "magicresistance_effect" msgstr "\"$unit($unit) wird kurz von einem magischen Licht umhüllt.\"" -msgid "siege" -msgstr "\"$unit($unit) belagert $building($building).\"" - msgid "missing_force" msgstr "\"$unit($unit) schafft es nicht, genug Kraft aufzubringen, um $spell($spell) auf Stufe $int($level) zu zaubern.\"" @@ -977,9 +971,6 @@ msgstr "\"$unit($mage) kümmert sich um die Verletzten und benutzt ein $resource msgid "error276" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Hier kann man keine Schiffe bauen.\"" -msgid "error166" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diese Rasse kann eine Burg nicht belagern.\"" - msgid "chaosgate_effect_2" msgstr "\"Ein Wirbel aus blendendem Licht erscheint.\"" @@ -998,9 +989,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist msgid "error82" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Es gibt keine Abstimmung mit dieser Nummer.\"" -msgid "error60" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit wird belagert.\"" - msgid "error162" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Heiltrank wird automatisch bei Bedarf benutzt.\"" @@ -1457,9 +1445,6 @@ msgstr "\"$unit($unit) öffnet eines der Schlösser in $region($region) mit $if( msgid "error255" msgstr "\"$unit($unit) in $region($region): '$order($command)' - So etwas kann man nicht opfern.\"" -msgid "entrance_besieged" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - $building($building) wird belagert.\"" - msgid "error260" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Besitzer eines Schiffes oder Gebäudes kann nicht neu sortiert werden.\"" @@ -1550,9 +1535,6 @@ msgstr "\"In $region($region) findet ein Kampf statt.\"" msgid "wormhole_dissolve" msgstr "\"Das Wurmloch in $region($region) schließt sich.\"" -msgid "error23" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Belagerungszustand macht die Kontaktaufnahme unmöglich.\"" - msgid "error12" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff gehört uns nicht.\"" @@ -2135,9 +2117,6 @@ msgstr "\"Seit $int($age) Wochen Mitglied der Allianz '$name ($int36($id))', ang msgid "deathcloud_effect" msgstr "\"$unit($mage) beschwört einen Giftelementar in $region($region).\"" -msgid "nr_building_besieged" -msgstr "\", belagert von $int($soldiers) Personen$if($lt($diff,0),\"\",\" (abgeschnitten)\")\"" - msgid "nr_population" msgstr "\"Deine Partei hat $int($population) Personen in $int($units) von maximal $int($limit) Einheiten.\"" @@ -2414,9 +2393,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff hat msgid "aborted_battle" msgstr "\"Der Kampf wurde abgebrochen, da alle Verteidiger flohen.\"" -msgid "error24" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Belagerungszustand macht Spionage unmöglich.\"" - msgid "usecatapult" msgstr "\"$int($amount) Krieger von $unit($unit) feuern ihre Katapulte ab.\"" diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index bf9d8e3c9..50108fc03 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -257,9 +257,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Buildings canno msgid "error165" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The potion does not agree with the unit.\"" -msgid "siege_catapults" -msgstr "\"$building($building) is under siege by $unit($unit). During siege, catapults caused $int($destruction) points destruction.\"" - msgid "curseinfo::magicstreet" msgstr "\"The roads are extremely dry and well-kept. ($int36($id))\"" @@ -638,9 +635,6 @@ msgstr "\"$unit($unit) appears.\"" msgid "magicresistance_effect" msgstr "\"$unit($unit) is briefly surrounded by a magical light.\"" -msgid "siege" -msgstr "\"$building($building) is under siege by $unit($unit).\"" - msgid "missing_force" msgstr "\"$unit($unit) cannot muster enough energy to cast $spell($spell) on level $int($level).\"" @@ -977,9 +971,6 @@ msgstr "\"$unit($mage) sees after the wounded and heals $int($amount). A $resour msgid "error276" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Ships cannot be built here.\"" -msgid "error166" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - This race cannot besiege a castle.\"" - msgid "chaosgate_effect_2" msgstr "\"A vortex of blinding light appears.\"" @@ -998,9 +989,6 @@ msgstr "\"'$order($command)' - $unit($unit) marched into $region($region) during msgid "error82" msgstr "\"$unit($unit) in $region($region): '$order($command)' - There is no agreement with this number.\"" -msgid "error60" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is under siege.\"" - msgid "error162" msgstr "\"$unit($unit) in $region($region): '$order($command)' - This healing potion will be automatically used when needed.\"" @@ -1457,9 +1445,6 @@ msgstr "\"$unit($unit) unlocks one of the locks in $region($region) with $if($eq msgid "error255" msgstr "\"$unit($unit) in $region($region): '$order($command)' - You cannot sacrifice this.\"" -msgid "entrance_besieged" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - $building($building) is under siege.\"" - msgid "error260" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The owner of a ship or a building cannot be sorted.\"" @@ -1550,9 +1535,6 @@ msgstr "\"There is a battle in $region($region).\"" msgid "wormhole_dissolve" msgstr "\"The wormhole in $region($region) disappears.\"" -msgid "error23" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Contact was not possible due to siege.\"" - msgid "error12" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship is not ours.\"" @@ -2135,9 +2117,6 @@ msgstr "\"Member of '$name ($int36($id))' for $int($age) weeks, led by $faction( msgid "deathcloud_effect" msgstr "\"$unit($mage) summons a poison elemental in $region($region).\"" -msgid "nr_building_besieged" -msgstr "\", besieged by $int($soldiers) soldiers$if($lt($diff,0),\"\",\" (cut off)\")\"" - msgid "nr_population" msgstr "\"Your faction has $int($population) people in $int($units) of $int($limit) possible units.\"" @@ -2414,9 +2393,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship has mo msgid "aborted_battle" msgstr "\"The battle was aborted because all enemies escaped.\"" -msgid "error24" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Espionage was not possible due to siege.\"" - msgid "usecatapult" msgstr "\"$int($amount) fighters of $unit($unit) launch their catapults.\"" diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index f4b166221..47d70ecc0 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -2772,10 +2772,6 @@ msgstr "Dieser wunderschoen geschmueckte Baum entfaltet in den Wintermonaten ein msgid "h10" msgstr "Kakteenschwitz" -msgctxt "keyword" -msgid "besiege" -msgstr "BELAGERE" - msgid "h11" msgstr "Sandfäule" diff --git a/res/translations/strings.en.po b/res/translations/strings.en.po index 32924310c..8a5dcb30f 100644 --- a/res/translations/strings.en.po +++ b/res/translations/strings.en.po @@ -2421,10 +2421,6 @@ msgctxt "iteminfo" msgid "xmastree" msgstr "In the winter months, this beautifully decorated tree has a magical effect on the entire forest." -msgctxt "keyword" -msgid "besiege" -msgstr "BESIEGE" - msgid "h10" msgstr "peyote" diff --git a/scripts/tests/bindings.lua b/scripts/tests/bindings.lua index 9aab6fd57..5820e0a47 100644 --- a/scripts/tests/bindings.lua +++ b/scripts/tests/bindings.lua @@ -31,7 +31,6 @@ function test_process() assert_equal("function", _G.type(eressea.process.movement)) assert_equal("function", _G.type(eressea.process.use)) assert_equal("function", _G.type(eressea.process.battle)) - assert_equal("function", _G.type(eressea.process.siege)) assert_equal("function", _G.type(eressea.process.leave)) assert_equal("function", _G.type(eressea.process.promote)) assert_equal("function", _G.type(eressea.process.restack)) diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index fa6f15d73..6bf78da63 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -182,13 +182,13 @@ void register_attributes(void) at_register(&at_seenspell); at_register(&at_seenspells); - /* neue REGION-Attribute */ + /* REGION Attribute */ at_register(&at_moveblock); at_register(&at_deathcount); at_register(&at_woodcount); + at_register(&at_germs); - /* neue UNIT-Attribute */ - at_register(&at_siege); + /* UNIT Attribute */ at_register(&at_effect); at_register(&at_private); @@ -205,8 +205,7 @@ void register_attributes(void) register_bordertype(&bt_illusionwall); register_bordertype(&bt_road); - at_register(&at_germs); - + at_deprecate("siege", a_readint); at_deprecate("maxmagicians", a_readint); /* factions with differnt magician limits, probably unused */ at_deprecate("hurting", a_readint); /* an old arena attribute */ at_deprecate("chaoscount", a_readint); /* used to increase the chance of monster spawns */ diff --git a/src/battle.c b/src/battle.c index 3f61269a0..1e256f9ca 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3577,17 +3577,6 @@ static void join_allies(battle * b) } if (se == s_end) continue; - /* Wenn die Einheit belagert ist, mu� auch einer der Alliierten belagert sein: */ - if (besieged(u)) { - fighter *ally; - for (ally = s->fighters; ally; ally = ally->next) { - if (besieged(ally->unit)) { - break; - } - } - if (ally == NULL) - continue; - } /* keine Einw�nde, also soll er mitmachen: */ if (c == NULL) { if (!join_battle(b, u, false, &c)) { diff --git a/src/bind_process.c b/src/bind_process.c index 947458ce5..58f90076f 100755 --- a/src/bind_process.c +++ b/src/bind_process.c @@ -76,10 +76,6 @@ void process_battle(void) { do_battles(); } -void process_siege(void) { - process_cmd(K_BESIEGE, siege_cmd, PROC_LAND_REGION); -} - void process_update_long_order(void) { region * r; for (r = regions; r; r = r->next) { diff --git a/src/creport.c b/src/creport.c index 137259083..ce67493da 100644 --- a/src/creport.c +++ b/src/creport.c @@ -645,7 +645,6 @@ static void cr_output_building(struct stream *out, building *b, const unit *owner, int fno, faction *f) { const char *bname, *billusion; - int i; stream_printf(out, "BURG %d\n", b->no); @@ -675,11 +674,6 @@ static void cr_output_building(struct stream *out, building *b, stream_printf(out, "%d;Partei\n", fno); } - i = building_get_siege(b); - if (i) { - stream_printf(out, "%d;Belagerer\n", i); - } - cr_output_curses(out, f, b, TYP_BUILDING); } @@ -784,7 +778,6 @@ void cr_output_unit(stream *out, const faction * f, const item_type *lasttype; int pr; item *itm, *show = NULL; - building *b; const char *pzTmp; skill *sv; item result[MAX_INVENTORY]; @@ -883,9 +876,6 @@ void cr_output_unit(stream *out, const faction * f, if (is_guard(u)) { stream_printf(out, "%d;bewacht\n", 1); } - if ((b = usiege(u)) != NULL) { - stream_printf(out, "%d;belagert\n", b->no); - } /* additional information for own units */ if (u->faction == f || omniscient(f)) { order *ord; diff --git a/src/economy.c b/src/economy.c index cc611d49d..f0c930a3f 100644 --- a/src/economy.c +++ b/src/economy.c @@ -980,11 +980,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) } } - if (besieged(u)) { - cmistake(u, u->thisorder, 60, MSG_PRODUCE); - return; - } - if (rtype->modifiers) { message *msg = get_modifiers(u, sk, rtype, &save_mod, &skill_mod); if (msg) { @@ -1606,11 +1601,6 @@ static void buy(unit * u, econ_request ** buyorders, struct order *ord) cmistake(u, ord, 26, MSG_COMMERCE); return; } - if (besieged(u)) { - /* Belagerte Einheiten k�nnen nichts kaufen. */ - cmistake(u, ord, 60, MSG_COMMERCE); - return; - } /* Entweder man ist Insekt in Sumpf/Wueste, oder es muss * einen Handelsposten in der Region geben: */ @@ -1930,12 +1920,6 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord) return false; } } - /* Belagerte Einheiten k�nnen nichts verkaufen. */ - - if (besieged(u)) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error60", "")); - return false; - } /* In der Region mu� es eine Burg geben. */ if (u_race(u) == get_race(RC_INSECT)) { @@ -2409,10 +2393,6 @@ void entertain_cmd(unit * u, struct order *ord) cmistake(u, ord, 58, MSG_INCOME); return; } - if (besieged(u)) { - cmistake(u, ord, 60, MSG_INCOME); - return; - } if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; @@ -2501,11 +2481,6 @@ static int do_work(unit * u, order * ord, econ_request * o) cmistake(u, ord, 313, MSG_INCOME); return -1; } - if (besieged(u)) { - if (ord) - cmistake(u, ord, 60, MSG_INCOME); - return -1; - } if (u->ship && is_guarded(r, u)) { if (ord) cmistake(u, ord, 69, MSG_INCOME); @@ -2614,10 +2589,6 @@ void tax_cmd(unit * u, struct order *ord, econ_request ** taxorders) return; } - if (besieged(u)) { - cmistake(u, ord, 60, MSG_INCOME); - return; - } n = armedmen(u, false); if (!n) { @@ -2688,10 +2659,6 @@ void loot_cmd(unit * u, struct order *ord, econ_request ** lootorders) return; } - if (besieged(u)) { - cmistake(u, ord, 60, MSG_INCOME); - return; - } n = armedmen(u, false); if (!n) { diff --git a/src/guard.c b/src/guard.c index 118ede5fc..468dd99bc 100644 --- a/src/guard.c +++ b/src/guard.c @@ -105,8 +105,6 @@ static bool is_guardian_r(const unit * guard) { if (guard->number == 0) return false; - if (besieged(guard)) - return false; /* if region_owners exist then they may be guardians: */ if (guard->building && rule_region_owners() && guard == building_owner(guard->building)) { diff --git a/src/jsonconf.test.c b/src/jsonconf.test.c index 7c15b63f1..9e0e8f6b6 100644 --- a/src/jsonconf.test.c +++ b/src/jsonconf.test.c @@ -120,7 +120,7 @@ static void test_disable(CuTest * tc) const char * data = "{\"disabled\": [ " "\"alchemy\"," "\"pay\"," - "\"besiege\"," + "\"attack\"," "\"module\"" "]}"; cJSON *json = cJSON_Parse(data); @@ -129,13 +129,13 @@ static void test_disable(CuTest * tc) CuAssertTrue(tc, skill_enabled(SK_ALCHEMY)); CuAssertTrue(tc, !keyword_disabled(K_BANNER)); CuAssertTrue(tc, !keyword_disabled(K_PAY)); - CuAssertTrue(tc, !keyword_disabled(K_BESIEGE)); + CuAssertTrue(tc, !keyword_disabled(K_ATTACK)); CuAssertIntEquals(tc, 1, config_get_int("module.enabled", 1)); json_config(json); CuAssertTrue(tc, !skill_enabled(SK_ALCHEMY)); CuAssertTrue(tc, !keyword_disabled(K_BANNER)); CuAssertTrue(tc, keyword_disabled(K_PAY)); - CuAssertTrue(tc, keyword_disabled(K_BESIEGE)); + CuAssertTrue(tc, keyword_disabled(K_ATTACK)); CuAssertIntEquals(tc, 0, config_get_int("module.enabled", 1)); cJSON_Delete(json); test_teardown(); diff --git a/src/kernel/build.c b/src/kernel/build.c index 11324f752..4e3dc4721 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -279,10 +279,6 @@ void build_road(unit * u, int size, direction_t d) cmistake(u, u->thisorder, 103, MSG_PRODUCE); return; } - if (besieged(u)) { - cmistake(u, u->thisorder, 60, MSG_PRODUCE); - return; - } if (rn == NULL || rn->terrain->max_road < 0) { cmistake(u, u->thisorder, 94, MSG_PRODUCE); @@ -780,11 +776,6 @@ build_building(unit * u, const building_type * btype, int id, int want, order * cmistake(u, ord, 93, MSG_PRODUCE); return 0; } - if (besieged(u)) { - /* units under siege can not build */ - cmistake(u, ord, 60, MSG_PRODUCE); - return 0; - } if (btype->flags & BTF_NOBUILD) { /* special building, cannot be built */ cmistake(u, ord, 221, MSG_PRODUCE); @@ -949,10 +940,6 @@ create_ship(unit * u, const struct ship_type *newtype, int want, cmistake(u, ord, 100, MSG_PRODUCE); return; } - if (besieged(u)) { - cmistake(u, ord, 60, MSG_PRODUCE); - return; - } /* check if skill and material for 1 size is available */ if (effskill(u, cons->skill, 0) < cons->minskill) { diff --git a/src/kernel/building.c b/src/kernel/building.c index 9dfc7db35..75cad30f7 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -870,14 +870,3 @@ int cmp_current_owner(const building * b, const building * a) } return 0; } - -int building_get_siege(const struct building *b) -{ - return b->_besieged; -} - -int building_add_siege(struct building *b, int delta) -{ - b->_besieged += delta; - return b->_besieged; -} diff --git a/src/kernel/building.h b/src/kernel/building.h index 319304d79..af605b448 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -118,7 +118,6 @@ extern "C" { int no; int size; int sizeleft; /* is only used during battle. should be a temporary attribute */ - int _besieged; /* should be an attribute */ int flags; } building; @@ -134,9 +133,6 @@ extern "C" { int id, int size, struct order *ord); bool building_finished(const struct building *b); - int building_get_siege(const struct building *b); - int building_add_siege(struct building *b, int delta); - int wage(const struct region *r, const struct faction *f, const struct race *rc, int in_turn); diff --git a/src/kernel/order.c b/src/kernel/order.c index c14a2b30b..2fd7c6eb8 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -373,7 +373,6 @@ bool is_repeated(keyword_t kwd) case K_ROUTE: case K_DRIVE: case K_WORK: - case K_BESIEGE: case K_ENTERTAIN: case K_TAX: case K_RESEARCH: @@ -414,7 +413,6 @@ bool is_exclusive(const order * ord) case K_ROUTE: case K_DRIVE: case K_WORK: - case K_BESIEGE: case K_ENTERTAIN: case K_TAX: case K_RESEARCH: @@ -456,7 +454,6 @@ bool is_long(keyword_t kwd) case K_ROUTE: case K_DRIVE: case K_WORK: - case K_BESIEGE: case K_ENTERTAIN: case K_TAX: case K_RESEARCH: diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 146761f05..30971310d 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -530,60 +530,6 @@ attrib_type at_target = { NO_READ }; -/*********************/ -/* at_siege */ -/*********************/ - -void a_writesiege(const variant *var, const void *owner, struct storage *store) -{ - struct building *b = (struct building *)var->v; - write_building_reference(b, store); -} - -int a_readsiege(variant *var, void *owner, gamedata *data) -{ - if (read_building_reference(data, (building **)&var->v, NULL) <= 0) { - return AT_READ_FAIL; - } - return AT_READ_OK; -} - -attrib_type at_siege = { - "siege", - DEFAULT_INIT, - DEFAULT_FINALIZE, - DEFAULT_AGE, - a_writesiege, - a_readsiege -}; - -struct building *usiege(const unit * u) -{ - attrib *a; - if (!fval(u, UFL_SIEGE)) - return NULL; - a = a_find(u->attribs, &at_siege); - assert(a || !"flag set, but no siege found"); - return (struct building *)a->data.v; -} - -void usetsiege(unit * u, const struct building *t) -{ - attrib *a = a_find(u->attribs, &at_siege); - if (!a && t) - a = a_add(&u->attribs, a_new(&at_siege)); - if (a) { - if (!t) { - a_remove(&u->attribs, a); - freset(u, UFL_SIEGE); - } - else { - a->data.v = (void *)t; - fset(u, UFL_SIEGE); - } - } -} - /*********************/ /* at_contact */ /*********************/ @@ -1914,16 +1860,6 @@ int getunit(const region * r, const faction * f, unit **uresult) return result; } -int besieged(const unit * u) -{ - /* belagert kann man in schiffen und burgen werden */ - if (u && !keyword_disabled(K_BESIEGE) && u->building) { - building * b = u->building; - return building_get_siege(b) >= b->size * SIEGEFACTOR; - } - return false; -} - bool has_horses(const unit * u) { item *itm = u->items; diff --git a/src/kernel/unit.h b/src/kernel/unit.h index a6135715c..3f82ef80a 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -47,7 +47,6 @@ extern "C" { #define UFL_NOTMOVING (1<<9) /* Die Einheit kann sich wg. langen Kampfes nicht bewegen */ #define UFL_DEFENDER (1<<10) #define UFL_HUNGER (1<<11) /* kann im Folgemonat keinen langen Befehl außer ARBEITE ausführen */ -#define UFL_SIEGE (1<<12) /* speedup: belagert eine burg, siehe attribut */ #define UFL_TARGET (1<<13) /* speedup: hat ein target, siehe attribut */ #define UFL_WERE (1<<14) #define UFL_ENTER (1<<15) /* unit has entered a ship/building and will not leave it */ @@ -121,7 +120,6 @@ extern "C" { extern struct attrib_type at_creator; extern struct attrib_type at_alias; - extern struct attrib_type at_siege; extern struct attrib_type at_target; extern struct attrib_type at_potionuser; extern struct attrib_type at_contact; @@ -138,8 +136,6 @@ extern "C" { const struct race *u_irace(const struct unit *u); const struct race *u_race(const struct unit *u); void u_setrace(struct unit *u, const struct race *); - struct building *usiege(const struct unit *u); - void usetsiege(struct unit *u, const struct building *b); const char *uprivate(const struct unit *u); void usetprivate(struct unit *u, const char *c); @@ -257,7 +253,6 @@ extern "C" { int read_unitid(const struct faction *f, const struct region *r); /* !< sets combatstatus of a unit */ - int besieged(const struct unit *u); bool has_horses(const struct unit *u); int maintenance_cost(const struct unit *u); bool has_limited_skills(const struct unit *u); diff --git a/src/keyword.c b/src/keyword.c index 48726bcbc..47fcc3c8e 100644 --- a/src/keyword.c +++ b/src/keyword.c @@ -94,7 +94,7 @@ const char *keywords[MAXKEYWORDS] = { "work", "attack", "steal", - "besiege", + "deprecated_besiege", "name", "use", "describe", diff --git a/src/keyword.h b/src/keyword.h index 6e4832708..bd4ab02d0 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -17,7 +17,7 @@ extern "C" K_WORK, K_ATTACK, K_STEAL, - K_BESIEGE, + K_BESIEGE_UNUSED, K_NAME, K_USE, K_DISPLAY, diff --git a/src/laws.c b/src/laws.c index 67a44c673..0e9285281 100644 --- a/src/laws.c +++ b/src/laws.c @@ -901,61 +901,6 @@ void demographics(void) immigration(); } -/* ------------------------------------------------------------- */ - -/* test if the unit can slip through a siege undetected. - * returns 0 if siege is successful, or 1 if the building is either - * not besieged or the unit can slip through the siege due to better stealth. - */ -static int slipthru(const region * r, const unit * u, const building * b) -{ - unit *u2; - int n, o; - - /* b ist die burg, in die man hinein oder aus der man heraus will. */ - if (b == NULL || building_get_siege(b) < b->size * SIEGEFACTOR) { - return 1; - } - - /* u wird am hinein- oder herausschluepfen gehindert, wenn STEALTH <= - * OBSERVATION +2 der belagerer u2 ist */ - n = effskill(u, SK_STEALTH, r); - - for (u2 = r->units; u2; u2 = u2->next) { - if (usiege(u2) == b) { - - if (invisible(u, u2) >= u->number) - continue; - - o = effskill(u2, SK_PERCEPTION, r); - - if (o + 2 >= n) { - return 0; /* entdeckt! */ - } - } - } - return 1; -} - -int can_contact(const region * r, const unit * u, const unit * u2) { - - /* hier geht es nur um die belagerung von burgen */ - UNUSED_ARG(r); - if (u->building == u2->building) { - return 1; - } - - /* unit u is trying to contact u2 - unasked for contact. wenn u oder u2 - * nicht in einer burg ist, oder die burg nicht belagert ist, ist - * slipthru () == 1. ansonsten ist es nur 1, wenn man die belagerer */ - - if (slipthru(u->region, u, u->building) && slipthru(u->region, u2, u2->building)) { - return 1; - } - - return (alliedunit(u, u2->faction, HELP_GIVE)); -} - int contact_cmd(unit * u, order * ord) { unit *u2; @@ -966,10 +911,6 @@ int contact_cmd(unit * u, order * ord) u2 = findunit(n); if (u2 != NULL) { - if (!can_contact(u->region, u, u2)) { - cmistake(u, u->thisorder, 23, MSG_EVENT); - return -1; - } usetcontact(u, u2); } return 0; @@ -994,13 +935,7 @@ int leave_cmd(unit * u, struct order *ord) return 0; } } - if (!slipthru(r, u, u->building)) { - ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "entrance_besieged", - "building", u->building)); - } - else { - leave(u, true); - } + leave(u, true); return 0; } @@ -1148,13 +1083,6 @@ int enter_building(unit * u, order * ord, int id, bool report) } return 0; } - if (!slipthru(r, u, b)) { - if (report) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "entrance_besieged", - "building", b)); - } - return 0; - } if (leave(u, 0)) { fset(u, UFL_ENTER); @@ -3804,98 +3732,6 @@ int armedmen(const unit * u, bool siege_weapons) return n; } -int siege_cmd(unit * u, order * ord) -{ - region *r = u->region; - building *b; - int d, pooled; - int bewaffnete, katapultiere = 0; - resource_type *rt_catapultammo = NULL; - resource_type *rt_catapult = NULL; - - init_order_depr(ord); - b = getbuilding(r); - - if (!b) { - cmistake(u, ord, 31, MSG_BATTLE); - return 31; - } - - if (!playerrace(u_race(u))) { - /* keine Drachen, Illusionen, Untote etc */ - cmistake(u, ord, 166, MSG_BATTLE); - return 166; - } - /* schaden durch katapulte */ - - rt_catapultammo = rt_find("catapultammo"); - rt_catapult = rt_find("catapult"); - - d = i_get(u->items, rt_catapult->itype); - if (d > u->number) d = u->number; - pooled = get_pooled(u, rt_catapultammo, GET_DEFAULT, d); - if (d > pooled) d = pooled; - if (effskill(u, SK_CATAPULT, 0) >= 1) { - katapultiere = d; - d *= effskill(u, SK_CATAPULT, 0); - } - else { - d = 0; - } - - bewaffnete = armedmen(u, true); - if (d == 0 && bewaffnete == 0) { - /* abbruch, falls unbewaffnet oder unfaehig, katapulte zu benutzen */ - cmistake(u, ord, 80, MSG_EVENT); - return 80; - } - - if (!is_guard(u)) { - /* abbruch, wenn die einheit nicht vorher die region bewacht - als - * warnung fuer alle anderen! */ - cmistake(u, ord, 81, MSG_EVENT); - return 81; - } - /* einheit und burg markieren - spart zeit beim behandeln der einheiten - * in der burg, falls die burg auch markiert ist und nicht alle - * einheiten wieder abgesucht werden muessen! */ - - usetsiege(u, b); - if (katapultiere < bewaffnete) katapultiere = bewaffnete; - building_add_siege(b, katapultiere); - - /* definitiver schaden eingeschraenkt */ - if (d > b->size - 1) d = b->size - 1; - - /* meldung, schaden anrichten */ - if (d && !curse_active(get_curse(b->attribs, &ct_magicwalls))) { - b->size -= d; - use_pooled(u, rt_catapultammo, - GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, d); - /* send message to the entire region */ - ADDMSG(&r->msgs, msg_message("siege_catapults", - "unit building destruction", u, b, d)); - } - else { - /* send message to the entire region */ - ADDMSG(&r->msgs, msg_message("siege", "unit building", u, b)); - } - return 0; -} - -void do_siege(region * r) -{ - if (fval(r->terrain, LAND_REGION)) { - unit *u; - - for (u = r->units; u; u = u->next) { - if (getkeyword(u->thisorder) == K_BESIEGE) { - siege_cmd(u, u->thisorder); - } - } - } -} - static void enter_1(region * r) { do_enter(r, 0); @@ -3979,11 +3815,6 @@ void init_processor(void) p += 10; add_proc_global(p, do_battles, "Attackieren"); - if (!keyword_disabled(K_BESIEGE)) { - p += 10; - add_proc_region(p, do_siege, "Belagern"); - } - p += 10; /* can't allow reserve before siege (weapons) */ add_proc_region(p, enter_1, "Betreten (3. Versuch)"); /* to claim a castle after a victory and to be able to DESTROY it in the same turn */ if (config_get_int("rules.reserve.twophase", 0)) { @@ -4201,7 +4032,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier) } /* simple visibility, just gotta have a viewer in the region to see 'em */ - if (leftship(u) || is_guard(u) || usiege(u) || u->building || u->ship) { + if (leftship(u) || is_guard(u) || u->building || u->ship) { return true; } @@ -4239,7 +4070,7 @@ bool cansee_unit(const unit * u, const unit * target, int modifier) else { int n, rings; - if (is_guard(target) || usiege(target) || target->building + if (is_guard(target) || target->building || target->ship) { return true; } @@ -4282,7 +4113,7 @@ cansee_durchgezogen(const faction * f, const region * r, const unit * u, else { int rings, n; - if (is_guard(u) || usiege(u) || u->building || u->ship) { + if (is_guard(u) || u->building || u->ship) { return true; } diff --git a/src/laws.h b/src/laws.h index 0b5db17c7..b7958891f 100755 --- a/src/laws.h +++ b/src/laws.h @@ -48,7 +48,6 @@ extern "C" { bool renamed_building(const struct building * b); int rename_building(struct unit * u, struct order * ord, struct building * b, const char *name); void get_food(struct region * r); - int can_contact(const struct region *r, const struct unit *u, const struct unit *u2); int enter_building(struct unit *u, struct order *ord, int id, bool report); int enter_ship(struct unit *u, struct order *ord, int id, bool report); @@ -82,7 +81,6 @@ extern "C" { int quit_cmd(struct unit *u, struct order *ord); int name_cmd(struct unit *u, struct order *ord); int use_cmd(struct unit *u, struct order *ord); - int siege_cmd(struct unit *u, struct order *ord); int leave_cmd(struct unit *u, struct order *ord); int pay_cmd(struct unit *u, struct order *ord); int promotion_cmd(struct unit *u, struct order *ord); diff --git a/src/laws.test.c b/src/laws.test.c index fb644dc90..778ee3323 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -95,38 +95,6 @@ static void test_rename_building_twice(CuTest * tc) test_teardown(); } -static void test_contact(CuTest * tc) -{ - region *r; - unit *u1, *u2, *u3; - building *b; - building_type *btype; - ally *al; - - test_setup(); - test_create_locale(); - btype = test_create_buildingtype("castle"); - r = test_create_region(0, 0, NULL); - b = new_building(btype, r, default_locale); - u1 = test_create_unit(test_create_faction(NULL), r); - u2 = test_create_unit(test_create_faction(NULL), r); - u3 = test_create_unit(test_create_faction(NULL), r); - set_level(u3, SK_PERCEPTION, 2); - usetsiege(u3, b); - building_add_siege(b, 1); - CuAssertIntEquals(tc, 1, building_get_siege(b)); - CuAssertIntEquals(tc, 1, can_contact(r, u1, u2)); - - u_set_building(u1, b); - CuAssertIntEquals(tc, 0, can_contact(r, u1, u2)); - al = ally_add(&u1->faction->allies, u2->faction); - al->status = HELP_ALL; - CuAssertIntEquals(tc, HELP_GIVE, can_contact(r, u1, u2)); - u_set_building(u2, b); - CuAssertIntEquals(tc, 1, can_contact(r, u1, u2)); - test_teardown(); -} - static void test_enter_building(CuTest * tc) { unit *u; @@ -1833,7 +1801,6 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_pay_cmd_must_be_owner); SUITE_ADD_TEST(suite, test_new_units); SUITE_ADD_TEST(suite, test_cannot_create_unit_above_limit); - SUITE_ADD_TEST(suite, test_contact); SUITE_ADD_TEST(suite, test_enter_building); SUITE_ADD_TEST(suite, test_enter_ship); SUITE_ADD_TEST(suite, test_display_cmd); diff --git a/src/process.pkg b/src/process.pkg index a81917293..89e8f2fa7 100755 --- a/src/process.pkg +++ b/src/process.pkg @@ -21,7 +21,6 @@ module eressea { void process_movement @ movement(void); /* MOVE/FOLLOW/ROUTE */ void process_use @ use(void); /* USE */ void process_battle @ battle(void); /* ATTACK */ - void process_siege @ siege(void); /* SIEGE */ void process_leave @ leave(void); /* LEAVE */ void process_maintenance @ maintenance(void); /* PAY */ void process_promote @ promote(void); /* PROMOTE */ diff --git a/src/process.pkg.c b/src/process.pkg.c index 42dff20ff..3e818f7ce 100644 --- a/src/process.pkg.c +++ b/src/process.pkg.c @@ -435,30 +435,6 @@ static int tolua_process_eressea_process_battle00(lua_State* tolua_S) #endif } -/* function: process_siege */ -static int tolua_process_eressea_process_siege00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isnoobj(tolua_S,1,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - { - process_siege(); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'siege'.",&tolua_err); - return 0; -#endif -} - /* function: process_leave */ static int tolua_process_eressea_process_leave00(lua_State* tolua_S) { @@ -993,7 +969,6 @@ LUALIB_API int luaopen_process (lua_State* tolua_S) tolua_function(tolua_S,"movement",tolua_process_eressea_process_movement00); tolua_function(tolua_S,"use",tolua_process_eressea_process_use00); tolua_function(tolua_S,"battle",tolua_process_eressea_process_battle00); - tolua_function(tolua_S,"siege",tolua_process_eressea_process_siege00); tolua_function(tolua_S,"leave",tolua_process_eressea_process_leave00); tolua_function(tolua_S,"maintenance",tolua_process_eressea_process_maintenance00); tolua_function(tolua_S,"promote",tolua_process_eressea_process_promote00); diff --git a/src/report.c b/src/report.c index 7de2550a4..29f124cef 100644 --- a/src/report.c +++ b/src/report.c @@ -1821,7 +1821,6 @@ nr_building(struct stream *out, const region *r, const building *b, const factio const char *name, *bname, *billusion = NULL; const struct locale *lang; char buffer[8192]; - message *msg; size_t size; sbstring sbs; @@ -1853,17 +1852,6 @@ nr_building(struct stream *out, const region *r, const building *b, const factio sbs_strcat(&sbs, LOC(lang, "nr_building_inprogress")); } - if (!keyword_disabled(K_BESIEGE) && r->seen.mode >= seen_lighthouse) { - int s = building_get_siege(b); - if (s > 0) { - msg = msg_message("nr_building_besieged", "soldiers diff", s, - s - b->size * SIEGEFACTOR); - size = nr_render(msg, lang, sbs.end, sbs.size - (sbs.end - sbs.begin), f); - sbs.end += size; - - msg_release(msg); - } - } i = 0; if (b->display && b->display[0]) { sbs_strcat(&sbs, "; "); diff --git a/src/reports.c b/src/reports.c index 9d9ab5f6f..25c331a9f 100644 --- a/src/reports.c +++ b/src/reports.c @@ -683,7 +683,6 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf, int i, dh; int getarnt = fval(u, UFL_ANON_FACTION); const char *pzTmp, *str; - building *b; bool isbattle = (bool)(mode == seen_battle); item *itm, *show = NULL; faction *fv; @@ -807,11 +806,6 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf, bufp = STRLCPY(bufp, LOC(lang, "unit_guards"), size); } - if ((b = usiege(u)) != NULL) { - bufp = STRLCPY(bufp, ", belagert ", size); - bufp = STRLCPY(bufp, buildingname(b), size); - } - dh = 0; if (u->faction == f) { skill *sv; diff --git a/src/spy.c b/src/spy.c index ae70f4db8..9dc9de35a 100644 --- a/src/spy.c +++ b/src/spy.c @@ -137,10 +137,6 @@ int spy_cmd(unit * u, struct order *ord) msg_feedback(u, u->thisorder, "feedback_unit_not_found", "")); return 0; } - if (!can_contact(r, u, target)) { - cmistake(u, u->thisorder, 24, MSG_EVENT); - return 0; - } if (effskill(u, SK_SPY, 0) < 1) { cmistake(u, u->thisorder, 39, MSG_EVENT); return 0; diff --git a/src/spy.test.c b/src/spy.test.c index 0224698a0..d8b879e3f 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -198,17 +198,17 @@ static void test_setstealth_cmd(CuTest *tc) { test_setup(); u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0)); lang = u->faction->locale; - u->flags = UFL_ANON_FACTION | UFL_SIEGE; + u->flags = UFL_ANON_FACTION | UFL_DEFENDER; u->thisorder = create_order(K_SETSTEALTH, lang, "%s %s", LOC(lang, parameters[P_FACTION]), LOC(lang, parameters[P_NOT])); setstealth_cmd(u, u->thisorder); - CuAssertIntEquals(tc, UFL_SIEGE, u->flags); + CuAssertIntEquals(tc, UFL_DEFENDER, u->flags); free_order(u->thisorder); u->thisorder = create_order(K_SETSTEALTH, lang, "%s", LOC(lang, parameters[P_FACTION])); setstealth_cmd(u, u->thisorder); - CuAssertIntEquals(tc, UFL_SIEGE | UFL_ANON_FACTION, u->flags); + CuAssertIntEquals(tc, UFL_DEFENDER | UFL_ANON_FACTION, u->flags); test_teardown(); } diff --git a/src/steal.c b/src/steal.c index 68a4239ec..8a390c8fb 100644 --- a/src/steal.c +++ b/src/steal.c @@ -188,10 +188,6 @@ void steal_cmd(unit * u, struct order *ord, econ_request ** stealorders) } assert(u->region == u2->region); - if (!can_contact(r, u, u2)) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error60", "")); - return; - } effsk = effskill(u, SK_STEALTH, 0); n = effsk - max_skill(r, f, SK_PERCEPTION); From d32689bac898bb9614632b55f769bae865f09d5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 10 Sep 2018 17:58:10 +0200 Subject: [PATCH 03/11] experiments with clang-tidy --- src/academy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/academy.c b/src/academy.c index 1298e9b57..538d36e06 100644 --- a/src/academy.c +++ b/src/academy.c @@ -16,8 +16,8 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#include -#include +#include "platform.h" +#include "kernel/config.h" #include #include #include From 12fd6435c5346b8d8edd12125a32affe64895140 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 10 Sep 2018 18:17:34 +0200 Subject: [PATCH 04/11] eliminate apparently dead code, and coverity warning. --- src/util/message.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/util/message.c b/src/util/message.c index 8915dca8f..d8c66f5e0 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -86,13 +86,7 @@ static void mt_register(message_type * mtype) { message_type *mt_create(message_type * mtype, const char *args[], int nparameters) { - if (args != NULL && args[nparameters]) { - /* count the number of parameters */ - do { - ++nparameters; - } while (args[nparameters]); - } - if (nparameters > 0) { + if (args && nparameters > 0) { int i; mtype->nparameters = nparameters; mtype->pnames = (char **)malloc(sizeof(char *) * nparameters); From ecaf72324cdd91597c0f2bccdc7ae77b2f52019a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 10 Sep 2018 19:50:22 +0200 Subject: [PATCH 05/11] Bug 2481: FOLGE wurde durch ZAUBERE verhindert. --- src/move.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index b815f5ea5..7f56932d8 100644 --- a/src/move.c +++ b/src/move.c @@ -2633,9 +2633,9 @@ void follow_unit(unit * u) } } if (follow) { - fset(u, UFL_FOLLOWING); fset(u2, UFL_FOLLOWED); /* FOLLOW unit on a (potentially) moving unit prevents long orders */ + fset(u, UFL_FOLLOWING | UFL_LONGACTION); set_order(&u->thisorder, NULL); } } From d6e8b38724f4b5164f012c1aacd9e207f6bb4837 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 12 Sep 2018 20:35:27 +0200 Subject: [PATCH 06/11] FOLGE SCHIFF reparieren (hat UFL_LONGORDER getestet). --- scripts/tests/e2/astral.lua | 6 ------ scripts/tests/e2/init.lua | 8 +++++++- scripts/tests/e2/movement.lua | 3 ++- src/move.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/tests/e2/astral.lua b/scripts/tests/e2/astral.lua index efed6345f..1573c9af2 100644 --- a/scripts/tests/e2/astral.lua +++ b/scripts/tests/e2/astral.lua @@ -13,12 +13,6 @@ function setup() eressea.settings.set("magic.regeneration.enable", "0") end -local function dump_messages(f) - for k, v in ipairs(f.messages) do - print(v) - end -end - function test_fetch_astral() local r = region.create(0, 0, "plain") local f = faction.create("human") diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 5c942fc74..55feab5bf 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,3 +1,10 @@ +function dump_messages(f) + for k, v in ipairs(f.messages) do + print(v) + end +end + +require 'tests.e2.movement' require 'tests.e2.astral' require 'tests.e2.spells' require 'tests.e2.e2features' @@ -7,7 +14,6 @@ require 'tests.e2.production' require 'tests.e2.adamantium' require 'tests.e2.undead' require 'tests.e2.shiplanding' -require 'tests.e2.movement' require 'tests.e2.destroy' require 'tests.e2.guard' require 'tests.e2.stealth' diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index fb82567af..57d2413c4 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -9,7 +9,7 @@ function setup() eressea.settings.set("NewbieImmunity", "0") end - function test_piracy() +function test_piracy() local r = region.create(0, 0, "plain") local r2 = region.create(1, 0, "plain") local r3 = region.create(-1, 0, "ocean") @@ -96,6 +96,7 @@ function test_follow_ship() local f = faction.create("human", "test@example.com", "de") local u1 = unit.create(f, r1, 1) local u2 = unit.create(f, r1, 1) + u2.name = 'Xolgrim' u1:add_item("money", 100) u2:add_item("money", 100) u1.ship = ship.create(r1, "boat") diff --git a/src/move.c b/src/move.c index 7f56932d8..5e8c56235 100644 --- a/src/move.c +++ b/src/move.c @@ -2368,7 +2368,7 @@ static void move_hunters(void) break; } - if (!fval(u, UFL_LONGACTION) && !LongHunger(u) && follow_ship(u, ord)) { + if (!LongHunger(u) && follow_ship(u, ord)) { up = &r->units; break; } From a876a60b6855c7e034ac3c229657934b741a6158 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 13 Sep 2018 16:16:32 +0200 Subject: [PATCH 07/11] Stop using player email to set faction name. --- src/economy.test.c | 1 + src/gmtool.c | 10 ---------- src/races/races.c | 2 -- src/races/zombies.c | 23 ----------------------- src/tests.c | 24 ++++++++++++++++++++++++ 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/economy.test.c b/src/economy.test.c index 90a4bd260..1a40c03db 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -487,6 +487,7 @@ static void test_recruit_insect(CuTest *tc) { test_setup(); test_create_calendar(); + test_create_terrain("desert", -1); f = test_create_faction(test_create_race("insect")); u = test_create_unit(f, test_create_region(0, 0, NULL)); u->thisorder = create_order(K_RECRUIT, f->locale, "%d", 1); diff --git a/src/gmtool.c b/src/gmtool.c index fdbfd3faa..c2193bd32 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -932,20 +932,10 @@ static void seed_player(state *st, const newfaction *player) { pnormalize(&nx, &ny, st->cursor.pl); r = findregion(nx, ny); if (r) { - const char *at = strchr(player->email, '@'); faction *f; addplayer(r, f = addfaction(player->email, player->password, player->race, player->lang, player->subscription)); - if (at) { - char fname[64]; - size_t len = at - player->email; - if (len>4 && lenemail, len); - fname[len]=0; - faction_setname(f, fname); - } - } } } } diff --git a/src/races/races.c b/src/races/races.c index 120a15dd9..44ca5d95e 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -30,7 +30,6 @@ void age_firedragon(struct unit *u); void age_dragon(struct unit *u); -void age_undead(struct unit *u); void age_skeleton(struct unit *u); void age_zombie(struct unit *u); void age_ghoul(struct unit *u); @@ -81,7 +80,6 @@ void equip_newunits(struct unit *u) void register_races(void) { /* function age for race->age() */ - register_function((pf_generic)age_undead, "age_undead"); register_function((pf_generic)age_skeleton, "age_skeleton"); register_function((pf_generic)age_zombie, "age_zombie"); register_function((pf_generic)age_ghoul, "age_ghoul"); diff --git a/src/races/zombies.c b/src/races/zombies.c index de3d81972..3c880d819 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -40,29 +40,6 @@ void make_undead_unit(unit * u) u->flags |= UFL_ISNEW; } -void age_undead(unit * u) -{ - region *r = u->region; - - /* untote, die einer partei angehoeren, koennen sich - * absplitten, anstatt sich zu vermehren. monster - * untote vermehren sich nur noch */ - - if (u->number > UNDEAD_MIN && !is_monsters(u->faction) - && rng_int() % 100 < UNDEAD_BREAKUP) { - int m, n = 0; - unit *u2; - - for (m = u->number; m; m--) { - if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION) - ++n; - } - u2 = create_unit(r, get_monsters(), 0, get_race(RC_UNDEAD), 0, NULL, u); - make_undead_unit(u2); - transfermen(u, u2, u->number - n); - } -} - void age_skeleton(unit * u) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) { diff --git a/src/tests.c b/src/tests.c index 4ee38d195..6395b4fcb 100644 --- a/src/tests.c +++ b/src/tests.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,29 @@ static void test_reset(void) { free_spellbooks(); free_prefixes(); mt_clear(); +/* + for (i = 0; i != MAXTERRAINS; ++i) { + int flags = 0; + if (i == T_FIREWALL) { + flags |= FORBIDDEN_REGION; + } else { + flags = FLY_INTO | WALK_INTO; + if (i == T_OCEAN) { + flags |= SEA_REGION | SWIM_INTO; + } + else { + flags |= LAND_REGION; + if (i == T_PLAIN) { + flags |= CAVALRY_REGION | FOREST_REGION; + } + else if (i == T_GLACIER || i == T_ICEBERG || i == T_ICEBERG_SLEEP) { + flags |= ARCTIC_REGION; + } + } + } + test_create_terrain(terrainnames[i], flags); + } +*/ for (i = 0; i != MAXSKILLS; ++i) { enable_skill(i, true); } From 681cf32e1f82a650f37ee2eba927b4e9ca57fab0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 15 Sep 2018 18:35:27 +0200 Subject: [PATCH 08/11] remove besiege from keywords[] array fix broken at_keys attributes remove unused global.attribs --- scripts/tests/e3/rules.lua | 7 ++-- src/attributes/key.c | 79 +++++++++++++++++++++++++++++++++----- src/bindings.c | 25 ------------ src/jsonconf.c | 2 +- src/kernel/config.c | 4 -- src/kernel/config.h | 1 - src/kernel/save.c | 11 ++++-- src/keyword.c | 6 +-- src/tests.c | 4 +- src/util/gamedata.h | 3 +- 10 files changed, 88 insertions(+), 54 deletions(-) diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 6d3e56d1a..b262f99a6 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -953,12 +953,11 @@ function test_bug2083() -- this is a bit weird, but the bug was caused by market code -- being called in two places. We want to make sure this doesn't happen for k, v in pairs(rules) do - set_key("xm09", true) - if 'table' == type(v) then + if 'table' == type(v) then cb = v['update'] - if 'function' == type(cb) then + if 'function' == type(cb) then cb() - end + end end end diff --git a/src/attributes/key.c b/src/attributes/key.c index 75958a6fb..1808c561f 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -25,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include #include #include #include @@ -76,25 +77,83 @@ static int keys_size(int n) { return 4096; } +static int read_flags(gamedata *data, int *keys, int n) { + int i; + for (i = 0; i != n; ++i) { + int key; + READ_INT(data->store, &key); + keys[i * 2] = key; + keys[i * 2 + 1] = 1; + } + return n; +} + +#ifdef KEYVAL_VERSION +static int read_keyval(gamedata *data, int *keys, int n) { + int i; + for (i = 0; i != n; ++i) { + int key, val; + READ_INT(data->store, &key); + READ_INT(data->store, &val); + keys[i * 2] = key; + keys[i * 2 + 1] = val; + } + return n; +} +#endif + +#ifdef FIXATKEYS_VERSION +static int read_keyval_orig(gamedata *data, int *keys, int n) { + int i, j = 0, dk = -1; + for (i = 0; i != n; ++i) { + int key, val; + READ_INT(data->store, &key); + READ_INT(data->store, &val); + if (key > dk) { + keys[j * 2] = key; + keys[j * 2 + 1] = val; + dk = key; + ++j; + } + } + return j; +} +#endif + static int a_readkeys(variant *var, void *owner, gamedata *data) { - int i, n, *keys; + int i, n, ksn, *keys; READ_INT(data->store, &n); assert(n < 4096 && n >= 0); if (n == 0) { return AT_READ_FAIL; } - keys = malloc(sizeof(int)*(keys_size(n) * 2 + 1)); - *keys = n; - for (i = 0; i != n; ++i) { - READ_INT(data->store, keys + i * 2 + 1); - if (data->version >= KEYVAL_VERSION) { - READ_INT(data->store, keys + i * 2 + 2); - } - else { - keys[i * 2 + 2] = 1; + ksn = keys_size(n); + keys = malloc((ksn * 2 + 1) * sizeof(int)); + if (data->version >= FIXATKEYS_VERSION) { + n = read_keyval(data, keys + 1, n); + } + else if (data->version >= KEYVAL_VERSION) { + int m = read_keyval_orig(data, keys + 1, n); + if (n != m) { + int ksm = keys_size(m); + if (ksm != ksn) { + int *nkeys = (int *)realloc(keys, (ksm * 2 + 1) * sizeof(int)); + if (nkeys != NULL) { + keys = nkeys; + } + else { + log_error("a_readkeys allocation failed: %s", strerror(errno)); + return AT_READ_FAIL; + } + } + n = m; } } + else { + n = read_flags(data, keys + 1, n); + } + keys[0] = n; if (data->version < SORTKEYS_VERSION) { int e = 1; for (i = 1; i != n; ++i) { diff --git a/src/bindings.c b/src/bindings.c index d72bddac2..bdf03afdf 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -153,15 +153,6 @@ int tolua_itemlist_next(lua_State * L) return 0; } -static int tolua_getkey(lua_State * L) -{ - const char *name = tolua_tostring(L, 1, 0); - int flag = atoi36(name); - - lua_pushboolean(L, key_get(global.attribs, flag)); - return 1; -} - static int tolua_translate(lua_State * L) { const char *str = tolua_tostring(L, 1, 0); @@ -175,20 +166,6 @@ static int tolua_translate(lua_State * L) return 0; } -static int tolua_setkey(lua_State * L) -{ - const char *name = tolua_tostring(L, 1, 0); - int value = (int)tolua_tonumber(L, 3, 0); - int flag = atoi36(name); - if (value) { - key_set(&global.attribs, flag, value); - } - else { - key_unset(&global.attribs, flag); - } - return 0; -} - static int tolua_random(lua_State * L) { lua_pushinteger(L, rng_int()); @@ -1003,8 +980,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile) tolua_function(L, TOLUA_CAST "update_owners", tolua_update_owners); tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill); tolua_function(L, TOLUA_CAST "create_curse", tolua_create_curse); - tolua_function(L, TOLUA_CAST "get_key", tolua_getkey); - tolua_function(L, TOLUA_CAST "set_key", tolua_setkey); tolua_function(L, TOLUA_CAST "translate", &tolua_translate); tolua_function(L, TOLUA_CAST "spells", tolua_get_spells); tolua_function(L, TOLUA_CAST "equip_newunits", tolua_equip_newunits); diff --git a/src/jsonconf.c b/src/jsonconf.c index fcd6f5c78..51116691f 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -846,7 +846,7 @@ static void json_keyword(cJSON *json, struct locale *lang) { } for (child = json->child; child; child = child->next) { keyword_t kwd = findkeyword(child->string); - if (kwd != NOKEYWORD) { + if (kwd != NOKEYWORD && keywords[kwd]) { if (child->type == cJSON_String) { init_keyword(lang, kwd, child->valuestring); locale_setstring(lang, mkname("keyword", keywords[kwd]), child->valuestring); diff --git a/src/kernel/config.c b/src/kernel/config.c index 750d406f6..eee2ec0f5 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -767,10 +767,6 @@ void free_gamedata(void) free_borders(); free_alliances(); - while (global.attribs) { - a_remove(&global.attribs, global.attribs); - } - while (planes) { plane *pl = planes; planes = planes->next; diff --git a/src/kernel/config.h b/src/kernel/config.h index 94abcb7f4..e104d4a1a 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -109,7 +109,6 @@ extern "C" { /* globale settings des Spieles */ typedef struct settings { - struct attrib *attribs; void *vm_state; } settings; diff --git a/src/kernel/save.c b/src/kernel/save.c index b51e82734..51585f26c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1392,7 +1392,13 @@ int read_game(gamedata *data) else { READ_STR(store, NULL, 0); } - read_attribs(data, &global.attribs, NULL); + + if (data->version < FIXATKEYS_VERSION) { + attrib *a = NULL; + read_attribs(data, &a, NULL); + a_removeall(&a, NULL); + } + READ_INT(store, &turn); log_debug(" - reading turn %d", turn); rng_init(turn + config_get_int("game.seed", 0)); @@ -1614,9 +1620,6 @@ int write_game(gamedata *data) { WRITE_INT(store, game_id()); WRITE_SECTION(store); - write_attribs(store, global.attribs, NULL); - WRITE_SECTION(store); - WRITE_INT(store, turn); WRITE_INT(store, 0 /* max_unique_id */); WRITE_INT(store, nextborder); diff --git a/src/keyword.c b/src/keyword.c index 47fcc3c8e..e2b5b4775 100644 --- a/src/keyword.c +++ b/src/keyword.c @@ -15,7 +15,7 @@ const char * keyword(keyword_t kwd) { static char result[32]; /* FIXME: static return value */ - if (kwd==NOKEYWORD) { + if (kwd==NOKEYWORD || keywords[kwd] == NULL) { return NULL; } if (!result[0]) { @@ -43,7 +43,7 @@ void init_keywords(const struct locale *lang) { keyword_t findkeyword(const char *s) { int i; for (i = 0; i != MAXKEYWORDS; ++i) { - if (strcmp(s, keywords[i]) == 0) { + if (keywords[i] && (strcmp(s, keywords[i]) == 0)) { return (keyword_t)i; } } @@ -94,7 +94,7 @@ const char *keywords[MAXKEYWORDS] = { "work", "attack", "steal", - "deprecated_besiege", + NULL, "name", "use", "describe", diff --git a/src/tests.c b/src/tests.c index 6395b4fcb..ddd6f7cf5 100644 --- a/src/tests.c +++ b/src/tests.c @@ -147,7 +147,9 @@ struct locale * test_create_locale(void) { locale_setstring(loc, combatstatus[i], combatstatus[i] + 7); } for (i = 0; i != MAXKEYWORDS; ++i) { - locale_setstring(loc, mkname("keyword", keywords[i]), keywords[i]); + if (keywords[i]) { + locale_setstring(loc, mkname("keyword", keywords[i]), keywords[i]); + } } for (i = 0; i != MAXPARAMS; ++i) { locale_setstring(loc, parameters[i], parameters[i]); diff --git a/src/util/gamedata.h b/src/util/gamedata.h index 22c1d9052..2dd4e1342 100644 --- a/src/util/gamedata.h +++ b/src/util/gamedata.h @@ -36,10 +36,11 @@ #define FAMILIAR_FIX_VERSION 359 /* familiar links are fixed */ #define SKILLSORT_VERSION 360 /* u->skills is sorted */ #define LANDDISPLAY_VERSION 360 /* r.display is now in r.land.display */ +#define FIXATKEYS_VERSION 361 /* remove global.attribs, fix at_keys */ /* unfinished: */ #define CRYPT_VERSION 400 /* passwords are encrypted */ -#define RELEASE_VERSION LANDDISPLAY_VERSION /* current datafile */ +#define RELEASE_VERSION FIXATKEYS_VERSION /* current datafile */ #define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */ #define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ From 658b47aeb4a8302515e26016094bc72463ad3c61 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 15 Sep 2018 19:12:32 +0200 Subject: [PATCH 09/11] remove seaserpent test that is not a test. --- scripts/tests/e2/e2features.lua | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 54033d496..acd2f1e03 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -541,16 +541,3 @@ function test_buy_sell() assert_equal(4, u:get_item(item)) assert_not_equal(0, u:get_item('money')) end - -function test_seaserpent_attack() - local r = region.create(0, 0, 'ocean') - local sh = ship.create(r, 'boat') - local us = unit.create(get_monsters(), r, 1, 'seaserpent') - local u = unit.create(faction.create('human', 'enno@example.com'), r, 20, 'human') - u.ship = sh - us:clear_orders() - us:add_order('ATTACKIERE ' .. itoa36(u.id)) - us:set_skill('unarmed', 10) - process_orders() - write_reports() -end From 65675d19478e19e13d0db58be7bf47aa7f809bf5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Sep 2018 10:02:09 +0200 Subject: [PATCH 10/11] Fix crash when removing drifted ships. --- src/move.c | 53 +++++++++++++++++++++++------------------------------ src/move.h | 2 +- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/move.c b/src/move.c index b815f5ea5..70425b72e 100644 --- a/src/move.c +++ b/src/move.c @@ -630,7 +630,7 @@ mark_travelthru(unit * u, region * r, const region_list * route, } } -ship *move_ship(ship * sh, region * from, region * to, region_list * route) +void move_ship(ship * sh, region * from, region * to, region_list * route) { unit **iunit = &from->units; unit **ulist = &to->units; @@ -663,8 +663,6 @@ ship *move_ship(ship * sh, region * from, region * to, region_list * route) if (*iunit == u) iunit = &u->next; } - - return sh; } static bool is_freezing(const unit * u) @@ -857,39 +855,34 @@ static void drifting_ships(region * r) } } - if (rnext != NULL) { + if (firstu != NULL) { + message *msg = msg_message("ship_drift", "ship dir", sh, dir); + msg_to_ship_inmates(sh, &firstu, &lastu, msg); + } + fset(sh, SF_DRIFTED); + if (ovl >= overload_start()) { + damage_ship(sh, damage_overload(ovl)); + msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh)); + } + else { + damage_ship(sh, damage_drift); + } + if (sh->damage >= sh->size * DAMAGE_SCALE) { + msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh)); + sink_ship(sh); + remove_ship(shp, sh); + } + else if (rnext != NULL) { /* Das Schiff und alle Einheiten darin werden nun von r - * nach rnext verschoben. Danach eine Meldung. */ + * nach rnext verschoben. Danach eine Meldung. */ add_regionlist(&route, rnext); set_coast(sh, r, rnext); - sh = move_ship(sh, r, rnext, route); + move_ship(sh, r, rnext, route); free_regionlist(route); - - if (firstu != NULL) { - message *msg = msg_message("ship_drift", "ship dir", sh, dir); - msg_to_ship_inmates(sh, &firstu, &lastu, msg); - } } - - if (sh != NULL) { - fset(sh, SF_DRIFTED); - if (ovl >= overload_start()) { - damage_ship(sh, damage_overload(ovl)); - msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh)); - } - else { - damage_ship(sh, damage_drift); - } - if (sh->damage >= sh->size * DAMAGE_SCALE) { - msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh)); - sink_ship(sh); - remove_ship(shp, sh); - } - } - - if (*shp == sh) { + else { shp = &sh->next; } } @@ -1970,7 +1963,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) if (fval(u, UFL_FOLLOWING)) caught_target(current_point, u); - sh = move_ship(sh, starting_point, current_point, *routep); + move_ship(sh, starting_point, current_point, *routep); /* Hafengebühren ? */ diff --git a/src/move.h b/src/move.h index ceab50aa3..754b708aa 100644 --- a/src/move.h +++ b/src/move.h @@ -77,7 +77,7 @@ extern "C" { bool canfly(struct unit *u); void leave_trail(struct ship *sh, struct region *from, struct region_list *route); - struct ship *move_ship(struct ship *sh, struct region *from, + void move_ship(struct ship *sh, struct region *from, struct region *to, struct region_list *route); int walkingcapacity(const struct unit *u); int movement_speed(const struct unit * u); From 552dbe5e72f6cc6ef8604daf76ad7381816dd343 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Sep 2018 10:10:17 +0200 Subject: [PATCH 11/11] In Rosthauch min und max verwechselt. --- src/spells/combatspells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 976c29aed..06a78c4f4 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -299,7 +299,7 @@ int sp_combatrosthauch(struct castorder * co) for (w = 0; df->weapons[w].type != NULL; ++w) { weapon *wp = df->weapons; int n = force; - if (n < wp->used) n = wp->used; + if (n > wp->used) n = wp->used; if (n) { requirement *mat = wp->type->itype->construction->materials; bool iron = false;