train_cmd.c
branch0.4
changeset 10025 c904d781d751
parent 10014 9157e384afb6
child 10039 2f478be92946
equal deleted inserted replaced
10024:cec4977c086d 10025:c904d781d751
  2286 }
  2286 }
  2287 
  2287 
  2288 static bool ProcessTrainOrder(Vehicle *v)
  2288 static bool ProcessTrainOrder(Vehicle *v)
  2289 {
  2289 {
  2290 	const Order *order;
  2290 	const Order *order;
  2291 	bool result;
  2291 	bool at_waypoint = false;
  2292 
  2292 
  2293 	// These are un-interruptible
  2293 	// These are un-interruptible
  2294 	if (v->current_order.type >= OT_GOTO_DEPOT &&
  2294 	if (v->current_order.type >= OT_GOTO_DEPOT &&
  2295 			v->current_order.type <= OT_LEAVESTATION) {
  2295 			v->current_order.type <= OT_LEAVESTATION) {
  2296 		// Let a depot order in the orderlist interrupt.
  2296 		// Let a depot order in the orderlist interrupt.
  2306 	}
  2306 	}
  2307 
  2307 
  2308 	// check if we've reached the waypoint?
  2308 	// check if we've reached the waypoint?
  2309 	if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) {
  2309 	if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) {
  2310 		v->cur_order_index++;
  2310 		v->cur_order_index++;
       
  2311 		at_waypoint = true;
  2311 	}
  2312 	}
  2312 
  2313 
  2313 	// check if we've reached a non-stop station while TTDPatch nonstop is enabled..
  2314 	// check if we've reached a non-stop station while TTDPatch nonstop is enabled..
  2314 	if (_patches.new_nonstop &&
  2315 	if (_patches.new_nonstop &&
  2315 			v->current_order.flags & OF_NON_STOP &&
  2316 			v->current_order.flags & OF_NON_STOP &&
  2340 	// Otherwise set it, and determine the destination tile.
  2341 	// Otherwise set it, and determine the destination tile.
  2341 	v->current_order = *order;
  2342 	v->current_order = *order;
  2342 
  2343 
  2343 	v->dest_tile = 0;
  2344 	v->dest_tile = 0;
  2344 
  2345 
  2345 	result = false;
  2346 	InvalidateVehicleOrder(v);
       
  2347 
  2346 	switch (order->type) {
  2348 	switch (order->type) {
  2347 		case OT_GOTO_STATION:
  2349 		case OT_GOTO_STATION:
  2348 			if (order->station == v->last_station_visited)
  2350 			if (order->station == v->last_station_visited)
  2349 				v->last_station_visited = INVALID_STATION;
  2351 				v->last_station_visited = INVALID_STATION;
  2350 			v->dest_tile = GetStation(order->station)->xy;
  2352 			v->dest_tile = GetStation(order->station)->xy;
  2351 			result = CheckReverseTrain(v);
       
  2352 			break;
  2353 			break;
  2353 
  2354 
  2354 		case OT_GOTO_DEPOT:
  2355 		case OT_GOTO_DEPOT:
  2355 			v->dest_tile = GetDepot(order->station)->xy;
  2356 			v->dest_tile = GetDepot(order->station)->xy;
  2356 			result = CheckReverseTrain(v);
       
  2357 			break;
  2357 			break;
  2358 
  2358 
  2359 		case OT_GOTO_WAYPOINT:
  2359 		case OT_GOTO_WAYPOINT:
  2360 			v->dest_tile = GetWaypoint(order->station)->xy;
  2360 			v->dest_tile = GetWaypoint(order->station)->xy;
  2361 			result = CheckReverseTrain(v);
       
  2362 			break;
  2361 			break;
  2363 	}
  2362 
  2364 
  2363 		default:
  2365 	InvalidateVehicleOrder(v);
  2364 			return false;
  2366 
  2365 	}
  2367 	return result;
  2366 
       
  2367 	return !at_waypoint && CheckReverseTrain(v);
  2368 }
  2368 }
  2369 
  2369 
  2370 static void MarkTrainDirty(Vehicle *v)
  2370 static void MarkTrainDirty(Vehicle *v)
  2371 {
  2371 {
  2372 	do {
  2372 	do {