Changeset - r27164:ac9a47f738f9
[Not reviewed]
master
0 1 0
Peter Nelson - 14 months ago 2023-04-16 23:03:39
peter1138@openttd.org
Fix #10627: Houses subsitute specs should only be copied on first definition.

Before #10627, substitue specs were always copied despite redefinition.
1 file changed with 18 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -2387,25 +2387,26 @@ static ChangeInfoResult TownHouseChangeI
 

	
 
				/* Allocate space for this house. */
 
				if (housespec == nullptr) {
 
					/* Only the first property 08 setting copies properties; if you later change it, properties will stay. */
 
					_cur.grffile->housespec[hid + i] = std::make_unique<HouseSpec>(*HouseSpec::Get(subs_id));
 
					housespec = _cur.grffile->housespec[hid + i].get();
 
				}
 

	
 
				housespec->enabled = true;
 
				housespec->grf_prop.local_id = hid + i;
 
				housespec->grf_prop.subst_id = subs_id;
 
				housespec->grf_prop.grffile = _cur.grffile;
 
				housespec->random_colour[0] = 0x04;  // those 4 random colours are the base colour
 
				housespec->random_colour[1] = 0x08;  // for all new houses
 
				housespec->random_colour[2] = 0x0C;  // they stand for red, blue, orange and green
 
				housespec->random_colour[3] = 0x06;
 

	
 
				/* Make sure that the third cargo type is valid in this
 
				 * climate. This can cause problems when copying the properties
 
				 * of a house that accepts food, where the new house is valid
 
				 * in the temperate climate. */
 
				if (!CargoSpec::Get(housespec->accepts_cargo[2])->IsValid()) {
 
					housespec->cargo_acceptance[2] = 0;
 

	
 
					housespec->enabled = true;
 
					housespec->grf_prop.local_id = hid + i;
 
					housespec->grf_prop.subst_id = subs_id;
 
					housespec->grf_prop.grffile = _cur.grffile;
 
					housespec->random_colour[0] = 0x04;  // those 4 random colours are the base colour
 
					housespec->random_colour[1] = 0x08;  // for all new houses
 
					housespec->random_colour[2] = 0x0C;  // they stand for red, blue, orange and green
 
					housespec->random_colour[3] = 0x06;
 

	
 
					/* Make sure that the third cargo type is valid in this
 
					 * climate. This can cause problems when copying the properties
 
					 * of a house that accepts food, where the new house is valid
 
					 * in the temperate climate. */
 
					if (!CargoSpec::Get(housespec->accepts_cargo[2])->IsValid()) {
 
						housespec->cargo_acceptance[2] = 0;
 
					}
 
				}
 
				break;
 
			}
0 comments (0 inline, 0 general)