mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-22 15:11:54 +00:00
(svn r11349) -Fix [FS#1372]: crash when moving "invalid" cargo to a station.
This commit is contained in:
parent
27bf599ae2
commit
21981fd8cb
@ -405,41 +405,34 @@ static void TransportIndustryGoods(TileIndex tile)
|
|||||||
{
|
{
|
||||||
Industry *i = GetIndustryByTile(tile);
|
Industry *i = GetIndustryByTile(tile);
|
||||||
const IndustrySpec *indspec = GetIndustrySpec(i->type);
|
const IndustrySpec *indspec = GetIndustrySpec(i->type);
|
||||||
uint cw, am;
|
bool moved_cargo = false;
|
||||||
|
|
||||||
cw = min(i->produced_cargo_waiting[0], 255);
|
for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) {
|
||||||
if (cw > indspec->minimal_cargo/* && i->produced_cargo[0] != 0xFF*/) {
|
uint cw = min(i->produced_cargo_waiting[j], 255);
|
||||||
i->produced_cargo_waiting[0] -= cw;
|
if (cw > indspec->minimal_cargo && i->produced_cargo[j] != CT_INVALID) {
|
||||||
|
i->produced_cargo_waiting[j] -= cw;
|
||||||
|
|
||||||
/* fluctuating economy? */
|
/* fluctuating economy? */
|
||||||
if (_economy.fluct <= 0) cw = (cw + 1) / 2;
|
if (_economy.fluct <= 0) cw = (cw + 1) / 2;
|
||||||
|
|
||||||
i->this_month_production[0] += cw;
|
i->this_month_production[j] += cw;
|
||||||
|
|
||||||
am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[0], cw);
|
uint am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[j], cw);
|
||||||
i->this_month_transported[0] += am;
|
i->this_month_transported[j] += am;
|
||||||
if (am != 0 && !StartStopIndustryTileAnimation(i, IAT_INDUSTRY_DISTRIBUTES_CARGO)) {
|
|
||||||
uint newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_production;
|
|
||||||
|
|
||||||
if (newgfx != INDUSTRYTILE_NOANIM) {
|
moved_cargo |= (am != 0);
|
||||||
ResetIndustryConstructionStage(tile);
|
|
||||||
SetIndustryCompleted(tile, true);
|
|
||||||
SetIndustryGfx(tile, newgfx);
|
|
||||||
MarkTileDirtyByTile(tile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cw = min(i->produced_cargo_waiting[1], 255);
|
if (moved_cargo && !StartStopIndustryTileAnimation(i, IAT_INDUSTRY_DISTRIBUTES_CARGO)) {
|
||||||
if (cw > indspec->minimal_cargo) {
|
uint newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_production;
|
||||||
i->produced_cargo_waiting[1] -= cw;
|
|
||||||
|
|
||||||
if (_economy.fluct <= 0) cw = (cw + 1) / 2;
|
if (newgfx != INDUSTRYTILE_NOANIM) {
|
||||||
|
ResetIndustryConstructionStage(tile);
|
||||||
i->this_month_production[1] += cw;
|
SetIndustryCompleted(tile, true);
|
||||||
|
SetIndustryGfx(tile, newgfx);
|
||||||
am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[1], cw);
|
MarkTileDirtyByTile(tile);
|
||||||
i->this_month_transported[1] += am;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user