Fix narrowing conversion warnings

pull/684/head
Jonathan G Rennison 1 month ago
parent bf0cb3c43f
commit 3712b84d2e

@ -1916,7 +1916,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
/* Clear all input cargo types */ /* Clear all input cargo types */
for (size_t j = 0; j < i->accepts_cargo.size(); j++) i->accepts_cargo[j] = INVALID_CARGO; for (size_t j = 0; j < i->accepts_cargo.size(); j++) i->accepts_cargo[j] = INVALID_CARGO;
/* Query actual types */ /* Query actual types */
uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? std::size(i->accepts_cargo) : 3; uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? (uint)std::size(i->accepts_cargo) : 3;
for (uint j = 0; j < maxcargoes; j++) { for (uint j = 0; j < maxcargoes; j++) {
uint16_t res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); uint16_t res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
if (res == CALLBACK_FAILED || GB(res, 0, 8) == UINT8_MAX) break; if (res == CALLBACK_FAILED || GB(res, 0, 8) == UINT8_MAX) break;
@ -1948,7 +1948,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
/* Clear all output cargo types */ /* Clear all output cargo types */
for (size_t j = 0; j < i->produced_cargo.size(); j++) i->produced_cargo[j] = INVALID_CARGO; for (size_t j = 0; j < i->produced_cargo.size(); j++) i->produced_cargo[j] = INVALID_CARGO;
/* Query actual types */ /* Query actual types */
uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? std::size(i->produced_cargo) : 2; uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? (uint)std::size(i->produced_cargo) : 2;
for (uint j = 0; j < maxcargoes; j++) { for (uint j = 0; j < maxcargoes; j++) {
uint16_t res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); uint16_t res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
if (res == CALLBACK_FAILED || GB(res, 0, 8) == UINT8_MAX) break; if (res == CALLBACK_FAILED || GB(res, 0, 8) == UINT8_MAX) break;

@ -1486,9 +1486,9 @@ protected:
* @param id cargo slot * @param id cargo slot
* @return percents of cargo transported, or -1 if industry doesn't use this cargo slot * @return percents of cargo transported, or -1 if industry doesn't use this cargo slot
*/ */
static inline int GetCargoTransportedPercentsIfValid(const Industry *i, uint id) static inline int GetCargoTransportedPercentsIfValid(const Industry *i, size_t id)
{ {
assert((size_t)id < std::size(i->produced_cargo)); assert(id < std::size(i->produced_cargo));
if (i->produced_cargo[id] == INVALID_CARGO) return -1; if (i->produced_cargo[id] == INVALID_CARGO) return -1;
return ToPercent8(i->last_month_pct_transported[id]); return ToPercent8(i->last_month_pct_transported[id]);

@ -17,7 +17,7 @@
static void Save_NSID() static void Save_NSID()
{ {
SlSetLength(4 + (_new_signal_style_mapping.size() * 5)); SlSetLength(4 + (_new_signal_style_mapping.size() * 5));
SlWriteUint32(_new_signal_style_mapping.size()); SlWriteUint32((uint)_new_signal_style_mapping.size());
for (const NewSignalStyleMapping &mapping : _new_signal_style_mapping) { for (const NewSignalStyleMapping &mapping : _new_signal_style_mapping) {
SlWriteUint32(mapping.grfid); SlWriteUint32(mapping.grfid);
SlWriteByte(mapping.grf_local_id); SlWriteByte(mapping.grf_local_id);

Loading…
Cancel
Save