]> git.pond.sub.org Git - empserver/blob - src/lib/commands/togg.c
Support UTF-8 encoded Unicode for user communications.
[empserver] / src / lib / commands / togg.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
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.
25  *
26  *  ---
27  *
28  *  togg.c: Set player flags
29  * 
30  *  Known contributors to this file:
31  *     Ken Stevens, 1995
32  *     Steve McClure, 1996
33  */
34
35 #include "misc.h"
36 #include "player.h"
37 #include "file.h"
38 #include "nat.h"
39 #include "commands.h"
40
41 int
42 togg(void)
43 {
44     int flag = 0;
45     int pos;
46     s_char *name;
47     struct natstr *np;
48
49     np = getnatp(player->cnum);
50     if (player->argp[1]) {
51         switch (*player->argp[1]) {
52         case 'i':
53             name = "inform";
54             flag = NF_INFORM;
55             break;
56         case 'f':
57             name = "flash";
58             flag = NF_FLASH;
59             break;
60         case 'b':
61             name = "beep";
62             flag = NF_BEEP;
63             break;
64         case 'c':
65             name = "coastwatch";
66             flag = NF_COASTWATCH;
67             break;
68         case 's':
69             name = "sonar";
70             flag = NF_SONAR;
71             break;
72         case 't':
73             name = "techlists";
74             flag = NF_TECHLISTS;
75             break;
76         case 'u':
77             name = "UTF-8";
78             flag = NF_UTF8;
79             break;
80         default:
81             return RET_SYN;
82         }
83         if (player->argp[2])
84             if (!strcmp(player->argp[2], "on"))
85                 pos = 1;
86             else if (!strcmp(player->argp[2], "off"))
87                 pos = 0;
88             else
89                 return RET_SYN;
90         else
91             pos = !(np->nat_flags & flag);
92         if (pos)
93             np->nat_flags |= flag;
94         else
95             np->nat_flags &= ~flag;
96         putnat(np);
97         pr("%s flag %s\n", name, pos ? "on" : "off");
98     } else {
99         if (np->nat_flags & NF_INFORM)
100             pr("inform flag on\n");
101         else
102             pr("inform flag off\n");
103         if (np->nat_flags & NF_FLASH)
104             pr("flash flag on\n");
105         else
106             pr("flash flag off\n");
107         if (np->nat_flags & NF_BEEP)
108             pr("beep flag on\n");
109         else
110             pr("beep flag off\n");
111         if (np->nat_flags & NF_COASTWATCH)
112             pr("coastwatch flag on\n");
113         else
114             pr("coastwatch flag off\n");
115         if (np->nat_flags & NF_SONAR)
116             pr("sonar flag on\n");
117         else
118             pr("sonar flag off\n");
119         if (np->nat_flags & NF_TECHLISTS)
120             pr("techlists flag on\n");
121         else
122             pr("techlists flag off\n");
123         if (np->nat_flags & NF_UTF8)
124             pr("UTF-8 flag on\n");
125         else
126             pr("UTF-8 flag off\n");
127     }
128
129     return RET_OK;
130 }