summaryrefslogtreecommitdiff
path: root/newgrf_engine.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-03 15:46:21 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-03 15:46:21 +0000
commitf104da53e10196e75607d795d57715cce8a582db (patch)
tree32c1f539574958feefa1794ac80ef7a40eb8c95d /newgrf_engine.c
parent8bdf61bf3ba1ebd8cc13d93c4caaafbe5729b281 (diff)
downloadopenttd-f104da53e10196e75607d795d57715cce8a582db.tar.xz
(svn r4714) - NewGRF: simplify evaluation of 'real' sprite groups.
Diffstat (limited to 'newgrf_engine.c')
-rw-r--r--newgrf_engine.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/newgrf_engine.c b/newgrf_engine.c
index 4b958350f..326b251d4 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -636,24 +636,22 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
}
-static uint32 VehicleResolveReal(const ResolverObject *object, uint num_loaded, uint num_loading, bool *in_motion)
+static const SpriteGroup *VehicleResolveReal(const ResolverObject *object, const SpriteGroup *group)
{
const Vehicle *v = object->u.vehicle.self;
uint totalsets;
uint set;
+ bool in_motion;
- if (v == NULL) {
- *in_motion = false;
- return 0;
- }
+ if (v == NULL) return group->g.real.loaded[0];
if (v->type == VEH_Train) {
- *in_motion = GetFirstVehicleInChain(v)->current_order.type != OT_LOADING;
+ in_motion = GetFirstVehicleInChain(v)->current_order.type != OT_LOADING;
} else {
- *in_motion = v->current_order.type != OT_LOADING;
+ in_motion = v->current_order.type != OT_LOADING;
}
- totalsets = *in_motion ? num_loaded : num_loading;
+ 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;
@@ -663,7 +661,7 @@ static uint32 VehicleResolveReal(const ResolverObject *object, uint num_loaded,
set = v->cargo_count * (totalsets - 2) / max(1, v->cargo_cap) + 1;
}
- return set;
+ return in_motion ? group->g.real.loaded[set] : group->g.real.loading[set];
}