Fix aircraft shadows being drawn facing the wrong direction
This commit is contained in:
@@ -96,6 +96,7 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
|
|||||||
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
|
||||||
bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
|
bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
|
||||||
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
|
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
|
||||||
|
Direction GetMapImageDirection() const { return this->First()->direction; }
|
||||||
int GetDisplaySpeed() const { return this->cur_speed; }
|
int GetDisplaySpeed() const { return this->cur_speed; }
|
||||||
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
|
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
|
||||||
int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
|
int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
|
||||||
|
@@ -172,6 +172,22 @@ static StationID FindNearestHangar(const Aircraft *v)
|
|||||||
|
|
||||||
void Aircraft::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
|
void Aircraft::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
|
||||||
{
|
{
|
||||||
|
if (this->subtype == AIR_SHADOW) {
|
||||||
|
Aircraft *first = this->First();
|
||||||
|
if (first->cur_image_valid_dir != direction || HasBit(first->vcache.cached_veh_flags, VCF_IMAGE_REFRESH)) {
|
||||||
|
VehicleSpriteSeq seq;
|
||||||
|
first->UpdateImageState(direction, seq);
|
||||||
|
if (first->sprite_seq != seq) {
|
||||||
|
first->sprite_seq = seq;
|
||||||
|
first->UpdateSpriteSeqBound();
|
||||||
|
first->Vehicle::UpdateViewport(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result->CopyWithoutPalette(first->sprite_seq); // the shadow is never coloured
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint8 spritenum = this->spritenum;
|
uint8 spritenum = this->spritenum;
|
||||||
|
|
||||||
if (is_custom_sprite(spritenum)) {
|
if (is_custom_sprite(spritenum)) {
|
||||||
@@ -552,10 +568,8 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
|||||||
|
|
||||||
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
|
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
|
||||||
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
|
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
|
||||||
u->sprite_seq.CopyWithoutPalette(v->sprite_seq); // the shadow is never coloured
|
u->UpdatePosition();
|
||||||
u->sprite_seq_bounds = v->sprite_seq_bounds;
|
u->UpdateViewport(true, false);
|
||||||
|
|
||||||
u->UpdatePositionAndViewport();
|
|
||||||
|
|
||||||
u = u->Next();
|
u = u->Next();
|
||||||
if (u != nullptr) {
|
if (u != nullptr) {
|
||||||
@@ -1364,7 +1378,7 @@ TileIndex Aircraft::GetOrderStationLocation(StationID station)
|
|||||||
void Aircraft::MarkDirty()
|
void Aircraft::MarkDirty()
|
||||||
{
|
{
|
||||||
this->colourmap = PAL_NONE;
|
this->colourmap = PAL_NONE;
|
||||||
this->InvalidateImageCache();
|
this->InvalidateImageCacheOfChain();
|
||||||
this->UpdateViewport(true, false);
|
this->UpdateViewport(true, false);
|
||||||
if (this->subtype == AIR_HELICOPTER) {
|
if (this->subtype == AIR_HELICOPTER) {
|
||||||
Aircraft *rotor = this->Next()->Next();
|
Aircraft *rotor = this->Next()->Next();
|
||||||
|
@@ -1387,7 +1387,7 @@ public:
|
|||||||
|
|
||||||
inline void UpdateImageStateUsingMapDirection(VehicleSpriteSeq &seq)
|
inline void UpdateImageStateUsingMapDirection(VehicleSpriteSeq &seq)
|
||||||
{
|
{
|
||||||
this->UpdateImageState(this->GetMapImageDirection(), seq);
|
this->UpdateImageState(((T *)this)->GetMapImageDirection(), seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user