X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0b4df29c8f7c08adc5865dbac01051040e7d45e0..0f4172ffbddd7b51c80f388adc69c4601d230bf6:/projects/sgauthstress/proto.cpp?ds=sidebyside diff --git a/projects/sgauthstress/proto.cpp b/projects/sgauthstress/proto.cpp index 692c6946..d1114f17 100644 --- a/projects/sgauthstress/proto.cpp +++ b/projects/sgauthstress/proto.cpp @@ -134,7 +134,7 @@ return true; void PROTO::AddUser(const USER & user, bool connect) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); users.push_back(std::make_pair(user.GetIP(), user)); users.back().second.InitNetwork(); @@ -153,7 +153,7 @@ if (connect) bool PROTO::Connect(uint32_t ip) { std::list >::iterator it; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); it = std::find_if(users.begin(), users.end(), HasIP(ip)); if (it == users.end()) return false; @@ -166,7 +166,7 @@ return RealConnect(&it->second); bool PROTO::Disconnect(uint32_t ip) { std::list >::iterator it; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); it = std::find_if(users.begin(), users.end(), HasIP(ip)); if (it == users.end()) return false; @@ -182,7 +182,7 @@ while (running) { int res; { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); res = poll(&pollFds.front(), pollFds.size(), timeout); } if (res < 0) @@ -205,7 +205,7 @@ stopped = true; void PROTO::CheckTimeouts() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::list >::iterator it; for (it = users.begin(); it != users.end(); ++it) { @@ -230,7 +230,7 @@ bool PROTO::RecvPacket() bool result = true; std::vector::iterator it; std::list >::iterator userIt; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); for (it = pollFds.begin(), userIt = users.begin(); it != pollFds.end() && userIt != users.end(); ++it, ++userIt) { if (it->revents) @@ -389,11 +389,8 @@ bool PROTO::INFO_Proc(const void * buffer, USER * user) return true; } -bool PROTO::ERR_Proc(const void * buffer, USER * user) +bool PROTO::ERR_Proc(const void * /*buffer*/, USER * user) { -const ERR_8 * packet = static_cast(buffer); -const char * ptr = static_cast(buffer); - //uint32_t len = packet->len; #ifdef ARCH_BE @@ -510,9 +507,8 @@ hdr.protoVer[0] = 0; hdr.protoVer[1] = 8; // IA_PROTO_VER unsigned char buffer[2048]; -memset(buffer, 0, sizeof(buffer)); -memcpy(buffer, packet, length); memcpy(buffer, &hdr, sizeof(hdr)); +memcpy(buffer + sizeof(hdr), packet, length); size_t offset = sizeof(HDR_8); for (size_t i = 0; i < IA_LOGIN_LEN / 8; i++)