Changeset 7fa452f in network-game


Ignore:
Timestamp:
Nov 8, 2014, 1:38:54 AM (10 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
master
Children:
347d768
Parents:
306758e
Message:

Change the player team variable so that 0 means no team, 1 means blue team, and 2 means red team (before, -1 meant no team, 0 meant blue team, and 1 meant red team)

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • client/Client/GameRender.cpp

    r306758e r7fa452f  
    9696         al_draw_filled_circle(pos.x, pos.y, 14, al_map_rgb(0, 0, 0));
    9797     
    98       if (p->team == 0)
     98      if (p->team == 1)
    9999         color = al_map_rgb(0, 0, 255);
    100       else if (p->team == 1)
     100      else if (p->team == 2)
    101101         color = al_map_rgb(255, 0, 0);
    102102      else {
  • client/Client/main.cpp

    r306758e r7fa452f  
    505505            for (itPlayers = gamePlayers.begin(); itPlayers != gamePlayers.end(); itPlayers++) {
    506506               switch (itPlayers->second->team) {
    507                case -1:
     507               case 0:
    508508                  drawPosition = 200;
    509509                  break;
    510                case 0:
     510               case 1:
    511511                  drawPosition = 400;
    512512                  break;
    513                case 1:
     513               case 2:
    514514                  drawPosition = 600;
    515515                  break;
     
    15141514void joinWaitingArea() {
    15151515   cout << "joining waiting area" << endl;
    1516    currentPlayer->team = -1;
     1516   currentPlayer->team = 0;
    15171517
    15181518   msgTo.type = MSG_TYPE_JOIN_TEAM;
     
    15241524void joinBlueTeam() {
    15251525   cout << "joining blue team" << endl;
    1526    currentPlayer->team = 0;
     1526   currentPlayer->team = 1;
    15271527
    15281528   msgTo.type = MSG_TYPE_JOIN_TEAM;
     
    15341534void joinRedTeam() {
    15351535   cout << "joining red team" << endl;
    1536    currentPlayer->team = 1;
     1536   currentPlayer->team = 2;
    15371537
    15381538   msgTo.type = MSG_TYPE_JOIN_TEAM;
  • common/Game.cpp

    r306758e r7fa452f  
    184184         switch (it->type) {
    185185            case OBJECT_BLUE_FLAG:
    186                if (p->team == 1) {
     186               if (p->team == 2) {
    187187                  p->hasBlueFlag = true;
    188188                  itemId = it->id;
     
    190190               break;
    191191            case OBJECT_RED_FLAG:
    192                if (p->team == 0) {
     192               if (p->team == 1) {
    193193                  p->hasRedFlag = true;
    194194                  itemId = it->id;
  • common/Player.cpp

    r306758e r7fa452f  
    3030   this->range = 0;
    3131   this->attackCooldown = 0;
    32    this->team = 0;   // blue team by default
     32   this->team = 0;   // no team by default
    3333   this->hasBlueFlag = false;
    3434   this->hasRedFlag = false;
     
    104104   this->range = 0;
    105105   this->attackCooldown = 0;
    106    this->team = 0;   // blue team by default
     106   this->team = 0;   // no team by default
    107107   this->hasBlueFlag = false;
    108108   this->hasRedFlag = false;
  • common/Player.h

    r306758e r7fa452f  
    8484   int range;
    8585   unsigned long long attackCooldown;
    86    int team; // 0 is blue, 1 is red
     86   int team; // 0 is none, 1 is blue, 2 is red
    8787   bool hasBlueFlag;
    8888   bool hasRedFlag;
  • server/DataAccess.cpp

    r306758e r7fa452f  
    180180   // the columns are result, team, blue score, and red score
    181181   // for result 0 is defeat and 1 is victory
    182    // for team, 0 is blue and 1 is red
     182   // for team, 1 is blue and 2 is red
    183183
    184184   MYSQL_RES *result;
     
    205205
    206206      if (blueScore == 3) {
    207          if (userTeam == 0)
     207         if (userTeam == 1)
    208208            gameResult = 1;
    209209         else
    210210            gameResult = 0;
    211211      }else if (redScore == 3) {
    212          if (userTeam == 1)
     212         if (userTeam == 2)
    213213            gameResult = 1;
    214214         else
  • server/server.cpp

    r306758e r7fa452f  
    139139                  switch (p->team)
    140140                  {
    141                   case 0:// blue team
     141                  case 1:// blue team
    142142                     spawnPos = p->currentGame->getMap()->getStructureLocation(STRUCTURE_BLUE_FLAG);
    143143                     break;
    144                   case 1:// red team
     144                  case 2:// red team
    145145                     spawnPos = p->currentGame->getMap()->getStructureLocation(STRUCTURE_RED_FLAG);
    146146                     break;
     
    191191               int winningTeam = -1;
    192192               if (game->getBlueScore() == 3)
    193                   winningTeam = 0;
     193                  winningTeam = 1;
    194194               else if (game->getRedScore() == 3)
    195                   winningTeam = 1;
     195                  winningTeam = 2;
    196196
    197197               if (winningTeam == -1)
     
    780780         map<unsigned int, Player*>& oldPlayers = g->getPlayers();
    781781         g->addPlayer(p);
    782          p->team = -1;
     782         p->team = 0;
    783783
    784784         // send info to other players
     
    921921         case STRUCTURE_BLUE_FLAG:
    922922         {
    923             if (p->team == 0 && p->hasRedFlag) {
     923            if (p->team == 1 && p->hasRedFlag) {
    924924               // check that your flag is at your base
    925925               pos = game->getMap()->getStructureLocation(STRUCTURE_BLUE_FLAG);
     
    950950         case STRUCTURE_RED_FLAG:
    951951         {
    952             if (p->team == 1 && p->hasBlueFlag) {
     952            if (p->team == 2 && p->hasBlueFlag) {
    953953               // check that your flag is at your base
    954954               pos = game->getMap()->getStructureLocation(STRUCTURE_RED_FLAG);
     
    10471047
    10481048         if (posDistance(p->pos, pos.toFloat()) < 10) {
    1049             if (p->team == 0 && itObjects->type == OBJECT_BLUE_FLAG) {
     1049            if (p->team == 1 && itObjects->type == OBJECT_BLUE_FLAG) {
    10501050               structPos = game->getMap()->getStructureLocation(STRUCTURE_BLUE_FLAG);
    10511051               flagReturned = true;
    10521052               break;
    1053             } else if (p->team == 1 && itObjects->type == OBJECT_RED_FLAG) {
     1053            } else if (p->team == 2 && itObjects->type == OBJECT_RED_FLAG) {
    10541054               structPos = game->getMap()->getStructureLocation(STRUCTURE_RED_FLAG);
    10551055               flagReturned = true;
Note: See TracChangeset for help on using the changeset viewer.