mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Nullptr dereference in industry var 0xB4 when no cargoes accepted (#13060)
parent
59c399c795
commit
36c735ebfa
|
@ -404,6 +404,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_setID, uint8_
|
|||
case 0xB0: return ClampTo<uint16_t>(this->industry->construction_date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date when built since 1920 (in days)
|
||||
case 0xB3: return this->industry->construction_type; // Construction type
|
||||
case 0xB4: {
|
||||
if (this->industry->accepted.empty()) return 0;
|
||||
auto it = std::max_element(std::begin(this->industry->accepted), std::end(this->industry->accepted), [](const auto &a, const auto &b) { return a.last_accepted < b.last_accepted; });
|
||||
return ClampTo<uint16_t>(it->last_accepted - EconomyTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue