From a7040bec70b5841b1384a6e37c0db46e16ac18b1 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 8 Jun 2025 10:08:24 +0200 Subject: [PATCH 1/2] [ZH] Prevent evaluating and saving disabled options in the Options Menu --- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 92 +++++++++++-------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 1984623f6b1..b7cfe293938 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -974,11 +974,14 @@ static void saveOptions( void ) //------------------------------------------------------------------------------------------------- // send Delay - TheWritableGlobalData->m_firewallSendDelay = GadgetCheckBoxIsChecked(checkSendDelay); - if (TheGlobalData->m_firewallSendDelay) { - (*pref)["SendDelay"] = AsciiString("yes"); - } else { - (*pref)["SendDelay"] = AsciiString("no"); + if (checkSendDelay && checkSendDelay->winGetEnabled()) + { + TheWritableGlobalData->m_firewallSendDelay = GadgetCheckBoxIsChecked(checkSendDelay); + if (TheGlobalData->m_firewallSendDelay) { + (*pref)["SendDelay"] = AsciiString("yes"); + } else { + (*pref)["SendDelay"] = AsciiString("no"); + } } //------------------------------------------------------------------------------------------------- @@ -1054,29 +1057,33 @@ static void saveOptions( void ) //------------------------------------------------------------------------------------------------- // LOD - Bool levelChanged=FALSE; - GadgetComboBoxGetSelectedPos( comboBoxDetail, &index ); - //The levels stored by the LOD Manager are inverted compared to GUI so find correct one: - switch (index) { - case HIGHDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_HIGH); - break; - case MEDIUMDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_MEDIUM); - break; - case LOWDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_LOW); - break; - case CUSTOMDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_CUSTOM); - break; - default: - DEBUG_ASSERTCRASH(FALSE,("LOD passed in was %d, %d is not a supported LOD",index,index)); - break; - } + if (comboBoxDetail && comboBoxDetail->winGetEnabled()) + { + Bool levelChanged=FALSE; + GadgetComboBoxGetSelectedPos( comboBoxDetail, &index ); - if (levelChanged) - (*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel()); + //The levels stored by the LOD Manager are inverted compared to GUI so find correct one: + switch (index) { + case HIGHDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_HIGH); + break; + case MEDIUMDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_MEDIUM); + break; + case LOWDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_LOW); + break; + case CUSTOMDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_CUSTOM); + break; + default: + DEBUG_ASSERTCRASH(FALSE,("LOD passed in was %d, %d is not a supported LOD",index,index)); + break; + } + + if (levelChanged) + (*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel()); + } //------------------------------------------------------------------------------------------------- // Resolution @@ -1088,12 +1095,11 @@ static void saveOptions( void ) oldDispSettings.bitDepth = TheDisplay->getBitDepth(); oldDispSettings.windowed = TheDisplay->getWindowed(); - if (index < TheDisplay->getDisplayModeCount() && index >= 0) + if (comboBoxResolution && comboBoxResolution->winGetEnabled() && index < TheDisplay->getDisplayModeCount() && index >= 0) { TheDisplay->getDisplayModeDescription(index,&xres,&yres,&bitDepth); if (TheGlobalData->m_xResolution != xres || TheGlobalData->m_yResolution != yres) { - if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheDisplay->getWindowed())) { dispChanged = TRUE; @@ -1131,19 +1137,27 @@ static void saveOptions( void ) //------------------------------------------------------------------------------------------------- // IP address - UnsignedInt ip; - GadgetComboBoxGetSelectedPos(comboBoxLANIP, &index); - if (index>=0 && TheGlobalData) + if (comboBoxLANIP && comboBoxLANIP->winGetEnabled()) { - ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxLANIP, index); - TheWritableGlobalData->m_defaultIP = ip; - pref->setLANIPAddress(ip); + UnsignedInt ip; + GadgetComboBoxGetSelectedPos(comboBoxLANIP, &index); + if (index>=0 && TheGlobalData) + { + ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxLANIP, index); + TheWritableGlobalData->m_defaultIP = ip; + pref->setLANIPAddress(ip); + } } - GadgetComboBoxGetSelectedPos(comboBoxOnlineIP, &index); - if (index>=0) + + if (comboBoxOnlineIP && comboBoxOnlineIP->winGetEnabled()) { - ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxOnlineIP, index); - pref->setOnlineIPAddress(ip); + UnsignedInt ip; + GadgetComboBoxGetSelectedPos(comboBoxOnlineIP, &index); + if (index>=0) + { + ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxOnlineIP, index); + pref->setOnlineIPAddress(ip); + } } //------------------------------------------------------------------------------------------------- From 2b6d5bdab7c134c1ee998e2d6e8c68bce2a4097c Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:32:11 +0200 Subject: [PATCH 2/2] Replicate in Generals --- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 92 +++++++++++-------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 7ea0bdadfae..48ef7d11f68 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -923,11 +923,14 @@ static void saveOptions( void ) //------------------------------------------------------------------------------------------------- // send Delay - TheWritableGlobalData->m_firewallSendDelay = GadgetCheckBoxIsChecked(checkSendDelay); - if (TheGlobalData->m_firewallSendDelay) { - (*pref)["SendDelay"] = AsciiString("yes"); - } else { - (*pref)["SendDelay"] = AsciiString("no"); + if (checkSendDelay && checkSendDelay->winGetEnabled()) + { + TheWritableGlobalData->m_firewallSendDelay = GadgetCheckBoxIsChecked(checkSendDelay); + if (TheGlobalData->m_firewallSendDelay) { + (*pref)["SendDelay"] = AsciiString("yes"); + } else { + (*pref)["SendDelay"] = AsciiString("no"); + } } //------------------------------------------------------------------------------------------------- @@ -1000,29 +1003,33 @@ static void saveOptions( void ) //------------------------------------------------------------------------------------------------- // LOD - Bool levelChanged=FALSE; - GadgetComboBoxGetSelectedPos( comboBoxDetail, &index ); - //The levels stored by the LOD Manager are inverted compared to GUI so find correct one: - switch (index) { - case HIGHDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_HIGH); - break; - case MEDIUMDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_MEDIUM); - break; - case LOWDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_LOW); - break; - case CUSTOMDETAIL: - levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_CUSTOM); - break; - default: - DEBUG_ASSERTCRASH(FALSE,("LOD passed in was %d, %d is not a supported LOD",index,index)); - break; - } + if (comboBoxDetail && comboBoxDetail->winGetEnabled()) + { + Bool levelChanged=FALSE; + GadgetComboBoxGetSelectedPos( comboBoxDetail, &index ); - if (levelChanged) - (*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel()); + //The levels stored by the LOD Manager are inverted compared to GUI so find correct one: + switch (index) { + case HIGHDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_HIGH); + break; + case MEDIUMDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_MEDIUM); + break; + case LOWDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_LOW); + break; + case CUSTOMDETAIL: + levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_CUSTOM); + break; + default: + DEBUG_ASSERTCRASH(FALSE,("LOD passed in was %d, %d is not a supported LOD",index,index)); + break; + } + + if (levelChanged) + (*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel()); + } //------------------------------------------------------------------------------------------------- // Resolution @@ -1034,12 +1041,11 @@ static void saveOptions( void ) oldDispSettings.bitDepth = TheDisplay->getBitDepth(); oldDispSettings.windowed = TheDisplay->getWindowed(); - if (index < TheDisplay->getDisplayModeCount() && index >= 0) + if (comboBoxResolution && comboBoxResolution->winGetEnabled() && index < TheDisplay->getDisplayModeCount() && index >= 0) { TheDisplay->getDisplayModeDescription(index,&xres,&yres,&bitDepth); if (TheGlobalData->m_xResolution != xres || TheGlobalData->m_yResolution != yres) { - if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheDisplay->getWindowed())) { dispChanged = TRUE; @@ -1077,19 +1083,27 @@ static void saveOptions( void ) //------------------------------------------------------------------------------------------------- // IP address - UnsignedInt ip; - GadgetComboBoxGetSelectedPos(comboBoxLANIP, &index); - if (index>=0 && TheGlobalData) + if (comboBoxLANIP && comboBoxLANIP->winGetEnabled()) { - ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxLANIP, index); - TheWritableGlobalData->m_defaultIP = ip; - pref->setLANIPAddress(ip); + UnsignedInt ip; + GadgetComboBoxGetSelectedPos(comboBoxLANIP, &index); + if (index>=0 && TheGlobalData) + { + ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxLANIP, index); + TheWritableGlobalData->m_defaultIP = ip; + pref->setLANIPAddress(ip); + } } - GadgetComboBoxGetSelectedPos(comboBoxOnlineIP, &index); - if (index>=0) + + if (comboBoxOnlineIP && comboBoxOnlineIP->winGetEnabled()) { - ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxOnlineIP, index); - pref->setOnlineIPAddress(ip); + UnsignedInt ip; + GadgetComboBoxGetSelectedPos(comboBoxOnlineIP, &index); + if (index>=0) + { + ip = (UnsignedInt)GadgetComboBoxGetItemData(comboBoxOnlineIP, index); + pref->setOnlineIPAddress(ip); + } } //-------------------------------------------------------------------------------------------------