Changeset - r8832:6c9ef37d3595
[Not reviewed]
master
0 4 0
rubidium - 16 years ago 2008-04-05 15:30:15
rubidium@openttd.org
(svn r12580) -Codechange: merge some logical related to non-stop orders.
4 files changed with 26 insertions and 31 deletions:
0 comments (0 inline, 0 general)
src/order_base.h
Show inline comments
 
@@ -9,6 +9,8 @@
 
#include "oldpool.h"
 
#include "core/bitmath_func.hpp"
 
#include "cargo_type.h"
 
#include "station_type.h"
 
#include "vehicle_type.h"
 

	
 
DECLARE_OLD_POOL(Order, Order, 6, 1000)
 

	
 
@@ -40,6 +42,8 @@ struct Order : PoolItem<Order, OrderID, 
 

	
 
	void Free();
 
	void FreeChain();
 

	
 
	bool ShouldStopAtStation(const Vehicle *v, StationID station) const;
 
};
 

	
 
static inline VehicleOrderID GetMaxOrderIndex()
src/order_cmd.cpp
Show inline comments
 
@@ -1343,6 +1343,7 @@ bool ProcessOrders(Vehicle *v)
 
			v->current_order.flags & OFB_NON_STOP &&
 
			IsTileType(v->tile, MP_STATION) &&
 
			v->current_order.dest == GetStationIndex(v->tile)) {
 
		v->last_station_visited = v->current_order.dest;
 
		UpdateVehicleTimetable(v, true);
 
		v->cur_order_index++;
 
	}
 
@@ -1414,6 +1415,23 @@ bool ProcessOrders(Vehicle *v)
 
	return may_reverse;
 
}
 

	
 
/**
 
 * Check whether the given vehicle should stop at the given station
 
 * based on this order and the non-stop settings.
 
 * @param v       the vehicle that might be stopping.
 
 * @param station the station to stop at.
 
 * @return true if the vehicle should stop.
 
 */
 
bool Order::ShouldStopAtStation(const Vehicle *v, StationID station) const
 
{
 
	return
 
			v->last_station_visited != station && // Do stop only when we've not just been there
 
			type == OT_GOTO_STATION &&            // Do stop only when going to a station
 
			/* Finally do stop when the non-stop flag is not set, or when we should stop at
 
			 * this station according to the new_nonstop setting. */
 
			(!this->flags & OFB_NON_STOP || ((this->dest != station) == _patches.new_nonstop));
 
}
 

	
 
void InitializeOrders()
 
{
 
	_Order_pool.CleanPool();
src/station_cmd.cpp
Show inline comments
 
@@ -2399,16 +2399,12 @@ static const byte _enter_station_speedta
 

	
 
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	StationID station_id = GetStationIndex(tile);
 
	if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
 

	
 
	if (v->type == VEH_TRAIN) {
 
		if (IsRailwayStation(tile) && IsFrontEngine(v) &&
 
				!IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) {
 
			StationID station_id = GetStationIndex(tile);
 

	
 
			if ((!(v->current_order.flags & OFB_NON_STOP) && !_patches.new_nonstop) ||
 
					(v->current_order.type == OT_GOTO_STATION && v->current_order.dest == station_id)) {
 
				if (!(_patches.new_nonstop && v->current_order.flags & OFB_NON_STOP) &&
 
						v->current_order.type != OT_LEAVESTATION &&
 
						v->last_station_visited != station_id) {
 
					DiagDirection dir = DirToDiagDir(v->direction);
 

	
 
					x &= 0xF;
 
@@ -2427,8 +2423,6 @@ static VehicleEnterTileStatus VehicleEnt
 
						}
 
					}
 
				}
 
			}
 
		}
 
	} else if (v->type == VEH_ROAD) {
 
		if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) {
 
			if (IsRoadStop(tile) && IsRoadVehFront(v)) {
src/train_cmd.cpp
Show inline comments
 
@@ -302,27 +302,6 @@ enum AccelType {
 
	AM_BRAKE
 
};
 

	
 
static bool TrainShouldStop(const Vehicle* v, TileIndex tile)
 
{
 
	const Order* o = &v->current_order;
 
	StationID sid = GetStationIndex(tile);
 

	
 
	assert(v->type == VEH_TRAIN);
 
	/* When does a train drive through a station
 
	 * first we deal with the "new nonstop handling" */
 
	if (_patches.new_nonstop && o->flags & OFB_NON_STOP && sid == o->dest) {
 
		return false;
 
	}
 

	
 
	if (v->last_station_visited == sid) return false;
 

	
 
	if (sid != o->dest && (o->flags & OFB_NON_STOP || _patches.new_nonstop)) {
 
		return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
/** new acceleration*/
 
static int GetTrainAcceleration(Vehicle *v, bool mode)
 
{
 
@@ -385,7 +364,7 @@ static int GetTrainAcceleration(Vehicle 
 
	}
 

	
 
	if (IsTileType(v->tile, MP_STATION) && IsFrontEngine(v)) {
 
		if (TrainShouldStop(v, v->tile)) {
 
		if (v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) {
 
			int station_length = GetStationByTile(v->tile)->GetPlatformLength(v->tile, DirToDiagDir(v->direction));
 

	
 
			int st_max_speed = 120;
0 comments (0 inline, 0 general)