src/bridge_cmd.cpp
branchcustombridgeheads
changeset 5650 aefc131bf5ce
parent 5649 55c8267c933f
child 5651 335d9bd345b0
equal deleted inserted replaced
5649:55c8267c933f 5650:aefc131bf5ce
   188 
   188 
   189 	if (p1 >= MapSize()) return CMD_ERROR;
   189 	if (p1 >= MapSize()) return CMD_ERROR;
   190 
   190 
   191 	// type of bridge
   191 	// type of bridge
   192 	if (HASBIT(p2, 15)) {
   192 	if (HASBIT(p2, 15)) {
   193 		railtype = 0;
   193 		railtype = RAILTYPE_BEGIN;
   194 		transport = TRANSPORT_ROAD;
   194 		transport = TRANSPORT_ROAD;
   195 	} else {
   195 	} else {
   196 		if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR;
   196 		if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR;
   197 		railtype = GB(p2, 8, 8);
   197 		railtype = (RailType)GB(p2, 8, 8);
   198 		transport = TRANSPORT_RAIL;
   198 		transport = TRANSPORT_RAIL;
   199 	}
   199 	}
   200 
   200 
   201 	x = TileX(end_tile);
   201 	x = TileX(end_tile);
   202 	y = TileY(end_tile);
   202 	y = TileY(end_tile);
   831 			if (IsSteepSlope(tileh)) {
   831 			if (IsSteepSlope(tileh)) {
   832 				z += TILE_HEIGHT;
   832 				z += TILE_HEIGHT;
   833 			} else if (f < 15) {
   833 			} else if (f < 15) {
   834 				return z + TILE_HEIGHT;
   834 				return z + TILE_HEIGHT;
   835 			}
   835 			}
   836 			tileh = _inclined_tileh[f - 15];
   836 			tileh = (Slope)_inclined_tileh[f - 15];
   837 		}
   837 		}
   838 	}
   838 	}
   839 	return z + GetPartialZ(x, y, tileh);
   839 	return z + GetPartialZ(x, y, tileh);
   840 }
   840 }
   841 
   841 
   846 	} else {
   846 	} else {
   847 		uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
   847 		uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
   848 
   848 
   849 		if (f == 0) return tileh;
   849 		if (f == 0) return tileh;
   850 		if (f < 15) return SLOPE_FLAT;
   850 		if (f < 15) return SLOPE_FLAT;
   851 		return _inclined_tileh[f - 15];
   851 		return (Slope)_inclined_tileh[f - 15];
   852 	}
   852 	}
   853 }
   853 }
   854 
   854 
   855 static void GetAcceptedCargo_Bridge(TileIndex tile, AcceptedCargo ac)
   855 static void GetAcceptedCargo_Bridge(TileIndex tile, AcceptedCargo ac)
   856 {
   856 {
  1016 
  1016 
  1017 	dir = GetBridgeRampDirection(tile);
  1017 	dir = GetBridgeRampDirection(tile);
  1018 
  1018 
  1019 	if (v->direction == DiagDirToDir(ReverseDiagDir(dir))) {
  1019 	if (v->direction == DiagDirToDir(ReverseDiagDir(dir))) {
  1020 		/* We are entering the bridge head from the bridge itself */
  1020 		/* We are entering the bridge head from the bridge itself */
  1021 		if (v->u.rail.track == 0x40) {
  1021 		if (v->u.rail.track == TRACK_BIT_WORMHOLE) {
  1022 			/* Get the vehicle out of the wormhole, the track will be chosen later
  1022 			/* Get the vehicle out of the wormhole, the track will be chosen later
  1023 			   by the pathfinder */
  1023 			   by the pathfinder */
  1024 			v->tile = tile;
  1024 			v->tile = tile;
  1025 			v->u.rail.track = TrackToTrackBits(TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
  1025 			v->u.rail.track = TrackToTrackBits(TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
  1026 			return 4;
  1026 			return 4;
  1044 			/* Non-zero bridge length. Adjust the other coordinate to the middle of tile
  1044 			/* Non-zero bridge length. Adjust the other coordinate to the middle of tile
  1045 			* to allow train controller to select proper vehicle image */
  1045 			* to allow train controller to select proper vehicle image */
  1046 			if (diff.x != 0) v->y_pos = y; else v->x_pos = x;
  1046 			if (diff.x != 0) v->y_pos = y; else v->x_pos = x;
  1047 			v->direction = DiagDirToDir(dir);
  1047 			v->direction = DiagDirToDir(dir);
  1048 			/* We're about to enter the bridge body, clear all up/down flags just in case */
  1048 			/* We're about to enter the bridge body, clear all up/down flags just in case */
  1049 			v->u.rail.track = 0x40;
  1049 			v->u.rail.track = TRACK_BIT_WORMHOLE;
  1050 			v->direction = DiagDirToDir(dir);
  1050 			v->direction = DiagDirToDir(dir);
  1051 			CLRBIT(v->u.rail.flags, VRF_GOINGUP);
  1051 			CLRBIT(v->u.rail.flags, VRF_GOINGUP);
  1052 			CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
  1052 			CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
  1053 			return 4;
  1053 			return 4;
  1054 		} else {
  1054 		} else {
  1066 	if (v->type == VEH_Road) return VehicleEnter_Street_Bridge(v, tile, x, y);
  1066 	if (v->type == VEH_Road) return VehicleEnter_Street_Bridge(v, tile, x, y);
  1067 
  1067 
  1068 	NOT_REACHED();
  1068 	NOT_REACHED();
  1069 }
  1069 }
  1070 
  1070 
  1071 const TileTypeProcs _tile_type_bridge_procs = {
  1071 extern const TileTypeProcs _tile_type_bridge_procs = {
  1072 	DrawTile_Bridge,           /* draw_tile_proc */
  1072 	DrawTile_Bridge,           /* draw_tile_proc */
  1073 	GetSlopeZ_Bridge,          /* get_slope_z_proc */
  1073 	GetSlopeZ_Bridge,          /* get_slope_z_proc */
  1074 	ClearTile_Bridge,          /* clear_tile_proc */
  1074 	ClearTile_Bridge,          /* clear_tile_proc */
  1075 	GetAcceptedCargo_Bridge,   /* get_accepted_cargo_proc */
  1075 	GetAcceptedCargo_Bridge,   /* get_accepted_cargo_proc */
  1076 	GetTileDesc_Bridge,        /* get_tile_desc_proc */
  1076 	GetTileDesc_Bridge,        /* get_tile_desc_proc */