From b0792b57e98398140fb8c4eba323a2597c8500d7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 1 Dec 2019 17:07:09 +0100 Subject: [PATCH 1/9] move binding function declarations to headers. --- src/bind_tolua.c | 3 ++- src/bindings.c | 3 +-- src/bindings.h | 2 ++ src/main.c | 2 -- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bind_tolua.c b/src/bind_tolua.c index d681b9088..3812e7689 100644 --- a/src/bind_tolua.c +++ b/src/bind_tolua.c @@ -14,7 +14,8 @@ #include -void tolua_bind_open(lua_State * L) { +void tolua_bind_open(lua_State * L) +{ tolua_eressea_open(L); tolua_process_open(L); tolua_settings_open(L); diff --git a/src/bindings.c b/src/bindings.c index 5cb758175..f2beb6d06 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -3,6 +3,7 @@ #endif #include "bindings.h" +#include "bind_tolua.h" #include "console.h" #include "gamedb.h" @@ -865,8 +866,6 @@ static int lua_rng_default(lua_State *L) { return 0; } -void tolua_bind_open(lua_State * L); - int tolua_bindings_open(lua_State * L, const dictionary *inifile) { tolua_open(L); diff --git a/src/bindings.h b/src/bindings.h index 144f65ca6..f0259bc6e 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -12,6 +12,8 @@ extern "C" { int tolua_selist_push(struct lua_State *L, const char *list_type, const char *elem_type, struct selist *list); + void bind_monsters(struct lua_State *L); + int log_lua_error(struct lua_State *L); void lua_done(struct lua_State *L); diff --git a/src/main.c b/src/main.c index cfc2f9c22..130a2f6f7 100644 --- a/src/main.c +++ b/src/main.c @@ -290,8 +290,6 @@ void locale_init(void) } } -extern void bind_monsters(lua_State *L); - int main(int argc, char **argv) { int err = 0; From 0b623d0768b38c51938e2d6eb4d38c83ec7ee05c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 1 Dec 2019 17:28:51 +0100 Subject: [PATCH 2/9] monster include structure, contd. --- src/bind_monsters.c | 3 --- src/monsters.h | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bind_monsters.c b/src/bind_monsters.c index f9aef4a2a..2acacfaa3 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -28,9 +28,6 @@ static int tolua_levitate_ship(lua_State * L) return 1; } -extern void spawn_undead(void); -extern void plan_monsters(struct faction *f); - static int tolua_planmonsters(lua_State * L) { faction *f = (faction *)tolua_tousertype(L, 1, get_monsters()); diff --git a/src/monsters.h b/src/monsters.h index 81f7e39a3..99d60a3fb 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -21,6 +21,10 @@ extern "C" { bool monster_is_waiting(const struct unit *u); void make_zombie(struct unit * u); + void spawn_undead(void); + void plan_monsters(struct faction *f); + + #ifdef __cplusplus } #endif From d949d9a6d063288d6ebc077686388ae4724a3d58 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Dec 2019 14:28:55 +0100 Subject: [PATCH 3/9] =?UTF-8?q?Bug=202623:=20Untote=20d=C3=BCrfen=20nicht?= =?UTF-8?q?=20in=20heilige=20Regionen=20ziehen.=20Code=20style=20fixes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/e2/spells.lua | 23 +++++++++++++++++++++++ src/laws.c | 22 ++++++++++++++-------- src/move.c | 11 +++++++++-- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index de2386113..9cdc28b96 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -14,6 +14,29 @@ function setup() eressea.settings.set("magic.regeneration.enable", "0") end +function test_undead_cannot_enter_holyground() + local r1 = region.create(0, 0, 'plain') + local r2 = region.create(1, 0, 'plain') + local f = faction.create('human') + local u1 = unit.create(f, r1, 1) + local u2 = unit.create(f, r2, 1) + + u2.name = "Xolgrim's Magier" + u1.name = "Xolgrim's Opfer" + + u2.magic = 'gwyrrd' + u2:set_skill('magic', 100) + u2.aura = 200 + u2:add_spell('holyground') + u2:add_order('ZAUBERE STUFE 10 "Heiliger Boden"') + + u1.race = "skeleton" + u1:add_order("NACH Osten") + process_orders() + assert_not_nil(r2:get_curse('holyground')) + assert_equal(r1, u1.region) +end + function test_shapeshift() local r = region.create(42, 0, "plain") local f = faction.create("demon", "noreply@eressea.de", "de") diff --git a/src/laws.c b/src/laws.c index 10975c6a7..4170975b5 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3712,8 +3712,9 @@ void process(void) log_debug("- Step %u", prio); while (proc && proc->priority == prio) { - if (proc->name) + if (proc->name) { log_debug(" - %s", proc->name); + } proc = proc->next; } @@ -3721,8 +3722,9 @@ void process(void) pglobal->data.global.process(); pglobal = pglobal->next; } - if (pglobal == NULL || pglobal->priority != prio) + if (pglobal == NULL || pglobal->priority != prio) { continue; + } for (r = regions; r; r = r->next) { unit *u; @@ -3733,8 +3735,9 @@ void process(void) pregion->data.per_region.process(r); pregion = pregion->next; } - if (pregion == NULL || pregion->priority != prio) + if (pregion == NULL || pregion->priority != prio) { continue; + } if (r->units) { for (u = r->units; u; u = u->next) { @@ -3744,14 +3747,16 @@ void process(void) punit->data.per_unit.process(u); punit = punit->next; } - if (punit == NULL || punit->priority != prio) + if (punit == NULL || punit->priority != prio) { continue; + } porder = punit; while (porder && porder->priority == prio && porder->type == PR_ORDER) { order **ordp = &u->orders; - if (porder->flags & PROC_THISORDER) + if (porder->flags & PROC_THISORDER) { ordp = &u->thisorder; + } while (*ordp) { order *ord = *ordp; if (getkeyword(ord) == porder->data.per_order.kword) { @@ -3780,8 +3785,9 @@ void process(void) } } } - if (!ord || *ordp == ord) + if (!ord || *ordp == ord) { ordp = &(*ordp)->next; + } } porder = porder->next; } @@ -3798,9 +3804,9 @@ void process(void) pregion->data.per_region.process(r); pregion = pregion->next; } - if (pregion == NULL || pregion->priority != prio) + if (pregion == NULL || pregion->priority != prio) { continue; - + } } } diff --git a/src/move.c b/src/move.c index d33987d54..5d5513cd3 100644 --- a/src/move.c +++ b/src/move.c @@ -974,10 +974,17 @@ bool move_blocked(const unit * u, const region * r, const region * r2) } if (r->attribs) { - const curse_type *fogtrap_ct = &ct_fogtrap; - curse *c = get_curse(r->attribs, fogtrap_ct); + curse *c = get_curse(r->attribs, &ct_fogtrap); + if (curse_active(c)) { + return true; + } + } + + if (r2->attribs && fval(u_race(u), RCF_UNDEAD)) { + curse *c = get_curse(r2->attribs, &ct_holyground); return curse_active(c); } + return false; } From dcf9b9df26fbca5a19bedfe2235526c2d98af5b5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jan 2020 11:34:26 +0100 Subject: [PATCH 4/9] bug 2626: fehlende neue messages nachtragen --- res/core/messages.xml | 56 +++++++++++++++++++++++++++++++++++++++++++ src/kernel/messages.c | 1 + 2 files changed, 57 insertions(+) diff --git a/res/core/messages.xml b/res/core/messages.xml index d40efb9ac..696cb9a2d 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -2690,6 +2690,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 656e08b3a..98411973d 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -62,6 +62,7 @@ static message *missing_feedback(const char *name, const struct unit *u, log_error("trying to create undefined feedback of type \"%s\"\n", name); } else if (missing_message_mode == MESSAGE_MISSING_REPLACE) { + log_warning("trying to create undefined message of type \"%s\"\n", name); if (strcmp(name, "missing_feedback") != 0) { if (!mt_find("missing_feedback")) { mt_create_va(mt_new("missing_feedback", NULL), "unit:unit", From 4f88bf137edf33de4f56d8c81f5789bfedfe058f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jan 2020 12:10:38 +0100 Subject: [PATCH 5/9] bug 2625 samen werden direkt zu schoesslingen --- src/economy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/economy.c b/src/economy.c index 35e08ade6..5da191e50 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1775,12 +1775,12 @@ static void breedtrees(unit * u, int raw) } if (n > raw) n = raw; - /* Fuer jeden Samen Talent*5% Erfolgschance. */ - for (i = n; i > 0; i--) { - if (rng_int() % 100 < skill * 5) - planted++; + /* Talent * 5% der Samen setzen an (max 100%) */ + planted = n; + if (skill < 20) { + planted = planted * skill / 20; } - rsettrees(r, 1, rtrees(r, 1) + planted); + rsettrees(r, 0, rtrees(r, 0) + planted); /* Alles ok. Abziehen. */ produceexp(u, SK_HERBALISM, u->number); From c8c22aea1b02f43df7f03e5aa80e297575ab8c89 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jan 2020 12:47:09 +0100 Subject: [PATCH 6/9] bug 2624: short range conversion bug in tree growth --- src/laws.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/laws.c b/src/laws.c index 4170975b5..53b49e1b6 100644 --- a/src/laws.c +++ b/src/laws.c @@ -594,6 +594,13 @@ growing_trees_e3(region * r, const int current_season, } } +static short cap_short(int i) { + if (i > SHRT_MIN) { + return ((i < SHRT_MAX) ? (short)i : SHRT_MAX); + } + return SHRT_MIN; +} + static void growing_trees(region * r, const season_t current_season, const season_t last_weeks_season) { @@ -687,8 +694,8 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee a = a_find(r->attribs, &at_germs); if (!a) { a = a_add(&r->attribs, a_new(&at_germs)); - a->data.sa[0] = (short)rtrees(r, 0); - a->data.sa[1] = (short)rtrees(r, 1); + a->data.sa[0] = cap_short(rtrees(r, 0)); + a->data.sa[1] = cap_short(rtrees(r, 1)); } /* wir haben 6 Wochen zum wachsen, jeder Same/Spross hat 18% Chance * zu wachsen, damit sollten nach 5-6 Wochen alle gewachsen sein */ From e337b8b4947acf6b0eea1114c017088fb09b793b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Jan 2020 17:14:44 +0100 Subject: [PATCH 7/9] Bug 2626: Korrekter Meldungstext. --- res/core/messages.xml | 8 ++++++++ res/translations/messages.de.po | 5 ++++- res/translations/messages.en.po | 5 ++++- src/give.c | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 696cb9a2d..ecb5707c1 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -2746,6 +2746,14 @@ + + + + + + + + diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 5d2717e51..6cb2b413b 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -2775,7 +2775,10 @@ msgid "error324" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit gehört nicht zu unserer Partei.\"" msgid "error322" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist bereits auf einem Schiff.\"" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Nur Schiffe gleicher Bauart können einen Konvoi bilden.\"" + +msgid "error328" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Nur Schiffe an der selbe Küste können einen Konvoi bilden.\"" msgid "error323" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\"" diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index 659adee9f..9ec9c934b 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2781,11 +2781,14 @@ msgid "error324" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\"" msgid "error322" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is already on a ship.\"" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Only ships of the same type can form a convoy.\"" msgid "error323" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship is under a spell.\"" +msgid "error328" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - All ships of a convoy must be on the same coast.\"" + msgid "dissolve_units_2" msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) turned into $if($eq($number,1),\"a tree\", \"trees\").\"" diff --git a/src/give.c b/src/give.c index ac792da9a..ff1a3ac03 100644 --- a/src/give.c +++ b/src/give.c @@ -371,7 +371,7 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) u2->ship->coast = u1->ship->coast; } else { - return msg_error(u1, ord, 182); + return msg_error(u1, ord, 328); } } } From 4785829d7f304f5f1b43054463f26a2c6fb2b819 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Jan 2020 18:02:42 +0100 Subject: [PATCH 8/9] Typo --- res/translations/messages.de.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 6cb2b413b..af60271ba 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -2778,7 +2778,7 @@ msgid "error322" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Nur Schiffe gleicher Bauart können einen Konvoi bilden.\"" msgid "error328" -msgstr "\"$unit($unit) in $region($region): '$order($command)' - Nur Schiffe an der selbe Küste können einen Konvoi bilden.\"" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Nur Schiffe an der selben Küste können einen Konvoi bilden.\"" msgid "error323" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\"" From 84dfe46ce522d73d9da911e2102686ad557967d4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Jan 2020 20:21:14 +0100 Subject: [PATCH 9/9] Revert "bug 2625 samen werden direkt zu schoesslingen" This reverts commit 4f88bf137edf33de4f56d8c81f5789bfedfe058f. --- src/economy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/economy.c b/src/economy.c index 5da191e50..35e08ade6 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1775,12 +1775,12 @@ static void breedtrees(unit * u, int raw) } if (n > raw) n = raw; - /* Talent * 5% der Samen setzen an (max 100%) */ - planted = n; - if (skill < 20) { - planted = planted * skill / 20; + /* Fuer jeden Samen Talent*5% Erfolgschance. */ + for (i = n; i > 0; i--) { + if (rng_int() % 100 < skill * 5) + planted++; } - rsettrees(r, 0, rtrees(r, 0) + planted); + rsettrees(r, 1, rtrees(r, 1) + planted); /* Alles ok. Abziehen. */ produceexp(u, SK_HERBALISM, u->number);