From: Maxim Mamontov Date: Tue, 10 May 2011 12:53:32 +0000 (+0300) Subject: Fix some types and add UserCount method to PROTO X-Git-Tag: 2.407-p1~17 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/7897474c8a3fb975cc0bcda45e40c47d58959ea6?ds=inline Fix some types and add UserCount method to PROTO --- 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;