diff options
author | celestar <celestar@openttd.org> | 2007-03-24 09:12:03 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2007-03-24 09:12:03 +0000 |
commit | 44be40052f0ec958784ab308859e1fd0290e9734 (patch) | |
tree | 0609b0f1d83ccc09e2f2cdf84583392216005ed5 /src/rail_cmd.cpp | |
parent | 6c06a10ffadf36bf1c37e4414053a7a214f79304 (diff) | |
download | openttd-44be40052f0ec958784ab308859e1fd0290e9734.tar.xz |
(svn r9425) -Codechange/Fix (FS#689): Housekeeping in the convert rail functions: Changed the order of error checks to generate more meaningful error messages, added some doxygen comments and replaced bitshifting by proper mathematical operations
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r-- | src/rail_cmd.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index ed6f39649..1c5f3603c 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -849,15 +849,24 @@ int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) typedef int32 DoConvertRailProc(TileIndex tile, RailType totype, bool exec); +/** + * Switches the rail type. + * Railtypes are stored on a per-tile basis, not on a per-track basis, so + * all the tracks in the given tile will be converted. + * @param tile The tile on which the railtype is to be convert. + * @param totype The railtype we want to convert to + * @param exec Switches between test and execute mode + * @return The cost and state of the operation + * @retval CMD_ERROR An error occured during the operation. + */ static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec) { if (!CheckTileOwnership(tile)) return CMD_ERROR; - if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR; - - // tile is already of requested type? if (GetRailType(tile) == totype) return CMD_ERROR; + if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR; + // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR; |