This commit is contained in:
Aruki 2019-06-14 23:32:26 -07:00
commit ca40d34739
8 changed files with 47 additions and 18 deletions

View File

@ -32,10 +32,10 @@
}, },
{ {
"name": "lzokay", "name": "lzokay",
"url": "https://github.com/sfuller/lzokay", "url": "https://github.com/jackoalan/lzokay",
"type": "git", "type": "git",
"head": "cmake", "head": "master",
"ref": "87467048df10e72540a5abcac9dd5c0c4df3a712" "ref": "343f9707f6ab2143d3455c93d8b7570a0ffcee97"
}, },
{ {
"name": "tinyxml2", "name": "tinyxml2",

View File

@ -102,11 +102,11 @@ namespace CompressionUtil
else return true; else return true;
} }
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut) bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
{ {
#if USE_LZOKAY #if USE_LZOKAY
size_t TotalOut = rTotalOut; size_t TotalOut;
lzokay::EResult Result = lzokay::decompress(pSrc, (size_t) SrcLen, pDst, TotalOut); lzokay::EResult Result = lzokay::decompress(pSrc, (size_t) SrcLen, pDst, DstLen, TotalOut);
rTotalOut = TotalOut; rTotalOut = TotalOut;
if (Result < lzokay::EResult::Success) if (Result < lzokay::EResult::Success)
@ -172,7 +172,7 @@ namespace CompressionUtil
// No zlib magic - this is LZO // No zlib magic - this is LZO
else else
{ {
bool Success = DecompressLZO(pSrc, Size, pDst, TotalOut); bool Success = DecompressLZO(pSrc, Size, pDst, (uint32) (pDstEnd - pDst), TotalOut);
if (!Success) return false; if (!Success) return false;
} }
@ -220,8 +220,9 @@ namespace CompressionUtil
bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut) bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
{ {
#if USE_LZOKAY #if USE_LZOKAY
rTotalOut = DstLen; size_t TotalOut;
lzokay::EResult Result = lzokay::compress(pSrc, (size_t) SrcLen, pDst, (size_t&) rTotalOut); lzokay::EResult Result = lzokay::compress(pSrc, (size_t) SrcLen, pDst, DstLen, TotalOut);
rTotalOut = TotalOut;
if (Result < lzokay::EResult::Success) if (Result < lzokay::EResult::Success)
{ {

View File

@ -16,6 +16,19 @@ enum class ELinkType
Outgoing Outgoing
}; };
class CInstanceID
{
uint32 mId = 0;
public:
operator uint32() const { return mId; }
CInstanceID() = default;
CInstanceID(uint32 id) : mId(id) {}
CInstanceID& operator=(uint32 id) { mId = id; return *this; }
uint8 Layer() const { return uint8((mId >> 26u) & 0x3fu); }
uint16 Area() const { return uint16((mId >> 16u) & 0x3ffu); }
uint16 Id() const { return uint16(mId & 0xffffu); }
};
class CScriptObject class CScriptObject
{ {
friend class CScriptLoader; friend class CScriptLoader;
@ -26,7 +39,7 @@ class CScriptObject
CScriptLayer *mpLayer; CScriptLayer *mpLayer;
uint32 mVersion; uint32 mVersion;
uint32 mInstanceID; CInstanceID mInstanceID;
std::vector<CLink*> mOutLinks; std::vector<CLink*> mOutLinks;
std::vector<CLink*> mInLinks; std::vector<CLink*> mInLinks;
std::vector<char> mPropertyData; std::vector<char> mPropertyData;
@ -75,7 +88,7 @@ public:
CScriptLayer* Layer() const { return mpLayer; } CScriptLayer* Layer() const { return mpLayer; }
uint32 Version() const { return mVersion; } uint32 Version() const { return mVersion; }
uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); } uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); }
uint32 InstanceID() const { return mInstanceID; } CInstanceID InstanceID() const { return mInstanceID; }
uint32 NumLinks(ELinkType Type) const { return (Type == ELinkType::Incoming ? mInLinks.size() : mOutLinks.size()); } 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]); } CLink* Link(ELinkType Type, uint32 Index) const { return (Type == ELinkType::Incoming ? mInLinks[Index] : mOutLinks[Index]); }
void* PropertyData() const { return (void*) mPropertyData.data(); } void* PropertyData() const { return (void*) mPropertyData.data(); }

View File

@ -70,7 +70,7 @@ public:
virtual void Destruct(void* pData) const virtual void Destruct(void* pData) const
{ {
RevertToDefault(pData); RevertToDefault(pData);
TTypedProperty::Destruct(pData); _GetInternalArray(pData).~SScriptArray();
} }
virtual bool MatchesDefault(void* pData) const virtual bool MatchesDefault(void* pData) const

View File

@ -280,7 +280,8 @@ CDependencyTree* CStringTable::BuildDependencyTree() const
{ {
if (Game() >= EGame::CorruptionProto) if (Game() >= EGame::CorruptionProto)
{ {
ASSERT(ParamString.StartsWith("0x")); if (!ParamString.StartsWith("0x"))
continue;
ParamString = ParamString.ChopFront(2); ParamString = ParamString.ChopFront(2);
} }

View File

@ -84,7 +84,7 @@ public:
class CInstancePtr class CInstancePtr
{ {
uint32 mInstanceID; CInstanceID mInstanceID;
CGameArea *mpArea; CGameArea *mpArea;
bool mValid; bool mValid;
@ -94,12 +94,12 @@ public:
inline void SetInstance(CScriptObject *pInst) inline void SetInstance(CScriptObject *pInst)
{ {
mInstanceID = pInst ? pInst->InstanceID() : 0; mInstanceID = pInst ? pInst->InstanceID() : CInstanceID();
mpArea = pInst ? pInst->Area() : nullptr; mpArea = pInst ? pInst->Area() : nullptr;
mValid = pInst ? true : false; mValid = pInst ? true : false;
} }
inline uint32 InstanceID() const { return mInstanceID; } inline CInstanceID InstanceID() const { return mInstanceID; }
inline CGameArea* Area() const { return mpArea; } inline CGameArea* Area() const { return mpArea; }
inline CScriptObject* operator* () const { return mValid ? mpArea->InstanceByID(mInstanceID) : nullptr; } inline CScriptObject* operator* () const { return mValid ? mpArea->InstanceByID(mInstanceID) : nullptr; }
inline CScriptObject* operator->() const { return mValid ? mpArea->InstanceByID(mInstanceID) : nullptr; } inline CScriptObject* operator->() const { return mValid ? mpArea->InstanceByID(mInstanceID) : nullptr; }

View File

@ -219,6 +219,11 @@ CWorldEditor::CWorldEditor(QWidget *parent)
CWorldEditor::~CWorldEditor() CWorldEditor::~CWorldEditor()
{ {
mScene.ClearScene();
mpArea = nullptr;
mpWorld = nullptr;
gpResourceStore->DestroyUnreferencedResources(); // this should destroy the area!
delete mpScriptSidebar; // For some reason WCreateTab filters an event during the viewport's destructor delete mpScriptSidebar; // For some reason WCreateTab filters an event during the viewport's destructor
delete ui; delete ui;
} }

View File

@ -10,6 +10,7 @@ WEditorProperties::WEditorProperties(QWidget *pParent /*= 0*/)
{ {
mpInstanceInfoLabel = new QLabel; mpInstanceInfoLabel = new QLabel;
mpInstanceInfoLabel->setText("<i>[No selection]</i>"); mpInstanceInfoLabel->setText("<i>[No selection]</i>");
mpInstanceInfoLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
mpInstanceInfoLayout = new QHBoxLayout; mpInstanceInfoLayout = new QHBoxLayout;
mpInstanceInfoLayout->addWidget(mpInstanceInfoLabel); mpInstanceInfoLayout->addWidget(mpInstanceInfoLabel);
@ -124,14 +125,22 @@ void WEditorProperties::OnSelectionModified()
mpInstanceInfoLabel->setText(QString("<i>[%1 objects selected]</i>").arg(pSelection->Size())); mpInstanceInfoLabel->setText(QString("<i>[%1 objects selected]</i>").arg(pSelection->Size()));
mpInstanceNameLineEdit->clear(); mpInstanceNameLineEdit->clear();
} }
mpInstanceInfoLabel->setToolTip({});
} }
else else
{ {
CScriptNode *pScript = static_cast<CScriptNode*>(mpDisplayNode); CScriptNode *pScript = static_cast<CScriptNode*>(mpDisplayNode);
TString InstanceID = TString::HexString(pScript->Instance()->InstanceID(), 8, false); CInstanceID InstanceID = pScript->Instance()->InstanceID();
TString ObjectType = pScript->Template()->Name(); TString ObjectType = pScript->Template()->Name();
mpInstanceInfoLabel->setText(QString("[%1] [%2]").arg( TO_QSTRING(ObjectType) ).arg( TO_QSTRING(InstanceID) )); mpInstanceInfoLabel->setText(QString("[%1] [%2]").
arg( TO_QSTRING(ObjectType) ).
arg( TO_QSTRING(TString::HexString(InstanceID, 8, false)) ));
mpInstanceInfoLabel->setToolTip(QString("[Layer: %1] [Area: %2] [ID: %3]").
arg( InstanceID.Layer() ).
arg( InstanceID.Area() ).
arg( TO_QSTRING(TString::HexString(InstanceID.Id(), 4, false)) ));
UpdatePropertyValues(); UpdatePropertyValues();
} }