Cleanup & refactoring

This commit is contained in:
Aruki
2018-12-16 14:00:40 -07:00
parent 2287b05bc3
commit c4829f5fda
197 changed files with 2461 additions and 2345 deletions

View File

@@ -92,8 +92,8 @@ public:
CScriptObject *pNewSender = mpArea->InstanceByID(NewSenderID);
mSenderID = NewSenderID;
if (pOldSender) pOldSender->RemoveLink(eOutgoing, this);
pNewSender->AddLink(eOutgoing, this, Index);
if (pOldSender) pOldSender->RemoveLink(ELinkType::Outgoing, this);
pNewSender->AddLink(ELinkType::Outgoing, this, Index);
}
void SetReceiver(uint32 NewReceiverID, uint32 Index = -1)
@@ -103,8 +103,8 @@ public:
CScriptObject *pNewReceiver = mpArea->InstanceByID(NewReceiverID);
mReceiverID = NewReceiverID;
if (pOldReceiver) pOldReceiver->RemoveLink(eIncoming, this);
pNewReceiver->AddLink(eIncoming, this, Index);
if (pOldReceiver) pOldReceiver->RemoveLink(ELinkType::Incoming, this);
pNewReceiver->AddLink(ELinkType::Incoming, this, Index);
}
uint32 SenderIndex() const
@@ -113,9 +113,9 @@ public:
if (pSender)
{
for (uint32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++)
for (uint32 iLink = 0; iLink < pSender->NumLinks(ELinkType::Outgoing); iLink++)
{
if (pSender->Link(eOutgoing, iLink) == this)
if (pSender->Link(ELinkType::Outgoing, iLink) == this)
return iLink;
}
}
@@ -129,9 +129,9 @@ public:
if (pReceiver)
{
for (uint32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++)
for (uint32 iLink = 0; iLink < pReceiver->NumLinks(ELinkType::Incoming); iLink++)
{
if (pReceiver->Link(eIncoming, iLink) == this)
if (pReceiver->Link(ELinkType::Incoming, iLink) == this)
return iLink;
}
}

View File

@@ -140,14 +140,14 @@ bool CScriptObject::HasNearVisibleActivation() const
CLink *pLink = mInLinks[iLink];
// Check for trigger activation
if (pLink->State() == 0x49533034 || pLink->State() == 0x49533035 || pLink->State() == 0x49533036) // "IS04", "IS05", or "IS06"
if (pLink->State() == FOURCC('IS04') || pLink->State() == FOURCC('IS05') || pLink->State() == FOURCC('IS06'))
{
if ( (!IsRelay && pLink->Message() == 0x41435456) || // "ACTV"
(IsRelay && pLink->Message() == 0x4143544E) ) // "ACTN"
if ( (!IsRelay && pLink->Message() == FOURCC('ACTV')) ||
(IsRelay && pLink->Message() == FOURCC('ACTN')) )
{
CScriptObject *pObj = pLink->Sender();
if (pObj->ObjectTypeID() == 0x54524752) // "TRGR"
if (pObj->ObjectTypeID() == FOURCC('TRGR'))
{
mIsCheckingNearVisibleActivation = false;
return true;
@@ -156,14 +156,14 @@ bool CScriptObject::HasNearVisibleActivation() const
}
// Check for relay activation
else if (pLink->State() == 0x524C4159) // "RLAY"
else if (pLink->State() == FOURCC('RLAY'))
{
if ( (!IsRelay && pLink->Message() == 0x41435456) || // "ACTV"
(IsRelay && pLink->Message() == 0x4143544E) ) // "ACTN"
if ( (!IsRelay && pLink->Message() == FOURCC('ACTV')) ||
(IsRelay && pLink->Message() == FOURCC('ACTN')) )
{
CScriptObject *pObj = pLink->Sender();
if (pObj->ObjectTypeID() == 0x53524C59) // "SRLY"
if (pObj->ObjectTypeID() == FOURCC('SRLY'))
Relays.push_back(pObj);
}
}
@@ -185,7 +185,7 @@ bool CScriptObject::HasNearVisibleActivation() const
void CScriptObject::AddLink(ELinkType Type, CLink *pLink, uint32 Index /*= -1*/)
{
std::vector<CLink*> *pLinkVec = (Type == eIncoming ? &mInLinks : &mOutLinks);
std::vector<CLink*> *pLinkVec = (Type == ELinkType::Incoming ? &mInLinks : &mOutLinks);
if (Index == -1 || Index == pLinkVec->size())
pLinkVec->push_back(pLink);
@@ -199,7 +199,7 @@ void CScriptObject::AddLink(ELinkType Type, CLink *pLink, uint32 Index /*= -1*/)
void CScriptObject::RemoveLink(ELinkType Type, CLink *pLink)
{
std::vector<CLink*> *pLinkVec = (Type == eIncoming ? &mInLinks : &mOutLinks);
std::vector<CLink*> *pLinkVec = (Type == ELinkType::Incoming ? &mInLinks : &mOutLinks);
for (auto it = pLinkVec->begin(); it != pLinkVec->end(); it++)
{
@@ -217,7 +217,7 @@ void CScriptObject::BreakAllLinks()
{
CLink *pLink = *it;
CScriptObject *pSender = pLink->Sender();
if (pSender) pSender->RemoveLink(eOutgoing, pLink);
if (pSender) pSender->RemoveLink(ELinkType::Outgoing, pLink);
delete pLink;
}
@@ -225,7 +225,7 @@ void CScriptObject::BreakAllLinks()
{
CLink *pLink = *it;
CScriptObject *pReceiver = pLink->Receiver();
if (pReceiver) pReceiver->RemoveLink(eIncoming, pLink);
if (pReceiver) pReceiver->RemoveLink(ELinkType::Incoming, pLink);
delete pLink;
}

View File

@@ -10,10 +10,10 @@
class CScriptLayer;
class CLink;
enum ELinkType
enum class ELinkType
{
eIncoming,
eOutgoing
Incoming,
Outgoing
};
class CScriptObject
@@ -76,8 +76,8 @@ public:
uint32 Version() const { return mVersion; }
uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); }
uint32 InstanceID() const { return mInstanceID; }
uint32 NumLinks(ELinkType Type) const { return (Type == eIncoming ? mInLinks.size() : mOutLinks.size()); }
CLink* Link(ELinkType Type, uint32 Index) const { return (Type == eIncoming ? mInLinks[Index] : mOutLinks[Index]); }
uint32 NumLinks(ELinkType Type) const { return (Type == ELinkType::Incoming ? mInLinks.size() : mOutLinks.size()); }
CLink* Link(ELinkType Type, uint32 Index) const { return (Type == ELinkType::Incoming ? mInLinks[Index] : mOutLinks[Index]); }
void* PropertyData() const { return (void*) mPropertyData.data(); }
CVector3f Position() const { return mPosition.IsValid() ? mPosition.Get() : CVector3f::skZero; }

View File

@@ -21,17 +21,17 @@ CScriptTemplate::CScriptTemplate(CGameTemplate *pGame)
, mpActiveProperty(nullptr)
, mpLightParametersProperty(nullptr)
, mPreviewScale(1.f)
, mVolumeShape(eNoShape)
, mVolumeShape(EVolumeShape::NoShape)
, mVolumeScale(1.f)
{
}
// New constructor
CScriptTemplate::CScriptTemplate(CGameTemplate* pInGame, uint32 InObjectID, const TString& kInFilePath)
: mRotationType(eRotationEnabled)
, mScaleType(eScaleEnabled)
: mRotationType(ERotationType::RotationEnabled)
, mScaleType(EScaleType::ScaleEnabled)
, mPreviewScale(1.f)
, mVolumeShape(eNoShape)
, mVolumeShape(EVolumeShape::NoShape)
, mVolumeScale(1.f)
, mSourceFile(kInFilePath)
, mObjectID(InObjectID)
@@ -85,10 +85,10 @@ void CScriptTemplate::Serialize(IArchive& Arc)
Arc << SerialParameter("Assets", mAssets, SH_Optional)
<< SerialParameter("Attachments", mAttachments, SH_Optional)
<< SerialParameter("RotationType", mRotationType, SH_Optional, eRotationEnabled)
<< SerialParameter("ScaleType", mScaleType, SH_Optional, eScaleEnabled)
<< SerialParameter("RotationType", mRotationType, SH_Optional, ERotationType::RotationEnabled)
<< SerialParameter("ScaleType", mScaleType, SH_Optional, EScaleType::ScaleEnabled)
<< SerialParameter("PreviewScale", mPreviewScale, SH_Optional, 1.0f)
<< SerialParameter("VolumeShape", mVolumeShape, SH_Optional, eNoShape)
<< SerialParameter("VolumeShape", mVolumeShape, SH_Optional, EVolumeShape::NoShape)
<< SerialParameter("VolumeScale", mVolumeScale, SH_Optional, 1.0f)
<< SerialParameter("VolumeConditionProperty", mVolumeConditionIDString, SH_Optional)
<< SerialParameter("VolumeConditions", mVolumeConditions, SH_Optional);
@@ -129,13 +129,13 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
if (pObj->Template() != this)
{
errorf("%s instance somehow called VolumeShape() on %s template", *pObj->Template()->Name(), *Name());
return eInvalidShape;
return EVolumeShape::InvalidShape;
}
if (mVolumeShape == eConditionalShape)
if (mVolumeShape == EVolumeShape::ConditionalShape)
{
int32 Index = CheckVolumeConditions(pObj, true);
if (Index == -1) return eInvalidShape;
if (Index == -1) return EVolumeShape::InvalidShape;
else return mVolumeConditions[Index].Shape;
}
else return mVolumeShape;
@@ -149,7 +149,7 @@ float CScriptTemplate::VolumeScale(CScriptObject *pObj)
return -1;
}
if (mVolumeShape == eConditionalShape)
if (mVolumeShape == EVolumeShape::ConditionalShape)
{
int32 Index = CheckVolumeConditions(pObj, false);
if (Index == -1) return mVolumeScale;
@@ -161,7 +161,7 @@ float CScriptTemplate::VolumeScale(CScriptObject *pObj)
int32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors)
{
// Private function
if (mVolumeShape == eConditionalShape)
if (mVolumeShape == EVolumeShape::ConditionalShape)
{
TIDString PropID = mVolumeConditionIDString;
IProperty* pProp = pObj->Template()->Properties()->ChildByIDString( PropID );
@@ -216,11 +216,11 @@ CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, uint32& rOutCh
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
{
if (it->AssetType == SEditorAsset::eCollision) continue;
if (it->AssetType == SEditorAsset::EAssetType::Collision) continue;
CResource *pRes = nullptr;
// File
if (it->AssetSource == SEditorAsset::eFile)
if (it->AssetSource == SEditorAsset::EAssetSource::File)
pRes = gpEditorStore->LoadResource(it->AssetLocation);
// Property
@@ -228,7 +228,7 @@ CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, uint32& rOutCh
{
IProperty* pProp = mpProperties->ChildByIDString(it->AssetLocation);
if (it->AssetType == SEditorAsset::eAnimParams && pProp->Type() == EPropertyType::AnimationSet)
if (it->AssetType == SEditorAsset::EAssetType::AnimParams && pProp->Type() == EPropertyType::AnimationSet)
{
CAnimationSetProperty* pAnimSet = TPropCast<CAnimationSetProperty>(pProp);
CAnimationParameters Params = pAnimSet->Value(pPropertyData);
@@ -255,7 +255,7 @@ CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, uint32& rOutCh
// If we have a valid resource, return
if (pRes)
{
rOutIsInGame = (pRes->Type() != eTexture && it->AssetSource == SEditorAsset::eProperty);
rOutIsInGame = (pRes->Type() != EResourceType::Texture && it->AssetSource == SEditorAsset::EAssetSource::Property);
return pRes;
}
}
@@ -268,11 +268,11 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(void* pPropertyData)
{
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
{
if (it->AssetType != SEditorAsset::eCollision) continue;
if (it->AssetType != SEditorAsset::EAssetType::Collision) continue;
CResource *pRes = nullptr;
// File
if (it->AssetSource == SEditorAsset::eFile)
if (it->AssetSource == SEditorAsset::EAssetSource::File)
pRes = gpResourceStore->LoadResource(it->AssetLocation);
// Property
@@ -283,12 +283,12 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(void* pPropertyData)
if (pProp->Type() == EPropertyType::Asset)
{
CAssetProperty* pAsset = TPropCast<CAssetProperty>(pProp);
pRes = gpResourceStore->LoadResource( pAsset->Value(pPropertyData), eDynamicCollision );
pRes = gpResourceStore->LoadResource( pAsset->Value(pPropertyData), EResourceType::DynamicCollision );
}
}
// Verify resource exists + is correct type
if (pRes && (pRes->Type() == eDynamicCollision))
if (pRes && (pRes->Type() == EResourceType::DynamicCollision))
return static_cast<CCollisionMeshGroup*>(pRes);
}

View File

@@ -44,23 +44,23 @@ struct SAttachment
class CScriptTemplate
{
public:
enum ERotationType {
eRotationEnabled, eRotationDisabled
enum class ERotationType {
RotationEnabled, RotationDisabled,
};
enum EScaleType {
eScaleEnabled, eScaleDisabled, eScaleVolume
enum class EScaleType {
ScaleEnabled, ScaleDisabled, ScaleVolume
};
private:
struct SEditorAsset
{
enum EAssetType {
eModel, eAnimParams, eBillboard, eCollision
enum class EAssetType {
Model, AnimParams, Billboard, Collision
} AssetType;
enum EAssetSource {
eProperty, eFile
enum class EAssetSource {
Property, File
} AssetSource;
TIDString AssetLocation;

View File

@@ -1,15 +1,15 @@
#ifndef EVOLUMESHAPE
#define EVOLUMESHAPE
enum EVolumeShape
enum class EVolumeShape
{
eNoShape,
eAxisAlignedBoxShape,
eBoxShape,
eEllipsoidShape,
eCylinderShape,
eConditionalShape,
eInvalidShape
NoShape,
AxisAlignedBoxShape,
BoxShape,
EllipsoidShape,
CylinderShape,
ConditionalShape,
InvalidShape
};
#endif // EVOLUMESHAPE