Codechange: replace magic numbers and C-style arrays with C++-style array for share owners

This commit is contained in:
Rubidium
2022-02-02 22:34:22 +01:00
committed by rubidium42
parent 2bfceea762
commit c73f578e8c
7 changed files with 54 additions and 67 deletions

View File

@@ -1755,10 +1755,9 @@ bool AfterLoadGame()
* 2) shares that are owned by inactive companies or self
* (caused by cheating clients in earlier revisions) */
for (Company *c : Company::Iterate()) {
for (uint i = 0; i < 4; i++) {
CompanyID company = c->share_owners[i];
if (company == INVALID_COMPANY) continue;
if (!Company::IsValidID(company) || company == c->index) c->share_owners[i] = INVALID_COMPANY;
for (auto &share_owner : c->share_owners) {
if (share_owner == INVALID_COMPANY) continue;
if (!Company::IsValidID(share_owner) || share_owner == c->index) share_owner = INVALID_COMPANY;
}
}
}