Changeset 53ba300 in network-game


Ignore:
Timestamp:
Oct 4, 2013, 5:37:46 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
50643fa
Parents:
90eaad2
Message:

The client handles MSG_TYPE_LOGOUT messages about other players

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r90eaad2 r53ba300  
    625625void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers, map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed)
    626626{
     627   // this is outdated since most messages now don't contain just a text string
    627628   string response = string(msg.buffer);
    628629
     
    697698               cout << "Got a logout message" << endl;
    698699
    699                if (response.compare("You have successfully logged out.") == 0)
     700               int playerId;
     701
     702               // Check if it's about you or another player
     703               memcpy(&playerId, msg.buffer, 4);
     704               response = string(msg.buffer+4);
     705
     706               if (playerId == curPlayerId)
    700707               {
    701                   cout << "Logged out" << endl;
    702                   state = STATE_START;
    703                   goToLoginScreen();
     708                  if (response.compare("You have successfully logged out.") == 0)
     709                  {
     710                     cout << "Logged out" << endl;
     711                     state = STATE_START;
     712                     goToLoginScreen();
     713                  }
     714
     715                  // if there was an error logging out, nothing happens
     716               }
     717               else
     718               {
     719                  delete mapPlayers[playerId];
    704720               }
    705721
Note: See TracChangeset for help on using the changeset viewer.