File diff r18912:e7974922f934 → r18913:fd2dc944ef3a
src/train.h
Show inline comments
 
@@ -71,98 +71,96 @@ struct Train FINAL : public GroundVehicl
 
	TrainCache tcache;
 

	
 
	/* Link between the two ends of a multiheaded engine */
 
	Train *other_multiheaded_part;
 

	
 
	uint16 crash_anim_pos; ///< Crash animation counter.
 

	
 
	uint16 flags;
 
	TrackBitsByte track;
 
	TrainForceProceedingByte force_proceed;
 
	RailTypeByte railtype;
 
	RailTypes compatible_railtypes;
 

	
 
	/** Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through signals. */
 
	uint16 wait_counter;
 

	
 
	/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
 
	Train() : GroundVehicleBase() {}
 
	/** We want to 'destruct' the right class. */
 
	virtual ~Train() { this->PreDestructor(); }
 

	
 
	friend struct GroundVehicle<Train, VEH_TRAIN>; // GroundVehicle needs to use the acceleration functions defined at Train.
 

	
 
	void MarkDirty();
 
	void UpdateDeltaXY(Direction direction);
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
 
	void PlayLeaveStationSound() const;
 
	bool IsPrimaryVehicle() const { return this->IsFrontEngine(); }
 
	SpriteID GetImage(Direction direction, EngineImageType image_type) const;
 
	int GetDisplaySpeed() const { return this->gcache.last_speed; }
 
	int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
 
	Money GetRunningCost() const;
 
	int GetDisplayImageWidth(Point *offset = NULL) const;
 
	bool IsInDepot() const;
 
	bool IsStoppedInDepot() const;
 
	bool Tick();
 
	void OnNewDay();
 
	uint Crash(bool flooded = false);
 
	Trackdir GetVehicleTrackdir() const;
 
	TileIndex GetOrderStationLocation(StationID station);
 
	bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
 

	
 
	void ReserveTrackUnderConsist() const;
 

	
 
	int GetCurveSpeedLimit() const;
 

	
 
	void ConsistChanged(bool same_length);
 

	
 
	void RailtypeChanged();
 

	
 
	int UpdateSpeed();
 

	
 
	void UpdateAcceleration();
 

	
 
	int GetCurrentMaxSpeed() const;
 

	
 
	/**
 
	 * Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
 
	 * @return Next vehicle in the consist.
 
	 */
 
	inline Train *GetNextUnit() const
 
	{
 
		Train *v = this->GetNextVehicle();
 
		if (v != NULL && v->IsRearDualheaded()) v = v->GetNextVehicle();
 

	
 
		return v;
 
	}
 

	
 
	/**
 
	 * Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
 
	 * @return Previous vehicle in the consist.
 
	 */
 
	inline Train *GetPrevUnit()
 
	{
 
		Train *v = this->GetPrevVehicle();
 
		if (v != NULL && v->IsRearDualheaded()) v = v->GetPrevVehicle();
 

	
 
		return v;
 
	}
 

	
 
	/**
 
	 * Calculate the offset from this vehicle's center to the following center taking the vehicle lengths into account.
 
	 * @return Offset from center to center.
 
	 */
 
	int CalcNextVehicleOffset() const
 
	{
 
		/* For vehicles with odd lengths the part before the center will be one unit
 
		 * longer than the part after the center. This means we have to round up the
 
		 * length of the next vehicle but may not round the length of the current
 
		 * vehicle. */
 
		return this->gcache.cached_veh_length / 2 + (this->Next() != NULL ? this->Next()->gcache.cached_veh_length + 1 : 0) / 2;
 
	}
 

	
 
protected: // These functions should not be called outside acceleration code.
 

	
 
	/**
 
	 * Allows to know the power value that this vehicle will use.
 
	 * @return Power value from the engine in HP, or zero if the vehicle is not powered.