summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-08-06 16:07:22 +0000
committerbjarni <bjarni@openttd.org>2005-08-06 16:07:22 +0000
commit9952ff0b597c3e9da0c9105cc6d2ab32e1ac7b8b (patch)
tree4628a0df8999b185f9edb643da5024f1ae22e3bc /vehicle_gui.c
parenta1a91eb7f7b9bc356e4a97f76fec2d58a5bf914a (diff)
downloadopenttd-9952ff0b597c3e9da0c9105cc6d2ab32e1ac7b8b.tar.xz
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
-This means that one company can only have one setting for renew and replacing more clients will not fight due to different settings anymore -This is a needed step in the line to fix autoreplacing dualheaded locomotives NOTE: savegame revision bump (peter1138 + me in coop)
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 375c32db5..9434d99c5 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -744,6 +744,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
uint16 click_scroll_pos = w->vscroll2.pos;
uint16 click_scroll_cap = w->vscroll2.cap;
byte click_side = 1;
+ Player *p = GetPlayer(_local_player);
switch(e->event) {
case WE_PAINT:
@@ -813,13 +814,13 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
}
}
- if ( selected_id[0] == selected_id[1] || _autoreplace_array[selected_id[0]] == selected_id[1]
+ if ( selected_id[0] == selected_id[1] || p->engine_replacement[selected_id[0]] == selected_id[1]
|| selected_id[0] == -1 || selected_id[1] == -1 )
SETBIT(w->disabled_state, 4);
else
CLRBIT(w->disabled_state, 4);
- if ( _autoreplace_array[selected_id[0]] == selected_id[0] || selected_id[0] == -1 )
+ if (p->engine_replacement[selected_id[0]] == INVALID_ENGINE || selected_id[0] == -1)
SETBIT(w->disabled_state, 6);
else
CLRBIT(w->disabled_state, 6);
@@ -831,10 +832,10 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
// sets up the string for the vehicle that is being replaced to
if ( selected_id[0] != -1 ) {
- if ( selected_id[0] == _autoreplace_array[selected_id[0]] )
+ if (p->engine_replacement[selected_id[0]] == INVALID_ENGINE)
SetDParam(0, STR_NOT_REPLACING);
else
- SetDParam(0, GetCustomEngineName(_autoreplace_array[selected_id[0]]));
+ SetDParam(0, GetCustomEngineName(p->engine_replacement[selected_id[0]]));
} else {
SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
}
@@ -908,14 +909,17 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, 15, ~GetPlayer(_local_player)->avail_railtypes, 1);
break;
}
- case 4: {
- _autoreplace_array[WP(w,replaceveh_d).sel_engine[0]] = WP(w,replaceveh_d).sel_engine[1];
+ case 4: { /* Start replacing */
+ EngineID veh_from = WP(w, replaceveh_d).sel_engine[0];
+ EngineID veh_to = WP(w, replaceveh_d).sel_engine[1];
+ DoCommandP(0, 3, veh_from + (veh_to << 16), NULL, CMD_REPLACE_VEHICLE);
SetWindowDirty(w);
break;
}
- case 6: {
- _autoreplace_array[WP(w,replaceveh_d).sel_engine[0]] = WP(w,replaceveh_d).sel_engine[0];
+ case 6: { /* Stop replacing */
+ EngineID veh_from = WP(w, replaceveh_d).sel_engine[0];
+ DoCommandP(0, 3, veh_from + (INVALID_ENGINE << 16), NULL, CMD_REPLACE_VEHICLE);
SetWindowDirty(w);
break;
}