Changeset - r28731:377f4b908032
[Not reviewed]
master
0 1 0
Peter Nelson - 10 months ago 2024-02-11 00:43:13
peter1138@openttd.org
Fix #12052: NewGRFs clearing industry cargo slots could fallback to default instead of empty. (#12053)

Ensure the default label is cleared when NewGRF sets a produced/accepted cargo slot, so that default fallback isn't used.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -3781,42 +3781,44 @@ static ChangeInfoResult IndustriesChange
 
				if (num_cargoes > lengthof(indsp->produced_cargo)) {
 
					GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
 
					error->param_value[1] = prop;
 
					return CIR_DISABLED;
 
				}
 
				for (uint i = 0; i < lengthof(indsp->produced_cargo); i++) {
 
					if (i < num_cargoes) {
 
						CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						indsp->produced_cargo[i] = cargo;
 
					} else {
 
						indsp->produced_cargo[i] = INVALID_CARGO;
 
					}
 
					indsp->produced_cargo_label[i] = CT_INVALID;
 
				}
 
				break;
 
			}
 

	
 
			case 0x26: { // variable length accepted cargoes
 
				byte num_cargoes = buf->ReadByte();
 
				if (num_cargoes > lengthof(indsp->accepts_cargo)) {
 
					GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
 
					error->param_value[1] = prop;
 
					return CIR_DISABLED;
 
				}
 
				for (uint i = 0; i < lengthof(indsp->accepts_cargo); i++) {
 
					if (i < num_cargoes) {
 
						CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						indsp->accepts_cargo[i] = cargo;
 
					} else {
 
						indsp->accepts_cargo[i] = INVALID_CARGO;
 
					}
 
					indsp->accepts_cargo_label[i] = CT_INVALID;
 
				}
 
				break;
 
			}
 

	
 
			case 0x27: { // variable length production rates
 
				byte num_cargoes = buf->ReadByte();
 
				if (num_cargoes > lengthof(indsp->production_rate)) {
 
					GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
 
					error->param_value[1] = prop;
 
					return CIR_DISABLED;
 
				}
 
				for (uint i = 0; i < lengthof(indsp->production_rate); i++) {
0 comments (0 inline, 0 general)