Fix #13235: NPE in fix_duplicated_banners()

Co-authored-by: IntelOrca <ted@brambles.org>
This commit is contained in:
Gymnasiast 2021-02-10 15:14:46 +01:00
parent 1cb3330779
commit 2aae1cb84e
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
1 changed files with 7 additions and 3 deletions

View File

@ -305,9 +305,13 @@ void fix_duplicated_banners()
Guard::Assert(!activeBanners[newBannerIndex]);
// Copy over the original banner, but update the location
auto& newBanner = *GetBanner(newBannerIndex);
newBanner = *GetBanner(bannerIndex);
newBanner.position = { x, y };
auto newBanner = GetBanner(newBannerIndex);
auto oldBanner = GetBanner(bannerIndex);
if (oldBanner != nullptr && newBanner != nullptr)
{
*newBanner = *oldBanner;
newBanner->position = { x, y };
}
tileElement->AsBanner()->SetIndex(newBannerIndex);
}