Small improvements to fuzzer for NetHackW.

Can toggle fuzzer on/off using "Pause" key if attached to debugger.
Extended command selected randomly.
This commit is contained in:
Bart House
2018-12-15 14:49:59 -08:00
parent 1be3ad0ddc
commit 266b5e3891
7 changed files with 125 additions and 70 deletions

View File

@@ -689,14 +689,8 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
} break;
case MSNH_MSG_RANDOM_INPUT: {
char c = randomkey();
if (c == '\n')
PostMessage(hWnd, WM_COMMAND, MAKELONG(IDOK, 0), 0);
else if (c == '\033')
PostMessage(hWnd, WM_COMMAND, MAKELONG(IDCANCEL, 0), 0);
else
PostMessage(GetDlgItem(hWnd, IDC_TEXT_CONTROL), WM_CHAR, c, 0);
PostMessage(GetMenuControl(hWnd),
WM_MSNH_COMMAND, MSNH_MSG_RANDOM_INPUT, 0);
} break;
}
@@ -1601,6 +1595,7 @@ reset_menu_count(HWND hwndList, PNHMenuWindow data)
LRESULT CALLBACK
NHMenuListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hWndParent = GetParent(hWnd);
BOOL bUpdateFocusItem;
/* we will redraw focused item whenever horizontal scrolling occurs
@@ -1632,6 +1627,20 @@ NHMenuListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
SetFocus(GetNHApp()->hMainWnd);
}
return FALSE;
case WM_MSNH_COMMAND:
if (wParam == MSNH_MSG_RANDOM_INPUT) {
char c = randomkey();
if (c == '\n')
PostMessage(hWndParent, WM_COMMAND, MAKELONG(IDOK, 0), 0);
else if (c == '\033')
PostMessage(hWndParent, WM_COMMAND, MAKELONG(IDCANCEL, 0), 0);
else
PostMessage(hWnd, WM_CHAR, c, 0);
return 0;
}
break;
}
/* update focused item */
@@ -1659,6 +1668,7 @@ NHMenuListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK
NHMenuTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hWndParent = GetParent(hWnd);
HDC hDC;
RECT rc;
@@ -1686,8 +1696,7 @@ NHMenuTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
&& (si.nPos + (int) si.nPage) <= (si.nMax - si.nMin))
SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0);
else
PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0),
0);
PostMessage(hWndParent, WM_COMMAND, MAKELONG(IDOK, 0), 0);
return 0;
}
case VK_NEXT:
@@ -1726,6 +1735,20 @@ NHMenuTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SETFOCUS:
HideCaret(hWnd);
return 0;
case WM_MSNH_COMMAND:
if (wParam == MSNH_MSG_RANDOM_INPUT) {
char c = randomkey();
if (c == '\n')
PostMessage(hWndParent, WM_COMMAND, MAKELONG(IDOK, 0), 0);
else if (c == '\033')
PostMessage(hWndParent, WM_COMMAND, MAKELONG(IDCANCEL, 0), 0);
else
PostMessage(hWnd, WM_CHAR, c, 0);
return 0;
}
break;
}
if (editControlWndProc)