From: Axel Wagner Date: Sat, 4 Nov 2017 12:13:46 +0000 (+0100) Subject: check for duplicate nicks when (#26) X-Git-Tag: rgb2rv17~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=57fc463e30fb0ac3fc25a4523be252885a50e4b3;p=c128-kasse check for duplicate nicks when (#26) --- 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;