mirror of https://github.com/OpenTTD/OpenTTD
(svn r20585) [1.0] -Backport from trunk:
- Fix: Autoreplace failed while attaching non-replaced wagons to the new chain, if to-be-sold-engines would become front-engines and the unitnumber limit would be exceeded (r20583) - Fix: Autoreplace can trigger an assertion when at the vehicle limit [FS#4044] (r20582) - Fix: Go via station and go via waypoint behaved differently when a train went back to the same (unordered) station again [FS#4039] (r20580) - Fix: Draw bounding boxes using white instead of pure white, so they are recoloured to grey in coloured newspaper instead of blue [FS#4051] (r20578) - Fix: Scroll button flickering when pressed [FS#4043] (r20577)release/1.0
parent
544887688b
commit
7cf8dd70c3
|
@ -454,6 +454,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
|
||||
/* Append engines to the new chain
|
||||
* We do this from back to front, so that the head of the temporary vehicle chain does not change all the time.
|
||||
* That way we also have less trouble when exceeding the unitnumber limit.
|
||||
* OTOH the vehicle attach callback is more expensive this way :s */
|
||||
Train *last_engine = NULL; ///< Shall store the last engine unit after this step
|
||||
if (cost.Succeeded()) {
|
||||
|
@ -462,6 +463,13 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
|
||||
if (RailVehInfo(append->engine_type)->railveh_type == RAILVEH_WAGON) continue;
|
||||
|
||||
if (new_vehs[i] != NULL) {
|
||||
/* Move the old engine to a separate row with DC_AUTOREPLACE. Else
|
||||
* moving the wagon in front may fail later due to unitnumber limit.
|
||||
* (We have to attach wagons without DC_AUTOREPLACE.) */
|
||||
MoveVehicle(old_vehs[i], NULL, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
}
|
||||
|
||||
if (last_engine == NULL) last_engine = append;
|
||||
cost.AddCost(MoveVehicle(append, new_head, DC_EXEC, false));
|
||||
if (cost.Failed()) break;
|
||||
|
|
|
@ -229,7 +229,7 @@ void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
|
|||
* ....V.
|
||||
*/
|
||||
|
||||
static const byte colour = 255;
|
||||
static const byte colour = 15;
|
||||
|
||||
GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, colour);
|
||||
GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, colour);
|
||||
|
|
|
@ -1775,11 +1775,15 @@ bool ProcessOrders(Vehicle *v)
|
|||
*/
|
||||
bool may_reverse = v->current_order.IsType(OT_NOTHING);
|
||||
|
||||
/* Check if we've reached a non-stop station.. */
|
||||
/* Check if we've reached a 'via' destination. */
|
||||
if (((v->current_order.IsType(OT_GOTO_STATION) && (v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) || v->current_order.IsType(OT_GOTO_WAYPOINT)) &&
|
||||
IsTileType(v->tile, MP_STATION) &&
|
||||
v->current_order.GetDestination() == GetStationIndex(v->tile)) {
|
||||
if (v->current_order.IsType(OT_GOTO_STATION)) v->last_station_visited = v->current_order.GetDestination();
|
||||
/* We set the last visited station here because we do not want
|
||||
* the train to stop at this 'via' station if the next order
|
||||
* is a no-non-stop order; in that case not setting the last
|
||||
* visited station will cause the vehicle to still stop. */
|
||||
v->last_station_visited = v->current_order.GetDestination();
|
||||
UpdateVehicleTimetable(v, true);
|
||||
v->IncrementOrderIndex();
|
||||
}
|
||||
|
|
|
@ -1228,9 +1228,10 @@ static CommandCost CheckTrainAttachment(Train *t)
|
|||
* @param dst The destination chain after constructing the train.
|
||||
* @param original_dst The original source chain.
|
||||
* @param dst The source chain after constructing the train.
|
||||
* @param check_limit Whether to check the vehicle limit.
|
||||
* @return possible error of this command.
|
||||
*/
|
||||
static CommandCost ValidateTrains(Train *original_dst, Train *dst, Train *original_src, Train *src)
|
||||
static CommandCost ValidateTrains(Train *original_dst, Train *dst, Train *original_src, Train *src, bool check_limit)
|
||||
{
|
||||
/* Check whether we may actually construct the trains. */
|
||||
CommandCost ret = CheckTrainAttachment(src);
|
||||
|
@ -1239,7 +1240,7 @@ static CommandCost ValidateTrains(Train *original_dst, Train *dst, Train *origin
|
|||
if (ret.Failed()) return ret;
|
||||
|
||||
/* Check whether we need to build a new train. */
|
||||
return CheckNewTrain(original_dst, dst, original_src, src);
|
||||
return check_limit ? CheckNewTrain(original_dst, dst, original_src, src) : CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1403,7 +1404,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||
/* If the autoreplace flag is set we do not need to test for the validity
|
||||
* because we are going to revert the train to its original state. As we
|
||||
* assume the original state was correct autoreplace can skip this. */
|
||||
CommandCost ret = ValidateTrains(original_dst_head, dst_head, original_src_head, src_head);
|
||||
CommandCost ret = ValidateTrains(original_dst_head, dst_head, original_src_head, src_head, true);
|
||||
if (ret.Failed()) {
|
||||
/* Restore the train we had. */
|
||||
RestoreTrainBackup(original_src);
|
||||
|
@ -1533,7 +1534,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
ArrangeTrains(&sell_head, NULL, &new_head, v, sell_chain);
|
||||
|
||||
/* We don't need to validate the second train; it's going to be sold. */
|
||||
CommandCost ret = ValidateTrains(NULL, NULL, first, new_head);
|
||||
CommandCost ret = ValidateTrains(NULL, NULL, first, new_head, (flags & DC_AUTOREPLACE) == 0);
|
||||
if (ret.Failed()) {
|
||||
/* Restore the train we had. */
|
||||
RestoreTrainBackup(original);
|
||||
|
|
|
@ -971,7 +971,9 @@ uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour)
|
|||
bool loading = false;
|
||||
|
||||
const Vehicle *u = v;
|
||||
const Station *st = v->last_station_visited != INVALID_STATION ? Station::Get(v->last_station_visited) : NULL;
|
||||
/* The station may be NULL when the (colour) string does not need to be set. */
|
||||
const Station *st = Station::GetIfValid(v->last_station_visited);
|
||||
assert(colour == NULL || st != NULL);
|
||||
|
||||
/* Count up max and used */
|
||||
for (; v != NULL; v = v->Next()) {
|
||||
|
|
|
@ -107,8 +107,8 @@ static void ScrollbarClickPositioning(Window *w, WidgetType wtp, int x, int y, i
|
|||
if (pos <= mi + 9) {
|
||||
/* Pressing the upper button? */
|
||||
w->flags4 |= WF_SCROLL_UP;
|
||||
if (_scroller_click_timeout == 0) {
|
||||
_scroller_click_timeout = 6;
|
||||
if (_scroller_click_timeout <= 1) {
|
||||
_scroller_click_timeout = 3;
|
||||
sb->UpdatePosition(rtl ? 1 : -1);
|
||||
}
|
||||
_left_button_clicked = false;
|
||||
|
@ -116,8 +116,8 @@ static void ScrollbarClickPositioning(Window *w, WidgetType wtp, int x, int y, i
|
|||
/* Pressing the lower button? */
|
||||
w->flags4 |= WF_SCROLL_DOWN;
|
||||
|
||||
if (_scroller_click_timeout == 0) {
|
||||
_scroller_click_timeout = 6;
|
||||
if (_scroller_click_timeout <= 1) {
|
||||
_scroller_click_timeout = 3;
|
||||
sb->UpdatePosition(rtl ? -1 : 1);
|
||||
}
|
||||
_left_button_clicked = false;
|
||||
|
|
|
@ -53,7 +53,7 @@ Point _cursorpos_drag_start;
|
|||
|
||||
int _scrollbar_start_pos;
|
||||
int _scrollbar_size;
|
||||
byte _scroller_click_timeout;
|
||||
byte _scroller_click_timeout = 0;
|
||||
|
||||
bool _scrolling_scrollbar;
|
||||
bool _scrolling_viewport;
|
||||
|
@ -1321,7 +1321,7 @@ static void DecreaseWindowCounters()
|
|||
Window *w;
|
||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||
/* Unclick scrollbar buttons if they are pressed. */
|
||||
if (w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
|
||||
if (_scroller_click_timeout == 0 && w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
|
||||
w->flags4 &= ~(WF_SCROLL_DOWN | WF_SCROLL_UP);
|
||||
w->SetDirty();
|
||||
}
|
||||
|
@ -2388,11 +2388,7 @@ void InvalidateWindowClassesData(WindowClass cls, int data)
|
|||
*/
|
||||
void CallWindowTickEvent()
|
||||
{
|
||||
if (_scroller_click_timeout > 3) {
|
||||
_scroller_click_timeout -= 3;
|
||||
} else {
|
||||
_scroller_click_timeout = 0;
|
||||
}
|
||||
if (_scroller_click_timeout != 0) _scroller_click_timeout--;
|
||||
|
||||
Window *w;
|
||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||
|
|
Loading…
Reference in New Issue