mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00: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:
parent
9dae626237
commit
552cf72b98
@ -310,6 +310,8 @@ RailTypes GetRailTypes(bool introduces)
|
||||
*/
|
||||
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels)
|
||||
{
|
||||
if (label == 0) return INVALID_RAILTYPE;
|
||||
|
||||
/* Loop through each rail type until the label is found */
|
||||
for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) {
|
||||
const RailTypeInfo *rti = GetRailTypeInfo(r);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user