src/rail_cmd.cpp
changeset 8236 8a5dd0b42e47
parent 8230 64f28fe2d5c8
child 8238 d47a86c79603
equal deleted inserted replaced
8235:7987f051dd76 8236:8a5dd0b42e47
   301  * @param p2 rail track to build
   301  * @param p2 rail track to build
   302  */
   302  */
   303 CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   303 CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   304 {
   304 {
   305 	Slope tileh;
   305 	Slope tileh;
   306 	RailType railtype;
   306 	RailType railtype = (RailType)p1;
   307 	Track track;
   307 	Track track = (Track)p2;
   308 	TrackBits trackbit;
   308 	TrackBits trackbit;
   309 	CommandCost cost(EXPENSES_CONSTRUCTION);
   309 	CommandCost cost(EXPENSES_CONSTRUCTION);
   310 	CommandCost ret;
   310 	CommandCost ret;
   311 
   311 
   312 	if (!ValParamRailtype(p1) || !ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
   312 	if (!ValParamRailtype(railtype) || !ValParamTrackOrientation(track)) return CMD_ERROR;
   313 	railtype = (RailType)p1;
       
   314 	track = (Track)p2;
       
   315 
   313 
   316 	tileh = GetTileSlope(tile, NULL);
   314 	tileh = GetTileSlope(tile, NULL);
   317 	trackbit = TrackToTrackBits(track);
   315 	trackbit = TrackToTrackBits(track);
   318 
   316 
   319 	switch (GetTileType(tile)) {
   317 	switch (GetTileType(tile)) {
   701 CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   699 CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   702 {
   700 {
   703 	Slope tileh;
   701 	Slope tileh;
   704 
   702 
   705 	/* check railtype and valid direction for depot (0 through 3), 4 in total */
   703 	/* check railtype and valid direction for depot (0 through 3), 4 in total */
   706 	if (!ValParamRailtype(p1)) return CMD_ERROR;
   704 	if (!ValParamRailtype((RailType)p1)) return CMD_ERROR;
   707 
   705 
   708 	tileh = GetTileSlope(tile, NULL);
   706 	tileh = GetTileSlope(tile, NULL);
   709 
   707 
   710 	DiagDirection dir = Extract<DiagDirection, 0>(p2);
   708 	DiagDirection dir = Extract<DiagDirection, 0>(p2);
   711 
   709 
  1148  * @param p2 new railtype to convert to
  1146  * @param p2 new railtype to convert to
  1149  */
  1147  */
  1150 CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
  1148 CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
  1151 {
  1149 {
  1152 	CommandCost cost(EXPENSES_CONSTRUCTION);
  1150 	CommandCost cost(EXPENSES_CONSTRUCTION);
  1153 
  1151 	RailType totype = (RailType)p2;
  1154 	if (!ValParamRailtype(p2)) return CMD_ERROR;
  1152 
       
  1153 	if (!ValParamRailtype(totype)) return CMD_ERROR;
  1155 	if (p1 >= MapSize()) return CMD_ERROR;
  1154 	if (p1 >= MapSize()) return CMD_ERROR;
  1156 
       
  1157 	RailType totype = (RailType)p2;
       
  1158 
  1155 
  1159 	uint ex = TileX(tile);
  1156 	uint ex = TileX(tile);
  1160 	uint ey = TileY(tile);
  1157 	uint ey = TileY(tile);
  1161 	uint sx = TileX(p1);
  1158 	uint sx = TileX(p1);
  1162 	uint sy = TileY(p1);
  1159 	uint sy = TileY(p1);