From 6234ae7e76689da0f6aab0727439e2fc5697a954 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2018 12:27:40 +0200 Subject: [PATCH 01/15] readability: bool vs int --- conf/e2/config.json | 2 +- conf/e3/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index ebc385adf..4da247263 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -39,7 +39,7 @@ "entertain.perlevel": 20, "taxing.perlevel": 20, "nmr.timeout": 5, - "nmr.removenewbie": 0, + "nmr.removenewbie": false, "GiveRestriction": 3, "hunger.long": true, "init_spells": 0, diff --git a/conf/e3/config.json b/conf/e3/config.json index c1fa2725c..b4b6d0e48 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -58,7 +58,7 @@ "entertain.base": 0, "entertain.perlevel": 20, "nmr.timeout": 5, - "nmr.removenewbie": 0, + "nmr.removenewbie": false, "GiveRestriction": 3, "healing.forest": 2.0, "hunger.long": false, From 4b5bd11f296485a5b15337815f6fb659eebfae90 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2018 13:29:54 +0200 Subject: [PATCH 02/15] spell_syntax without bsdstring, better tests. --- src/report.c | 139 ++++++++++++++++++++++------------------------ src/report.h | 2 +- src/report.test.c | 51 +++++------------ 3 files changed, 82 insertions(+), 110 deletions(-) diff --git a/src/report.c b/src/report.c index 3976bb05b..55189a66c 100644 --- a/src/report.c +++ b/src/report.c @@ -79,7 +79,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include #include -#include #include #include #include @@ -243,39 +242,44 @@ static size_t write_spell_modifier(const spell * sp, int flag, const char * str, return 0; } -void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct locale *lang) +void nr_spell_syntax(char *buf, size_t size, spellbook_entry * sbe, const struct locale *lang) { - int bytes; - char buf[4096]; - char *bufp = buf; - size_t size = sizeof(buf) - 1; const spell *sp = spellref_get(&sbe->spref); const char *params = sp->parameter; + const char *spname; + sbstring sbs; + sbs_init(&sbs, buf, size); if (sp->sptyp & ISCOMBATSPELL) { - bytes = (int)str_strlcpy(bufp, LOC(lang, keyword(K_COMBATSPELL)), size); + sbs_strcpy(&sbs, LOC(lang, keyword(K_COMBATSPELL))); } else { - bytes = (int)str_strlcpy(bufp, LOC(lang, keyword(K_CAST)), size); + sbs_strcpy(&sbs, LOC(lang, keyword(K_CAST))); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); /* Reihenfolge beachten: Erst REGION, dann STUFE! */ if (sp->sptyp & FARCASTING) { - bytes = snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION])); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " ["); + sbs_strcat(&sbs, LOC(lang, parameters[P_REGION])); + sbs_strcat(&sbs, " x y]"); } if (sp->sptyp & SPELLLEVEL) { - bytes = snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL])); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " ["); + sbs_strcat(&sbs, LOC(lang, parameters[P_LEVEL])); + sbs_strcat(&sbs, " n]"); } - bytes = (int)snprintf(bufp, size, " \"%s\"", spell_name(sp, lang)); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + spname = spell_name(sp, lang); + if (strchr(spname, ' ') != NULL) { + /* contains spaces, needs quotes */ + sbs_strcat(&sbs, " '"); + sbs_strcat(&sbs, spname); + sbs_strcat(&sbs, "'"); + } + else { + sbs_strcat(&sbs, " "); + sbs_strcat(&sbs, spname); + } while (params && *params) { typedef struct starget { @@ -298,52 +302,48 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc if (cp == 'u') { targetp = targets + 1; locp = LOC(lang, targetp->vars); - bytes = (int)snprintf(bufp, size, " <%s>", locp); + sbs_strcat(&sbs, " <"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, ">"); if (*params == '+') { ++params; - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); + sbs_strcat(&sbs, " [<"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, "> ...]"); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); } else if (cp == 's') { targetp = targets + 2; locp = LOC(lang, targetp->vars); - bytes = (int)snprintf(bufp, size, " <%s>", locp); + sbs_strcat(&sbs, " <"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, ">"); if (*params == '+') { ++params; - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); + sbs_strcat(&sbs, " [<"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, "> ...]"); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); } else if (cp == 'r') { - bytes = (int)str_strlcpy(bufp, " ", size); + sbs_strcat(&sbs, " "); if (*params == '+') { ++params; - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)str_strlcpy(bufp, " [ ...]", size); + sbs_strcat(&sbs, " [ ...]"); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); } else if (cp == 'b') { targetp = targets + 3; locp = LOC(lang, targetp->vars); - bytes = (int)snprintf(bufp, size, " <%s>", locp); + sbs_strcat(&sbs, " <"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, ">"); if (*params == '+') { ++params; - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); + sbs_strcat(&sbs, " [<"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, "> ...]"); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); } else if (cp == 'k') { int i, maxparam = 0; @@ -361,41 +361,35 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc ++maxparam; } if (!maxparam || maxparam > 1) { - bytes = (int)str_strlcpy(bufp, " (", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " ("); } i = 0; for (targetp = targets; targetp->flag; ++targetp) { if (!maxparam || sp->sptyp & targetp->flag) { if (i++ != 0) { - bytes = (int)str_strlcpy(bufp, " |", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " |"); } if (targetp->param && targetp->vars) { locp = LOC(lang, targetp->vars); - bytes = - (int)snprintf(bufp, size, " %s <%s>", parameters[targetp->param], - locp); + sbs_strcat(&sbs, " "); + sbs_strcat(&sbs, parameters[targetp->param]); + sbs_strcat(&sbs, " <"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, ">"); if (multi) { - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp); + sbs_strcat(&sbs, " [<"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, "> ...]"); } } else { - bytes = - (int)snprintf(bufp, size, " %s", parameters[targetp->param]); + sbs_strcat(&sbs, " "); + sbs_strcat(&sbs, parameters[targetp->param]); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); } } if (!maxparam || maxparam > 1) { - bytes = (int)str_strlcpy(bufp, " )", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " )"); } } else if (cp == 'i' || cp == 'c') { @@ -416,23 +410,24 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc } if (*params == '?') { ++params; - bytes = (int)snprintf(bufp, size, " [<%s>]", locp); + sbs_strcat(&sbs, " [<"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, ">]"); } else { - bytes = (int)snprintf(bufp, size, " <%s>", locp); + sbs_strcat(&sbs, " <"); + sbs_strcat(&sbs, locp); + sbs_strcat(&sbs, ">"); } - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); } else { log_error("unknown spell parameter %c for spell %s", cp, sp->sname); } } - *bufp = 0; - paragraph(out, buf, 2, 0, 0); - } +#include "util/bsdstring.h" + void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang) { int bytes, k, itemanz, costtyp; @@ -542,10 +537,8 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la paragraph(out, buf, 0, 0, 0); paragraph(out, LOC(lang, "nr_spell_syntax"), 0, 0, 0); - bufp = buf; - size = sizeof(buf) - 1; - - nr_spell_syntax(out, sbe, lang); + nr_spell_syntax(buf, sizeof(buf), sbe, lang); + paragraph(out, buf, 2, 0, 0); newline(out); } diff --git a/src/report.h b/src/report.h index 45c620562..bb3629497 100644 --- a/src/report.h +++ b/src/report.h @@ -30,7 +30,7 @@ extern "C" { void report_travelthru(struct stream *out, struct region * r, const struct faction * f); void report_region(struct stream *out, const struct region * r, struct faction * f); - void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); + void nr_spell_syntax(char *buf, size_t size, struct spellbook_entry * sbe, const struct locale *lang); void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang); #ifdef __cplusplus diff --git a/src/report.test.c b/src/report.test.c index 77bb6dca6..4fa97825c 100644 --- a/src/report.test.c +++ b/src/report.test.c @@ -228,32 +228,11 @@ static void set_parameter(spell_fixture spell, char *value) { } static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) { - stream strm; char buf[1024]; - char *linestart, *newline; - size_t len; - mstream_init(&strm); - nr_spell_syntax(&strm, spell->sbe, spell->lang); - strm.api->rewind(strm.handle); - len = strm.api->read(strm.handle, buf, sizeof(buf)); - buf[len] = '\0'; + nr_spell_syntax(buf, sizeof(buf), spell->sbe, spell->lang); - linestart = strtok(buf, "\n"); - while (linestart && !strstr(linestart, "ZAUBERE")) - linestart = strtok(NULL, "\n"); - - CuAssertPtrNotNull(tc, linestart); - - newline = strtok(NULL, "\n"); - while (newline) { - *(newline - 1) = '\n'; - newline = strtok(NULL, "\n"); - } - - CuAssertStrEquals_Msg(tc, msg, syntax, linestart); - - mstream_done(&strm); + CuAssertStrEquals_Msg(tc, msg, syntax, buf); } static void test_write_spell_syntax(CuTest *tc) { @@ -262,54 +241,54 @@ static void test_write_spell_syntax(CuTest *tc) { test_setup(); setup_spell_fixture(&spell); - check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\""); + check_spell_syntax(tc, "vanilla", &spell, "ZAUBERE Testzauber"); spell.sp->sptyp |= FARCASTING; - check_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\""); + check_spell_syntax(tc, "far", &spell, "ZAUBERE [REGION x y] Testzauber"); spell.sp->sptyp |= SPELLLEVEL; - check_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\""); + check_spell_syntax(tc, "farlevel", &spell, "ZAUBERE [REGION x y] [STUFE n] Testzauber"); spell.sp->sptyp = 0; set_parameter(spell, "kc"); - check_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT | SCHIFF | BURG )"); + check_spell_syntax(tc, "kc", &spell, "ZAUBERE Testzauber ( REGION | EINHEIT | SCHIFF | BURG )"); spell.sp->sptyp |= BUILDINGSPELL; - check_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG "); + check_spell_syntax(tc, "kc typed", &spell, "ZAUBERE Testzauber BURG "); spell.sp->sptyp = 0; set_parameter(spell, "b"); - check_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" "); + check_spell_syntax(tc, "b", &spell, "ZAUBERE Testzauber "); set_parameter(spell, "s"); - check_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" "); + check_spell_syntax(tc, "s", &spell, "ZAUBERE Testzauber "); set_parameter(spell, "s+"); - check_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" [ ...]"); + check_spell_syntax(tc, "s+", &spell, "ZAUBERE Testzauber [ ...]"); set_parameter(spell, "u"); - check_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" "); + check_spell_syntax(tc, "u", &spell, "ZAUBERE Testzauber "); set_parameter(spell, "r"); - check_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" "); + check_spell_syntax(tc, "r", &spell, "ZAUBERE Testzauber "); set_parameter(spell, "bc"); free(spell.sp->syntax); spell.sp->syntax = str_strdup("hodor"); - check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" "); + check_spell_syntax(tc, "bc hodor", &spell, "ZAUBERE Testzauber "); free(spell.sp->syntax); spell.sp->syntax = 0; set_parameter(spell, "c?"); free(spell.sp->syntax); spell.sp->syntax = str_strdup("hodor"); - check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []"); + check_spell_syntax(tc, "c?", &spell, "ZAUBERE Testzauber []"); free(spell.sp->syntax); spell.sp->syntax = 0; set_parameter(spell, "kc+"); check_spell_syntax(tc, "kc+", &spell, - " ZAUBERE \"Testzauber\" ( REGION | EINHEIT [ ...] | SCHIFF \n [ ...] | BURG [ ...] )"); + "ZAUBERE Testzauber ( REGION | EINHEIT [ ...] | SCHIFF [ ...] | BURG [ ...] )"); cleanup_spell_fixture(&spell); test_teardown(); From 5b0f3f9ea712e63c4b3e85dce4001439aa5ea5f4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 9 Jun 2018 21:22:02 +0200 Subject: [PATCH 03/15] more sbstring upgrades --- src/report.c | 70 +++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/src/report.c b/src/report.c index 55189a66c..c171eae5c 100644 --- a/src/report.c +++ b/src/report.c @@ -79,6 +79,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include #include +#include "util/bsdstring.h" #include #include #include @@ -426,8 +427,6 @@ void nr_spell_syntax(char *buf, size_t size, spellbook_entry * sbe, const struct } } -#include "util/bsdstring.h" - void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang) { int bytes, k, itemanz, costtyp; @@ -1841,72 +1840,61 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, static void nr_building(struct stream *out, const region *r, const building *b, const faction *f) { - int i, bytes; + int i; const char *name, *bname, *billusion = NULL; const struct locale *lang; - char buffer[8192], *bufp = buffer; + char buffer[8192]; message *msg; - size_t size = sizeof(buffer) - 1; + size_t size; + sbstring sbs; assert(f); lang = f->locale; newline(out); - bytes = - snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, - "nr_size"), b->size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_init(&sbs, buffer, sizeof(buffer)); report_building(b, &bname, &billusion); + + size = str_slprintf(buffer, sizeof(buffer), "%s, %s %d, ", buildingname(b), + LOC(lang, "nr_size"), b->size); + sbs.end += size; name = LOC(lang, billusion ? billusion : bname); - bytes = (int)str_strlcpy(bufp, name, size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, name); + if (billusion) { unit *owner = building_owner(b); if (owner && owner->faction == f) { /* illusion. report real type */ - name = LOC(lang, bname); - bytes = snprintf(bufp, size, " (%s)", name); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " ("); + sbs_strcat(&sbs, LOC(lang, bname)); + sbs_strcat(&sbs, ")"); } } if (!building_finished(b)) { - bytes = (int)str_strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)str_strlcpy(bufp, LOC(lang, "nr_building_inprogress"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, " "); + sbs_strcat(&sbs, LOC(lang, "nr_building_inprogress")); } if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) { msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, b->besieged - b->size * SIEGEFACTOR); - bytes = (int)nr_render(msg, lang, bufp, size, f); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + + size = nr_render(msg, lang, sbs.end, sbs.size - (sbs.end - sbs.begin), f); + sbs.end += size; + msg_release(msg); } i = 0; if (b->display && b->display[0]) { - bytes = (int)str_strlcpy(bufp, "; ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)str_strlcpy(bufp, b->display, size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, "; "); + sbs_strcat(&sbs, b->display); i = b->display[strlen(b->display) - 1]; } if (i != '!' && i != '?' && i != '.') { - bytes = (int)str_strlcpy(bufp, ".", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + sbs_strcat(&sbs, "."); } - *bufp = 0; paragraph(out, buffer, 2, 0, 0); if (r->seen.mode >= seen_lighthouse) { @@ -1916,14 +1904,10 @@ nr_building(struct stream *out, const region *r, const building *b, const factio static void nr_paragraph(struct stream *out, message * m, faction * f) { - int bytes; - char buf[4096], *bufp = buf; - size_t size = sizeof(buf) - 1; + char buf[4096]; assert(f); - bytes = (int)nr_render(m, f->locale, bufp, size, f); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + nr_render(m, f->locale, buf, sizeof(buf), f); msg_release(m); paragraph(out, buf, 0, 0, 0); @@ -2027,6 +2011,8 @@ void report_travelthru(struct stream *out, region *r, const faction *f) } } +#include "util/bsdstring.h" + int report_plaintext(const char *filename, report_context * ctx, const char *bom) From c3d08d153679fe9330c7aeae886822a958f1b15d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 11 Jun 2018 21:00:01 +0200 Subject: [PATCH 04/15] redirect cron output to a logfile --- process/cron/preview.cron | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/process/cron/preview.cron b/process/cron/preview.cron index 71ebd0571..eb39fd8f8 100755 --- a/process/cron/preview.cron +++ b/process/cron/preview.cron @@ -1,5 +1,5 @@ #!/bin/bash - +( [ "$PREVIEW" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -13,3 +13,5 @@ for game in 2 3 4 ; do ${SRC}/s/preview -g ${game} run && \ ${SRC}/s/preview -g ${game} send done +) | tee -a $HOME/log/preview.cron.log + From 6d10ee8fa568bdd8b2f7907c8b33b7618d6d7fee Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 24 Jun 2018 18:08:19 +0200 Subject: [PATCH 05/15] =?UTF-8?q?BUG=202453:=20Erstausstattung=20und=20Def?= =?UTF-8?q?ault-Befehle=20f=C3=BCr=20neue=20Parteien.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/eressea/e2/init.lua | 1 + scripts/eressea/init.lua | 1 + scripts/map.lua | 1 + src/kernel/config.c | 36 ++++++++++++------------------------ src/kernel/config.test.c | 15 +++++++++++---- src/kernel/faction.c | 8 +++++++- src/kernel/faction.test.c | 23 +++++++++++++++++++++++ 7 files changed, 56 insertions(+), 29 deletions(-) diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index 52636d207..9df7a1062 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -4,6 +4,7 @@ eressea.log.debug('rules for game E2') math.randomseed(rng.random()) local equipment = require('eressea.equipment') + local sets = { ['seed_faction'] = { ['items'] = { diff --git a/scripts/eressea/init.lua b/scripts/eressea/init.lua index 1af37d2d5..d840fe899 100644 --- a/scripts/eressea/init.lua +++ b/scripts/eressea/init.lua @@ -1,5 +1,6 @@ require 'eressea.path' require 'eressea.resources' +require 'eressea.equipment' require 'eressea.spells' local self = {} diff --git a/scripts/map.lua b/scripts/map.lua index cad3ae1fd..98579924f 100644 --- a/scripts/map.lua +++ b/scripts/map.lua @@ -6,5 +6,6 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' require 'eressea.path' require 'eressea' require 'eressea.xmlconf' + eressea.read_game(get_turn() .. ".dat") gmtool.editor() diff --git a/src/kernel/config.c b/src/kernel/config.c index ff2457971..ec45ddd0d 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -631,28 +631,24 @@ void kernel_init(void) translation_init(); } -static order * defaults[MAXLOCALES]; - order *default_order(const struct locale *lang) { int i = locale_index(lang); + keyword_t kwd; + const char * str; order *result = 0; - assert(i < MAXLOCALES); - result = defaults[i]; - if (!result) { - const char * str; - keyword_t kwd = NOKEYWORD; - str = config_get("orders.default"); - if (str) { - kwd = findkeyword(str); - } - if (kwd != NOKEYWORD) { - result = create_order(kwd, lang, NULL); - defaults[i] = result; - } + assert(i < MAXLOCALES); + kwd = keyword_disabled(K_WORK) ? NOKEYWORD : K_WORK; + str = config_get("orders.default"); + if (str) { + kwd = findkeyword(str); } - return result ? copy_order(result) : 0; + if (kwd != NOKEYWORD) { + result = create_order(kwd, lang, NULL); + return copy_order(result); + } + return NULL; } int rule_give(void) @@ -760,14 +756,6 @@ void free_config(void) { */ void free_gamedata(void) { - int i; - - for (i = 0; i != MAXLOCALES; ++i) { - if (defaults[i]) { - free_order(defaults[i]); - defaults[i] = 0; - } - } free(forbidden_ids); forbidden_ids = NULL; diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 7a2097ce4..e99ba9d08 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -180,15 +180,22 @@ static void test_default_order(CuTest *tc) { test_setup(); loc = test_create_locale(); - ord = default_order(loc); - CuAssertPtrEquals(tc, 0, ord); - free_order(ord); - config_set("orders.default", "work"); ord = default_order(loc); CuAssertPtrNotNull(tc, ord); CuAssertIntEquals(tc, K_WORK, getkeyword(ord)); free_order(ord); + + enable_keyword(K_WORK, false); + ord = default_order(loc); + CuAssertPtrEquals(tc, NULL, ord); + free_order(ord); + + config_set("orders.default", "entertain"); + ord = default_order(loc); + CuAssertPtrNotNull(tc, ord); + CuAssertIntEquals(tc, K_ENTERTAIN, getkeyword(ord)); + free_order(ord); test_teardown(); } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index bc08ba010..16c0c789c 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -29,6 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "group.h" #include "item.h" #include "messages.h" +#include "order.h" #include "plane.h" #include "race.h" #include "region.h" @@ -294,8 +295,13 @@ unit *addplayer(region * r, faction * f) assert(f->units == NULL); faction_setorigin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); + u->thisorder = default_order(f->locale); + unit_addorder(u, copy_order(u->thisorder)); name = config_get("rules.equip_first"); - equip_unit(u, name ? name : "first_unit"); + if (!equip_unit(u, name ? name : "first_unit")) { + /* give every unit enough money to survive the first turn */ + i_change(&u->items, get_resourcetype(R_SILVER)->itype, maintenance_cost(u)); + } u->hp = unit_max_hp(u) * u->number; fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) { diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 7748f693d..37ec70e50 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -3,8 +3,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -298,9 +300,30 @@ static void test_save_special_items(CuTest *tc) { test_teardown(); } +static void test_addplayer(CuTest *tc) { + unit *u; + region *r; + faction *f; + item_type *itype; + test_setup(); + callbacks.equip_unit = NULL; + itype = test_create_silver(); + r = test_create_plain(0, 0); + f = test_create_faction(NULL); + u = addplayer(r, f); + CuAssertPtrNotNull(tc, u); + CuAssertPtrEquals(tc, r, u->region); + CuAssertPtrEquals(tc, f, u->faction); + CuAssertIntEquals(tc, i_get(u->items, itype), 10); + CuAssertPtrNotNull(tc, u->orders); + CuAssertIntEquals(tc, K_WORK, getkeyword(u->orders)); + test_teardown(); +} + CuSuite *get_faction_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_addplayer); SUITE_ADD_TEST(suite, test_max_migrants); SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_remove_empty_factions); From 501830817051c581665ee5714bde5156d3c34712 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 28 Jun 2018 22:48:57 +0200 Subject: [PATCH 06/15] remove at_chaoscount, update storage module. --- clibs | 2 +- src/attributes/attributes.c | 1 + src/battle.c | 2 -- src/bind_region.c | 9 +----- src/chaos.c | 61 ------------------------------------- src/chaos.h | 7 ----- src/eressea.c | 2 -- src/gmtool.c | 2 -- src/kernel/order.test.c | 1 + src/monsters.c | 20 +++++------- storage | 2 +- 11 files changed, 13 insertions(+), 96 deletions(-) diff --git a/clibs b/clibs index f9842e07a..bd70ef20b 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f9842e07a442c5453c270badf25ab72633b4edf5 +Subproject commit bd70ef20babbe9949e5ad5acd5317e7d39ad1e72 diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 907478aaa..fa6f15d73 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -209,6 +209,7 @@ void register_attributes(void) at_deprecate("maxmagicians", a_readint); /* factions with differnt magician limits, probably unused */ at_deprecate("hurting", a_readint); /* an old arena attribute */ + at_deprecate("chaoscount", a_readint); /* used to increase the chance of monster spawns */ at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ at_deprecate("orcification", a_readint); /* required for old datafiles */ at_deprecate("lua", read_ext); /* required for old datafiles */ diff --git a/src/battle.c b/src/battle.c index 9092718a2..be950af7f 100644 --- a/src/battle.c +++ b/src/battle.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "battle.h" #include "alchemy.h" -#include "chaos.h" #include "guard.h" #include "laws.h" #include "monsters.h" @@ -2531,7 +2530,6 @@ static void battle_effects(battle * b, int dead_players) } if (dead_peasants) { deathcounts(r, dead_peasants + dead_players); - add_chaoscount(r, dead_peasants / 2); rsetpeasants(r, rp - dead_peasants); } } diff --git a/src/bind_region.c b/src/bind_region.c index e041fba77..b49ceb078 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -7,7 +7,6 @@ #include "bind_ship.h" #include "bind_building.h" -#include "chaos.h" #include "teleport.h" #include @@ -356,7 +355,7 @@ static int tolua_region_get_resourcelevel(lua_State * L) #define LUA_ASSERT(c, s) if (!(c)) { log_error("%s(%d): %s\n", __FILE__, __LINE__, (s)); return 0; } static int special_resource(const char *type) { - const char * special[] = { "seed", "sapling", "tree", "grave", "chaos", 0 }; + const char * special[] = { "seed", "sapling", "tree", "grave", NULL }; int i; for (i = 0; special[i]; ++i) { @@ -389,9 +388,6 @@ static int tolua_region_get_resource(lua_State * L) case 3: result = deathcount(r); break; - case 4: - result = get_chaoscount(r); - break; default: rtype = rt_find(type); if (rtype) { @@ -423,9 +419,6 @@ static int tolua_region_set_resource(lua_State * L) case 3: deathcounts(r, value - deathcount(r)); break; - case 4: - add_chaoscount(r, value - get_chaoscount(r)); - break; default: rtype = rt_find(type); if (rtype != NULL) { diff --git a/src/chaos.c b/src/chaos.c index 67cdb356d..21a5a8624 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -39,57 +39,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -/*********************/ -/* at_chaoscount */ -/*********************/ -attrib_type at_chaoscount = { - "chaoscount", - DEFAULT_INIT, - DEFAULT_FINALIZE, - DEFAULT_AGE, - a_writeint, - a_readint, - NULL, - ATF_UNIQUE -}; - -void set_chaoscount(struct region *r, int deaths) -{ - if (deaths==0) { - a_removeall(&r->attribs, &at_chaoscount); - } else { - attrib *a = a_find(r->attribs, &at_chaoscount); - if (!a) { - a = a_add(&r->attribs, a_new(&at_chaoscount)); - } - a->data.i = deaths; - } -} - -int get_chaoscount(const region * r) -{ - attrib *a = a_find(r->attribs, &at_chaoscount); - if (!a) - return 0; - return a->data.i; -} - -void add_chaoscount(region * r, int fallen) -{ - attrib *a; - - if (fallen == 0) - return; - - a = a_find(r->attribs, &at_chaoscount); - if (!a) - a = a_add(&r->attribs, a_new(&at_chaoscount)); - a->data.i += fallen; - - if (a->data.i <= 0) - a_remove(&r->attribs, a); -} - static const terrain_type *chaosterrain(void) { static const terrain_type **types; @@ -248,18 +197,8 @@ void chaos_update(void) { region *r; /* Chaos */ for (r = regions; r; r = r->next) { - int i; - if ((r->flags & RF_CHAOTIC)) { chaos(r); } - i = get_chaoscount(r); - if (i) { - add_chaoscount(r, -(int)(i * ((double)(rng_int() % 10)) / 100.0)); - } } } - -void chaos_register(void) { - at_register(&at_chaoscount); -} diff --git a/src/chaos.h b/src/chaos.h index 0c2667083..550aa3efb 100644 --- a/src/chaos.h +++ b/src/chaos.h @@ -24,15 +24,8 @@ extern "C" { struct region; - extern struct attrib_type at_chaoscount; - - void chaos_register(void); void chaos_update(void); - void set_chaoscount(struct region *r, int deaths); - int get_chaoscount(const struct region * r); - void add_chaoscount(struct region * r, int deaths); - #ifdef __cplusplus } #endif diff --git a/src/eressea.c b/src/eressea.c index 982dfe6ee..0bf1454ee 100644 --- a/src/eressea.c +++ b/src/eressea.c @@ -24,7 +24,6 @@ #include "attributes/attributes.h" #include "races/races.h" -#include "chaos.h" #include "items.h" #include "creport.h" #include "report.h" @@ -82,5 +81,4 @@ void game_init(void) register_attributes(); register_gmcmd(); - chaos_register(); } diff --git a/src/gmtool.c b/src/gmtool.c index e13701f6f..d3858d09f 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -50,7 +50,6 @@ #include #include "gmtool_structs.h" -#include "chaos.h" #include "console.h" #include "listbox.h" #include "wormhole.h" @@ -531,7 +530,6 @@ static void statusline(WINDOW * win, const char *str) } static void reset_region(region *r) { - set_chaoscount(r, 0); r->flags = 0; a_removeall(&r->attribs, NULL); while (r->units) { diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index 37f88ae5a..3a2f44c56 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -512,6 +512,7 @@ static void test_create_order_long(CuTest *tc) { stream_order(&out, ord, lang, true); out.api->rewind(out.handle); out.api->readln(out.handle, buffer, sizeof(buffer)); + CuAssertIntEquals(tc, 1026, strlen(buffer)); mstream_done(&out); free_order(ord); test_teardown(); diff --git a/src/monsters.c b/src/monsters.c index be4ec7525..181615a40 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -24,7 +24,6 @@ #include "monsters.h" #include "economy.h" -#include "chaos.h" #include "give.h" #include "guard.h" #include "laws.h" @@ -843,18 +842,14 @@ void plan_monsters(faction * f) pathfinder_cleanup(); } -static double chaosfactor(region * r) -{ - return fval(r, RF_CHAOTIC) ? ((double)(1 + get_chaoscount(r)) / 1000.0) : 0.0; -} - static int nrand(int handle_start, int sub) { int res = 0; do { - if (rng_int() % 100 < handle_start) + if (rng_int() % 100 < handle_start) { res++; + } handle_start -= sub; } while (handle_start > 0); @@ -876,7 +871,7 @@ void spawn_dragons(void) region *r; faction *monsters = get_or_create_monsters(); int minage = config_get_int("monsters.spawn.min_age", 100); - int spawn_chance = 100 * config_get_int("monsters.spawn.chance", 100); + int spawn_chance = config_get_int("monsters.spawn.chance", 100); if (spawn_chance <= 0) { /* monster spawning disabled */ @@ -895,7 +890,8 @@ void spawn_dragons(void) else if ((r->terrain == newterrain(T_GLACIER) || r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_DESERT)) - && rng_int() % spawn_chance < (5 + 100 * chaosfactor(r))) { + && rng_int() % spawn_chance < 6) + { if (chance(0.80)) { u = create_unit(r, monsters, nrand(60, 20) + 1, get_race(RC_FIREDRAGON), 0, NULL, NULL); } @@ -907,7 +903,7 @@ void spawn_dragons(void) log_debug("spawning %d %s in %s.\n", u->number, LOC(default_locale, - rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); + rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); name_unit(u); @@ -932,9 +928,9 @@ void spawn_undead(void) continue; } } - /* Chance 0.1% * chaosfactor */ + if (r->land && unburied > rpeasants(r) / 20 - && rng_int() % 10000 < (100 + 100 * chaosfactor(r))) { + && rng_int() % 10000 < 200) { message *msg; unit *u; /* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen. diff --git a/storage b/storage index 5623ee652..4d33d5081 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 5623ee6527e97af20c7d8efc03800b6fe1579744 +Subproject commit 4d33d5081f593272c25baa64d6210635c1c7e828 From af7e2919235f4afaf585669a3971c525dcee9ae1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 28 Jun 2018 23:03:12 +0200 Subject: [PATCH 07/15] submodule updates --- clibs | 2 +- storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clibs b/clibs index bd70ef20b..9b6e34959 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit bd70ef20babbe9949e5ad5acd5317e7d39ad1e72 +Subproject commit 9b6e34959f77d7ca3a4ce3826cb487487f557441 diff --git a/storage b/storage index 4d33d5081..6eea76952 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 4d33d5081f593272c25baa64d6210635c1c7e828 +Subproject commit 6eea7695285f9c9f1d25421897ca55f466ef7566 From 6403c75c858a8becfed7ece8aecdcd2bae805f2c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 2 Jul 2018 19:58:26 +0200 Subject: [PATCH 08/15] monsters should not be anonymous. --- src/kernel/faction.c | 30 ------------------------------ src/monsters.c | 5 +++++ 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 16c0c789c..b4dfe51ca 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -492,36 +492,6 @@ void destroyfaction(faction ** fp) } handle_event(f->attribs, "destroy", f); -#if 0 - faction *ff; - for (ff = factions; ff; ff = ff->next) { - group *g; - ally *sf, **sfp; - - for (sfp = &ff->allies; *sfp;) { - sf = *sfp; - if (sf->faction == f || sf->faction == NULL) { - *sfp = sf->next; - free(sf); - } - else - sfp = &(*sfp)->next; - } - for (g = ff->groups; g; g = g->next) { - for (sfp = &g->allies; *sfp; ) { - sf = *sfp; - if (sf->faction == f || sf->faction == NULL) { - *sfp = sf->next; - free(sf); - } - else { - sfp = &(*sfp)->next; - } - } - } - } -#endif - if (f->alliance) { setalliance(f, 0); } diff --git a/src/monsters.c b/src/monsters.c index 181615a40..bbeb483b8 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -755,6 +755,11 @@ void plan_monsters(faction * f) if (u->faction!=f) continue; + /* Parteitarnung von Monstern ist doof: */ + if (fval(u, UFL_ANON_FACTION)) { + u->flags &= ~UFL_ANON_FACTION; + } + /* Befehle m�ssen jede Runde neu gegeben werden: */ free_orders(&u->orders); if (skill_enabled(SK_PERCEPTION)) { From 8af4b1fe292a0fca7cca3512e904b63ac83473ec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jul 2018 10:45:11 +0200 Subject: [PATCH 09/15] pipe cron output to logfile, fix sendreport script --- process/Makefile | 3 +-- process/cron/run-eressea.cron | 4 +++- process/functions.sh | 10 -------- process/sendreport.sh | 45 ++++++++++++++++++++--------------- 4 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 process/functions.sh diff --git a/process/Makefile b/process/Makefile index 8edfed0b8..0d84bdae2 100644 --- a/process/Makefile +++ b/process/Makefile @@ -1,6 +1,5 @@ SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \ -run-turn sendreports.sh -IGNORE=sendreport.sh +run-turn sendreports.sh sendreport.sh shellcheck: $(SCRIPTS) shellcheck $(SCRIPTS) diff --git a/process/cron/run-eressea.cron b/process/cron/run-eressea.cron index 4ea38184c..ecd4c6b11 100755 --- a/process/cron/run-eressea.cron +++ b/process/cron/run-eressea.cron @@ -1,6 +1,6 @@ #!/bin/bash GAME=$1 - +( [ "$ENABLED" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -58,3 +58,5 @@ $BIN/compress.sh $GAME $TURN $BIN/sendreports.sh $GAME $BIN/backup-eressea $GAME $TURN rm -f test/execute.lock +) | tee -a $HOME/log/eressea.cron.log + diff --git a/process/functions.sh b/process/functions.sh deleted file mode 100644 index 859fd302a..000000000 --- a/process/functions.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -PATH=$ERESSEA/bin:$PATH - -function abort() { - if [ $# -gt 0 ]; then - echo $@ - fi - exit -1 -} diff --git a/process/sendreport.sh b/process/sendreport.sh index be643ef56..d98ed505e 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -1,11 +1,17 @@ #!/bin/bash -if [ -z $ERESSEA ]; then +if [ -z "$ERESSEA" ]; then echo "You have to define the \$ERESSEA environment variable to run $0" exit -2 fi -source $HOME/bin/functions.sh + +function abort() { + if [ $# -gt 0 ]; then + echo "$@" + fi + exit -1 +} GAME=$1 EMAIL=$2 @@ -14,32 +20,33 @@ PASSWD=$4 #echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log function reply() { - echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL - abort $@ + echo "$@" | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" + abort "$@" } -LOCKFILE=$ERESSEA/.report.lock -[ -e $LOCKFILE ] && reply "lockfile exists. wait for mail delivery to finish." +LOCKFILE="$ERESSEA/.report.lock" +[ -e "$LOCKFILE" ] && reply "lockfile exists. wait for mail delivery to finish." -REPLYTO='accounts@eressea.de' +echo "$(date):report:$GAME:$EMAIL:$FACTION:$PASSWD" >> "$ERESSEA/request.log" -echo `date`:report:$GAME:$EMAIL:$FACTION:$PASSWD >> $ERESSEA/request.log +cd "$ERESSEA" || exit +checkpasswd.py "game-$GAME/passwd" "$FACTION" "$PASSWD" || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" -cd $ERESSEA -checkpasswd.py game-$GAME/passwd $FACTION $PASSWD || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" - -cd $ERESSEA/game-$GAME/reports -if [ ! -e ${FACTION}.sh ]; then +cd "$ERESSEA/game-$GAME/reports" || exit +if [ ! -e "${FACTION}.sh" ]; then echo "Der Report für Partei $FACTION kann wegen technischer Probleme leider nicht nachgefordert werden: No such file ${FACTION}.sh" \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL + | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" exit fi -source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" +bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION" -if [ -e $ERESSEA/game-$GAME/eressea.db ]; then +if [ -e "$ERESSEA/game-$GAME/eressea.db" ]; then SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" - OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") - echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER + OWNER=$(sqlite3 "$ERESSEA/game-$GAME/eressea.db" "$SQL") + if [ ! -z "$OWNER" ]; then + echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ + | mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER" + fi fi + From 68f241ad7df8c22b4d803daaf8122e384a1c9e72 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 11 Jun 2018 21:00:01 +0200 Subject: [PATCH 10/15] redirect cron output to a logfile --- process/cron/preview.cron | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/process/cron/preview.cron b/process/cron/preview.cron index 71ebd0571..eb39fd8f8 100755 --- a/process/cron/preview.cron +++ b/process/cron/preview.cron @@ -1,5 +1,5 @@ #!/bin/bash - +( [ "$PREVIEW" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -13,3 +13,5 @@ for game in 2 3 4 ; do ${SRC}/s/preview -g ${game} run && \ ${SRC}/s/preview -g ${game} send done +) | tee -a $HOME/log/preview.cron.log + From e2c2f61927f43777888852cbf79b6d5b0540ba25 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jul 2018 10:45:11 +0200 Subject: [PATCH 11/15] pipe cron output to logfile, fix sendreport script --- process/Makefile | 3 +-- process/cron/run-eressea.cron | 4 +++- process/functions.sh | 10 -------- process/sendreport.sh | 45 ++++++++++++++++++++--------------- 4 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 process/functions.sh diff --git a/process/Makefile b/process/Makefile index 8edfed0b8..0d84bdae2 100644 --- a/process/Makefile +++ b/process/Makefile @@ -1,6 +1,5 @@ SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \ -run-turn sendreports.sh -IGNORE=sendreport.sh +run-turn sendreports.sh sendreport.sh shellcheck: $(SCRIPTS) shellcheck $(SCRIPTS) diff --git a/process/cron/run-eressea.cron b/process/cron/run-eressea.cron index 4ea38184c..ecd4c6b11 100755 --- a/process/cron/run-eressea.cron +++ b/process/cron/run-eressea.cron @@ -1,6 +1,6 @@ #!/bin/bash GAME=$1 - +( [ "$ENABLED" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -58,3 +58,5 @@ $BIN/compress.sh $GAME $TURN $BIN/sendreports.sh $GAME $BIN/backup-eressea $GAME $TURN rm -f test/execute.lock +) | tee -a $HOME/log/eressea.cron.log + diff --git a/process/functions.sh b/process/functions.sh deleted file mode 100644 index 859fd302a..000000000 --- a/process/functions.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -PATH=$ERESSEA/bin:$PATH - -function abort() { - if [ $# -gt 0 ]; then - echo $@ - fi - exit -1 -} diff --git a/process/sendreport.sh b/process/sendreport.sh index be643ef56..d98ed505e 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -1,11 +1,17 @@ #!/bin/bash -if [ -z $ERESSEA ]; then +if [ -z "$ERESSEA" ]; then echo "You have to define the \$ERESSEA environment variable to run $0" exit -2 fi -source $HOME/bin/functions.sh + +function abort() { + if [ $# -gt 0 ]; then + echo "$@" + fi + exit -1 +} GAME=$1 EMAIL=$2 @@ -14,32 +20,33 @@ PASSWD=$4 #echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log function reply() { - echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL - abort $@ + echo "$@" | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" + abort "$@" } -LOCKFILE=$ERESSEA/.report.lock -[ -e $LOCKFILE ] && reply "lockfile exists. wait for mail delivery to finish." +LOCKFILE="$ERESSEA/.report.lock" +[ -e "$LOCKFILE" ] && reply "lockfile exists. wait for mail delivery to finish." -REPLYTO='accounts@eressea.de' +echo "$(date):report:$GAME:$EMAIL:$FACTION:$PASSWD" >> "$ERESSEA/request.log" -echo `date`:report:$GAME:$EMAIL:$FACTION:$PASSWD >> $ERESSEA/request.log +cd "$ERESSEA" || exit +checkpasswd.py "game-$GAME/passwd" "$FACTION" "$PASSWD" || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" -cd $ERESSEA -checkpasswd.py game-$GAME/passwd $FACTION $PASSWD || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" - -cd $ERESSEA/game-$GAME/reports -if [ ! -e ${FACTION}.sh ]; then +cd "$ERESSEA/game-$GAME/reports" || exit +if [ ! -e "${FACTION}.sh" ]; then echo "Der Report für Partei $FACTION kann wegen technischer Probleme leider nicht nachgefordert werden: No such file ${FACTION}.sh" \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL + | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" exit fi -source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" +bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION" -if [ -e $ERESSEA/game-$GAME/eressea.db ]; then +if [ -e "$ERESSEA/game-$GAME/eressea.db" ]; then SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" - OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") - echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER + OWNER=$(sqlite3 "$ERESSEA/game-$GAME/eressea.db" "$SQL") + if [ ! -z "$OWNER" ]; then + echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ + | mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER" + fi fi + From b1b4654b0eb0736497dcd82c192a7ca34f1e4b63 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jul 2018 12:21:42 +0200 Subject: [PATCH 12/15] Bug 2445: duplicate strings warnings. --- conf/e2/locales.json | 2 ++ res/translations/strings-e2.de.po | 49 +++++++++++++++++++++++++++++++ res/translations/strings-e2.en.po | 49 +++++++++++++++++++++++++++++++ res/translations/strings.de.po | 36 ----------------------- res/translations/strings.en.po | 36 ----------------------- 5 files changed, 100 insertions(+), 72 deletions(-) create mode 100644 res/translations/strings-e2.de.po create mode 100644 res/translations/strings-e2.en.po diff --git a/conf/e2/locales.json b/conf/e2/locales.json index 21e91755f..3376cfedc 100644 --- a/conf/e2/locales.json +++ b/conf/e2/locales.json @@ -1,7 +1,9 @@ { "include": [ "config://res/translations/strings.de.po", + "config://res/translations/strings-e2.de.po", "config://res/translations/strings.en.po", + "config://res/translations/strings-e2.en.po", "config://res/translations/messages.de.po", "config://res/translations/messages.en.po", "config://res/core/messages.xml" diff --git a/res/translations/strings-e2.de.po b/res/translations/strings-e2.de.po new file mode 100644 index 000000000..fde4244af --- /dev/null +++ b/res/translations/strings-e2.de.po @@ -0,0 +1,49 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de\n" +"X-Generator: Poedit 2.0.7\n" + +msgctxt "spellinfo" +msgid "concealing_aura" +msgstr "Dieser Zauber wird die gesamte Ausrüstung der Zieleinheit für einige Zeit vor den Blicken anderer verschleiern." + +msgctxt "spellinfo" +msgid "raindance" +msgstr "Dieses uralte Tanzritual ruft die Kräfte des Lebens und der Fruchtbarkeit. Die Erträge der Bauern werden für einige Wochen deutlich besser ausfallen." + +msgctxt "spellinfo" +msgid "earn_silver#gwyrrd" +msgstr "Die Fähigkeiten der Gwyrrd-Magier in der Viehzucht und Heilung sind bei den Bauern sehr begehrt. Gerade auf Märkten sind ihre Dienste häufig sehr gefragt. Manch einer mag auch sein Talent dazu nutzen, ein Tier für einen besseren Preis zu verkaufen. Pro Stufe kann der Magier so 50 Silber verdienen." + +msgctxt "spellinfo" +msgid "earn_silver#draig" +msgstr "In den dunkleren Gassen gibt es sie, die Flüche und Verhexungen auf Bestellung. Aber auch Gegenzauber hat der Jünger des Draigs natürlich im Angebot. Ob nun der Sohn des Nachbarn in einen Liebesbann gezogen werden soll oder die Nebenbuhlerin Pickel und Warzen bekommen soll, niemand gibt gerne zu, zu solchen Mitteln gegriffen zu haben. Für diese Dienstleistung streicht der Magier 50 Silber pro Stufe ein." + +msgctxt "spellinfo" +msgid "earn_silver#cerddor" +msgstr "Cerddormagier sind die führenden Gaukler unter den Magiern, sie lieben es das Volk zu unterhalten und im Mittelpunkt zu stehen. Schon Anfänger lernen die kleinen Kunststücke und magischen Tricks, mit denen man das Volk locken und verführen kann, den Geldbeutel ganz weit zu öffnen, und am Ende der Woche wird der Gaukler 50 Silber pro Stufe verdient haben." + +msgctxt "spellinfo" +msgid "earn_silver#tybied" +msgstr "Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen alles, was man sonst nicht bekommen kann. Ob nun die kryptische Formel unter dem Holzschuh des untreuen Ehemannes wirklich geholfen hat - nun, der des Lesens nicht mächtige Bauer wird es nie wissen. Dem Magier hilft es auf jeden Fall... beim Füllen seines Geldbeutels. 50 Silber pro Stufe lassen sich so in einer Woche verdienen." + +msgctxt "spellinfo" +msgid "earn_silver#illaun" +msgstr "Niemand kann so gut die Träume deuten wie ein Magier des Illaun. Auch die Kunst der Wahrsagerei, des Kartenlegens und des Handlesens sind ihm geläufig. Dafür zahlen ihm die Bauern 50 Silber pro Stufe." + +msgctxt "describe" +msgid "lifepotion" +msgstr "Das 'Wasser des Lebens' ist in der Lage, aus gefällten Baumstämmen wieder lebende Bäume zu machen. Dazu wird ein knotiger Saugwurz zusammen mit einem Elfenlieb erwärmt, so dass man gerade noch den Finger reinhalten kann. Dies gieße man in ein Gefäß und lasse es langsam abkühlen. Der Extrakt reicht für 10 Holzstämme." + +msgctxt "spellinfo" +msgid "blessedharvest" +msgstr "Dieses Ernteritual verbessert die Erträge der arbeitenden Bauern in der Region um ein Silberstück. Je mehr Kraft der Druide investiert, desto länger wirkt der Zauber." + diff --git a/res/translations/strings-e2.en.po b/res/translations/strings-e2.en.po new file mode 100644 index 000000000..3867de0f7 --- /dev/null +++ b/res/translations/strings-e2.en.po @@ -0,0 +1,49 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"X-Generator: Poedit 2.0.7\n" + +msgctxt "spellinfo" +msgid "earn_silver#gwyrrd" +msgstr "The abilities of the mages of Gwyrrd concerning the breeding and healing of cattle are highly appreciated among the peasants. Especially at the markets, their services are demanded frequently. Some of them also use their talents to sell an animal at a higher price. A magician can earn 50 silver pieces per level in this way." + +msgctxt "spellinfo" +msgid "earn_silver#draig" +msgstr "In the dark alleys you can find those who sell curses and hexes on demand - but you can buy the apropriate counterspells from the followers of Draig as well. May it be a love spell for the son of a neighbour or a wart in the face of a rival. For offering these services, the sorcerer charges 50 silver pieces per level." + +msgctxt "spellinfo" +msgid "earn_silver#cerddor" +msgstr "The mages of Cerddor truly are the bards of the wizards; they love to use their sorcery to entertain the crowds and to be the center of attention. Even the apprentices study those little magic tricks, which attract and fascinate the people and thus ensnare them into leaving a few coins or more for the artist. By the end of the week, the bard will have earned 50 silver per level." + +msgctxt "spellinfo" +msgid "earn_silver#illaun" +msgstr "No one can read dreams as well as the mages of Illaun. Furthermore, they are also familiar with all other common means of foretelling the future like crystal balls, tarot cards or palms. A mentalist can earn 50 silver pieces per level and week for offering these services to peasants." + +msgctxt "spellinfo" +msgid "earn_silver#tybied" +msgstr "If the local alchemist could not help you, you should visit a scholar of Tybied. His potions and tinctures may help when nothing else does. If the cryptic formula under the wooden shoes of the unfaithful husband really helped? - well, the peasant, who isn't capable of reading, will never know. At least it helped the magician... to fill his purse. In one week he can earn 50 silver per level that way." + +msgctxt "spellinfo" +msgid "blessedharvest" +msgstr "This ritual increases the output of the local farms. Peasants in the region produce an extra silverpiece. The stronger the druid's spell is, the longer the effect will last." + +msgctxt "spellinfo" +msgid "raindance" +msgstr "This ancient rite calls upon the forces of life and fertility. For the next few weeks, the peasant's harvest will be extraordinary good." + +msgctxt "spellinfo" +msgid "concealing_aura" +msgstr "This spell will hide the whole equipment of a target unit from the looks of others." + +msgctxt "describe" +msgid "lifepotion" +msgstr "The \"Water of Life\" allows living trees to be created from logs. A Knotroot and Elvendear are heated until one can just still keep one's finger in. This is then poured into a jar and allowed to cool slowly. The extract is sufficient for 10 pieces of wood." + diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index afcceb94b..1731fa10e 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -327,10 +327,6 @@ msgctxt "spell" msgid "clone" msgstr "Seelenkopie" -msgctxt "spellinfo" -msgid "concealing_aura" -msgstr "Dieser Zauber wird die gesamte Ausrüstung der Zieleinheit für einige Zeit vor den Blicken anderer verschleiern." - msgctxt "shipinfo" msgid "balloon" msgstr "Der Sumpfgasballon besteht aus einem großen Weidenkorb, welcher Platz für maximal 5 Personen oder 500 Gewichtseinheiten bietet, und einer großen, mit Sumpfgas gefüllten Wyrmblase. Bei guten Winden kann sich der Ballon zwei Regionen pro Woche fortbewegen. Das Führen eines Ballons ist nicht einfach, und der Kapitän muss mindestens ein Segeltalent von 6 besitzen. Diese neue Entwicklung auf Eressea wird ausschließlich für den Xontormia-Expreß hergestellt und die Baupläne sind streng geheim. So ist es auch bisher noch niemandem gelungen, ein Exemplar nachzubauen." @@ -908,10 +904,6 @@ msgctxt "spellinfo" msgid "disturbingdreams" msgstr "Dieser Zauber führt in der betroffenen Region für einige Wochen zu Schlaflosigkeit und Unruhe. Den Betroffenen fällt das Lernen deutlich schwerer." -msgctxt "spellinfo" -msgid "raindance" -msgstr "Dieses uralte Tanzritual ruft die Kräfte des Lebens und der Fruchtbarkeit. Die Erträge der Bauern werden für einige Wochen deutlich besser ausfallen." - msgid "wdw_pyramid" msgstr "Pyramide" @@ -1459,10 +1451,6 @@ msgctxt "race" msgid "goblin_x" msgstr "Goblin" -msgctxt "spellinfo" -msgid "earn_silver#gwyrrd" -msgstr "Die Fähigkeiten der Gwyrrd-Magier in der Viehzucht und Heilung sind bei den Bauern sehr begehrt. Gerade auf Märkten sind ihre Dienste häufig sehr gefragt. Manch einer mag auch sein Talent dazu nutzen, ein Tier für einen besseren Preis zu verkaufen. Pro Stufe kann der Magier so 50 Silber verdienen." - msgctxt "spell" msgid "raindance" msgstr "Regentanz" @@ -1494,10 +1482,6 @@ msgstr "Mallorn" msgid "mallorn_p" msgstr "Mallorn" -msgctxt "describe" -msgid "lifepotion" -msgstr "Das 'Wasser des Lebens' ist in der Lage, aus gefällten Baumstämmen wieder lebende Bäume zu machen. Dazu wird ein knotiger Saugwurz zusammen mit einem Elfenlieb erwärmt, so dass man gerade noch den Finger reinhalten kann. Dies gieße man in ein Gefäß und lasse es langsam abkühlen. Der Extrakt reicht für 10 Holzstämme." - msgctxt "spell" msgid "homestone" msgstr "Heimstein" @@ -1740,10 +1724,6 @@ msgstr "Beschwörung eines Wasserelementares" msgid "GEBAEUDE" msgstr "GEBÄUDE" -msgctxt "spellinfo" -msgid "blessedharvest" -msgstr "Dieses Ernteritual verbessert die Erträge der arbeitenden Bauern in der Region um ein Silberstück. Je mehr Kraft der Druide investiert, desto länger wirkt der Zauber." - msgid "KRAEUTER" msgstr "KRÄUTER" @@ -3147,10 +3127,6 @@ msgctxt "spellinfo" msgid "create_focus" msgstr "Erzeugt einen Aurafokus." -msgctxt "spellinfo" -msgid "earn_silver#draig" -msgstr "In den dunkleren Gassen gibt es sie, die Flüche und Verhexungen auf Bestellung. Aber auch Gegenzauber hat der Jünger des Draigs natürlich im Angebot. Ob nun der Sohn des Nachbarn in einen Liebesbann gezogen werden soll oder die Nebenbuhlerin Pickel und Warzen bekommen soll, niemand gibt gerne zu, zu solchen Mitteln gegriffen zu haben. Für diese Dienstleistung streicht der Magier 50 Silber pro Stufe ein." - msgctxt "spell" msgid "song_of_slavery" msgstr "Gesang der Versklavung" @@ -4910,10 +4886,6 @@ msgstr "Elixier der Macht" msgid "wand_p" msgstr "Zauberstäbe" -msgctxt "spellinfo" -msgid "earn_silver#cerddor" -msgstr "Cerddormagier sind _die_ Gaukler unter den Magiern, sie lieben es das Volk zu unterhalten und im Mittelpunkt zu stehen. Schon Anfänger lernen die kleinen Kunststücke und magischen Tricks, mit denen man das Volk locken und verführen kann, den Geldbeutel ganz weit zu öffnen, und am Ende der Woche wird der Gaukler 50 Silber pro Stufe verdient haben." - msgctxt "spell" msgid "strength" msgstr "Unbekannter Effekt" @@ -4996,10 +4968,6 @@ msgstr "Myrrhe" msgid "skeleton_prefix_9" msgstr "Dunkle" -msgctxt "spellinfo" -msgid "earn_silver#illaun" -msgstr "Niemand kann so gut die Träume deuten wie ein Magier des Illaun. Auch die Kunst der Wahrsagerei, des Kartenlegens und des Handlesens sind ihm geläufig. Dafür zahlen ihm die Bauern 50 Silber pro Stufe." - msgctxt "spell" msgid "big_recruit" msgstr "Hohe Kunst der Überzeugung" @@ -5913,10 +5881,6 @@ msgctxt "spell" msgid "cerddorfumbleshield" msgstr "Bannlied" -msgctxt "spellinfo" -msgid "earn_silver#tybied" -msgstr "Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen alles, was man sonst nicht bekommen kann. Ob nun die kryptische Formel unter dem Holzschuh des untreuen Ehemannes wirklich geholfen hat - nun, der des Lesens nicht mächtige Bauer wird es nie wissen. Dem Magier hilft es auf jeden Fall... beim Füllen seines Geldbeutels. 50 Silber pro Stufe lassen sich so in einer Woche verdienen." - msgid "ANZAHL" msgstr "ANZAHL" diff --git a/res/translations/strings.en.po b/res/translations/strings.en.po index c8bd637db..0d64e9f99 100644 --- a/res/translations/strings.en.po +++ b/res/translations/strings.en.po @@ -273,10 +273,6 @@ msgctxt "spell" msgid "clone" msgstr "Doppelganger" -msgctxt "spellinfo" -msgid "concealing_aura" -msgstr "This spell will hide the whole equipment of a target unit from the looks of others." - msgctxt "spell" msgid "bloodsacrifice" msgstr "Lesser Sacrifice" @@ -695,10 +691,6 @@ msgctxt "spellinfo" msgid "disturbingdreams" msgstr "This spell causes insomnia and restlessness in a whole region for several weeks. All affected persons will learn much slower than normal." -msgctxt "spellinfo" -msgid "raindance" -msgstr "This ancient rite calls upon the forces of life and fertility. For the next few weeks, the peasant's harvest will be extraordinary good." - msgid "wdw_pyramid" msgstr "pyramid" @@ -1221,10 +1213,6 @@ msgctxt "race" msgid "goblin_x" msgstr "goblin" -msgctxt "spellinfo" -msgid "earn_silver#gwyrrd" -msgstr "The abilities of the mages of Gwyrrd concerning the breeding and healing of cattle are highly appreciated among the peasants. Especially at the markets, their services are demanded frequently. Some of them also use their talents to sell an animal at a higher price. A magician can earn 50 silver pieces per level in this way." - msgctxt "spell" msgid "raindance" msgstr "Rain Dance" @@ -1252,10 +1240,6 @@ msgstr "mallorn" msgid "mallorn_p" msgstr "mallorn" -msgctxt "describe" -msgid "lifepotion" -msgstr "The \"Water of Life\" allows living trees to be created from logs. A Knotroot and Elvendear are heated until one can just still keep one's finger in. This is then poured into a jar and allowed to cool slowly. The extract is sufficient for 10 pieces of wood." - msgid "thickfog_trail" msgstr "%s" @@ -1490,10 +1474,6 @@ msgctxt "spell" msgid "goodwinds" msgstr "Summon Water Elemental" -msgctxt "spellinfo" -msgid "blessedharvest" -msgstr "This ritual increases the output of the local farms. Peasants in the region produce an extra silverpiece. The stronger the druid's spell is, the longer the effect will last." - msgid "KRAEUTER" msgstr "HERBS" @@ -2732,10 +2712,6 @@ msgctxt "spellinfo" msgid "create_focus" msgstr "Creates an aurafocus crystal." -msgctxt "spellinfo" -msgid "earn_silver#draig" -msgstr "In the dark alleys you can find those who sell curses and hexes on demand - but you can buy the apropriate counterspells from the followers of Draig as well. May it be a love spell for the son of a neighbour or a wart in the face of a rival. For offering these services, the sorcerer charges 50 silver pieces per level." - msgctxt "spell" msgid "song_of_slavery" msgstr "Song of Slavery" @@ -4370,10 +4346,6 @@ msgstr "elixir of power" msgid "wand_p" msgstr "wands" -msgctxt "spellinfo" -msgid "earn_silver#cerddor" -msgstr "The mages of Cerddor truly are the bards of the wizards; they love to use their sorcery to entertain the crowds and to be the center of attention. Even the apprentices study those little magic tricks, which attract and fascinate the people and thus ensnare them into leaving a few coins or more for the artist. By the end of the week, the bard will have earned 50 silver per level." - msgctxt "spell" msgid "strength" msgstr "Unknown Effect" @@ -4426,10 +4398,6 @@ msgstr "trees" msgid "myrrh_p" msgstr "myrrh" -msgctxt "spellinfo" -msgid "earn_silver#illaun" -msgstr "No one can read dreams as well as the mages of Illaun. Furthermore, they are also familiar with all other common means of foretelling the future like crystal balls, tarot cards or palms. A mentalist can earn 50 silver pieces per level and week for offering these services to peasants." - msgctxt "spell" msgid "big_recruit" msgstr "High art of persuasion" @@ -5222,10 +5190,6 @@ msgctxt "spell" msgid "cerddorfumbleshield" msgstr "Countersong" -msgctxt "spellinfo" -msgid "earn_silver#tybied" -msgstr "If the local alchemist could not help you, you should visit a scholar of Tybied. His potions and tinctures may help when nothing else does. If the cryptic formula under the wooden shoes of the unfaithful husband really helped? - well, the peasant, who isn't capable of reading, will never know. At least it helped the magician... to fill his purse. In one week he can earn 50 silver per level that way." - msgctxt "keyword" msgid "teach" msgstr "TEACH" From 64eb545b4a864f2be65f03c5590f57ecb7784b0f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Jul 2018 20:24:23 +0200 Subject: [PATCH 13/15] Bug 2460: Startgeschenke --- scripts/eressea/equipment.lua | 15 +++++++++++---- scripts/tests/config.lua | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/eressea/equipment.lua b/scripts/eressea/equipment.lua index 6e4ccfc9b..8852dfb27 100644 --- a/scripts/eressea/equipment.lua +++ b/scripts/eressea/equipment.lua @@ -1,13 +1,20 @@ --- forward declaration required: - +-- forward declarations required: local self = {} + +local function equip_first(u) + equip_newunits(u) + name = 'seed_' .. u.race + equip_unit(u, name, 255) +end + local mysets = { ['first_unit'] = { ['items'] = { ['money'] = 2500, ['log'] = 10, ['stone'] = 4 - } + }, + ['callback'] = equip_first }, ['seed_unit'] = { ['items'] = { @@ -75,7 +82,7 @@ local mysets = { }, ['seed_insect'] = { ['items'] = { - ['nestwarmth'] =9 + ['nestwarmth'] = 9 } }, ['seed_halfling'] = { diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index a3104a6b6..316a8ccca 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -14,6 +14,22 @@ function test_read_race() assert_not_nil(f) end +function test_first_insect() + local f = faction.create('insect') + local r = region.create(0, 0, "plain") + local u = unit.create(f, r, 1) + u:equip('first_unit') + assert_equal(9, u:get_item('nestwarmth')) +end + +function test_first_troll() + local f = faction.create('troll') + local r = region.create(0, 0, "plain") + local u = unit.create(f, r, 1) + u:equip('first_unit') + assert_equal(2, u:eff_skill('perception')) +end + function test_seed_unit() local r = region.create(0, 0, "plain") local f = faction.create('human') From 21cbff0740a827fd7aff8af77c1c772ef79fed98 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Jul 2018 20:54:28 +0200 Subject: [PATCH 14/15] update submodules --- storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage b/storage index 6eea76952..0ef4b39e3 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 6eea7695285f9c9f1d25421897ca55f466ef7566 +Subproject commit 0ef4b39e39d8146d6ca323500a285c53843db988 From 820264aa8214af81ce5bdb8c7e252af5079fbe55 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Jul 2018 13:39:23 +0200 Subject: [PATCH 15/15] BUG 2461: Liste der Angreifer zeigt nicht alle Parteien. --- src/battle.c | 2 +- src/battle.h | 1 + src/battle.test.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++ src/reports.c | 10 +++-- 4 files changed, 112 insertions(+), 5 deletions(-) diff --git a/src/battle.c b/src/battle.c index be950af7f..38590b8a6 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3323,7 +3323,7 @@ fighter * get_fighter(battle * b, const struct unit * u) return 0; } -static int join_battle(battle * b, unit * u, bool attack, fighter ** cp) +int join_battle(battle * b, unit * u, bool attack, fighter ** cp) { side *s; fighter *fc = NULL; diff --git a/src/battle.h b/src/battle.h index c9429a6b3..48fa7c63a 100644 --- a/src/battle.h +++ b/src/battle.h @@ -261,6 +261,7 @@ extern "C" { void free_battle(struct battle * b); struct fighter *make_fighter(struct battle *b, struct unit *u, struct side * s, bool attack); + int join_battle(struct battle * b, struct unit * u, bool attack, struct fighter ** cp); struct side *make_side(struct battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction); diff --git a/src/battle.test.c b/src/battle.test.c index 56ca24ac4..7c7012e77 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -1,6 +1,8 @@ #include #include "battle.h" + +#include "reports.h" #include "skill.h" #include @@ -16,6 +18,8 @@ #include #include +#include +#include #include #include #include @@ -552,6 +556,103 @@ static void test_battle_skilldiff(CuTest *tc) test_teardown(); } +static void test_battle_report_one(CuTest *tc) +{ + battle * b = NULL; + region *r; + unit *u1, *u2; + message *m; + const char *expect; + fighter *fig; + + test_setup(); + mt_create_va(mt_new("start_battle", NULL), "factions:string", MT_NEW_END); + r = test_create_plain(0, 0); + u1 = test_create_unit(test_create_faction(NULL), r); + u2 = test_create_unit(test_create_faction(NULL), r); + b = make_battle(r); + join_battle(b, u1, true, &fig); + join_battle(b, u2, false, &fig); + faction_setname(u1->faction, "Monster"); + expect = factionname(u1->faction); + + report_battle_start(b); + CuAssertPtrNotNull(tc, m = test_find_messagetype(u1->faction->battles->msgs, "start_battle")); + CuAssertStrEquals(tc, expect, (const char *)m->parameters[0].v); + + free_battle(b); + test_teardown(); +} + +static void test_battle_report_two(CuTest *tc) +{ + battle * b = NULL; + region *r; + unit *u1, *u2; + message *m; + char expect[64]; + fighter *fig; + struct locale *lang; + + test_setup(); + lang = test_create_locale(); + locale_setstring(lang, "and", "and"); + mt_create_va(mt_new("start_battle", NULL), "factions:string", MT_NEW_END); + r = test_create_plain(0, 0); + u1 = test_create_unit(test_create_faction(NULL), r); + u1->faction->locale = lang; + u2 = test_create_unit(test_create_faction(NULL), r); + u2->faction->locale = lang; + + str_slprintf(expect, sizeof(expect), "%s and %s", factionname(u1->faction), factionname(u2->faction)); + b = make_battle(r); + join_battle(b, u1, true, &fig); + join_battle(b, u2, true, &fig); + report_battle_start(b); + + CuAssertPtrNotNull(tc, m = test_find_messagetype(u1->faction->battles->msgs, "start_battle")); + CuAssertStrEquals(tc, expect, (const char *)m->parameters[0].v); + + free_battle(b); + test_teardown(); +} + +static void test_battle_report_three(CuTest *tc) +{ + battle * b = NULL; + region *r; + unit *u1, *u2, *u3; + message *m; + char expect[64]; + fighter *fig; + struct locale *lang; + + test_setup(); + lang = test_create_locale(); + locale_setstring(lang, "and", "and"); + mt_create_va(mt_new("start_battle", NULL), "factions:string", MT_NEW_END); + r = test_create_plain(0, 0); + u1 = test_create_unit(test_create_faction(NULL), r); + u1->faction->locale = lang; + u2 = test_create_unit(test_create_faction(NULL), r); + u2->faction->locale = lang; + u3 = test_create_unit(test_create_faction(NULL), r); + u3->faction->locale = lang; + + str_slprintf(expect, sizeof(expect), "%s, %s and %s", factionname(u1->faction), factionname(u2->faction), factionname(u3->faction)); + b = make_battle(r); + join_battle(b, u1, true, &fig); + join_battle(b, u2, true, &fig); + join_battle(b, u3, true, &fig); + report_battle_start(b); + + CuAssertPtrNotNull(tc, m = test_find_messagetype(u1->faction->battles->msgs, "start_battle")); + CuAssertStrEquals(tc, expect, (const char *)m->parameters[0].v); + + free_battle(b); + test_teardown(); +} + static void test_battle_skilldiff_building(CuTest *tc) { troop ta, td; @@ -690,6 +791,9 @@ CuSuite *get_battle_suite(void) SUITE_ADD_TEST(suite, test_select_armor); SUITE_ADD_TEST(suite, test_battle_skilldiff); SUITE_ADD_TEST(suite, test_battle_skilldiff_building); + SUITE_ADD_TEST(suite, test_battle_report_one); + SUITE_ADD_TEST(suite, test_battle_report_two); + SUITE_ADD_TEST(suite, test_battle_report_three); SUITE_ADD_TEST(suite, test_defenders_get_building_bonus); SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus); SUITE_ADD_TEST(suite, test_building_bonus_respects_size); diff --git a/src/reports.c b/src/reports.c index d240ee86d..5355a1db9 100644 --- a/src/reports.c +++ b/src/reports.c @@ -2193,10 +2193,12 @@ void report_battle_start(battle * b) } } } - if (first && lastf) { - sbs_strcat(&sbs, " "); - sbs_strcat(&sbs, LOC(f->locale, "and")); - sbs_strcat(&sbs, " "); + if (lastf) { + if (first) { + sbs_strcat(&sbs, " "); + sbs_strcat(&sbs, LOC(f->locale, "and")); + sbs_strcat(&sbs, " "); + } sbs_strcat(&sbs, lastf); }