Changeset 48801af in network-game
- Timestamp:
- Nov 11, 2014, 1:20:11 AM (10 years ago)
- Branches:
- master
- Children:
- 85da778
- Parents:
- c941e07
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Player.cpp
rc941e07 r48801af 30 30 this->range = 0; 31 31 this->attackCooldown = 0; 32 this->team = 0; // no team by default32 this->team = TEAM_NONE; 33 33 this->hasBlueFlag = false; 34 34 this->hasRedFlag = false; … … 104 104 this->range = 0; 105 105 this->attackCooldown = 0; 106 this->team = 0; // no team by default106 this->team = TEAM_NONE; 107 107 this->hasBlueFlag = false; 108 108 this->hasRedFlag = false; -
common/Player.h
rc941e07 r48801af 39 39 ATTACK_MELEE, 40 40 ATTACK_RANGED 41 }; 42 43 enum PlayerTeam { 44 TEAM_NONE, 45 TEAM_BLUE, 46 TEAM_RED 41 47 }; 42 48 … … 84 90 int range; 85 91 unsigned long long attackCooldown; 86 int team; // 0 is none, 1 is blue, 2 is red92 PlayerTeam team; 87 93 bool hasBlueFlag; 88 94 bool hasRedFlag; -
server/server.cpp
rc941e07 r48801af 139 139 switch (p->team) 140 140 { 141 case 1:// blue team141 case Player::TEAM_BLUE: 142 142 spawnPos = p->currentGame->getMap()->getStructureLocation(STRUCTURE_BLUE_FLAG); 143 143 break; 144 case 2:// red team144 case Player::TEAM_RED: 145 145 spawnPos = p->currentGame->getMap()->getStructureLocation(STRUCTURE_RED_FLAG); 146 146 break; … … 781 781 map<unsigned int, Player*>& oldPlayers = g->getPlayers(); 782 782 g->addPlayer(p); 783 p->team = 0;783 p->team = Player::TEAM_NONE; 784 784 785 785 // send info to other players … … 922 922 case STRUCTURE_BLUE_FLAG: 923 923 { 924 if (p->team == 1&& p->hasRedFlag) {924 if (p->team == Player::TEAM_BLUE && p->hasRedFlag) { 925 925 // check that your flag is at your base 926 926 pos = game->getMap()->getStructureLocation(STRUCTURE_BLUE_FLAG); … … 951 951 case STRUCTURE_RED_FLAG: 952 952 { 953 if (p->team == 2&& p->hasBlueFlag) {953 if (p->team == Player::TEAM_RED && p->hasBlueFlag) { 954 954 // check that your flag is at your base 955 955 pos = game->getMap()->getStructureLocation(STRUCTURE_RED_FLAG); … … 1048 1048 1049 1049 if (posDistance(p->pos, pos.toFloat()) < 10) { 1050 if (p->team == 1&& itObjects->type == OBJECT_BLUE_FLAG) {1050 if (p->team == Player::TEAM_BLUE && itObjects->type == OBJECT_BLUE_FLAG) { 1051 1051 structPos = game->getMap()->getStructureLocation(STRUCTURE_BLUE_FLAG); 1052 1052 flagReturned = true; 1053 1053 break; 1054 } else if (p->team == 2&& itObjects->type == OBJECT_RED_FLAG) {1054 } else if (p->team == Player::TEAM_RED && itObjects->type == OBJECT_RED_FLAG) { 1055 1055 structPos = game->getMap()->getStructureLocation(STRUCTURE_RED_FLAG); 1056 1056 flagReturned = true;
Note:
See TracChangeset
for help on using the changeset viewer.