mirror of https://github.com/OpenTTD/OpenTTD
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
parent
2de3dc2735
commit
d06f52a7f0
|
@ -841,8 +841,12 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (dst_head->subtype == TS_Front_Engine)
|
if (dst_head->subtype == TS_Front_Engine)
|
||||||
UpdateTrainAcceleration(dst_head);
|
UpdateTrainAcceleration(dst_head);
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index);
|
||||||
|
/* Update the refit button */
|
||||||
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, dst_head->index, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* I added this to so that the refit buttons get updated */
|
||||||
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, src_head->index, 12);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, src_head->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, src_head->tile);
|
||||||
RebuildVehicleLists();
|
RebuildVehicleLists();
|
||||||
}
|
}
|
||||||
|
|
21
train_gui.c
21
train_gui.c
|
@ -809,16 +809,29 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch(e->event) {
|
switch(e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
Vehicle *v;
|
Vehicle *v, *u;
|
||||||
StringID str;
|
StringID str;
|
||||||
|
|
||||||
v = GetVehicle(w->window_number);
|
v = GetVehicle(w->window_number);
|
||||||
|
|
||||||
w->disabled_state = (v->owner == _local_player) ? 0 : 0x380;
|
w->disabled_state = (v->owner == _local_player) ? 0 : 0x380;
|
||||||
|
|
||||||
if (v->cargo_cap == 0) {
|
SETBIT(w->disabled_state, 12);
|
||||||
//we cannot refit this engine
|
|
||||||
SETBIT(w->disabled_state, 12);
|
/* See if any carriage can be refitted */
|
||||||
|
for ( u = v; u != NULL; u = u->next) {
|
||||||
|
if (_engine_refit_masks[u->engine_type] != 0) {
|
||||||
|
CLRBIT(w->disabled_state, 12);
|
||||||
|
/* We have a refittable carriage, bail out */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Above code doesn't seem to handle non-newgrf engines, do it separately
|
||||||
|
TODO: handle engines which are NOT the head of the train, but don't break wagons */
|
||||||
|
if (v->cargo_cap != 0) {
|
||||||
|
/* we can refit this engine */
|
||||||
|
CLRBIT(w->disabled_state, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw widgets & caption */
|
/* draw widgets & caption */
|
||||||
|
|
Loading…
Reference in New Issue