mirror of https://github.com/OpenTTD/OpenTTD
(svn r22123) -Fix [FS#4522]: CommandQueue::Pop() did not update 'last'; popping the last item caused the queue to disconnect unless there was only one item.
parent
0eaa2ffa63
commit
77fa68c1da
|
@ -81,13 +81,16 @@ CommandPacket *CommandQueue::Pop(bool ignore_paused)
|
||||||
{
|
{
|
||||||
CommandPacket **prev = &this->first;
|
CommandPacket **prev = &this->first;
|
||||||
CommandPacket *ret = this->first;
|
CommandPacket *ret = this->first;
|
||||||
|
CommandPacket *prev_item = NULL;
|
||||||
if (ignore_paused && _pause_mode != PM_UNPAUSED) {
|
if (ignore_paused && _pause_mode != PM_UNPAUSED) {
|
||||||
while (ret != NULL && !IsCommandAllowedWhilePaused(ret->cmd)) {
|
while (ret != NULL && !IsCommandAllowedWhilePaused(ret->cmd)) {
|
||||||
|
prev_item = ret;
|
||||||
prev = &ret->next;
|
prev = &ret->next;
|
||||||
ret = ret->next;
|
ret = ret->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
|
if (ret == this->last) this->last = prev_item;
|
||||||
*prev = ret->next;
|
*prev = ret->next;
|
||||||
this->count--;
|
this->count--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue