summaryrefslogtreecommitdiffstats
path: root/src/Net/Packets
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-02-14 13:48:26 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-02-14 13:48:26 +0100
commit0a8624a39a7d0a99963153533a7ca3092154d3bd (patch)
treed190bc5f101c1e90cb0650fa1fcbee01ee56313a /src/Net/Packets
parent04363ca342914ba75e693edb876cbe535839fa79 (diff)
downloadmad-0a8624a39a7d0a99963153533a7ca3092154d3bd.tar
mad-0a8624a39a7d0a99963153533a7ca3092154d3bd.zip
Nur ein paar kleinere Bug- und Warnungsfixes
Diffstat (limited to 'src/Net/Packets')
-rw-r--r--src/Net/Packets/UserListPacket.cpp34
-rw-r--r--src/Net/Packets/UserListPacket.h2
2 files changed, 18 insertions, 18 deletions
diff --git a/src/Net/Packets/UserListPacket.cpp b/src/Net/Packets/UserListPacket.cpp
index d364522..d7415c3 100644
--- a/src/Net/Packets/UserListPacket.cpp
+++ b/src/Net/Packets/UserListPacket.cpp
@@ -31,19 +31,19 @@ void UserListPacket::assemblePacket() {
for(std::vector<Common::UserInfo>::iterator user = userList.begin(); user != userList.end(); ++user)
str += user->getUsername() + "\n" + user->getFullName() + "\n";
- setLength(sizeof(uint16_t) + sizeof(UserData)*userList.size() + str.length());
+ setLength(sizeof(uint32_t) + sizeof(UserData)*userList.size() + str.length());
- nUsers = (uint16_t*)rawData->data;
- userData = (UserData*)(rawData->data + sizeof(uint16_t));
- charData = (char*)(rawData->data + sizeof(uint16_t) + sizeof(UserData)*userList.size());
+ nUsers = (uint32_t*)rawData->data;
+ userData = (UserData*)(rawData->data + sizeof(uint32_t));
+ charData = (char*)(rawData->data + sizeof(uint32_t) + sizeof(UserData)*userList.size());
std::memcpy(charData, str.c_str(), str.length());
- *nUsers = htons(userList.size());
+ *nUsers = htonl(userList.size());
for(size_t i = 0; i < userList.size(); ++i) {
- userData[i].uid = htons((uint32_t)userList[i].getUid());
- userData[i].gid = htons((uint32_t)userList[i].getGid());
+ userData[i].uid = htonl((uint32_t)userList[i].getUid());
+ userData[i].gid = htonl((uint32_t)userList[i].getGid());
}
}
@@ -53,21 +53,21 @@ void UserListPacket::parsePacket() {
if(getLength() < sizeof(uint16_t))
return;
- nUsers = (uint16_t*)rawData->data;
- userList.resize(ntohs(*nUsers));
+ nUsers = (uint32_t*)rawData->data;
+ userList.resize(ntohl(*nUsers));
- if(getLength() < sizeof(uint16_t) + sizeof(UserData)*userList.size())
- setLength(sizeof(uint16_t) + sizeof(UserData)*userList.size());
+ if(getLength() < sizeof(uint32_t) + sizeof(UserData)*userList.size())
+ setLength(sizeof(uint32_t) + sizeof(UserData)*userList.size());
- nUsers = (uint16_t*)rawData->data;
- userData = (UserData*)(rawData->data + sizeof(uint16_t));
- charData = (char*)(rawData->data + sizeof(uint16_t) + sizeof(UserData)*userList.size());
+ nUsers = (uint32_t*)rawData->data;
+ userData = (UserData*)(rawData->data + sizeof(uint32_t));
+ charData = (char*)(rawData->data + sizeof(uint32_t) + sizeof(UserData)*userList.size());
- std::istringstream stream(std::string(charData, getLength() - (sizeof(uint16_t)+sizeof(UserData)*userList.size())));
+ std::istringstream stream(std::string(charData, getLength() - (sizeof(uint32_t)+sizeof(UserData)*userList.size())));
for(size_t i = 0; i < userList.size(); ++i) {
- userList[i].setUid(ntohs(userData[i].uid));
- userList[i].setGid(ntohs(userData[i].gid));
+ userList[i].setUid(ntohl(userData[i].uid));
+ userList[i].setGid(ntohl(userData[i].gid));
if(!stream.eof()) {
std::string str;
diff --git a/src/Net/Packets/UserListPacket.h b/src/Net/Packets/UserListPacket.h
index d099fab..364a36d 100644
--- a/src/Net/Packets/UserListPacket.h
+++ b/src/Net/Packets/UserListPacket.h
@@ -35,7 +35,7 @@ class UserListPacket : public Packet {
uint32_t gid;
};
- uint16_t *nUsers;
+ uint32_t *nUsers;
UserData *userData;
char *charData;