Cache the last vehicle in a consist to have a visual effect

This commit is contained in:
Jonathan G Rennison
2019-01-26 01:22:36 +00:00
parent e5b61e0b6c
commit 37adf9be4a
4 changed files with 21 additions and 0 deletions

View File

@@ -413,6 +413,7 @@ Vehicle::Vehicle(VehicleType type)
this->last_station_visited = INVALID_STATION;
this->last_loading_station = INVALID_STATION;
this->cur_image_valid_dir = INVALID_DIR;
this->vcache.cached_veh_flags = 0;
}
/**
@@ -3486,6 +3487,8 @@ void Vehicle::ShowVisualEffect() const
CreateEffectVehicleRel(v, x, y, 10, evt);
}
if (HasBit(v->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT)) break;
} while ((v = v->Next()) != NULL);
if (sound) PlayVehicleSound(this, VSE_VISUAL_EFFECT);
@@ -3668,6 +3671,8 @@ char *Vehicle::DumpVehicleFlags(char *b, const char *last) const
dump('x', HasBit(this->vehicle_flags, VF_LAST_LOAD_ST_SEP));
dump('s', HasBit(this->vehicle_flags, VF_TIMETABLE_SEPARATION));
dump('a', HasBit(this->vehicle_flags, VF_AUTOMATE_TIMETABLE));
b += seprintf(b, last, ", vcf:");
dump('l', HasBit(this->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT));
if (this->IsGroundVehicle()) {
uint16 gv_flags = this->GetGroundVehicleFlags();
b += seprintf(b, last, ", gvf:");