CScannableObjectInfo: Make use of size_t in constructor

Gets rid of unnecessary zero extensions and keeps loop variables the
same sized type as the comparison type.

While we're at it we can collapse a loop into a ranged for and get rid
of some avoidable sign conversions.
This commit is contained in:
Lioncash 2020-04-12 21:42:52 -04:00
parent 414c06b33e
commit e91432ebf0
1 changed files with 17 additions and 13 deletions

View File

@ -4,26 +4,30 @@
namespace urde {
CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, CAssetId resId) : x0_scannableObjectId(resId) {
u32 version = in.readUint32Big();
const u32 version = in.readUint32Big();
Load(in, version);
for (u32 i = 0; i < x14_buckets.size(); ++i) {
x14_buckets[i].x4_appearanceRange *= x8_totalDownloadTime;
for (auto& bucket : x14_buckets) {
bucket.x4_appearanceRange *= x8_totalDownloadTime;
}
const float appearanceOffset = g_tweakGui->GetScanAppearanceDuration();
for (size_t i = 0; i < x14_buckets.size(); ++i) {
if (x14_buckets[i].x8_imagePos == UINT32_MAX) {
continue;
}
float appearanceOffset = g_tweakGui->GetScanAppearanceDuration();
for (u32 i = 0; i < x14_buckets.size(); ++i) {
if (x14_buckets[i].x8_imagePos != -1) {
x8_totalDownloadTime += appearanceOffset;
for (u32 j = i; j < x14_buckets.size(); j++)
for (size_t j = i; j < x14_buckets.size(); j++) {
x14_buckets[j].x4_appearanceRange += appearanceOffset;
}
}
for (u32 i = 0; i < x14_buckets.size() - 1; ++i) {
for (u32 j = i + 1; j < x14_buckets.size(); ++j) {
if (x14_buckets[i].x8_imagePos == x14_buckets[j].x8_imagePos && x14_buckets[i].x8_imagePos != -1)
x14_buckets[j].x8_imagePos = -1;
for (size_t i = 0; i < x14_buckets.size() - 1; ++i) {
for (size_t j = i + 1; j < x14_buckets.size(); ++j) {
if (x14_buckets[i].x8_imagePos == x14_buckets[j].x8_imagePos && x14_buckets[i].x8_imagePos != UINT32_MAX) {
x14_buckets[j].x8_imagePos = UINT32_MAX;
}
}
}
}