From 418339320427488f2084acbeaf5cbe30d78ee9c0 Mon Sep 17 00:00:00 2001 From: Mark Olsen Date: Tue, 19 Mar 2024 10:35:43 +0000 Subject: [PATCH] Added a define for activating support for 'new' video code. Vanilla Conquer had internal changes to how it handled frame rendering when SDL support was added. This code is only active for SDL builds, and not for builds with the legacy Windows video code enabled. However, this code should be used for all new video code implementations and not just SDL, so hiding it behind the SDL_BUILD is misleading and also makes it harder to add support for other platforms. Changed the compile time checks for SDL_BUILD into NEW_VIDEO_BUILD where those checks guard code that is not SDL-specific. --- common/CMakeLists.txt | 4 ++-- common/framelimit.cpp | 6 +++--- common/wwmouse.cpp | 14 +++++++------- redalert/globals.cpp | 2 +- redalert/startup.cpp | 2 +- tiberiandawn/startup.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index f6042f1e..03cd6e3e 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -198,10 +198,10 @@ if(BUILD_VANILLATD OR BUILD_VANILLARA) target_compile_definitions(commonv PUBLIC OPENAL_BUILD) endif() if(SDL2) - target_compile_definitions(commonv PUBLIC SDL_BUILD SDL2_BUILD) + target_compile_definitions(commonv PUBLIC SDL_BUILD SDL2_BUILD NEW_VIDEO_BUILD) endif() if(SDL1) - target_compile_definitions(commonv PUBLIC SDL_BUILD SDL1_BUILD) + target_compile_definitions(commonv PUBLIC SDL_BUILD SDL1_BUILD NEW_VIDEO_BUILD) endif() if(NETWORKING) target_compile_definitions(commonv PUBLIC WINSOCK_IPX NETWORKING) diff --git a/common/framelimit.cpp b/common/framelimit.cpp index 64105dcd..2a46e076 100644 --- a/common/framelimit.cpp +++ b/common/framelimit.cpp @@ -11,14 +11,14 @@ extern WWMouseClass* WWMouse; -#ifdef SDL_BUILD +#ifdef NEW_VIDEO_BUILD void Video_Render_Frame(); #endif void Frame_Limiter(FrameLimitFlags flags) { static auto frame_start = std::chrono::steady_clock::now(); -#ifdef SDL_BUILD +#ifdef NEW_VIDEO_BUILD static auto render_avg = 0; auto render_start = std::chrono::steady_clock::now(); @@ -43,7 +43,7 @@ void Frame_Limiter(FrameLimitFlags flags) #endif if (Settings.Video.FrameLimit > 0 && !(flags & FrameLimitFlags::FL_NO_BLOCK)) { -#ifdef SDL_BUILD +#ifdef NEW_VIDEO_BUILD auto frame_end = render_end; #else auto frame_end = std::chrono::steady_clock::now(); diff --git a/common/wwmouse.cpp b/common/wwmouse.cpp index 43d8fcc3..a61877dc 100644 --- a/common/wwmouse.cpp +++ b/common/wwmouse.cpp @@ -164,7 +164,7 @@ void WWMouseClass::Unblock_Mouse(GraphicBufferClass* buffer) void WWMouseClass::Process_Mouse(void) { -#if !defined(REMASTER_BUILD) && !defined(SDL_BUILD) +#if !defined(REMASTER_BUILD) && !defined(NEW_VIDEO_BUILD) int x, y; // @@ -288,7 +288,7 @@ void* WWMouseClass::Set_Cursor(int xhotspot, int yhotspot, void* cursor) void WWMouseClass::Low_Hide_Mouse() { // ST - 1/3/2019 10:50AM -#if !defined(REMASTER_BUILD) && !defined(SDL_BUILD) +#if !defined(REMASTER_BUILD) && !defined(NEW_VIDEO_BUILD) if (!State) { if (MouseBuffX != -1 || MouseBuffY != -1) { if (Screen->Lock()) { @@ -322,7 +322,7 @@ void WWMouseClass::Low_Show_Mouse(int x, int y) State--; // ST - 1/3/2019 10:50AM -#if !defined(REMASTER_BUILD) && !defined(SDL_BUILD) +#if !defined(REMASTER_BUILD) && !defined(NEW_VIDEO_BUILD) // // If the mouse is completely visible then draw it at its current @@ -450,7 +450,7 @@ void WWMouseClass::Conditional_Show_Mouse(void) void WWMouseClass::Draw_Mouse(GraphicViewPortClass* scr) { -#if defined(REMASTER_BUILD) || defined(SDL_BUILD) +#if defined(REMASTER_BUILD) || defined(NEW_VIDEO_BUILD) scr; return; // ST - 1/3/2019 10:50AM @@ -511,7 +511,7 @@ void WWMouseClass::Draw_Mouse(GraphicViewPortClass* scr) void WWMouseClass::Erase_Mouse(GraphicViewPortClass* scr, int forced) { -#if defined(REMASTER_BUILD) || defined(SDL_BUILD) +#if defined(REMASTER_BUILD) || defined(NEW_VIDEO_BUILD) // ST - 1/3/2019 10:50AM scr; forced; @@ -618,7 +618,7 @@ int WWMouseClass::Get_Mouse_Y(void) *=============================================================================================*/ void WWMouseClass::Get_Mouse_XY(int& x, int& y) { -#if defined(SDL_BUILD) +#ifdef NEW_VIDEO_BUILD Get_Video_Mouse(x, y); #elif defined(_WIN32) POINT pt; @@ -854,7 +854,7 @@ void* WWMouseClass::Set_Mouse_Cursor(int hotspotx, int hotspoty, Cursor* cursor) result = PrevCursor; PrevCursor = cursor; -#ifdef SDL_BUILD +#ifdef NEW_VIDEO_BUILD Set_Video_Cursor(MouseCursor, CursorWidth, CursorHeight, MouseXHot, MouseYHot); #endif diff --git a/redalert/globals.cpp b/redalert/globals.cpp index bfdd751c..0b22c23d 100644 --- a/redalert/globals.cpp +++ b/redalert/globals.cpp @@ -189,7 +189,7 @@ int AllDone; ** This is true if the game is the currently in focus windows app ** */ -#ifdef SDL_BUILD +#ifdef NEW_VIDEO_BUILD bool GameInFocus = true; #else bool GameInFocus = false; diff --git a/redalert/startup.cpp b/redalert/startup.cpp index d6b1a12c..a84a5087 100644 --- a/redalert/startup.cpp +++ b/redalert/startup.cpp @@ -487,7 +487,7 @@ int main(int argc, char* argv[]) HiddenPage.Clear(); Memory_Error_Exit = Print_Error_Exit; -#ifdef SDL_BUILD +#ifdef NEW_VIDEO_BUILD Reset_Video_Mode(); #endif diff --git a/tiberiandawn/startup.cpp b/tiberiandawn/startup.cpp index 94122879..6c4e60dd 100644 --- a/tiberiandawn/startup.cpp +++ b/tiberiandawn/startup.cpp @@ -468,7 +468,7 @@ int main(int argc, char** argv) CCDebugString("C&C95 - About to exit.\n"); -#if defined(SDL_BUILD) +#ifdef NEW_VIDEO_BUILD Reset_Video_Mode(); #endif