(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
-Trains will now remember the length of stations it visits and sell cars
when being autoreplaced if they became too long
-If it needs to remove cars, then it starts from the front and sells
all it can find until the train is short enough
-This only works for trains, that knows the station length of the route
so a full uninterrupted run is needed
-a train needs 1-2 runs to detect if the shortest station is expanded
-This feature can be turned on and off in the train replace window
and each company can have it's own setting
-NOTE: minor savegame version bump
This commit is contained in:
@@ -748,10 +748,10 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||
static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
static const StringID _vehicle_type_names[4] = {STR_019F_TRAIN, STR_019C_ROAD_VEHICLE, STR_019E_SHIP,STR_019D_AIRCRAFT};
|
||||
const Player *p = GetPlayer(_local_player);
|
||||
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
const Player *p = GetPlayer(_local_player);
|
||||
int pos = w->vscroll.pos;
|
||||
int selected_id[2] = {-1,-1};
|
||||
int x = 1;
|
||||
@@ -839,6 +839,12 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
// now the actual drawing of the window itself takes place
|
||||
SetDParam(0, _vehicle_type_names[WP(w, replaceveh_d).vehicletype - VEH_Train]);
|
||||
|
||||
if (WP(w, replaceveh_d).vehicletype == VEH_Train) {
|
||||
// set on/off for renew_keep_length
|
||||
SetDParam(1, p->renew_keep_length ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
|
||||
}
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
// sets up the string for the vehicle that is being replaced to
|
||||
@@ -925,6 +931,9 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, 15, 0, ~GetPlayer(_local_player)->avail_railtypes);
|
||||
break;
|
||||
}
|
||||
case 17: { /* toggle renew_keep_length */
|
||||
DoCommandP(0, 5, p->renew_keep_length ? 0 : 1, NULL, CMD_REPLACE_VEHICLE);
|
||||
} break;
|
||||
case 4: { /* Start replacing */
|
||||
EngineID veh_from = WP(w, replaceveh_d).sel_engine[0];
|
||||
EngineID veh_to = WP(w, replaceveh_d).sel_engine[1];
|
||||
@@ -991,7 +1000,7 @@ static const Widget _replace_rail_vehicle_widgets[] = {
|
||||
{ WWT_PANEL, RESIZE_TB, 14, 154, 277, 210, 221, STR_NULL, STR_REPLACE_HELP_RAILTYPE},
|
||||
{ WWT_CLOSEBOX, RESIZE_TB, 14, 278, 289, 210, 221, STR_0225, STR_REPLACE_HELP_RAILTYPE},
|
||||
{ WWT_PANEL, RESIZE_TB, 14, 290, 305, 210, 221, STR_NULL, STR_NULL},
|
||||
{ WWT_PANEL, RESIZE_TB, 14, 317, 455, 198, 209, STR_NULL, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 317, 455, 198, 209, STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP},
|
||||
// end of train specific stuff
|
||||
{ WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 210, 221, STR_NULL, STR_RESIZE_BUTTON},
|
||||
{ WIDGETS_END},
|
||||
|
||||
Reference in New Issue
Block a user