Avoid integer overflow in MoveGoodsToStation

In case where input cargo amount > 255
pull/132/head
Jonathan G Rennison 4 years ago
parent fa73e42dfd
commit f2bc12bb21

@ -4339,7 +4339,7 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc
uint owner = p.first->owner;
/* Multiply the amount by (company best / sum of best for each company) to get cargo allocated to a company
* and by (station rating / sum of ratings in a company) to get the result for a single station. */
p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
p.second = ((uint64) amount) * ((uint64) company_best[owner]) * ((uint64) p.first->goods[type].rating) / (best_sum * company_sum[owner]);
moving += p.second;
}

Loading…
Cancel
Save