2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program 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 2 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * turn.c: Turn the game on, off, or set the login message.
30 * Known contributors to this file:
44 * Enable / disable logins and set the message of the day.
55 p = getstarg(player->argp[1], "on, off or motd? ", buf);
58 if (strcmp(p, "off") == 0) {
59 msgfilepath = downfil;
60 } else if (strcmp(p, "on") == 0) {
61 pr("Removing no-login message and re-enabling logins.\n");
62 if ((unlink(downfil) == -1) && (errno != ENOENT))
64 pr("Could not remove no-login file, logins still disabled.\n");
65 logerror("Could not remove no-login file (%s).\n", downfil);
70 msgfilepath = motdfil;
73 if (msgfilepath == downfil)
74 pr("Enter a message shown to countries trying to log in.\n");
76 pr("Enter a new message of the day.\n");
79 tgm.tel_length = getele("The World", buf);
81 if (tgm.tel_length < 0)
84 if (msgfilepath == downfil)
85 pr("NOT disabling logins.\n");
87 } else if (tgm.tel_length == 0)
89 if (msgfilepath == motdfil)
91 pr("Removing exsting motd.\n");
92 if ((unlink(msgfilepath) == -1) && (errno != ENOENT))
94 pr("Could not remove motd.\n");
95 logerror("Could not remove motd file (%s).\n", msgfilepath);
100 pr("Writing empty no-login message.\n");
104 fd = open(msgfilepath, O_RDWR | O_CREAT | O_TRUNC, 0660);
106 fd = open(msgfilepath, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0660);
110 pr("Something went wrong opening the message file.\n");
111 logerror("Could not open message file (%s).\n", msgfilepath);
115 if (msgfilepath == downfil)
116 pr("Logins disabled.\n");
118 if ((write(fd, &tgm, sizeof(tgm)) < sizeof(tgm)) ||
119 (write(fd, buf, tgm.tel_length) < tgm.tel_length) ||
122 pr("Something went wrong writing the message file.\n");
123 logerror("Could not properly write message file (%s).\n",