diff --git a/vehicle_gui.c b/vehicle_gui.c --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -421,7 +421,7 @@ static void train_engine_drawing_loop(in const RailVehicleInfo *rvi = RailVehInfo(i); const EngineInfo *info = &_engine_info[i]; - if (p->engine_replacement[i] == INVALID_ENGINE && _player_num_engines[i] == 0 && show_outdated) continue; + if (!EngineHasReplacement(p, i) && _player_num_engines[i] == 0 && show_outdated) continue; if (rvi->power == 0 && !show_cars) // disables display of cars (works since they do not have power) continue; @@ -480,7 +480,7 @@ static void SetupScrollStuffForReplaceWi const EngineInfo *info = &_engine_info[engine_id]; if (ENGINE_AVAILABLE && RailVehInfo(engine_id)->power && e->railtype == railtype) { - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { if (sel[0] == 0) selected_id[0] = engine_id; count++; sel[0]--; @@ -503,7 +503,7 @@ static void SetupScrollStuffForReplaceWi do { info = &_engine_info[engine_id]; - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { if (sel[0] == 0) selected_id[0] = engine_id; count++; sel[0]--; @@ -536,7 +536,7 @@ static void SetupScrollStuffForReplaceWi do { info = &_engine_info[engine_id]; - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { if (sel[0] == 0) selected_id[0] = engine_id; count++; sel[0]--; @@ -571,7 +571,7 @@ static void SetupScrollStuffForReplaceWi do { info = &_engine_info[engine_id]; - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { count++; if (sel[0] == 0) selected_id[0] = engine_id; sel[0]--; @@ -650,7 +650,7 @@ static void DrawEngineArrayInReplaceWind do { info = &_engine_info[engine_id]; - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10); DrawRoadVehEngine(x+29, y+6, engine_id, _player_num_engines[engine_id] > 0 ? SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)) : PALETTE_CRASH); @@ -687,7 +687,7 @@ static void DrawEngineArrayInReplaceWind do { info = &_engine_info[engine_id]; - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10); DrawShipEngine(x+35, y+10, engine_id, _player_num_engines[engine_id] > 0 ? SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)) : PALETTE_CRASH); @@ -722,7 +722,7 @@ static void DrawEngineArrayInReplaceWind do { info = &_engine_info[engine_id]; - if (_player_num_engines[engine_id] > 0 || p->engine_replacement[engine_id] != INVALID_ENGINE) { + if (_player_num_engines[engine_id] > 0 || EngineHasReplacement(p, engine_id)) { if (sel[0] == 0) selected_id[0] = engine_id; if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10); @@ -835,7 +835,7 @@ static void ReplaceVehicleWndProc(Window if (selected_id[0] == -1 || selected_id[1] == -1 || selected_id[0] == selected_id[1] || - p->engine_replacement[selected_id[0]] == selected_id[1]) { + EngineReplacement(p, selected_id[0]) == selected_id[1]) { SETBIT(w->disabled_state, 4); } else { CLRBIT(w->disabled_state, 4); @@ -845,7 +845,7 @@ static void ReplaceVehicleWndProc(Window // The left list (existing vehicle) is empty // or The selected vehicle has no replacement set up if (selected_id[0] == -1 || - p->engine_replacement[selected_id[0]] == INVALID_ENGINE) { + !EngineHasReplacement(p, selected_id[0])) { SETBIT(w->disabled_state, 6); } else { CLRBIT(w->disabled_state, 6); @@ -863,10 +863,10 @@ static void ReplaceVehicleWndProc(Window // sets up the string for the vehicle that is being replaced to if (selected_id[0] != -1) { - if (p->engine_replacement[selected_id[0]] == INVALID_ENGINE) { + if (!EngineHasReplacement(p, selected_id[0])) { SetDParam(0, STR_NOT_REPLACING); } else { - SetDParam(0, GetCustomEngineName(p->engine_replacement[selected_id[0]])); + SetDParam(0, GetCustomEngineName(EngineReplacement(p, selected_id[0]))); } } else { SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);