src/cargotype.cpp
branchcpp_gui
changeset 6307 f40e88cff863
parent 6303 84c215fc8eb8
equal deleted inserted replaced
6306:036aa28ca80e 6307:f40e88cff863
    69 	}
    69 	}
    70 
    70 
    71 	/* No matching label was found, so it is invalid */
    71 	/* No matching label was found, so it is invalid */
    72 	return CT_INVALID;
    72 	return CT_INVALID;
    73 }
    73 }
       
    74 
       
    75 
       
    76 /** Find the CargoID of a 'bitnum' value.
       
    77  * @param bitnum 'bitnum' to find.
       
    78  * @return First CargoID with the given bitnum, or CT_INVALID if not found.
       
    79  */
       
    80 CargoID GetCargoIDByBitnum(uint8 bitnum)
       
    81 {
       
    82 	if (bitnum == INVALID_CARGO) return CT_INVALID;
       
    83 
       
    84 	for (CargoID c = 0; c < lengthof(_cargo); c++) {
       
    85 		if (_cargo[c].bitnum == bitnum) return c;
       
    86 	}
       
    87 
       
    88 	/* No matching label was found, so it is invalid */
       
    89 	return CT_INVALID;
       
    90 }
       
    91