From 51572fef9856af0df7891ae5278560bb58960449 Mon Sep 17 00:00:00 2001 From: Wirlaburla Date: Sat, 23 Sep 2023 11:23:35 -0500 Subject: [PATCH] Increase username sizes to fix long usernames being cut off. --- src/client.h | 4 ++-- src/main.cpp | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/client.h b/src/client.h index 6cb0c01..928f4a3 100644 --- a/src/client.h +++ b/src/client.h @@ -32,8 +32,8 @@ char* room = "GroundZero#Reception"; char* dimension = "dimension-1"; uint16_t roomID = 1; -char login_username[16]; -char login_password[16]; +char login_username[32]; +char login_password[32]; uint16_t xPos = 0; uint16_t yPos = 0; diff --git a/src/main.cpp b/src/main.cpp index 8ec33de..116e4e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -129,7 +129,7 @@ int main(int argc, char const* argv[]) { if (aRecv_t.joinable()) aRecv_t.detach(); wsend(autosock, new unsigned char[] {0x03, 0x01, CMD_SESSEXIT}, 0); } else if (strcmp(cmd, "login") == 0) { - char username[16] = {0}; j = 0; + char username[32] = {0}; j = 0; while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x20) { username[j++] = s; } @@ -188,7 +188,7 @@ int main(int argc, char const* argv[]) { subcmd[j++] = 0; if (strcmp(subcmd, "add") == 0) { - char *username = new char[16]; j = 0; + char *username = new char[32]; j = 0; while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x00) { username[j++] = s; } @@ -218,7 +218,7 @@ int main(int argc, char const* argv[]) { wprintw(wlog, "\n*%s is already your friend!", username); } } else if (strcmp(subcmd, "del") == 0) { - char *username = new char[16]; j = 0; + char *username = new char[32]; j = 0; while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x00) { username[j++] = s; } @@ -263,7 +263,7 @@ int main(int argc, char const* argv[]) { subcmd[j++] = 0; if (strcmp(subcmd, "add") == 0) { - char *username = new char[16]; j = 0; + char *username = new char[32]; j = 0; while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x00) { username[j++] = s; } @@ -282,7 +282,7 @@ int main(int argc, char const* argv[]) { wprintw(wlog, "\n*%s is already muted.", username); } } else if (strcmp(subcmd, "del") == 0) { - char *username = new char[16]; j = 0; + char *username = new char[32]; j = 0; while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x00) { username[j++] = s; } @@ -491,7 +491,7 @@ void reciever(int sock_fd, bool autoserver = false) { readPropertyList(bufin); } else if (bufin[p+2] == CMD_CHATMSG && bufin[p+1] == 0x01) { bool muted = false; - char *username = new char[16]; + char *username = new char[32]; char *message = new char[250]; int offs = p+3; offs++; // Ignore empty byte @@ -511,7 +511,7 @@ void reciever(int sock_fd, bool autoserver = false) { } } else if (bufin[p+2] == CMD_WHISPER && bufin[p+1] == 0x01) { int muted = false; - char *username = new char[16]; + char *username = new char[32]; char *message; int offs = p+3; offs++; // Ignore empty byte @@ -537,7 +537,7 @@ void reciever(int sock_fd, bool autoserver = false) { userEnter(bufin[p+t]); } } else if (bufin[p+2] == CMD_REGOBJID && bufin[p+1] == 0xff) { - char *longID = new char[16]; + char *longID = new char[32]; int shortID; int offs = p+3; int long_len = bufin[offs++]; @@ -553,8 +553,8 @@ void reciever(int sock_fd, bool autoserver = false) { close(sock_fd); if (autoserver) { wprintw(wlog, "\n*Logged out of %s.", login_username); - login_username[0] = 0; - + memset(&(login_password[0]), 0, sizeof(login_password)); + // Clear properties.erase(properties.begin(), properties.end()); objects.erase(objects.begin(), objects.end()); @@ -635,7 +635,7 @@ void reciever(int sock_fd, bool autoserver = false) { } teleport(sock_fd, xPos, yPos, zPos, rot); } else if (bufin[p+2] == CMD_BUDDYNTF && bufin[p+1] == 0x01) { - char* username = new char[24]; + char* username = new char[32]; int offs = p+3; int username_len = bufin[offs++]; memcpy(username, &bufin[offs], username_len);