Changeset a9a1295 in network-game for server/DataAccess.cpp


Ignore:
Timestamp:
Nov 10, 2014, 3:15:39 AM (10 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
c941e07
Parents:
ace001a (diff), 426fb84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:weretaco/network-game

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/DataAccess.cpp

    race001a ra9a1295  
    178178{
    179179   // each array is the score for one game
    180    // the columns are result, team, blue score, and red score
     180   // the columns are result, team, blue score, red score, and time the game ended
    181181   // for result 0 is defeat and 1 is victory
    182182   // for team, 1 is blue and 2 is red
     
    197197   int i=0;
    198198   while ( ( row = mysql_fetch_row(result)) != NULL ) {
    199       gameHistory[i] = new int[4];
     199      gameHistory[i] = new int[5];
    200200
    201201      int userTeam = atoi(row[2]);
    202       int blueScore = atoi(row[4]);
    203       int redScore = atoi(row[3]);
     202      int blueScore = atoi(row[3]);
     203      int redScore = atoi(row[4]);
     204      time_t timeFinished = atoi(row[5]);
    204205      int gameResult = -1;
    205206
     
    222223      gameHistory[i][2] = blueScore;
    223224      gameHistory[i][3] = redScore;
     225      gameHistory[i][4] = timeFinished;
    224226
    225227      i++;
     
    236238}
    237239
    238 int DataAccess::saveGameHistory(int playerId, int team, int blueScore, int redScore)
     240int DataAccess::saveGameHistory(int playerId, int team, int blueScore, int redScore, time_t timeFinished)
    239241{
    240242   ostringstream oss;
    241243
    242244   cout << "Saving game to db" << endl;
    243    oss << playerId << ", " << team << ", " << blueScore << ", " << redScore;
    244 
    245    return insert("gameHistory", "user_id, user_team, blue_score, red_score", oss.str());
     245   oss << playerId << ", " << team << ", " << blueScore << ", " << redScore << ", " << timeFinished;
     246
     247   return insert("gameHistory", "user_id, user_team, blue_score, red_score, time_finished", oss.str());
    246248}
    247249
Note: See TracChangeset for help on using the changeset viewer.