Changeset 7f884ea in network-game for common/Game.cpp


Ignore:
Timestamp:
Jan 24, 2014, 12:27:15 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
f66d04f
Parents:
e70b66b
Message:

Map-related structs are now outside of the WorldMap class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    re70b66b r7f884ea  
    102102}
    103103
    104 void Game::addObjectToMap(WorldMap::ObjectType objectType, int x, int y) {
     104void Game::addObjectToMap(ObjectType objectType, int x, int y) {
    105105   NETWORK_MSG serverMsg;
    106106
     
    120120   if (0 <= x && x < this->worldMap->width*25 &&
    121121       0 <= y && y < this->worldMap->height*25 &&
    122        this->worldMap->getElement(x/25, y/25) == WorldMap::TERRAIN_GRASS)
     122       this->worldMap->getElement(x/25, y/25) == TERRAIN_GRASS)
    123123   {
    124124      p->target.x = x;
     
    140140   switch(this->worldMap->getElement(p->pos.x/25, p->pos.y/25))
    141141   {
    142       case WorldMap::TERRAIN_NONE:
    143       case WorldMap::TERRAIN_OCEAN:
    144       case WorldMap::TERRAIN_ROCK:
     142      case TERRAIN_NONE:
     143      case TERRAIN_OCEAN:
     144      case TERRAIN_ROCK:
    145145      {
    146146         p->pos = oldPos;
     
    167167      if (posDistance(p->pos, it->pos.toFloat()) < 10) {
    168168         switch (it->type) {
    169             case WorldMap::OBJECT_BLUE_FLAG:
     169            case OBJECT_BLUE_FLAG:
    170170               if (p->team == 1) {
    171171                  p->hasBlueFlag = true;
     
    173173               }
    174174               break;
    175             case WorldMap::OBJECT_RED_FLAG:
     175            case OBJECT_RED_FLAG:
    176176               if (p->team == 0) {
    177177                  p->hasRedFlag = true;
     
    179179               }
    180180               break;
    181             case WorldMap::OBJECT_NONE:
     181            case OBJECT_NONE:
    182182               break;
    183183         }
     
    198198   if (p->isDead)
    199199   {
    200       WorldMap::ObjectType flagType = WorldMap::OBJECT_NONE;
     200      ObjectType flagType = OBJECT_NONE;
    201201      if (p->hasBlueFlag)
    202          flagType = WorldMap::OBJECT_BLUE_FLAG;
     202         flagType = OBJECT_BLUE_FLAG;
    203203      else if (p->hasRedFlag)
    204          flagType = WorldMap::OBJECT_RED_FLAG;
    205 
    206       if (flagType != WorldMap::OBJECT_NONE)
     204         flagType = OBJECT_RED_FLAG;
     205
     206      if (flagType != OBJECT_NONE)
    207207         this->addObjectToMap(flagType, p->pos.x, p->pos.y);
    208208   }
     
    252252      cout << "player move processed" << endl;
    253253
    254       WorldMap::ObjectType flagType;
     254      ObjectType flagType;
    255255      POSITION pos;
    256256      bool flagTurnedIn = false;
     
    260260      switch(this->worldMap->getStructure(p->pos.x/25, p->pos.y/25))
    261261      {
    262          case WorldMap::STRUCTURE_BLUE_FLAG:
     262         case STRUCTURE_BLUE_FLAG:
    263263         {
    264264            if (p->team == 0 && p->hasRedFlag)
    265265            {
    266266               // check that your flag is at your base
    267                pos = this->worldMap->getStructureLocation(WorldMap::STRUCTURE_BLUE_FLAG);
     267               pos = this->worldMap->getStructureLocation(STRUCTURE_BLUE_FLAG);
    268268                           
    269269               vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects();
     
    272272               for (itObjects = vctObjects->begin(); itObjects != vctObjects->end(); itObjects++)
    273273               {
    274                   if (itObjects->type == WorldMap::OBJECT_BLUE_FLAG)
     274                  if (itObjects->type == OBJECT_BLUE_FLAG)
    275275                  {
    276276                     if (itObjects->pos.x == pos.x*25+12 && itObjects->pos.y == pos.y*25+12)
     
    285285               {
    286286                  p->hasRedFlag = false;
    287                   flagType = WorldMap::OBJECT_RED_FLAG;
    288                   pos = this->worldMap->getStructureLocation(WorldMap::STRUCTURE_RED_FLAG);
     287                  flagType = OBJECT_RED_FLAG;
     288                  pos = this->worldMap->getStructureLocation(STRUCTURE_RED_FLAG);
    289289                  flagTurnedIn = true;
    290290                  this->blueScore++;
     
    294294            break;
    295295         }
    296          case WorldMap::STRUCTURE_RED_FLAG:
     296         case STRUCTURE_RED_FLAG:
    297297         {
    298298            if (p->team == 1 && p->hasBlueFlag)
    299299            {
    300300               // check that your flag is at your base
    301                pos = this->worldMap->getStructureLocation(WorldMap::STRUCTURE_RED_FLAG);
     301               pos = this->worldMap->getStructureLocation(STRUCTURE_RED_FLAG);
    302302                       
    303303               vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects();
     
    306306               for (itObjects = vctObjects->begin(); itObjects != vctObjects->end(); itObjects++)
    307307               {
    308                   if (itObjects->type == WorldMap::OBJECT_RED_FLAG)
     308                  if (itObjects->type == OBJECT_RED_FLAG)
    309309                  {
    310310                     if (itObjects->pos.x == pos.x*25+12 && itObjects->pos.y == pos.y*25+12)
     
    319319               {
    320320                  p->hasBlueFlag = false;
    321                   flagType = WorldMap::OBJECT_BLUE_FLAG;
    322                   pos = this->worldMap->getStructureLocation(WorldMap::STRUCTURE_BLUE_FLAG);
     321                  flagType = OBJECT_BLUE_FLAG;
     322                  pos = this->worldMap->getStructureLocation(STRUCTURE_BLUE_FLAG);
    323323                  flagTurnedIn = true;
    324324                  this->redScore++;
     
    385385         {
    386386            if (p->team == 0 &&
    387                 itObjects->type == WorldMap::OBJECT_BLUE_FLAG)
     387                itObjects->type == OBJECT_BLUE_FLAG)
    388388            {
    389                structPos = this->worldMap->getStructureLocation(WorldMap::STRUCTURE_BLUE_FLAG);
     389               structPos = this->worldMap->getStructureLocation(STRUCTURE_BLUE_FLAG);
    390390               flagReturned = true;
    391391               break;
    392392            }
    393393            else if (p->team == 1 &&
    394                      itObjects->type == WorldMap::OBJECT_RED_FLAG)
     394                     itObjects->type == OBJECT_RED_FLAG)
    395395            {
    396                structPos = this->worldMap->getStructureLocation(WorldMap::STRUCTURE_RED_FLAG);
     396               structPos = this->worldMap->getStructureLocation(STRUCTURE_RED_FLAG);
    397397               flagReturned = true;
    398398               break;
Note: See TracChangeset for help on using the changeset viewer.