Changeset ea17281 in network-game for common


Ignore:
Timestamp:
Jul 4, 2014, 8:09:47 PM (10 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
e98426d
Parents:
a0ce8a3
Message:

Game.addPlayer takes a boolean to indicate wheter it runs on the server. If it's not, the team isn't randomly generated.

Location:
common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    ra0ce8a3 rea17281  
    4343}
    4444
    45 bool Game::addPlayer(Player* p) {
     45bool Game::addPlayer(Player* p, bool serverSide) {
    4646   if (players.find(p->getId()) == players.end()) {
    4747      players[p->getId()] = p;
     
    5858      p->hasRedFlag = false;
    5959
    60       // choose a random team (either 0 or 1)
    61       p->team = rand() % 2;
     60      if (serverSide) {
     61         // choose a random team (either 0 or 1)
     62         p->team = rand() % 2;
     63      }
    6264
    6365      p->currentGame = this;
  • common/Game.h

    ra0ce8a3 rea17281  
    4949
    5050   map<unsigned int, Player*>& getPlayers();
    51    bool addPlayer(Player* p);
     51   bool addPlayer(Player* p, bool serverSide);
    5252   bool removePlayer(unsigned int id);
    5353
  • common/MessageProcessor.cpp

    ra0ce8a3 rea17281  
    5050
    5151   // assume we don't care about the value of socklen
    52    cout << "Waiting for message from server" << endl;
     52   //cout << "Waiting for message from server" << endl;
    5353   int ret =  recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)source, &socklen);
    54    cout << "Returned from wait" << endl;
     54   //cout << "Returned from wait" << endl;
    5555
    5656   if (ret == -1)
Note: See TracChangeset for help on using the changeset viewer.