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


Ignore:
Timestamp:
Sep 26, 2013, 8:29:14 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
f41a7f9
Parents:
321fbbc
Message:

The Game class now has a WorldMap. When a client creates or joins a game, the server sends out all the basic game info (the map and info about all players in the game)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    r321fbbc rb92e6a7  
    66   this->id = 0;
    77   this->name = "";
     8   this->blueScore = 0;
     9   this->redScore = 0;
     10   this->worldMap = NULL;
    811}
    912
     
    1114   this->id = 0;
    1215   this->name = name;
     16   this->blueScore = 0;
     17   this->redScore = 0;
     18   this->worldMap = WorldMap::loadMapFromFile("../data/map.txt");
    1319}
    1420
    1521Game::~Game() {
    16 }
    17 
    18 void Game::setId(int id) {
    19    this->id = id;
     22   delete this->worldMap;
    2023}
    2124
    2225int Game::getNumPlayers() {
    23    return players.size();
     26   return this->players.size();
     27}
     28
     29map<unsigned int, Player*>& Game::getPlayers() {
     30   return this->players;
     31}
     32
     33int Game::getRedScore() {
     34   return this->redScore;
     35}
     36
     37int Game::getBlueScore() {
     38   return this->blueScore;
     39}
     40
     41WorldMap* Game::getMap() {
     42   return this->worldMap;
     43}
     44
     45void Game::setId(unsigned int id) {
     46   this->id = id;
    2447}
    2548
     
    3356}
    3457
    35 bool Game::removePlayer(int id) {
     58bool Game::removePlayer(unsigned int id) {
    3659   if (players.erase(id) == 1)
    3760      return true;
     
    3962      return false;
    4063}
     64
     65void Game::setRedScore(int score) {
     66   this->redScore = score;
     67}
     68
     69void Game::setBlueScore(int score) {
     70   this->blueScore = score;
     71}
Note: See TracChangeset for help on using the changeset viewer.