src/vehicle.h
branchNewGRF_ports
changeset 6870 ca3fd1fbe311
parent 6868 7eb395287b3d
child 6871 5a9dc001e1ad
equal deleted inserted replaced
6869:76282d3b748d 6870:ca3fd1fbe311
   218 };
   218 };
   219 
   219 
   220 struct Vehicle;
   220 struct Vehicle;
   221 DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
   221 DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
   222 
   222 
       
   223 /* Some declarations of functions, so we can make them friendly */
   223 struct SaveLoad;
   224 struct SaveLoad;
   224 const SaveLoad *GetVehicleDescription(VehicleType vt);
   225 extern const SaveLoad *GetVehicleDescription(VehicleType vt);
   225 void AfterLoadVehicles();
   226 extern void AfterLoadVehicles();
       
   227 struct LoadgameState;
       
   228 extern bool LoadOldVehicle(LoadgameState *ls, int num);
   226 
   229 
   227 struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
   230 struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
   228 	VehicleTypeByte type;    ///< Type of vehicle
   231 	VehicleTypeByte type;    ///< Type of vehicle
   229 	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
   232 	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
   230 
   233 
   232 	Vehicle *next;           // pointer to the next vehicle in the chain
   235 	Vehicle *next;           // pointer to the next vehicle in the chain
   233 	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
   236 	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
   234 	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
   237 	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
   235 public:
   238 public:
   236 	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
   239 	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
   237 	friend void AfterLoadVehicles();
   240 	friend void AfterLoadVehicles();                              // So we can set the previous and first pointers while loading
       
   241 	friend bool LoadOldVehicle(LoadgameState *ls, int num);       // So we can set the proper next pointer while loading
   238 
   242 
   239 	Vehicle *depot_list;     // NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
   243 	Vehicle *depot_list;     // NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
   240 
   244 
   241 	StringID string_id;      // Displayed string
   245 	StringID string_id;      // Displayed string
   242 
   246 
   380 	 */
   384 	 */
   381 	virtual const char* GetTypeString() const { return "base vehicle"; }
   385 	virtual const char* GetTypeString() const { return "base vehicle"; }
   382 
   386 
   383 	/**
   387 	/**
   384 	 * Marks the vehicles to be redrawn and updates cached variables
   388 	 * Marks the vehicles to be redrawn and updates cached variables
       
   389 	 *
       
   390 	 * This method marks the area of the vehicle on the screen as dirty.
       
   391 	 * It can be use to repaint the vehicle.
       
   392 	 *
       
   393 	 * @ingroup dirty
   385 	 */
   394 	 */
   386 	virtual void MarkDirty() {}
   395 	virtual void MarkDirty() {}
   387 
   396 
   388 	/**
   397 	/**
   389 	 * Updates the x and y offsets and the size of the sprite used
   398 	 * Updates the x and y offsets and the size of the sprite used
   410 
   419 
   411 	/**
   420 	/**
   412 	 * Whether this is the primary vehicle in the chain.
   421 	 * Whether this is the primary vehicle in the chain.
   413 	 */
   422 	 */
   414 	virtual bool IsPrimaryVehicle() const { return false; }
   423 	virtual bool IsPrimaryVehicle() const { return false; }
   415 
       
   416 	/**
       
   417 	 * Whether this vehicle understands the concept of a front engine, so
       
   418 	 * basically, if GetFirstVehicleInChain() can be called for it.
       
   419 	 */
       
   420 	virtual bool HasFront() const { return false; }
       
   421 
   424 
   422 	/**
   425 	/**
   423 	 * Gets the sprite to show for the given direction
   426 	 * Gets the sprite to show for the given direction
   424 	 * @param direction the direction the vehicle is facing
   427 	 * @param direction the direction the vehicle is facing
   425 	 * @return the sprite for the given vehicle in the given direction
   428 	 * @return the sprite for the given vehicle in the given direction