Skip to content

Commit 88bdb7c

Browse files
authored
bugfix(gui): Remove slider bounds checks to prevent unexpected reset of custom settings (TheSuperHackers#2624)
1 parent 1aca023 commit 88bdb7c

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,14 @@ WindowMsgHandledType GadgetHorizontalSliderSystem( GameWindow *window, UnsignedI
394394
Int newPos = (Int)mData1;
395395
GameWindow *child = window->winGetChild();
396396

397-
if( newPos < s->minVal || newPos > s->maxVal )
398-
break;
397+
// TheSuperHackers @fix No longer reject out of bounds positions to prevent
398+
// reset of custom option.ini settings to 0.
399399

400400
s->position = newPos;
401401

402402
// Translate to window coords
403403
newPos = (Int)((newPos - s->minVal) * s->numTicks);
404+
newPos = clamp(0, newPos, (Int)((s->maxVal - s->minVal) * s->numTicks));
404405

405406
child->winSetPosition( newPos , HORIZONTAL_SLIDER_THUMB_POSITION );
406407
break;

Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,14 @@ WindowMsgHandledType GadgetVerticalSliderSystem( GameWindow *window, UnsignedInt
378378
Int newPos = (Int)mData1;
379379
GameWindow *child = window->winGetChild();
380380

381-
if (newPos < s->minVal || newPos > s->maxVal)
382-
break;
381+
// TheSuperHackers @fix No longer reject out of bounds positions to prevent
382+
// reset of custom option.ini settings to 0.
383383

384384
s->position = newPos;
385385

386386
// Translate to window coords
387387
newPos = (Int)((s->maxVal - newPos) * s->numTicks);
388+
newPos = clamp(0, newPos, (Int)((s->maxVal - s->minVal) * s->numTicks));
388389

389390
child->winSetPosition( 0, newPos );
390391

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,14 @@ WindowMsgHandledType GadgetHorizontalSliderSystem( GameWindow *window, UnsignedI
394394
Int newPos = (Int)mData1;
395395
GameWindow *child = window->winGetChild();
396396

397-
if( newPos < s->minVal || newPos > s->maxVal )
398-
break;
397+
// TheSuperHackers @fix No longer reject out of bounds positions to prevent
398+
// reset of custom option.ini settings to 0.
399399

400400
s->position = newPos;
401401

402402
// Translate to window coords
403403
newPos = (Int)((newPos - s->minVal) * s->numTicks);
404+
newPos = clamp(0, newPos, (Int)((s->maxVal - s->minVal) * s->numTicks));
404405

405406
child->winSetPosition( newPos , HORIZONTAL_SLIDER_THUMB_POSITION );
406407
break;

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,14 @@ WindowMsgHandledType GadgetVerticalSliderSystem( GameWindow *window, UnsignedInt
378378
Int newPos = (Int)mData1;
379379
GameWindow *child = window->winGetChild();
380380

381-
if (newPos < s->minVal || newPos > s->maxVal)
382-
break;
381+
// TheSuperHackers @fix No longer reject out of bounds positions to prevent
382+
// reset of custom option.ini settings to 0.
383383

384384
s->position = newPos;
385385

386386
// Translate to window coords
387387
newPos = (Int)((s->maxVal - newPos) * s->numTicks);
388+
newPos = clamp(0, newPos, (Int)((s->maxVal - s->minVal) * s->numTicks));
388389

389390
child->winSetPosition( 0, newPos );
390391

0 commit comments

Comments
 (0)