mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r26790) [1.4] -Backport from trunk:
- Fix: Loading a game with order backups leaked Orders and left unreachable items in the pool (r26787) - Fix: Buffer overrun in SQCompiler::Error (r26764) - Fix: Desync due to not always properly restoring game state from the savegame (r26753) - Fix: [Script] Crashes and infinite loops when using lists in item-descending order [FS#6085] (r26744)
This commit is contained in:
parent
8e36fb0ada
commit
2134c2e905
|
@ -66,7 +66,7 @@ public:
|
||||||
static SQChar temp[256];
|
static SQChar temp[256];
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, s);
|
va_start(vl, s);
|
||||||
scvsprintf(temp, s, vl);
|
scvsnprintf(temp, sizeof(temp), s, vl);
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
throw temp;
|
throw temp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,12 @@ void Load_BKOR()
|
||||||
* Furthermore before savegame version 192 the actual content was always corrupt.
|
* Furthermore before savegame version 192 the actual content was always corrupt.
|
||||||
*/
|
*/
|
||||||
if (!_networking || _network_server || IsSavegameVersionBefore(192)) {
|
if (!_networking || _network_server || IsSavegameVersionBefore(192)) {
|
||||||
_order_backup_pool.CleanPool();
|
/* Note: We cannot use CleanPool since that skips part of the destructor
|
||||||
|
* and then leaks un-reachable Orders in the order pool. */
|
||||||
|
OrderBackup *ob;
|
||||||
|
FOR_ALL_ORDER_BACKUPS(ob) {
|
||||||
|
delete ob;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ static void Load_STNN()
|
||||||
for (uint32 j = 0; j < _num_flows; ++j) {
|
for (uint32 j = 0; j < _num_flows; ++j) {
|
||||||
SlObject(&flow, _flow_desc);
|
SlObject(&flow, _flow_desc);
|
||||||
if (fs == NULL || prev_source != flow.source) {
|
if (fs == NULL || prev_source != flow.source) {
|
||||||
fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share))).first->second);
|
fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted))).first->second);
|
||||||
} else {
|
} else {
|
||||||
fs->AppendShare(flow.via, flow.share, flow.restricted);
|
fs->AppendShare(flow.via, flow.share, flow.restricted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,12 @@ public:
|
||||||
this->has_no_more_items = true;
|
this->has_no_more_items = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->item_iter--;
|
if (this->item_iter == this->list->items.begin()) {
|
||||||
|
/* Use 'end' as marker for 'beyond begin' */
|
||||||
|
this->item_iter = this->list->items.end();
|
||||||
|
} else {
|
||||||
|
this->item_iter--;
|
||||||
|
}
|
||||||
if (this->item_iter != this->list->items.end()) item_next = (*this->item_iter).first;
|
if (this->item_iter != this->list->items.end()) item_next = (*this->item_iter).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,13 @@ public:
|
||||||
* Create a FlowStat with an initial entry.
|
* Create a FlowStat with an initial entry.
|
||||||
* @param st Station the initial entry refers to.
|
* @param st Station the initial entry refers to.
|
||||||
* @param flow Amount of flow for the initial entry.
|
* @param flow Amount of flow for the initial entry.
|
||||||
|
* @param restricted If the flow to be added is restricted.
|
||||||
*/
|
*/
|
||||||
inline FlowStat(StationID st, uint flow)
|
inline FlowStat(StationID st, uint flow, bool restricted = false)
|
||||||
{
|
{
|
||||||
assert(flow > 0);
|
assert(flow > 0);
|
||||||
this->shares[flow] = st;
|
this->shares[flow] = st;
|
||||||
this->unrestricted = flow;
|
this->unrestricted = restricted ? 0 : flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue