/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* Known contributors to this file:
* Dave Pare, 1994
* Steve McClure, 2000
- * Markus Armbruster, 2006-2008
+ * Markus Armbruster, 2006-2009
+ * Ron Koenderink, 2004-2009
*/
#include <config.h>
#include "com.h"
#include "empio.h"
#include "file.h"
+#include "game.h"
#include "match.h"
#include "misc.h"
#include "nat.h"
#include "player.h"
#include "proto.h"
#include "prototypes.h"
-#include "tel.h"
#define KEEP_COMMANDS 50
free(tmp);
}
-/*
- * returns true if down
- */
-static int
-gamedown(int suppress_deity_message)
-{
- FILE *down_fp;
- struct telstr tgm;
- char buf[MAXTELSIZE + 1]; /* UTF-8 */
-
- if ((down_fp = fopen(downfil, "rb")) == NULL)
- return 0;
- if (fread(&tgm, sizeof(tgm), 1, down_fp) != 1) {
- logerror("bad header on login message (downfil)");
- fclose(down_fp);
- return 1;
- }
- if (tgm.tel_length >= (long)sizeof(buf)) {
- logerror("text length (%ld) is too long for login message (downfil)", tgm.tel_length);
- fclose(down_fp);
- return 1;
- }
- if (fread(buf, tgm.tel_length, 1, down_fp) != 1) {
- logerror("bad length %ld on login message", tgm.tel_length);
- fclose(down_fp);
- return 1;
- }
- buf[tgm.tel_length] = 0;
- fclose(down_fp);
- if (player->god) {
- if (!suppress_deity_message)
- pr("The game is down\n");
- return 0;
- }
- uprnf(buf);
- pr("\nThe game is down\n");
- return 1;
-}
-
static int
seconds_since_midnight(time_t time)
{
}
int
-may_play_now(struct natstr *natp, time_t now,
- int suppress_deity_message)
+may_play_now(struct natstr *natp, time_t now)
{
- update_timeused(now);
+ if (CANT_HAPPEN(natp->nat_cnum != player->cnum))
+ return 0;
- if (!gamehours(now)) {
- if (natp->nat_stat != STAT_GOD || !suppress_deity_message)
- pr("Empire hours restriction in force\n");
+ if (gamehours(now)) {
+ if (player->flags & PF_HOURS) {
+ pr("\nEmpire hours restriction lifted\n");
+ player->flags &= ~PF_HOURS;
+ }
+ } else {
+ if (!(player->flags & PF_HOURS)) {
+ pr("\nEmpire hours restriction in force\n");
+ player->flags |= PF_HOURS;
+ }
if (natp->nat_stat != STAT_GOD)
return 0;
}
- if (gamedown(suppress_deity_message))
- return 0;
+ if (game_play_disabled()) {
+ if (!(player->flags & PF_DOWN)) {
+ show_first_tel(downfil);
+ pr("\nThe game is down\n");
+ player->flags |= PF_DOWN;
+ }
+ if (natp->nat_stat != STAT_GOD)
+ return 0;
+ } else
+ player->flags &= ~PF_DOWN;
if ((natp->nat_stat != STAT_GOD && natp->nat_stat != STAT_VIS)
&& natp->nat_timeused > m_m_p_d * 60) {