forked from github/server
clean up config.c, remove static configuration caching
This commit is contained in:
parent
bc936bf019
commit
990fda6234
|
@ -3134,6 +3134,12 @@ static void peasant_taxes(region * r)
|
|||
}
|
||||
}
|
||||
|
||||
static bool rule_auto_taxation(void)
|
||||
{
|
||||
int rule = get_param_int(global.parameters, "rules.economy.taxation", 0);
|
||||
return rule != 0;
|
||||
}
|
||||
|
||||
void produce(struct region *r)
|
||||
{
|
||||
request workers[MAX_WORKERS];
|
||||
|
|
|
@ -233,6 +233,12 @@ static bool can_give_men(const unit *u, order *ord, message **msg) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool rule_transfermen(void)
|
||||
{
|
||||
int rule = get_param_int(global.parameters, "rules.transfermen", 1);
|
||||
return rule != 0;
|
||||
}
|
||||
|
||||
message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||
{
|
||||
ship *sh;
|
||||
|
|
|
@ -216,26 +216,13 @@ int LongHunger(const struct unit *u)
|
|||
|
||||
int SkillCap(skill_t sk)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (sk == SK_MAGIC)
|
||||
return 0; /* no caps on magic */
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
gamecookie = global.cookie;
|
||||
rule = get_param_int(global.parameters, "skill.maxlevel", 0);
|
||||
}
|
||||
return rule;
|
||||
if (sk == SK_MAGIC) return 0; /* no caps on magic */
|
||||
return get_param_int(global.parameters, "skill.maxlevel", 0);
|
||||
}
|
||||
|
||||
int NMRTimeout(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
gamecookie = global.cookie;
|
||||
rule = get_param_int(global.parameters, "nmr.timeout", 0);
|
||||
}
|
||||
return rule;
|
||||
return get_param_int(global.parameters, "nmr.timeout", 0);
|
||||
}
|
||||
|
||||
race_t old_race(const struct race * rc)
|
||||
|
@ -1294,103 +1281,44 @@ int cmp_current_owner(const building * b, const building * a)
|
|||
|
||||
bool rule_stealth_other(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule = get_param_int(global.parameters, "stealth.faction.other", 1);
|
||||
gamecookie = global.cookie;
|
||||
assert(rule >= 0);
|
||||
}
|
||||
int rule = get_param_int(global.parameters, "stealth.faction.other", 1);
|
||||
return rule != 0;
|
||||
}
|
||||
|
||||
bool rule_stealth_anon(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule = get_param_int(global.parameters, "stealth.faction.anon", 1);
|
||||
gamecookie = global.cookie;
|
||||
assert(rule >= 0);
|
||||
}
|
||||
int rule = get_param_int(global.parameters, "stealth.faction.anon", 1);
|
||||
return rule != 0;
|
||||
}
|
||||
|
||||
bool rule_region_owners(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule = get_param_int(global.parameters, "rules.region_owners", 0);
|
||||
gamecookie = global.cookie;
|
||||
assert(rule >= 0);
|
||||
}
|
||||
int rule = get_param_int(global.parameters, "rules.region_owners", 0);
|
||||
return rule != 0;
|
||||
}
|
||||
|
||||
bool rule_auto_taxation(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule =
|
||||
get_param_int(global.parameters, "rules.economy.taxation", 0);
|
||||
gamecookie = global.cookie;
|
||||
assert(rule >= 0);
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
|
||||
int rule_blessed_harvest(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule =
|
||||
get_param_int(global.parameters, "rules.blessed_harvest.flags",
|
||||
int rule = get_param_int(global.parameters, "rules.blessed_harvest.flags",
|
||||
HARVEST_WORK);
|
||||
gamecookie = global.cookie;
|
||||
assert(rule >= 0);
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
|
||||
int rule_alliance_limit(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule = get_param_int(global.parameters, "rules.limit.alliance", 0);
|
||||
gamecookie = global.cookie;
|
||||
int rule = get_param_int(global.parameters, "rules.limit.alliance", 0);
|
||||
assert(rule >= 0);
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
|
||||
int rule_faction_limit(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule = get_param_int(global.parameters, "rules.limit.faction", 0);
|
||||
gamecookie = global.cookie;
|
||||
int rule = get_param_int(global.parameters, "rules.limit.faction", 0);
|
||||
assert(rule >= 0);
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
|
||||
bool rule_transfermen(void)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule = -1;
|
||||
if (rule < 0 || gamecookie != global.cookie) {
|
||||
rule = get_param_int(global.parameters, "rules.transfermen", 1);
|
||||
gamecookie = global.cookie;
|
||||
assert(rule >= 0);
|
||||
}
|
||||
return rule != 0;
|
||||
}
|
||||
|
||||
static int
|
||||
default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||
{
|
||||
|
|
|
@ -151,7 +151,6 @@ extern "C" {
|
|||
int cmp_current_owner(const struct building *b,
|
||||
const struct building *bother);
|
||||
|
||||
bool rule_transfermen(void);
|
||||
bool rule_region_owners(void);
|
||||
bool rule_stealth_other(void); // units can pretend to be another faction, TARNE PARTEI <no>
|
||||
bool rule_stealth_anon(void); // units can anonymize their faction, TARNE PARTEI [NICHT]
|
||||
|
@ -160,7 +159,6 @@ extern "C" {
|
|||
#define HARVEST_WORK 0x00
|
||||
#define HARVEST_TAXES 0x01
|
||||
int rule_blessed_harvest(void);
|
||||
bool rule_auto_taxation(void);
|
||||
#define GIVE_SELF 1
|
||||
#define GIVE_PEASANTS 2
|
||||
#define GIVE_LUXURIES 4
|
||||
|
|
|
@ -1366,7 +1366,7 @@ int eff_skill(const unit * u, const skill *sv, const region *r)
|
|||
|
||||
if (mlevel > 0) {
|
||||
int skillcap = SkillCap(sv->id);
|
||||
if (skillcap && mlevel > skillcap) {
|
||||
if (skillcap>0 && mlevel > skillcap) {
|
||||
return skillcap;
|
||||
}
|
||||
return mlevel;
|
||||
|
|
|
@ -343,7 +343,8 @@ int teach_cmd(unit * u, struct order *ord)
|
|||
for (student = r->units; teaching && student; student = student->next) {
|
||||
if (LongHunger(student)) {
|
||||
continue;
|
||||
} else if (student->faction == u->faction) {
|
||||
}
|
||||
else if (student->faction == u->faction) {
|
||||
if (getkeyword(student->thisorder) == K_STUDY) {
|
||||
/* Input ist nun von student->thisorder !! */
|
||||
init_order(student->thisorder);
|
||||
|
@ -534,7 +535,7 @@ static double study_speedup(unit * u, skill_t s, study_rule_t rule)
|
|||
int study_cmd(unit * u, order * ord)
|
||||
{
|
||||
region *r = u->region;
|
||||
int p;
|
||||
int p, cap;
|
||||
magic_t mtyp;
|
||||
int l;
|
||||
int studycost, days;
|
||||
|
@ -569,7 +570,8 @@ int study_cmd(unit * u, order * ord)
|
|||
cmistake(u, ord, 77, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk, 0)) {
|
||||
cap = SkillCap(sk);
|
||||
if (cap > 0 && cap <= effskill(u, sk, 0)) {
|
||||
cmistake(u, ord, 771, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue