Changeset 635ad9b in network-game for client/Client/main.cpp


Ignore:
Timestamp:
Dec 23, 2013, 11:33:36 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
e1af80c
Parents:
778d0c9
Message:

Correction to GameSummary constructor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r778d0c9 r635ad9b  
    5656void shutdownWinSock();
    5757void 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);
    6059int getRefreshRate(int width, int height);
    6160void drawMessageStatus(ALLEGRO_FONT* font);
     
    458457
    459458      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);
    461460
    462461      if (redraw)
     
    606605            }
    607606         }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;
    610620
    611621            string strWinner;
    612622
    613623            if (gameSummary->getWinner() == 0)
    614                 strWinner = "Blue Team Wins";
     624               strWinner = "Blue Team Wins";
    615625            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;
    617631
    618632            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());
    621635            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;
    622638         }
    623639
     
    705721
    706722void 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)
    709724{
    710725   // this is outdated since most messages now don't contain just a text string
     
    10321047               cout << "Should switch to STATE_LOBBY and show the final score" << endl;
    10331048
    1034                string gameName(msg.buffer);
    1035 
    10361049               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;
    10401060
    10411061               gameSummary = new GameSummary(gameName, winner, blueScore, redScore);
     
    10461066               wndCurrent = wndGameSummary;
    10471067
     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;
    10481073               break;
    10491074            }
     
    14481473{
    14491474    delete gameSummary;
     1475    gameSummary = NULL;
    14501476    wndCurrent = wndLobby;
    1451 }
     1477    cout << "Processed button actions" << endl;
     1478}
Note: See TracChangeset for help on using the changeset viewer.