Changeset ace001a in network-game
- Timestamp:
- Nov 10, 2014, 3:15:05 AM (10 years ago)
- Branches:
- master
- Children:
- a9a1295
- Parents:
- 347d768
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r347d768 race001a 17 17 #include <cstdio> 18 18 #include <cstdlib> 19 //#include <cmath>20 19 #include <sys/types.h> 21 20 #include <string> 22 21 #include <iostream> 22 #include <iomanip> 23 23 #include <sstream> 24 24 #include <fstream> … … 483 483 oss.str(""); 484 484 485 oss << "6/11/2014, 5:12 PM" << endl; 485 time_t time_finished = gameHistory[i][4]; 486 struct tm* now = localtime(&time_finished); 487 488 oss << (now->tm_mon + 1) << "/" << now->tm_mday << "/" << (now->tm_year + 1900) << " ";; 489 490 if (now->tm_hour == 0) 491 oss << "12"; 492 else if (now->tm_hour <= 12) 493 oss << now->tm_hour; 494 else 495 oss << now->tm_hour-12; 496 497 oss << ":" << setfill('0') << setw(2) << now->tm_min << setfill(' ') << " "; 498 499 if (now->tm_hour < 12) 500 oss << "AM"; 501 else 502 oss << "PM"; 503 504 oss << endl; 505 486 506 al_draw_text(font, al_map_rgb(0, 255, 0), 622, 190+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str()); 487 507 oss.clear(); … … 921 941 gameHistory = (int**)malloc(numGames*sizeof(int*)); 922 942 for (int i=0; i<numGames; i++) { 923 gameHistory[i] = (int*)malloc( 4*sizeof(int));943 gameHistory[i] = (int*)malloc(5*sizeof(int)); 924 944 cout << endl << "game record " << (i+1) << endl; 925 945 926 memcpy(&gameHistory[i][0], msg.buffer+16+i*16, 4); 927 memcpy(&gameHistory[i][1], msg.buffer+20+i*16, 4); 928 memcpy(&gameHistory[i][2], msg.buffer+24+i*16, 4); 929 memcpy(&gameHistory[i][3], msg.buffer+28+i*16, 4); 946 memcpy(&gameHistory[i][0], msg.buffer+16+i*20, 4); 947 memcpy(&gameHistory[i][1], msg.buffer+20+i*20, 4); 948 memcpy(&gameHistory[i][2], msg.buffer+24+i*20, 4); 949 memcpy(&gameHistory[i][3], msg.buffer+28+i*20, 4); 950 memcpy(&gameHistory[i][4], msg.buffer+32+i*20, 4); 930 951 931 952 cout << "result: " << gameHistory[i][0] << endl; … … 933 954 cout << "blue score: " << gameHistory[i][2] << endl; 934 955 cout << "red score: " << gameHistory[i][3] << endl; 956 957 time_t time_finished = gameHistory[i][4]; 958 struct tm* now = localtime(&time_finished); 959 960 cout << "time game finished: "; 961 cout << (now->tm_year + 1900) << '-' 962 << (now->tm_mon + 1) << '-' 963 << now->tm_mday << " " 964 << now->tm_hour << ":" 965 << now->tm_min 966 << endl; 935 967 } 936 968
Note:
See TracChangeset
for help on using the changeset viewer.