Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameclient): stop listbox autoscroll when an entry can never fit

Olcay Seygan1c37c6325c49
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e2c89469..e23eb509d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -241,6 +241,7 @@ found and fixed — EA's own, not port damage.**
- A map sent to you over the network has to be a map. The other machine used to name any file it liked and fill it with anything at all, and it was written where the name pointed; now the name cannot leave the map folder, the kind has to be one a map transfer carries, and the contents have to match the kind.
- The processor's rounding mode is reset from the right register every frame.
- The disconnect screen no longer interrupts a game that is merely slow.
+- The disconnect screen no longer freezes the game when its message is taller than its box. The list scrolled to fit a line that could never fit and never stopped, so when a player dropped out of a three-player match the other two locked up for good; now they wait out the vote and play on.
- The keepalive interval setting is read now, and kept in a sane range.
- The anti-freeze brake is measured properly and comes on twice as early.
- Online input delay is now less than half what it was.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp
index b72191bfb..dbfd0926e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp
@@ -1504,26 +1504,21 @@ WindowMsgHandledType GadgetListBoxSystem( GameWindow *window, UnsignedInt msg,
if( list->autoScroll )
{
+ // we use -1 because insertPos was increased in addEntry
+ const Int shownRow = ( row == -1 ) ? ( list->insertPos - 1 ) : row;
while( TRUE )
{
// If off bottom of screen, scroll and try again.
- // we use -1 because insertPos was increased in addEntry
- if( row == -1 )
- {
- if( list->listData[(list->insertPos - 1)].listHeight >=
- (list->displayPos + list->displayHeight) )
- adjustDisplay( window, 1, TRUE );
- else
- break;
- }
- else
- {
- if( list->listData[( row )].listHeight >=
- (list->displayPos + list->displayHeight) )
- adjustDisplay( window, 1, TRUE );
- else
- break;
- }
+ if( list->listData[ shownRow ].listHeight < ( list->displayPos + list->displayHeight ) )
+ break;
+
+ /* An entry taller than the box never fits however far it scrolls, and EA's loop
+ then spun forever: the disconnect screen on a 100x100 headless window froze
+ both surviving machines of a network game the moment a player dropped. */
+ const Int displayPosBefore = list->displayPos;
+ adjustDisplay( window, 1, TRUE );
+ if( list->displayPos == displayPosBefore )
+ break;
}
}