2 * 'cheat' is a tool for generating save game files to test states that ought
3 * not happen. It leverages chunks of advent, mostly initialize() and
4 * savefile(), so we know we're always outputing save files that advent
14 bool oldstyle = false;
17 int main(int argc, char *argv[])
20 char *savefilename = NULL;
27 const char* opts = "d:s:v:o:";
28 const char* usage = "Usage: %s [-d numdie] [-s numsaves] [-v version] -o savefilename \n"
29 " -d number of deaths. Signed integer value.\n"
30 " -s number of saves. Signed integer value.\n"
31 " -v version number of save format.\n"
32 " -o required. File name of save game to write.\n";
34 while ((ch = getopt(argc, argv, opts)) != EOF) {
37 numdie = (long)atoi(optarg);
40 saved = (long)atoi(optarg);
43 version = (long)atoi(optarg);;
46 savefilename = optarg;
56 // Save filename required; the point of cheat is to generate save file
57 if (savefilename == NULL) {
61 "ERROR: filename required\n");
65 // Initialize game variables
72 fp = fopen(savefilename, WRITE_MODE);
75 "Can't open file %s. Exiting.\n", savefilename);
79 savefile(fp, version);
81 printf("cheat: %s created.\n", savefilename);