Changeset 426fb84 in network-game for server/server.cpp


Ignore:
Timestamp:
Nov 10, 2014, 3:12:54 AM (10 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
master
Children:
a9a1295
Parents:
347d768
Message:

Save the actual time a game ends to the databse and send it to the client as part of a player's game history

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    r347d768 r426fb84  
    200200                  map<unsigned int, Player*>::iterator it;
    201201
     202                  time_t timeFinished = time(NULL);
    202203                  for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++) {
    203204                      Player* p = it->second;
     
    211212                          p->losses++;
    212213                      da.updatePlayer(p);
    213                       da.saveGameHistory(p->getId(), winningTeam, game->getBlueScore(), game->getRedScore());
     214                      da.saveGameHistory(p->getId(), winningTeam, game->getBlueScore(), game->getRedScore(), timeFinished);
    214215                  }
    215216               }
     
    613614         memcpy(serverMsg.buffer+12, &numGames, 4);
    614615         for (unsigned int i=0; i<numGames; i++) {
    615             memcpy(serverMsg.buffer+16+i*16, &gameHistory[i][0], 4);
    616             memcpy(serverMsg.buffer+20+i*16, &gameHistory[i][1], 4);
    617             memcpy(serverMsg.buffer+24+i*16, &gameHistory[i][2], 4);
    618             memcpy(serverMsg.buffer+28+i*16, &gameHistory[i][3], 4);
     616            memcpy(serverMsg.buffer+16+i*20, &gameHistory[i][0], 4);
     617            memcpy(serverMsg.buffer+20+i*20, &gameHistory[i][1], 4);
     618            memcpy(serverMsg.buffer+24+i*20, &gameHistory[i][2], 4);
     619            memcpy(serverMsg.buffer+28+i*20, &gameHistory[i][3], 4);
     620            memcpy(serverMsg.buffer+32+i*20, &gameHistory[i][4], 4);
    619621            delete[] gameHistory[i];
    620622         }
Note: See TracChangeset for help on using the changeset viewer.