Codechange: Allocate houses dynamically instead of from a fixed array.

This uses vectors for HouseSpecs and global/town building counts.
This commit is contained in:
Peter Nelson
2024-03-12 17:28:44 +00:00
committed by Michael Lutz
parent 8746be8bf2
commit 3e83dcedfd
9 changed files with 87 additions and 46 deletions

View File

@@ -165,7 +165,11 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
return;
}
*HouseSpec::Get(house_id) = *hs;
auto &house_specs = HouseSpec::Specs();
/* Now that we know we can use the given id, copy the spec to its final destination. */
if (house_id >= house_specs.size()) house_specs.resize(house_id + 1);
house_specs[house_id] = *hs;
/* Now add the overrides. */
for (int i = 0; i < this->max_offset; i++) {