fixed invalid_username formatting
This commit is contained in:
parent
5873d55d98
commit
82df5f5b1c
@ -394,12 +394,6 @@ void *why2_communicate_thread(void *arg)
|
|||||||
|
|
||||||
while (invalid_username)
|
while (invalid_username)
|
||||||
{
|
{
|
||||||
if (usernames_n++ == WHY2_MAX_USERNAME_TRIES) //ASKED CLIENT WAY TOO FUCKING MANY TIMES FOR USERNAME, KICK HIM
|
|
||||||
{
|
|
||||||
exiting = 1;
|
|
||||||
goto deallocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((raw = read_user(connection, &raw_ptr)) == NULL) //READ
|
if ((raw = read_user(connection, &raw_ptr)) == NULL) //READ
|
||||||
{
|
{
|
||||||
force_exiting = 1; //FAILURE
|
force_exiting = 1; //FAILURE
|
||||||
@ -437,6 +431,12 @@ void *why2_communicate_thread(void *arg)
|
|||||||
why2_deallocate(raw);
|
why2_deallocate(raw);
|
||||||
why2_deallocate(raw_ptr);
|
why2_deallocate(raw_ptr);
|
||||||
|
|
||||||
|
if (++usernames_n == WHY2_MAX_USERNAME_TRIES) //ASKED CLIENT WAY TOO FUCKING MANY TIMES FOR USERNAME, KICK HIM
|
||||||
|
{
|
||||||
|
exiting = 1;
|
||||||
|
goto deallocation;
|
||||||
|
}
|
||||||
|
|
||||||
if (invalid_username)
|
if (invalid_username)
|
||||||
{
|
{
|
||||||
why2_send_socket(WHY2_CHAT_CODE_INVALID_USERNAME, WHY2_CHAT_SERVER_USERNAME, connection); //TELL THE USER HE IS DUMB AS FUCK
|
why2_send_socket(WHY2_CHAT_CODE_INVALID_USERNAME, WHY2_CHAT_SERVER_USERNAME, connection); //TELL THE USER HE IS DUMB AS FUCK
|
||||||
@ -478,6 +478,8 @@ void *why2_communicate_thread(void *arg)
|
|||||||
|
|
||||||
send_to_all(raw); //FUCKING SEND TO ALL YOU TWAT
|
send_to_all(raw); //FUCKING SEND TO ALL YOU TWAT
|
||||||
|
|
||||||
|
why2_send_socket(WHY2_CHAT_CODE_ACCEPT_MESSAGES, WHY2_CHAT_SERVER_USERNAME, connection); //TELL USER HE CAN START COMMUNICATING
|
||||||
|
|
||||||
why2_deallocate(raw);
|
why2_deallocate(raw);
|
||||||
why2_deallocate(connection_message);
|
why2_deallocate(connection_message);
|
||||||
why2_deallocate(username);
|
why2_deallocate(username);
|
||||||
@ -638,6 +640,7 @@ void *why2_listen_server(void *socket)
|
|||||||
{
|
{
|
||||||
char *read = NULL;
|
char *read = NULL;
|
||||||
why2_bool exiting = 0;
|
why2_bool exiting = 0;
|
||||||
|
why2_bool asking_username = 0;
|
||||||
|
|
||||||
printf(">>> ");
|
printf(">>> ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -652,16 +655,24 @@ void *why2_listen_server(void *socket)
|
|||||||
{
|
{
|
||||||
if (strcmp(read + 8, WHY2_CHAT_CODE_SSQC) == 0)
|
if (strcmp(read + 8, WHY2_CHAT_CODE_SSQC) == 0)
|
||||||
{
|
{
|
||||||
printf("%s\nServer closed the connection.\n", WHY2_CLEAR_AND_GO_UP);
|
printf("%s%s\nServer closed the connection.\n", WHY2_CLEAR_AND_GO_UP WHY2_CLEAR_AND_GO_UP, (!asking_username ? "\n": ""));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
pthread_cancel(getline_thread); //CANCEL CLIENT getline
|
pthread_cancel(getline_thread); //CANCEL CLIENT getline
|
||||||
exiting = 1; //EXIT THIS THREAD
|
exiting = 1; //EXIT THIS THREAD
|
||||||
|
} else if (strcmp(read + 8, WHY2_CHAT_CODE_ACCEPT_MESSAGES) == 0) //PICK USERNAME
|
||||||
|
{
|
||||||
|
asking_username = 0;
|
||||||
|
//goto continue_input;
|
||||||
} else if (strcmp(read + 8, WHY2_CHAT_CODE_PICK_USERNAME) == 0) //PICK USERNAME
|
} else if (strcmp(read + 8, WHY2_CHAT_CODE_PICK_USERNAME) == 0) //PICK USERNAME
|
||||||
{
|
{
|
||||||
|
username_pick:
|
||||||
|
|
||||||
printf("%sEnter username (a-Z, 0-9; %d-%d characters):\n", WHY2_CLEAR_AND_GO_UP, WHY2_MIN_USERNAME_LENGTH, WHY2_MAX_USERNAME_LENGTH);
|
printf("%sEnter username (a-Z, 0-9; %d-%d characters):\n", WHY2_CLEAR_AND_GO_UP, WHY2_MIN_USERNAME_LENGTH, WHY2_MAX_USERNAME_LENGTH);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
asking_username = 1;
|
||||||
|
|
||||||
goto continue_input;
|
goto continue_input;
|
||||||
} else if (strcmp(read + 8, WHY2_CHAT_CODE_INVALID_COMMAND) == 0) //PICK USERNAME
|
} else if (strcmp(read + 8, WHY2_CHAT_CODE_INVALID_COMMAND) == 0) //PICK USERNAME
|
||||||
{
|
{
|
||||||
@ -674,7 +685,7 @@ void *why2_listen_server(void *socket)
|
|||||||
printf("\nInvalid username!\n\n\n");
|
printf("\nInvalid username!\n\n\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
goto continue_input;
|
goto username_pick;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user