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/Common/ModuleManager.cpp | 2 ++ src/Net/Packets/UserListPacket.cpp | 34 +++++++++++++++++----------------- src/Net/Packets/UserListPacket.h | 2 +- src/modules/UserBackendMysql.cpp | 1 - 4 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp index 0e892c5..03ed880 100644 --- a/src/Common/ModuleManager.cpp +++ b/src/Common/ModuleManager.cpp @@ -34,6 +34,8 @@ ModuleManager ModuleManager::moduleManager; int ModuleManager::preopenCallback(lt_dlhandle handle) { moduleManager.modules.insert(std::make_pair(lt_dlgetinfo(handle)->name, std::make_pair(handle, false))); + + return 0; } void ModuleManager::doInit() { 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; diff --git a/src/modules/UserBackendMysql.cpp b/src/modules/UserBackendMysql.cpp index 886f345..0b028fb 100644 --- a/src/modules/UserBackendMysql.cpp +++ b/src/modules/UserBackendMysql.cpp @@ -142,7 +142,6 @@ bool UserBackendMysql::userList(const sigc::slot users; - MYSQL_ROW row; while(MYSQL_ROW row = mysql_fetch_row(result)) { Common::UserInfo user(std::strtoul(row[0], 0, 10), row[2]); -- cgit v1.2.3