train_cmd.c
changeset 755 823358e83abf
parent 744 41293b73ebbb
child 812 79c99885ad00
equal deleted inserted replaced
754:d419123e39d6 755:823358e83abf
   750 		return CMD_ERROR;
   750 		return CMD_ERROR;
   751 
   751 
   752 	if (flags & DC_EXEC) {
   752 	if (flags & DC_EXEC) {
   753 		v->u.rail.days_since_order_progr = 0;
   753 		v->u.rail.days_since_order_progr = 0;
   754 		v->vehstatus ^= VS_STOPPED;
   754 		v->vehstatus ^= VS_STOPPED;
   755 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
   755 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   756 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   756 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   757 	}
   757 	}
   758 	return 0;
   758 	return 0;
   759 }
   759 }
   760 
   760 
   910 static void SetLastSpeed(Vehicle *v, int spd) {
   910 static void SetLastSpeed(Vehicle *v, int spd) {
   911 	int old = v->u.rail.last_speed;
   911 	int old = v->u.rail.last_speed;
   912 	if (spd != old) {
   912 	if (spd != old) {
   913 		v->u.rail.last_speed = spd;
   913 		v->u.rail.last_speed = spd;
   914 		if (_patches.vehicle_speed || !old != !spd)
   914 		if (_patches.vehicle_speed || !old != !spd)
   915 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
   915 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   916 	}
   916 	}
   917 }
   917 }
   918 
   918 
   919 static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
   919 static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
   920 {
   920 {
  1182 				v->cur_order_index++;
  1182 				v->cur_order_index++;
  1183 			}
  1183 			}
  1184 
  1184 
  1185 			v->current_order.type = OT_DUMMY;
  1185 			v->current_order.type = OT_DUMMY;
  1186 			v->current_order.flags = 0;
  1186 			v->current_order.flags = 0;
  1187 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
  1187 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1188 		}
  1188 		}
  1189 		return 0;
  1189 		return 0;
  1190 	}
  1190 	}
  1191 
  1191 
  1192 	tfdd = FindClosestTrainDepot(v);
  1192 	tfdd = FindClosestTrainDepot(v);
  1196 	if (flags & DC_EXEC) {
  1196 	if (flags & DC_EXEC) {
  1197 		v->dest_tile = tfdd.tile;
  1197 		v->dest_tile = tfdd.tile;
  1198 		v->current_order.type = OT_GOTO_DEPOT;
  1198 		v->current_order.type = OT_GOTO_DEPOT;
  1199 		v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
  1199 		v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
  1200 		v->current_order.station = GetDepotByTile(tfdd.tile);
  1200 		v->current_order.station = GetDepotByTile(tfdd.tile);
  1201 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
  1201 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1202 	}
  1202 	}
  1203 
  1203 
  1204 	return 0;
  1204 	return 0;
  1205 }
  1205 }
  1206 
  1206 
  1803 	if (LoadUnloadVehicle(v) != 0) {
  1803 	if (LoadUnloadVehicle(v) != 0) {
  1804 		InvalidateWindow(WC_TRAINS_LIST, v->owner);
  1804 		InvalidateWindow(WC_TRAINS_LIST, v->owner);
  1805 		MarkTrainDirty(v);
  1805 		MarkTrainDirty(v);
  1806 		UpdateTrainAcceleration(v);
  1806 		UpdateTrainAcceleration(v);
  1807 	}
  1807 	}
  1808 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
  1808 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1809 }
  1809 }
  1810 
  1810 
  1811 static byte AfterSetTrainPos(Vehicle *v)
  1811 static byte AfterSetTrainPos(Vehicle *v)
  1812 {
  1812 {
  1813 	byte new_z, old_z;
  1813 	byte new_z, old_z;
  1995 	u = v;
  1995 	u = v;
  1996 	BEGIN_ENUM_WAGONS(v)
  1996 	BEGIN_ENUM_WAGONS(v)
  1997 		v->vehstatus |= VS_CRASHED;
  1997 		v->vehstatus |= VS_CRASHED;
  1998 	END_ENUM_WAGONS(v)
  1998 	END_ENUM_WAGONS(v)
  1999 
  1999 
  2000 	InvalidateWindowWidget(WC_VEHICLE_VIEW, u->index, 4);
  2000 	InvalidateWindowWidget(WC_VEHICLE_VIEW, u->index, STATUS_BAR);
  2001 }
  2001 }
  2002 
  2002 
  2003 static int CountPassengersInTrain(Vehicle *v)
  2003 static int CountPassengersInTrain(Vehicle *v)
  2004 {
  2004 {
  2005 	int num = 0;
  2005 	int num = 0;
  2114 					}
  2114 					}
  2115 
  2115 
  2116 					if (v->current_order.type == OT_LEAVESTATION) {
  2116 					if (v->current_order.type == OT_LEAVESTATION) {
  2117 						v->current_order.type = OT_NOTHING;
  2117 						v->current_order.type = OT_NOTHING;
  2118 						v->current_order.flags = 0;
  2118 						v->current_order.flags = 0;
  2119 						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
  2119 						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  2120 					}
  2120 					}
  2121 				}
  2121 				}
  2122 			} else {
  2122 			} else {
  2123 				/* A new tile is about to be entered. */
  2123 				/* A new tile is about to be entered. */
  2124 
  2124 
  2679 			/* If we were already heading for a depot but it has
  2679 			/* If we were already heading for a depot but it has
  2680 			 * suddenly moved farther away, we continue our normal
  2680 			 * suddenly moved farther away, we continue our normal
  2681 			 * schedule? */
  2681 			 * schedule? */
  2682 			v->current_order.type = OT_DUMMY;
  2682 			v->current_order.type = OT_DUMMY;
  2683 			v->current_order.flags = 0;
  2683 			v->current_order.flags = 0;
  2684 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
  2684 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  2685 		}
  2685 		}
  2686 		return;
  2686 		return;
  2687 	}
  2687 	}
  2688 
  2688 
  2689 	depot = GetDepotByTile(tfdd.tile);
  2689 	depot = GetDepotByTile(tfdd.tile);
  2695 
  2695 
  2696 	v->current_order.type = OT_GOTO_DEPOT;
  2696 	v->current_order.type = OT_GOTO_DEPOT;
  2697 	v->current_order.flags = OF_NON_STOP;
  2697 	v->current_order.flags = OF_NON_STOP;
  2698 	v->current_order.station = depot;
  2698 	v->current_order.station = depot;
  2699 	v->dest_tile = tfdd.tile;
  2699 	v->dest_tile = tfdd.tile;
  2700 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
  2700 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  2701 }
  2701 }
  2702 
  2702 
  2703 int32 GetTrainRunningCost(Vehicle *v)
  2703 int32 GetTrainRunningCost(Vehicle *v)
  2704 {
  2704 {
  2705 	int32 cost = 0;
  2705 	int32 cost = 0;