|
@@ -418,13 +418,13 @@ static void train_engine_drawing_loop(in
|
|
|
|
|
|
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
|
|
|
const Engine *e = GetEngine(i);
|
|
|
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;
|
|
|
|
|
|
if (*sel == 0) *selected_id = i;
|
|
|
|
|
@@ -477,13 +477,13 @@ static void SetupScrollStuffForReplaceWi
|
|
|
w->widget[16].color = _player_colors[_local_player]; // sets the colour of that art thing
|
|
|
for (engine_id = 0; engine_id < NUM_TRAIN_ENGINES; engine_id++) {
|
|
|
const Engine *e = GetEngine(engine_id);
|
|
|
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]--;
|
|
|
}
|
|
|
if (HASBIT(e->player_avail, _local_player)) {
|
|
|
if (sel[1] == 0) selected_id[1] = engine_id;
|
|
@@ -500,13 +500,13 @@ static void SetupScrollStuffForReplaceWi
|
|
|
byte cargo;
|
|
|
const EngineInfo* info;
|
|
|
engine_id = ROAD_ENGINES_INDEX;
|
|
|
|
|
|
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]--;
|
|
|
}
|
|
|
} while (++engine_id,++e,--num);
|
|
|
|
|
@@ -533,13 +533,13 @@ static void SetupScrollStuffForReplaceWi
|
|
|
byte cargo, refittable;
|
|
|
const EngineInfo* info;
|
|
|
engine_id = SHIP_ENGINES_INDEX;
|
|
|
|
|
|
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]--;
|
|
|
}
|
|
|
} while (++engine_id,++e,--num);
|
|
|
|
|
@@ -568,13 +568,13 @@ static void SetupScrollStuffForReplaceWi
|
|
|
const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
|
|
|
const EngineInfo* info;
|
|
|
engine_id = AIRCRAFT_ENGINES_INDEX;
|
|
|
|
|
|
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]--;
|
|
|
}
|
|
|
} while (++engine_id,++e,--num);
|
|
|
|
|
@@ -647,13 +647,13 @@ static void DrawEngineArrayInReplaceWind
|
|
|
|
|
|
if (selected_id[0] >= ROAD_ENGINES_INDEX && selected_id[0] < SHIP_ENGINES_INDEX) {
|
|
|
cargo = RoadVehInfo(selected_id[0])->cargo_type;
|
|
|
|
|
|
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);
|
|
|
SetDParam(0, _player_num_engines[engine_id]);
|
|
|
DrawStringRightAligned(213, y+5, STR_TINY_BLACK, 0);
|
|
|
y += 14;
|
|
@@ -684,13 +684,13 @@ static void DrawEngineArrayInReplaceWind
|
|
|
if (selected_id[0] != -1) {
|
|
|
cargo = ShipVehInfo(selected_id[0])->cargo_type;
|
|
|
refittable = ShipVehInfo(selected_id[0])->refittable;
|
|
|
|
|
|
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);
|
|
|
SetDParam(0, _player_num_engines[engine_id]);
|
|
|
DrawStringRightAligned(213, y+15, STR_TINY_BLACK, 0);
|
|
|
y += 24;
|
|
@@ -719,13 +719,13 @@ static void DrawEngineArrayInReplaceWind
|
|
|
EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
|
|
|
byte subtype = AircraftVehInfo(selected_id[0])->subtype;
|
|
|
const EngineInfo* info;
|
|
|
|
|
|
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);
|
|
|
DrawAircraftEngine(x+29, y+10, engine_id, _player_num_engines[engine_id] > 0 ? SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)) : PALETTE_CRASH);
|
|
|
SetDParam(0, _player_num_engines[engine_id]);
|
|
|
DrawStringRightAligned(213, y+15, STR_TINY_BLACK, 0);
|
|
@@ -832,23 +832,23 @@ static void ReplaceVehicleWndProc(Window
|
|
|
// Either list is empty
|
|
|
// or Both lists have the same vehicle selected
|
|
|
// or The right list (new replacement) has the existing replacement vehicle selected
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
// Disable the "Stop Replacing" button if:
|
|
|
// 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);
|
|
|
}
|
|
|
|
|
|
// now the actual drawing of the window itself takes place
|
|
@@ -860,16 +860,16 @@ static void ReplaceVehicleWndProc(Window
|
|
|
}
|
|
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
// 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);
|
|
|
}
|
|
|
|
|
|
DrawString(145, (w->resize.step_height == 24 ? 67 : 87) + w->resize.step_height * w->vscroll.cap, STR_02BD, 0x10);
|