IProperty: Make use of size_t where applicable

This commit is contained in:
Lioncash 2020-06-21 19:25:51 -04:00
parent 48d0ae5e10
commit ebd1468bbf
8 changed files with 39 additions and 33 deletions

View File

@ -26,16 +26,17 @@ void IDependencyNode::GetAllResourceReferences(std::set<CAssetID>& rOutSet) cons
void IDependencyNode::ParseProperties(CResourceEntry* pParentEntry, CStructProperty* pProperties, void* pData)
{
// Recursive function for parsing dependencies in properties
for (uint32 PropertyIdx = 0; PropertyIdx < pProperties->NumChildren(); PropertyIdx++)
for (size_t PropertyIdx = 0; PropertyIdx < pProperties->NumChildren(); PropertyIdx++)
{
IProperty* pProp = pProperties->ChildByIndex(PropertyIdx);
EPropertyType Type = pProp->Type();
const EPropertyType Type = pProp->Type();
// Technically we aren't parsing array children, but it's not really worth refactoring this function
// to support it when there aren't any array properties that contain any asset references anyway...
if (Type == EPropertyType::Struct)
ParseProperties( pParentEntry, TPropCast<CStructProperty>(pProp), pData );
{
ParseProperties(pParentEntry, TPropCast<CStructProperty>(pProp), pData);
}
else if (Type == EPropertyType::Sound)
{
uint32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pData);
@ -51,7 +52,6 @@ void IDependencyNode::ParseProperties(CResourceEntry* pParentEntry, CStructPrope
}
}
}
else if (Type == EPropertyType::Asset)
{
CAssetID ID = TPropCast<CAssetProperty>(pProp)->Value(pData);
@ -61,7 +61,6 @@ void IDependencyNode::ParseProperties(CResourceEntry* pParentEntry, CStructPrope
mChildren.push_back(std::make_unique<CPropertyDependency>(pProp->IDString(true), ID));
}
}
else if (Type == EPropertyType::AnimationSet)
{
CAnimationParameters Params = TPropCast<CAnimationSetProperty>(pProp)->Value(pData);

View File

@ -180,7 +180,7 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, voi
auto* pStruct = TPropCast<CStructProperty>(pProperty);
std::vector<IProperty*> PropertiesToWrite;
for (uint32 ChildIdx = 0; ChildIdx < pStruct->NumChildren(); ChildIdx++)
for (size_t ChildIdx = 0; ChildIdx < pStruct->NumChildren(); ChildIdx++)
{
IProperty *pChild = pStruct->ChildByIndex(ChildIdx);

View File

@ -268,7 +268,7 @@ void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct)
[[maybe_unused]] const uint32 StructStart = rSCLY.Tell();
// Verify property count
const uint32 PropertyCount = pStruct->NumChildren();
const size_t PropertyCount = pStruct->NumChildren();
[[maybe_unused]] uint32 Version = 0;
if (!pStruct->IsAtomic())
@ -278,7 +278,7 @@ void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct)
}
// Parse properties
for (uint32 ChildIndex = 0; ChildIndex < PropertyCount; ChildIndex++)
for (size_t ChildIndex = 0; ChildIndex < PropertyCount; ChildIndex++)
{
IProperty *pProperty = pStruct->ChildByIndex(ChildIndex);
@ -363,13 +363,13 @@ std::unique_ptr<CScriptLayer> CScriptLoader::LoadLayerMP1(IInputStream& rSCLY)
void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructProperty* pStruct)
{
// Verify property count
uint32 ChildCount = pStruct->NumChildren();
size_t ChildCount = pStruct->NumChildren();
if (!pStruct->IsAtomic())
ChildCount = rSCLY.ReadUShort();
// Parse properties
for (uint32 ChildIdx = 0; ChildIdx < ChildCount; ChildIdx++)
for (size_t ChildIdx = 0; ChildIdx < ChildCount; ChildIdx++)
{
IProperty* pProperty = nullptr;
const uint32 PropertyStart = rSCLY.Tell();

View File

@ -177,11 +177,11 @@ void CStructProperty::InitFromArchetype(IProperty* pOther)
// Copy children
_ClearChildren();
mChildren.reserve( pOther->NumChildren() );
mChildren.reserve(pOther->NumChildren());
for (uint32 ChildIdx = 0; ChildIdx < pOther->NumChildren(); ChildIdx++)
for (size_t ChildIdx = 0; ChildIdx < pOther->NumChildren(); ChildIdx++)
{
IProperty* pChild = CreateCopy( pOther->ChildByIndex(ChildIdx) );
IProperty* pChild = CreateCopy(pOther->ChildByIndex(ChildIdx));
mChildren.push_back(pChild);
}
}

View File

@ -208,11 +208,11 @@ public:
/** Accessors */
EGame Game() const;
ECookPreference CookPreference() const { return mCookPreference; }
uint32 NumChildren() const { return mChildren.size(); }
size_t NumChildren() const { return mChildren.size(); }
IProperty* ChildByIndex(uint32 ChildIndex) const
IProperty* ChildByIndex(size_t ChildIndex) const
{
ASSERT(ChildIndex >= 0 && ChildIndex < mChildren.size());
ASSERT(ChildIndex < mChildren.size());
return mChildren[ChildIndex];
}
@ -278,17 +278,17 @@ public:
static IProperty* CreateCopy(IProperty* pArchetype);
static IProperty* CreateIntrinsic(EPropertyType Type,
EGame Game,
uint32 Offset,
const TString& rkName);
EGame Game,
uint32 Offset,
const TString& rkName);
static IProperty* CreateIntrinsic(EPropertyType Type,
IProperty* pParent,
uint32 Offset,
const TString& rkName);
IProperty* pParent,
uint32 Offset,
const TString& rkName);
static IProperty* ArchiveConstructor(EPropertyType Type,
const IArchive& Arc);
const IArchive& Arc);
};
template<typename PropType, EPropertyType PropEnum>

View File

@ -23,7 +23,7 @@ CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScen
PropertyModified(mPlaneSize.Property());
// Fetch textures
for (uint32 TextureIdx = 0; TextureIdx < 3; TextureIdx++)
for (size_t TextureIdx = 0; TextureIdx < mTextureAssets.size(); TextureIdx++)
{
mTextureAssets[TextureIdx] = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIndex(6 + TextureIdx));
if (mTextureAssets[TextureIdx].IsValid())

View File

@ -73,7 +73,7 @@ void CGeneratePropertyNamesDialog::AddToIDPool(IProperty* pProperty)
/** Populate the ID pool with the children of the given property */
void CGeneratePropertyNamesDialog::AddChildrenToIDPool(IProperty* pProperty, bool Recursive)
{
for (uint32 ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++)
for (size_t ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++)
{
IProperty* pChild = pProperty->ChildByIndex(ChildIdx);

View File

@ -47,7 +47,7 @@ int CPropertyModel::RecursiveBuildArrays(IProperty* pProperty, int ParentID)
for (uint32 ElementIdx = 0; ElementIdx < ArrayCount; ElementIdx++)
{
mpPropertyData = pArray->ItemPointer(pOldData, ElementIdx);
int NewChildID = RecursiveBuildArrays( pArray->ItemArchetype(), MyID );
const int NewChildID = RecursiveBuildArrays( pArray->ItemArchetype(), MyID );
mProperties[MyID].ChildIDs.push_back(NewChildID);
}
@ -55,9 +55,9 @@ int CPropertyModel::RecursiveBuildArrays(IProperty* pProperty, int ParentID)
}
else
{
for (uint32 ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++)
for (size_t ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++)
{
int NewChildID = RecursiveBuildArrays( pProperty->ChildByIndex(ChildIdx), MyID );
const int NewChildID = RecursiveBuildArrays( pProperty->ChildByIndex(ChildIdx), MyID );
mProperties[MyID].ChildIDs.push_back(NewChildID);
}
}
@ -183,10 +183,17 @@ int CPropertyModel::columnCount(const QModelIndex& /*rkParent*/) const
int CPropertyModel::rowCount(const QModelIndex& rkParent) const
{
if (!mpRootProperty) return 0;
if (!rkParent.isValid()) return mpRootProperty->NumChildren();
if (rkParent.column() != 0) return 0;
if (rkParent.internalId() & 0x80000000) return 0;
if (!mpRootProperty)
return 0;
if (!rkParent.isValid())
return static_cast<int>(mpRootProperty->NumChildren());
if (rkParent.column() != 0)
return 0;
if ((rkParent.internalId() & 0x80000000) != 0)
return 0;
IProperty *pProp = PropertyForIndex(rkParent, false);
int ID = rkParent.internalId();