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

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

Fix a bug that prevents the player from moving anywhere

  • Property mode set to 100644
File size: 17.6 KB
RevLine 
[4c202e0]1#include "../../common/Compiler.h"
2
[e08572c]3#if defined WINDOWS
[0dde5da]4 #include <winsock2.h>
5 #include <WS2tcpip.h>
[e08572c]6#elif defined LINUX
[0dde5da]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>
[a845faf]13#endif
[1912323]14
[d352805]15#include <sys/types.h>
[88cdae2]16#include <cstdio>
17#include <cstdlib>
[a845faf]18#include <string>
[1912323]19#include <iostream>
[88cdae2]20#include <sstream>
[1912323]21
[eb8adb1]22#include <map>
[1912323]23
[3a79253]24#include <map>
25
[d352805]26#include <allegro5/allegro.h>
27#include <allegro5/allegro_font.h>
28#include <allegro5/allegro_ttf.h>
[88cdae2]29#include <allegro5/allegro_primitives.h>
[7d7df47]30
[b53c6b3]31#include "../../common/Message.h"
[e607c0f]32#include "../../common/Common.h"
[62ee2ce]33#include "../../common/WorldMap.h"
[4c202e0]34#include "../../common/Player.h"
[7d7df47]35
[87b3ee2]36#include "Window.h"
37#include "Textbox.h"
38#include "Button.h"
[6475138]39#include "chat.h"
40
[a845faf]41#ifdef WINDOWS
[6475138]42 #pragma comment(lib, "ws2_32.lib")
[a845faf]43#endif
[1912323]44
45using namespace std;
46
[0dde5da]47void initWinSock();
48void shutdownWinSock();
[45b2750]49void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId);
[62ee2ce]50void drawMap(WorldMap* gameMap);
[88cdae2]51void drawPlayers(map<unsigned int, Player>& mapPlayers, unsigned int curPlayerId);
[62ee2ce]52POSITION screenToMap(POSITION pos);
53POSITION mapToScreen(POSITION pos);
[87b3ee2]54
55// callbacks
56void registerAccount();
57void login();
58void logout();
59void quit();
60void sendChatMessage();
[4da5aa3]61
[1912323]62void error(const char *);
[7d7df47]63
[d352805]64const float FPS = 60;
65const int SCREEN_W = 640;
66const int SCREEN_H = 480;
[0cc431d]67
68enum STATE {
69 STATE_START,
[87b3ee2]70 STATE_LOGIN // this means you're already logged in
[d352805]71};
[87b3ee2]72
73int state;
74
75bool doexit;
76
77Window* wndLogin;
78Window* wndMain;
79Window* wndCurrent;
80
81Textbox* txtUsername;
82Textbox* txtPassword;
83Textbox* txtChat;
84
85int sock;
86struct sockaddr_in server, from;
87struct hostent *hp;
88NETWORK_MSG msgTo, msgFrom;
89string username;
90chat chatConsole;
[d352805]91
92int main(int argc, char **argv)
93{
94 ALLEGRO_DISPLAY *display = NULL;
95 ALLEGRO_EVENT_QUEUE *event_queue = NULL;
96 ALLEGRO_TIMER *timer = NULL;
97 bool key[4] = { false, false, false, false };
98 bool redraw = true;
[87b3ee2]99 doexit = false;
[eb8adb1]100 map<unsigned int, Player> mapPlayers;
[88cdae2]101 unsigned int curPlayerId = -1;
[9a3e6b1]102
[87b3ee2]103 state = STATE_START;
[9a3e6b1]104
[d352805]105 if(!al_init()) {
106 fprintf(stderr, "failed to initialize allegro!\n");
107 return -1;
108 }
109
[88cdae2]110 if (al_init_primitives_addon())
111 cout << "Primitives initialized" << endl;
112 else
113 cout << "Primitives not initialized" << endl;
114
[d352805]115 al_init_font_addon();
116 al_init_ttf_addon();
117
[88cdae2]118 #if defined WINDOWS
119 ALLEGRO_FONT *font = al_load_ttf_font("../pirulen.ttf", 12, 0);
120 #elif defined LINUX
121 ALLEGRO_FONT *font = al_load_ttf_font("pirulen.ttf", 12, 0);
122 #endif
123
[d352805]124 if (!font) {
125 fprintf(stderr, "Could not load 'pirulen.ttf'.\n");
126 getchar();
127 return -1;
128 }
129
130 if(!al_install_keyboard()) {
131 fprintf(stderr, "failed to initialize the keyboard!\n");
132 return -1;
133 }
[87b3ee2]134
135 if(!al_install_mouse()) {
136 fprintf(stderr, "failed to initialize the mouse!\n");
137 return -1;
138 }
[d352805]139
140 timer = al_create_timer(1.0 / FPS);
141 if(!timer) {
142 fprintf(stderr, "failed to create timer!\n");
143 return -1;
144 }
145
146 display = al_create_display(SCREEN_W, SCREEN_H);
147 if(!display) {
148 fprintf(stderr, "failed to create display!\n");
149 al_destroy_timer(timer);
150 return -1;
151 }
[87b3ee2]152
[384b7e0]153 WorldMap* gameMap = WorldMap::loadMapFromFile("../../data/map.txt");
[62ee2ce]154
[87b3ee2]155 wndLogin = new Window(0, 0, SCREEN_W, SCREEN_H);
156 wndLogin->addComponent(new Textbox(104, 40, 100, 20, font));
157 wndLogin->addComponent(new Textbox(104, 70, 100, 20, font));
158 wndLogin->addComponent(new Button(22, 100, 90, 20, font, "Register", registerAccount));
159 wndLogin->addComponent(new Button(122, 100, 60, 20, font, "Login", login));
160 wndLogin->addComponent(new Button(540, 10, 80, 20, font, "Quit", quit));
161
162 txtUsername = (Textbox*)wndLogin->getComponent(0);
163 txtPassword = (Textbox*)wndLogin->getComponent(1);
164
165 wndMain = new Window(0, 0, SCREEN_W, SCREEN_H);
166 wndMain->addComponent(new Textbox(95, 40, 525, 20, font));
167 wndMain->addComponent(new Button(95, 70, 160, 20, font, "Send Message", sendChatMessage));
168 wndMain->addComponent(new Button(540, 10, 80, 20, font, "Logout", logout));
169
170 txtChat = (Textbox*)wndMain->getComponent(0);
171
172 wndCurrent = wndLogin;
[d352805]173
174 event_queue = al_create_event_queue();
175 if(!event_queue) {
176 fprintf(stderr, "failed to create event_queue!\n");
177 al_destroy_display(display);
178 al_destroy_timer(timer);
179 return -1;
180 }
181
182 al_set_target_bitmap(al_get_backbuffer(display));
183
184 al_register_event_source(event_queue, al_get_display_event_source(display));
185 al_register_event_source(event_queue, al_get_timer_event_source(timer));
186 al_register_event_source(event_queue, al_get_keyboard_event_source());
[87b3ee2]187 al_register_event_source(event_queue, al_get_mouse_event_source());
[d352805]188
189 al_clear_to_color(al_map_rgb(0,0,0));
190
191 al_flip_display();
[9a3e6b1]192
193 if (argc != 3) {
194 cout << "Usage: server port" << endl;
195 exit(1);
196 }
197
198 initWinSock();
199
200 sock = socket(AF_INET, SOCK_DGRAM, 0);
201 if (sock < 0)
202 error("socket");
203
[e607c0f]204 set_nonblock(sock);
205
[9a3e6b1]206 server.sin_family = AF_INET;
207 hp = gethostbyname(argv[1]);
208 if (hp==0)
209 error("Unknown host");
210
211 memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
212 server.sin_port = htons(atoi(argv[2]));
213
[d352805]214 al_start_timer(timer);
[e607c0f]215
[d352805]216 while(!doexit)
217 {
218 ALLEGRO_EVENT ev;
[3d81c0d]219
[d352805]220 al_wait_for_event(event_queue, &ev);
[87b3ee2]221
222 if(wndCurrent->handleEvent(ev)) {
223 // do nothing
224 }
225 else if(ev.type == ALLEGRO_EVENT_TIMER) {
[a1a3bd5]226 redraw = true; // seems like we should just call a draw function here instead
[d352805]227 }
228 else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
[9a3e6b1]229 doexit = true;
[a1a3bd5]230
231 // perform a check to see if it's time to send an update to the server
232 // need to store num ticks since the lst update for this
233 // also check how often each update actually happens and how much it deviates from 60 times per second
[d352805]234 }
235 else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) {
236 }
237 else if(ev.type == ALLEGRO_EVENT_KEY_UP) {
238 switch(ev.keyboard.keycode) {
239 case ALLEGRO_KEY_ESCAPE:
240 doexit = true;
241 break;
242 }
243 }
[88cdae2]244 else if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP) {
[ad5d122]245 if(wndCurrent == wndMain) {
246 msgTo.type = MSG_TYPE_PLAYER_MOVE;
[88cdae2]247
[62ee2ce]248 POSITION pos;
249 pos.x = ev.mouse.x;
250 pos.y = ev.mouse.y;
251 pos = screenToMap(pos);
252
253 if (pos.x != -1)
254 {
255 memcpy(msgTo.buffer, &curPlayerId, 4);
256 memcpy(msgTo.buffer+4, &pos.x, 4);
257 memcpy(msgTo.buffer+8, &pos.y, 4);
[88cdae2]258
[62ee2ce]259 sendMessage(&msgTo, sock, &server);
260 }
261 else
262 cout << "Invalid point: User did not click on the map" << endl;
[ad5d122]263 }
[88cdae2]264 }
[e607c0f]265
266 if (receiveMessage(&msgFrom, sock, &from) >= 0)
[45b2750]267 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, curPlayerId);
[054b50b]268
[a1a3bd5]269 if (redraw)
[e607c0f]270 {
[d352805]271 redraw = false;
[88cdae2]272
[87b3ee2]273 wndCurrent->draw(display);
[9a3e6b1]274
[6475138]275 chatConsole.draw(font, al_map_rgb(255,255,255));
[9a3e6b1]276
[87b3ee2]277 if(wndCurrent == wndLogin) {
278 al_draw_text(font, al_map_rgb(0, 255, 0), 4, 43, ALLEGRO_ALIGN_LEFT, "Username:");
279 al_draw_text(font, al_map_rgb(0, 255, 0), 1, 73, ALLEGRO_ALIGN_LEFT, "Password:");
280 }
281 else if(wndCurrent == wndMain) {
282 al_draw_text(font, al_map_rgb(0, 255, 0), 4, 43, ALLEGRO_ALIGN_LEFT, "Message:");
[62ee2ce]283
[a1a3bd5]284 // update player positions
285 map<unsigned int, Player>::iterator it;
286 for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
287 {
[227baaa]288 it->second.move(gameMap); // ignore return value
[a1a3bd5]289 }
290
[62ee2ce]291 drawMap(gameMap);
292 drawPlayers(mapPlayers, curPlayerId);
[87b3ee2]293 }
294
[d352805]295 al_flip_display();
296 }
297 }
[9a3e6b1]298
299 #if defined WINDOWS
300 closesocket(sock);
301 #elif defined LINUX
302 close(sock);
303 #endif
304
305 shutdownWinSock();
[d352805]306
[87b3ee2]307 delete wndLogin;
308 delete wndMain;
309
[62ee2ce]310 delete gameMap;
311
[d352805]312 al_destroy_event_queue(event_queue);
313 al_destroy_display(display);
314 al_destroy_timer(timer);
315
316 return 0;
317}
318
[4da5aa3]319// need to make a function like this that works on windows
320void error(const char *msg)
321{
322 perror(msg);
323 shutdownWinSock();
324 exit(1);
325}
326
[0dde5da]327void initWinSock()
328{
329#if defined WINDOWS
330 WORD wVersionRequested;
331 WSADATA wsaData;
332 int wsaerr;
333
334 wVersionRequested = MAKEWORD(2, 2);
335 wsaerr = WSAStartup(wVersionRequested, &wsaData);
336
337 if (wsaerr != 0) {
338 cout << "The Winsock dll not found." << endl;
339 exit(1);
340 }else
341 cout << "The Winsock dll was found." << endl;
342#endif
343}
344
345void shutdownWinSock()
346{
347#if defined WINDOWS
348 WSACleanup();
349#endif
[1912323]350}
351
[62ee2ce]352POSITION screenToMap(POSITION pos)
353{
354 pos.x = pos.x-300;
355 pos.y = pos.y-100;
356
357 if (pos.x < 0 || pos.y < 0)
358 {
359 pos.x = -1;
360 pos.y = -1;
361 }
362
363 return pos;
364}
365
366POSITION mapToScreen(POSITION pos)
367{
368 pos.x = pos.x+300;
369 pos.y = pos.y+100;
370
371 return pos;
372}
373
[ca44f82]374POSITION mapToScreen(FLOAT_POSITION pos)
375{
376 POSITION p;
377 p.x = pos.x+300;
378 p.y = pos.y+100;
379
380 return p;
381}
382
[45b2750]383void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId)
[1912323]384{
[4da5aa3]385 string response = string(msg.buffer);
386
[a1a3bd5]387 cout << "Processing message" << endl;
388
[4da5aa3]389 switch(state)
390 {
391 case STATE_START:
392 {
[e607c0f]393 cout << "In STATE_START" << endl;
394
[87b3ee2]395 switch(msg.type)
[4da5aa3]396 {
[87b3ee2]397 case MSG_TYPE_REGISTER:
398 {
399 break;
400 }
401 case MSG_TYPE_LOGIN:
402 {
403 if (response.compare("Player has already logged in.") == 0)
404 {
405 username.clear();
406 cout << "User login failed" << endl;
407 }
408 else if (response.compare("Incorrect username or password") == 0)
409 {
410 username.clear();
411 cout << "User login failed" << endl;
412 }
413 else
414 {
415 state = STATE_LOGIN;
416 wndCurrent = wndMain;
[88cdae2]417
418 Player p("", "");
419 p.deserialize(msg.buffer);
420 mapPlayers[p.id] = p;
421 curPlayerId = p.id;
422
423 cout << "Got a valid login response with the player" << endl;
424 cout << "Player id: " << curPlayerId << endl;
[a1a3bd5]425 cout << "map size: " << mapPlayers.size() << endl;
[87b3ee2]426 }
[88cdae2]427
[a1a3bd5]428 break;
429 }
430 case MSG_TYPE_PLAYER: // kind of hacky to put this here
431 {
432 cout << "Got MSG_TYPE_PLAYER message in Start" << endl;
433
434 Player p("", "");
435 p.deserialize(msg.buffer);
436 p.timeLastUpdated = getCurrentMillis();
437 mapPlayers[p.id] = p;
438
439 cout << "new player id: " << p.id << endl;
440 cout << "map size: " << mapPlayers.size() << endl;
441
[45b2750]442 break;
443 }
444 case MSG_TYPE_OBJECT:
445 {
446 cout << "Received object message. Baller Biller!" << endl;
447
448 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
449 o.deserialize(msg.buffer);
450 gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);
451
[87b3ee2]452 break;
453 }
[4da5aa3]454 }
455
456 break;
457 }
458 case STATE_LOGIN:
459 {
[eb8adb1]460 switch(msg.type)
[4da5aa3]461 {
[87b3ee2]462 case MSG_TYPE_REGISTER:
463 {
464 break;
465 }
466 case MSG_TYPE_LOGIN:
467 {
[a1a3bd5]468 cout << "Got a login message" << endl;
469
[eb8adb1]470 chatConsole.addLine(response);
[a1a3bd5]471 cout << "Added new line" << endl;
[eb8adb1]472
[a1a3bd5]473 break;
474 }
475 case MSG_TYPE_LOGOUT:
476 {
[054b50b]477 cout << "Got a logout message" << endl;
[a1a3bd5]478
[87b3ee2]479 if (response.compare("You have successfully logged out.") == 0)
480 {
481 cout << "Logged out" << endl;
482 state = STATE_START;
483 wndCurrent = wndLogin;
484 }
[054b50b]485
486 break;
487 }
[4c202e0]488 case MSG_TYPE_PLAYER:
489 {
[a1a3bd5]490 cout << "Got MSG_TYPE_PLAYER message in Login" << endl;
491
[60776f2]492 Player p("", "");
493 p.deserialize(msg.buffer);
[054b50b]494 p.timeLastUpdated = getCurrentMillis();
[3a79253]495 mapPlayers[p.id] = p;
[4c202e0]496
[eb8adb1]497 break;
498 }
[a1a3bd5]499 case MSG_TYPE_PLAYER_MOVE:
500 {
501 cout << "Got a player move message" << endl;
502
503 unsigned int id;
504 int x, y;
505
506 memcpy(&id, msg.buffer, 4);
507 memcpy(&x, msg.buffer+4, 4);
508 memcpy(&y, msg.buffer+8, 4);
509
510 mapPlayers[id].target.x = x;
511 mapPlayers[id].target.y = y;
512
513 break;
514 }
[eb8adb1]515 case MSG_TYPE_CHAT:
516 {
517 chatConsole.addLine(response);
[4c202e0]518
[87b3ee2]519 break;
520 }
[45b2750]521 case MSG_TYPE_OBJECT:
522 {
523 cout << "Received object message. Baller Biller!" << endl;
524
525 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
526 o.deserialize(msg.buffer);
527 gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);
528
529 break;
530 }
531 default:
532 {
533 cout << "Received an unexpected message type: " << msg.type << endl;
534 }
[4da5aa3]535 }
[eb8adb1]536
[4da5aa3]537 break;
538 }
539 default:
540 {
541 cout << "The state has an invalid value: " << state << endl;
542
543 break;
544 }
545 }
[0dde5da]546}
[87b3ee2]547
[d436ac4]548// this should probably be in the WorldMap class
[62ee2ce]549void drawMap(WorldMap* gameMap)
550{
551 POSITION mapPos;
552 mapPos.x = 0;
553 mapPos.y = 0;
554 mapPos = mapToScreen(mapPos);
[6e66ffd]555
[62ee2ce]556 for (int x=0; x<12; x++)
557 {
558 for (int y=0; y<12; y++)
559 {
560 WorldMap::TerrainType el = gameMap->getElement(x, y);
[cc1c6c1]561 WorldMap::StructureType structure = gameMap->getStructure(x, y);
[62ee2ce]562
563 if (el == WorldMap::TERRAIN_GRASS)
564 al_draw_filled_rectangle(x*25+mapPos.x, y*25+mapPos.y, x*25+25+mapPos.x, y*25+25+mapPos.y, al_map_rgb(0, 255, 0));
565 else if (el == WorldMap::TERRAIN_OCEAN)
566 al_draw_filled_rectangle(x*25+mapPos.x, y*25+mapPos.y, x*25+25+mapPos.x, y*25+25+mapPos.y, al_map_rgb(0, 0, 255));
567 else if (el == WorldMap::TERRAIN_ROCK)
568 al_draw_filled_rectangle(x*25+mapPos.x, y*25+mapPos.y, x*25+25+mapPos.x, y*25+25+mapPos.y, al_map_rgb(100, 100, 0));
[a1a3bd5]569
[6e66ffd]570 if (structure == WorldMap::STRUCTURE_BLUE_FLAG) {
571 al_draw_circle(x*25+12+mapPos.x, y*25+12+mapPos.y, 12, al_map_rgb(0, 0, 0), 3);
572 //al_draw_filled_rectangle(x*25+5+mapPos.x, y*25+5+mapPos.y, x*25+20+mapPos.x, y*25+20+mapPos.y, al_map_rgb(0, 0, 255));
573 }else if (structure == WorldMap::STRUCTURE_RED_FLAG) {
574 al_draw_circle(x*25+12+mapPos.x, y*25+12+mapPos.y, 12, al_map_rgb(0, 0, 0), 3);
575 //al_draw_filled_rectangle(x*25+5+mapPos.x, y*25+5+mapPos.y, x*25+20+mapPos.x, y*25+20+mapPos.y, al_map_rgb(255, 0, 0));
576 }
577 }
578 }
579
580 for (int x=0; x<12; x++)
581 {
582 for (int y=0; y<12; y++)
583 {
584 vector<WorldMap::Object> vctObjects = gameMap->getObjects(x, y);
585
586 vector<WorldMap::Object>::iterator it;
587 for(it = vctObjects.begin(); it != vctObjects.end(); it++) {
588 switch(it->type) {
589 case WorldMap::OBJECT_BLUE_FLAG:
590 al_draw_filled_rectangle(it->pos.x-8+mapPos.x, it->pos.y-8+mapPos.y, it->pos.x+8+mapPos.x, it->pos.y+8+mapPos.y, al_map_rgb(0, 0, 255));
591 break;
592 case WorldMap::OBJECT_RED_FLAG:
593 al_draw_filled_rectangle(it->pos.x-8+mapPos.x, it->pos.y-8+mapPos.y, it->pos.x+8+mapPos.x, it->pos.y+8+mapPos.y, al_map_rgb(255, 0, 0));
594 break;
595 }
596 }
[62ee2ce]597 }
598 }
599}
600
[88cdae2]601void drawPlayers(map<unsigned int, Player>& mapPlayers, unsigned int curPlayerId)
602{
603 map<unsigned int, Player>::iterator it;
604
[62ee2ce]605 Player* p;
606 POSITION pos;
607
[88cdae2]608 for(it = mapPlayers.begin(); it != mapPlayers.end(); it++)
609 {
[62ee2ce]610 p = &it->second;
611 pos = mapToScreen(p->pos);
[88cdae2]612
[7efed11]613 if (p->id == curPlayerId)
614 al_draw_filled_circle(pos.x, pos.y, 12, al_map_rgb(255, 0, 0));
615 else
616 al_draw_filled_circle(pos.x, pos.y, 12, al_map_rgb(191, 0, 0));
617
[7d91bbe]618 if (p->hasBlueFlag)
[7efed11]619 al_draw_filled_rectangle(pos.x+4, pos.y-18, pos.x+18, pos.y-4, al_map_rgb(0, 0, 255));
[7d91bbe]620 else if(p->hasRedFlag)
[7efed11]621 al_draw_filled_rectangle(pos.x+4, pos.y-18, pos.x+18, pos.y-4, al_map_rgb(255, 0, 0));
[88cdae2]622 }
623}
624
[87b3ee2]625void registerAccount()
626{
627 string username = txtUsername->getStr();
628 string password = txtPassword->getStr();
629
630 txtUsername->clear();
631 txtPassword->clear();
632
633 msgTo.type = MSG_TYPE_REGISTER;
634
635 strcpy(msgTo.buffer, username.c_str());
636 strcpy(msgTo.buffer+username.size()+1, password.c_str());
637
638 sendMessage(&msgTo, sock, &server);
639}
640
641void login()
642{
643 string strUsername = txtUsername->getStr();
644 string strPassword = txtPassword->getStr();
645 username = strUsername;
646
647 txtUsername->clear();
648 txtPassword->clear();
649
650 msgTo.type = MSG_TYPE_LOGIN;
651
652 strcpy(msgTo.buffer, strUsername.c_str());
653 strcpy(msgTo.buffer+username.size()+1, strPassword.c_str());
654
655 sendMessage(&msgTo, sock, &server);
656}
657
658void logout()
659{
660 txtChat->clear();
661
662 msgTo.type = MSG_TYPE_LOGOUT;
663
664 strcpy(msgTo.buffer, username.c_str());
665
666 sendMessage(&msgTo, sock, &server);
667}
668
669void quit()
670{
671 doexit = true;
672}
673
674void sendChatMessage()
675{
676 string msg = txtChat->getStr();
677
678 txtChat->clear();
679
680 msgTo.type = MSG_TYPE_CHAT;
681
682 strcpy(msgTo.buffer, msg.c_str());
683
684 sendMessage(&msgTo, sock, &server);
685}
Note: See TracBrowser for help on using the repository browser.