diff options
author | peter1138 <peter1138@openttd.org> | 2005-11-26 16:41:14 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2005-11-26 16:41:14 +0000 |
commit | 14064b223db33f041005ee86283c73a259153da6 (patch) | |
tree | ccd73fcd302984e4abaf2d806bf28bf73a54e79f /vehicle.c | |
parent | 29a0f76ac9cb2d329dbefff91bc998d6f92d5521 (diff) | |
download | openttd-14064b223db33f041005ee86283c73a259153da6.tar.xz |
(svn r3239) - Codechange: Introduce and use helper functions for engine replacement code.
Diffstat (limited to 'vehicle.c')
-rw-r--r-- | vehicle.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1618,7 +1618,8 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags) bool new_front = false; Vehicle *new_v = NULL; - new_engine_type = p->engine_replacement[old_v->engine_type] == INVALID_ENGINE ? old_v->engine_type : p->engine_replacement[old_v->engine_type]; + new_engine_type = EngineReplacement(p, old_v->engine_type); + if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type; cost = DoCommand(old_v->x_pos, old_v->y_pos, new_engine_type, 1, flags, CMD_BUILD_VEH(old_v->type)); if (CmdFailed(cost)) return cost; @@ -1722,7 +1723,7 @@ static void MaybeReplaceVehicle(Vehicle *v) if (!p->engine_renew || w->age - w->max_age < (p->engine_renew_months * 30) || // replace if engine is too old w->max_age == 0) { // rail cars got a max age of 0 - if (p->engine_replacement[w->engine_type] == INVALID_ENGINE) // updates to a new model + if (!EngineHasReplacement(p, w->engine_type)) // updates to a new model continue; } |