mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r18508) -Fix [FS#3372]: if a rail station class had less data than capacity it would try to set a negative position
This commit is contained in:
parent
619e70f94a
commit
7c2a61e210
@ -150,6 +150,7 @@ static FORCEINLINE T *AlignPtr(T *x, uint n)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static FORCEINLINE T Clamp(const T a, const T min, const T max)
|
static FORCEINLINE T Clamp(const T a, const T min, const T max)
|
||||||
{
|
{
|
||||||
|
assert(min <= max);
|
||||||
if (a <= min) return min;
|
if (a <= min) return min;
|
||||||
if (a >= max) return max;
|
if (a >= max) return max;
|
||||||
return a;
|
return a;
|
||||||
|
@ -1017,7 +1017,7 @@ public:
|
|||||||
|
|
||||||
this->vscroll.SetCount(_railstation.station_count);
|
this->vscroll.SetCount(_railstation.station_count);
|
||||||
this->vscroll.SetCapacity(GB(this->GetWidget<NWidgetCore>(BRSW_NEWST_LIST)->widget_data, MAT_ROW_START, MAT_ROW_BITS));
|
this->vscroll.SetCapacity(GB(this->GetWidget<NWidgetCore>(BRSW_NEWST_LIST)->widget_data, MAT_ROW_START, MAT_ROW_BITS));
|
||||||
this->vscroll.SetPosition(Clamp(_railstation.station_type - 2, 0, this->vscroll.GetCount() - this->vscroll.GetCapacity()));
|
this->vscroll.SetPosition(Clamp(_railstation.station_type - 2, 0, max(this->vscroll.GetCount() - this->vscroll.GetCapacity(), 0)));
|
||||||
} else {
|
} else {
|
||||||
/* New stations are not available, so ensure the default station
|
/* New stations are not available, so ensure the default station
|
||||||
* type is 'selected'. */
|
* type is 'selected'. */
|
||||||
|
Loading…
Reference in New Issue
Block a user