Changeset 321fbbc in network-game


Ignore:
Timestamp:
Sep 26, 2013, 5:41:56 PM (11 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
master
Children:
b92e6a7
Parents:
2992b1a
Message:

Client only stores the game name and number of players of each game

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r2992b1a r321fbbc  
    119119chat chatConsole, debugConsole;
    120120bool debugging;
    121 map<string, Game> mapGames;
     121map<string, int> mapGames;
    122122
    123123MessageProcessor msgProcessor;
     
    452452
    453453         if (wndCurrent == wndLobby) {
    454             map<string, Game>::iterator it;
     454            map<string, int>::iterator it;
    455455            int i=0;
    456456            ostringstream ossGame;
    457457            for (it = mapGames.begin(); it != mapGames.end(); it++) {
    458                ossGame << it->first << " (" << it->second.getNumPlayers() << " players)" << endl;
     458               ossGame << it->first << " (" << it->second << " players)" << endl;
    459459               al_draw_text(font, al_map_rgb(0, 255, 0), SCREEN_W*1/4-100, 120+i*15, ALLEGRO_ALIGN_LEFT, ossGame.str().c_str());
    460460               ossGame.clear();
     
    836836               cout << "Received game info for " << gameName << " (num players: " << numPlayers << ")" << endl;
    837837               
    838                if (mapGames.find(gameName) == mapGames.end())
    839                   mapGames[gameName] = Game(gameName);
    840                mapGames[gameName].setNumPlayers(numPlayers);
     838               mapGames[gameName] = numPlayers;
    841839
    842840               break;
  • common/Game.cpp

    r2992b1a r321fbbc  
    2424}
    2525
    26 void Game::setNumPlayers(int numPlayers) {
    27    int numCurPlayers = this->getNumPlayers();
    28    int numNewPlayers = numPlayers-numCurPlayers;
    29 
    30    for (int i=0; i<numNewPlayers; i++)
    31       this->players[numCurPlayers+i] = NULL;
    32 }
    33 
    3426bool Game::addPlayer(Player* p) {
    3527   if (players.count(p->id) == 0) {
  • common/Game.h

    r2992b1a r321fbbc  
    3333
    3434   void setId(int id);
    35    void setNumPlayers(int numPlayers);
    3635   bool addPlayer(Player* p);
    3736   bool removePlayer(int id);
Note: See TracChangeset for help on using the changeset viewer.