Merge branch 'master' of github.com:brmlab/brmbar

This commit is contained in:
Pavol Rusnak 2011-04-22 04:30:13 +02:00
commit dd772c2ea3

View file

@ -18,13 +18,15 @@ int modify_credit(name, price)
person_data = fopen(filename, "r"); person_data = fopen(filename, "r");
if (person_data == NULL) { if (person_data == NULL) {
printf("Warning: Filename %s does not exist! Creating...\n", filename); printf("Warning: Filename %s does not exist!\n", filename);
credit = 0; credit = 0;
} else { } else {
fscanf(person_data, "%i", &credit); fscanf(person_data, "%i", &credit);
fclose(person_data); fclose(person_data);
} }
// Write only if the price would change credit
if (price != 0) {
credit += price; credit += price;
person_data = fopen(filename, "w"); person_data = fopen(filename, "w");
if (person_data == NULL) { if (person_data == NULL) {
@ -33,6 +35,7 @@ int modify_credit(name, price)
fprintf(person_data, "%i", credit); fprintf(person_data, "%i", credit);
fclose(person_data); fclose(person_data);
} }
}
return credit; return credit;
} }