cprintf("\r\nn) Neu d) Loeschen p) Einzahlen b) Seite hoch f) Seite runter\r\ng) Filtern e) Aendern s) Speichern z) Zurueck\r\n");
}
-static struct credits_t *find_credit(char *name){
+struct credits_t *find_credit(char *name){
int i;
for (i = 0; i < credits.num_items; i++)
- if (strncasecmp(name, credits.credits[i].nickname, 11) == 0)
+ if (strncmp(name, credits.credits[i].nickname, 11) == 0)
return &credits.credits[i];
return NULL;
}
BYTE c, nickname_len;
int einheiten;
char *nickname;
+ struct credits_t *credit;
if (status.status[n].item_name == NULL) {
cprintf("FEHLER: Diese Einheit existiert nicht.\r\n");
nickname_len = strlen(nickname);
/* go through credits and remove the amount of money or set nickname
* to NULL if no such credit could be found */
- for (c = 0; c < credits.num_items; ++c)
- if (strncmp(nickname, credits.credits[c].nickname, nickname_len) == 0) {
- if ((signed int)credits.credits[c].credit < ((signed int)status.status[n].price * einheiten)) {
- cprintf("Sorry, %s hat nicht genug Geld :-(\r\n", nickname);
- return;
- }
- /* Geld abziehen */
- credits.credits[c].credit -= (status.status[n].price * einheiten);
- cprintf("\r\nVerbleibendes Guthaben fuer %s: %d Cents. Druecke RETURN...\r\n",
- nickname, credits.credits[c].credit);
- toggle_videomode();
- cprintf("\r\nDein verbleibendes Guthaben betraegt %d Cents.\r\n", credits.credits[c].credit);
- toggle_videomode();
- get_input();
- matches++;
- break;
+ credit = find_credit(nickname);
+ if (credit != NULL) {
+ if ((signed int)credit->credit < ((signed int)status.status[n].price * einheiten)) {
+ cprintf("Sorry, %s hat nicht genug Geld :-(\r\n", nickname);
+ return;
}
- if (matches == 0) {
+ /* Geld abziehen */
+ credit->credit -= (status.status[n].price * einheiten);
+ cprintf("\r\nVerbleibendes Guthaben fuer %s: %d Cents. Druecke RETURN...\r\n",
+ nickname, credit->credit);
+ toggle_videomode();
+ cprintf("\r\nDein verbleibendes Guthaben betraegt %d Cents.\r\n", credit->credit);
+ toggle_videomode();
+ get_input();
+ matches++;
+ } else {
cprintf("\r\nNickname nicht gefunden in der Guthabenverwaltung! Abbruch, druecke RETURN...\r\n");
get_input();
return;