forked from github/server
eliminate even more static variable caches
This commit is contained in:
parent
f7698d92a9
commit
2e392b4d7c
11 changed files with 58 additions and 101 deletions
|
@ -77,7 +77,7 @@
|
|||
"rules.blessed_harvest.flags": 1,
|
||||
"rules.magic.elfpower": true,
|
||||
"rules.magic.playerschools": "gwyrrd illaun draig cerddor",
|
||||
"rules.build.other_buildings": 1,
|
||||
"rules.build.other_buildings": true,
|
||||
"rules.economy.taxation": 1,
|
||||
"rules.food.flags": 2,
|
||||
"rules.economy.roqf": 5,
|
||||
|
|
|
@ -3136,8 +3136,11 @@ static void peasant_taxes(region * r)
|
|||
|
||||
static bool rule_auto_taxation(void)
|
||||
{
|
||||
int rule = config_get_int("rules.economy.taxation", 0);
|
||||
return rule != 0;
|
||||
return config_get_int("rules.economy.taxation", 0) != 0;
|
||||
}
|
||||
|
||||
static bool rule_autowork(void) {
|
||||
return config_get_int("work.auto", 0) != 0;
|
||||
}
|
||||
|
||||
void produce(struct region *r)
|
||||
|
@ -3145,7 +3148,6 @@ void produce(struct region *r)
|
|||
request workers[MAX_WORKERS];
|
||||
request *taxorders, *lootorders, *sellorders, *stealorders, *buyorders;
|
||||
unit *u;
|
||||
static int rule_autowork = -1;
|
||||
bool limited = true;
|
||||
request *nextworker = workers;
|
||||
assert(r);
|
||||
|
@ -3160,10 +3162,6 @@ void produce(struct region *r)
|
|||
*
|
||||
* lehren vor lernen. */
|
||||
|
||||
if (rule_autowork < 0) {
|
||||
rule_autowork = config_get_int("work.auto", 0);
|
||||
}
|
||||
|
||||
assert(rmoney(r) >= 0);
|
||||
assert(rpeasants(r) >= 0);
|
||||
|
||||
|
@ -3237,7 +3235,7 @@ void produce(struct region *r)
|
|||
break;
|
||||
|
||||
case K_WORK:
|
||||
if (!rule_autowork && do_work(u, u->thisorder, nextworker) == 0) {
|
||||
if (!rule_autowork() && do_work(u, u->thisorder, nextworker) == 0) {
|
||||
assert(nextworker - workers < MAX_WORKERS);
|
||||
++nextworker;
|
||||
}
|
||||
|
@ -3282,7 +3280,7 @@ void produce(struct region *r)
|
|||
* auszugeben bereit sind. */
|
||||
if (entertaining)
|
||||
expandentertainment(r);
|
||||
if (!rule_autowork) {
|
||||
if (!rule_autowork()) {
|
||||
expandwork(r, workers, nextworker, maxworkingpeasants(r));
|
||||
}
|
||||
if (taxorders)
|
||||
|
|
|
@ -685,7 +685,6 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
|||
const char *btname;
|
||||
order *new_order = NULL;
|
||||
const struct locale *lang = u->faction->locale;
|
||||
static int rule_other = -1;
|
||||
|
||||
assert(u->number);
|
||||
assert(btype->construction);
|
||||
|
@ -749,10 +748,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
|||
n = 1;
|
||||
}
|
||||
if (b) {
|
||||
if (rule_other < 0) {
|
||||
rule_other =
|
||||
config_get_int("rules.build.other_buildings", 1);
|
||||
}
|
||||
bool rule_other = config_get_int("rules.build.other_buildings", 1) != 0;
|
||||
if (!rule_other) {
|
||||
unit *owner = building_owner(b);
|
||||
if (!owner || owner->faction != u->faction) {
|
||||
|
|
|
@ -82,10 +82,7 @@ void terraform_resources(region * r)
|
|||
{
|
||||
int i;
|
||||
const terrain_type *terrain = r->terrain;
|
||||
static int terraform_all = -1;
|
||||
if (terraform_all < 0) {
|
||||
terraform_all = config_get_int("rules.terraform.all", 0);
|
||||
}
|
||||
bool terraform_all = config_get_int("rules.terraform.all", 0) != 0;
|
||||
|
||||
if (terrain->production == NULL)
|
||||
return;
|
||||
|
|
|
@ -1721,17 +1721,13 @@ void unit_addorder(unit * u, order * ord)
|
|||
|
||||
int unit_max_hp(const unit * u)
|
||||
{
|
||||
static int rules_stamina = -1;
|
||||
int h;
|
||||
double p;
|
||||
static const curse_type *heal_ct = NULL;
|
||||
|
||||
if (rules_stamina < 0) {
|
||||
rules_stamina = config_get_int("rules.stamina", STAMINA_AFFECTS_HP);
|
||||
}
|
||||
int rule_stamina = config_get_int("rules.stamina", STAMINA_AFFECTS_HP);
|
||||
h = u_race(u)->hitpoints;
|
||||
|
||||
if (rules_stamina & 1) {
|
||||
if (rule_stamina & 1) {
|
||||
p = pow(effskill(u, SK_STAMINA, u->region) / 2.0, 1.5) * 0.2;
|
||||
h += (int)(h * p + 0.5);
|
||||
}
|
||||
|
|
39
src/laws.c
39
src/laws.c
|
@ -118,7 +118,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
static bool RemoveNMRNewbie(void)
|
||||
{
|
||||
int value = config_get_int("nmr.removenewbie", 0);
|
||||
return value!=0;
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
static void age_unit(region * r, unit * u)
|
||||
|
@ -250,7 +250,7 @@ static double peasant_growth_factor(void)
|
|||
|
||||
#ifdef SLOWLUCK
|
||||
int peasant_luck_effect(int peasants, int luck, int maxp, double variance) {
|
||||
int n, births=0;
|
||||
int n, births = 0;
|
||||
double factor = peasant_growth_factor();
|
||||
for (n = peasants; n && luck; --n) {
|
||||
int chances = 0;
|
||||
|
@ -482,7 +482,7 @@ extern struct attrib_type at_germs;
|
|||
|
||||
static void
|
||||
growing_trees_e3(region * r, const int current_season,
|
||||
const int last_weeks_season)
|
||||
const int last_weeks_season)
|
||||
{
|
||||
static const int transform[4][3] = {
|
||||
{ -1, -1, 0 },
|
||||
|
@ -785,12 +785,7 @@ void demographics(void)
|
|||
/* die Nachfrage nach Produkten steigt. */
|
||||
struct demand *dmd;
|
||||
if (r->land) {
|
||||
static int plant_rules = -1;
|
||||
|
||||
if (plant_rules < 0) {
|
||||
plant_rules =
|
||||
config_get_int("rules.grow.formula", 0);
|
||||
}
|
||||
int plant_rules = config_get_int("rules.grow.formula", 0);
|
||||
for (dmd = r->land->demands; dmd; dmd = dmd->next) {
|
||||
if (dmd->value > 0 && dmd->value < MAXDEMAND) {
|
||||
float rise = DMRISE;
|
||||
|
@ -988,11 +983,7 @@ static int mayboard(const unit * u, ship * sh)
|
|||
|
||||
static bool CheckOverload(void)
|
||||
{
|
||||
static int value = -1;
|
||||
if (value < 0) {
|
||||
value = config_get_int("rules.check_overload", 0);
|
||||
}
|
||||
return value != 0;
|
||||
return config_get_int("rules.check_overload", 0) != 0;
|
||||
}
|
||||
|
||||
int enter_ship(unit * u, struct order *ord, int id, bool report)
|
||||
|
@ -1209,9 +1200,7 @@ int *age = NULL;
|
|||
|
||||
static void nmr_death(faction * f)
|
||||
{
|
||||
static int rule = -1;
|
||||
if (rule < 0)
|
||||
rule = config_get_int("rules.nmr.destroy", 0);
|
||||
int rule = config_get_int("rules.nmr.destroy", 0) != 0;
|
||||
if (rule) {
|
||||
unit *u;
|
||||
for (u = f->units; u; u = u->nextF) {
|
||||
|
@ -2745,7 +2734,8 @@ void sinkships(struct region * r)
|
|||
double dmg = config_get_flt("rules.ship.damage.nocrewocean", 0.3);
|
||||
damage_ship(sh, dmg);
|
||||
}
|
||||
} else if (!ship_owner(sh)) {
|
||||
}
|
||||
else if (!ship_owner(sh)) {
|
||||
// any ship lying around without an owner slowly rots
|
||||
double dmg = config_get_flt("rules.ship.damage.nocrew", 0.05);
|
||||
damage_ship(sh, dmg);
|
||||
|
@ -3432,7 +3422,8 @@ void update_long_order(unit * u)
|
|||
if (hunger) {
|
||||
// Hungernde Einheiten führen NUR den default-Befehl aus
|
||||
set_order(&u->thisorder, default_order(u->faction->locale));
|
||||
} else if (!exclusive) {
|
||||
}
|
||||
else if (!exclusive) {
|
||||
// Wenn die Einheit handelt oder zaubert, muss der Default-Befehl gelöscht werden.
|
||||
set_order(&u->thisorder, NULL);
|
||||
}
|
||||
|
@ -3459,7 +3450,7 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order
|
|||
return EUNUSABLE;
|
||||
}
|
||||
result = itype->use ? itype->use(u, itype, amount, ord) : EUNUSABLE;
|
||||
if (result>0) {
|
||||
if (result > 0) {
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, result);
|
||||
}
|
||||
return result;
|
||||
|
@ -4645,10 +4636,10 @@ bool cansee_unit(const unit * u, const unit * target, int modifier)
|
|||
|
||||
bool
|
||||
cansee_durchgezogen(const faction * f, const region * r, const unit * u,
|
||||
int modifier)
|
||||
/* r kann != u->region sein, wenn es um durchreisen geht */
|
||||
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
|
||||
* erblickt wird */
|
||||
int modifier)
|
||||
/* r kann != u->region sein, wenn es um durchreisen geht */
|
||||
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
|
||||
* erblickt wird */
|
||||
{
|
||||
int n;
|
||||
unit *u2;
|
||||
|
|
|
@ -215,15 +215,11 @@ static void free_mage(attrib * a)
|
|||
|
||||
bool FactionSpells(void)
|
||||
{
|
||||
static int rules_factionspells = -1;
|
||||
if (rules_factionspells < 0) {
|
||||
rules_factionspells = config_get_int("rules.magic.factionlist", 0);
|
||||
}
|
||||
return rules_factionspells!=0;
|
||||
return config_get_int("rules.magic.factionlist", 0) != 0;
|
||||
}
|
||||
|
||||
void read_spells(struct quicklist **slistp, magic_t mtype,
|
||||
struct storage *store)
|
||||
struct storage *store)
|
||||
{
|
||||
for (;;) {
|
||||
spell *sp;
|
||||
|
|
|
@ -962,10 +962,7 @@ static void demon_skillchanges(void)
|
|||
|
||||
if (fval(u, UFL_HUNGER)) {
|
||||
/* hungry demons only go down, never up in skill */
|
||||
static int rule_hunger = -1;
|
||||
if (rule_hunger < 0) {
|
||||
rule_hunger = config_get_int("hunger.demon.skill", 0);
|
||||
}
|
||||
int rule_hunger = config_get_int("hunger.demon.skill", 0) != 0;
|
||||
if (rule_hunger) {
|
||||
upchance = 0;
|
||||
downchance = 15;
|
||||
|
@ -1009,15 +1006,13 @@ static void icebergs(void)
|
|||
}
|
||||
}
|
||||
|
||||
#define HERBS_ROT /* herbs owned by units have a chance to rot. */
|
||||
#define HERBROTCHANCE 5 /* Verrottchance für Kräuter (ifdef HERBS_ROT) */
|
||||
#ifdef HERBS_ROT
|
||||
static void rotting_herbs(void)
|
||||
{
|
||||
static int rule_rot = -1;
|
||||
region *r;
|
||||
|
||||
if (rule_rot < 0) {
|
||||
rule_rot = config_get_int("rules.economy.herbrot", HERBROTCHANCE);
|
||||
}
|
||||
int rule_rot = config_get_int("rules.economy.herbrot", HERBROTCHANCE);
|
||||
if (rule_rot == 0) return;
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
|
|
|
@ -42,14 +42,12 @@
|
|||
/* experimental gameplay features (that don't affect the savefile) */
|
||||
/* TODO: move these settings to settings.h or into configuration files */
|
||||
#define GOBLINKILL /* Goblin-Spezialklau kann tödlich enden */
|
||||
#define HERBS_ROT /* herbs owned by units have a chance to rot. */
|
||||
#define INSECT_POTION /* Spezialtrank für Insekten */
|
||||
#define ORCIFICATION /* giving snotlings to the peasants gets counted */
|
||||
|
||||
#define TREESIZE (8) /* space used by trees (in #peasants) */
|
||||
|
||||
#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */
|
||||
#define HERBROTCHANCE 5 /* Verrottchance für Kräuter (ifdef HERBS_ROT) */
|
||||
|
||||
/* Gebäudegröße = Minimalbelagerer */
|
||||
#define SIEGEFACTOR 2
|
||||
|
|
11
src/study.c
11
src/study.c
|
@ -546,17 +546,10 @@ int study_cmd(unit * u, order * ord)
|
|||
skill_t sk;
|
||||
int maxalchemy = 0;
|
||||
int speed_rule = (study_rule_t)config_get_int("study.speedup", 0);
|
||||
static int learn_newskills = -1;
|
||||
struct building *b = inside_building(u);
|
||||
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
||||
bool learn_newskills = config_get_int("study.newskills", 1) != 0;
|
||||
|
||||
if (learn_newskills < 0) {
|
||||
const char *str = config_get("study.newskills");
|
||||
if (str && strcmp(str, "false") == 0)
|
||||
learn_newskills = 0;
|
||||
else
|
||||
learn_newskills = 1;
|
||||
}
|
||||
if (!unit_can_study(u)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
|
||||
u_race(u)));
|
||||
|
@ -580,7 +573,7 @@ int study_cmd(unit * u, order * ord)
|
|||
cmistake(u, ord, 771, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
if (learn_newskills == 0) {
|
||||
if (!learn_newskills) {
|
||||
skill *sv = unit_skill(u, sk);
|
||||
if (sv == NULL) {
|
||||
/* we can only learn skills we already have */
|
||||
|
|
|
@ -270,11 +270,8 @@ void get_food(region * r)
|
|||
peasantfood = 0;
|
||||
}
|
||||
if (hungry > 0) {
|
||||
static int demon_hunger = -1;
|
||||
if (demon_hunger < 0) {
|
||||
demon_hunger = config_get_int("hunger.demons", 0);
|
||||
}
|
||||
if (demon_hunger == 0) {
|
||||
bool demon_hunger = config_get_int("hunger.demons", 0) != 0;
|
||||
if (demon_hunger) {
|
||||
/* demons who don't feed are hungry */
|
||||
if (hunger(hungry, u))
|
||||
fset(u, UFL_HUNGER);
|
||||
|
|
Loading…
Reference in a new issue