From 43c2c74d75399f3bc50febff133f423fd262b17f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 13 Aug 2016 10:13:22 +0200 Subject: [PATCH 1/5] correct the list of glacier herbs. this will fix newly created glaciers only. there are several bad glaciers in E2, this commit is not repairing them. https://bugs.eressea.de/view.php?id=2220 --- conf/e2/terrains.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/e2/terrains.json b/conf/e2/terrains.json index a96023ef8..d26c656ea 100644 --- a/conf/e2/terrains.json +++ b/conf/e2/terrains.json @@ -141,7 +141,7 @@ }, "glacier": { "size": 100, - "herbs": [ "h15", "h16", "h17" ], + "herbs": [ "h18", "h19", "h20" ], "seed": 2, "road": 250, "flags": [ "arctic", "land", "walk", "sail", "fly" ], From 3e47f02fc2599fbfe38656e7cfbe98c50bd1c5be Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 9 Aug 2016 18:28:15 +0200 Subject: [PATCH 2/5] coverity CID 141509 Unchecked return value from library Conflicts: src/util/log.c --- src/util/log.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/util/log.c b/src/util/log.c index cc9fafb92..36e81a5df 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -102,21 +102,29 @@ void log_rotate(const char *filename, int maxindex) assert(strlen(filename) < sizeof(buffer[0]) - 4); sprintf(buffer[dst], "%s.%d", filename, maxindex); -#ifdef HAVE_UNISTD_H - /* make sure we don't overwrite an existing file (hard links) */ - unlink(buffer[dst]); -#endif + if (remove(buffer[dst]) != 0) { + if (errno != ENOENT) { + fprintf(stderr, "log rotate %s: %d %s", buffer[dst], errno, strerror(errno)); + } + errno = 0; + } + while (maxindex > 0) { - int err, src = 1 - dst; + int src = 1 - dst; sprintf(buffer[src], "%s.%d", filename, --maxindex); - err = rename(buffer[src], buffer[dst]); - if (err != 0) { - log_debug("log rotate %s: %s", buffer[dst], strerror(errno)); + if (rename(buffer[src], buffer[dst]) != 0) { + if (errno != ENOENT) { + fprintf(stderr, "log rotate %s: %d %s", buffer[dst], errno, strerror(errno)); + } + errno = 0; } dst = src; } if (rename(filename, buffer[dst]) != 0) { - log_debug("log rotate %s: %s", buffer[dst], strerror(errno)); + if (errno != ENOENT) { + fprintf(stderr, "log rotate %s: %d %s", buffer[dst], errno, strerror(errno)); + } + errno = 0; } } From a858ceda76b1af603a842f0c8991faf2d57a378d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 31 Aug 2016 18:15:54 +0200 Subject: [PATCH 3/5] release version 3.9.1 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index f9749c33c..505d1d571 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 9 -#define VERSION_BUILD 0 +#define VERSION_BUILD 1 From fed399042d9789d53a0266dfee22577fcc5a4f5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 1 Sep 2016 20:40:07 +0100 Subject: [PATCH 4/5] fix piracy order aliasing issue #549 https://bugs.eressea.de/view.php?id=2233 piracy_cmd always works on u->thisorder, does not need an argument. --- src/move.c | 2 +- src/piracy.c | 14 ++++++++------ src/piracy.h | 2 +- src/piracy.test.c | 49 +++++++++++++++++------------------------------ 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/move.c b/src/move.c index 09f3c2b3f..5de13a2a4 100644 --- a/src/move.c +++ b/src/move.c @@ -2482,7 +2482,7 @@ static void move_pirates(void) unit *u = *up; if (!fval(u, UFL_NOTMOVING) && getkeyword(u->thisorder) == K_PIRACY) { - piracy_cmd(u, u->thisorder); + piracy_cmd(u); fset(u, UFL_LONGACTION | UFL_NOTMOVING); } diff --git a/src/piracy.c b/src/piracy.c index 1a556f92f..8af0b899e 100644 --- a/src/piracy.c +++ b/src/piracy.c @@ -115,8 +115,9 @@ direction_t find_piracy_target(unit *u, int *il) { return NODIRECTION; } -void piracy_cmd(unit * u, order *ord) +void piracy_cmd(unit * u) { + order *ord; region *r = u->region; ship *sh = u->ship, *sh2; direction_t target_dir; @@ -127,11 +128,11 @@ void piracy_cmd(unit * u, order *ord) int saff = 0; int *il; - if (!validate_pirate(u, ord)) { + if (!validate_pirate(u, u->thisorder)) { return; } - il = parse_ids(ord); + il = parse_ids(u->thisorder); /* Feststellen, ob schon ein anderer alliierter Pirat ein * Ziel gefunden hat. */ @@ -201,11 +202,12 @@ void piracy_cmd(unit * u, order *ord) "ship unit region dir", sh, u, r, target_dir)); /* Befehl konstruieren */ - set_order(&u->thisorder, create_order(K_MOVE, u->faction->locale, "%s", - LOC(u->faction->locale, directions[target_dir]))); + // TODO: why change u->thisorder? + // FIXME: when u->thisorder == ord, set_order calls free, destroys both. + ord = create_order(K_MOVE, u->faction->locale, "%s", LOC(u->faction->locale, directions[target_dir])); /* Bewegung ausführen */ - init_order(u->thisorder); + init_order(ord); move_cmd(u, ord); } diff --git a/src/piracy.h b/src/piracy.h index b74fbd509..14b4a4805 100644 --- a/src/piracy.h +++ b/src/piracy.h @@ -11,7 +11,7 @@ extern "C" { struct order; struct region; - void piracy_cmd(struct unit * u, struct order *ord); + void piracy_cmd(struct unit * u); void age_piracy(struct region *r); #ifdef __cplusplus diff --git a/src/piracy.test.c b/src/piracy.test.c index 1c266fd47..affb6f5c4 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -32,7 +32,7 @@ static void setup_piracy(void) { } static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const char *p_shiptype, - order **ord, unit **victim, int v_r_flags, const char *v_shiptype) { + unit **victim, int v_r_flags, const char *v_shiptype) { terrain_type *vterrain; ship_type *st_boat = NULL; race *rc; @@ -67,16 +67,13 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha } f->locale = get_or_create_locale("de"); - *ord = create_order(K_PIRACY, f->locale, "%s", itoa36((*victim)->faction->no)); - assert(*ord); - + (*pirate)->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36((*victim)->faction->no)); } static void test_piracy_cmd(CuTest * tc) { faction *f; region *r; unit *u, *u2; - order *ord; terrain_type *t_ocean; ship_type *st_boat; @@ -93,10 +90,9 @@ static void test_piracy_cmd(CuTest * tc) { u_set_ship(u, test_create_ship(u->region, st_boat)); assert(f && u); f->locale = get_or_create_locale("de"); - ord = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no)); - assert(ord); + u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no)); - piracy_cmd(u, ord); + piracy_cmd(u); CuAssertPtrEquals(tc, 0, u->thisorder); CuAssertTrue(tc, u->region != r); CuAssertPtrEquals(tc, u2->region, u->region); @@ -104,7 +100,6 @@ static void test_piracy_cmd(CuTest * tc) { CuAssertPtrNotNullMsg(tc, "successful PIRACY sets attribute", r->attribs); // FIXME: this is testing implementation, not interface CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(f->msgs, "piratesawvictim")); CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(f->msgs, "shipsail")); - free_order(ord); test_cleanup(); } @@ -113,7 +108,6 @@ static void test_piracy_cmd_errors(CuTest * tc) { race *r; faction *f; unit *u, *u2; - order *ord; ship_type *st_boat; test_cleanup(); @@ -123,15 +117,15 @@ static void test_piracy_cmd_errors(CuTest * tc) { r = test_create_race("pirates"); u = test_create_unit(f = test_create_faction(r), test_create_region(0, 0, get_or_create_terrain("ocean"))); f->locale = get_or_create_locale("de"); - ord = create_order(K_PIRACY, f->locale, ""); - assert(u && ord); + u->thisorder = create_order(K_PIRACY, f->locale, ""); + assert(u && u->thisorder); - piracy_cmd(u, ord); + piracy_cmd(u); CuAssertPtrNotNullMsg(tc, "must be on a ship for PIRACY", test_find_messagetype(f->msgs, "error144")); test_clear_messages(f); fset(r, RCF_SWIM); - piracy_cmd(u, ord); + piracy_cmd(u); CuAssertPtrEquals_Msg(tc, "swimmers are pirates", 0, test_find_messagetype(f->msgs, "error144")); CuAssertPtrEquals_Msg(tc, "swimmers are pirates", 0, test_find_messagetype(f->msgs, "error146")); freset(r, RCF_SWIM); @@ -146,40 +140,37 @@ static void test_piracy_cmd_errors(CuTest * tc) { u_set_ship(u2, u->ship); test_clear_messages(f); - piracy_cmd(u2, ord); + piracy_cmd(u2); CuAssertPtrNotNullMsg(tc, "must be owner for PIRACY", test_find_messagetype(f->msgs, "error146")); test_clear_messages(f); - piracy_cmd(u, ord); + piracy_cmd(u); CuAssertPtrNotNullMsg(tc, "must specify target for PIRACY", test_find_messagetype(f->msgs, "piratenovictim")); - free_order(ord); + CuAssertPtrNotNull(tc, u->thisorder); test_cleanup(); } static void test_piracy_cmd_walking(CuTest * tc) { unit *pirate, *victim; - order *ord; region *r; test_cleanup(); - setup_pirate(&pirate, 0, 0, NULL, &ord, &victim, SWIM_INTO | SEA_REGION, "boat"); + setup_pirate(&pirate, 0, 0, NULL, &victim, SWIM_INTO | SEA_REGION, "boat"); /* fset(rc, RCF_SWIM); */ r = pirate->region; - piracy_cmd(pirate, ord); - CuAssertPtrEquals(tc, 0, pirate->thisorder); + piracy_cmd(pirate); + CuAssertPtrNotNull(tc, pirate->thisorder); CuAssertTrue(tc, pirate->region == r); CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(pirate->faction->msgs, "error144")); - free_order(ord); test_cleanup(); } static void test_piracy_cmd_land_to_land(CuTest * tc) { unit *u; - order *ord; region *r; faction *f; int target; @@ -205,34 +196,30 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) { u = test_create_unit(f, r); u->ship = test_create_ship(r, stype); set_level(u, SK_SAILING, u->ship->type->sumskill); - ord = create_order(K_PIRACY, f->locale, "%s", itoa36(target)); + u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(target)); - piracy_cmd(u, ord); + piracy_cmd(u); CuAssertPtrEquals(tc, 0, u->thisorder); CuAssertPtrEquals(tc, r, u->region); - // TODO check message - free_order(ord); test_cleanup(); } static void test_piracy_cmd_swimmer(CuTest * tc) { unit *pirate, *victim; - order *ord; region *r; test_cleanup(); - setup_pirate(&pirate, 0, RCF_SWIM, NULL, &ord, &victim, SWIM_INTO | SEA_REGION, "boat"); + setup_pirate(&pirate, 0, RCF_SWIM, NULL, &victim, SWIM_INTO | SEA_REGION, "boat"); r = pirate->region; - piracy_cmd(pirate, ord); + piracy_cmd(pirate); CuAssertPtrEquals(tc, 0, pirate->thisorder); CuAssertTrue(tc, pirate->region != r); CuAssertPtrEquals(tc, victim->region, pirate->region); CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(pirate->faction->msgs, "piratesawvictim")); CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(pirate->faction->msgs, "travel")); - free_order(ord); test_cleanup(); } From a75b5917846a8e575a4f9163d62c0d36bf156b69 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 1 Sep 2016 20:49:05 +0100 Subject: [PATCH 5/5] Fix the nocostbuilding curse description. https://bugs.eressea.de/view.php?id=2232 --- res/core/de/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 0b09a972b..c9a2ae616 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -4464,6 +4464,10 @@ Heimstein Homestone + + Mauern der Ewigkeit + Eternal Walls + Wasserelementar Water Elemental