From 8a95ea0c0025b7a5b8e8f067b0167b44da3d46ab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Sep 2015 16:41:22 +0200 Subject: [PATCH] speeding up produceexp_chance --- src/kernel/config.h | 2 +- src/kernel/unit.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kernel/config.h b/src/kernel/config.h index c8fc106e6..ade8bfa63 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -261,7 +261,7 @@ extern "C" { unsigned int data_turn; struct param *parameters; void *vm_state; - float producexpchance; + double producexpchance; int cookie; int data_version; /* TODO: eliminate in favor of gamedata.version */ struct _dictionary_ *inifile; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 5fb841d9a..696015aef 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1935,7 +1935,12 @@ bool unit_can_study(const unit *u) { } static double produceexp_chance(void) { - return get_param_flt(global.parameters, "study.from_use", 1.0 / 3); + static int update = 0; + if (update != global.cookie) { + global.producexpchance = get_param_flt(global.parameters, "study.from_use", 1.0 / 3); + update = global.cookie; + } + return global.producexpchance; } void produceexp_ex(struct unit *u, skill_t sk, int n, bool (*learn)(unit *, skill_t, double))