Changeset 5806dc2 in network-game for common/Player.cpp


Ignore:
Timestamp:
Jan 29, 2013, 7:30:52 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
b128109
Parents:
ad5d122
Message:

Simplified Player serialization code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Player.cpp

    rad5d122 r5806dc2  
    5959void Player::deserialize(char* buffer)
    6060{
    61    char test[256];
    62 
    6361   memcpy(&this->id, buffer, 4);
    64    strcpy(test, buffer+4);
    65    memcpy(&this->pos.x, buffer+5+strlen(test), 4);
    66    memcpy(&this->pos.y, buffer+9+strlen(test), 4);
     62   this->name.assign(buffer+4);
     63   memcpy(&this->pos.x, buffer+5+this->name.size(), 4);
     64   memcpy(&this->pos.y, buffer+9+this->name.size(), 4);
    6765
    6866   cout << "id: " << this->id << endl;
    69    cout << "name: " << test << endl;
     67   cout << "name: " << this->name << endl;
    7068   cout << "x: " << this->pos.x << endl;
    7169   cout << "y: " << this->pos.y << endl;
Note: See TracChangeset for help on using the changeset viewer.