7 #include "linenoise/linenoise.h"
10 struct game_t game = {
11 .dloc[1] = LOC_KINGHALL,
12 .dloc[2] = LOC_WESTBANK,
14 .dloc[4] = LOC_ALIKE3,
15 .dloc[5] = LOC_COMPLEX,
17 /* Sixth dwarf is special (the pirate). He always starts at his
18 * chest's eventual location inside the maze. This loc is saved
19 * in chloc for ref. The dead end in the other maze has its
20 * loc stored in chloc2. */
21 .dloc[6] = LOC_DEADEND12,
22 .chloc = LOC_DEADEND12,
23 .chloc2 = LOC_DEADEND13,
30 FILE *logfp = NULL, *rfp = NULL;
31 bool oldstyle = false;
35 int main(int argc, char *argv[])
38 char *savefilename = NULL;
44 const char* opts = "d:s:v:o:";
45 const char* usage = "Usage: %s [-d numdie] [-s numsaves] [-v version] -o savefilename \n";
46 while ((ch = getopt(argc, argv, opts)) != EOF) {
49 numdie = (long)atoi(optarg);
52 saved = (long)atoi(optarg);
55 version = (long)atoi(optarg);;
58 savefilename = optarg;
64 " -d number of deaths. Signed integer value.'\n");
66 " -s number of saves. Signed integer value.\n");
68 " -v version number of save format.\n");
70 " -o file name of save game to write.\n");
76 if (savefilename == NULL) {
80 "ERROR: filename required\n");
86 /* Initialize game variables */
89 make_zzword(game.zzword);
90 game.newloc = LOC_START;
92 game.limit = GAMELIMIT;
98 fp = fopen(savefilename, WRITE_MODE);
101 "Can't open file %s. Exiting.\n", savefilename);
105 savefile(fp, version);
107 printf("cheat: %s created.\n", savefilename);