From 0a8624a39a7d0a99963153533a7ca3092154d3bd Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 14 Feb 2009 13:48:26 +0100 Subject: Nur ein paar kleinere Bug- und Warnungsfixes --- src/Net/Packets/UserListPacket.cpp | 34 +++++++++++++++++----------------- src/Net/Packets/UserListPacket.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/Net') 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::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; -- cgit v1.2.3