From 62fbee2eb31ff6dcaf32e61acbe2bff8e28393ea Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 12 Oct 2015 18:59:15 +0200 Subject: [PATCH 1/5] eliminate find_spell warning for games where nobody is cursed, and you cannot summon igjarjuk --- src/battle.c | 4 ++-- src/kernel/spell.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle.c b/src/battle.c index 3980d71c8..9c6c37fb1 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1699,9 +1699,9 @@ void do_combatmagic(battle * b, combatmagic_t was) if (was == DO_PRECOMBATSPELL) { for (s = b->sides; s != b->sides + b->nsides; ++s) { fighter *fig = 0; - if (s->bf->attacker) { + if (s->bf->attacker && fval(s->faction, FFL_CURSED)) { spell *sp = find_spell("igjarjuk"); - if (sp && fval(s->faction, FFL_CURSED)) { + if (sp) { int si; for (si = 0; s->enemies[si]; ++si) { side *se = s->enemies[si]; diff --git a/src/kernel/spell.c b/src/kernel/spell.c index b9a8b5895..eb505430e 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -103,7 +103,7 @@ spell *find_spell(const char *name) cb_get_kv(match, &sp, sizeof(sp)); } else { - log_warning("find_spell: could not find spell '%s'\n", name); + log_debug("find_spell: could not find spell '%s'\n", name); } return sp; } From 86fea3723b2550c0f93563bd76969c387c53f5c5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Oct 2015 20:55:19 +0200 Subject: [PATCH 2/5] try adding coverity scan --- .travis.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 003fb67ad..3586024a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,33 @@ sudo: false language: c compiler: - - gcc - - clang +- gcc +- clang script: s/travis-build addons: apt: packages: - - liblua5.2-dev - - libncurses5-dev - - libsqlite3-dev - - libxml2-dev - - valgrind + - liblua5.2-dev + - libncurses5-dev + - libsqlite3-dev + - libxml2-dev + - valgrind os: - - linux +- linux notifications: slack: secure: F89aXLWaE125PaJIlETv12jT4EfH6wLXJmGCPZzrN3OcLn2ahDWqjwuzR7lOEDf2nAISmeMPyDZMhEHXLNHAE5qP6lg9yliYQw5hzGmDK9m1xUq/pPEne/b2Y7K3my1mkRZ6n3asbHgSmBWAfCIk1JN8R5Rv+rmbLuWLc+zofts= +env: + global: + secure: SOuZkWHfQmKf7qCVkK8WSsTU7R9f2nJYh1tMFdiauVKfdOSqYZwoPomp9S+7cPZhGrYEZ91mPadrWGTD/02c+tXVOJA51JGzvM55kl8Dy1htqHt7thCjAr1cDRh/Ek+qLGGf4CwAlzO/xnSUCttvioT8F678HJgArwqnR6i3Mgc= + +addons: + coverity_scan: + project: + name: "eressea/server" + description: "Eressea PBEM server" + notification_email: enno.rehling@gmail.com + build_command: s/travis-build + branch_pattern: coverity_scan +# build_command_prepend: "" + From 50f9f37ecc1d5cab03fd6e05ace92344840d08f4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 22 Oct 2015 21:01:46 +0200 Subject: [PATCH 3/5] Revert "try adding coverity scan" This reverts commit 86fea3723b2550c0f93563bd76969c387c53f5c5. --- .travis.yml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3586024a6..003fb67ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,19 @@ sudo: false language: c compiler: -- gcc -- clang + - gcc + - clang script: s/travis-build addons: apt: packages: - - liblua5.2-dev - - libncurses5-dev - - libsqlite3-dev - - libxml2-dev - - valgrind + - liblua5.2-dev + - libncurses5-dev + - libsqlite3-dev + - libxml2-dev + - valgrind os: -- linux + - linux notifications: slack: secure: F89aXLWaE125PaJIlETv12jT4EfH6wLXJmGCPZzrN3OcLn2ahDWqjwuzR7lOEDf2nAISmeMPyDZMhEHXLNHAE5qP6lg9yliYQw5hzGmDK9m1xUq/pPEne/b2Y7K3my1mkRZ6n3asbHgSmBWAfCIk1JN8R5Rv+rmbLuWLc+zofts= -env: - global: - secure: SOuZkWHfQmKf7qCVkK8WSsTU7R9f2nJYh1tMFdiauVKfdOSqYZwoPomp9S+7cPZhGrYEZ91mPadrWGTD/02c+tXVOJA51JGzvM55kl8Dy1htqHt7thCjAr1cDRh/Ek+qLGGf4CwAlzO/xnSUCttvioT8F678HJgArwqnR6i3Mgc= - -addons: - coverity_scan: - project: - name: "eressea/server" - description: "Eressea PBEM server" - notification_email: enno.rehling@gmail.com - build_command: s/travis-build - branch_pattern: coverity_scan -# build_command_prepend: "" - From 451303d7d3d7dea74d373a559fcc462c9afd5dd4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 3 Nov 2015 11:54:08 +0100 Subject: [PATCH 4/5] autoseed as a module for E2 made from pieces of newplayer.lua and populate.lua --- scripts/eressea/autoseed.lua | 102 +++++++++++++++++++++++++++++++++++ scripts/eressea/e2/init.lua | 1 + 2 files changed, 103 insertions(+) create mode 100644 scripts/eressea/autoseed.lua diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua new file mode 100644 index 000000000..69a21a310 --- /dev/null +++ b/scripts/eressea/autoseed.lua @@ -0,0 +1,102 @@ +local autoseed = {} + +-- minimum required resources in the 7-hex neighborhood: +local peasants = 20000 +local trees = 1000 +-- number of starters per region: +local per_region = 2 + +local function score(r, res) + assert(r) + res = res or "peasant" + local x, y, rn + local peas = r:get_resource(res) + for _, rn in pairs(r.adj) do + if rn and not rn.units() then + peas = peas + rn:get_resource(res) + end + end + return peas +end + +local function select_regions(regions, peasants, trees) + local sel = {} + for r in regions do + if not r.plane and r.terrain~="ocean" and not r.units() then + if score(r, "peasant") >= peasants and score(r, "tree") >= trees then + table.insert(sel, r) + end + end + end + return sel +end + +local function read_players() +-- return {{ email = "noreply@mailinator.com", race = "dwarf", lang = "de" }} + local players = {} + local input = io.open("newfactions", "r") + while input do + 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 + table.insert(players, { race = race, lang = lang, email = email }) + end + end + return players +end + +local function seed(r, email, race, lang) + local f = faction.create(email, race, lang) + local u = unit.create(f, r) + equip_unit(u, "new_faction") + equip_unit(u, "first_unit") + equip_unit(u, "first_" .. race, 7) -- disable old callbacks + unit.create(f, r, 5):set_skill("mining", 30) + unit.create(f, r, 5):set_skill("quarrying", 30) + f:set_origin(r) + return f +end + +local function get_faction_by_email(email) + for f in factions() do + if f.email == email then + return f + end + end + return nil +end + +function autoseed.init() + -- local newbs = {} + local num_seeded = 2 + local start = nil + + eressea.log.info('autoseed new players') + players = read_players() + if players and #players > 0 then + local sel + eressea.log.info(#players .. ' new players') + sel = select_regions(regions(), peasants, trees) + end + for _, p in ipairs(players) do + if num_seeded == per_region then + while not start or start.units() do + local index = 1 + (rng_int() % #sel) + start = sel[index] + end + num_seeded = 0 + end + local dupe = get_faction_by_email(p.email) + if dupe then + eressea.log.warning("seed: duplicate email " .. p.email .. " already used by faction " .. tostring(f)) + else + local f = seed(start, p.email, p.race or "human", p.lang or "de") + num_seeded = num_seeded + 1 + print("new faction ".. tostring(f) .. " starts in ".. tostring(start)) + -- table.insert(newbs, f) + end + end +end + +return autoseed diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index 2bdc79b64..dd01a06d4 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -3,6 +3,7 @@ eressea.log.debug("rules for game E2") return { require('eressea'), + require('eressea.autoseed'), require('eressea.xmas2004'), require('eressea.xmas2005'), require('eressea.xmas2006'), From ee6db51068bbb66bdd48b155f7d01d24e9fa7b73 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 3 Nov 2015 12:27:51 +0100 Subject: [PATCH 5/5] release version 3.6.6 --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 7eabd81de..e553a30b1 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 6 -#define VERSION_BUILD 5 +#define VERSION_BUILD 6