Changeset ad5d122 in network-game for client


Ignore:
Timestamp:
Jan 29, 2013, 7:19:59 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
5806dc2
Parents:
80b3f94
Message:

Fixed a bug with Player serialization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r80b3f94 rad5d122  
    303303      }
    304304      else if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP) {
    305          mapPlayers[curPlayerId].pos.x = ev.mouse.x;
    306          mapPlayers[curPlayerId].pos.y = ev.mouse.y;
    307 
    308          // send the server a MSG_TYPE_PLAYER_MOVE message
    309          msgTo.type = MSG_TYPE_PLAYER_MOVE;
    310 
    311          ostringstream oss;
    312          oss << ev.mouse.x;
    313          oss << ev.mouse.y;
    314 
    315          memcpy(msgTo.buffer, oss.str().c_str(), oss.str().length());
    316          sendMessage(&msgTo, sock, &server);
     305         if(wndCurrent == wndMain) {
     306            msgTo.type = MSG_TYPE_PLAYER_MOVE;
     307
     308            memcpy(msgTo.buffer, &curPlayerId, 4);
     309            memcpy(msgTo.buffer+4, &ev.mouse.x, 4);
     310            memcpy(msgTo.buffer+8, &ev.mouse.y, 4);
     311
     312            sendMessage(&msgTo, sock, &server);
     313         }
    317314      }
    318315
Note: See TracChangeset for help on using the changeset viewer.