~martijnbraam/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH among-sus v2] disallow duplicate names

~wenngle
Details
Message ID
<161091895642.21673.16025308298471131331-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +9 -0
From: wenngle <wenngle@disroot.org>

---
Thanks for the feedback. This fixes the issues raised with the first
patch.

 main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/main.c b/main.c
index 9a25284..e19162c 100644
--- a/main.c
+++ b/main.c
@@ -1223,6 +1223,7 @@ handle_input(int fd)
		players[pid].fd = -1;
		if (players[pid].stage != PLAYER_STAGE_NAME) {
			snprintf(buf, sizeof(buf), "Player [%s] disconnected.", players[pid].name);
			players[pid].name[0] = '\0';
			printf("Sending disconnection message\n");
			broadcast(buf, -1);
		}
@@ -1239,6 +1240,7 @@ handle_input(int fd)
		players[pid].fd = -1;
		if (players[pid].stage != PLAYER_STAGE_NAME) {
			snprintf(buf, sizeof(buf), "Player [%s] left the game.", players[pid].name);
			players[pid].name[0] = '\0';
			printf("Sending parting message\n");
			broadcast(buf, -1);
		}
@@ -1273,6 +1275,13 @@ handle_input(int fd)
				write(fd, buf, strlen(buf));
				return 0;
			}
			for (int i = 0; i < NUM_PLAYERS; i++) {
				if (strcmp(players[i].name, buf) == 0) {
					snprintf(buf, sizeof(buf), "Taken, pick another name\n> ");
					write(fd, buf, strlen(buf));
					return 0;
				}
			}
			for (size_t i = 0; i < strlen(buf); i++) {
				if(!isprint(buf[i])) {
					snprintf(buf, sizeof(buf), "Invalid char, pick another name\n> ");
-- 
2.26.2
Details
Message ID
<C8MI0GLASO8A.FMOZAFHPBS2A@monch>
In-Reply-To
<161091895642.21673.16025308298471131331-0@git.sr.ht> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Thanks!

To git@git.sr.ht:~martijnbraam/among-sus
   ef438e1..a663003  master -> master

Pushed with a minor fix (changing i's type to size_t)
Reply to thread Export thread (mbox)