mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Codechange: Use SetPosition() to clamp after changing count/capacity.
This commit is contained in:
parent
6202eae9d5
commit
878c5d8d85
@ -721,9 +721,8 @@ public:
|
||||
assert(num <= MAX_UVALUE(uint16));
|
||||
|
||||
this->count = ClampTo<uint16_t>(num);
|
||||
num -= this->cap;
|
||||
if (num < 0) num = 0;
|
||||
if (num < this->pos) this->pos = num;
|
||||
/* Ensure position is within bounds */
|
||||
this->SetPosition(this->pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -736,7 +735,8 @@ public:
|
||||
assert(capacity <= MAX_UVALUE(uint16));
|
||||
|
||||
this->cap = ClampTo<uint16_t>(capacity);
|
||||
if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
|
||||
/* Ensure position is within bounds */
|
||||
this->SetPosition(this->pos);
|
||||
}
|
||||
|
||||
void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
|
||||
|
Loading…
Reference in New Issue
Block a user