From 7897474c8a3fb975cc0bcda45e40c47d58959ea6 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Tue, 10 May 2011 15:53:32 +0300 Subject: [PATCH 1/1] Fix some types and add UserCount method to PROTO --- projects/sgauthstress/proto.cpp | 11 +++++++---- projects/sgauthstress/proto.h | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/projects/sgauthstress/proto.cpp b/projects/sgauthstress/proto.cpp index 40762b13..b89681f6 100644 --- a/projects/sgauthstress/proto.cpp +++ b/projects/sgauthstress/proto.cpp @@ -15,9 +15,9 @@ PROTO::PROTO(const std::string & server, uint16_t port, uint16_t localPort, int to) - : running(false), - stopped(true), - timeout(to) + : timeout(to), + running(false), + stopped(true) { uint32_t ip = inet_addr(server.c_str()); if (ip == INADDR_NONE) @@ -66,6 +66,7 @@ void * PROTO::Runner(void * data) { PROTO * protoPtr = static_cast(data); protoPtr->Run(); +return NULL; } bool PROTO::Start() @@ -202,6 +203,8 @@ it = processors.find(packetName); if (it != processors.end()) return (this->*it->second)(buffer, user); +printfd(__FILE__, "PROTO::HandlePacket() - invalid packet signature: '%s'\n", packetName.c_str()); + return false; } @@ -320,7 +323,7 @@ bool PROTO::ERR_Proc(const void * buffer, USER * user) const ERR_8 * packet = static_cast(buffer); const char * ptr = static_cast(buffer); -for (int i = 0; i < sizeof(packet) / 8; i++) +for (size_t i = 0; i < sizeof(ERR_8) / 8; i++) Blowfish_Decrypt(user->GetCtx(), (uint32_t *)(ptr + i * 8), (uint32_t *)(ptr + i * 8 + 4)); //uint32_t len = packet->len; diff --git a/projects/sgauthstress/proto.h b/projects/sgauthstress/proto.h index 0a2fb2de..05fe4722 100644 --- a/projects/sgauthstress/proto.h +++ b/projects/sgauthstress/proto.h @@ -35,6 +35,8 @@ class PROTO { bool Connect(uint32_t ip); bool Disconnect(uint32_t ip); + + size_t UserCount() const { return users.size(); } private: BLOWFISH_CTX ctx; struct sockaddr_in localAddr; -- 2.44.2