MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetEntitySpec

Method SetEntitySpec

src/newgrf_commons.cpp:160–185  ·  view source on GitHub ↗

* Install the specs into the HouseSpecs array * It will find itself the proper slot on which it will go * @param hs HouseSpec read from the grf file, ready for inclusion */

Source from the content-addressed store, hash-verified

158 * @param hs HouseSpec read from the grf file, ready for inclusion
159 */
160void HouseOverrideManager::SetEntitySpec(HouseSpec &&hs)
161{
162 HouseID house_id = this->AddEntityID(hs.grf_prop.local_id, hs.grf_prop.grfid, hs.grf_prop.subst_id);
163
164 if (house_id == this->invalid_id) {
165 GrfMsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
166 return;
167 }
168
169 auto &house_specs = HouseSpec::Specs();
170
171 /* Now that we know we can use the given id, copy the spec to its final destination. */
172 if (house_id >= house_specs.size()) house_specs.resize(house_id + 1);
173 house_specs[house_id] = std::move(hs);
174
175 /* Now add the overrides. */
176 for (int i = 0; i < this->max_offset; i++) {
177 HouseSpec *overridden_hs = HouseSpec::Get(i);
178
179 if (this->entity_overrides[i] != house_specs[house_id].grf_prop.local_id || this->grfid_overrides[i] != house_specs[house_id].grf_prop.grfid) continue;
180
181 overridden_hs->grf_prop.override_id = house_id;
182 this->entity_overrides[i] = this->invalid_id;
183 this->grfid_overrides[i] = 0;
184 }
185}
186
187/**
188 * Return the ID (if ever available) of a previously inserted entity.

Callers 4

FinaliseHouseArrayFunction · 0.45
FinaliseIndustriesArrayFunction · 0.45
FinaliseObjectsArrayFunction · 0.45
FinaliseAirportsArrayFunction · 0.45

Calls 4

AddEntityIDMethod · 0.80
resizeMethod · 0.80
sizeMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected