summaryrefslogtreecommitdiff
path: root/src/vehicle_base.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2016-10-16 14:59:44 +0000
committerfrosch <frosch@openttd.org>2016-10-16 14:59:44 +0000
commit117e73751c9aeea9f9663c15226c52541d2c8723 (patch)
tree694627f8d7396e81945fc84bce6b951f229add22 /src/vehicle_base.h
parentc175067ed9c17d43feaf356cd575dddddd699889 (diff)
downloadopenttd-117e73751c9aeea9f9663c15226c52541d2c8723.tar.xz
(svn r27668) -Feature: [NewGRF] Allow composing vehicles from multiple sprites.
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r--src/vehicle_base.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 0b5f2e1de..f2a02072a 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -128,11 +128,12 @@ struct VehicleCache {
/** Sprite sequence for a vehicle part. */
struct VehicleSpriteSeq {
- SpriteID sprite;
+ PalSpriteID seq[4];
+ uint count;
bool operator==(const VehicleSpriteSeq &other) const
{
- return this->sprite == other.sprite;
+ return this->count == other.count && MemCmpT<PalSpriteID>(this->seq, other.seq, this->count) == 0;
}
bool operator!=(const VehicleSpriteSeq &other) const
@@ -145,7 +146,7 @@ struct VehicleSpriteSeq {
*/
bool IsValid() const
{
- return this->sprite != 0;
+ return this->count != 0;
}
/**
@@ -153,7 +154,7 @@ struct VehicleSpriteSeq {
*/
void Clear()
{
- this->sprite = 0;
+ this->count = 0;
}
/**
@@ -161,7 +162,21 @@ struct VehicleSpriteSeq {
*/
void Set(SpriteID sprite)
{
- this->sprite = sprite;
+ this->count = 1;
+ this->seq[0].sprite = sprite;
+ this->seq[0].pal = 0;
+ }
+
+ /**
+ * Copy data from another sprite sequence, while dropping all recolouring information.
+ */
+ void CopyWithoutPalette(const VehicleSpriteSeq &src)
+ {
+ this->count = src.count;
+ for (uint i = 0; i < src.count; ++i) {
+ this->seq[i].sprite = src.seq[i].sprite;
+ this->seq[i].pal = 0;
+ }
}
void GetBounds(Rect *bounds) const;
@@ -982,7 +997,10 @@ struct SpecializedVehicle : public Vehicle {
/**
* Set vehicle type correctly
*/
- inline SpecializedVehicle<T, Type>() : Vehicle(Type) { }
+ inline SpecializedVehicle<T, Type>() : Vehicle(Type)
+ {
+ this->sprite_seq.count = 1;
+ }
/**
* Get the first vehicle in the chain