mirror of
https://codeberg.org/scip/diceware.git
synced 2025-12-17 19:00:57 +01:00
format
This commit is contained in:
23
dictfile.c
23
dictfile.c
@@ -35,24 +35,20 @@ int *incr_dicedigit(int *digits) {
|
|||||||
digits[2] = 100;
|
digits[2] = 100;
|
||||||
if (digits[1] == 6000) {
|
if (digits[1] == 6000) {
|
||||||
digits[1] = 1000;
|
digits[1] = 1000;
|
||||||
digits[0] += 10000; /* may overflow to 71111, must be catched by caller */
|
digits[0] +=
|
||||||
}
|
10000; /* may overflow to 71111, must be catched by caller */
|
||||||
else
|
} else
|
||||||
digits[1] += 1000;
|
digits[1] += 1000;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
digits[2] += 100;
|
digits[2] += 100;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
digits[3] += 10;
|
digits[3] += 10;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
digits[4]++;
|
digits[4]++;
|
||||||
|
|
||||||
return digits;
|
return digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int get_dicenum(int *digits) {
|
int get_dicenum(int *digits) {
|
||||||
/*
|
/*
|
||||||
get the actual number of an array of dice digits
|
get the actual number of an array of dice digits
|
||||||
@@ -103,15 +99,13 @@ char **fetch_dict(char *dictfile) {
|
|||||||
for (i = 0; i < 6666; i++)
|
for (i = 0; i < 6666; i++)
|
||||||
words[i] = NULL;
|
words[i] = NULL;
|
||||||
|
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
while ((linelen = getline(&line, &len, DICT)) != -1) {
|
while ((linelen = getline(&line, &len, DICT)) != -1) {
|
||||||
if (!dontjump) {
|
if (!dontjump) {
|
||||||
if (jump > 0) {
|
if (jump > 0) {
|
||||||
jump--;
|
jump--;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
jump = rand_lim(32);
|
jump = rand_lim(32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,7 +132,8 @@ char **fetch_dict(char *dictfile) {
|
|||||||
digits = incr_dicedigit(digits);
|
digits = incr_dicedigit(digits);
|
||||||
pos = get_dicenum(digits);
|
pos = get_dicenum(digits);
|
||||||
|
|
||||||
/* this is what pos gets next after 66666, which is max reachable with 5 dices */
|
/* this is what pos gets next after 66666, which is max reachable with 5
|
||||||
|
* dices */
|
||||||
if (pos == 71111)
|
if (pos == 71111)
|
||||||
break;
|
break;
|
||||||
} /* endif word 4<=>10 */
|
} /* endif word 4<=>10 */
|
||||||
|
|||||||
Reference in New Issue
Block a user