src/road_cmd.cpp
branchcpp_gui
changeset 6285 187e3ef04cc9
parent 6268 4b5241e5dd10
child 6298 c30fe89622df
equal deleted inserted replaced
6284:45d0233e7d79 6285:187e3ef04cc9
     1 /* $Id$ */
     1 /* $Id$ */
     2 
     2 
     3 #include "stdafx.h"
     3 #include "stdafx.h"
     4 #include "openttd.h"
     4 #include "openttd.h"
     5 #include "bridge_map.h"
     5 #include "bridge_map.h"
       
     6 #include "bridge.h"
     6 #include "cmd_helper.h"
     7 #include "cmd_helper.h"
     7 #include "rail_map.h"
     8 #include "rail_map.h"
     8 #include "road_map.h"
     9 #include "road_map.h"
     9 #include "sprite.h"
    10 #include "sprite.h"
    10 #include "table/sprites.h"
    11 #include "table/sprites.h"
   159 			}
   160 			}
   160 
   161 
   161 			if (flags & DC_EXEC) {
   162 			if (flags & DC_EXEC) {
   162 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   163 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   163 
   164 
   164 				MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailTypeCrossing(tile));
   165 				MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
   165 				MarkTileDirtyByTile(tile);
   166 				MarkTileDirtyByTile(tile);
   166 				YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
   167 				YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
   167 			}
   168 			}
   168 			return _price.remove_road * 2;
   169 			return _price.remove_road * 2;
   169 		}
   170 		}
   371 	if (!IsLevelCrossing(tile)) return CMD_ERROR;
   372 	if (!IsLevelCrossing(tile)) return CMD_ERROR;
   372 
   373 
   373 	// not owned by me?
   374 	// not owned by me?
   374 	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
   375 	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
   375 
   376 
   376 	if (GetRailTypeCrossing(tile) == totype) return CMD_ERROR;
   377 	if (GetRailType(tile) == totype) return CMD_ERROR;
   377 
   378 
   378 	// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
   379 	// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
   379 	if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailTypeCrossing(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
   380 	if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
   380 
   381 
   381 	if (exec) {
   382 	if (exec) {
   382 		SetRailTypeCrossing(tile, totype);
   383 		SetRailType(tile, totype);
   383 		MarkTileDirtyByTile(tile);
   384 		MarkTileDirtyByTile(tile);
   384 		YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
   385 		YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
   385 	}
   386 	}
   386 
   387 
   387 	return _price.build_rail >> 1;
   388 	return _price.build_rail >> 1;
   714 			SpriteID image;
   715 			SpriteID image;
   715 			SpriteID pal = PAL_NONE;
   716 			SpriteID pal = PAL_NONE;
   716 
   717 
   717 			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
   718 			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
   718 
   719 
   719 			image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing;
   720 			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.crossing;
   720 
   721 
   721 			if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
   722 			if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
   722 			if (IsCrossingBarred(ti->tile)) image += 2;
   723 			if (IsCrossingBarred(ti->tile)) image += 2;
   723 
   724 
   724 			if (IsOnSnow(ti->tile)) {
   725 			if (IsOnSnow(ti->tile)) {
   730 					default:              image += 4; break; // Paved
   731 					default:              image += 4; break; // Paved
   731 				}
   732 				}
   732 			}
   733 			}
   733 
   734 
   734 			DrawGroundSprite(image, pal);
   735 			DrawGroundSprite(image, pal);
   735 			if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
   736 			if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
   736 			break;
   737 			break;
   737 		}
   738 		}
   738 
   739 
   739 		default:
   740 		default:
   740 		case ROAD_TILE_DEPOT: {
   741 		case ROAD_TILE_DEPOT: {