summaryrefslogtreecommitdiff
path: root/src/vehicle_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-01-31 20:27:33 +0000
committerrubidium <rubidium@openttd.org>2011-01-31 20:27:33 +0000
commit67a5cd0b185158ca4926c8cb45f1735a1001e00b (patch)
tree9c1da7950e0954846792a820537dbd4778932e19 /src/vehicle_base.h
parent8f67baae2e5766300442f9ca5c962dbbce848ad4 (diff)
downloadopenttd-67a5cd0b185158ca4926c8cb45f1735a1001e00b.tar.xz
(svn r21932) -Document: some tidbits related to vehicles
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r--src/vehicle_base.h70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index c5290e770..623f534fb 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -156,27 +156,29 @@ public:
int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
Date timetable_start; ///< When the vehicle is supposed to start the timetable.
- /* Boundaries for the current position in the world and a next hash link.
- * NOSAVE: All of those can be updated with VehiclePositionChanged() */
- Rect coord;
- Vehicle *next_hash, **prev_hash;
- Vehicle *next_new_hash, **prev_new_hash;
- Vehicle **old_new_hash;
+ Rect coord; ///< NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
+
+ Vehicle *next_hash; ///< NOSAVE: Next vehicle in the visual location hash.
+ Vehicle **prev_hash; ///< NOSAVE: Previous vehicle in the visual location hash.
+
+ Vehicle *next_new_hash; ///< NOSAVE: Next vehicle in the tile location hash.
+ Vehicle **prev_new_hash; ///< NOSAVE: Previous vehicle in the tile location hash.
+ Vehicle **old_new_hash; ///< NOSAVE: Cache of the current hash chain.
SpriteID colourmap; ///< NOSAVE: cached colour mapping
/* Related to age and service time */
- Year build_year;
+ Year build_year; ///< Year the vehicle has been built.
Date age; ///< Age in days
Date max_age; ///< Maximum age
- Date date_of_last_service;
- Date service_interval;
+ Date date_of_last_service; ///< Last date the vehicle had a service at a depot.
+ Date service_interval; ///< The interval for (automatic) servicing; either in days or %.
uint16 reliability; ///< Reliability.
uint16 reliability_spd_dec; ///< Reliability decrease speed.
byte breakdown_ctr; ///< Counter for managing breakdown events. @see Vehicle::HandleBreakdown
byte breakdown_delay; ///< Counter for managing breakdown length.
- byte breakdowns_since_last_service;
- byte breakdown_chance;
+ byte breakdowns_since_last_service; ///< Counter for the amount of breakdowns.
+ byte breakdown_chance; ///< Current chance of breakdowns.
int32 x_pos; ///< x coordinate.
int32 y_pos; ///< y coordinate.
@@ -193,7 +195,7 @@ public:
byte z_extent; ///< z-extent of vehicle bounding box
int8 x_offs; ///< x offset for vehicle sprite
int8 y_offs; ///< y offset for vehicle sprite
- EngineID engine_type;
+ EngineID engine_type; ///< The type of engine used for this vehicle.
TextEffectID fill_percent_te_id; ///< a text-effect id to a loading indicator object
UnitID unitnumber; ///< unit number, for display purposes only
@@ -201,16 +203,13 @@ public:
uint16 cur_speed; ///< current speed
byte subspeed; ///< fractional speed
byte acceleration; ///< used by train & aircraft
- uint32 motion_counter;
- byte progress;
+ 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.
- /* for randomized variational spritegroups
- * bitmask used to resolve them; parts of it get reseeded when triggers
- * of corresponding spritegroups get matched */
- byte random_bits;
- byte waiting_triggers; ///< triggers to be yet matched
+ 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;
+ StationID last_station_visited; ///< The last station we stopped at.
CargoID cargo_type; ///< type of cargo this vehicle is carrying
byte cargo_subtype; ///< Used for livery refits (NewGRF variations)
@@ -228,15 +227,12 @@ public:
union {
OrderList *list; ///< Pointer to the order list for this vehicle
Order *old; ///< Only used during conversion of old save games
- } orders;
+ } orders; ///< The orders currently assigned to the vehicle.
byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
- /** Ticks to wait before starting next cycle. */
- uint16 load_unload_ticks;
-
+ uint16 load_unload_ticks; ///< Ticks to wait before starting next cycle.
GroupID group_id; ///< Index of group Pool array
-
byte subtype; ///< subtype (Filled with values from #EffectVehicles/#TrainSubTypes/#AircraftSubTypes)
NewGRFCache grf_cache; ///< Cache of often used calculated NewGRF values
@@ -736,7 +732,17 @@ public:
}
};
+/**
+ * Iterate over all vehicles from a given point.
+ * @param var The variable used to iterate over.
+ * @param start The vehicle to start the iteration at.
+ */
#define FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start)
+
+/**
+ * Iterate over all vehicles.
+ * @param var The variable used to iterate over.
+ */
#define FOR_ALL_VEHICLES(var) FOR_ALL_VEHICLES_FROM(var, 0)
/**
@@ -896,14 +902,19 @@ struct SpecializedVehicle : public Vehicle {
}
};
+/**
+ * Iterate over all vehicles of a particular type.
+ * @param name The type of vehicle to iterate over.
+ * @param var The variable used to iterate over.
+ */
#define FOR_ALL_VEHICLES_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE)
/**
* Disasters, like submarines, skyrangers and their shadows, belong to this class.
*/
struct DisasterVehicle : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> {
- uint16 image_override;
- VehicleID big_ufo_destroyer_target;
+ SpriteID image_override; ///< Override for the default disaster vehicle sprite.
+ VehicleID big_ufo_destroyer_target; ///< The big UFO that this destroyer is supposed to bomb.
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
DisasterVehicle() : SpecializedVehicleBase() {}
@@ -914,6 +925,10 @@ struct DisasterVehicle : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER
bool Tick();
};
+/**
+ * Iterate over disaster vehicles.
+ * @param var The variable used to iterate over.
+ */
#define FOR_ALL_DISASTERVEHICLES(var) FOR_ALL_VEHICLES_OF_TYPE(DisasterVehicle, var)
/** Generates sequence of free UnitID numbers */
@@ -929,6 +944,7 @@ struct FreeUnitIDGenerator {
~FreeUnitIDGenerator() { free(this->cache); }
};
+/** Sentinel for an invalid coordinate. */
static const int32 INVALID_COORD = 0x7fffffff;
#endif /* VEHICLE_BASE_H */