Populate mods before we use it

While we're here, otherprofs[] doesn't need to be fully zeroed to
be a valid empty string.
code-review-i
Dave Vandervies 4 years ago
parent 820be05b0d
commit 59d1a2921e
  1. 12
      character.c

@ -333,19 +333,17 @@ void genBackground(){
}
size_t genChar(char* output, size_t maxlen){
int i;
profs = 0;
languages = 0;
for(int i = 0; i <= 100; i++){
otherprofs[i] = '\0';
}
int i;
genRace();
genClass();
genBackground();
otherprofs[0] = '\0';
for(i=0; i < 6; i++){
stats[i] = dieroll(3,6);
mods[i] = (stats[i]/2)-5;
}
genRace();
genClass();
genBackground();
snprintf(output, maxlen, "Race = %s\r\nBackground = %s\r\nClass = %s\r\nStr = %d %d\r\nDex = %d %d\r\nCon = %d %d\r\nInt = %d %d\r\nWis = %d %d\r\nCha = %d %d\r\n\r\nHP: %d\r\n", race, background, class, stats[STR], mods[STR], stats[DEX], mods[DEX], stats[CON], mods[CON], stats[INT], mods[INT], stats[WIS], mods[WIS], stats[CHA], mods[CHA], hp);

Loading…
Cancel
Save