From 7dd8b8a305b180beb0510bb74576b64032022b2a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 18 Jul 2007 06:16:33 +0000 Subject: [PATCH] New xdump updates: (EF_UPDATES, update_ca): New. (empfile): Add it. (update_time): Move to src/lib/global/updtime.c. --- include/file.h | 1 + include/nsc.h | 1 + include/server.h | 2 +- src/lib/commands/xdump.c | 3 ++- src/lib/global/file.c | 5 ++++- src/lib/global/nsc.c | 7 ++++++- src/lib/global/updtime.c | 38 ++++++++++++++++++++++++++++++++++++++ src/server/update.c | 7 ++----- 8 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 src/lib/global/updtime.c diff --git a/include/file.h b/include/file.h index 3011a13f..0ca82d91 100644 --- a/include/file.h +++ b/include/file.h @@ -129,6 +129,7 @@ enum { EF_NUKE_CHR, EF_NEWS_CHR, EF_INFRASTRUCTURE, + EF_UPDATES, EF_TABLE, EF_META, /* Symbol tables */ diff --git a/include/nsc.h b/include/nsc.h index 5ba06a9b..15bb6516 100644 --- a/include/nsc.h +++ b/include/nsc.h @@ -219,6 +219,7 @@ extern struct castr realm_ca[]; extern struct castr game_ca[]; extern struct castr intrchr_ca[]; extern struct castr rpt_ca[]; +extern struct castr update_ca[]; extern struct castr empfile_ca[]; extern struct castr symbol_ca[]; extern struct symbol ship_chr_flags[]; diff --git a/include/server.h b/include/server.h index c0bb483d..dd24388e 100644 --- a/include/server.h +++ b/include/server.h @@ -40,7 +40,7 @@ extern int shutdown_pending; extern int update_pending; extern int update_running; extern empth_rwlock_t *update_lock; -extern time_t update_time[]; +extern time_t update_time[16]; void market_init(void); void update_main(void); diff --git a/src/lib/commands/xdump.c b/src/lib/commands/xdump.c index e1d4217b..77b3eed3 100644 --- a/src/lib/commands/xdump.c +++ b/src/lib/commands/xdump.c @@ -28,7 +28,7 @@ * xdump.c: Experimental extended dump * * Known contributors to this file: - * Markus Armbruster, 2004-2006 + * Markus Armbruster, 2004-2007 */ /* @@ -46,6 +46,7 @@ * - News item characteristics: rpt[] * - News page headings: page_headings[] * - Commands: player_coms[] (TODO) + * - Update schedule: update_time[] (not really static) * - Configuration: configkeys[] * * Dynamic game data: diff --git a/src/lib/global/file.c b/src/lib/global/file.c index 9f91ebb7..017c1647 100644 --- a/src/lib/global/file.c +++ b/src/lib/global/file.c @@ -28,7 +28,7 @@ * file.c: Empire game data file descriptions. * * Known contributors to this file: - * Markus Armbruster, 2005 + * Markus Armbruster, 2005-2007 */ #include @@ -49,6 +49,7 @@ #include "product.h" #include "sect.h" #include "ship.h" +#include "server.h" #include "trade.h" #include "treaty.h" @@ -162,6 +163,8 @@ struct empfile empfile[] = { ARRAY_TABLE(rpt, EFF_CFG)}, {EF_INFRASTRUCTURE, "infrastructure", "infra.config", intrchr_ca, ARRAY_CACHE(intrchr, EFF_CFG)}, + {EF_UPDATES, "updates", NULL, update_ca, + ARRAY_TABLE(update_time, EFF_CFG)}, {EF_TABLE, "table", NULL, empfile_ca, ARRAY_TABLE(empfile, EFF_CFG)}, {EF_META, "meta", NULL, mdchr_ca, diff --git a/src/lib/global/nsc.c b/src/lib/global/nsc.c index 0e1ca3ea..8a58a4cd 100644 --- a/src/lib/global/nsc.c +++ b/src/lib/global/nsc.c @@ -28,7 +28,7 @@ * nsc.c: Empire selection global structures * * Known contributors to this file: - * Markus Armbruster, 2004-2006 + * Markus Armbruster, 2004-2007 */ /* @@ -576,6 +576,11 @@ struct castr rpt_ca[] = { {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD} }; +struct castr update_ca[] = { + {NSC_TIME, 0, 0, 0, "time", EF_BAD}, + {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD} +}; + struct castr empfile_ca[] = { {NSC_INT, 0, 0, offsetof(struct empfile, uid), "uid", EF_TABLE}, {NSC_STRING, NSC_CONST, 0, offsetof(struct empfile, name), "name", EF_BAD}, diff --git a/src/lib/global/updtime.c b/src/lib/global/updtime.c new file mode 100644 index 00000000..0c37c6ca --- /dev/null +++ b/src/lib/global/updtime.c @@ -0,0 +1,38 @@ +/* + * 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. + * + * --- + * + * updtime.c: Scheduled update times + * + * Known contributors to this file: + * Markus Armbruster, 2007 + */ + +#include + +#include "server.h" + +time_t update_time[]; diff --git a/src/server/update.c b/src/server/update.c index b4e7c07c..2704cad1 100644 --- a/src/server/update.c +++ b/src/server/update.c @@ -48,8 +48,6 @@ #include "prototypes.h" #include "server.h" -#define UPDATES 16 - /* * Lock to synchronize player threads with the update. * Update takes it exclusive, commands take it shared. @@ -68,8 +66,6 @@ int update_pending; */ int update_running; -time_t update_time[UPDATES]; - static time_t update_schedule_anchor; static int update_wanted; @@ -116,7 +112,8 @@ update_get_schedule(void) { time_t now = time(NULL); - if (read_schedule(schedulefil, update_time, UPDATES, + if (read_schedule(schedulefil, update_time, + sizeof(update_time) / sizeof(*update_time), now + 30, update_schedule_anchor) < 0) { logerror("No update schedule!"); update_time[0] = 0;