- Timestamp:
- Dec 31, 2012, 1:22:06 AM (12 years ago)
- Branches:
- master
- Children:
- 8a3ef42
- Parents:
- 8f438a5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r8f438a5 reb8adb1 19 19 #include <iostream> 20 20 21 #include <map> 22 21 23 #include <allegro5/allegro.h> 22 24 #include <allegro5/allegro_font.h> … … 40 42 void initWinSock(); 41 43 void shutdownWinSock(); 42 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole );44 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player>& mapPlayers); 43 45 44 46 // callbacks … … 95 97 bool redraw = true; 96 98 doexit = false; 99 map<unsigned int, Player> mapPlayers; 97 100 98 101 float bouncer_x = SCREEN_W / 2.0 - BOUNCER_SIZE / 2.0; … … 290 293 if (receiveMessage(&msgFrom, sock, &from) >= 0) 291 294 { 292 processMessage(msgFrom, state, chatConsole );295 processMessage(msgFrom, state, chatConsole, mapPlayers); 293 296 cout << "state: " << state << endl; 294 297 } … … 368 371 } 369 372 370 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole )373 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player>& mapPlayers) 371 374 { 372 375 string response = string(msg.buffer); … … 414 417 case STATE_LOGIN: 415 418 { 416 chatConsole.addLine(response); 417 418 switch(msg.type) 419 switch(msg.type) 419 420 { 420 421 case MSG_TYPE_REGISTER: … … 424 425 case MSG_TYPE_LOGIN: 425 426 { 427 chatConsole.addLine(response); 428 426 429 if (response.compare("You have successfully logged out.") == 0) 427 430 { … … 442 445 p.deserialize(msg.buffer); 443 446 447 cout << "p.id: " << p.id << endl; 444 448 cout << "p.name: " << p.name << endl; 445 449 cout << "p.pos.x: " << p.pos.x << endl; 446 450 cout << "p.pos.y: " << p.pos.y << endl; 447 451 452 mapPlayers[p.id] = p; 453 448 454 break; 449 455 } 450 } 451 456 case MSG_TYPE_CHAT: 457 { 458 chatConsole.addLine(response); 459 460 break; 461 } 462 } 463 452 464 break; 453 465 }
Note:
See TracChangeset
for help on using the changeset viewer.