train_cmd.c
branchcustombridgeheads
changeset 5615 d6197e6c420e
parent 5614 623bae81fbd2
child 5621 6ce400c0a2f4
equal deleted inserted replaced
5614:623bae81fbd2 5615:d6197e6c420e
  3091 						v->current_order.type = OT_NOTHING;
  3091 						v->current_order.type = OT_NOTHING;
  3092 						v->current_order.flags = 0;
  3092 						v->current_order.flags = 0;
  3093 						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  3093 						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  3094 					}
  3094 					}
  3095 				}
  3095 				}
  3096 			} else {
  3096 			} else new_tile:{
  3097 				/* A new tile is about to be entered. */
  3097 				/* A new tile is about to be entered. */
  3098 
  3098 
  3099 				byte bits;
  3099 				byte bits;
  3100 
  3100 
  3101 				/* Determine what direction we're entering the new tile from */
  3101 				/* Determine what direction we're entering the new tile from */
  3207 			GetNewVehiclePos(v, &gp);
  3207 			GetNewVehiclePos(v, &gp);
  3208 
  3208 
  3209 			SetSpeedLimitOnBridge(v);
  3209 			SetSpeedLimitOnBridge(v);
  3210 
  3210 
  3211 			if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && ((VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 0x4) != 0)) {
  3211 			if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && ((VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 0x4) != 0)) {
  3212 				/* vehicle just left the bridge/tunnel wormhole and entered ramp/exit from inside */
  3212 				if (IsBridgeTile(gp.new_tile)) {
       
  3213 					/* when on a bridge, v->tile points to one of the bridge heads. GetNewVehicleDirection will
       
  3214 					 * fail, because it expects the new and old tile (gp.{new|old}tile) to be adjacent to each
       
  3215 					 * other. So we set the old_tile here manually by using the current vehicle coordinates */
       
  3216 					gp.old_tile = TileVirtXY(v->x_pos, v->y_pos);
       
  3217 					goto new_tile; /* We need the same code when entering from a bridge than from any other tile */
       
  3218 				}
       
  3219 
  3213 			} else {
  3220 			} else {
  3214 				/* vehicle stays in the bridge/tunnel wormhole */
  3221 				/* vehicle stays in the bridge/tunnel wormhole */
  3215 				v->x_pos = gp.x;
  3222 				v->x_pos = gp.x;
  3216 				v->y_pos = gp.y;
  3223 				v->y_pos = gp.y;
  3217 				VehiclePositionChanged(v);
  3224 				VehiclePositionChanged(v);