File diff r20251:8c2b509af318 → r20252:76a6f1c78ce7
src/vehicle_base.h
Show inline comments
 
@@ -3,24 +3,25 @@
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file  vehicle_base.h Base class for all vehicles. */
 

	
 
#ifndef VEHICLE_BASE_H
 
#define VEHICLE_BASE_H
 

	
 
#include "core/smallmap_type.hpp"
 
#include "track_type.h"
 
#include "command_type.h"
 
#include "order_base.h"
 
#include "cargopacket.h"
 
#include "texteff.hpp"
 
#include "engine_type.h"
 
#include "order_func.h"
 
#include "transport_type.h"
 
#include "group_type.h"
 
#include "base_consist.h"
 

	
 
/** Vehicle status bits in #Vehicle::vehstatus. */
 
@@ -202,28 +203,30 @@ public:
 
	UnitID unitnumber;                  ///< unit number, for display purposes only
 

	
 
	uint16 cur_speed;                   ///< current speed
 
	byte subspeed;                      ///< fractional speed
 
	byte acceleration;                  ///< used by train & aircraft
 
	uint32 motion_counter;              ///< counter to occasionally play a vehicle sound.
 
	byte progress;                      ///< The percentage (if divided by 256) this vehicle already crossed the tile unit.
 

	
 
	byte random_bits;                   ///< Bits used for determining which randomized variational spritegroups to use when drawing.
 
	byte waiting_triggers;              ///< Triggers to be yet matched before rerandomizing the random bits.
 

	
 
	StationID last_station_visited;     ///< The last station we stopped at.
 
	StationID last_loading_station;     ///< Last station the vehicle has stopped at and could possibly leave from with any cargo loaded.
 

	
 
	CargoID cargo_type;                 ///< type of cargo this vehicle is carrying
 
	byte cargo_subtype;                 ///< Used for livery refits (NewGRF variations)
 
	uint16 cargo_cap;                   ///< total capacity
 
	uint16 refit_cap;                   ///< Capacity left over from before last refit.
 
	VehicleCargoList cargo;             ///< The cargo this vehicle is carrying
 
	uint16 cargo_age_counter;           ///< Ticks till cargo is aged next.
 

	
 
	byte day_counter;                   ///< Increased by one for each day
 
	byte tick_counter;                  ///< Increased by one for each tick
 
	byte running_ticks;                 ///< Number of ticks this vehicle was not stopped this day
 

	
 
	byte vehstatus;                     ///< Status
 
	Order current_order;                ///< The current order (+ status, like: loading)
 

	
 
	union {
 
		OrderList *list;            ///< Pointer to the order list for this vehicle
 
@@ -248,24 +251,28 @@ public:
 
	void LeaveStation();
 

	
 
	GroundVehicleCache *GetGroundVehicleCache();
 
	const GroundVehicleCache *GetGroundVehicleCache() const;
 

	
 
	uint16 &GetGroundVehicleFlags();
 
	const uint16 &GetGroundVehicleFlags() const;
 

	
 
	void DeleteUnreachedImplicitOrders();
 

	
 
	void HandleLoading(bool mode = false);
 

	
 
	void GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) const;
 

	
 
	uint GetConsistTotalCapacity() const;
 

	
 
	/**
 
	 * Marks the vehicles to be redrawn and updates cached variables
 
	 *
 
	 * This method marks the area of the vehicle on the screen as dirty.
 
	 * It can be use to repaint the vehicle.
 
	 *
 
	 * @ingroup dirty
 
	 */
 
	virtual void MarkDirty() {}
 

	
 
	/**
 
	 * Updates the x and y offsets and the size of the sprite used
 
@@ -589,24 +596,35 @@ public:
 
	 * Get the number of orders this vehicle has.
 
	 * @return the number of orders this vehicle has.
 
	 */
 
	inline VehicleOrderID GetNumOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumOrders(); }
 

	
 
	/**
 
	 * Get the number of manually added orders this vehicle has.
 
	 * @return the number of manually added orders this vehicle has.
 
	 */
 
	inline VehicleOrderID GetNumManualOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumManualOrders(); }
 

	
 
	/**
 
	 * Get the next station the vehicle will stop at.
 
	 * @return ID of the next station the vehicle will stop at or INVALID_STATION.
 
	 */
 
	inline StationID GetNextStoppingStation() const
 
	{
 
		return (this->orders.list == NULL) ? INVALID_STATION : this->orders.list->GetNextStoppingStation(this);
 
	}
 

	
 
	void RefreshNextHopsStats();
 

	
 
	/**
 
	 * Copy certain configurations and statistics of a vehicle after successful autoreplace/renew
 
	 * The function shall copy everything that cannot be copied by a command (like orders / group etc),
 
	 * and that shall not be resetted for the new vehicle.
 
	 * @param src The old vehicle
 
	 */
 
	inline void CopyVehicleConfigAndStatistics(const Vehicle *src)
 
	{
 
		this->CopyConsistPropertiesFrom(src);
 

	
 
		this->unitnumber = src->unitnumber;
 

	
 
		this->current_order = src->current_order;