/* various code that was replicated in *main.c */
#include "hack.h"
+#include <ctype.h>
#ifndef NO_SIGNAL
#include <signal.h>
#endif
STATIC_DCL void FDECL(regen_hp, (int));
STATIC_DCL void FDECL(interrupt_multi, (const char *));
+STATIC_DCL void FDECL(debug_fields, (const char *));
void
moveloop(resuming)
*/
static struct early_opt earlyopts[] = {
- {ARG_DEBUG, "debug", 5, FALSE},
+ {ARG_DEBUG, "debug", 5, TRUE},
{ARG_VERSION, "version", 4, TRUE},
};
-boolean
+/*
+ * Returns:
+ * 0 = no match
+ * 1 = found and skip past this argument
+ * 2 = found and trigger immediate exit
+ */
+
+int
argcheck(argc, argv, e_arg)
int argc;
char *argv[];
if ((idx >= SIZE(earlyopts)) || (argc <= 1))
return FALSE;
- for (i = 1; i < argc; ++i) {
+ for (i = 0; i < argc; ++i) {
if (argv[i][0] != '-')
continue;
if (argv[i][1] == '-') {
}
if (match) {
+ const char *extended_opt = index(userea,':');
+
+ if (!extended_opt)
+ extended_opt = index(userea, '=');
switch(e_arg) {
case ARG_DEBUG:
+ if (extended_opt) {
+ extended_opt++;
+ debug_fields(extended_opt);
+ }
+ return 1;
break;
case ARG_VERSION: {
boolean insert_into_pastebuf = FALSE;
- const char *extended_opt = index(userea,':');
-
- if (!extended_opt)
- extended_opt = index(userea, '=');
if (extended_opt) {
extended_opt++;
}
}
early_version_info(insert_into_pastebuf);
- return TRUE;
+ return 2;
break;
}
default:
return FALSE;
}
+/*
+ * These are internal controls to aid developers with
+ * testing and debugging particular aspects of the code.
+ * They are not player options and the only place they
+ * are documented is right here. No gameplay is altered.
+ *
+ * test - test whether this parser is working
+ * ttystatus - TTY:
+ * immediateflips - WIN32: turn off display performance
+ * optimization so that display output
+ * can be debugged without buffering.
+ */
+void
+debug_fields(opts)
+const char *opts;
+{
+ char *op;
+ boolean negated = FALSE;
+ boolean retval = TRUE;
+
+ while ((op = index(opts, ',')) != 0) {
+ *op++ = 0;
+ /* recurse */
+ debug_fields(op);
+ }
+ if (strlen(opts) > BUFSZ / 2)
+ return;
+
+
+ /* strip leading and trailing white space */
+ while (isspace((uchar) *opts))
+ opts++;
+ op = eos((char *) opts);
+ while (--op >= opts && isspace((uchar) *op))
+ *op = '\0';
+
+ if (!*opts) {
+ /* empty */
+ return;
+ }
+ while ((*opts == '!') || !strncmpi(opts, "no", 2)) {
+ if (*opts == '!')
+ opts++;
+ else
+ opts += 2;
+ negated = !negated;
+ }
+ if (match_optname(opts, "test", 4, FALSE))
+ iflags.debug.test = negated ? FALSE : TRUE;
+#ifdef TTY_GRAPHICS
+ if (match_optname(opts, "ttystatus", 9, FALSE))
+ iflags.debug.ttystatus = negated ? FALSE : TRUE;
+#endif
+#ifdef WIN32
+ if (match_optname(opts, "immediateflips", 14, FALSE))
+ iflags.debug.immediateflips = negated ? FALSE : TRUE;
+#endif
+ return;
+}
/*allmain.c*/
Strcpy(hackdir, HACKDIR);
#endif
if (argc > 1) {
- if (argcheck(argc, argv, ARG_VERSION))
+ if (argcheck(argc, argv, ARG_VERSION) == 2)
nethack_exit(EXIT_SUCCESS);
+ if (argcheck(argc, argv, ARG_DEBUG) == 1) {
+ argc--;
+ argv++;
+ }
+
if (!strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
/* avoid matching "-dec" for DECgraphics; since the man page
* says -d directory, hope nobody's using -desomething_else
dir = nh_getenv("HACKDIR");
if (argc > 1) {
- if (argcheck(argc, argv, ARG_VERSION))
+ if (argcheck(argc, argv, ARG_VERSION) == 2)
exit(EXIT_SUCCESS);
+ if (argcheck(argc, argv, ARG_DEBUG) == 1) {
+ argc--;
+ argv++;
+ }
+
if (!strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
/* avoid matching "-dec" for DECgraphics; since the man page
* says -d directory, hope nobody's using -desomething_else
static boolean buffer_flipping_initialized = FALSE;
-boolean do_immediate_flips = FALSE;
-
static void check_buffer_size(int width, int height);
static cell_t * buffer_get_cell(console_buffer_t * buffer, int x, int y);
while (dst != sentinel)
*dst++ = clear_cell;
- if (do_immediate_flips && buffer == &back_buffer)
+ if (iflags.debug.immediateflips && buffer == &back_buffer)
back_buffer_flip();
}
cell_t * dst = buffer_get_cell(&back_buffer, x, y);
*dst = *cell;
- if (do_immediate_flips)
+ if (iflags.debug.immediateflips)
back_buffer_flip();
}
while (cell != sentinel)
*cell++ = clear_cell;
- if (do_immediate_flips)
+ if (iflags.debug.immediateflips)
back_buffer_flip();
}