summaryrefslogtreecommitdiff
path: root/src/players.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-08-10 15:02:21 +0000
committerfrosch <frosch@openttd.org>2008-08-10 15:02:21 +0000
commit4eae917c1ce88d30e81a80230f653cfe7761ea99 (patch)
tree71f1b3a72f2c6f8bfcd5f92e59b693bd3ad4ad7b /src/players.cpp
parentb1ed3bad58d892b38e9a99f6ae7df2df5d1a034d (diff)
downloadopenttd-4eae917c1ce88d30e81a80230f653cfe7761ea99.tar.xz
(svn r14037) -Fix (r8610): The autoreplace gui showed vehicle types for replacement which CmdSetAutoReplace() did not accept.
Diffstat (limited to 'src/players.cpp')
-rw-r--r--src/players.cpp16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/players.cpp b/src/players.cpp
index cf1dca355..c3bef5c3c 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -717,21 +717,7 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (!IsValidGroupID(id_g) && !IsAllGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR;
if (new_engine_type != INVALID_ENGINE) {
- /* First we make sure that it's a valid type the user requested
- * check that it's an engine that is in the engine array */
- if (!IsEngineIndex(new_engine_type)) return CMD_ERROR;
-
- /* check that the new vehicle type is the same as the original one */
- if (GetEngine(old_engine_type)->type != GetEngine(new_engine_type)->type) return CMD_ERROR;
-
- /* make sure that we do not replace a plane with a helicopter or vise versa */
- if (GetEngine(new_engine_type)->type == VEH_AIRCRAFT &&
- (AircraftVehInfo(old_engine_type)->subtype & AIR_CTOL) != (AircraftVehInfo(new_engine_type)->subtype & AIR_CTOL)) {
- return CMD_ERROR;
- }
-
- /* make sure that the player can actually buy the new engine */
- if (!HasBit(GetEngine(new_engine_type)->player_avail, _current_player)) return CMD_ERROR;
+ if (!CheckAutoreplaceValidity(old_engine_type, new_engine_type, _current_player)) return CMD_ERROR;
cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, id_g, flags);
} else {