speeding up produceexp_chance

This commit is contained in:
Enno Rehling 2015-09-12 16:41:22 +02:00
parent 9bdc811582
commit 8a95ea0c00
2 changed files with 7 additions and 2 deletions

View File

@ -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;

View File

@ -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))