Changeset 0129700 in network-game for common/Game.cpp


Ignore:
Timestamp:
Dec 19, 2013, 3:31:45 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
fef7c69
Parents:
70fc3e8
Message:

The Game class validates player movement on the server side

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    r70fc3e8 r0129700  
    6767}
    6868
     69bool Game::startPlayerMovement(unsigned int id, int x, int y) {
     70   // need to check if players actually contains the id
     71   Player* p = players[id];
     72
     73   // we need to make sure the player can move here
     74   if (0 <= x && x < this->worldMap->width*25 &&
     75       0 <= y && y < this->worldMap->height*25 &&
     76       this->worldMap->getElement(x/25, y/25) == WorldMap::TERRAIN_GRASS)
     77   {
     78      p->target.x = x;
     79      p->target.y = y;
     80
     81      p->isChasing = false;
     82      p->isAttacking = false;
     83
     84      return true;
     85   }
     86   else
     87      return false;
     88}
     89
    6990void Game::setRedScore(int score) {
    7091   this->redScore = score;
Note: See TracChangeset for help on using the changeset viewer.