From a4498f8b433532170214cc76a24ee97a05d70b96 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Sep 2016 21:27:46 +0200 Subject: [PATCH 1/2] require at least 2K peasants in starting regions --- scripts/eressea/autoseed.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/eressea/autoseed.lua b/scripts/eressea/autoseed.lua index d0f83b6d3..2441c7079 100644 --- a/scripts/eressea/autoseed.lua +++ b/scripts/eressea/autoseed.lua @@ -3,6 +3,8 @@ local autoseed = {} -- minimum required resources in the 7-hex neighborhood: local peasants = 10000 local trees = 800 +-- minimum resources in the region itself: +local min_peasants = 2000 -- number of starters per region: local per_region = 2 @@ -23,11 +25,13 @@ 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 - sp = score(r, "peasant") - st = score(r, "tree") - if sp >= peasants then - if st >= trees then - table.insert(sel, r) + if r:get_resource("peasant") >= min_peasants then + sp = score(r, "peasant") + st = score(r, "tree") + if sp >= peasants then + if st >= trees then + table.insert(sel, r) + end end end end From 34a6dd8d543915c91be0eb411a068d622908bd11 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 22 Oct 2016 22:35:10 +0200 Subject: [PATCH 2/2] fix crash in 997: re-introduce cfindhash. this prevents duplicate curse.no values. --- src/kernel/curse.c | 9 +++++++++ src/kernel/curse.h | 1 + src/kernel/unit.c | 1 + 3 files changed, 11 insertions(+) diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 612127182..d545bfd71 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -98,6 +98,15 @@ static void cunhash(curse * c) } } +curse *cfindhash(int i) +{ + curse *old; + + for (old = cursehash[i % MAXENTITYHASH]; old; old = old->nexthash) + if (old->no == i) + return old; + return NULL; +} /* ------------------------------------------------------------- */ /* at_curse */ void curse_init(attrib * a) diff --git a/src/kernel/curse.h b/src/kernel/curse.h index c78e43405..534a936e3 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -285,6 +285,7 @@ extern "C" { void ct_register(const curse_type *); void ct_checknames(void); + curse *cfindhash(int i); curse *findcurse(int curseid); void curse_init(struct attrib *a); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index a95dbe4cb..455c789ac 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1876,6 +1876,7 @@ int newunitid(void) start_random_no = random_unit_no; while (ufindhash(random_unit_no) || dfindhash(random_unit_no) + || cfindhash(random_unit_no) || forbiddenid(random_unit_no)) { random_unit_no++; if (random_unit_no == MAX_UNIT_NR + 1) {