Changeset b28e2bf in network-game for client/Client/main.cpp
- Timestamp:
- Jul 5, 2014, 2:26:04 AM (10 years ago)
- Branches:
- master
- Children:
- cdb0e98
- Parents:
- fd9cdb5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
rfd9cdb5 rb28e2bf 142 142 Player* currentPlayer; 143 143 144 int honorPoints; 145 int numGames; 146 int** gameHistory; 147 144 148 MessageProcessor msgProcessor; 145 149 … … 160 164 game = NULL; 161 165 gameSummary = NULL; 166 167 honorPoints = 0; 168 numGames = 0; 169 gameHistory = NULL; 162 170 163 171 state = STATE_START; … … 436 444 else if (wndCurrent == wndProfile) 437 445 { 438 al_draw_text(font, al_map_rgb(0, 255, 0), 65, 90, ALLEGRO_ALIGN_LEFT, "Honor Points: 500"); 446 ostringstream oss; 447 oss << "Honor Points: " << honorPoints << endl; 448 al_draw_text(font, al_map_rgb(0, 255, 0), 65, 90, ALLEGRO_ALIGN_LEFT, oss.str().c_str()); 449 oss.clear(); 450 oss.str(""); 439 451 440 452 // display records of the last 10 games 441 for (int i=0; i<10; i++) { 442 al_draw_text(font, al_map_rgb(0, 255, 0), 142, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, "VICTORY"); 443 al_draw_text(font, al_map_rgb(0, 255, 0), 302, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, "3"); 444 al_draw_text(font, al_map_rgb(0, 255, 0), 462, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, "2"); 445 al_draw_text(font, al_map_rgb(0, 255, 0), 622, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, "6/11/2014, 5:12 PM"); 453 for (int i=0; i<numGames; i++) { 454 455 if (gameHistory[i][0] == 0) 456 oss << "DEFEAT" << endl; 457 else if (gameHistory[i][0] == 1) 458 oss << "VICTORY" << endl; 459 460 al_draw_text(font, al_map_rgb(0, 255, 0), 142, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str()); 461 oss.clear(); 462 oss.str(""); 463 464 oss << gameHistory[i][2] << endl; 465 al_draw_text(font, al_map_rgb(0, 255, 0), 302, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str()); 466 oss.clear(); 467 oss.str(""); 468 469 oss << gameHistory[i][3] << endl; 470 al_draw_text(font, al_map_rgb(0, 255, 0), 462, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str()); 471 oss.clear(); 472 oss.str(""); 473 474 oss << "6/11/2014, 5:12 PM" << endl; 475 al_draw_text(font, al_map_rgb(0, 255, 0), 622, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str()); 476 oss.clear(); 477 oss.str(""); 478 446 479 } 447 480 … … 588 621 } 589 622 623 if (gameHistory != NULL) { 624 for (int i=0; i<numGames; i++) { 625 free(gameHistory[i]); 626 } 627 628 free(gameHistory); 629 } 630 590 631 al_destroy_event_queue(event_queue); 591 632 al_destroy_display(display); … … 861 902 case MSG_TYPE_PROFILE: 862 903 { 904 memcpy(&honorPoints, msg.buffer, 4); 905 memcpy(&numGames, msg.buffer+4, 4); 906 907 cout << "Got records for " << numGames << " games." << endl; 908 gameHistory = (int**)malloc(numGames*sizeof(int*)); 909 for (int i=0; i<numGames; i++) { 910 gameHistory[i] = (int*)malloc(4*sizeof(int)); 911 cout << endl << "game record " << (i+1) << endl; 912 913 memcpy(&gameHistory[i][0], msg.buffer+8+i*16, 4); 914 memcpy(&gameHistory[i][1], msg.buffer+12+i*16, 4); 915 memcpy(&gameHistory[i][2], msg.buffer+16+i*16, 4); 916 memcpy(&gameHistory[i][3], msg.buffer+20+i*16, 4); 917 918 cout << "result: " << gameHistory[i][0] << endl; 919 cout << "team: " << gameHistory[i][1] << endl; 920 cout << "blue score: " << gameHistory[i][2] << endl; 921 cout << "red score: " << gameHistory[i][3] << endl; 922 } 923 863 924 wndCurrent = wndProfile; 864 925
Note:
See TracChangeset
for help on using the changeset viewer.