aboutsummaryrefslogtreecommitdiffstats
path: root/games/znibbles/files/patch-src::X11::X11Interface.C
blob: db509a10727e480f1c0204d6227ee8a4f853fc72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
--- src/X11/X11Interface.C	Wed May 12 21:43:42 1999
+++ src/X11/X11Interface.C	Sat Oct 26 00:32:49 2002
@@ -38,7 +38,7 @@
 # include <config.h>
 #endif
 
-#include <iostream.h>
+#include <iostream>
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -109,7 +109,7 @@
   display_version();
 
   if (_two_key)
-    cout << "Two-key mode enabled" << endl;
+    std::cout << "Two-key mode enabled" << std::endl;
 
   
   // connect pipe_handler to SIGPIPE signal
@@ -125,8 +125,8 @@
     exit(2); 
   }
 
-  cout << "Connecting to ZNibbles server:  " \
-       << options.get_host_name() << ":" << options.get_port() << "... " << endl;
+  std::cout << "Connecting to ZNibbles server:  " \
+       << options.get_host_name() << ":" << options.get_port() << "... " << std::endl;
   
   // create and bind socket to any port 
   port = 0;
@@ -136,7 +136,7 @@
   } 
 
 //   if (debug)
-//     cout << "Client socket created on port: " << ntohs(client_address.sin_port) << endl;
+//     std::cout << "Client socket created on port: " << ntohs(client_address.sin_port) << std::endl;
   
   // Build server address 
   server_address.sin_family = AF_INET;
@@ -153,7 +153,7 @@
 
   display_play_help();
 
-  cout << "Connection accepted\n" << endl;
+  std::cout << "Connection accepted\n" << std::endl;
 
 //   hack_socket_client = socket_client; // hack for signal handling
 //   action.sa_handler = stop_handler;
@@ -163,7 +163,7 @@
 
   init_messages(options.get_message_file());
 
-  cout << "initializing interface..." << endl;
+  std::cout << "initializing interface..." << std::endl;
   X11Init(argc, argv);
 }
 
@@ -201,56 +201,56 @@
 // display version number (long format)
 void X11Interface::display_version() 
 {
-  cerr << "ZNibbles v" VERSION " - A little silly game - "
+  std::cerr << "ZNibbles v" VERSION " - A little silly game - "
        << "(c) Vincent Mallet 1997, 1998, 1999 - vmallet@enst.fr" 
-       << endl << endl;
+       << std::endl << std::endl;
 }
 
 // display version number (short format)
 void X11Interface::display_version_short()
 {
-  cout << "ZNibbles X11 Client -experimental- " VERSION << endl;
+  std::cout << "ZNibbles X11 Client -experimental- " VERSION << std::endl;
 }
 
 //display small help for invocation
 void X11Interface::display_help(char *name)
 {
-  cout << "Usage: " << name << " [OPTION].. PLAYERNAME" << endl;
-  cout << endl;
-  cout << "Start a ZNibbles X11 client and connect to the specified nibbles server." << endl;
-  cout << endl;
-  cout << "  -n, --host-name=HOST     connect to server HOST [default is localhost]" << endl;
-  cout << "  -p, --port=NUM           connect to port NUM of server [default is 5051]" << endl;
-  cout << "  -m, --message-file=FILE  load predefined messages from file FILE" << endl;
-  cout << "  -t, --twokey             control worm with only two keys, LEFT and RIGHT" << endl;
-  cout << "  -i, --enable-stdin       enable standard input for sending messages" << endl;
-  cout << "  -d, --debug              enable debug output" << endl;
-  cout << "  -V, --version            print version number, then exit" << endl;
-  cout << "  -h, --help               show this message and exit" << endl;
-  cout << endl;
-  cout << "Report bugs to <vmallet@enst.fr>." << endl;
+  std::cout << "Usage: " << name << " [OPTION].. PLAYERNAME" << std::endl;
+  std::cout << std::endl;
+  std::cout << "Start a ZNibbles X11 client and connect to the specified nibbles server." << std::endl;
+  std::cout << std::endl;
+  std::cout << "  -n, --host-name=HOST     connect to server HOST [default is localhost]" << std::endl;
+  std::cout << "  -p, --port=NUM           connect to port NUM of server [default is 5051]" << std::endl;
+  std::cout << "  -m, --message-file=FILE  load predefined messages from file FILE" << std::endl;
+  std::cout << "  -t, --twokey             control worm with only two keys, LEFT and RIGHT" << std::endl;
+  std::cout << "  -i, --enable-stdin       enable standard input for sending messages" << std::endl;
+  std::cout << "  -d, --debug              enable debug output" << std::endl;
+  std::cout << "  -V, --version            print version number, then exit" << std::endl;
+  std::cout << "  -h, --help               show this message and exit" << std::endl;
+  std::cout << std::endl;
+  std::cout << "Report bugs to <vmallet@enst.fr>." << std::endl;
 }
 
 
 // display help on key used
 void X11Interface::display_play_help()
 {
-  cout << endl;
-  cout << "Welcome to ZNibbles!" << endl;
-  cout << endl;
-  cout << "Valid keys while playing:" << endl
-       << endl
-       << "     Up, Down, Left, Right:   move worm 1" << endl
-       << endl
-       << "     p/u                  :   pause/unpause game" << endl
-       << endl
-       << "     P/U                  :   pause/unpause _your_ worm" << endl
-       << endl
-       << "     1, 2, ... 0          :   send predefined messages to other players" << endl
-       << endl
-       << "     Ctrl+Q               :   quit game" << endl
-       << endl
-       << " Have fun!" << endl;
+  std::cout << std::endl;
+  std::cout << "Welcome to ZNibbles!" << std::endl;
+  std::cout << std::endl;
+  std::cout << "Valid keys while playing:" << std::endl
+       << std::endl
+       << "     Up, Down, Left, Right:   move worm 1" << std::endl
+       << std::endl
+       << "     p/u                  :   pause/unpause game" << std::endl
+       << std::endl
+       << "     P/U                  :   pause/unpause _your_ worm" << std::endl
+       << std::endl
+       << "     1, 2, ... 0          :   send predefined messages to other players" << std::endl
+       << std::endl
+       << "     Ctrl+Q               :   quit game" << std::endl
+       << std::endl
+       << " Have fun!" << std::endl;
 }
 
 
@@ -261,7 +261,7 @@
 
 void X11Interface::pipe_handler(int sig)
 {
-  cerr << "--- Lost Server Connection! ---" << endl;
+  std::cerr << "--- Lost Server Connection! ---" << std::endl;
   sig++; // warnings..
   dead_server = 1;
 }
@@ -285,7 +285,7 @@
 
     z++;
     if (t.receive_from(socket_client)) {
-      //      cout << "receive error, errno=" << errno << endl;
+      //      std::cout << "receive error, errno=" << errno << std::endl;
 
       handle_Xevent();
       
@@ -309,7 +309,7 @@
 	}
 	
 	if (dir) {
-	  cout << "Sending Direction ==" << dir << endl;
+	  std::cout << "Sending Direction ==" << dir << std::endl;
 	  tx.reset();
 	  tx.put_char(PLAYER_CHANGEDIR);
 	  tx.put_char(dir);
@@ -323,7 +323,7 @@
 	  break; // on verra ca plus tard.
 	  
 	case WORLD_DESC: 
-	  cout << endl << "got WORLD_DESC " << endl;
+	  std::cout << std::endl << "got WORLD_DESC " << std::endl;
 	  w.read_description(t);
 	  tx.reset();
 	  tx.put_char(CYCLE_ACK);
@@ -333,14 +333,14 @@
 	  break;
 	  
 	case CHANGE_NOTIFY:
-	  //FAST	  cout << endl <<  "got CHANGE_NOTIFY " << endl;
+	  //FAST	  std::cout << std::endl <<  "got CHANGE_NOTIFY " << std::endl;
 	  t.get_char(); 
 	  w.read_changes(t);
 	  break;
 	  
 	case VOID_TRAME:
 	  {
-	    cout << "got VOID_TRAME " << endl;
+	    std::cout << "got VOID_TRAME " << std::endl;
 	    t.get_char();
 	    char *p = t.get_string();
 	    if (p && strcmp(p, "w") == 0)
@@ -358,10 +358,10 @@
 	
 	case TEXT_MESSAGE:
 	  {
-	    cout << "got *private* TEXT_MESSAGE == '";
+	    std::cout << "got *private* TEXT_MESSAGE == '";
 	    t.get_char(); // skip packet id
 	    char *msg = t.get_string();
-	    cout << msg << "'" << endl;
+	    std::cout << msg << "'" << std::endl;
 	  }
 	break;
 
@@ -393,13 +393,13 @@
 	break;
 
 	case QUIT_GAME:
-	  cout << "Got QUIT_GAME" << endl;
-	  cout << "Client shutting down.... " << endl;
+	  std::cout << "Got QUIT_GAME" << std::endl;
+	  std::cout << "Client shutting down.... " << std::endl;
 	  done = 1;
 	  break;
 
 	default:
-	  cout << "got unknown frame type: " << (int) t.peek_char() << endl;
+	  std::cout << "got unknown frame type: " << (int) t.peek_char() << std::endl;
 	  break;
 	}
     }
@@ -427,13 +427,13 @@
 	nibblesarea.redraw2();
       break;
     case ButtonPress:
-      cout << "ButtonPress" << endl;
+      std::cout << "ButtonPress" << std::endl;
       break;
     case KeyPress:
       nibblesarea.handle_key(&report);
       break;
     case ConfigureNotify:
-      cout << "Configure" << endl;
+      std::cout << "Configure" << std::endl;
       break;
     }
   }
@@ -442,30 +442,30 @@
 
 void X11Interface::add_player(Player& p)
 {
-  cout << "Player <" << p.get_name() <<"> joined the game!" << endl;
+  std::cout << "Player <" << p.get_name() <<"> joined the game!" << std::endl;
 }
 
 void X11Interface::kill_player(Player& p, int reason)
 {
-  cout << "Player <" << p.get_name() <<"> LEFT the game!     (reason=" << reason << ")" << endl;
+  std::cout << "Player <" << p.get_name() <<"> LEFT the game!     (reason=" << reason << ")" << std::endl;
 }
 
 
 void X11Interface::display_message(Player& from, char *msg, int priv)
 {
   if (priv) 
-    cout << "*private*  Message: " << from.get_name() << "> " << msg << endl;
+    std::cout << "*private*  Message: " << from.get_name() << "> " << msg << std::endl;
   else 
-    cout << "Message: " << from.get_name() << "> " << msg << endl;
+    std::cout << "Message: " << from.get_name() << "> " << msg << std::endl;
 }
 
 void X11Interface::display_system_message(char *msg, Player *p, int color) // default p=NULL, color=0
 {
   color++;
-  cout << "*** ";
+  std::cout << "*** ";
   if (p)
-    cout << p->get_name() << " ";
-  cout << msg;
+    std::cout << p->get_name() << " ";
+  std::cout << msg;
 }