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