Add -d option
This commit is contained in:
parent
c80162b467
commit
ff46cf7fac
3 changed files with 11 additions and 4 deletions
1
advent.h
1
advent.h
|
@ -200,6 +200,7 @@ struct settings_t {
|
|||
int argc;
|
||||
int optind;
|
||||
FILE *scriptfp;
|
||||
int debug;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
9
main.c
9
main.c
|
@ -1261,20 +1261,23 @@ int main(int argc, char *argv[])
|
|||
/* Options. */
|
||||
|
||||
#if defined ADVENT_AUTOSAVE
|
||||
const char* opts = "l:oa:";
|
||||
const char* opts = "dl:oa:";
|
||||
const char* usage = "Usage: %s [-l logfilename] [-o] [-a filename] [script...]\n";
|
||||
FILE *rfp = NULL;
|
||||
const char* autosave_filename = NULL;
|
||||
#elif !defined ADVENT_NOSAVE
|
||||
const char* opts = "l:or:";
|
||||
const char* opts = "dl:or:";
|
||||
const char* usage = "Usage: %s [-l logfilename] [-o] [-r restorefilename] [script...]\n";
|
||||
FILE *rfp = NULL;
|
||||
#else
|
||||
const char* opts = "l:o";
|
||||
const char* opts = "dl:o";
|
||||
const char* usage = "Usage: %s [-l logfilename] [-o] [script...]\n";
|
||||
#endif
|
||||
while ((ch = getopt(argc, argv, opts)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
settings.debug +=1;
|
||||
break;
|
||||
case 'l':
|
||||
settings.logfp = fopen(optarg, "w");
|
||||
if (settings.logfp == NULL)
|
||||
|
|
5
misc.c
5
misc.c
|
@ -699,7 +699,7 @@ bool tstbit(int mask, int bit)
|
|||
}
|
||||
|
||||
void set_seed(int32_t seedval)
|
||||
/* Set the LCG seed */
|
||||
/* Set the LCG1 seed */
|
||||
{
|
||||
game.lcg_x = seedval % LCG_M;
|
||||
if (game.lcg_x < 0) {
|
||||
|
@ -718,6 +718,9 @@ static int32_t get_next_lcg_value(void)
|
|||
{
|
||||
int32_t old_x = game.lcg_x;
|
||||
game.lcg_x = (LCG_A * game.lcg_x + LCG_C) % LCG_M;
|
||||
if (settings.debug) {
|
||||
printf("# random %d\n", old_x);
|
||||
}
|
||||
return old_x;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue