From 23a7ed59acf29f4f1bb7f421b06573d918a318aa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Sep 2015 17:17:29 +0200 Subject: [PATCH 1/7] backport familiar skill test from 3.7 development --- src/kernel/unit.test.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 7f281fc36..a76b5ea69 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -239,6 +239,33 @@ static void test_default_name(CuTest *tc) { test_cleanup(); } +static void test_skill_familiar(CuTest *tc) { + unit *mag, *fam; + region *r; + + test_cleanup(); + + // setup two units + mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + fam = test_create_unit(mag->faction, test_create_region(0, 0, 0)); + set_level(fam, SK_PERCEPTION, 6); + CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION)); + set_level(mag, SK_PERCEPTION, 6); + CuAssertIntEquals(tc, 6, effskill(mag, SK_PERCEPTION)); + + // make them mage and familiar to each other + CuAssertIntEquals(tc, true, create_newfamiliar(mag, fam)); + + // when they are in the same region, the mage gets half their skill as a bonus + CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION)); + CuAssertIntEquals(tc, 9, effskill(mag, SK_PERCEPTION)); + + // when they are further apart, divide bonus by distance + r = test_create_region(3, 0, 0); + move_unit(fam, r, &r->units); + CuAssertIntEquals(tc, 7, effskill(mag, SK_PERCEPTION)); + test_cleanup(); +} CuSuite *get_unit_suite(void) { @@ -254,5 +281,6 @@ CuSuite *get_unit_suite(void) SUITE_ADD_TEST(suite, test_remove_empty_units_in_region); SUITE_ADD_TEST(suite, test_names); SUITE_ADD_TEST(suite, test_default_name); + SUITE_ADD_TEST(suite, test_skill_familiar); return suite; } From 3a1444f37803021e6c30d1bb0270b10f7272e0f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 14 Sep 2015 17:38:58 +0200 Subject: [PATCH 2/7] backport (failing) at_familiarmage test from 3.7 branch --- src/kernel/unit.test.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index a76b5ea69..d962fee51 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -239,6 +239,31 @@ static void test_default_name(CuTest *tc) { test_cleanup(); } +static void test_skill_hunger(CuTest *tc) { + unit *u; + + test_cleanup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + set_level(u, SK_ARMORER, 6); + set_level(u, SK_SAILING, 6); + fset(u, UFL_HUNGER); + + set_param(&global.parameters, "rules.hunger.reduces_skill", "0"); + CuAssertIntEquals(tc, 6, effskill(u, SK_ARMORER)); + CuAssertIntEquals(tc, 6, effskill(u, SK_SAILING)); + + set_param(&global.parameters, "rules.hunger.reduces_skill", "1"); + CuAssertIntEquals(tc, 3, effskill(u, SK_ARMORER)); + CuAssertIntEquals(tc, 3, effskill(u, SK_SAILING)); + + set_param(&global.parameters, "rules.hunger.reduces_skill", "2"); + CuAssertIntEquals(tc, 3, effskill(u, SK_ARMORER)); + CuAssertIntEquals(tc, 5, effskill(u, SK_SAILING)); + set_level(u, SK_SAILING, 2); + CuAssertIntEquals(tc, 1, effskill(u, SK_SAILING)); + test_cleanup(); +} + static void test_skill_familiar(CuTest *tc) { unit *mag, *fam; region *r; @@ -267,6 +292,29 @@ static void test_skill_familiar(CuTest *tc) { test_cleanup(); } +static void test_age_familiar(CuTest *tc) { + unit *mag, *fam; + + test_cleanup(); + + // setup two units + mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + fam = test_create_unit(mag->faction, test_create_region(0, 0, 0)); + CuAssertPtrEquals(tc, 0, get_familiar(mag)); + CuAssertPtrEquals(tc, 0, get_familiar_mage(fam)); + CuAssertIntEquals(tc, true, create_newfamiliar(mag, fam)); + CuAssertPtrEquals(tc, fam, get_familiar(mag)); + CuAssertPtrEquals(tc, mag, get_familiar_mage(fam)); + a_age(&fam->attribs); + a_age(&mag->attribs); + CuAssertPtrEquals(tc, fam, get_familiar(mag)); + CuAssertPtrEquals(tc, mag, get_familiar_mage(fam)); + set_number(fam, 0); + a_age(&mag->attribs); + CuAssertPtrEquals(tc, 0, get_familiar(mag)); + test_cleanup(); +} + CuSuite *get_unit_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -281,6 +329,8 @@ CuSuite *get_unit_suite(void) SUITE_ADD_TEST(suite, test_remove_empty_units_in_region); SUITE_ADD_TEST(suite, test_names); SUITE_ADD_TEST(suite, test_default_name); + SUITE_ADD_TEST(suite, test_skill_hunger); SUITE_ADD_TEST(suite, test_skill_familiar); + SUITE_ADD_TEST(suite, test_age_familiar); return suite; } From e217a4b55091bcf1dfcbcac090e850e66fe82bb3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 25 Aug 2015 22:50:58 +0200 Subject: [PATCH 3/7] age_unit accidentally returned AT_AGE_REMOVE (caused by a recent change to curse_age) --- src/kernel/curse.c | 2 +- src/util/attrib.c | 2 +- src/util/attrib.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kernel/curse.c b/src/kernel/curse.c index afa8ac2c3..828552a3a 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -131,7 +131,7 @@ int curse_age(attrib * a) else if (c->duration != INT_MAX) { c->duration = _max(0, c->duration - 1); } - return c->duration; + return (c->duration > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } void destroy_curse(curse * c) diff --git a/src/util/attrib.c b/src/util/attrib.c index fb50d8dfc..26869cfee 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -256,7 +256,7 @@ int a_age(attrib ** p) if (a->type->age) { int result = a->type->age(a); assert(result >= 0 || !"age() returned a negative value"); - if (result == 0) { + if (result == AT_AGE_REMOVE) { a_remove(p, a); continue; } diff --git a/src/util/attrib.h b/src/util/attrib.h index cbba4ebf4..c235fd67a 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -90,8 +90,8 @@ extern "C" { #define AT_READ_OK 0 #define AT_READ_FAIL -1 -#define AT_AGE_KEEP 0 /* keep the attribute for another turn */ -#define AT_AGE_REMOVE 1 /* remove the attribute after calling age() */ +#define AT_AGE_REMOVE 0 /* remove the attribute after calling age() */ +#define AT_AGE_KEEP 1 /* keep the attribute for another turn */ #ifdef __cplusplus } From 1028539adb171c2c76779fe8e805a9b765156b52 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Sep 2015 18:29:18 +0200 Subject: [PATCH 4/7] version number increase --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index c494bb5ee..11bf425d6 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 6 -#define VERSION_BUILD 3 +#define VERSION_BUILD 4 From 6162d0f16cdc2504884ba12a0c3c8e7af10dbd9e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 Sep 2015 11:31:43 +0200 Subject: [PATCH 5/7] fixing bug 2141 --- res/core/weapons/mallorncrossbow.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/core/weapons/mallorncrossbow.xml b/res/core/weapons/mallorncrossbow.xml index 8d4a5027b..fb7be26c0 100644 --- a/res/core/weapons/mallorncrossbow.xml +++ b/res/core/weapons/mallorncrossbow.xml @@ -5,8 +5,8 @@ - - + + From 37a8081c9bb9d1029365c8a89b0de93084cbeca9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 2 Oct 2015 11:30:14 +0200 Subject: [PATCH 6/7] handle express issues by filename --- process/compress.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/process/compress.py b/process/compress.py index 95b725fb0..204d580d7 100755 --- a/process/compress.py +++ b/process/compress.py @@ -24,7 +24,13 @@ try: except: print "%s: reports.txt file does not exist" % (argv[0], ) exit(0) - + +extras = [ '../wochenbericht.txt' ] +express='../express-%s.txt' % turn +if os.path.isfile(express): + os.symlink(express, 'express.txt') + extras.append('express.txt') + for line in infile.readlines(): settings = line[:-1].split(":") options = { "turn" : turn} @@ -38,7 +44,6 @@ for line in infile.readlines(): if not options.has_key("reports"): continue reports = options["reports"].split(",") -# reports = reports + [ "iso.cr" ] prefix = "%(turn)s-%(faction)s." % options if options["compression"]=="zip": output = prefix+"zip" @@ -61,7 +66,6 @@ for line in infile.readlines(): if os.path.isfile(output): continue os.system("bzip2 %s" % filename) - extras = [ '../wochenbericht.txt', '../express.txt' ] for extra in extras: if os.path.isfile(extra): files = files + [extra] From 99c385412ac391b4e3ddec777107689979d871d1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 10 Oct 2015 22:50:15 +0200 Subject: [PATCH 7/7] fix crash in mail_cmd when order is missing a message --- src/buildno.h | 2 +- src/laws.c | 8 ++++---- src/laws.test.c | 41 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/buildno.h b/src/buildno.h index 11bf425d6..7eabd81de 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 6 -#define VERSION_BUILD 4 +#define VERSION_BUILD 5 diff --git a/src/laws.c b/src/laws.c index 488f6bbda..aedc34dc9 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2027,7 +2027,7 @@ int mail_cmd(unit * u, struct order *ord) } s = getstrtoken(); - if (!s[0]) { + if (!s || !s[0]) { cmistake(u, ord, 30, MSG_MESSAGE); break; } @@ -2050,7 +2050,7 @@ int mail_cmd(unit * u, struct order *ord) } s = getstrtoken(); - if (!s[0]) { + if (!s || !s[0]) { cmistake(u, ord, 30, MSG_MESSAGE); break; } @@ -2082,7 +2082,7 @@ int mail_cmd(unit * u, struct order *ord) s = getstrtoken(); - if (!s[0]) { + if (!s || !s[0]) { cmistake(u, ord, 30, MSG_MESSAGE); break; } @@ -2111,7 +2111,7 @@ int mail_cmd(unit * u, struct order *ord) s = getstrtoken(); - if (!s[0]) { + if (!s || !s[0]) { cmistake(u, ord, 30, MSG_MESSAGE); break; } diff --git a/src/laws.test.c b/src/laws.test.c index a824f4cab..431c03845 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -970,7 +970,7 @@ static void test_ally_cmd(CuTest *tc) { test_cleanup(); } -void test_nmr_warnings(CuTest *tc) { +static void test_nmr_warnings(CuTest *tc) { faction *f1, *f2; test_cleanup(); set_param(&global.parameters, "nmr.timeout", "3"); @@ -989,6 +989,43 @@ void test_nmr_warnings(CuTest *tc) { test_cleanup(); } +static void test_mail_cmd(CuTest *tc) { + unit *u; + order *ord; + faction *f; + struct locale *lang; + + test_cleanup(); + f = test_create_faction(0); + f->locale = lang = get_or_create_locale("de"); + locale_setstring(lang, parameters[P_UNIT], "EINHEIT"); + init_parameters(lang); + u = test_create_unit(f, test_create_region(0, 0, 0)); + ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s 'Hodor!'", itoa36(u->no)); + mail_cmd(u, ord); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "unitmessage")); + test_cleanup(); +} + +static void test_mail_cmd_no_msg(CuTest *tc) { + unit *u; + order *ord; + faction *f; + struct locale *lang; + + test_cleanup(); + f = test_create_faction(0); + f->locale = lang = get_or_create_locale("de"); + locale_setstring(lang, parameters[P_UNIT], "EINHEIT"); + init_parameters(lang); + u = test_create_unit(f, test_create_region(0, 0, 0)); + ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s", itoa36(u->no)); + mail_cmd(u, ord); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "unitmessage")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30")); + test_cleanup(); +} + CuSuite *get_laws_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -1033,6 +1070,8 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_force_leave_ships); SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean); SUITE_ADD_TEST(suite, test_peasant_luck_effect); + SUITE_ADD_TEST(suite, test_mail_cmd); + SUITE_ADD_TEST(suite, test_mail_cmd_no_msg); (void)test_luck_message; /* disabled, breaks on travis */ return suite;