Changeset - r28733:cb3e748cfe2f
[Not reviewed]
master
0 1 0
Peter Nelson - 10 months ago 2024-02-11 17:42:04
peter1138@openttd.org
Fix: Industry tiles and houses could accept incorrect cargo types. (#12062)

Ensure the default label is cleared when NewGRFs set industry tile or house acceptance.

This was missed by #12053.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -2597,24 +2597,25 @@ static ChangeInfoResult TownHouseChangeI
 
				}
 
				/* Always write the full accepts_cargo array, and check each index for being inside the
 
				 * provided data. This ensures all values are properly initialized, and also avoids
 
				 * any risks of array overrun. */
 
				for (uint i = 0; i < lengthof(housespec->accepts_cargo); i++) {
 
					if (i < count) {
 
						housespec->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						housespec->cargo_acceptance[i] = buf->ReadByte();
 
					} else {
 
						housespec->accepts_cargo[i] = INVALID_CARGO;
 
						housespec->cargo_acceptance[i] = 0;
 
					}
 
					housespec->accepts_cargo_label[i] = CT_INVALID;
 
				}
 
				break;
 
			}
 

	
 
			default:
 
				ret = CIR_UNKNOWN;
 
				break;
 
		}
 
	}
 

	
 
	return ret;
 
}
 
@@ -3333,24 +3334,25 @@ static ChangeInfoResult IndustrytilesCha
 
					error->param_value[1] = prop;
 
					return CIR_DISABLED;
 
				}
 
				for (uint i = 0; i < std::size(tsp->acceptance); i++) {
 
					if (i < num_cargoes) {
 
						tsp->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						/* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */
 
						tsp->acceptance[i] = (int8_t)buf->ReadByte();
 
					} else {
 
						tsp->accepts_cargo[i] = INVALID_CARGO;
 
						tsp->acceptance[i] = 0;
 
					}
 
					tsp->accepts_cargo_label[i] = CT_INVALID;
 
				}
 
				break;
 
			}
 

	
 
			default:
 
				ret = CIR_UNKNOWN;
 
				break;
 
		}
 
	}
 

	
 
	return ret;
 
}
0 comments (0 inline, 0 general)