From 406f8ca3e6c9f7a348222266c35476ac7ab14b23 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Mar 2017 20:25:01 +0200 Subject: [PATCH 1/3] BUG 2315: always use plural for resources --- src/creport.c | 2 +- src/creport.test.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/creport.c b/src/creport.c index 21e3f6d0b..dc897e055 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1184,7 +1184,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s } for (n = 0; n < size; ++n) { if (result[n].level >= 0 && result[n].number >= 0) { - const char * name = resourcename(result[n].rtype, result[n].number != 1); + const char * name = resourcename(result[n].rtype, 1); assert(name); stream_printf(out, "%d;%s\n", result[n].number, crtag(name)); } diff --git a/src/creport.test.c b/src/creport.test.c index 46e6e6967..e87de235e 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -52,8 +53,15 @@ static void test_cr_unit(CuTest *tc) { static void setup_resources(void) { struct locale *lang; + item_type *itype; test_setup(); + itype = it_get_or_create(rt_get_or_create("stone")); + itype->rtype->flags = RTF_LIMITED | RTF_POOLED; + itype->construction = calloc(1, sizeof(construction)); + itype->construction->skill = SK_QUARRYING; + itype->construction->minskill = 1; + rmt_create(itype->rtype); init_resources(); lang = get_or_create_locale("de"); /* CR tags are translated from this */ locale_setstring(lang, "money", "Silber"); @@ -62,6 +70,8 @@ static void setup_resources(void) { locale_setstring(lang, "horse_p", "Pferde"); locale_setstring(lang, "peasant", "Bauer"); locale_setstring(lang, "peasant_p", "Bauern"); + locale_setstring(lang, "stone", "Stein"); + locale_setstring(lang, "stone_p", "Steine"); locale_setstring(lang, "tree", "Blume"); locale_setstring(lang, "tree_p", "Blumen"); locale_setstring(lang, "sapling", "Schoessling"); @@ -77,25 +87,31 @@ static void test_cr_resources(CuTest *tc) { char line[1024]; faction *f; region *r; - + unit *u; + setup_resources(); f = test_create_faction(0); r = test_create_region(0, 0, 0); + u = test_create_unit(f, r); + set_level(u, SK_QUARRYING, 1); r->land->horses = 1; r->land->peasants = 200; r->land->money = 300; rsettrees(r, 0, 1); rsettrees(r, 1, 2); rsettrees(r, 2, 3); + region_setresource(r, get_resourcetype(R_STONE), 1); mstream_init(&strm); - cr_output_resources(&strm, f, r, false); + cr_output_resources(&strm, f, r, true); strm.api->rewind(strm.handle); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "3;Baeume", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "2;Schoesslinge", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "1;Steine", line); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); @@ -132,6 +148,15 @@ static void test_cr_resources(CuTest *tc) { CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, "1;number", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9)); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "\"Steine\";type", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "1;skill", line); + CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); + CuAssertStrEquals(tc, "1;number", line); + mstream_done(&strm); test_cleanup(); } From 4b0b5e821597f54953cf9ab331597458d4fda337 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Mar 2017 17:41:53 +0200 Subject: [PATCH 2/3] fix duplicate _LP64 define --- src/platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform.h b/src/platform.h index a56328485..104ff28d7 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,6 +1,8 @@ #pragma once +#ifndef _LP64 #define _LP64 0 /* fix a warning in pdcurses 3.4 */ +#endif #ifndef UNILIB_H #define UNILIB_H From aebc7d4cac56969f0d03586dfb951badd14ab6bf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Apr 2017 13:40:42 +0200 Subject: [PATCH 3/3] BUG 2138: Ponnuki is dead, long live Ponnuki https://bugs.eressea.de/view.php?id=2318 --- scripts/eressea/ponnuki.lua | 23 ++++++++++++++++------- src/kernel/config.c | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/eressea/ponnuki.lua b/scripts/eressea/ponnuki.lua index 96bb0b5f1..29f882ab5 100644 --- a/scripts/eressea/ponnuki.lua +++ b/scripts/eressea/ponnuki.lua @@ -14,8 +14,10 @@ local function ponnuki_brain(u) u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i]) local d = math.random(6) local r = u.region:next(d-1) - u:clear_orders() - u:add_order("NACH " .. directions[d]) + if r.terrain == 'glacier' then + u:clear_orders() + u:add_order("NACH " .. directions[d]) + end end function ponnuki.init() @@ -26,11 +28,18 @@ function ponnuki.init() local home = get_region(-67, -5) local f = get_faction(666) if home and f then - u = unit.create(f, home, 1, "illusion") - u.id = atoi36("ponn") - u.name = "Ponnuki" - u.info = "Go, Ponnuki, Go!" - u:set_racename("Ritter von Go") + if home.terrain~="glacier" then + home.terrain="glacier" + home.name = 'Magrathea' + end + u = unit.create(f, home, 1, "template") + if u then + u.id = atoi36("ponn") + u.name = "Ponnuki" + u.info = "Go, Ponnuki, Go!" + u.race_name = "Ritter von Go" + print(u:show()) + end else eressea.log.error("Ponnuki cannot find Magrathea") end diff --git a/src/kernel/config.c b/src/kernel/config.c index a18fc6494..bf61c8f02 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -123,7 +123,7 @@ const char *parameters[MAXPARAMS] = { "TEMP", "FLIEHE", "GEBAEUDE", - "GIB", /* F�r HELFE */ + "GIB", /* HELFE GIB */ "KAEMPFE", "DURCHREISE", "BEWACHE",