From aa3397a24f8f59efde168796df416b16c1c72212 Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Sun, 28 Feb 2016 16:02:25 +0100 Subject: [PATCH 01/23] reduced report directory spam --- scripts/tests/common.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 49c0416a8..446a7cf6d 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -674,7 +674,7 @@ function test_laen2() process_orders() init_reports() - write_report(u1.faction) +-- write_report(u1.faction) assert_equal(laen - 2, r:get_resource("laen")) assert_equal(2, u1:get_item("laen")) end @@ -985,13 +985,21 @@ local function find_in_report(f, pattern, extension) return start~=nil end +local function remove_report(faction) + local filetrunk = config.reportpath .. "/" .. get_turn() .. "-" .. itoa36(faction.id) + os.remove(filetrunk .. ".nr") + os.remove(filetrunk .. ".cr") + os.remove(filetrunk .. ".txt") +end + function test_coordinates_no_plane() local r = region.create(0, 0, "mountain") - local f = faction.create("noreply@eressea.de", "human", "de") + local f = faction.create("noplane@eressea.de", "human", "de") local u = unit.create(f, r, 1) init_reports() write_report(f) assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) + remove_report(f) end function test_show_shadowmaster_attacks() @@ -1005,6 +1013,7 @@ function test_show_shadowmaster_attacks() init_reports() write_report(f) assert_false(find_in_report(f, ", ,")) + remove_report(f) end function test_coordinates_named_plane() @@ -1015,6 +1024,7 @@ function test_coordinates_named_plane() init_reports() write_report(f) assert_true(find_in_report(f, r.name .. " %(0,0,Hell%), Berg")) + remove_report(f) end function test_coordinates_unnamed_plane() @@ -1025,6 +1035,7 @@ function test_coordinates_unnamed_plane() init_reports() write_report(f) assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) + remove_report(f) end function test_coordinates_noname_plane() @@ -1035,6 +1046,7 @@ function test_coordinates_noname_plane() init_reports() write_report(f) assert_true(find_in_report(f, r.name .. " %(0,0%), Berg")) + remove_report(f) end function test_lighthouse() @@ -1064,6 +1076,7 @@ function test_lighthouse() assert_false(find_in_report(f, " %(0,0%) %(vom Turm erblickt%)")) assert_false(find_in_report(f, " %(0,1%) %(vom Turm erblickt%)")) assert_false(find_in_report(f, " %(4,0%) %(vom Turm erblickt%)")) + remove_report(f) end module("tests.parser", package.seeall, lunit.testcase) From 11b8d8516792c04673d2fec052e17d397f4c4e26 Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Sun, 28 Feb 2016 16:11:51 +0100 Subject: [PATCH 02/23] fixed reversed logic for demon peasant hunger (bug 2187) renamed config variable hunger.demons to hunger.demons.peasant_tolerance and reversed reversed logic in upkeep.c --- conf/e3/config.json | 4 ++-- conf/e4/config.json | 4 ++-- scripts/tests/e3/rules.lua | 21 ++++++++++++++++++++ src/laws.test.c | 39 ++++++++++++++++++++++++++++++++++++++ src/randenc.c | 2 +- src/upkeep.c | 2 +- 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/conf/e3/config.json b/conf/e3/config.json index 8d575340c..a1fc05b74 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -42,9 +42,9 @@ "nmr.removenewbie": 0, "GiveRestriction": 3, "hunger.long": false, - "hunger.demon.skill": true, "hunger.damage": "1d9+9", - "hunger.demons": true, + "hunger.demons.skill": true, + "hunger.demons.peasant_tolerance": true, "init_spells": 0, "recruit.allow_merge": true, "study.expensivemigrants": true, diff --git a/conf/e4/config.json b/conf/e4/config.json index e23eee261..7584db2a7 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -42,9 +42,9 @@ "nmr.removenewbie": 0, "GiveRestriction": 3, "hunger.long": false, - "hunger.demon.skill": true, "hunger.damage": "1d9+9", - "hunger.demons": true, + "hunger.demons.skill": true, + "hunger.demons.peasant_tolerance"": true, "init_spells": 0, "recruit.allow_merge": true, "study.expensivemigrants": true, diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index a4ee0ea3f..323103e73 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -965,3 +965,24 @@ function test_no_uruk() local f1 = faction.create("noreply@eressea.de", "uruk", "de") assert_equal(f1.race, "orc") end + +function test_bug2187() + set_rule("rules.food.flags", "0") + + local r = region.create(0,0,"plain") + local f = faction.create("2187@eressea.de", "goblin", "de") + local u = unit.create(f, r, 1) + u.race = "demon" + u.hp = u.hp_max * u.number + + r:set_resource("peasant", 0) + u:add_item("money", 500) + + hp = u.hp + process_orders() + assert_equal(hp, u.hp) +-- init_reports() +-- write_report(f) + + set_rule("rules.food.flags", "4") +end \ No newline at end of file diff --git a/src/laws.test.c b/src/laws.test.c index 5be4c7143..a261bf907 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1299,6 +1299,44 @@ static void test_immigration(CuTest * tc) test_cleanup(); } +static void test_demon_hunger(CuTest * tc) +{ + const resource_type *rtype; + region *r; + race *rc; + faction *f; + unit *u; + message* msg; + + test_cleanup(); + test_create_world(); + r = findregion(0, 0); + rc = test_create_race("demon"); + f = test_create_faction(rc); + u = test_create_unit(f, r); + u->hp = 999; + + config_set("hunger.demons.peasant_tolerance", "1"); + + rtype = get_resourcetype(R_SILVER); + i_change(&u->items, rtype->itype, 30); + scale_number(u, 1); + rsetpeasants(r, 0); + + get_food(r); + + CuAssertIntEquals(tc, 20, i_get(u->items, rtype->itype)); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "malnourish")); + + config_set("hunger.demons.peasant_tolerance", "0"); + + get_food(r); + + CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype)); + msg = test_get_last_message(u->faction->msgs); + CuAssertStrEquals(tc, "malnourish", test_get_messagetype(msg)); +} + CuSuite *get_laws_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -1358,6 +1396,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_name_ship); SUITE_ADD_TEST(suite, test_show_without_item); SUITE_ADD_TEST(suite, test_immigration); + SUITE_ADD_TEST(suite, test_demon_hunger); return suite; } diff --git a/src/randenc.c b/src/randenc.c index d948ea270..ae533f9ea 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -963,7 +963,7 @@ static void demon_skillchanges(void) if (fval(u, UFL_HUNGER)) { /* hungry demons only go down, never up in skill */ - int rule_hunger = config_get_int("hunger.demon.skill", 0) != 0; + int rule_hunger = config_get_int("hunger.demons.skill", 0) != 0; if (rule_hunger) { upchance = 0; downchance = 15; diff --git a/src/upkeep.c b/src/upkeep.c index 193c68480..5d114c74e 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -271,7 +271,7 @@ void get_food(region * r) peasantfood = 0; } if (hungry > 0) { - bool demon_hunger = config_get_int("hunger.demons", 0) != 0; + bool demon_hunger = config_get_int("hunger.demons.peasant_tolerance", 0) == 0; if (demon_hunger) { /* demons who don't feed are hungry */ if (hunger(hungry, u)) From e3f27e3571923b0c7514893ec7876df082a2788e Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Sun, 28 Feb 2016 20:34:37 +0100 Subject: [PATCH 03/23] clean up after your tests, young grashopper --- src/laws.test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/laws.test.c b/src/laws.test.c index a261bf907..64f65663c 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1335,6 +1335,8 @@ static void test_demon_hunger(CuTest * tc) CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype)); msg = test_get_last_message(u->faction->msgs); CuAssertStrEquals(tc, "malnourish", test_get_messagetype(msg)); + + test_cleanup(); } CuSuite *get_laws_suite(void) From fcc26bcbf388260cd265da108d66845d26835e72 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Mar 2016 15:06:45 +0100 Subject: [PATCH 04/23] fix broken json --- conf/e4/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/e4/config.json b/conf/e4/config.json index 7584db2a7..12da61937 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -44,7 +44,7 @@ "hunger.long": false, "hunger.damage": "1d9+9", "hunger.demons.skill": true, - "hunger.demons.peasant_tolerance"": true, + "hunger.demons.peasant_tolerance": true, "init_spells": 0, "recruit.allow_merge": true, "study.expensivemigrants": true, From 2c6a39ebb012f74b2184518e4251145df2951330 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Mar 2016 15:25:13 +0100 Subject: [PATCH 05/23] release version 3.8.6 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 191483238..39668bfb9 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 5 +#define VERSION_BUILD 6 From bc8c39f4bb88b5cff5f6cc4942da5297ae4ae5d3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Mar 2016 22:08:54 +0100 Subject: [PATCH 06/23] fix message-crash https://bugs.eressea.de/view.php?id=2199 release version 3.8.7 --- res/core/messages.xml | 12 ++++++------ src/buildno.h | 2 +- src/kernel/xmlreader.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 4044f6de6..9a207ad5f 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -22,9 +22,9 @@ - "$unit($unit) in $region($region): '$order($command)' - Ungültige Zielregion." - "$unit($unit) in $region($region): '$order($command)' - invalid target region." + "$unit($unit) in $region($region): '$order($command)' - Ungültige Zielregion." + "$unit($unit) in $region($region): '$order($command)' - invalid target region." @@ -32,9 +32,9 @@ - "$unit($unit) in $region($region): '$order($command)' - keine Richtung angegeben." - "$unit($unit) in $region($region): '$order($command)' - no direction was specified." + "$unit($unit) in $region($region): '$order($command)' - keine Richtung angegeben." + "$unit($unit) in $region($region): '$order($command)' - no direction was specified." @@ -42,9 +42,9 @@ - "$unit($unit) in $region($region): '$order($command)' - In der Zielregion befinden sich noch Einheiten." - "$unit($unit) in $region($region): '$order($command)' - There are units in the target region." + "$unit($unit) in $region($region): '$order($command)' - In der Zielregion befinden sich noch Einheiten." + "$unit($unit) in $region($region): '$order($command)' - There are units in the target region." diff --git a/src/buildno.h b/src/buildno.h index 39668bfb9..3a7947aaa 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 6 +#define VERSION_BUILD 7 diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 86a49983a..e1e476cd6 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1981,6 +1981,7 @@ static int parse_messages(xmlDocPtr doc) /* strings */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "text", xpath); + assert(result->nodesetval->nodeNr>0); for (k = 0; k != result->nodesetval->nodeNr; ++k) { xmlNodePtr node = result->nodesetval->nodeTab[k]; struct locale *lang; From 30b3cff6574fbeeda4cfcc54c92e955b04180489 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Apr 2016 12:23:51 +0200 Subject: [PATCH 07/23] fix a crash in write_game caused by remove_empty_factions https://bugs.eressea.de/view.php?id=2201 --- src/buildno.h | 2 +- src/kernel/faction.c | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/buildno.h b/src/buildno.h index 3a7947aaa..1b97adf8b 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 7 +#define VERSION_BUILD 8 diff --git a/src/kernel/faction.c b/src/kernel/faction.c index edb8a9e2f..2699e1b09 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -74,9 +74,6 @@ faction *factions; static void free_faction(faction * f) { funhash(f); - if (f->alliance && f->alliance->_leader == f) { - setalliance(f, 0); - } if (f->msgs) { free_messagelist(f->msgs->begin); free(f->msgs); @@ -454,7 +451,7 @@ void destroyfaction(faction ** fp) } #endif - if (f->alliance && f->alliance->_leader == f) { + if (f->alliance) { setalliance(f, 0); } @@ -681,8 +678,6 @@ void remove_empty_factions(void) if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) { log_debug("dead: %s", factionname(f)); destroyfaction(fp); - free_faction(f); - free(f); } else { fp = &(*fp)->next; From b2e8c75c0261d9082e1c9ceadb5368f099fa5fd8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Apr 2016 12:37:26 +0200 Subject: [PATCH 08/23] add a test that should have crashed before my fix. --- src/kernel/faction.test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 19b4da883..10bc0683b 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -13,6 +13,7 @@ #include "monster.h" #include #include +#include #include #include @@ -46,8 +47,10 @@ static void test_remove_empty_factions_alliance(CuTest *tc) { al = makealliance(0, "Hodor"); setalliance(f, al); CuAssertPtrEquals(tc, f, alliance_get_leader(al)); + CuAssertIntEquals(tc, 1, ql_length(al->members)); remove_empty_factions(); CuAssertPtrEquals(tc, 0, al->_leader); + CuAssertIntEquals(tc, 0, ql_length(al->members)); test_cleanup(); } @@ -61,6 +64,9 @@ static void test_remove_empty_factions(CuTest *tc) { f = test_create_faction(0); fno = f->no; remove_empty_factions(); + CuAssertIntEquals(tc, false, f->_alive); + CuAssertPtrEquals(tc, fm, factions); + CuAssertPtrEquals(tc, NULL, fm->next); CuAssertPtrEquals(tc, 0, findfaction(fno)); CuAssertPtrEquals(tc, fm, get_monsters()); test_cleanup(); From 1fa16931195f38c71a5030136bee0ae74ee5afc5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 1 May 2016 13:36:00 +0200 Subject: [PATCH 09/23] test multiple loggers --- src/test_eressea.c | 1 + src/util/CMakeLists.txt | 1 + src/util/log.test.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/util/log.test.c diff --git a/src/test_eressea.c b/src/test_eressea.c index a9b9b941c..a628d9009 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -84,6 +84,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(umlaut); ADD_SUITE(unicode); ADD_SUITE(strings); + ADD_SUITE(log); ADD_SUITE(rng); /* items */ ADD_SUITE(xerewards); diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index a441bcfe7..a34d6cbb0 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -8,6 +8,7 @@ attrib.test.c strings.test.c bsdstring.test.c functions.test.c +log.test.c umlaut.test.c unicode.test.c rng.test.c diff --git a/src/util/log.test.c b/src/util/log.test.c new file mode 100644 index 000000000..017481e48 --- /dev/null +++ b/src/util/log.test.c @@ -0,0 +1,33 @@ +#include + +#include "log.h" + +#include +#include + +void log_string(void *data, int level, const char *module, const char *format, va_list args) { + char *str = (char *)data; + const char *arg = va_arg(args, const char *); + strncpy(str, arg, 32); +} + +static void test_logging(CuTest * tc) +{ + char str1[32]; + char str2[32]; + int id1 = log_create(LOG_CPWARNING, str1, log_string); + int id2 = log_create(LOG_CPWARNING, str2, log_string); + CuAssertTrue(tc, id1!=id2); + log_warning("Hello %s", "World"); + CuAssertStrEquals(tc, str1, "World"); + CuAssertStrEquals(tc, str2, "World"); + log_destroy(id1); + log_destroy(id2); +} + +CuSuite *get_log_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_logging); + return suite; +} From 41277ed5ee97b992122e8e42508669c2f50ba569 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 1 May 2016 13:39:25 +0200 Subject: [PATCH 10/23] prove that logging is broken (new test segfaults) --- src/util/log.c | 20 ++++++++++++++++++-- src/util/log.h | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/util/log.c b/src/util/log.c index 958e26e2f..b5a8ef9fd 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -35,18 +35,34 @@ typedef struct logger { void(*log)(void *data, int level, const char *module, const char *format, va_list args); void *data; int flags; + int id; struct logger *next; } logger; static logger *loggers; +static int log_id; -void log_create(int flags, void *data, log_fun call) { +int log_create(int flags, void *data, log_fun call) { logger *lgr = malloc(sizeof(logger)); lgr->log = call; lgr->flags = flags; lgr->data = data; lgr->next = loggers; loggers = lgr; + return lgr->id = ++log_id; +} + +void log_destroy(int id) { + logger ** lp = &loggers; + while (*lp) { + logger *lg = *lp; + if (lg->id==id) { + *lp = lg->next; + free(lg); + break; + } + lp = &lg->next; + } } #define MAXLENGTH 4096 /* because I am lazy, CP437 output is limited to this many chars */ @@ -138,7 +154,6 @@ static void _log_write(FILE * stream, int codepage, const char *format, va_list if (codepage) { char buffer[MAXLENGTH]; char converted[MAXLENGTH]; - vsnprintf(buffer, sizeof(buffer), format, args); if (cp_convert(buffer, converted, MAXLENGTH, codepage) == 0) { fputs(converted, stream); @@ -177,6 +192,7 @@ static void log_write(int flags, const char *module, const char *format, va_list int level = flags & LOG_LEVELS; if (lg->flags & level) { int dupe = 0; + if (lg->flags & LOG_BRIEF) { dupe = check_dupe(format, level); } diff --git a/src/util/log.h b/src/util/log.h index 8fd8f2a95..d19c4cf9b 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -38,7 +38,8 @@ extern "C" { typedef void(*log_fun)(void *data, int level, const char *module, const char *format, va_list args); - void log_create(int flags, void *data, log_fun call); + int log_create(int flags, void *data, log_fun call); + void log_destroy(int id); void log_to_file(int flags, FILE *out); extern int log_flags; From f24b1c1cdcdea66f83d87150f2819538d7179a72 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 1 May 2016 13:40:01 +0200 Subject: [PATCH 11/23] fix multi-logging --- src/util/log.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/log.c b/src/util/log.c index b5a8ef9fd..cc9fafb92 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -192,13 +192,16 @@ static void log_write(int flags, const char *module, const char *format, va_list int level = flags & LOG_LEVELS; if (lg->flags & level) { int dupe = 0; + va_list copy; + va_copy(copy, args); if (lg->flags & LOG_BRIEF) { dupe = check_dupe(format, level); } if (dupe == 0) { - lg->log(lg->data, level, NULL, format, args); + lg->log(lg->data, level, NULL, format, copy); } + va_end(copy); } } } From 0557aa84acb5c5e5250b68a4a1839d88a4ac76aa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 1 May 2016 13:40:10 +0200 Subject: [PATCH 12/23] release version 3.8.9 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 1b97adf8b..7f9758de0 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 8 +#define VERSION_BUILD 9 From 65a163b4d94498377f0e599b79f5483e4e4dfbec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 5 May 2016 13:48:57 +0200 Subject: [PATCH 13/23] do not seed new factions if there isn't a minimum number of them --- scripts/eressea/autoseed.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index 35c7f0e34..25a799ff4 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -69,12 +69,12 @@ end function autoseed.init() -- local newbs = {} - local num_seeded = 2 + local num_seeded = per_region local start = nil eressea.log.info('autoseed new players') players = read_players() - if players and #players > 0 then + if players and #players >= per_region then local sel eressea.log.info(#players .. ' new players') sel = select_regions(regions(), peasants, trees) From 21ee84dc65019aa5d963ab3dfc298d854256c99e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 May 2016 10:35:23 +0200 Subject: [PATCH 14/23] autoseed barfs on blank lines, catch that case --- scripts/eressea/autoseed.lua | 2 +- src/buildno.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index 25a799ff4..e5cd2e478 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -39,7 +39,7 @@ local function read_players() local str = input:read("*line") if str==nil then break end local email, race, lang = str:match("([^ ]*) ([^ ]*) ([^ ]*)") - if string.char(string.byte(email, 1))~='#' then + if email and string.char(string.byte(email, 1))~='#' then table.insert(players, { race = race, lang = lang, email = email }) end end diff --git a/src/buildno.h b/src/buildno.h index 7f9758de0..a8f4772c5 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 9 +#define VERSION_BUILD 10 From b5a84f07ba6a894b841c398ecb657a83cb54f305 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 17 May 2016 15:45:11 +0200 Subject: [PATCH 15/23] release version 3.8.11 - disable autoseed (endless loop) --- scripts/eressea/e2/init.lua | 2 +- src/buildno.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index ed996c395..5bf6402cb 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -3,7 +3,7 @@ eressea.log.debug("rules for game E2") return { require('eressea'), - require('eressea.autoseed'), +-- require('eressea.autoseed'), require('eressea.xmas'), require('eressea.xmasitems'), require('eressea.wedding'), diff --git a/src/buildno.h b/src/buildno.h index a8f4772c5..7de3cac5f 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 10 +#define VERSION_BUILD 11 From 01035a7325be3257571d7980a7b61f43b775ea71 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 May 2016 20:49:47 +0200 Subject: [PATCH 16/23] password reading from external file is active, but broken. yikes --- src/kernel/save.c | 5 ++--- src/kernel/version.h | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 1619b3622..3930a5993 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1185,15 +1185,14 @@ static char * getpasswd(int fno) { static void read_password(gamedata *data, faction *f) { char name[128]; READ_STR(data->store, name, sizeof(name)); - if (data->version == BADCRYPT_VERSION) { + if (name[0]=='$' && data->version == BADCRYPT_VERSION) { char * pass = getpasswd(f->no); if (pass) { faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT)); free(pass); // TODO: remove this allocation! } else { - free(f->_password); - f->_password = NULL; + log_error("data version is BADCRYPT but %s not in password.txt", itoa36(f->no)); } } else { diff --git a/src/kernel/version.h b/src/kernel/version.h index f758bf0e9..aa0de93ab 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -33,10 +33,13 @@ #define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */ #define OWNER_3_VERSION 349 /* regions store last owner, not last alliance */ #define ATTRIBOWNER_VERSION 351 /* all attrib_type functions know who owns the attribute */ -#define BADCRYPT_VERSION 351 /* passwords are encrypted, poorly */ -#define CRYPT_VERSION 352 /* passwords are encrypted */ -#define RELEASE_VERSION ATTRIBOWNER_VERSION /* current datafile */ +#define BADCRYPT_VERSION 351 /* passwords are broken, 969.dat only. */ +#define NOCRYPT_VERSION 352 /* passwords are plaintext again */ +/* unfinished: */ +#define CRYPT_VERSION 400 /* passwords are encrypted */ + +#define RELEASE_VERSION NOCRYPT_VERSION /* current datafile */ #define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */ -#define MAX_VERSION BADCRYPT_VERSION /* change this if we can need to read the future datafile, and we can do so */ +#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ #define STREAM_VERSION 2 /* internal encoding of binary files */ From cdd7606f024ac08557265fc8ea55b38a0cd832bc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 May 2016 22:38:18 +0200 Subject: [PATCH 17/23] fixing the password saving test. --- src/kernel/save.test.c | 16 ++++++++++------ src/util/log.test.c | 1 + vs2015-build.bat | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index de7f28084..070ee878e 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -231,21 +231,25 @@ static void test_read_password_external(CuTest *tc) { CuAssertPtrNotNull(tc, f->_password); data = gamedata_open(path, "wb"); CuAssertPtrNotNull(tc, data); - WRITE_TOK(data->store, (const char *)f->_password); - WRITE_TOK(data->store, (const char *)f->_password); + WRITE_TOK(data->store, "newpassword"); + WRITE_TOK(data->store, "secret"); + WRITE_TOK(data->store, "$brokenhash"); gamedata_close(data); data = gamedata_open(path, "rb"); CuAssertPtrNotNull(tc, data); + data->version = NOCRYPT_VERSION; + _test_read_password(data, f); + CuAssertStrEquals(tc, "newpassword", f->_password); data->version = BADCRYPT_VERSION; _test_read_password(data, f); - CuAssertPtrEquals(tc, 0, f->_password); + CuAssertStrEquals(tc, "secret", f->_password); F = fopen(pwfile, "wt"); - fprintf(F, "%s:secret\n", itoa36(f->no)); + fprintf(F, "%s:pwfile\n", itoa36(f->no)); fclose(F); _test_read_password(data, f); - CuAssertPtrNotNull(tc, f->_password); + CuAssertStrEquals(tc, "pwfile", f->_password); + CuAssertTrue(tc, checkpasswd(f, "pwfile")); gamedata_close(data); - CuAssertTrue(tc, checkpasswd(f, "secret")); CuAssertIntEquals(tc, 0, remove(path)); CuAssertIntEquals(tc, 0, remove(pwfile)); } diff --git a/src/util/log.test.c b/src/util/log.test.c index 017481e48..9c0e8bb73 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -1,3 +1,4 @@ +#include #include #include "log.h" diff --git a/vs2015-build.bat b/vs2015-build.bat index 82f1f4cd6..6c39659d1 100644 --- a/vs2015-build.bat +++ b/vs2015-build.bat @@ -5,7 +5,9 @@ CD .. SET ERESSEA=%CD% CD %SRCDIR% +IF exist build-vs%VSVERSION% goto HAVEDIR mkdir build-vs%VSVERSION% +:HAVEDIR cd build-vs%VSVERSION% "%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. PAUSE From 2282bdf3d13079ca17869553b2385d5599d7a9cf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 May 2016 23:08:23 +0200 Subject: [PATCH 18/23] release version 3.8.12 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 7de3cac5f..10ef6468d 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 11 +#define VERSION_BUILD 12 From 72d9f8adf0c6f3931a520743aa5910aba431884b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 May 2016 10:58:49 +0200 Subject: [PATCH 19/23] For NMR purposes, count cursed factions like NPCs (i.e. not). fix warnings in log tests log whitespace cleanup --- src/buildno.h | 2 +- src/kernel/save.c | 74 ++++++++++++++++++++++----------------------- src/summary.c | 7 +++-- src/util/log.test.c | 3 ++ 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/buildno.h b/src/buildno.h index 10ef6468d..21a1eaf34 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 12 +#define VERSION_BUILD 13 diff --git a/src/kernel/save.c b/src/kernel/save.c index 3930a5993..b64c9098c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -230,7 +230,7 @@ static faction *factionorders(void) const char *pass = gettoken(token, sizeof(token)); if (!checkpasswd(f, (const char *)pass)) { - log_debug("Invalid password for faction %s\n", itoa36(fid)); + log_debug("Invalid password for faction %s", itoa36(fid)); ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", f->no, pass)); return 0; @@ -244,7 +244,7 @@ static faction *factionorders(void) } else { - log_debug("orders for invalid faction %s\n", itoa36(fid)); + log_debug("orders for invalid faction %s", itoa36(fid)); } return f; } @@ -403,14 +403,14 @@ void read_items(struct storage *store, item ** ilist) itype = it_find(ibuf); READ_INT(store, &i); if (i <= 0) { - log_error("data contains an entry with %d %s\n", i, resourcename(itype->rtype, NMF_PLURAL)); + log_error("data contains an entry with %d %s", i, resourcename(itype->rtype, NMF_PLURAL)); } else { if (itype && itype->rtype) { i_change(ilist, itype, i); } else { - log_error("data contains unknown item type %s.\n", ibuf); + log_error("data contains unknown item type %s.", ibuf); } assert(itype && itype->rtype); } @@ -488,7 +488,7 @@ static int resolve_owner(variant id, void *address) if (id.i != 0) { f = findfaction(id.i); if (f == NULL) { - log_error("region has an invalid owner (%s)\n", itoa36(id.i)); + log_error("region has an invalid owner (%s)", itoa36(id.i)); } } owner->owner = f; @@ -594,13 +594,13 @@ unit *read_unit(struct gamedata *data) READ_INT(data->store, &n); if (n <= 0) { - log_error("data contains invalid unit %d.\n", n); + log_error("data contains invalid unit %d.", n); assert(n > 0); return 0; } u = findunit(n); if (u) { - log_error("reading unit %s that already exists.\n", unitname(u)); + log_error("reading unit %s that already exists.", unitname(u)); while (u->attribs) { a_remove(&u->attribs, u->attribs); } @@ -627,7 +627,7 @@ unit *read_unit(struct gamedata *data) ++u->faction->no_units; } else { - log_error("unit %s has faction == NULL\n", itoa36(u->no)); + log_error("unit %s has faction == NULL", itoa36(u->no)); return 0; } @@ -676,7 +676,7 @@ unit *read_unit(struct gamedata *data) } } else { - log_error("read_unit: unit in unkown building '%s'\n", itoa36(n)); + log_error("read_unit: unit in unkown building '%s'", itoa36(n)); } } @@ -690,7 +690,7 @@ unit *read_unit(struct gamedata *data) } } else { - log_error("read_unit: unit in unkown ship '%s'\n", itoa36(n)); + log_error("read_unit: unit in unkown ship '%s'", itoa36(n)); } } @@ -701,7 +701,7 @@ unit *read_unit(struct gamedata *data) if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_anon()) { /* if this rule is broken, then fix broken units */ u->flags -= UFL_ANON_FACTION; - log_warning("%s was anonymous.\n", unitname(u)); + log_warning("%s was anonymous.", unitname(u)); } /* Persistente Befehle einlesen */ free_orders(&u->orders); @@ -719,11 +719,11 @@ unit *read_unit(struct gamedata *data) ord = NULL; } else if (p == MAXPERSISTENT) { - log_info("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT); + log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT); } } else if (n == MAXORDERS) { - log_info("%s had %d or more orders\n", unitname(u), MAXORDERS); + log_info("%s had %d or more orders", unitname(u), MAXORDERS); } if (ord != NULL) free_order(ord); @@ -751,7 +751,7 @@ unit *read_unit(struct gamedata *data) read_items(data->store, &u->items); READ_INT(data->store, &u->hp); if (u->hp < u->number) { - log_error("Einheit %s hat %u Personen, und %u Trefferpunkte\n", itoa36(u->no), u->number, u->hp); + log_error("Einheit %s hat %u Personen, und %u Trefferpunkte", itoa36(u->no), u->number, u->hp); u->hp = u->number; } @@ -787,7 +787,7 @@ void write_unit(struct gamedata *data, const unit * u) writeorder(data, ord, u->faction->locale); } else { - log_info("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT); + log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT); break; } } @@ -800,7 +800,7 @@ void write_unit(struct gamedata *data, const unit * u) writeorder(data, ord, u->faction->locale); } else { - log_info("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT); + log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT); break; } } @@ -825,7 +825,7 @@ void write_unit(struct gamedata *data, const unit * u) write_items(data->store, u->items); WRITE_SECTION(data->store); if (u->hp == 0 && u_race(u)!= get_race(RC_SPELL)) { - log_error("unit %s has 0 hitpoints, adjusting.\n", itoa36(u->no)); + log_error("unit %s has 0 hitpoints, adjusting.", itoa36(u->no)); ((unit *)u)->hp = u->number; } WRITE_INT(data->store, u->hp); @@ -876,7 +876,7 @@ static region *readregion(struct gamedata *data, int x, int y) READ_STR(data->store, name, sizeof(name)); terrain = get_terrain(name); if (terrain == NULL) { - log_error("Unknown terrain '%s'\n", name); + log_error("Unknown terrain '%s'", name); assert(!"unknown terrain"); } r->terrain = terrain; @@ -895,19 +895,19 @@ static region *readregion(struct gamedata *data, int x, int y) READ_INT(data->store, &i); if (i < 0) { - log_error("number of trees in %s is %d.\n", regionname(r, NULL), i); + log_error("number of trees in %s is %d.", regionname(r, NULL), i); i = 0; } rsettrees(r, 0, i); READ_INT(data->store, &i); if (i < 0) { - log_error("number of young trees in %s is %d.\n", regionname(r, NULL), i); + log_error("number of young trees in %s is %d.", regionname(r, NULL), i); i = 0; } rsettrees(r, 1, i); READ_INT(data->store, &i); if (i < 0) { - log_error("number of seeds in %s is %d.\n", regionname(r, NULL), i); + log_error("number of seeds in %s is %d.", regionname(r, NULL), i); i = 0; } rsettrees(r, 2, i); @@ -923,7 +923,7 @@ static region *readregion(struct gamedata *data, int x, int y) res = malloc(sizeof(rawmaterial)); res->type = rmt_find(name); if (res->type == NULL) { - log_error("invalid resourcetype %s in data.\n", name); + log_error("invalid resourcetype %s in data.", name); } assert(res->type != NULL); READ_INT(data->store, &n); @@ -1124,7 +1124,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co if (bookp) { sp = find_spell(spname); if (!sp) { - log_error("read_spells: could not find spell '%s'\n", spname); + log_error("read_spells: could not find spell '%s'", spname); } } if (global.data_version >= SPELLBOOK_VERSION) { @@ -1185,7 +1185,7 @@ static char * getpasswd(int fno) { static void read_password(gamedata *data, faction *f) { char name[128]; READ_STR(data->store, name, sizeof(name)); - if (name[0]=='$' && data->version == BADCRYPT_VERSION) { + if (name[0] == '$' && data->version == BADCRYPT_VERSION) { char * pass = getpasswd(f->no); if (pass) { faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT)); @@ -1274,7 +1274,7 @@ faction *readfaction(struct gamedata * data) READ_STR(data->store, name, sizeof(name)); if (set_email(&f->email, name) != 0) { - log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), name); + log_warning("Invalid email address for faction %s: %s", itoa36(f->no), name); set_email(&f->email, ""); } @@ -1291,7 +1291,7 @@ faction *readfaction(struct gamedata * data) READ_STR(data->store, name, sizeof(name)); f->race = rc_find(name); if (!f->race) { - log_error("unknown race in data: %s\n", name); + log_error("unknown race in data: %s", name); } assert(f->race); READ_INT(data->store, &n); @@ -1456,7 +1456,7 @@ int readgame(const char *filename, bool backup) size_t sz; init_locales(); - log_debug("- reading game data from %s\n", filename); + log_debug("- reading game data from %s", filename); sprintf(path, "%s/%s", datapath(), filename); if (backup) { @@ -1509,7 +1509,7 @@ int readgame(const char *filename, bool backup) a_read(&store, &global.attribs, NULL); READ_INT(&store, &turn); global.data_turn = turn; - log_debug(" - reading turn %d\n", turn); + log_debug(" - reading turn %d", turn); rng_init(turn); READ_INT(&store, &nread); /* max_unique_id = ignore */ READ_INT(&store, &nextborder); @@ -1528,7 +1528,7 @@ int readgame(const char *filename, bool backup) pl = calloc(1, sizeof(plane)); } else { - log_warning("the plane with id=%d already exists.\n", id); + log_warning("the plane with id=%d already exists.", id); } pl->id = id; READ_STR(&store, name, sizeof(name)); @@ -1550,7 +1550,7 @@ int readgame(const char *filename, bool backup) } else { log_error( - ("This datafile contains watchers, but we are unable to read them\n")); + ("This datafile contains watchers, but we are unable to read them.")); } } } @@ -1711,10 +1711,10 @@ int readgame(const char *filename, bool backup) binstore_done(&store); fstream_done(&strm); /* Unaufgeloeste Zeiger initialisieren */ - log_debug("fixing unresolved references.\n"); + log_debug("fixing unresolved references."); resolve(); - log_debug("updating area information for lighthouses.\n"); + log_debug("updating area information for lighthouses."); for (r = regions; r; r = r->next) { if (r->flags & RF_LIGHTHOUSE) { building *b; @@ -1722,7 +1722,7 @@ int readgame(const char *filename, bool backup) update_lighthouse(b); } } - log_debug("marking factions as alive.\n"); + log_debug("marking factions as alive."); for (f = factions; f; f = f->next) { if (f->flags & FFL_NPC) { f->_alive = true; @@ -1731,7 +1731,7 @@ int readgame(const char *filename, bool backup) int no = 666; while (findfaction(no)) ++no; - log_warning("renum(monsters, %d)\n", no); + log_warning("renum(monsters, %d)", no); renumber_faction(f, no); } } @@ -1743,7 +1743,7 @@ int readgame(const char *filename, bool backup) faction *f = u->faction; int skl = effskill(u, SK_MAGIC, 0); if (f->magiegebiet == M_GRAY) { - log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]); + log_error("faction %s had magic=gray, fixing (%s)", factionname(f), magic_school[mage->magietyp]); f->magiegebiet = mage->magietyp; } if (f->max_spelllevel < skl) { @@ -1769,7 +1769,7 @@ int readgame(const char *filename, bool backup) if (loadplane || maxregions >= 0) { remove_empty_factions(); } - log_debug("Done loading turn %d.\n", turn); + log_debug("Done loading turn %d.", turn); return 0; } @@ -1861,7 +1861,7 @@ int writegame(const char *filename) WRITE_INT(&store, n); WRITE_SECTION(&store); - log_debug(" - Schreibe %d Parteien...\n", n); + log_debug(" - Schreibe %d Parteien...", n); for (f = factions; f; f = f->next) { if (fval(f, FFL_NPC)) { clear_npc_orders(f); diff --git a/src/summary.c b/src/summary.c index 093481c76..824b86238 100644 --- a/src/summary.c +++ b/src/summary.c @@ -89,13 +89,16 @@ int update_nmrs(void) if (fval(f, FFL_ISNEW)) { ++newplayers; } - else if (!fval(f, FFL_NOIDLEOUT)) { + else if (!fval(f, FFL_NOIDLEOUT|FFL_CURSED)) { int nmr = turn - f->lastorders + 1; if (nmr < 0 || nmr > NMRTimeout()) { - log_error("faction %s has %d NMRS\n", factionid(f), nmr); + log_error("faction %s has %d NMR", factionid(f), nmr); nmr = _max(0, nmr); nmr = _min(nmr, NMRTimeout()); } + if (nmr > 0) { + log_debug("faction %s has %d NMR", factionid(f), nmr); + } ++nmrs[nmr]; } } diff --git a/src/util/log.test.c b/src/util/log.test.c index 9c0e8bb73..6c2a89846 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -9,6 +9,9 @@ void log_string(void *data, int level, const char *module, const char *format, va_list args) { char *str = (char *)data; const char *arg = va_arg(args, const char *); + unused_arg(format); + unused_arg(module); + unused_arg(level); strncpy(str, arg, 32); } From dbaad4c403cd50573dcb0977981f6d0ab7921910 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jul 2016 10:59:50 +0200 Subject: [PATCH 20/23] release version 3.8.14 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 21a1eaf34..874106784 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 13 +#define VERSION_BUILD 14 From ca7b250c46d3c762fd02de34499f5343f1dfa2ca Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jul 2016 11:02:21 +0200 Subject: [PATCH 21/23] otherfaction can be null if not f->alive --- src/creport.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/creport.c b/src/creport.c index 186afab4d..591061f94 100644 --- a/src/creport.c +++ b/src/creport.c @@ -795,10 +795,8 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "%d;Verkleidung\n", sf->no); if (fval(u, UFL_ANON_FACTION)) stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION))); - if (otherfaction) { - if (otherfaction != u->faction) { - stream_printf(out, "%d;Anderepartei\n", otherfaction->no); - } + if (otherfaction && otherfaction != u->faction) { + stream_printf(out, "%d;Anderepartei\n", otherfaction->no); } mage = get_familiar_mage(u); if (mage) { @@ -819,11 +817,9 @@ void cr_output_unit(stream *out, const region * r, const faction * f, if (sf == f) { stream_printf(out, "1;Verraeter\n"); } - if (a_otherfaction) { - if (otherfaction != u->faction) { - if (alliedunit(u, f, HELP_FSTEALTH)) { - stream_printf(out, "%d;Anderepartei\n", otherfaction->no); - } + if (otherfaction && otherfaction != u->faction) { + if (alliedunit(u, f, HELP_FSTEALTH)) { + stream_printf(out, "%d;Anderepartei\n", otherfaction->no); } } } From ae3e5b8088f492c70f0cedb47da9050560df6c9f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Aug 2016 23:27:23 +0200 Subject: [PATCH 22/23] release version 3.8.15 --- src/attributes/otherfaction.c | 3 +-- src/buildno.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/attributes/otherfaction.c b/src/attributes/otherfaction.c index 83196f959..16682d8f8 100644 --- a/src/attributes/otherfaction.c +++ b/src/attributes/otherfaction.c @@ -75,8 +75,7 @@ faction *visible_faction(const faction * f, const unit * u) attrib *a = a_find(u->attribs, &at_otherfaction); if (a) { faction *fv = get_otherfaction(a); - assert(fv != NULL); /* fv should never be NULL! */ - return fv; + if (fv) return fv; } } return u->faction; diff --git a/src/buildno.h b/src/buildno.h index 874106784..204ec9beb 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 14 +#define VERSION_BUILD 15 From 44b6a87649ef19710e0e68afeee4e72eb328d756 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 7 Aug 2016 00:40:10 +0200 Subject: [PATCH 23/23] death by NMR was broken, because I can't write loops good. --- src/buildno.h | 2 +- src/kernel/faction.c | 2 +- src/kernel/unit.c | 2 +- src/laws.c | 23 ++++++++++++++--------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/buildno.h b/src/buildno.h index 204ec9beb..c84827cec 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 15 +#define VERSION_BUILD 16 diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 2699e1b09..c7f9498b8 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -387,7 +387,7 @@ void destroyfaction(faction ** fp) else { region *r = u->region; - if (!fval(r->terrain, SEA_REGION) && !!playerrace(u_race(u))) { + if (r->land && !!playerrace(u_race(u))) { const race *rc = u_race(u); int m = rmoney(r); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 04d113033..e4f0b1d44 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -334,7 +334,7 @@ int gift_items(unit * u, int flags) item *itm = *itm_p; if (flags & GIFT_PEASANTS) { - if (!fval(u->region->terrain, SEA_REGION)) { + if (u->region->land) { if (itm->type->rtype == rsilver) { rsetmoney(r, rmoney(r) + itm->number); itm->number = 0; diff --git a/src/laws.c b/src/laws.c index 1e1fc33ad..f6cca67a6 100755 --- a/src/laws.c +++ b/src/laws.c @@ -1221,23 +1221,28 @@ static void nmr_death(faction * f) static void remove_idle_players(void) { faction **fp; + int timeout = NMRTimeout(); log_info(" - beseitige Spieler, die sich zu lange nicht mehr gemeldet haben..."); for (fp = &factions; *fp;) { faction *f = *fp; - if (fval(f, FFL_NOIDLEOUT)) { - f->lastorders = turn; - } - if (NMRTimeout() > 0 && turn - f->lastorders >= NMRTimeout()) { + + if (timeout > 0 && turn - f->lastorders >= timeout) { nmr_death(f); destroyfaction(fp); - } else if (turn != f->lastorders) { - char info[256]; - sprintf(info, "%d Einheiten, %d Personen, %d Silber", - f->no_units, f->num_total, f->money); + } else { + if (fval(f, FFL_NOIDLEOUT)) { + f->lastorders = turn; + fp = &f->next; + } + else if (turn != f->lastorders) { + char info[256]; + sprintf(info, "%d Einheiten, %d Personen, %d Silber", + f->no_units, f->num_total, f->money); + } + fp = &f->next; } - fp = &f->next; } log_info(" - beseitige Spieler, die sich nach der Anmeldung nicht gemeldet haben...");