source: network-game/client/Client/main.cpp@ f63aa57

Last change on this file since f63aa57 was f63aa57, checked in by dportnoy <dmp1488@…>, 11 years ago

The old Game window has been completely removed from the client and the client frees all gui components on its own, instead of relying on the Window destructor

  • Property mode set to 100644
File size: 42.6 KB
Line 
1#include "../../common/Compiler.h"
2
3#if defined WINDOWS
4 #include <winsock2.h>
5 #include <ws2tcpip.h>
6#elif defined LINUX
7 #include <sys/types.h>
8 #include <unistd.h>
9 #include <sys/socket.h>
10 #include <netinet/in.h>
11 #include <netdb.h>
12 #include <cstring>
13#endif
14
15#include <cstdio>
16#include <cstdlib>
17#include <cmath>
18#include <sys/types.h>
19#include <string>
20#include <iostream>
21#include <sstream>
22#include <fstream>
23#include <map>
24#include <vector>
25
26#include <allegro5/allegro.h>
27#include <allegro5/allegro_font.h>
28#include <allegro5/allegro_ttf.h>
29#include <allegro5/allegro_primitives.h>
30
31#include "../../common/Common.h"
32#include "../../common/MessageContainer.h"
33#include "../../common/MessageProcessor.h"
34#include "../../common/WorldMap.h"
35#include "../../common/Player.h"
36#include "../../common/Projectile.h"
37#include "../../common/Game.h"
38#include "../../common/GameSummary.h"
39
40#include "Window.h"
41#include "TextLabel.h"
42#include "Button.h"
43#include "Textbox.h"
44#include "RadioButtonList.h"
45
46#include "GameRender.h"
47
48#include "chat.h"
49
50#ifdef WINDOWS
51 #pragma comment(lib, "ws2_32.lib")
52#endif
53
54using namespace std;
55
56void initWinSock();
57void shutdownWinSock();
58void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers,
59 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId);
60int getRefreshRate(int width, int height);
61void drawMessageStatus(ALLEGRO_FONT* font);
62
63// Callback declarations
64void goToLoginScreen();
65void goToRegisterScreen();
66void registerAccount();
67void login();
68void logout();
69void quit();
70void sendChatMessage();
71void toggleDebugging();
72void joinGame();
73void createGame();
74void leaveGame();
75void closeGameSummary();
76
77const float FPS = 60;
78const int SCREEN_W = 1024;
79const int SCREEN_H = 768;
80
81enum STATE {
82 STATE_START,
83 STATE_LOBBY,
84 STATE_GAME
85};
86
87int state;
88
89bool doexit;
90
91vector<GuiComponent*> vctComponents;
92
93Window* wndLogin;
94Window* wndRegister;
95Window* wndLobby;
96Window* wndLobbyDebug;
97Window* wndNewGame;
98Window* wndGameSummary;
99Window* wndCurrent;
100
101// wndLogin
102Textbox* txtUsername;
103Textbox* txtPassword;
104TextLabel* lblLoginStatus;
105
106// wndRegister
107Textbox* txtUsernameRegister;
108Textbox* txtPasswordRegister;
109RadioButtonList* rblClasses;
110TextLabel* lblRegisterStatus;
111
112// wndLobby
113Textbox* txtJoinGame;
114Textbox* txtCreateGame;
115Textbox* txtChat;
116
117int sock;
118struct sockaddr_in server, from;
119struct hostent *hp;
120NETWORK_MSG msgTo, msgFrom;
121string username;
122chat chatConsole, debugConsole;
123bool debugging;
124map<string, int> mapGames;
125Game* game;
126GameSummary* gameSummary;
127
128MessageProcessor msgProcessor;
129
130int main(int argc, char **argv)
131{
132 ALLEGRO_DISPLAY *display = NULL;
133 ALLEGRO_EVENT_QUEUE *event_queue = NULL;
134 ALLEGRO_TIMER *timer = NULL;
135 bool key[4] = { false, false, false, false };
136 map<unsigned int, Player*> mapPlayers;
137 map<unsigned int, Projectile> mapProjectiles;
138 unsigned int curPlayerId = -1;
139 ofstream outputLog;
140
141 doexit = false;
142 debugging = false;
143 bool redraw = true;
144 bool fullscreen = false;
145 game = NULL;
146 gameSummary = NULL;
147
148 state = STATE_START;
149
150 if(!al_init()) {
151 fprintf(stderr, "failed to initialize allegro!\n");
152 return -1;
153 }
154
155 outputLog.open("client.log", ios::app);
156 outputLog << "Started client on " << getCurrentDateTimeString() << endl;
157
158 if (al_init_primitives_addon())
159 cout << "Primitives initialized" << endl;
160 else
161 cout << "Primitives not initialized" << endl;
162
163 al_init_font_addon();
164 al_init_ttf_addon();
165
166 #if defined WINDOWS
167 ALLEGRO_FONT *font = al_load_ttf_font("../pirulen.ttf", 12, 0);
168 #elif defined LINUX
169 ALLEGRO_FONT *font = al_load_ttf_font("pirulen.ttf", 12, 0);
170 #endif
171
172 if (!font) {
173 fprintf(stderr, "Could not load 'pirulen.ttf'.\n");
174 getchar();
175 return -1;
176 }
177
178 if(!al_install_keyboard()) {
179 fprintf(stderr, "failed to initialize the keyboard!\n");
180 return -1;
181 }
182
183 if(!al_install_mouse()) {
184 fprintf(stderr, "failed to initialize the mouse!\n");
185 return -1;
186 }
187
188 timer = al_create_timer(1.0 / FPS);
189 if(!timer) {
190 fprintf(stderr, "failed to create timer!\n");
191 return -1;
192 }
193
194 int refreshRate = getRefreshRate(SCREEN_W, SCREEN_H);
195 // if the computer doesn't support this resolution, just use windowed mode
196 if (refreshRate > 0 && fullscreen) {
197 al_set_new_display_flags(ALLEGRO_FULLSCREEN);
198 al_set_new_display_refresh_rate(refreshRate);
199 }
200 display = al_create_display(SCREEN_W, SCREEN_H);
201 if(!display) {
202 fprintf(stderr, "failed to create display!\n");
203 al_destroy_timer(timer);
204 return -1;
205 }
206
207 WorldMap* gameMap = WorldMap::loadMapFromFile("../../data/map.txt");
208
209 cout << "Loaded map" << endl;
210
211 debugConsole.addLine("Debug console:");
212 debugConsole.addLine("");
213
214 wndLogin = new Window(0, 0, SCREEN_W, SCREEN_H);
215 vctComponents.push_back(wndLogin->addComponent(new Textbox(516, 40, 100, 20, font)));
216 vctComponents.push_back(wndLogin->addComponent(new Textbox(516, 70, 100, 20, font)));
217 vctComponents.push_back(wndLogin->addComponent(new TextLabel(410, 40, 100, 20, font, "Username:", ALLEGRO_ALIGN_RIGHT)));
218 vctComponents.push_back(wndLogin->addComponent(new TextLabel(410, 70, 100, 20, font, "Password:", ALLEGRO_ALIGN_RIGHT)));
219 vctComponents.push_back(wndLogin->addComponent(new TextLabel((SCREEN_W-600)/2, 100, 600, 20, font, "", ALLEGRO_ALIGN_CENTRE)));
220 vctComponents.push_back(wndLogin->addComponent(new Button(SCREEN_W/2-100, 130, 90, 20, font, "Register", goToRegisterScreen)));
221 vctComponents.push_back(wndLogin->addComponent(new Button(SCREEN_W/2+10, 130, 90, 20, font, "Login", login)));
222 vctComponents.push_back(wndLogin->addComponent(new Button(920, 10, 80, 20, font, "Quit", quit)));
223 vctComponents.push_back(wndLogin->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)));
224
225 txtUsername = (Textbox*)wndLogin->getComponent(0);
226 txtPassword = (Textbox*)wndLogin->getComponent(1);
227 lblLoginStatus = (TextLabel*)wndLogin->getComponent(4);
228
229 cout << "Created login screen" << endl;
230
231 wndRegister = new Window(0, 0, SCREEN_W, SCREEN_H);
232 vctComponents.push_back(wndRegister->addComponent(new Textbox(516, 40, 100, 20, font)));
233 vctComponents.push_back(wndRegister->addComponent(new Textbox(516, 70, 100, 20, font)));
234 vctComponents.push_back(wndRegister->addComponent(new TextLabel(410, 40, 100, 20, font, "Username:", ALLEGRO_ALIGN_RIGHT)));
235 vctComponents.push_back(wndRegister->addComponent(new TextLabel(410, 70, 100, 20, font, "Password:", ALLEGRO_ALIGN_RIGHT)));
236 vctComponents.push_back(wndRegister->addComponent(new RadioButtonList(432, 100, "Pick a class", font)));
237 vctComponents.push_back(wndRegister->addComponent(new TextLabel((SCREEN_W-600)/2, 190, 600, 20, font, "", ALLEGRO_ALIGN_CENTRE)));
238 vctComponents.push_back(wndRegister->addComponent(new Button(SCREEN_W/2-100, 220, 90, 20, font, "Back", goToLoginScreen)));
239 vctComponents.push_back(wndRegister->addComponent(new Button(SCREEN_W/2+10, 220, 90, 20, font, "Submit", registerAccount)));
240 vctComponents.push_back(wndRegister->addComponent(new Button(920, 10, 80, 20, font, "Quit", quit)));
241 vctComponents.push_back(wndRegister->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)));
242
243 txtUsernameRegister = (Textbox*)wndRegister->getComponent(0);
244 txtPasswordRegister = (Textbox*)wndRegister->getComponent(1);
245
246 rblClasses = (RadioButtonList*)wndRegister->getComponent(4);
247 rblClasses->addRadioButton("Warrior");
248 rblClasses->addRadioButton("Ranger");
249
250 lblRegisterStatus = (TextLabel*)wndRegister->getComponent(5);
251
252 cout << "Created register screen" << endl;
253
254 txtJoinGame = new Textbox(SCREEN_W*1/2+15+4, 40, 100, 20, font);
255 txtCreateGame = new Textbox(SCREEN_W*3/4+4, 40, 100, 20, font);
256
257 vctComponents.push_back(txtJoinGame);
258 vctComponents.push_back(txtCreateGame);
259
260 wndLobby = new Window(0, 0, SCREEN_W, SCREEN_H);
261 vctComponents.push_back(wndLobby->addComponent(new Button(920, 10, 80, 20, font, "Logout", logout)));
262 vctComponents.push_back(wndLobby->addComponent(new TextLabel(SCREEN_W*1/2+15-112, 40, 110, 20, font, "Game Name:", ALLEGRO_ALIGN_RIGHT)));
263 wndLobby->addComponent(txtJoinGame);
264 vctComponents.push_back(wndLobby->addComponent(new Button(SCREEN_W*1/2+15-100, 80, 200, 20, font, "Join Existing Game", joinGame)));
265 vctComponents.push_back(wndLobby->addComponent(new TextLabel(SCREEN_W*3/4-112, 40, 110, 20, font, "Game Name:", ALLEGRO_ALIGN_RIGHT)));
266 wndLobby->addComponent(txtCreateGame);
267 vctComponents.push_back(wndLobby->addComponent(new Button(SCREEN_W*3/4-100, 80, 200, 20, font, "Create New Game", createGame)));
268 vctComponents.push_back(wndLobby->addComponent(new Textbox(95, 40, 300, 20, font)));
269 vctComponents.push_back(wndLobby->addComponent(new Button(95, 70, 60, 20, font, "Send", sendChatMessage)));
270 vctComponents.push_back(wndLobby->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)));
271
272
273 txtChat = (Textbox*)wndLobby->getComponent(7);
274
275 cout << "Created lobby screen" << endl;
276
277 wndLobbyDebug = new Window(0, 0, SCREEN_W, SCREEN_H);
278 vctComponents.push_back(wndLobbyDebug->addComponent(new Button(920, 10, 80, 20, font, "Logout", logout)));
279 vctComponents.push_back(wndLobbyDebug->addComponent(new TextLabel(SCREEN_W*1/2+15-112, 40, 110, 20, font, "Game Name:", ALLEGRO_ALIGN_RIGHT)));
280 wndLobbyDebug->addComponent(txtJoinGame);
281 vctComponents.push_back(wndLobbyDebug->addComponent(new Button(SCREEN_W*1/2+15-100, 80, 200, 20, font, "Join Existing Game", joinGame)));
282 vctComponents.push_back(wndLobbyDebug->addComponent(new TextLabel(SCREEN_W*3/4-112, 40, 110, 20, font, "Game Name:", ALLEGRO_ALIGN_RIGHT)));
283 wndLobbyDebug->addComponent(txtCreateGame);
284 vctComponents.push_back(wndLobbyDebug->addComponent(new Button(SCREEN_W*3/4-100, 80, 200, 20, font, "Create New Game", createGame)));
285 vctComponents.push_back(wndLobbyDebug->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)));
286
287 cout << "Created debug lobby screen" << endl;
288
289 wndNewGame = new Window(0, 0, SCREEN_W, SCREEN_H);
290 vctComponents.push_back(wndNewGame->addComponent(new Button(880, 10, 120, 20, font, "Leave Game", leaveGame)));
291
292 cout << "Created new game screen" << endl;
293
294 wndGameSummary = new Window(0, 0, SCREEN_W, SCREEN_H);
295 vctComponents.push_back(wndGameSummary->addComponent(new Button(840, 730, 160, 20, font, "Back to Lobby", closeGameSummary)));
296
297 cout << "Created game summary screen" << endl;
298
299 goToLoginScreen();
300
301 event_queue = al_create_event_queue();
302 if(!event_queue) {
303 fprintf(stderr, "failed to create event_queue!\n");
304 al_destroy_display(display);
305 al_destroy_timer(timer);
306 return -1;
307 }
308
309 al_set_target_bitmap(al_get_backbuffer(display));
310
311 al_register_event_source(event_queue, al_get_display_event_source(display));
312 al_register_event_source(event_queue, al_get_timer_event_source(timer));
313 al_register_event_source(event_queue, al_get_keyboard_event_source());
314 al_register_event_source(event_queue, al_get_mouse_event_source());
315
316 al_clear_to_color(al_map_rgb(0,0,0));
317
318 al_flip_display();
319
320 if (argc != 3) {
321 cout << "Usage: server port" << endl;
322 exit(1);
323 }
324
325 initWinSock();
326
327 sock = socket(AF_INET, SOCK_DGRAM, 0);
328 if (sock < 0)
329 error("socket");
330
331 set_nonblock(sock);
332
333 server.sin_family = AF_INET;
334 hp = gethostbyname(argv[1]);
335 if (hp == 0)
336 error("Unknown host");
337
338 memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
339 server.sin_port = htons(atoi(argv[2]));
340
341 msgProcessor = MessageProcessor(sock, &outputLog);
342
343 al_start_timer(timer);
344
345 while(!doexit)
346 {
347 ALLEGRO_EVENT ev;
348
349 al_wait_for_event(event_queue, &ev);
350
351 if(wndCurrent->handleEvent(ev)) {
352 // do nothing
353 }
354 else if(ev.type == ALLEGRO_EVENT_TIMER) {
355 redraw = true; // seems like we should just call a draw function here instead
356 }
357 else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
358 doexit = true;
359 }
360 else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) {
361 }
362 else if(ev.type == ALLEGRO_EVENT_KEY_UP) {
363 switch(ev.keyboard.keycode) {
364 case ALLEGRO_KEY_ESCAPE:
365 doexit = true;
366 break;
367 case ALLEGRO_KEY_S: // pickup an item next to you
368 if (state == STATE_GAME) {
369 msgTo.type = MSG_TYPE_PICKUP_FLAG;
370 memcpy(msgTo.buffer, &curPlayerId, 4);
371 msgProcessor.sendMessage(&msgTo, &server);
372 }
373 break;
374 case ALLEGRO_KEY_D: // drop the current item
375 if (state == STATE_GAME) {
376 Player* p = NULL;
377 try {
378 p = mapPlayers.at(curPlayerId);
379 } catch (const out_of_range& ex) {}
380
381 if (p != NULL) {
382 int flagType = WorldMap::OBJECT_NONE;
383
384 if (p->hasBlueFlag)
385 flagType = WorldMap::OBJECT_BLUE_FLAG;
386 else if (p->hasRedFlag)
387 flagType = WorldMap::OBJECT_RED_FLAG;
388
389 if (flagType != WorldMap::OBJECT_NONE) {
390 msgTo.type = MSG_TYPE_DROP_FLAG;
391 memcpy(msgTo.buffer, &curPlayerId, 4);
392 msgProcessor.sendMessage(&msgTo, &server);
393 }
394 }
395 }
396 break;
397 }
398 }
399 else if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP) {
400 if(wndCurrent == wndNewGame) {
401 if (ev.mouse.button == 1) { // left click
402 msgTo.type = MSG_TYPE_PLAYER_MOVE;
403
404 POSITION pos;
405 pos.x = ev.mouse.x;
406 pos.y = ev.mouse.y;
407 pos = screenToMap(pos);
408
409 if (pos.x != -1)
410 {
411 memcpy(msgTo.buffer, &curPlayerId, 4);
412 memcpy(msgTo.buffer+4, &pos.x, 4);
413 memcpy(msgTo.buffer+8, &pos.y, 4);
414
415 msgProcessor.sendMessage(&msgTo, &server);
416 }
417 else
418 cout << "Invalid point: User did not click on the map" << endl;
419 }else if (ev.mouse.button == 2) { // right click
420 cout << "Detected a right-click" << endl;
421 map<unsigned int, Player*>::iterator it;
422
423 Player* curPlayer = mapPlayers[curPlayerId];;
424
425 cout << "Got current player" << endl;
426 cout << "current game: " << game << endl;
427
428 map<unsigned int, Player*> playersInGame = game->getPlayers();
429 Player* target;
430
431 for(it = playersInGame.begin(); it != playersInGame.end(); it++)
432 {
433 // need to check if the right-click was actually on this player
434 // right now, this code will target all players other than the current one
435 target = it->second;
436 cout << "set target" << endl;
437 if (target->id != curPlayerId && target->team != curPlayer->team)
438 {
439 cout << "Found valid target" << endl;
440
441 msgTo.type = MSG_TYPE_START_ATTACK;
442 memcpy(msgTo.buffer, &curPlayerId, 4);
443 memcpy(msgTo.buffer+4, &target->id, 4);
444
445 msgProcessor.sendMessage(&msgTo, &server);
446 }
447 }
448 }
449 }
450 }
451
452 if (msgProcessor.receiveMessage(&msgFrom, &from) >= 0)
453 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId);
454
455 if (redraw)
456 {
457 redraw = false;
458
459 msgProcessor.resendUnackedMessages();
460
461 if (debugging && wndCurrent == wndLobby)
462 wndLobbyDebug->draw(display);
463 else
464 wndCurrent->draw(display);
465
466 if (wndCurrent == wndLobby) {
467 if (!debugging)
468 chatConsole.draw(font, al_map_rgb(255,255,255));
469
470 map<string, int>::iterator it;
471 int i=0;
472 ostringstream ossGame;
473 for (it = mapGames.begin(); it != mapGames.end(); it++) {
474 ossGame << it->first << " (" << it->second << " players)" << endl;
475 al_draw_text(font, al_map_rgb(0, 255, 0), SCREEN_W*1/2-100, 120+i*15, ALLEGRO_ALIGN_LEFT, ossGame.str().c_str());
476 ossGame.clear();
477 ossGame.str("");
478 i++;
479 }
480 }
481 else if (wndCurrent == wndNewGame)
482 {
483 al_draw_text(font, al_map_rgb(0, 255, 0), 4, 4, ALLEGRO_ALIGN_LEFT, "Players");
484
485 map<unsigned int, Player*>& gamePlayers = game->getPlayers();
486 map<unsigned int, Player*>::iterator it;
487
488 int playerCount = 0;
489 for (it = gamePlayers.begin(); it != gamePlayers.end(); it++)
490 {
491 al_draw_text(font, al_map_rgb(0, 255, 0), 4, 19+(playerCount+1)*15, ALLEGRO_ALIGN_LEFT, it->second->name.c_str());
492 playerCount++;
493 }
494
495 ostringstream ossScoreBlue, ossScoreRed;
496
497 ossScoreBlue << "Blue: " << game->getBlueScore() << endl;
498 ossScoreRed << "Red: " << game->getRedScore() << endl;
499
500 al_draw_text(font, al_map_rgb(0, 255, 0), 330, 80, ALLEGRO_ALIGN_LEFT, ossScoreBlue.str().c_str());
501 al_draw_text(font, al_map_rgb(0, 255, 0), 515, 80, ALLEGRO_ALIGN_LEFT, ossScoreRed.str().c_str());
502
503 // update players
504 for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++)
505 {
506 it->second->updateTarget(game->getPlayers());
507 }
508
509 for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++)
510 {
511 it->second->move(game->getMap()); // ignore return value
512 }
513
514 // update projectile positions
515 map<unsigned int, Projectile>::iterator it2;
516 for (it2 = game->getProjectiles().begin(); it2 != game->getProjectiles().end(); it2++)
517 {
518 it2->second.move(game->getPlayers());
519 }
520
521 GameRender::drawMap(game->getMap());
522 GameRender::drawPlayers(game->getPlayers(), font, curPlayerId);
523
524 // draw projectiles
525 for (it2 = game->getProjectiles().begin(); it2 != game->getProjectiles().end(); it2++)
526 {
527 Projectile proj = it2->second;
528
529 FLOAT_POSITION target = game->getPlayers()[proj.target]->pos;
530 float angle = atan2(target.y-proj.pos.toFloat().y, target.x-proj.pos.toFloat().x);
531
532 POSITION start, end;
533 start.x = cos(angle)*15+proj.pos.x;
534 start.y = sin(angle)*15+proj.pos.y;
535 end.x = proj.pos.x;
536 end.y = proj.pos.y;
537
538 start = mapToScreen(start);
539 end = mapToScreen(end);
540
541 al_draw_line(start.x, start.y, end.x, end.y, al_map_rgb(0, 0, 0), 4);
542 }
543 }
544 else if (wndCurrent == wndGameSummary)
545 {
546 ostringstream ossBlueScore, ossRedScore;
547
548 ossBlueScore << "Blue Score: " << gameSummary->getBlueScore();
549 ossRedScore << "Red Score: " << gameSummary->getRedScore();
550
551 string strWinner;
552
553 if (gameSummary->getWinner() == 0)
554 strWinner = "Blue Team Wins";
555 else if (gameSummary->getWinner() == 1)
556 strWinner = "Red Team Wins";
557 else
558 strWinner = "winner set to wrong value";
559
560 al_draw_text(font, al_map_rgb(0, 255, 0), 512, 40, ALLEGRO_ALIGN_CENTRE, gameSummary->getName().c_str());
561 al_draw_text(font, al_map_rgb(0, 255, 0), 330, 80, ALLEGRO_ALIGN_LEFT, ossBlueScore.str().c_str());
562 al_draw_text(font, al_map_rgb(0, 255, 0), 515, 80, ALLEGRO_ALIGN_LEFT, ossRedScore.str().c_str());
563 al_draw_text(font, al_map_rgb(0, 255, 0), 512, 120, ALLEGRO_ALIGN_CENTRE, strWinner.c_str());
564 }
565
566 if (debugging) {
567 //debugConsole.draw(font, al_map_rgb(255,255,255));
568 drawMessageStatus(font);
569 }
570
571 al_flip_display();
572 }
573 }
574
575 #if defined WINDOWS
576 closesocket(sock);
577 #elif defined LINUX
578 close(sock);
579 #endif
580
581 shutdownWinSock();
582
583 // delete all components
584 for (unsigned int x=0; x<vctComponents.size(); x++)
585 delete vctComponents[x];
586
587 delete wndLogin;
588 delete wndRegister;
589 delete wndLobby;
590 delete wndLobbyDebug;
591 delete wndNewGame;
592 delete wndGameSummary;
593
594 delete gameMap;
595
596 if (game != NULL)
597 delete game;
598
599 if (gameSummary != NULL)
600 delete gameSummary;
601
602 map<unsigned int, Player*>::iterator it;
603
604 for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) {
605 delete it->second;
606 }
607
608 al_destroy_event_queue(event_queue);
609 al_destroy_display(display);
610 al_destroy_timer(timer);
611
612 outputLog << "Stopped client on " << getCurrentDateTimeString() << endl;
613 outputLog.close();
614
615 return 0;
616}
617
618void initWinSock()
619{
620#if defined WINDOWS
621 WORD wVersionRequested;
622 WSADATA wsaData;
623 int wsaerr;
624
625 wVersionRequested = MAKEWORD(2, 2);
626 wsaerr = WSAStartup(wVersionRequested, &wsaData);
627
628 if (wsaerr != 0) {
629 cout << "The Winsock dll not found." << endl;
630 exit(1);
631 }else
632 cout << "The Winsock dll was found." << endl;
633#endif
634}
635
636void shutdownWinSock()
637{
638#if defined WINDOWS
639 WSACleanup();
640#endif
641}
642
643void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers,
644 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId)
645{
646 // this is outdated since most messages now don't contain just a text string
647 string response = string(msg.buffer);
648
649 switch(state)
650 {
651 case STATE_START:
652 {
653 cout << "In STATE_START" << endl;
654
655 switch(msg.type)
656 {
657 case MSG_TYPE_REGISTER:
658 {
659 lblRegisterStatus->setText(response);
660 break;
661 }
662 default:
663 {
664 cout << "(STATE_REGISTER) Received invalid message of type " << msg.type << endl;
665 break;
666 }
667 }
668
669 break;
670 }
671 case STATE_LOBBY:
672 {
673 cout << "In STATE_LOBBY" << endl;
674 switch(msg.type)
675 {
676 case MSG_TYPE_LOGIN:
677 {
678 if (response.compare("Player has already logged in.") == 0)
679 {
680 goToLoginScreen();
681 state = STATE_START;
682
683 lblLoginStatus->setText(response);
684 }
685 else if (response.compare("Incorrect username or password") == 0)
686 {
687 goToLoginScreen();
688 state = STATE_START;
689
690 lblLoginStatus->setText(response);
691 }
692 else
693 {
694 wndCurrent = wndLobby;
695
696 // this message should only be sent when a player first logs in so they know their id
697
698 Player* p = new Player("", "");
699 p->deserialize(msg.buffer);
700
701 if (mapPlayers.find(p->id) != mapPlayers.end())
702 delete mapPlayers[p->id];
703 mapPlayers[p->id] = p;
704 curPlayerId = p->id;
705
706 cout << "Got a valid login response with the player" << endl;
707 cout << "Player id: " << curPlayerId << endl;
708 cout << "Player health: " << p->health << endl;
709 cout << "player map size: " << mapPlayers.size() << endl;
710 }
711
712 break;
713 }
714 case MSG_TYPE_LOGOUT:
715 {
716 cout << "Got a logout message" << endl;
717
718 int playerId;
719
720 // Check if it's about you or another player
721 memcpy(&playerId, msg.buffer, 4);
722 response = string(msg.buffer+4);
723
724 if (playerId == curPlayerId)
725 {
726 if (response.compare("You have successfully logged out.") == 0)
727 {
728 cout << "Logged out" << endl;
729 state = STATE_START;
730 goToLoginScreen();
731 }
732
733 // if there was an error logging out, nothing happens
734 }
735 else
736 {
737 delete mapPlayers[playerId];
738 }
739
740 break;
741 }
742 case MSG_TYPE_PLAYER:
743 {
744 cout << "Received MSG_TYPE_PLAYER" << endl;
745
746 Player p("", "");
747 p.deserialize(msg.buffer);
748 p.timeLastUpdated = getCurrentMillis();
749 p.isChasing = false;
750 if (p.health <= 0)
751 p.isDead = true;
752 else
753 p.isDead = false;
754
755 if (mapPlayers.find(p.id) != mapPlayers.end())
756 *(mapPlayers[p.id]) = p;
757 else
758 mapPlayers[p.id] = new Player(p);
759
760 break;
761 }
762 case MSG_TYPE_PLAYER_MOVE:
763 {
764 unsigned int id;
765 int x, y;
766
767 memcpy(&id, msg.buffer, 4);
768 memcpy(&x, msg.buffer+4, 4);
769 memcpy(&y, msg.buffer+8, 4);
770
771 mapPlayers[id]->target.x = x;
772 mapPlayers[id]->target.y = y;
773
774 break;
775 }
776 case MSG_TYPE_CHAT:
777 {
778 chatConsole.addLine(response);
779
780 break;
781 }
782 case MSG_TYPE_OBJECT:
783 {
784 cout << "Received OBJECT message" << endl;
785
786 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
787 o.deserialize(msg.buffer);
788 cout << "object id: " << o.id << endl;
789 gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);
790
791 break;
792 }
793 case MSG_TYPE_REMOVE_OBJECT:
794 {
795 cout << "Received REMOVE_OBJECT message!" << endl;
796
797 int id;
798 memcpy(&id, msg.buffer, 4);
799
800 cout << "Removing object with id " << id << endl;
801
802 if (!gameMap->removeObject(id))
803 cout << "Did not remove the object" << endl;
804
805 break;
806 }
807 case MSG_TYPE_ATTACK:
808 {
809 cout << "Received ATTACK message" << endl;
810
811 break;
812 }
813 case MSG_TYPE_START_ATTACK:
814 {
815 cout << "Received START_ATTACK message" << endl;
816
817 unsigned int id, targetID;
818 memcpy(&id, msg.buffer, 4);
819 memcpy(&targetID, msg.buffer+4, 4);
820
821 cout << "source id: " << id << endl;
822 cout << "target id: " << targetID << endl;
823
824 Player* source = mapPlayers[id];
825 source->targetPlayer = targetID;
826 source->isChasing = true;
827
828 break;
829 }
830 case MSG_TYPE_PROJECTILE:
831 {
832 cout << "Received a PROJECTILE message" << endl;
833
834 unsigned int id, x, y, targetId;
835
836 memcpy(&id, msg.buffer, 4);
837 memcpy(&x, msg.buffer+4, 4);
838 memcpy(&y, msg.buffer+8, 4);
839 memcpy(&targetId, msg.buffer+12, 4);
840
841 cout << "id: " << id << endl;
842 cout << "x: " << x << endl;
843 cout << "y: " << y << endl;
844 cout << "Target: " << targetId << endl;
845
846 Projectile proj(x, y, targetId, 0);
847 proj.setId(id);
848
849 mapProjectiles[id] = proj;
850
851 break;
852 }
853 case MSG_TYPE_REMOVE_PROJECTILE:
854 {
855 cout << "Received a REMOVE_PROJECTILE message" << endl;
856
857 int id;
858 memcpy(&id, msg.buffer, 4);
859
860 mapProjectiles.erase(id);
861
862 break;
863 }
864 case MSG_TYPE_GAME_INFO:
865 {
866 cout << "Received a GAME_INFO message" << endl;
867
868 string gameName(msg.buffer+4);
869 int numPlayers;
870
871 memcpy(&numPlayers, msg.buffer, 4);
872
873 cout << "Received game info for " << gameName << " (num players: " << numPlayers << ")" << endl;
874
875 if (numPlayers > 0)
876 mapGames[gameName] = numPlayers;
877 else
878 mapGames.erase(gameName);
879
880 break;
881 }
882 case MSG_TYPE_JOIN_GAME_SUCCESS:
883 {
884 cout << "Received a JOIN_GAME_SUCCESS message" << endl;
885
886 string gameName(msg.buffer);
887 game = new Game(gameName, "../../data/map.txt");
888 cout << "Game name: " << gameName << endl;
889
890 state = STATE_GAME;
891 wndCurrent = wndNewGame;
892
893 msgTo.type = MSG_TYPE_JOIN_GAME_ACK;
894 strcpy(msgTo.buffer, gameName.c_str());
895
896 msgProcessor.sendMessage(&msgTo, &server);
897
898 break;
899 }
900 case MSG_TYPE_JOIN_GAME_FAILURE:
901 {
902 cout << "Received a JOIN_GAME_FAILURE message" << endl;
903
904 break;
905 }
906 default:
907 {
908 cout << "(STATE_LOBBY) Received invlaid message of type " << msg.type << endl;
909
910 break;
911 }
912 }
913
914 break;
915 }
916 case STATE_GAME:
917 {
918 cout << "(STATE_GAME) ";
919 switch(msg.type)
920 {
921 case MSG_TYPE_GAME_INFO:
922 {
923 cout << "Received a GAME_INFO message" << endl;
924
925 string gameName(msg.buffer+4);
926 int numPlayers;
927
928 memcpy(&numPlayers, msg.buffer, 4);
929
930 cout << "Received game info for " << gameName << " (num players: " << numPlayers << ")" << endl;
931
932 if (numPlayers > 0)
933 mapGames[gameName] = numPlayers;
934 else
935 mapGames.erase(gameName);
936
937 break;
938 }
939 case MSG_TYPE_SCORE:
940 {
941 cout << "Received SCORE message!" << endl;
942
943 int blueScore;
944 memcpy(&blueScore, msg.buffer, 4);
945 cout << "blue score: " << blueScore << endl;
946 game->setBlueScore(blueScore);
947
948 int redScore;
949 memcpy(&redScore, msg.buffer+4, 4);
950 cout << "red score: " << redScore << endl;
951 game->setRedScore(redScore);
952
953 cout << "Processed SCORE message!" << endl;
954
955 break;
956 }
957 case MSG_TYPE_FINISH_GAME:
958 {
959 cout << "Got a finish game message" << endl;
960 cout << "Should switch to STATE_LOBBY and show the final score" << endl;
961
962 unsigned int winner, blueScore, redScore;
963 memcpy(&winner, msg.buffer, 4);
964 memcpy(&blueScore, msg.buffer+4, 4);
965 memcpy(&redScore, msg.buffer+8, 4);
966
967 string gameName(msg.buffer+12);
968
969 cout << "winner: " << winner << endl;
970 cout << "blueScore: " << blueScore << endl;
971 cout << "redScore: " << redScore << endl;
972 cout << "gameName: " << gameName << endl;
973
974 gameSummary = new GameSummary(gameName, winner, blueScore, redScore);
975
976 delete game;
977 game = NULL;
978 state = STATE_LOBBY;
979 wndCurrent = wndGameSummary;
980
981
982 cout << "winner from obj: " << gameSummary->getWinner() << endl;
983 cout << "blueScore from obj: " << gameSummary->getBlueScore() << endl;
984 cout << "redScore from obj: " << gameSummary->getRedScore() << endl;
985 cout << "gameName from obj: " << gameSummary->getName() << endl;
986 break;
987 }
988 case MSG_TYPE_PLAYER:
989 {
990 cout << "Received MSG_TYPE_PLAYER" << endl;
991
992 Player p("", "");
993 p.deserialize(msg.buffer);
994 p.timeLastUpdated = getCurrentMillis();
995 p.isChasing = false;
996 if (p.health <= 0)
997 p.isDead = true;
998 else
999 p.isDead = false;
1000
1001 if (mapPlayers.find(p.id) != mapPlayers.end())
1002 *(mapPlayers[p.id]) = p;
1003 else
1004 mapPlayers[p.id] = new Player(p);
1005
1006 break;
1007 }
1008 case MSG_TYPE_PLAYER_JOIN_GAME:
1009 {
1010 cout << "Received MSG_TYPE_PLAYER_JOIN_GAME" << endl;
1011
1012 Player p("", "");
1013 p.deserialize(msg.buffer);
1014 p.timeLastUpdated = getCurrentMillis();
1015 p.isChasing = false;
1016 if (p.health <= 0)
1017 p.isDead = true;
1018 else
1019 p.isDead = false;
1020
1021 if (mapPlayers.find(p.id) != mapPlayers.end())
1022 *(mapPlayers[p.id]) = p;
1023 else
1024 mapPlayers[p.id] = new Player(p);
1025
1026 game->addPlayer(mapPlayers[p.id]);
1027
1028 break;
1029 }
1030 case MSG_TYPE_LEAVE_GAME:
1031 {
1032 cout << "Received a LEAVE_GAME message" << endl;
1033
1034 string gameName(msg.buffer+4);
1035 unsigned int playerId;
1036
1037 memcpy(&playerId, msg.buffer, 4);
1038
1039 game->removePlayer(playerId);
1040
1041 break;
1042 }
1043 case MSG_TYPE_PLAYER_MOVE:
1044 {
1045 cout << "Received PLAYER_MOVE message" << endl;
1046
1047 unsigned int id;
1048 int x, y;
1049
1050 memcpy(&id, msg.buffer, 4);
1051 memcpy(&x, msg.buffer+4, 4);
1052 memcpy(&y, msg.buffer+8, 4);
1053
1054 cout << "id: " << id << endl;
1055
1056 mapPlayers[id]->target.x = x;
1057 mapPlayers[id]->target.y = y;
1058
1059 break;
1060 }
1061 case MSG_TYPE_OBJECT:
1062 {
1063 cout << "Received object message in STATE_GAME" << endl;
1064
1065 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
1066 o.deserialize(msg.buffer);
1067 cout << "object id: " << o.id << endl;
1068 game->getMap()->updateObject(o.id, o.type, o.pos.x, o.pos.y);
1069
1070 break;
1071 }
1072 case MSG_TYPE_REMOVE_OBJECT:
1073 {
1074 cout << "Received REMOVE_OBJECT message!" << endl;
1075
1076 int id;
1077 memcpy(&id, msg.buffer, 4);
1078
1079 cout << "Removing object with id " << id << endl;
1080
1081 if (!game->getMap()->removeObject(id))
1082 cout << "Did not remove the object" << endl;
1083
1084 break;
1085 }
1086 case MSG_TYPE_ATTACK:
1087 {
1088 cout << "Received ATTACK message" << endl;
1089
1090 break;
1091 }
1092 case MSG_TYPE_START_ATTACK:
1093 {
1094 cout << "Received START_ATTACK message" << endl;
1095
1096 unsigned int id, targetId;
1097 memcpy(&id, msg.buffer, 4);
1098 memcpy(&targetId, msg.buffer+4, 4);
1099
1100 cout << "source id: " << id << endl;
1101 cout << "target id: " << targetId << endl;
1102
1103 // need to check the target exists in the current game
1104 Player* source = game->getPlayers()[id];
1105 source->targetPlayer = targetId;
1106 source->isChasing = true;
1107
1108 break;
1109 }
1110 case MSG_TYPE_PROJECTILE:
1111 {
1112 cout << "Received a PROJECTILE message" << endl;
1113
1114 unsigned int projId, x, y, targetId;
1115
1116 memcpy(&projId, msg.buffer, 4);
1117 memcpy(&x, msg.buffer+4, 4);
1118 memcpy(&y, msg.buffer+8, 4);
1119 memcpy(&targetId, msg.buffer+12, 4);
1120
1121 cout << "projId: " << projId << endl;
1122 cout << "x: " << x << endl;
1123 cout << "y: " << y << endl;
1124 cout << "Target: " << targetId << endl;
1125
1126 Projectile proj(x, y, targetId, 0);
1127 proj.setId(projId);
1128
1129 game->addProjectile(proj);
1130
1131 break;
1132 }
1133 case MSG_TYPE_REMOVE_PROJECTILE:
1134 {
1135 cout << "Received a REMOVE_PROJECTILE message" << endl;
1136
1137 unsigned int id;
1138 memcpy(&id, msg.buffer, 4);
1139
1140 game->removeProjectile(id);
1141
1142 break;
1143 }
1144 default:
1145 {
1146 cout << "Received invalid message of type " << msg.type << endl;
1147
1148 break;
1149 }
1150 }
1151
1152 break;
1153 }
1154 default:
1155 {
1156 cout << "The state has an invalid value: " << state << endl;
1157
1158 break;
1159 }
1160 }
1161}
1162
1163int getRefreshRate(int width, int height)
1164{
1165 int numRefreshRates = al_get_num_display_modes();
1166 ALLEGRO_DISPLAY_MODE displayMode;
1167
1168 for(int i=0; i<numRefreshRates; i++) {
1169 al_get_display_mode(i, &displayMode);
1170
1171 if (displayMode.width == width && displayMode.height == height)
1172 return displayMode.refresh_rate;
1173 }
1174
1175 return 0;
1176}
1177
1178void drawMessageStatus(ALLEGRO_FONT* font)
1179{
1180 int clientMsgOffset = 5;
1181 int serverMsgOffset = 950;
1182
1183 al_draw_text(font, al_map_rgb(0, 255, 255), 0+clientMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "ID");
1184 al_draw_text(font, al_map_rgb(0, 255, 255), 20+clientMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "Type");
1185 al_draw_text(font, al_map_rgb(0, 255, 255), 240+clientMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "Acked?");
1186
1187 al_draw_text(font, al_map_rgb(0, 255, 255), serverMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "ID");
1188
1189 map<unsigned int, map<unsigned long, MessageContainer> >& sentMessages = msgProcessor.getSentMessages();
1190 int id, type;
1191 bool acked;
1192 ostringstream ossId, ossAcked;
1193
1194 map<unsigned int, map<unsigned long, MessageContainer> >::iterator it;
1195
1196 int msgCount = 0;
1197 for (it = sentMessages.begin(); it != sentMessages.end(); it++) {
1198 map<unsigned long, MessageContainer> playerMessage = it->second;
1199 map<unsigned long, MessageContainer>::iterator it2;
1200 for (it2 = playerMessage.begin(); it2 != playerMessage.end(); it2++) {
1201
1202 id = it->first;
1203 ossId.str("");;
1204 ossId << id;
1205
1206 type = it2->second.getMessage()->type;
1207 string typeStr = MessageContainer::getMsgTypeString(type);
1208
1209 acked = it2->second.getAcked();
1210 ossAcked.str("");;
1211 ossAcked << boolalpha << acked;
1212
1213 al_draw_text(font, al_map_rgb(0, 255, 0), clientMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossId.str().c_str());
1214 al_draw_text(font, al_map_rgb(0, 255, 0), 20+clientMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, typeStr.c_str());
1215 al_draw_text(font, al_map_rgb(0, 255, 0), 240+clientMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossAcked.str().c_str());
1216
1217 msgCount++;
1218 }
1219 }
1220
1221 if (msgProcessor.getAckedMessages().size() > 0) {
1222 map<unsigned int, unsigned long long> ackedMessages = msgProcessor.getAckedMessages()[0];
1223 map<unsigned int, unsigned long long>::iterator it3;
1224
1225 msgCount = 0;
1226 for (it3 = ackedMessages.begin(); it3 != ackedMessages.end(); it3++) {
1227 ossId.str("");;
1228 ossId << it3->first;
1229
1230 al_draw_text(font, al_map_rgb(255, 0, 0), 25+serverMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossId.str().c_str());
1231
1232 msgCount++;
1233 }
1234 }
1235}
1236
1237// Callback definitions
1238
1239void goToRegisterScreen()
1240{
1241 txtUsernameRegister->clear();
1242 txtPasswordRegister->clear();
1243 lblRegisterStatus->setText("");
1244 rblClasses->setSelectedButton(-1);
1245
1246 wndCurrent = wndRegister;
1247}
1248
1249void goToLoginScreen()
1250{
1251 txtUsername->clear();
1252 txtPassword->clear();
1253 lblLoginStatus->setText("");
1254
1255 wndCurrent = wndLogin;
1256}
1257
1258// maybe need a goToGameScreen function as well and add state changes to these functions as well
1259
1260void registerAccount()
1261{
1262 string username = txtUsernameRegister->getStr();
1263 string password = txtPasswordRegister->getStr();
1264
1265 txtUsernameRegister->clear();
1266 txtPasswordRegister->clear();
1267 // maybe clear rblClasses as well (add a method to RadioButtonList to enable this)
1268
1269 Player::PlayerClass playerClass;
1270
1271 switch (rblClasses->getSelectedButton()) {
1272 case 0:
1273 playerClass = Player::CLASS_WARRIOR;
1274 break;
1275 case 1:
1276 playerClass = Player::CLASS_RANGER;
1277 break;
1278 default:
1279 cout << "Invalid class selection" << endl;
1280 playerClass = Player::CLASS_NONE;
1281 break;
1282 }
1283
1284 msgTo.type = MSG_TYPE_REGISTER;
1285
1286 strcpy(msgTo.buffer, username.c_str());
1287 strcpy(msgTo.buffer+username.size()+1, password.c_str());
1288 memcpy(msgTo.buffer+username.size()+password.size()+2, &playerClass, 4);
1289
1290 msgProcessor.sendMessage(&msgTo, &server);
1291}
1292
1293void login()
1294{
1295 string strUsername = txtUsername->getStr();
1296 string strPassword = txtPassword->getStr();
1297 username = strUsername;
1298
1299 txtUsername->clear();
1300 txtPassword->clear();
1301
1302 msgTo.type = MSG_TYPE_LOGIN;
1303
1304 strcpy(msgTo.buffer, strUsername.c_str());
1305 strcpy(msgTo.buffer+username.size()+1, strPassword.c_str());
1306
1307 msgProcessor.sendMessage(&msgTo, &server);
1308
1309 state = STATE_LOBBY;
1310}
1311
1312void logout()
1313{
1314 switch(state) {
1315 case STATE_LOBBY:
1316 txtJoinGame->clear();
1317 txtCreateGame->clear();
1318 break;
1319 default:
1320 cout << "Logout called from invalid state: " << state << endl;
1321 break;
1322 }
1323
1324 msgTo.type = MSG_TYPE_LOGOUT;
1325
1326 strcpy(msgTo.buffer, username.c_str());
1327
1328 msgProcessor.sendMessage(&msgTo, &server);
1329}
1330
1331void quit()
1332{
1333 doexit = true;
1334}
1335
1336void sendChatMessage()
1337{
1338 string msg = txtChat->getStr();
1339 txtChat->clear();
1340
1341 msgTo.type = MSG_TYPE_CHAT;
1342 strcpy(msgTo.buffer, msg.c_str());
1343
1344 msgProcessor.sendMessage(&msgTo, &server);
1345}
1346
1347void toggleDebugging()
1348{
1349 debugging = !debugging;
1350}
1351
1352void joinGame()
1353{
1354 cout << "Joining game" << endl;
1355
1356 string msg = txtJoinGame->getStr();
1357 txtJoinGame->clear();
1358
1359 msgTo.type = MSG_TYPE_JOIN_GAME;
1360 strcpy(msgTo.buffer, msg.c_str());
1361
1362 msgProcessor.sendMessage(&msgTo, &server);
1363}
1364
1365void createGame()
1366{
1367 cout << "Creating game" << endl;
1368
1369 string msg = txtCreateGame->getStr();
1370 txtCreateGame->clear();
1371
1372 cout << "Sending message: " << msg.c_str() << endl;
1373
1374 msgTo.type = MSG_TYPE_CREATE_GAME;
1375 strcpy(msgTo.buffer, msg.c_str());
1376
1377 msgProcessor.sendMessage(&msgTo, &server);
1378}
1379
1380void leaveGame()
1381{
1382 cout << "Leaving game" << endl;
1383
1384 game = NULL;
1385
1386 state = STATE_LOBBY;
1387 wndCurrent = wndLobby;
1388
1389 msgTo.type = MSG_TYPE_LEAVE_GAME;
1390
1391 msgProcessor.sendMessage(&msgTo, &server);
1392}
1393
1394void closeGameSummary()
1395{
1396 delete gameSummary;
1397 gameSummary = NULL;
1398 wndCurrent = wndLobby;
1399 cout << "Processed button actions" << endl;
1400}
Note: See TracBrowser for help on using the repository browser.