diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e8a51787a..3e820d6f7 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -167,28 +167,23 @@ void run_game_loop(unsigned int uMsg) nthread_ignore_mutex(FALSE); while (gbRunGame) { - diablo_color_cyc_logic(); - if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { - gbRunGameResult = FALSE; - gbRunGame = FALSE; - break; - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - bLoop = gbRunGame && nthread_has_500ms_passed(FALSE); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); - if (!bLoop) { - continue; + while (PeekMessage(&msg)) { + if (msg.message == WM_QUIT) { + gbRunGameResult = FALSE; + gbRunGame = FALSE; + break; } - } else if (!nthread_has_500ms_passed(FALSE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + if (!gbRunGame) + break; + if (!nthread_has_500ms_passed(FALSE)) { ProcessInput(); DrawAndBlit(); continue; } + diablo_color_cyc_logic(); multi_process_network_packets(); game_loop(gbGameLoopStartup); gbGameLoopStartup = FALSE; @@ -1692,25 +1687,7 @@ extern void plrctrls_after_game_logic(); void game_logic() { - if (PauseMode == 2) { - return; - } - if (PauseMode == 1) { - PauseMode = 2; - } - if (gbMaxPlayers == 1 && gmenu_exception()) { - force_redraw |= 1; - return; - } - - if (!gmenu_exception() && sgnTimeoutCurs == 0) { -#ifndef USE_SDL1 - finish_simulated_mouse_clicks(MouseX, MouseY); -#endif - CheckCursMove(); - plrctrls_after_check_curs_move(); - track_process(); - } + ProcessInput(); if (gbProcessPlayers) { ProcessPlayers(); } @@ -1766,19 +1743,13 @@ void timeout_cursor(BOOL bTimeout) void diablo_color_cyc_logic() { - DWORD tc; - - tc = GetTickCount(); - if (tc - color_cycle_timer >= 50) { - color_cycle_timer = tc; - if (palette_get_colour_cycling()) { - if (leveltype == DTYPE_HELL) { - lighting_color_cycling(); - } else if (leveltype == DTYPE_CAVES) { - //if (fullscreen) - palette_update_caves(); - } - } + if (!palette_get_colour_cycling()) + return; + + if (leveltype == DTYPE_HELL) { + lighting_color_cycling(); + } else if (leveltype == DTYPE_CAVES) { + palette_update_caves(); } } diff --git a/Source/interfac.cpp b/Source/interfac.cpp index c90437c4f..dedb091ea 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -13,7 +13,7 @@ void interface_msg_pump() { MSG Msg; - while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { + while (PeekMessage(&Msg)) { if (Msg.message != WM_QUIT) { TranslateMessage(&Msg); DispatchMessage(&Msg); diff --git a/Source/movie.cpp b/Source/movie.cpp index ff304908b..115c14876 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -18,7 +18,7 @@ void play_movie(char *pszMovie, BOOL user_can_close) SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); MSG Msg; while (video_stream && movie_playing) { - while (movie_playing && PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { + while (movie_playing && PeekMessage(&Msg)) { TranslateMessage(&Msg); switch (Msg.message) { case WM_KEYDOWN: diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 97153afac..7180fd083 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -195,7 +195,7 @@ void FocusOnCharInfo(); SHORT WINAPI GetAsyncKeyState(int vKey); -WINBOOL WINAPI PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg); +WINBOOL WINAPI PeekMessageA(LPMSG lpMsg); WINBOOL WINAPI TranslateMessage(const MSG *lpMsg); LRESULT WINAPI DispatchMessageA(const MSG *lpMsg); @@ -464,8 +464,6 @@ constexpr auto DVL_FILE_BEGIN = 0; constexpr auto DVL_FILE_CURRENT = 1; constexpr auto DVL_ERROR_FILE_NOT_FOUND = 2; -constexpr auto DVL_PM_NOREMOVE = 0x0000; -constexpr auto DVL_PM_REMOVE = 0x0001; constexpr auto DVL_WM_QUIT = 0x0012; constexpr auto DVL_INFINITE = 0xFFFFFFFF; diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index f217ef856..b346253d8 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -186,32 +186,32 @@ void selhero_CatToName(char *in_buf, char *out_buf, int cnt) strncat(out_buf, output.c_str(), cnt - strlen(out_buf)); } -bool UiFocusNavigation(SDL_Event *event) +void UiFocusNavigation(SDL_Event *event) { switch (GetMenuAction(*event)) { case MenuAction::SELECT: UiFocusNavigationSelect(); - return true; + return; case MenuAction::UP: UiFocus(SelectedItem - 1, UiItemsWraps); - return true; + return; case MenuAction::DOWN: UiFocus(SelectedItem + 1, UiItemsWraps); - return true; + return; case MenuAction::PAGE_UP: UiFocusPageUp(); - return true; + return; case MenuAction::PAGE_DOWN: UiFocusPageDown(); - return true; + return; case MenuAction::DELETE: UiFocusNavigationYesNo(); - return true; + return; case MenuAction::BACK: if (!gfnListEsc) break; UiFocusNavigationEsc(); - return true; + return; default: break; } @@ -252,7 +252,7 @@ bool UiFocusNavigation(SDL_Event *event) selhero_CatToName(clipboard, UiTextInput, UiTextInputLen); } } - return true; + return; #endif case SDLK_BACKSPACE: case SDLK_LEFT: { @@ -260,7 +260,7 @@ bool UiFocusNavigation(SDL_Event *event) if (nameLen > 0) { UiTextInput[nameLen - 1] = '\0'; } - return true; + return; } default: break; @@ -281,7 +281,7 @@ bool UiFocusNavigation(SDL_Event *event) #ifndef USE_SDL1 case SDL_TEXTINPUT: selhero_CatToName(event->text.text, UiTextInput, UiTextInputLen); - return true; + return; #endif default: break; @@ -294,10 +294,8 @@ bool UiFocusNavigation(SDL_Event *event) OutputToLogical(&event->button.x, &event->button.y); #endif if (UiItemMouseEvents(event, gUiItems, gUiItemCnt)) - return true; + return; } - - return false; } void UiHandleEvents(SDL_Event *event) diff --git a/SourceX/DiabloUI/diabloui.h b/SourceX/DiabloUI/diabloui.h index 5c45e7ba5..1a710750b 100644 --- a/SourceX/DiabloUI/diabloui.h +++ b/SourceX/DiabloUI/diabloui.h @@ -40,7 +40,7 @@ extern void (*gfnSoundFunction)(char *file); bool IsInsideRect(const SDL_Event &event, const SDL_Rect &rect); void UiFadeIn(); -bool UiFocusNavigation(SDL_Event *event); +void UiFocusNavigation(SDL_Event *event); void UiHandleEvents(SDL_Event *event); bool UiItemMouseEvents(SDL_Event *event, UiItem *items, std::size_t size); int GetCenterOffset(int w, int bw = 0); diff --git a/SourceX/DiabloUI/dialogs.cpp b/SourceX/DiabloUI/dialogs.cpp index 141afb4aa..14e9c5f7b 100644 --- a/SourceX/DiabloUI/dialogs.cpp +++ b/SourceX/DiabloUI/dialogs.cpp @@ -54,7 +54,7 @@ UiItem OK_DIALOG[] = { UiItem OK_DIALOG_WITH_CAPTION[] = { DIALOG_ART_L, - UiText(dialogText, SDL_Color { 255, 255, 0, 0 }, { 147, 110, 345, 20 }, UIS_CENTER), + UiText(dialogText, SDL_Color{ 255, 255, 0, 0 }, { 147, 110, 345, 20 }, UIS_CENTER), UiText(dialogCaption, { 147, 141, 345, 190 }, UIS_CENTER), MakeSmlButton("OK", &DialogActionOK, 264, 335), }; diff --git a/SourceX/DiabloUI/progress.cpp b/SourceX/DiabloUI/progress.cpp index 65e95a3df..c59119530 100644 --- a/SourceX/DiabloUI/progress.cpp +++ b/SourceX/DiabloUI/progress.cpp @@ -65,7 +65,8 @@ void progress_Render(BYTE progress) SDL_Rect dsc_rect = { static_cast(SCREEN_X + x + 50), static_cast(SCREEN_Y + y + 8), - SCREEN_WIDTH, SCREEN_HEIGHT }; + SCREEN_WIDTH, SCREEN_HEIGHT + }; if (SDL_BlitSurface(msgSurface, NULL, pal_surface, &dsc_rect) <= -1) { ErrSdl(); } @@ -118,4 +119,4 @@ BOOL UiProgressDialog(HWND window, char *msg, int enable, int (*fnfunc)(), int r return progress == 100; } -} +} // namespace dvl diff --git a/SourceX/DiabloUI/title.cpp b/SourceX/DiabloUI/title.cpp index 31de2b250..c86db113e 100644 --- a/SourceX/DiabloUI/title.cpp +++ b/SourceX/DiabloUI/title.cpp @@ -64,4 +64,4 @@ void UiSetSpawned(BOOL bSpawned) gbSpawned = bSpawned; } -} +} // namespace dvl diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index 17d31191c..3d2b52802 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -331,28 +331,12 @@ void BlurInventory() FocusOnCharInfo(); } -WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) +WINBOOL PeekMessageA(LPMSG lpMsg) { #ifdef __SWITCH__ HandleDocking(); #endif - if (wMsgFilterMin != 0) - UNIMPLEMENTED(); - if (wMsgFilterMax != 0) - UNIMPLEMENTED(); - if (hWnd != NULL) - UNIMPLEMENTED(); - - if (wRemoveMsg == DVL_PM_NOREMOVE) { - // This does not actually fill out lpMsg, but this is ok - // since the engine never uses it in this case - return !message_queue.empty() || SDL_PollEvent(NULL); - } - if (wRemoveMsg != DVL_PM_REMOVE) { - UNIMPLEMENTED(); - } - if (!message_queue.empty()) { *lpMsg = message_queue.front(); message_queue.pop_front(); @@ -364,7 +348,6 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter return false; } - lpMsg->hwnd = hWnd; lpMsg->message = 0; lpMsg->lParam = 0; lpMsg->wParam = 0; @@ -602,7 +585,6 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter WINBOOL TranslateMessage(const MSG *lpMsg) { - assert(lpMsg->hwnd == 0); if (lpMsg->message == DVL_WM_KEYDOWN) { int key = lpMsg->wParam; unsigned mod = (DWORD)lpMsg->lParam >> 16; @@ -705,7 +687,6 @@ SHORT GetAsyncKeyState(int vKey) LRESULT DispatchMessageA(const MSG *lpMsg) { DUMMY_ONCE(); - assert(lpMsg->hwnd == 0); assert(CurrentProc); // assert(CurrentProc == GM_Game);