Changeset ad5d122 in network-game
- Timestamp:
- Jan 29, 2013, 7:19:59 PM (12 years ago)
- Branches:
- master
- Children:
- 5806dc2
- Parents:
- 80b3f94
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r80b3f94 rad5d122 303 303 } 304 304 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 } 317 314 } 318 315 -
common/Player.cpp
r80b3f94 rad5d122 53 53 memcpy(buffer, &this->id, 4); 54 54 strcpy(buffer+4, this->name.c_str()); 55 memcpy(buffer+ 4+this->name.length(), &this->pos.x, 4);56 memcpy(buffer+ 8+this->name.length(), &this->pos.y, 4);55 memcpy(buffer+5+this->name.length(), &this->pos.x, 4); 56 memcpy(buffer+9+this->name.length(), &this->pos.y, 4); 57 57 } 58 58 … … 63 63 memcpy(&this->id, buffer, 4); 64 64 strcpy(test, buffer+4); 65 memcpy(&this->pos.x, buffer+ 4+strlen(test), 4);66 memcpy(&this->pos.y, buffer+ 8+strlen(test), 4);65 memcpy(&this->pos.x, buffer+5+strlen(test), 4); 66 memcpy(&this->pos.y, buffer+9+strlen(test), 4); 67 67 68 68 cout << "id: " << this->id << endl;
Note:
See TracChangeset
for help on using the changeset viewer.