Changeset dfb9363 in network-game


Ignore:
Timestamp:
Jan 27, 2014, 2:12:03 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
6f64166
Parents:
11ad6fb
Message:

Client correctly handles other players leaving

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r11ad6fb rdfb9363  
    657657void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers, unsigned int& curPlayerId)
    658658{
     659   cout << "Total players in map: " << mapPlayers.size() << endl;
     660
    659661   // this is outdated since most messages now don't contain just a text string
    660662   string response = string(msg.buffer);
     
    737739               if (playerId == curPlayerId)
    738740               {
     741                  cout << "Got logout message for self" << endl;
     742
    739743                  if (response.compare("You have successfully logged out.") == 0)
    740744                  {
     
    749753               {
    750754                  delete mapPlayers[playerId];
     755                  mapPlayers.erase(playerId);
    751756               }
    752757
     
    963968               break;
    964969            }
    965              case MSG_TYPE_LOGOUT:
     970            case MSG_TYPE_LOGOUT:
    966971            {
    967972               cout << "Got a logout message" << endl;
     
    975980               if (playerId == curPlayerId)
    976981                  cout << "Received MSG_TYPE_LOGOUT for self in STATE_GAME. This shouldn't happen." << endl;
    977                else
     982               else {
    978983                  delete mapPlayers[playerId];
     984                  mapPlayers.erase(playerId);
     985               }
    979986
    980987               break;
Note: See TracChangeset for help on using the changeset viewer.