1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-21 13:39:09 +00:00

(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.

This commit is contained in:
glx
2008-03-27 21:36:16 +00:00
parent 5ddb78af9f
commit bbdb831301
11 changed files with 46 additions and 2 deletions

View File

@@ -400,7 +400,32 @@ enum {
/* Vehicle Resolver Functions */
static inline const Vehicle *GRV(const ResolverObject *object)
{
return object->scope == VSG_SCOPE_SELF ? object->u.vehicle.self : object->u.vehicle.parent;
switch (object->scope) {
default: NOT_REACHED();
case VSG_SCOPE_SELF: return object->u.vehicle.self;
case VSG_SCOPE_PARENT: return object->u.vehicle.parent;
case VSG_SCOPE_RELATIVE: {
const Vehicle *v;
switch (GB(object->count, 6, 2)) {
default: NOT_REACHED();
case 0x00: // count back (away from the engine), starting at this vehicle
case 0x01: // count forward (toward the engine), starting at this vehicle
v = object->u.vehicle.self;
break;
case 0x02: // count back, starting at the engine
v = object->u.vehicle.parent;
break;
case 0x03: // count back, starting at the first vehicle in this chain of vehicles with the same ID, as for vehicle variable 41
v = object->u.vehicle.parent;
while (v != NULL && v->engine_type != object->u.vehicle.self->engine_type) v = v->Next();
break;
}
uint32 count = GB(object->count, 0, 4);
if (count == 0) count = GetRegister(0x100);
while (v != NULL && count-- != 0) v = (GB(object->count, 6, 2) == 0x01) ? v->Previous() : v->Next();
return v;
}
}
}
@@ -816,6 +841,7 @@ static inline void NewVehicleResolver(ResolverObject *res, EngineID engine_type,
res->last_value = 0;
res->trigger = 0;
res->reseed = 0;
res->count = 0;
}