* 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 */
| 158 | * @param hs HouseSpec read from the grf file, ready for inclusion |
| 159 | */ |
| 160 | void 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. |
no test coverage detected