Changeset e0fd377 in network-game for client/Client/main.cpp
- Timestamp:
- Dec 25, 2013, 3:23:09 PM (11 years ago)
- Branches:
- master
- Children:
- df74597
- Parents:
- f3fb980
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
rf3fb980 re0fd377 56 56 void shutdownWinSock(); 57 57 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers, 58 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId , int &scoreBlue, int &scoreRed);58 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId); 59 59 int getRefreshRate(int width, int height); 60 60 void drawMessageStatus(ALLEGRO_FONT* font); … … 81 81 STATE_START, 82 82 STATE_LOBBY, 83 STATE_GAME, 84 STATE_NEW_GAME 83 STATE_GAME 85 84 }; 86 85 … … 140 139 ofstream outputLog; 141 140 142 int scoreBlue, scoreRed;143 144 141 doexit = false; 145 142 debugging = false; … … 148 145 game = NULL; 149 146 gameSummary = NULL; 150 151 scoreBlue = 0;152 scoreRed = 0;153 147 154 148 state = STATE_START; … … 368 362 break; 369 363 case ALLEGRO_KEY_S: // pickup an item next to you 370 if (state == STATE_GAME || state == STATE_NEW_GAME) {364 if (state == STATE_GAME) { 371 365 msgTo.type = MSG_TYPE_PICKUP_FLAG; 372 366 memcpy(msgTo.buffer, &curPlayerId, 4); … … 375 369 break; 376 370 case ALLEGRO_KEY_D: // drop the current item 377 if (state == STATE_GAME || state == STATE_NEW_GAME) {371 if (state == STATE_GAME) { 378 372 Player* p = NULL; 379 373 try { … … 458 452 459 453 if (msgProcessor.receiveMessage(&msgFrom, &from) >= 0) 460 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId , scoreBlue, scoreRed);454 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId); 461 455 462 456 if (redraw) … … 557 551 ostringstream ossScoreBlue, ossScoreRed; 558 552 559 ossScoreBlue << "Blue: " << scoreBlue<< endl;560 ossScoreRed << "Red: " << scoreRed<< endl;553 ossScoreBlue << "Blue: " << game->getBlueScore() << endl; 554 ossScoreRed << "Red: " << game->getRedScore() << endl; 561 555 562 556 al_draw_text(font, al_map_rgb(0, 255, 0), 330, 80, ALLEGRO_ALIGN_LEFT, ossScoreBlue.str().c_str()); … … 711 705 712 706 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers, 713 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId , int &scoreBlue, int &scoreRed)707 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId) 714 708 { 715 709 // this is outdated since most messages now don't contain just a text string … … 739 733 } 740 734 case STATE_LOBBY: 735 { 741 736 cout << "In STATE_LOBBY" << endl; 742 case STATE_GAME:743 {744 737 switch(msg.type) 745 738 { … … 875 868 break; 876 869 } 877 case MSG_TYPE_SCORE:878 {879 memcpy(&scoreBlue, msg.buffer, 4);880 memcpy(&scoreRed, msg.buffer+4, 4);881 882 break;883 }884 870 case MSG_TYPE_ATTACK: 885 871 { … … 965 951 cout << "Game name: " << gameName << endl; 966 952 967 state = STATE_ NEW_GAME;953 state = STATE_GAME; 968 954 wndCurrent = wndNewGame; 969 955 … … 991 977 break; 992 978 } 993 case STATE_ NEW_GAME:979 case STATE_GAME: 994 980 { 995 cout << "(STATE_ NEW_GAME) ";981 cout << "(STATE_GAME) "; 996 982 switch(msg.type) 997 983 { … … 1125 1111 case MSG_TYPE_OBJECT: 1126 1112 { 1127 cout << "Received object message in STATE_ NEW_GAME" << endl;1113 cout << "Received object message in STATE_GAME" << endl; 1128 1114 1129 1115 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0); … … 1381 1367 txtCreateGame->clear(); 1382 1368 break; 1383 case STATE_GAME:1384 txtChat->clear();1385 chatConsole.clear();1386 break;1387 1369 default: 1388 1370 cout << "Logout called from invalid state: " << state << endl;
Note:
See TracChangeset
for help on using the changeset viewer.