New update scheduler:
(schedulefil): New. (set_dirs, set_paths): Rename. Initialize schedulfil. (read_schedule): New. Can read several updates, which will be used in later changesets. (update_time): Change to array. Will be used in later changesets. (update_schedule_anchor): New. (update_init): Initialize it. (update_get_schedule): New. (update_init): Call it to initialize update_time[]. (update_sched): Rewrite. (update_forced, update_wanted): Replace. (update_reschedule): New. (main): Call it on SIGHUP to reload the schedule. (update_trigger, update_force, force, player_coms): Drop force's capability to schedule updates in the future, because it's not worth the trouble to implement again. Deities can simply edit the schedule file to schedule updates. Remove update_force() and update_trigger()'s parameter. (upda): Update for new scheduler. Take care to keep output the same as far as possible, even though it's ugly, to avoid breaking clients. (update_policy, adj_update, update_times, hourslop, blitz_time): econfig keys removed. (update_demand, UPD_DEMAND_NONE, UPD_DEMAND_SCHED, UPD_DEMAND_ASYNC) (update_demandpolicy, UDP_NORMAL, UDP_TIMES, UDP_NORMAL, UDP_BLITZ) (UDP_MAX, UDP_DEFAULT, UDDEM_TMCHECK, UDDEM_COMSET, UDDEM_DISABLE) (UDDEM_MAX, UDDEM_DEFAULT): econfig key and values replaced. Users changed. wantupd.h is now empty, remove. (demand_check): External linkage. (update_policy_check): Now pointless, remove. (is_daytime_near, min_to_next_daytime, regular_update_time) (scheduled_update_time, next_scheduled_time, updatetime) (next_update_time, next_update_check_time): Unused, Remove. (demand_check, demandupdatecheck): Move call of demand_update_time() from demand_check(), which controls all demand updates, to demandupdatecheck(), which controls only unscheduled ones. Fixes update command not to lie about the next scheduled demand update. (demandupdatecheck): Check updates_disabled() so that zdone no longer claims to trigger an update when it can't.
This commit is contained in:
parent
15f8f48353
commit
71320ed67f
20 changed files with 487 additions and 448 deletions
|
@ -101,46 +101,34 @@ EMPCFBOTH("WORLD_X", WORLD_X, int, NSC_INT, 0,
|
|||
EMPCFBOTH("WORLD_Y", WORLD_Y, int, NSC_INT, 0,
|
||||
"World size Y dimension")
|
||||
|
||||
EMPCF_COMMENT("\n\n### Update policy")
|
||||
EMPCFBOTH("update_policy", update_policy, int, NSC_INT, 0,
|
||||
"Update policy")
|
||||
EMPCF_COMMENT("# 0 - Schedule updates according to etu_per_update, s_p_etu, adj_update\n"
|
||||
"# 1 - Update at times specified by key \"update_times\"\n"
|
||||
"# 2 - Blitz update every blitz_time minute\n"
|
||||
"# 3 - No regular updates, only demand ones")
|
||||
EMPCF_COMMENT("\n\n### Update policy\n\n"
|
||||
"# Note: the update schedule is defined in the file schedule in the\n"
|
||||
"# same directory as this file.")
|
||||
EMPCFBOTH("etu_per_update", etu_per_update, int, NSC_INT, 0,
|
||||
"Number of ETUs per update")
|
||||
EMPCFBOTH("s_p_etu", s_p_etu, int, NSC_INT, 0,
|
||||
"Seconds per ETU")
|
||||
EMPCF_COMMENT("# updates under policy 0 occur every s_p_etu * etu_per_update seconds")
|
||||
EMPCFBOTH("adj_update", adj_update, int, NSC_INT, KM_INTERNAL,
|
||||
"Move the update forward or backward (in seconds)")
|
||||
EMPCF_COMMENT("# FIXME get rid of this!\n"
|
||||
"# Until then, set it so that s_p_etu * etu_per_update seconds equals\n"
|
||||
"# the time between scheduled updates.")
|
||||
EMPCFBOTH("update_window", update_window, int, NSC_INT, 0,
|
||||
"Window the update will occur in (in seconds) before and after the update time")
|
||||
EMPCFBOTH("update_times", update_times, char *, NSC_STRING, 0,
|
||||
"Times of day when updates may occur under policy 1, separated by space.")
|
||||
EMPCF_COMMENT("# Give time of day as HOUR:MINUTE, e.g. 20:00\n"
|
||||
"# Times must coincide with updates under policy 0.")
|
||||
EMPCFBOTH("hourslop", hourslop, int, NSC_INT, KM_INTERNAL,
|
||||
"Number of minutes update check can slip to match update_times")
|
||||
EMPCFBOTH("blitz_time", blitz_time, int, NSC_INT, 0,
|
||||
"Number of minutes between updates under policy 2.")
|
||||
"Time window the update will occur in after the update time, in seconds")
|
||||
EMPCFBOTH("pre_update_hook", pre_update_hook, char *, NSC_STRING, KM_INTERNAL,
|
||||
"Shell command run right before the update.")
|
||||
|
||||
EMPCF_COMMENT("\n\n### Demand update policy")
|
||||
EMPCFBOTH("update_demandpolicy", update_demandpolicy, int, NSC_INT, 0,
|
||||
EMPCFBOTH("update_demand", update_demand, int, NSC_INT, 0,
|
||||
"Demand update policy")
|
||||
EMPCF_COMMENT("# 0 - Votes tallied at update times under policy 0\n"
|
||||
"# 1 - Votes tallies right after a vote\n"
|
||||
"# 2 - Demand updates disabled")
|
||||
EMPCF_COMMENT("# 0 - No demand updates\n"
|
||||
"# 1 - Scheduled updates are demand updates\n"
|
||||
"# 2 - Demand updates run right after the deciding vote is cast,\n"
|
||||
"# in addition to (non-demand) scheduled updates\n")
|
||||
EMPCFBOTH("update_wantmin", update_wantmin, int, NSC_INT, 0,
|
||||
"Number of votes required for a demand update")
|
||||
EMPCFBOTH("update_missed", update_missed, int, NSC_INT, 0,
|
||||
"A country vetoes further demand updates after missing that many votes")
|
||||
EMPCFBOTH("update_demandtimes", update_demandtimes, char *, NSC_STRING, 0,
|
||||
"Time of day ranges when demand updates can occur, separated by space.")
|
||||
EMPCF_COMMENT("# Give range HOUR:MINUTE-HOUR:MINUTE, e.g. 20:00-24:00\n"
|
||||
"Times when unscheduled demand updates can occur, separated by space.")
|
||||
EMPCF_COMMENT("# Give time ranges as HOUR:MINUTE-HOUR:MINUTE, e.g. 20:00-24:00\n"
|
||||
"# Ranges CANNOT cross midnight.")
|
||||
|
||||
EMPCF_COMMENT("\n\n### Game hours restrictions")
|
||||
|
@ -149,7 +137,7 @@ EMPCFBOTH("game_days", game_days, char *, NSC_STRING, 0,
|
|||
EMPCF_COMMENT("# Give days as Su Mo Tu We Th Fr Sa.")
|
||||
EMPCFBOTH("game_hours", game_hours, char *, NSC_STRING, 0,
|
||||
"Time of day ranges when the game is open, separated by space.")
|
||||
EMPCF_COMMENT("# Give range HOUR:MINUTE-HOUR:MINUTE, e.g. 20:00-24:00\n"
|
||||
EMPCF_COMMENT("# Give time ranges as HOUR:MINUTE-HOUR:MINUTE, e.g. 20:00-24:00\n"
|
||||
"# Ranges CANNOT cross midnight.")
|
||||
|
||||
EMPCF_COMMENT("\n\n### Options")
|
||||
|
|
|
@ -45,6 +45,7 @@ extern char dflt_econfig[];
|
|||
#undef EMP_CONFIG_H_OUTPUT
|
||||
|
||||
extern char *configdir;
|
||||
extern char *schedulefil;
|
||||
|
||||
extern char motdfil[];
|
||||
extern char downfil[];
|
||||
|
@ -60,6 +61,12 @@ enum {
|
|||
KM_OPTION = 4 /* historically an option */
|
||||
};
|
||||
|
||||
enum {
|
||||
UPD_DEMAND_NONE, /* no demand updates */
|
||||
UPD_DEMAND_SCHED, /* scheduled updates are demand updates */
|
||||
UPD_DEMAND_ASYNC, /* zdone triggers unscheduled update */
|
||||
};
|
||||
|
||||
struct keymatch {
|
||||
char *km_key; /* the key */
|
||||
nsc_type km_type; /* type of associated data */
|
||||
|
|
|
@ -298,8 +298,6 @@ extern double hap_req(struct natstr *np);
|
|||
extern int is_wday_allowed(int, char *);
|
||||
extern int is_daytime_allowed(int, char *);
|
||||
extern int gamehours(time_t);
|
||||
extern int is_daytime_near(int, char *, int);
|
||||
extern int min_to_next_daytime(int, char *);
|
||||
/* land.c */
|
||||
extern int has_units(coord, coord, natid, struct lndstr *);
|
||||
extern int has_units_with_mob(coord, coord, natid);
|
||||
|
@ -332,6 +330,8 @@ extern char *BestLandPath(char *, struct sctstr *, struct sctstr *,
|
|||
extern char *BestShipPath(char *, int, int, int, int, int);
|
||||
extern char *BestAirPath(char *, int, int, int, int);
|
||||
extern double pathcost(struct sctstr *, char *, int);
|
||||
/* rdsched.c */
|
||||
extern int read_schedule(char *, time_t[], int, time_t, time_t);
|
||||
/* res_pop.c */
|
||||
extern int max_population(float, int, int);
|
||||
extern int max_pop(float, struct sctstr *);
|
||||
|
@ -343,12 +343,9 @@ extern int sectdamage(struct sctstr *, int, struct emp_qelem *);
|
|||
/* type.c */
|
||||
extern int sct_typematch(char *);
|
||||
/* wantupd.c */
|
||||
extern void update_policy_check(void);
|
||||
extern int demand_update_want(int *, int *, int);
|
||||
extern int demand_check(void);
|
||||
extern int demandupdatecheck(void);
|
||||
extern int updatetime(time_t *);
|
||||
extern void next_update_time(time_t *, time_t *, time_t *);
|
||||
extern void next_update_check_time(time_t *, time_t *, time_t *);
|
||||
extern int updates_disabled(void);
|
||||
/* xundump.c */
|
||||
extern int xundump(FILE *, char *, int);
|
||||
|
|
|
@ -39,14 +39,15 @@
|
|||
extern int shutdown_pending;
|
||||
extern int update_pending;
|
||||
extern empth_rwlock_t *update_lock;
|
||||
extern time_t update_time;
|
||||
extern time_t update_time[];
|
||||
extern int updating_mob;
|
||||
|
||||
void mobility_init(void);
|
||||
void market_init(void);
|
||||
void update_main(void);
|
||||
void update_init(void);
|
||||
int update_trigger(time_t);
|
||||
int update_trigger(void);
|
||||
int update_reschedule(void);
|
||||
int shutdown_initiate(int);
|
||||
|
||||
/* thread entry points */
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Empire - A multi-player, client/server Internet based war game.
|
||||
* Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
|
||||
* Ken Stevens, Steve McClure
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* See files README, COPYING and CREDITS in the root of the source
|
||||
* tree for related information and legal notices. It is expected
|
||||
* that future projects/authors will amend these files as needed.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* wantupd.h: Header used to check to see if an update is wanted
|
||||
* and/or allowed.
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Doug Hay, 1991
|
||||
*/
|
||||
|
||||
#ifndef WANTUPD_H
|
||||
#define WANTUPD_H
|
||||
|
||||
/* Update policies */
|
||||
#define UDP_NORMAL 0
|
||||
#define UDP_TIMES 1
|
||||
#define UDP_NOREG 3
|
||||
#define UDP_BLITZ 2
|
||||
#define UDP_MAX 3
|
||||
#define UDP_DEFAULT UDP_NORMAL
|
||||
|
||||
/* Demand update policies */
|
||||
#define UDDEM_TMCHECK 0
|
||||
#define UDDEM_COMSET 1
|
||||
#define UDDEM_DISABLE 2
|
||||
#define UDDEM_MAX 2
|
||||
#define UDDEM_DEFAULT UDDEM_DISABLE
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue