Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Aug 16, 2025

This change moves the default resolution constants to GameDefines.h and uses them at places.

TODO

  • Replicate in Generals

@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Aug 16, 2025
#define MIN_DISPLAY_BIT_DEPTH 16
#define DEFAULT_DISPLAY_BIT_DEPTH 32
#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for
#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to make these static const or CONSTEXPR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After VC6, yes. With VC6 this ideally is an enum value or macro.

@Mauller
Copy link

Mauller commented Aug 17, 2025

Missing the change for

W3DHorizontalSlider.cpp
line 153: Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / 800;

line 232: Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / 800;
line 233: Real yMulti = INT_TO_REAL(TheDisplay->getWidth()) / 600;

GlobalLanguage.cpp
line 194: Real adjustFactor = TheGlobalData->m_xResolution/800.0f;

i think this is also meant to relate to default width too

W3DMainMenu.cpp
liune 111: static Int x = -800;

@xezon
Copy link
Author

xezon commented Aug 17, 2025

Fixed.

Copy link

@Mauller Mauller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me from what i could find.

@xezon
Copy link
Author

xezon commented Aug 19, 2025

Replicated in Generals with conflicts.

D:\Projects\TheSuperHackers\GeneralsGameCode>FOR /F "delims=" %b IN ('git merge-base --fork-point main') DO git diff %b  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git diff 1eceff554e000afcf314552e0dca47d2736c52d1  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch
Checking patch Generals/GameEngine/Include/Common/GameDefines.h...
error: Generals/GameEngine/Include/Common/GameDefines.h: No such file or directory
Checking patch Generals/Code/GameEngine/Source/Common/GlobalData.cpp...
Hunk #1 succeeded at 614 (offset -5 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarResizer.cpp...
Checking patch Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp...
Hunk #1 succeeded at 836 (offset -44 lines).
Hunk #2 succeeded at 1648 (offset -67 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupPlayerInfo.cpp...
error: while searching for:
}
void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int itemData, Int& row, Int& column, UnicodeString text = UnicodeString::TheEmptyString, Int extra = 0)
{
        Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / 800.0f);
        Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / 600.0f);

        static Int enabledColor = 0xFFFFFFFF;
        static Int disabledColor = GameMakeColor(80, 80, 80, 255);

error: patch failed: Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupPlayerInfo.cpp:468
Checking patch Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp...
Hunk #1 succeeded at 812 (offset -17 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp...
Hunk #1 succeeded at 187 (offset -4 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp...
error: while searching for:

        // calculate where this screen position should be since the position being passed in is based off 8x6
        Coord2D multiplier;
        multiplier.x = (float)TheDisplay->getWidth() / 800.0f;
        multiplier.y = (float)TheDisplay->getHeight() / 600.0f;

        // lets bring out the data structure!
        m_militarySubtitle = NEW MilitarySubtitleData;

error: patch failed: Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp:4183
Checking patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DMainMenu.cpp...
Checking patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DHorizontalSlider.cpp...
Checking patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp...
Hunk #1 succeeded at 110 (offset -1 lines).
Hunk #2 succeeded at 428 (offset -49 lines).
Hunk #3 succeeded at 697 (offset -50 lines).
Checking patch Generals/Code/Main/WinMain.cpp...
Hunk #1 succeeded at 76 (offset -3 lines).
Hunk #2 succeeded at 576 (offset -22 lines).
Hunk #3 succeeded at 658 (offset -22 lines).
Hunk #4 succeeded at 685 (offset -22 lines).
Applied patch Generals/Code/GameEngine/Source/Common/GlobalData.cpp cleanly.
Applied patch Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarResizer.cpp cleanly.
Applied patch Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp cleanly.
Applying patch Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupPlayerInfo.cpp with 1 reject...
Rejected hunk #1.
Applied patch Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp cleanly.
Applied patch Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp cleanly.
Applying patch Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp with 1 reject...
Rejected hunk #1.
Applied patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DMainMenu.cpp cleanly.
Applied patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DHorizontalSlider.cpp cleanly.
Applied patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp cleanly.
Applied patch Generals/Code/Main/WinMain.cpp cleanly.

@xezon xezon merged commit a4a57a2 into TheSuperHackers:main Aug 19, 2025
18 checks passed
@xezon xezon deleted the xezon/refactor-default-display-res branch August 19, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants