Changeset 635ad9b in network-game for client/Client/main.cpp
- Timestamp:
- Dec 23, 2013, 11:33:36 PM (11 years ago)
- Branches:
- master
- Children:
- e1af80c
- Parents:
- 778d0c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r778d0c9 r635ad9b 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, 59 GameSummary* gameSummary); 58 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed); 60 59 int getRefreshRate(int width, int height); 61 60 void drawMessageStatus(ALLEGRO_FONT* font); … … 458 457 459 458 if (msgProcessor.receiveMessage(&msgFrom, sock, &from, &outputLog) >= 0) 460 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId, scoreBlue, scoreRed , gameSummary);459 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId, scoreBlue, scoreRed); 461 460 462 461 if (redraw) … … 606 605 } 607 606 }else if (wndCurrent == wndGameSummary) { 608 string strBlueScore = "Blue Score: "+gameSummary->getBlueScore(); 609 string strRedScore = "Red Score: "+gameSummary->getRedScore(); 607 cout << "Drawing game summary" << endl; 608 609 cout << "blue score from obj: " << gameSummary->getBlueScore() << endl; 610 cout << "red score from obj: " << gameSummary->getRedScore() << endl; 611 612 ostringstream ossBlueScore, ossRedScore; 613 614 cout << "Declared scores" << endl; 615 616 ossBlueScore << "Blue Score: " << gameSummary->getBlueScore(); 617 ossRedScore << "Red Score: " << gameSummary->getRedScore(); 618 619 cout << "set scores" << endl; 610 620 611 621 string strWinner; 612 622 613 623 if (gameSummary->getWinner() == 0) 614 624 strWinner = "Blue Team Wins"; 615 625 else if (gameSummary->getWinner() == 1) 616 strWinner = "Red Team Wins"; 626 strWinner = "Red Team Wins"; 627 else 628 strWinner = "winner set to wrong value"; 629 630 cout << "Calling the drawing routines" << endl; 617 631 618 632 al_draw_text(font, al_map_rgb(0, 255, 0), 512, 40, ALLEGRO_ALIGN_CENTRE, gameSummary->getName().c_str()); 619 al_draw_text(font, al_map_rgb(0, 255, 0), 330, 80, ALLEGRO_ALIGN_LEFT, strBlueScore.c_str());620 al_draw_text(font, al_map_rgb(0, 255, 0), 515, 80, ALLEGRO_ALIGN_LEFT, strRedScore.c_str());633 al_draw_text(font, al_map_rgb(0, 255, 0), 330, 80, ALLEGRO_ALIGN_LEFT, ossBlueScore.str().c_str()); 634 al_draw_text(font, al_map_rgb(0, 255, 0), 515, 80, ALLEGRO_ALIGN_LEFT, ossRedScore.str().c_str()); 621 635 al_draw_text(font, al_map_rgb(0, 255, 0), 512, 120, ALLEGRO_ALIGN_CENTRE, strWinner.c_str()); 636 637 cout << "Done drawing game summary" << endl; 622 638 } 623 639 … … 705 721 706 722 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers, 707 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed, 708 GameSummary* gameSummary) 723 map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed) 709 724 { 710 725 // this is outdated since most messages now don't contain just a text string … … 1032 1047 cout << "Should switch to STATE_LOBBY and show the final score" << endl; 1033 1048 1034 string gameName(msg.buffer);1035 1036 1049 unsigned int winner, blueScore, redScore; 1037 memcpy(&winner, msg.buffer+4, 4); 1038 memcpy(&blueScore, msg.buffer+8, 4); 1039 memcpy(&redScore, msg.buffer+12, 4); 1050 memcpy(&winner, msg.buffer, 4); 1051 memcpy(&blueScore, msg.buffer+4, 4); 1052 memcpy(&redScore, msg.buffer+8, 4); 1053 1054 string gameName(msg.buffer+12); 1055 1056 cout << "winner: " << winner << endl; 1057 cout << "blueScore: " << blueScore << endl; 1058 cout << "redScore: " << redScore << endl; 1059 cout << "gameName: " << gameName << endl; 1040 1060 1041 1061 gameSummary = new GameSummary(gameName, winner, blueScore, redScore); … … 1046 1066 wndCurrent = wndGameSummary; 1047 1067 1068 1069 cout << "winner from obj: " << gameSummary->getWinner() << endl; 1070 cout << "blueScore from obj: " << gameSummary->getBlueScore() << endl; 1071 cout << "redScore from obj: " << gameSummary->getRedScore() << endl; 1072 cout << "gameName from obj: " << gameSummary->getName() << endl; 1048 1073 break; 1049 1074 } … … 1448 1473 { 1449 1474 delete gameSummary; 1475 gameSummary = NULL; 1450 1476 wndCurrent = wndLobby; 1451 } 1477 cout << "Processed button actions" << endl; 1478 }
Note:
See TracChangeset
for help on using the changeset viewer.