Fix for loops with no-op initialization

code-review-i
Dave Vandervies 5 years ago
parent d22c184965
commit 820be05b0d
  1. 10
      character.c

@ -21,8 +21,9 @@ int hp;
int dieroll(int num,int sides){ int dieroll(int num,int sides){
int total = 0; int total = 0;
for(num;num>0;num--){ while (num > 0) {
total = total + arc4random_uniform(sides)+1; total = total + arc4random_uniform(sides)+1;
num--;
} }
return total; return total;
} }
@ -60,10 +61,9 @@ void classProfs(unsigned long* classprofs, int count, int num){
classprofs[i]=local; classprofs[i]=local;
} }
//Grab the first N elements, based on the class's value, but first, if we have more profs than available profs, get some random ones //Grab the first N elements, based on the class's value, but first, if we have more profs than available profs, get some random ones
if(num > count){ while (num > count){
for(count;num > count;count--){ addProf(1lu << arc4random_uniform(18));
addProf(1lu << arc4random_uniform(18)); count--;
}
} }
for(int i=0;i<=num;i++){ for(int i=0;i<=num;i++){
addProf(classprofs[num]); addProf(classprofs[num]);

Loading…
Cancel
Save