Changeset df79cfd in network-game


Ignore:
Timestamp:
May 25, 2013, 7:32:50 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
a6066e8
Parents:
b8cb03f
Message:

The server assigns a random team to each player when they login

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • common/Player.cpp

    rb8cb03f rdf79cfd  
    3131   this->target.y = p.target.y;
    3232   this->addr = p.addr;
    33       this->team = 0;   // blue team by default
    34    this->hasBlueFlag = false;
    35    this->hasRedFlag = false;
     33   this->team = p.team;
     34   this->hasBlueFlag = p.hasBlueFlag;
     35   this->hasRedFlag = p.hasRedFlag;
    3636}
    3737
  • server/server.cpp

    rb8cb03f rdf79cfd  
    305305            serverMsg.type = MSG_TYPE_PLAYER;
    306306
    307             p->setAddr(from);
    308307            updateUnusedId(unusedId, mapPlayers);
    309308            p->id = unusedId;
    310309            cout << "new player id: " << p->id << endl;
     310            p->setAddr(from);
     311
     312            // choose a random team (either 0 or 1)
     313            p->team = rand() % 2;
    311314
    312315            // tell the new player about all the existing players
Note: See TracChangeset for help on using the changeset viewer.