(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:
frosch 2014-09-07 15:09:05 +00:00
parent 8e36fb0ada
commit 2134c2e905
5 changed files with 17 additions and 6 deletions

View File

@ -66,7 +66,7 @@ public:
static SQChar temp[256];
va_list vl;
va_start(vl, s);
scvsprintf(temp, s, vl);
scvsnprintf(temp, sizeof(temp), s, vl);
va_end(vl);
throw temp;
}

View File

@ -295,7 +295,12 @@ void Load_BKOR()
* Furthermore before savegame version 192 the actual content was always corrupt.
*/
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;
}
}
}

View File

@ -539,7 +539,7 @@ static void Load_STNN()
for (uint32 j = 0; j < _num_flows; ++j) {
SlObject(&flow, _flow_desc);
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 {
fs->AppendShare(flow.via, flow.share, flow.restricted);
}

View File

@ -354,7 +354,12 @@ public:
this->has_no_more_items = true;
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;
}

View File

@ -48,12 +48,13 @@ public:
* Create a FlowStat with an initial entry.
* @param st Station the initial entry refers to.
* @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);
this->shares[flow] = st;
this->unrestricted = flow;
this->unrestricted = restricted ? 0 : flow;
}
/**