startup sequence and iflags values

early_init() calls decl_globals_init() which zeros out
a number structures:
    ZERO(flags);
    ZERO(iflags);
    ZERO(a11y);
    ZERO(disp);
    ZERO(u);
    ZERO(ubirthday);
    ZERO(urealtime);

Setting values in any of those during startup prior to
the early_init() call was futile, and the values would
get overwritten.

Such was the case with the setting of iflags.colorcount
during Windows startup, so do it after early_init() has
been called.
This commit is contained in:
nhmall
2024-03-25 22:30:08 -04:00
parent 875c83cc2c
commit 66f92ad182
2 changed files with 13 additions and 9 deletions

View File

@@ -997,10 +997,6 @@ tty_startup(int *wid, int *hgt)
*wid = console.width;
*hgt = console.height;
set_option_mod_status("mouse_support", set_in_game);
if (iflags.colorcount == 0) {
iflags.colorcount = 16777216;
// iflags.colorcount = 256;
}
}
void
@@ -2406,11 +2402,6 @@ void nethack_enter_consoletty(void)
#ifdef VIRTUAL_TERMINAL_SEQUENCES
char buf[BUFSZ], *bp, *localestr;
BOOL success;
if (iflags.colorcount == 0) {
iflags.colorcount = 16777216;
// iflags.colorcount = 256;
}
#endif /* VIRTUAL_TERMINAL_SEQUENCES */
#if 0
/* set up state needed by early_raw_print() */

View File

@@ -499,6 +499,9 @@ MAIN(int argc, char *argv[])
char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ];
char failbuf[BUFSZ];
int getlock_result = 0;
HWND hwnd;
HDC hdc;
int bpp;
#ifdef _MSC_VER
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
@@ -513,6 +516,16 @@ MAIN(int argc, char *argv[])
#endif /* WIN32CON */
early_init(argc, argv);
/* setting iflags.colorcount has to be after early_init()
* because it zeros out all of iflags */
hwnd = GetDesktopWindow();
hdc = GetDC(hwnd);
if (hdc) {
bpp = GetDeviceCaps(hdc, BITSPIXEL);
iflags.colorcount = (bpp >= 16) ? 16777216 : (bpp >= 8) ? 256 : 16;
ReleaseDC(hwnd, hdc);
}
#ifdef _MSC_VER
#ifdef DEBUG
/* set these appropriately for VS debugging */