forked from github/server
eliminate static variables and cache logic from more modules
This commit is contained in:
parent
86faae6eea
commit
7e27928d17
5 changed files with 22 additions and 46 deletions
|
@ -2360,16 +2360,12 @@ static void breedtrees(unit * u, int raw)
|
|||
{
|
||||
int n, i, skill, planted = 0;
|
||||
const resource_type *rtype;
|
||||
static int gamecookie = -1;
|
||||
static int current_season;
|
||||
int current_season;
|
||||
region *r = u->region;
|
||||
|
||||
if (gamecookie != global.cookie) {
|
||||
gamedate date;
|
||||
get_gamedate(turn, &date);
|
||||
current_season = date.season;
|
||||
gamecookie = global.cookie;
|
||||
}
|
||||
gamedate date;
|
||||
|
||||
get_gamedate(turn, &date);
|
||||
current_season = date.season;
|
||||
|
||||
/* Bäume züchten geht nur im Frühling */
|
||||
if (current_season != SEASON_SPRING) {
|
||||
|
|
|
@ -181,22 +181,17 @@ bool is_astral(const region * r)
|
|||
|
||||
plane *get_astralplane(void)
|
||||
{
|
||||
static plane *astralspace;
|
||||
static int rule_astralplane = -1;
|
||||
static int gamecookie = -1;
|
||||
if (rule_astralplane < 0) {
|
||||
rule_astralplane =
|
||||
get_param_int(global.parameters, "modules.astralspace", 1);
|
||||
}
|
||||
plane *astralspace = 0;
|
||||
int rule_astralplane =
|
||||
get_param_int(global.parameters, "modules.astralspace", 1);
|
||||
|
||||
if (!rule_astralplane) {
|
||||
return NULL;
|
||||
}
|
||||
if (gamecookie != global.cookie) {
|
||||
if (!astralspace) {
|
||||
astralspace = getplanebyname("Astralraum");
|
||||
gamecookie = global.cookie;
|
||||
}
|
||||
|
||||
if (astralspace == NULL) {
|
||||
if (!astralspace) {
|
||||
astralspace = create_new_plane(1, "Astralraum",
|
||||
TE_CENTER_X - 500, TE_CENTER_X + 500,
|
||||
TE_CENTER_Y - 500, TE_CENTER_Y + 500, 0);
|
||||
|
|
|
@ -850,17 +850,13 @@ void leave_building(unit * u)
|
|||
|
||||
bool can_leave(unit * u)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule_leave = -1;
|
||||
int rule_leave;
|
||||
|
||||
if (!u->building) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rule_leave < 0 || gamecookie != global.cookie) {
|
||||
gamecookie = global.cookie;
|
||||
rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
|
||||
}
|
||||
rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
|
||||
|
||||
if (rule_leave!=0 && u->building && u == building_owner(u->building)) {
|
||||
return false;
|
||||
|
|
|
@ -117,13 +117,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
static bool RemoveNMRNewbie(void)
|
||||
{
|
||||
static int value = -1;
|
||||
static int gamecookie = -1;
|
||||
|
||||
if (value < 0 || gamecookie != global.cookie) {
|
||||
value = get_param_int(global.parameters, "nmr.removenewbie", 0);
|
||||
gamecookie = global.cookie;
|
||||
}
|
||||
int value = get_param_int(global.parameters, "nmr.removenewbie", 0);
|
||||
return value!=0;
|
||||
}
|
||||
|
||||
|
|
21
src/report.c
21
src/report.c
|
@ -2054,19 +2054,14 @@ const char *charset)
|
|||
char *bufp;
|
||||
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
|
||||
size_t size;
|
||||
|
||||
/* static variables can cope with writing for different turns */
|
||||
static int thisseason = -1;
|
||||
static int nextseason = -1;
|
||||
static int gamecookie = -1;
|
||||
if (gamecookie != global.cookie) {
|
||||
gamedate date;
|
||||
get_gamedate(turn + 1, &date);
|
||||
thisseason = date.season;
|
||||
get_gamedate(turn + 2, &date);
|
||||
nextseason = date.season;
|
||||
gamecookie = global.cookie;
|
||||
}
|
||||
int thisseason;
|
||||
int nextseason;
|
||||
gamedate date;
|
||||
|
||||
get_gamedate(turn + 1, &date);
|
||||
thisseason = date.season;
|
||||
get_gamedate(turn + 2, &date);
|
||||
nextseason = date.season;
|
||||
|
||||
if (F == NULL) {
|
||||
perror(filename);
|
||||
|
|
Loading…
Reference in a new issue