mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
Limit maximum recursion depth in StationViewWindow::EstimateDestinations
This commit is contained in:
parent
99055c22cb
commit
3807f0551d
@ -1493,9 +1493,9 @@ struct StationViewWindow : public Window {
|
||||
* @param count Size of the batch of cargo.
|
||||
* @param dest CargoDataEntry to save the results in.
|
||||
*/
|
||||
void EstimateDestinations(CargoID cargo, StationID source, StationID next, uint count, CargoDataEntry *dest)
|
||||
void EstimateDestinations(CargoID cargo, StationID source, StationID next, uint count, CargoDataEntry *dest, uint depth = 0)
|
||||
{
|
||||
if (Station::IsValidID(next) && Station::IsValidID(source)) {
|
||||
if (depth <= 128 && Station::IsValidID(next) && Station::IsValidID(source)) {
|
||||
CargoDataEntry tmp;
|
||||
const FlowStatMap &flowmap = Station::Get(next)->goods[cargo].flows;
|
||||
FlowStatMap::const_iterator map_it = flowmap.find(source);
|
||||
@ -1528,7 +1528,7 @@ struct StationViewWindow : public Window {
|
||||
if (child->GetStation() == next) {
|
||||
dest->InsertOrRetrieve(next)->Update(estimate);
|
||||
} else {
|
||||
EstimateDestinations(cargo, source, child->GetStation(), estimate, dest);
|
||||
EstimateDestinations(cargo, source, child->GetStation(), estimate, dest, depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user