ShopSystem::ShopSystem() { LoadShop("Text//Upgrades.txt", upgrades); selectedUpgrade = upgrades.begin(); }
void LoadNPCList() { int i = 0; int j = 0; int k = 0; FILE *file; char *c; char buf[512]; file = fopen("system/npclist.def","r"); if(file == NULL) { fprintf(stderr,"Unable to open npc file\n"); return; } memset(&NPCList,0,sizeof(NPCList)); i = 0; j = 0; k = 0; NumNPCS = 0; while(fscanf(file, "%s", buf) != EOF) { if(strcmp(buf,"#") ==0) { fgets(buf, sizeof(buf), file); continue;/*ignore the rest of the line.*/ } if(strcmp(buf,"</NPC>") ==0) { i++; NumNPCS++; if(i >= MAXNPCS) { fprintf(stderr,"maximum number of NPCS loaded from file!\n"); return; } continue; } if(strcmp(buf,"<NPC>") ==0) { fgetc(file); /*clear the space before the word*/ fgets(NPCList[i].name, 80, file); c = strchr(NPCList[i].name, '\n'); if(c != NULL) *c = '\0'; /*replace trailing return with terminating character*/ continue; } if(strcmp(buf,"<monster>") ==0) { fgetc(file); /*clear the space before the word*/ fgets(NPCList[i].monster, 80, file); c = strchr(NPCList[i].monster, '\n'); if(c != NULL) *c = '\0'; /*replace trailing return with terminating character*/ continue; } if(strcmp(buf,"<questlist>") ==0) { LoadQuest(file,i); continue; } if(strcmp(buf,"<shoplist>") ==0) { LoadShop(file,i); continue; } if(strcmp(buf,"<dialoglist>") ==0) { LoadDialog(file,i); continue; } } fclose(file); }