summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-12-15 22:22:23 +0000
committerrubidium <rubidium@openttd.org>2008-12-15 22:22:23 +0000
commitf1c7e4662a379fdc1f59e69c0823b7daae5a4958 (patch)
tree9e4f9e7101dee155ee062c63cfb77577042f7304 /src
parent5e938aae05a293e95881da7ef4d8b5bffdf12f6e (diff)
downloadopenttd-f1c7e4662a379fdc1f59e69c0823b7daae5a4958.tar.xz
(svn r14678) -Fix [FS#2435]: gradual filling graphics were not chosen according to the NewGRF spec (Maedhros)
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index f7a0587fd..1f07ab663 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -778,8 +778,6 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
static const SpriteGroup *VehicleResolveReal(const ResolverObject *object, const SpriteGroup *group)
{
const Vehicle *v = object->u.vehicle.self;
- uint totalsets;
- uint set;
if (v == NULL) {
if (group->g.real.num_loading > 0) return group->g.real.loading[0];
@@ -789,15 +787,10 @@ static const SpriteGroup *VehicleResolveReal(const ResolverObject *object, const
bool in_motion = !v->First()->current_order.IsType(OT_LOADING);
- totalsets = in_motion ? group->g.real.num_loaded : group->g.real.num_loading;
+ uint totalsets = in_motion ? group->g.real.num_loaded : group->g.real.num_loading;
- if (v->cargo.Count() >= v->cargo_cap || totalsets == 1) {
- set = totalsets - 1;
- } else if (v->cargo.Empty() || totalsets == 2) {
- set = 0;
- } else {
- set = v->cargo.Count() * (totalsets - 2) / max((uint16)1, v->cargo_cap) + 1;
- }
+ uint set = (v->cargo.Count() * totalsets) / max((uint16)1, v->cargo_cap);
+ set = min(set, totalsets - 1);
return in_motion ? group->g.real.loaded[set] : group->g.real.loading[set];
}