train_cmd.c
branchcustombridgeheads
changeset 5614 623bae81fbd2
parent 5613 8b68de175f44
child 5615 d6197e6c420e
equal deleted inserted replaced
5613:8b68de175f44 5614:623bae81fbd2
  3018   * Sets the correct coordinates to traverse the bridge
  3018   * Sets the correct coordinates to traverse the bridge
  3019   * and aligns the vehicle with the bridge. The function
  3019   * and aligns the vehicle with the bridge. The function
  3020   * assumes the train is on a bridge head about to enter
  3020   * assumes the train is on a bridge head about to enter
  3021   * the bridge.
  3021   * the bridge.
  3022   */
  3022   */
  3023 static void PutTrainOntoBridge(Vehicle *v)
  3023 static void PutTrainOntoBridge(Vehicle *v, int x, int y)
  3024 {
  3024 {
  3025 	DiagDirection dir;
  3025 	DiagDirection dir;
  3026 	uint8 dxy;
  3026 	uint8 dxy;
  3027 	assert(IsBridgeTile(v->tile));
  3027 	assert(IsBridgeTile(v->tile));
  3028 	dir = GetBridgeRampDirection(v->tile);
  3028 	dir = GetBridgeRampDirection(v->tile);
  3036 		case DIAGDIR_NE: dxy = 0xF8; break;
  3036 		case DIAGDIR_NE: dxy = 0xF8; break;
  3037 		case DIAGDIR_SE: dxy = 0x80; break;
  3037 		case DIAGDIR_SE: dxy = 0x80; break;
  3038 		case DIAGDIR_SW: dxy = 0x08; break;
  3038 		case DIAGDIR_SW: dxy = 0x08; break;
  3039 		case DIAGDIR_NW: dxy = 0x8F; break;
  3039 		case DIAGDIR_NW: dxy = 0x8F; break;
  3040 	}
  3040 	}
  3041 	SB(v->x_pos, 0, 4, GB(dxy, 4, 4));
  3041 	SB(x, 0, 4, GB(dxy, 4, 4));
  3042 	SB(v->y_pos, 0, 4, GB(dxy, 0, 4));
  3042 	SB(y, 0, 4, GB(dxy, 0, 4));
       
  3043 	v->x_pos = x;
       
  3044 	v->y_pos = y;
  3043 }
  3045 }
  3044 
  3046 
  3045 static void TrainController(Vehicle *v, bool update_image)
  3047 static void TrainController(Vehicle *v, bool update_image)
  3046 {
  3048 {
  3047 	Vehicle *prev;
  3049 	Vehicle *prev;
  3103 
  3105 
  3104 				/* We should not let the train that is leaving custom bridge head (entering bridge)
  3106 				/* We should not let the train that is leaving custom bridge head (entering bridge)
  3105 				 * to enter the tile that is under bridge. Enter the bridge wormhole instead. */
  3107 				 * to enter the tile that is under bridge. Enter the bridge wormhole instead. */
  3106 				if (IsBridgeTile(gp.old_tile) && GetBridgeRampDirection(gp.old_tile) == enterdir) {
  3108 				if (IsBridgeTile(gp.old_tile) && GetBridgeRampDirection(gp.old_tile) == enterdir) {
  3107 					/* train entering the bridge body */
  3109 					/* train entering the bridge body */
  3108 					PutTrainOntoBridge(v);
  3110 					PutTrainOntoBridge(v, gp.x, gp.y);
  3109 					UpdateTrainDeltaXY(v, v->direction);
  3111 					UpdateTrainDeltaXY(v, v->direction);
  3110 					if (update_image) v->cur_image = GetTrainImage(v, v->direction);
  3112 					if (update_image) v->cur_image = GetTrainImage(v, v->direction);
  3111 					continue;
  3113 					continue;
  3112 				}
  3114 				}
  3113 
  3115