Changeset 60776f2 in network-game
- Timestamp:
- Dec 26, 2012, 3:27:08 PM (12 years ago)
- Branches:
- master
- Children:
- 5066e27
- Parents:
- 3b8adee
- git-author:
- dportnoy <dmp1488@…> (12/26/12 15:26:07)
- git-committer:
- dportnoy <dmp1488@…> (12/26/12 15:27:08)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r3b8adee r60776f2 371 371 { 372 372 string response = string(msg.buffer); 373 374 cout << "Got message: " << msg.type << endl; 373 375 374 376 switch(state) … … 437 439 case MSG_TYPE_PLAYER: 438 440 { 439 Player p = *(Player*)(&(msg.buffer)); 440 441 cout << "p.name: " << p.name; 442 cout << "p.pos.x: " << p.pos.x; 443 cout << "p.pos.y: " << p.pos.y; 441 Player p("", ""); 442 p.deserialize(msg.buffer); 443 444 cout << "p.name: " << p.name << endl; 445 cout << "p.pos.x: " << p.pos.x << endl; 446 cout << "p.pos.y: " << p.pos.y << endl; 444 447 445 448 break; -
common/Player.cpp
r3b8adee r60776f2 37 37 38 38 oss << this->name; 39 oss.write((char*)&(this->pos.x), sizeof(int)); 40 oss.write((char*)&(this->pos.y), sizeof(int)); 39 41 40 memcpy(buffer, oss.str().c_str(), this->name.length()+1 );42 memcpy(buffer, oss.str().c_str(), this->name.length()+1+2*sizeof(int)); 41 43 } 42 44 … … 44 46 { 45 47 istringstream iss; 48 iss.str(buffer); 46 49 47 50 iss >> this->name; 51 iss.read((char*)&(this->pos.x), sizeof(int)); 52 iss.read((char*)&(this->pos.y), sizeof(int)); 48 53 } 49 54
Note:
See TracChangeset
for help on using the changeset viewer.