204 } |
204 } |
205 |
205 |
206 if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON && |
206 if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON && |
207 UsesWagonOverride(u) && !HasBit(u->u.rail.cached_vis_effect, 7)) { |
207 UsesWagonOverride(u) && !HasBit(u->u.rail.cached_vis_effect, 7)) { |
208 /* wagon is powered */ |
208 /* wagon is powered */ |
209 SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status |
209 SetBit(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status |
210 } else { |
210 } else { |
211 ClrBit(u->u.rail.flags, VRF_POWEREDWAGON); |
211 ClrBit(u->u.rail.flags, VRF_POWEREDWAGON); |
212 } |
212 } |
213 |
213 |
214 /* Do not count powered wagons for the compatible railtypes, as wagons always |
214 /* Do not count powered wagons for the compatible railtypes, as wagons always |
745 v->build_year = _cur_year; |
745 v->build_year = _cur_year; |
746 v->cur_image = 0xAC2; |
746 v->cur_image = 0xAC2; |
747 v->random_bits = VehicleRandomBits(); |
747 v->random_bits = VehicleRandomBits(); |
748 |
748 |
749 v->vehicle_flags = 0; |
749 v->vehicle_flags = 0; |
750 if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); |
750 if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); |
751 |
751 |
752 v->group_id = DEFAULT_GROUP; |
752 v->group_id = DEFAULT_GROUP; |
753 |
753 |
754 v->subtype = 0; |
754 v->subtype = 0; |
755 SetFrontEngine(v); |
755 SetFrontEngine(v); |
1463 ClrBit(*swap_flag2, VRF_GOINGUP); |
1463 ClrBit(*swap_flag2, VRF_GOINGUP); |
1464 ClrBit(*swap_flag2, VRF_GOINGDOWN); |
1464 ClrBit(*swap_flag2, VRF_GOINGDOWN); |
1465 |
1465 |
1466 /* Reverse the rail-flags (if needed) */ |
1466 /* Reverse the rail-flags (if needed) */ |
1467 if (HasBit(flag1, VRF_GOINGUP)) { |
1467 if (HasBit(flag1, VRF_GOINGUP)) { |
1468 SETBIT(*swap_flag2, VRF_GOINGDOWN); |
1468 SetBit(*swap_flag2, VRF_GOINGDOWN); |
1469 } else if (HasBit(flag1, VRF_GOINGDOWN)) { |
1469 } else if (HasBit(flag1, VRF_GOINGDOWN)) { |
1470 SETBIT(*swap_flag2, VRF_GOINGUP); |
1470 SetBit(*swap_flag2, VRF_GOINGUP); |
1471 } |
1471 } |
1472 if (HasBit(flag2, VRF_GOINGUP)) { |
1472 if (HasBit(flag2, VRF_GOINGUP)) { |
1473 SETBIT(*swap_flag1, VRF_GOINGDOWN); |
1473 SetBit(*swap_flag1, VRF_GOINGDOWN); |
1474 } else if (HasBit(flag2, VRF_GOINGDOWN)) { |
1474 } else if (HasBit(flag2, VRF_GOINGDOWN)) { |
1475 SETBIT(*swap_flag1, VRF_GOINGUP); |
1475 SetBit(*swap_flag1, VRF_GOINGUP); |
1476 } |
1476 } |
1477 } |
1477 } |
1478 |
1478 |
1479 static void ReverseTrainSwapVeh(Vehicle *v, int l, int r) |
1479 static void ReverseTrainSwapVeh(Vehicle *v, int l, int r) |
1480 { |
1480 { |
1938 if (v->current_order.type == OT_LOADING) v->LeaveStation(); |
1938 if (v->current_order.type == OT_LOADING) v->LeaveStation(); |
1939 |
1939 |
1940 v->dest_tile = tfdd.tile; |
1940 v->dest_tile = tfdd.tile; |
1941 v->current_order.type = OT_GOTO_DEPOT; |
1941 v->current_order.type = OT_GOTO_DEPOT; |
1942 v->current_order.flags = OF_NON_STOP; |
1942 v->current_order.flags = OF_NON_STOP; |
1943 if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT); |
1943 if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OFB_HALT_IN_DEPOT); |
1944 v->current_order.dest = GetDepotByTile(tfdd.tile)->index; |
1944 v->current_order.dest = GetDepotByTile(tfdd.tile)->index; |
1945 v->current_order.refit_cargo = CT_INVALID; |
1945 v->current_order.refit_cargo = CT_INVALID; |
1946 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1946 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1947 /* If there is no depot in front, reverse automatically */ |
1947 /* If there is no depot in front, reverse automatically */ |
1948 if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); |
1948 if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); |
2260 /* handle "path not found" state */ |
2260 /* handle "path not found" state */ |
2261 if (path_not_found) { |
2261 if (path_not_found) { |
2262 /* PF didn't find the route */ |
2262 /* PF didn't find the route */ |
2263 if (!HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) { |
2263 if (!HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) { |
2264 /* it is first time the problem occurred, set the "path not found" flag */ |
2264 /* it is first time the problem occurred, set the "path not found" flag */ |
2265 SETBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION); |
2265 SetBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION); |
2266 /* and notify user about the event */ |
2266 /* and notify user about the event */ |
2267 if (_patches.lost_train_warn && v->owner == _local_player) { |
2267 if (_patches.lost_train_warn && v->owner == _local_player) { |
2268 SetDParam(0, v->unitnumber); |
2268 SetDParam(0, v->unitnumber); |
2269 AddNewsItem( |
2269 AddNewsItem( |
2270 STR_TRAIN_IS_LOST, |
2270 STR_TRAIN_IS_LOST, |
2568 byte middle_z = GetSlopeZ((v->x_pos & INV_TILE_SIZE_MASK) | HALF_TILE_SIZE, (v->y_pos & INV_TILE_SIZE_MASK) | HALF_TILE_SIZE); |
2568 byte middle_z = GetSlopeZ((v->x_pos & INV_TILE_SIZE_MASK) | HALF_TILE_SIZE, (v->y_pos & INV_TILE_SIZE_MASK) | HALF_TILE_SIZE); |
2569 |
2569 |
2570 /* For some reason tunnel tiles are always given as sloped :( |
2570 /* For some reason tunnel tiles are always given as sloped :( |
2571 * But they are not sloped... */ |
2571 * But they are not sloped... */ |
2572 if (middle_z != v->z_pos && !IsTunnelTile(TileVirtXY(v->x_pos, v->y_pos))) { |
2572 if (middle_z != v->z_pos && !IsTunnelTile(TileVirtXY(v->x_pos, v->y_pos))) { |
2573 SETBIT(v->u.rail.flags, (middle_z > old_z) ? VRF_GOINGUP : VRF_GOINGDOWN); |
2573 SetBit(v->u.rail.flags, (middle_z > old_z) ? VRF_GOINGUP : VRF_GOINGDOWN); |
2574 } |
2574 } |
2575 } |
2575 } |
2576 } |
2576 } |
2577 |
2577 |
2578 VehiclePositionChanged(v); |
2578 VehiclePositionChanged(v); |
3524 void ConvertOldMultiheadToNew() |
3524 void ConvertOldMultiheadToNew() |
3525 { |
3525 { |
3526 Vehicle *v; |
3526 Vehicle *v; |
3527 FOR_ALL_VEHICLES(v) { |
3527 FOR_ALL_VEHICLES(v) { |
3528 if (v->type == VEH_TRAIN) { |
3528 if (v->type == VEH_TRAIN) { |
3529 SETBIT(v->subtype, 7); // indicates that it's the old format and needs to be converted in the next loop |
3529 SetBit(v->subtype, 7); // indicates that it's the old format and needs to be converted in the next loop |
3530 } |
3530 } |
3531 } |
3531 } |
3532 |
3532 |
3533 FOR_ALL_VEHICLES(v) { |
3533 FOR_ALL_VEHICLES(v) { |
3534 if (v->type == VEH_TRAIN) { |
3534 if (v->type == VEH_TRAIN) { |