From 57fc463e30fb0ac3fc25a4523be252885a50e4b3 Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Sat, 4 Nov 2017 13:13:46 +0100 Subject: [PATCH] check for duplicate nicks when (#26) --- src/credit_manager.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/credit_manager.c b/src/credit_manager.c index 6654324..8766790 100644 --- a/src/credit_manager.c +++ b/src/credit_manager.c @@ -85,6 +85,7 @@ static void new_credit(void) { char name[NICKNAME_MAX_LEN + 1]; char *time; int credit; + int i; if (credits.num_items == MAX_CREDIT_ITEMS) { cprintf("\rEs ist bereits die maximale Anzahl an Eintr" aUML @@ -98,6 +99,15 @@ static void new_credit(void) { if (cgetn_input(name, sizeof(name)) == 0) return; + for (i = 0; i < credits.num_items; i++) { + if (strncmp(credits.credits[i].nickname, name, NICKNAME_MAX_LEN) != 0) { + continue; + } + cprintf("\rNickname existiert bereits, dr" uUML "cke RETURN...\r\n"); + cget_return(); + return; + } + cprintf("\r\nGuthaben in Cents:\r\n"); if ((credit = cget_number(0)) == 0) return; -- 2.39.5