mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 10:22:39 +01:00
Codefix: Immediately return invalid rail/road type when looking for label 0. (#13045)
Looking for label 0 would incorrectly return the first undefined type instead of INVALID_RAIL/ROADTYPE, which could potentially cause incorrect behaviour.
This commit is contained in:
@@ -253,6 +253,8 @@ RoadTypes GetRoadTypes(bool introduces)
|
||||
*/
|
||||
RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels)
|
||||
{
|
||||
if (label == 0) return INVALID_ROADTYPE;
|
||||
|
||||
/* Loop through each road type until the label is found */
|
||||
for (RoadType r = ROADTYPE_BEGIN; r != ROADTYPE_END; r++) {
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(r);
|
||||
|
||||
Reference in New Issue
Block a user