Changeset 626e5b0 in network-game for client


Ignore:
Timestamp:
May 25, 2013, 2:18:05 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
e487381
Parents:
2df63d6
Message:

The client sends a DROP_FLAG message when the user presses D

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r2df63d6 r626e5b0  
    228228      else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
    229229         doexit = true;
    230 
    231          // perform a check to see if it's time to send an update to the server
    232          // need to store num ticks since the lst update for this
    233          // also check how often each update actually happens and how much it deviates from 60 times per second
    234230      }
    235231      else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) {
     
    239235            case ALLEGRO_KEY_ESCAPE:
    240236               doexit = true;
     237               break;
     238            case ALLEGRO_KEY_D:  // drop the current item
     239               if (state == STATE_LOGIN) {
     240                  map<unsigned int, Player>::iterator it;
     241                  Player* p = NULL;
     242                  for(it = mapPlayers.begin(); it != mapPlayers.end(); it++)
     243                  {
     244                     &it->second;
     245                     if (it->second.id == curPlayerId)
     246                        p = &it->second;
     247                  }
     248
     249                  if (p != NULL) {
     250                     int flagType = WorldMap::OBJECT_NONE;
     251
     252                     if (p->hasBlueFlag)
     253                        flagType = WorldMap::OBJECT_BLUE_FLAG;
     254                     else if (p->hasRedFlag)
     255                        flagType = WorldMap::OBJECT_RED_FLAG;
     256
     257                     if (flagType != WorldMap::OBJECT_NONE) {
     258                        msgTo.type = MSG_TYPE_DROP_FLAG;
     259                        memcpy(msgTo.buffer, &curPlayerId, 4);
     260                        sendMessage(&msgTo, sock, &server);
     261                     }
     262                  }
     263               }
    241264               break;
    242265         }
Note: See TracChangeset for help on using the changeset viewer.