summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_gui.c18
-rw-r--r--roadveh_gui.c18
-rw-r--r--ship_gui.c19
-rw-r--r--train_gui.c18
4 files changed, 32 insertions, 41 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 33f81cf9d..163718e1d 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -130,16 +130,14 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
} break;
- case 6: /* rename */
- WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine;
- ShowQueryString(
- GetCustomEngineName(WP(w,buildtrain_d).sel_engine),
- STR_A039_RENAME_AIRCRAFT_TYPE,
- 31,
- 160,
- w->window_class,
- w->window_number);
- break;
+ case 6: { /* rename */
+ int sel_eng = WP(w,buildtrain_d).sel_engine;
+ if (sel_eng != -1) {
+ WP(w,buildtrain_d).rename_engine = sel_eng;
+ ShowQueryString(GetCustomEngineName(sel_eng),
+ STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number);
+ }
+ } break;
}
break;
diff --git a/roadveh_gui.c b/roadveh_gui.c
index f55e1fef5..ab835ecf8 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -411,16 +411,14 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE));
} break;
- case 6: /* rename */
- WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine;
- ShowQueryString(
- GetCustomEngineName(WP(w,buildtrain_d).sel_engine),
- STR_9036_RENAME_ROAD_VEHICLE_TYPE,
- 31,
- 160,
- w->window_class,
- w->window_number);
- break;
+ case 6: { /* rename */
+ int sel_eng = WP(w,buildtrain_d).sel_engine;
+ if (sel_eng != -1) {
+ WP(w,buildtrain_d).rename_engine = sel_eng;
+ ShowQueryString(GetCustomEngineName(sel_eng),
+ STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number);
+ }
+ } break;
}
break;
diff --git a/ship_gui.c b/ship_gui.c
index f08b3e0d9..491f42c6d 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -402,17 +402,14 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
} break;
- case 6: /* rename */
- WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine;
- ShowQueryString(
- GetCustomEngineName(WP(w,buildtrain_d).sel_engine),
- STR_9838_RENAME_SHIP_TYPE,
- 31,
- 160,
- w->window_class,
- w->window_number);
- break;
-
+ case 6: { /* rename */
+ int sel_eng = WP(w,buildtrain_d).sel_engine;
+ if (sel_eng != -1) {
+ WP(w,buildtrain_d).rename_engine = sel_eng;
+ ShowQueryString(GetCustomEngineName(sel_eng),
+ STR_9838_RENAME_SHIP_TYPE, 31, 160, w->window_class, w->window_number);
+ }
+ } break;
}
break;
diff --git a/train_gui.c b/train_gui.c
index 9333ecf1f..4b22c66d5 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -200,16 +200,14 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
if (sel_eng != -1)
DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
} break;
- case 6:
- WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine;
- ShowQueryString(
- GetCustomEngineName(WP(w,buildtrain_d).sel_engine),
- STR_886A_RENAME_TRAIN_VEHICLE_TYPE,
- 31,
- 160,
- w->window_class,
- w->window_number);
- break;
+ case 6: { /* rename */
+ int sel_eng = WP(w,buildtrain_d).sel_engine;
+ if (sel_eng != -1) {
+ WP(w,buildtrain_d).rename_engine = sel_eng;
+ ShowQueryString(GetCustomEngineName(sel_eng),
+ STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number);
+ }
+ } break;
}
} break;