New server.h for server startup, control and shutdown, i.e. stuff in

src/server.  Use it.
This commit is contained in:
Markus Armbruster 2004-02-19 19:02:30 +00:00
parent 8115388a58
commit 22a356b1e1
19 changed files with 73 additions and 24 deletions

55
include/server.h Normal file
View file

@ -0,0 +1,55 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
* related information and legal notices. It is expected that any future
* projects/authors will amend these files as needed.
*
* ---
*
* server.h: Server startup, control and shutdown
*
* Known contributors to this file:
* Markus Armbruster, 2004
*/
#ifndef SERVER_H
#define SERVER_H
extern int shutdown_pending;
extern int update_pending;
extern empth_sem_t *update_sem;
extern time_t update_time;
extern int updating_mob;
void mobility_init(void);
/* thread entry points */
void player_accept(void *);
void delete_lostitems(void *);
void market_update(void *);
void mobility_check(void *);
void player_kill_idle(void *);
void update_main(void *);
void update_sched(void *);
void shutdown_sequence(void *);
#endif SERVER_H

View file

@ -36,13 +36,11 @@
#include "player.h" #include "player.h"
#include "empthread.h" #include "empthread.h"
#include "commands.h" #include "commands.h"
#include "server.h"
int int
force(void) force(void)
{ {
extern empth_sem_t *update_sem;
extern int update_pending;
extern int shutdown_pending;
int seconds; int seconds;
time_t now; time_t now;

View file

@ -43,6 +43,7 @@
#include "file.h" #include "file.h"
#include "commands.h" #include "commands.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
#include "prototypes.h" #include "prototypes.h"
#include <stdio.h> #include <stdio.h>
@ -52,7 +53,6 @@ mobupdate(void)
{ {
FILE *fp; FILE *fp;
long minites; long minites;
extern int updating_mob;
struct mob_acc_globals timestamps; struct mob_acc_globals timestamps;
long now; long now;

View file

@ -38,13 +38,12 @@
#include "nat.h" #include "nat.h"
#include "file.h" #include "file.h"
#include "commands.h" #include "commands.h"
#include "server.h"
#include "prototypes.h" #include "prototypes.h"
int int
shut(void) shut(void)
{ {
extern int update_pending;
extern int shutdown_pending;
int shutdown_minutes; int shutdown_minutes;
int shutdown_was_pending; int shutdown_was_pending;
s_char buf[100]; s_char buf[100];

View file

@ -39,6 +39,7 @@
#include "optlist.h" #include "optlist.h"
#include "keyword.h" #include "keyword.h"
#include "wantupd.h" #include "wantupd.h"
#include "server.h"
/* /*
* Tell what the update policy is, and when the next update * Tell what the update policy is, and when the next update
@ -49,7 +50,6 @@ upda(void)
{ {
FILE *fp; FILE *fp;
struct mob_acc_globals timestamps; struct mob_acc_globals timestamps;
extern int updating_mob;
if (opt_MOB_ACCESS) { if (opt_MOB_ACCESS) {
#if !defined(_WIN32) #if !defined(_WIN32)
@ -73,7 +73,6 @@ upda(void)
} }
if (opt_UPDATESCHED) { if (opt_UPDATESCHED) {
time_t now, next, delta; time_t now, next, delta;
extern int update_time;
if (updates_disabled()) if (updates_disabled())
pr("UPDATES ARE DISABLED!\n"); pr("UPDATES ARE DISABLED!\n");

View file

@ -58,11 +58,11 @@
#include "empthread.h" #include "empthread.h"
#include "commands.h" #include "commands.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
int int
zdon(void) zdon(void)
{ {
extern empth_sem_t *update_sem;
natid whichcnum; natid whichcnum;
struct natstr *natp; struct natstr *natp;
register s_char *p; register s_char *p;

View file

@ -44,12 +44,12 @@
#include "optlist.h" #include "optlist.h"
#include "subs.h" #include "subs.h"
#include "common.h" #include "common.h"
#include "server.h"
int int
dispatch(s_char *buf, s_char *redir) dispatch(s_char *buf, s_char *redir)
{ {
extern struct cmndstr player_coms[]; extern struct cmndstr player_coms[];
extern int update_pending;
struct natstr *np; struct natstr *np;
struct cmndstr *command; struct cmndstr *command;
int cmd; int cmd;

View file

@ -51,8 +51,8 @@
#include "path.h" #include "path.h"
#include "prototypes.h" #include "prototypes.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
extern int update_pending;
#ifndef MIN #ifndef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MIN(x,y) ((x) < (y) ? (x) : (y))

View file

@ -53,7 +53,7 @@
#include "com.h" #include "com.h"
#include "news.h" #include "news.h"
#include "tel.h" #include "tel.h"
extern int update_pending; #include "server.h"
#include "prototypes.h" #include "prototypes.h"
static void outid(struct player *pl, int n); static void outid(struct player *pl, int n);

View file

@ -38,9 +38,9 @@
#include "player.h" #include "player.h"
#include "prototypes.h" #include "prototypes.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
extern s_char *relates[]; extern s_char *relates[];
extern int update_pending;
int int
setrel(natid us, natid them, int rel) setrel(natid us, natid them, int rel)

View file

@ -50,6 +50,7 @@
#include "mission.h" #include "mission.h"
#include "optlist.h" #include "optlist.h"
#include "damage.h" #include "damage.h"
#include "server.h"
#include "prototypes.h" #include "prototypes.h"
extern double tfactfire(natid, double); extern double tfactfire(natid, double);
@ -119,7 +120,6 @@ void
shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp, shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
int *togetherp, natid actor) int *togetherp, natid actor)
{ {
extern int update_pending;
struct emp_qelem *qp; struct emp_qelem *qp;
struct emp_qelem *next; struct emp_qelem *next;
struct mlist *mlp; struct mlist *mlp;

View file

@ -42,6 +42,7 @@
#include "tel.h" #include "tel.h"
#include "file.h" #include "file.h"
#include "player.h" #include "player.h"
#include "server.h"
#include "prototypes.h" #include "prototypes.h"
static struct telstr last_tel[MAXNOC]; static struct telstr last_tel[MAXNOC];
@ -62,7 +63,6 @@ clear_telegram_is_new(natid to)
static int static int
telegram_is_new(natid to, struct telstr *tel) telegram_is_new(natid to, struct telstr *tel)
{ {
extern int update_pending;
int is_new = 0; int is_new = 0;
is_new |= tel->tel_type != last_tel[to].tel_type; is_new |= tel->tel_type != last_tel[to].tel_type;
@ -84,7 +84,6 @@ wu(natid from, natid to, s_char *format, ...)
struct natstr *np; struct natstr *np;
va_list ap; va_list ap;
s_char buf[4096]; s_char buf[4096];
extern int update_pending;
va_start(ap, format); va_start(ap, format);
(void)vsprintf(buf, format, ap); (void)vsprintf(buf, format, ap);

View file

@ -46,8 +46,8 @@
#include "gen.h" #include "gen.h"
#include "subs.h" #include "subs.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
extern int update_pending;
int updating_mob = 1; int updating_mob = 1;
@ -65,7 +65,6 @@ increase_mob(time_t * counter, float mult)
time_t secs; time_t secs;
time_t now; time_t now;
time_t left; time_t left;
extern int updating_mob;
int newetus; int newetus;
float newmob; float newmob;
int inewmob; int inewmob;

View file

@ -38,6 +38,7 @@
#include "proto.h" #include "proto.h"
#include "prototypes.h" #include "prototypes.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
/*ARGSUSED*/ /*ARGSUSED*/
void void

View file

@ -41,6 +41,7 @@
#include <stdio.h> #include <stdio.h>
#include "prototypes.h" #include "prototypes.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
/*ARGSUSED*/ /*ARGSUSED*/
void void

View file

@ -64,14 +64,11 @@
#include "product.h" #include "product.h"
#include "optlist.h" #include "optlist.h"
#include "global.h" #include "global.h"
#include "server.h"
#include "prototypes.h" #include "prototypes.h"
s_char program[] = "server"; s_char program[] = "server";
extern void player_accept(void *);
extern void player_kill_idle(void *);
extern void update_sched(void *);
extern void delete_lostitems(void *);
void nullify_objects(void); void nullify_objects(void);
void init_files(void); void init_files(void);
void close_files(void); void close_files(void);

View file

@ -37,6 +37,7 @@
#include "keyword.h" #include "keyword.h"
#include "empthread.h" #include "empthread.h"
#include "file.h" #include "file.h"
#include "server.h"
#include <stdio.h> #include <stdio.h>
#include "prototypes.h" #include "prototypes.h"

View file

@ -40,12 +40,12 @@
#include <stdio.h> #include <stdio.h>
#include "prototypes.h" #include "prototypes.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
/*ARGSUSED*/ /*ARGSUSED*/
void void
mobility_check(void *argv) mobility_check(void *argv)
{ {
extern int updating_mob;
struct mob_acc_globals timestamps; struct mob_acc_globals timestamps;
time_t now; time_t now;
FILE *fp; FILE *fp;
@ -93,7 +93,6 @@ mobility_check(void *argv)
void void
mobility_init(void) mobility_init(void)
{ {
extern int updating_mob;
struct mob_acc_globals timestamps; struct mob_acc_globals timestamps;
time_t now; time_t now;
time_t lastsavedtime; time_t lastsavedtime;

View file

@ -38,6 +38,7 @@
#include "empthread.h" #include "empthread.h"
#include "prototypes.h" #include "prototypes.h"
#include "optlist.h" #include "optlist.h"
#include "server.h"
empth_sem_t *update_sem; empth_sem_t *update_sem;