Changeset 3476207 in network-game


Ignore:
Timestamp:
Jul 4, 2014, 8:23:38 PM (10 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
dfc81f0, f15d6a9
Parents:
e98426d
Message:

Client shows all players in the game lobby and sends messages to the server when the client player switches teams

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    re98426d r3476207  
    439439            int drawPosition = 0;
    440440
    441             switch (currentPlayer->team) {
    442             case -1:
    443                drawPosition = 200;
    444                break;
    445             case 0:
    446                drawPosition = 400;
    447                break;
    448             case 1:
    449                drawPosition = 600;
    450                break;
    451             }
    452 
    453441            map<unsigned int, Player*> gamePlayers = game->getPlayers();
    454442            map<unsigned int, Player*>::iterator itPlayers;
     
    456444            int i=0;
    457445            for (itPlayers = gamePlayers.begin(); itPlayers != gamePlayers.end(); itPlayers++) {
     446               switch (itPlayers->second->team) {
     447               case -1:
     448                  drawPosition = 200;
     449                  break;
     450               case 0:
     451                  drawPosition = 400;
     452                  break;
     453               case 1:
     454                  drawPosition = 600;
     455                  break;
     456               }
     457
    458458               oss << itPlayers->second->name << endl;
    459459               al_draw_text(font, al_map_rgb(0, 255, 0), drawPosition, 135+i*15, ALLEGRO_ALIGN_LEFT, oss.str().c_str());
     
    845845               state = STATE_GAME_LOBBY;
    846846               wndCurrent = wndGameLobby;
    847                mapPlayers[curPlayerId]->team = -1;
    848847
    849848               msgTo.type = MSG_TYPE_JOIN_GAME_ACK;
     
    954953               p.deserialize(msg.buffer);
    955954               cout << "Deserialized player" << endl;
     955               cout << "player team: " << p.team << endl;
     956               cout << "current player team: " << currentPlayer->team << endl;
    956957               p.timeLastUpdated = getCurrentMillis();
    957958               p.isChasing = false;
     
    966967                  mapPlayers[p.getId()] = new Player(p);
    967968
    968                game->addPlayer(mapPlayers[p.getId()]);
     969               game->addPlayer(mapPlayers[p.getId()], false);
    969970
    970971               break;
     
    13691370   cout << "joining waiting area" << endl;
    13701371   currentPlayer->team = -1;
     1372
     1373   msgTo.type = MSG_TYPE_JOIN_TEAM;
     1374   memcpy(msgTo.buffer, &(currentPlayer->team), 4);
     1375
     1376   msgProcessor.sendMessage(&msgTo, &server);
    13711377}
    13721378
     
    13741380   cout << "joining blue team" << endl;
    13751381   currentPlayer->team = 0;
     1382
     1383   msgTo.type = MSG_TYPE_JOIN_TEAM;
     1384   memcpy(msgTo.buffer, &(currentPlayer->team), 4);
     1385
     1386   msgProcessor.sendMessage(&msgTo, &server);
    13761387}
    13771388
     
    13791390   cout << "joining red team" << endl;
    13801391   currentPlayer->team = 1;
     1392
     1393   msgTo.type = MSG_TYPE_JOIN_TEAM;
     1394   memcpy(msgTo.buffer, &(currentPlayer->team), 4);
     1395
     1396   msgProcessor.sendMessage(&msgTo, &server);
    13811397}
    13821398
Note: See TracChangeset for help on using the changeset viewer.