Index: common/Player.cpp
===================================================================
--- common/Player.cpp	(revision 092817adb027b80ee540b5b3e6c8f485cbda00e0)
+++ common/Player.cpp	(revision 11062102ef714b823a46ff973138fe9bbfe4bb1a)
@@ -53,11 +53,23 @@
    ostringstream oss;
 
+   cout << "Player name: " << this->name << endl;
+
+   /*
    oss.write((char*)&(this->id), sizeof(int));
    oss << this->name;
+   cout << "first oss str: " << oss.str() << endl;
    oss.write("\0", 1);
+   cout << "second oss str: " << oss.str() << endl;
    oss.write((char*)&(this->pos.x), sizeof(int));
+   cout << "third oss str: " << oss.str() << endl;
    oss.write((char*)&(this->pos.y), sizeof(int));
+   */
 
-   memcpy(buffer, oss.str().c_str(), this->name.length()+1+2*sizeof(int));
+   oss << this->id;
+   oss << this->name;
+   css << this->pos.x;
+   css << this->pos.y;
+
+   memcpy(buffer, oss.str().c_str(), oss.str().length);
 }
 
@@ -67,8 +79,15 @@
    iss.str(buffer);
 
+   /*
    iss.read((char*)&(this->id), sizeof(int));
    iss >> this->name;
    iss.read((char*)&(this->pos.x), sizeof(int));
    iss.read((char*)&(this->pos.y), sizeof(int));
+   */
+
+   iss >> this.id;
+   iss >> this->name;
+   iss >> this->pos.x;
+   iss >> this->pos.y;
 }
 
Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 092817adb027b80ee540b5b3e6c8f485cbda00e0)
+++ server/server.cpp	(revision 11062102ef714b823a46ff973138fe9bbfe4bb1a)
@@ -32,5 +32,5 @@
 bool processMessage(const NETWORK_MSG &clientMsg, const struct sockaddr_in &from, map<unsigned int, Player>& mapPlayers, unsigned int& unusedId, NETWORK_MSG &serverMsg);
 
-void updateUnusedId(unsigned int& id);
+void updateUnusedId(unsigned int& id, map<unsigned int, Player>& mapPlayers);
 
 // this should probably go somewhere in the common folder
@@ -94,5 +94,5 @@
    NETWORK_MSG clientMsg, serverMsg;
    map<unsigned int, Player> mapPlayers;
-   unsigned int unusedId = 0;
+   unsigned int unusedId = 1;
 
    //SSL_load_error_strings();
@@ -212,7 +212,7 @@
          {
             p->setAddr(from);
+            updateUnusedId(unusedId, mapPlayers);
             p->id = unusedId;
             mapPlayers[unusedId] = *p;
-            updateUnusedId(unusedId);
 
             strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with other players.");
@@ -288,6 +288,7 @@
 }
 
-void updateUnusedId(unsigned int& id)
-{
-   id = 5;
-}
+void updateUnusedId(unsigned int& id, map<unsigned int, Player>& mapPlayers)
+{
+   while (mapPlayers.find(id) != mapPlayers.end())
+      id++;
+}
