static void game_usage_info(void) { int i, wid, hgt, circumf, lat, lon, pergame, perside, perturn; const char *varid; char buf[BUFSIZE]; Variant *var; Obj *vardflt; printf("\nGame variant options"); if (mainmodule == NULL) { printf(":\n\n No game loaded, no information available.\n\n"); return; } printf(" for \"%s\":\n\n", mainmodule->name); if (mainmodule->variants == NULL) { printf(" No variants available.\n\n"); return; } for (i = 0; mainmodule->variants[i].id != lispnil; ++i) { var = &(mainmodule->variants[i]); varid = c_string(var->id); vardflt = var->dflt; switch (keyword_code(varid)) { case K_SEE_ALL: printf(" -V\t\t\t%s (default %s)\n", var->help, (vardflt == lispnil ? "true" : (c_number(eval(vardflt)) ? "true" : "false"))); break; case K_SEQUENTIAL: printf(" -seq\t\t%s (default %s)\n", var->help, (vardflt == lispnil ? "false" : (c_number(eval(vardflt)) ? "false" : "true"))); printf(" -sim\t\tSides move simultaneously (opposite of -seq)\n"); break; case K_WORLD_SEEN: printf(" -v\t\t\t%s (default %s)\n", var->help, (vardflt == lispnil ? "true" : (c_number(eval(vardflt)) ? "true" : "false"))); break; case K_WORLD_SIZE: printf(" -M wid[xhgt][Wcircumf][+lat][+long]\tset world size (default "); /* Note that if the game definition sets these values directly using world or area forms, this is misleading; but that's the fault of the game designer for including both preset values and a variant whose defaults don't match those presets. */ circumf = DEFAULTCIRCUMFERENCE; wid = DEFAULTWIDTH; hgt = DEFAULTHEIGHT; lat = lon = 0; /* Pick the width and height out of the list. */ if (vardflt != lispnil) { wid = c_number(eval(car(vardflt))); vardflt = cdr(vardflt); } if (vardflt != lispnil) { hgt = c_number(eval(car(vardflt))); vardflt = cdr(vardflt); } else { hgt = wid; } /* Pick up a circumference etc if given. */ if (vardflt != lispnil) { circumf = c_number(eval(car(vardflt))); vardflt = cdr(vardflt); } if (vardflt != lispnil) { lat = c_number(eval(car(vardflt))); vardflt = cdr(vardflt); } if (vardflt != lispnil) { lon = c_number(eval(car(vardflt))); } printf("%dx%dW%d", wid, hgt, circumf); if (lat != 0 || lon != 0) printf("+%d+%d", lat, lon); printf(")\n"); break; case K_REAL_TIME: pergame = perside = perturn = 0; if (vardflt != lispnil) { pergame = c_number(eval(car(vardflt))); vardflt = cdr(vardflt); } if (vardflt != lispnil) { perside = c_number(eval(car(vardflt))); vardflt = cdr(vardflt); } if (vardflt != lispnil) { perturn = c_number(eval(car(vardflt))); } printf(" -tgame mins\t\tlimit game time to <mins> minutes (default %d)\n", pergame); printf(" -tside mins\t\tlimit each player <mins> minutes in all (default %d)\n", perside); printf(" -tturn mins\t\tlimit each turn to <mins> minutes (default %d)\n", perturn); break; default: printf(" -v%s[=value]\t%s (default ", varid, var->help); if (vardflt == lispnil || (numberp(vardflt) && c_number(vardflt) == 0)) { printf("false"); } else if (numberp(vardflt) && c_number(vardflt) == 1) { printf("true"); } else { sprintlisp(buf, vardflt, BUFSIZE); printf("%s", buf); } printf(")\n"); break; } } }
void syntax_error(Obj *x, char *msg) { sprintlisp(readerrbuf, x, BUFSIZE); init_warning("syntax error in `%s' - %s", readerrbuf, msg); }