Cache sprite sequence bounds for vehicles
This commit is contained in:
@@ -208,8 +208,7 @@ void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID en
|
||||
VehicleSpriteSeq seq;
|
||||
GetAircraftIcon(engine, image_type, &seq);
|
||||
|
||||
Rect rect;
|
||||
seq.GetBounds(&rect);
|
||||
Rect16 rect = seq.GetBounds();
|
||||
preferred_x = Clamp(preferred_x,
|
||||
left - UnScaleGUI(rect.left),
|
||||
right - UnScaleGUI(rect.right));
|
||||
@@ -238,8 +237,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoff
|
||||
VehicleSpriteSeq seq;
|
||||
GetAircraftIcon(engine, image_type, &seq);
|
||||
|
||||
Rect rect;
|
||||
seq.GetBounds(&rect);
|
||||
Rect16 rect = seq.GetBounds();
|
||||
|
||||
width = UnScaleGUI(rect.right - rect.left + 1);
|
||||
height = UnScaleGUI(rect.bottom - rect.top + 1);
|
||||
@@ -371,6 +369,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
|
||||
w->spritenum = 0xFF;
|
||||
w->subtype = AIR_ROTOR;
|
||||
w->sprite_seq.Set(SPR_ROTOR_STOPPED);
|
||||
w->UpdateSpriteSeqBound();
|
||||
w->random_bits = VehicleRandomBits();
|
||||
/* Use rotor's air.state to store the rotor animation frame */
|
||||
w->state = HRS_ROTOR_STOPPED;
|
||||
@@ -504,6 +503,7 @@ static void HelicopterTickHandler(Aircraft *v)
|
||||
}
|
||||
|
||||
u->sprite_seq = seq;
|
||||
u->UpdateSpriteSeqBound();
|
||||
|
||||
u->UpdatePositionAndViewport();
|
||||
}
|
||||
@@ -524,7 +524,9 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
||||
v->UpdatePosition();
|
||||
v->UpdateViewport(true, false);
|
||||
if (v->subtype == AIR_HELICOPTER) {
|
||||
GetRotorImage(v, EIT_ON_MAP, &v->Next()->Next()->sprite_seq);
|
||||
Aircraft *rotor = v->Next()->Next();
|
||||
GetRotorImage(v, EIT_ON_MAP, &rotor->sprite_seq);
|
||||
rotor->UpdateSpriteSeqBound();
|
||||
}
|
||||
|
||||
Aircraft *u = v->Next();
|
||||
@@ -537,6 +539,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
||||
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
|
||||
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
|
||||
u->sprite_seq.CopyWithoutPalette(v->sprite_seq); // the shadow is never coloured
|
||||
u->sprite_seq_bounds = v->sprite_seq_bounds;
|
||||
|
||||
u->UpdatePositionAndViewport();
|
||||
|
||||
@@ -1308,7 +1311,9 @@ void Aircraft::MarkDirty()
|
||||
this->cur_image_valid_dir = INVALID_DIR;
|
||||
this->UpdateViewport(true, false);
|
||||
if (this->subtype == AIR_HELICOPTER) {
|
||||
GetRotorImage(this, EIT_ON_MAP, &this->Next()->Next()->sprite_seq);
|
||||
Aircraft *rotor = this->Next()->Next();
|
||||
GetRotorImage(this, EIT_ON_MAP, &rotor->sprite_seq);
|
||||
rotor->UpdateSpriteSeqBound();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user