2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * turn.c: Turn the game on, off, or set the login message.
29 * Known contributors to this file:
31 * Ron Koenderink, 2005-2007
32 * Markus Armbruster, 2005-2009
51 char msgbuf[MAXTELSIZE + 1]; /* UTF-8 */
55 p = getstarg(player->argp[1], "on, off or motd? ", buf);
58 if (strcmp(p, "off") == 0) {
59 msgfilepath = downfil;
60 pr("Enter a message explaining the down time.\n");
61 len = getele("The World", msgbuf);
63 } else if (strcmp(p, "on") == 0) {
64 msgfilepath = downfil;
68 msgfilepath = motdfil;
69 pr("Enter a new message of the day.\n");
70 len = getele("The World", msgbuf);
77 if (unlink(msgfilepath) < 0 && (errno != ENOENT)) {
78 pr("Could not remove %s file.\n", msgfilepath);
79 logerror("Could not remove %s file (%s)",
80 msgfilepath, strerror(errno));
84 fptr = fopen(msgfilepath, "wb");
86 pr("Something went wrong opening the message file.\n");
87 logerror("Could not open message file (%s).\n", msgfilepath);
90 memset(&tgm, 0, sizeof(tgm));
93 if (fwrite(&tgm, sizeof(tgm), 1, fptr) != 1 ||
94 fwrite(msgbuf, 1, tgm.tel_length, fptr) != tgm.tel_length) {
96 pr("Something went wrong writing the message file.\n");
97 logerror("Could not properly write message file (%s).\n",
102 pr("Something went wrong closing the message.\n");
103 logerror("Could not properly close message file (%s).\n",
110 game_ctrl_play(!down);
112 /* "The game is down" will be printed automatically */