From 9baba00087bd8bdaf2d68ecbaad2b2352d20267a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Sep 2016 21:29:42 +0200 Subject: [PATCH 1/4] use mtype->key instead of repeated hashstring calls. --- src/util/crmessage.c | 4 ++-- src/util/nrmessage.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/crmessage.c b/src/util/crmessage.c index 98afe0f05..56f1e5dcd 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -81,7 +81,7 @@ static crmessage_type *crtypes[CRMAXHASH]; static crmessage_type *crt_find(const struct message_type *mtype) { - unsigned int hash = hashstring(mtype->name) % CRMAXHASH; + unsigned int hash = mtype->key % CRMAXHASH; crmessage_type *found = NULL; crmessage_type *type = crtypes[hash]; while (type) { @@ -94,7 +94,7 @@ static crmessage_type *crt_find(const struct message_type *mtype) void crt_register(const struct message_type *mtype) { - unsigned int hash = hashstring(mtype->name) % CRMAXHASH; + unsigned int hash = mtype->key % CRMAXHASH; crmessage_type *crt = crtypes[hash]; while (crt && crt->mtype != mtype) { crt = crt->next; diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index e3b0bcc0b..79638ec30 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -40,7 +40,7 @@ nrmessage_type *nrt_find(const struct locale * lang, const struct message_type * mtype) { nrmessage_type *found = NULL; - unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH; + unsigned int hash = mtype->key % NRT_MAXHASH; nrmessage_type *type = nrtypes[hash]; while (type) { if (type->mtype == mtype) { @@ -101,7 +101,7 @@ void nrt_register(const struct message_type *mtype, const struct locale *lang, const char *string, int level, const char *section) { - unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH; + unsigned int hash = mtype->key % NRT_MAXHASH; nrmessage_type *nrt = nrtypes[hash]; while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) { nrt = nrt->next; From f4eda9f59ecfca40f1f8ff2fb86515f135a56f96 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 06:28:12 +0100 Subject: [PATCH 2/4] prefer dice to dice_rand --- src/items.c | 4 ++-- src/kernel/region.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/items.c b/src/items.c index 78f6e3188..0f97ea675 100644 --- a/src/items.c +++ b/src/items.c @@ -178,8 +178,8 @@ struct order *ord) return 0; } -#define BAGPIPEFRACTION dice_rand("2d4+2") -#define BAGPIPEDURATION dice_rand("2d10+4") +#define BAGPIPEFRACTION (dice(2,4)+2) +#define BAGPIPEDURATION (dice(2,10)+4) static int use_bagpipeoffear(struct unit *u, const struct item_type *itype, diff --git a/src/kernel/region.c b/src/kernel/region.c index e4f33db33..48256fb60 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1217,7 +1217,7 @@ void terraform_region(region * r, const terrain_type * terrain) if (!fval(r, RF_CHAOTIC)) { int peasants; - peasants = (region_maxworkers(r) * (20 + dice_rand("6d10"))) / 100; + peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100; rsetpeasants(r, MAX(100, peasants)); rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, INT_MAX) + 1) + rng_int() % 5)); From 40e0a9a65f956c037cff8dba0a4e0030c24ede44 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Mar 2017 22:21:27 +0100 Subject: [PATCH 3/4] merge bugs --- src/kernel/item.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index d9a466543..97ae92174 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -565,46 +565,6 @@ item *i_new(const item_type * itype, int size) #include "region.h" -static int -give_horses(unit * s, unit * d, const item_type * itype, int n, -struct order *ord) -{ - if (d == NULL) { - int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - region *r = s->region; - if (use < n) { - use += - use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, - n - use); - } - if (r->land) { - rsethorses(r, rhorses(r) + use); - } - return 0; - } - return -1; /* use the mechanism */ -} - -static int -give_money(unit * s, unit * d, const item_type * itype, int n, -struct order *ord) -{ - if (d == NULL) { - int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - region *r = s->region; - if (use < n) { - use += - use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, - n - use); - } - if (r->land) { - rsetmoney(r, rmoney(r) + use); - } - return 0; - } - return -1; /* use the mechanism */ -} - const potion_type *oldpotiontype[MAX_POTIONS + 1]; /*** alte items ***/ From 2b4d2db112555ecfa8f7704644b36d27f0b2a145 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Mar 2017 16:23:33 +0100 Subject: [PATCH 4/4] VS 15 not yet supported. --- tests/runtests.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/runtests.bat b/tests/runtests.bat index 7a58e5762..41b5f8056 100644 --- a/tests/runtests.bat +++ b/tests/runtests.bat @@ -3,7 +3,6 @@ IF EXIST ..\build-vs10 SET BUILD=..\build-vs10\eressea\Debug IF EXIST ..\build-vs11 SET BUILD=..\build-vs11\eressea\Debug IF EXIST ..\build-vs12 SET BUILD=..\build-vs12\eressea\Debug IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug -IF EXIST ..\build-vs15 SET BUILD=..\build-vs15\eressea\Debug SET SERVER=%BUILD%\eressea.exe %BUILD%\test_eressea.exe %SERVER% ..\scripts\run-tests.lua