From: matze Date: Sat, 28 Jul 2007 21:34:16 +0000 (+0000) Subject: merge X-Git-Tag: rgb2rv6~80 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6be276e20891d5ea6a013dcac76e7cf519fa225b;p=c128-kasse merge git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@29 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/config.c b/config.c index 6a76e6a..19c375d 100644 --- a/config.c +++ b/config.c @@ -15,6 +15,7 @@ struct credits_t credits[MAX_CREDIT_ITEMS+1]; #ifdef REAL_DATA void load_config(); + void load_items(){ FILE* f; char line[80]; @@ -30,10 +31,32 @@ void load_items(){ } +/** + * must be called after load_items() + */ void load_state(){ - status[0].times_sold=23; - status[1].times_sold=42; + FILE* f; + char line[80]; + char * sep; + char i, j; + f = fopen("state", "r"); + if (f==NULL){ + printf("cannot open state\n"); + return; + } + while (!feof(f)) { + fgets(line, 79, f); + sep = strchr(line, '='); + *(line + (sep-line)) = 0; + for (i=0; i< MAX_ITEMS; i++) { + if (strcmp(line, status[i].item_name)==0) { + status[i].times_sold = atoi(sep+1); + break; + } + } + } } + void save_state(){} void load_config() {