equal
deleted
inserted
replaced
15 #include "newgrf_engine.h" |
15 #include "newgrf_engine.h" |
16 |
16 |
17 |
17 |
18 uint CountArticulatedParts(EngineID engine_type, bool purchase_window) |
18 uint CountArticulatedParts(EngineID engine_type, bool purchase_window) |
19 { |
19 { |
20 if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0; |
20 if (!HasBit(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0; |
21 |
21 |
22 Vehicle *v = NULL;; |
22 Vehicle *v = NULL;; |
23 if (!purchase_window) { |
23 if (!purchase_window) { |
24 v = new InvalidVehicle(); |
24 v = new InvalidVehicle(); |
25 v->engine_type = engine_type; |
25 v->engine_type = engine_type; |
39 void AddArticulatedParts(Vehicle **vl, VehicleType type) |
39 void AddArticulatedParts(Vehicle **vl, VehicleType type) |
40 { |
40 { |
41 const Vehicle *v = vl[0]; |
41 const Vehicle *v = vl[0]; |
42 Vehicle *u = vl[0]; |
42 Vehicle *u = vl[0]; |
43 |
43 |
44 if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return; |
44 if (!HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return; |
45 |
45 |
46 for (uint i = 1; i < MAX_UVALUE(EngineID); i++) { |
46 for (uint i = 1; i < MAX_UVALUE(EngineID); i++) { |
47 uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, v->engine_type, v); |
47 uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, v->engine_type, v); |
48 if (callback == CALLBACK_FAILED || callback == 0xFF) return; |
48 if (callback == CALLBACK_FAILED || callback == 0xFF) return; |
49 |
49 |
54 |
54 |
55 Vehicle *previous = u; |
55 Vehicle *previous = u; |
56 u = u->Next(); |
56 u = u->Next(); |
57 |
57 |
58 EngineID engine_type = GetFirstEngineOfType(type) + GB(callback, 0, 7); |
58 EngineID engine_type = GetFirstEngineOfType(type) + GB(callback, 0, 7); |
59 bool flip_image = HASBIT(callback, 7); |
59 bool flip_image = HasBit(callback, 7); |
60 |
60 |
61 /* get common values from first engine */ |
61 /* get common values from first engine */ |
62 u->direction = v->direction; |
62 u->direction = v->direction; |
63 u->owner = v->owner; |
63 u->owner = v->owner; |
64 u->tile = v->tile; |
64 u->tile = v->tile; |