From 095e3d39ce50db92396d474b736d434fd827db0d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Feb 2020 15:24:36 +0100 Subject: [PATCH 1/3] Bug 2637: Monster sollen sich nicht parteitarnen. --- src/monsters.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/monsters.c b/src/monsters.c index 08b65ce3a..cd6efc558 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -44,6 +44,7 @@ /* attributes includes */ #include +#include #include #include @@ -772,6 +773,7 @@ void plan_monsters(faction * f) if (fval(u, UFL_ANON_FACTION)) { u->flags &= ~UFL_ANON_FACTION; } + a_removeall(&u->attribs, &at_otherfaction); if (rc->splitsize < 10) { /* hermit-type monsters eat each other */ From 5ee57514752ff6d8197040009e7f986acf2a6c2c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 20 Feb 2020 21:09:04 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Keine=20Befehle=20l=C3=B6schen,=20ist=20nic?= =?UTF-8?q?ht=20n=C3=B6tig=20und=20verwirtr=20nur.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ src/kernel/unit.c | 2 +- src/laws.c | 7 ------- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 98b1e8e0a..cccbf2c32 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ tests/data/185.dat /cutest/ /critbit/ *.mo +/CMakeSettings.json +/.vs diff --git a/src/kernel/unit.c b/src/kernel/unit.c index e9ec8e657..0e22e8d2d 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -647,7 +647,7 @@ void leave_building(unit * u) { building * b = u->building; - u->building = 0; + u->building = NULL; if (b->_owner == u) { building_update_owner(b); assert(b->_owner != u); diff --git a/src/laws.c b/src/laws.c index 97d9b774f..b00da467c 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1226,13 +1226,6 @@ void do_enter(struct region *r, bool is_final_attempt) } } if (ulast != NULL) { - /* Wenn wir hier angekommen sind, war der Befehl - * erfolgreich und wir loeschen ihn, damit er im - * zweiten Versuch nicht nochmal ausgefuehrt wird. */ - *ordp = ord->next; - ord->next = NULL; - free_order(ord); - if (ulast != u) { /* put u behind ulast so it's the last unit in the building */ *uptr = u->next; From e5e936acc6bd0b361ba71e1897cb692ffbac1795 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 21 Feb 2020 21:12:19 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Bug=202640:=20LERNE=20AUTO=20sollte=20nicht?= =?UTF-8?q?=20alle=20Einheiten=20zu=20Lehrern=20delegieren.=20Fixt=20den?= =?UTF-8?q?=20konkreten=20Bug,=20f=C3=BChlt=20sich=20aber=20immer=20noch?= =?UTF-8?q?=20nach=20einemn=20Spezialfall=20an=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/automate.c | 2 +- src/automate.test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/automate.c b/src/automate.c index 2c9a94ad0..960c67a4c 100644 --- a/src/automate.c +++ b/src/automate.c @@ -96,7 +96,7 @@ void autostudy_run(scholar scholars[], int nscholars) int mint; ts += scholars[se].u->number; /* count total scholars */ mint = (ts + 10) / 11; /* need a minimum of ceil(ts/11) teachers */ - for (; mint > tt && si != nscholars; ++si) { + for (; mint > tt && si != nscholars - 1; ++si) { tt += scholars[si].u->number; } } diff --git a/src/automate.test.c b/src/automate.test.c index 5508cce88..adb4c1da7 100644 --- a/src/automate.test.c +++ b/src/automate.test.c @@ -110,6 +110,40 @@ static void test_autostudy_run_twoteachers(CuTest *tc) { test_teardown(); } +/** + * Reproduce Bug 2640 + */ +static void test_autostudy_run_bigunit(CuTest *tc) { + scholar scholars[4]; + int nscholars; + unit *u1, *u2, *ulist; + faction *f; + region *r; + skill_t skill; + + test_setup(); + r = test_create_plain(0, 0); + f = test_create_faction(NULL); + u1 = test_create_unit(f, r); + set_number(u1, 20); + set_level(u1, SK_ENTERTAINMENT, 16); + u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]); + u2 = test_create_unit(f, r); + set_number(u2, 1000); + set_level(u2, SK_ENTERTAINMENT, 10); + u2->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]); + + ulist = r->units; + CuAssertIntEquals(tc, 2, nscholars = autostudy_init(scholars, 4, &ulist, &skill)); + CuAssertPtrEquals(tc, NULL, ulist); + autostudy_run(scholars, nscholars); + CuAssertIntEquals(tc, SK_ENTERTAINMENT, skill); + CuAssertIntEquals(tc, 0, scholars[0].learn); + CuAssertIntEquals(tc, 200, scholars[1].learn); + + test_teardown(); +} + static void test_autostudy_run(CuTest *tc) { scholar scholars[4]; int nscholars; @@ -325,6 +359,7 @@ CuSuite *get_automate_suite(void) SUITE_ADD_TEST(suite, test_autostudy_run_noteachers); SUITE_ADD_TEST(suite, test_autostudy_run_teachers_learn); SUITE_ADD_TEST(suite, test_autostudy_run_twoteachers); + SUITE_ADD_TEST(suite, test_autostudy_run_bigunit); SUITE_ADD_TEST(suite, test_autostudy_run_skilldiff); return suite; }