From a382752354a8657a5cde40d40bc48e2e1bb58c8e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 18 Jan 2013 19:37:43 -0500 Subject: [PATCH 1/8] Fill out bink stub Max 2012 doesn't like getting a null from ClassDesc2::Create(). I can't blame it. --- Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp | 35 +++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp b/Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp index ae499a18..a6a77390 100644 --- a/Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp +++ b/Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp @@ -42,18 +42,43 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "HeadSpin.h" #include "hsWindows.h" + +#include #include #pragma hdrstop -class BinkClassDesc : public ClassDesc2 +/** Stubbed out BitmapIO instance for deprecated bink layers **/ +class plBinkBitmapIO : public BitmapIO { public: - int IsPublic() { return 1; } - void* Create(BOOL loading=FALSE) + int ExtCount() { return 1; } + const TCHAR* Ext(int n) { return _T("bik"); } + + const TCHAR* LongDesc() { return _T("DEAD: Bink File"); } + const TCHAR* ShortDesc() { return _T("Bink"); } + + const TCHAR* AuthorName() { return _T("Colin Bonstead"); } + const TCHAR* CopyrightMessage() { return _T("Copyright 2004, Cyan Inc."); } + unsigned int Version() { return 100; } + + int Capability() { return 0; } + DWORD EvaluateConfigure() { return 0; } + BOOL LoadConfigure(void* ptr) { return FALSE; } + BOOL SaveConfigure(void* ptr) { return FALSE; } + + BMMRES GetImageInfo(BitmapInfo* fbi) { return BMMRES_INTERNALERROR; } + BitmapStorage* Load(BitmapInfo* fbi, Bitmap* map, BMMRES* status) { return nullptr; } + void ShowAbout(HWND hWnd) { - hsAssert(false, "bink layers removed due to license issues"); - return nil; + hsMessageBoxWithOwner(hWnd, "Bink Layers removed due to license issues", "DEAD", hsMessageBoxNormal, MB_ICONEXCLAMATION); } +}; + +class BinkClassDesc : public ClassDesc2 +{ +public: + int IsPublic() { return 1; } + void* Create(BOOL loading=FALSE) { return static_cast(new plBinkBitmapIO); } const TCHAR* ClassName() { return "Bink"; } SClass_ID SuperClassID() { return BMM_IO_CLASS_ID; } From 3e592b76ff612eb1493eae82805c45f2bed19fa4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 26 Jan 2013 20:49:38 -0500 Subject: [PATCH 2/8] Don't throw away components that come last --- Sources/Tools/MaxComponent/plComponentMgr.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Sources/Tools/MaxComponent/plComponentMgr.cpp b/Sources/Tools/MaxComponent/plComponentMgr.cpp index 6e32c8b9..1b91220c 100644 --- a/Sources/Tools/MaxComponent/plComponentMgr.cpp +++ b/Sources/Tools/MaxComponent/plComponentMgr.cpp @@ -102,13 +102,6 @@ int IDescCompare(ClassDesc *desc1, ClassDesc *desc2); void plComponentMgr::Register(ClassDesc *desc) { - // No descs? Go ahead and push it to the back... - if (fDescs.size() == 0) - { - fDescs.push_back(desc); - return; - } - // Organize desc's by category and name std::vector::iterator it; for (it = fDescs.begin(); it != fDescs.end(); it++) @@ -119,6 +112,9 @@ void plComponentMgr::Register(ClassDesc *desc) return; } } + + // Still here? Push it to the back. + fDescs.push_back(desc); } int IDescCompare(ClassDesc *desc1, ClassDesc *desc2) From 66423478cc9871e145ad92913019f8fc5cd70f6d Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 26 Jan 2013 20:52:40 -0500 Subject: [PATCH 3/8] Allow encrypted age files Yes, this bit me in the ass. --- Sources/Tools/MaxComponent/Pch.h | 1 + .../Tools/MaxComponent/plMiscComponents.cpp | 37 ++++++++----------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Sources/Tools/MaxComponent/Pch.h b/Sources/Tools/MaxComponent/Pch.h index 42566e6f..50773a0f 100644 --- a/Sources/Tools/MaxComponent/Pch.h +++ b/Sources/Tools/MaxComponent/Pch.h @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Standard Library #include #include +#include #include #include #include diff --git a/Sources/Tools/MaxComponent/plMiscComponents.cpp b/Sources/Tools/MaxComponent/plMiscComponents.cpp index 594f7d90..395ae812 100644 --- a/Sources/Tools/MaxComponent/plMiscComponents.cpp +++ b/Sources/Tools/MaxComponent/plMiscComponents.cpp @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "resource.h" #include +#include #include #pragma hdrstop @@ -96,6 +97,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Location Related #include "plAgeDescription/plAgeDescription.h" +#include "plFile/plEncryptedStream.h" #include "MaxMain/plMaxCFGFile.h" #include "MaxMain/plAgeDescInterface.h" #include "plResMgr/plPageInfo.h" @@ -649,9 +651,9 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg ) plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge)); IVerifyLatestAgeAsset( curAge, path, errMsg ); + std::unique_ptr aged(plPageInfoUtils::GetAgeDesc(curAge)); - hsUNIXStream s; - if (!s.Open(path)) + if (!aged) { errMsg->Set( true, "PageInfo Convert Error", @@ -664,13 +666,8 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg ) return; } - // create and read the age desc - plAgeDescription aged; - aged.Read(&s); - s.Close(); - // Update based on the age file now - fCompPB->SetValue( kInfoSeqPrefix, 0, (int)aged.GetSequencePrefix() ); + fCompPB->SetValue( kInfoSeqPrefix, 0, (int)aged->GetSequencePrefix() ); // Find our page const char *compPBPageName = fCompPB->GetStr( kInfoPage ); @@ -688,9 +685,9 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg ) } plAgePage *page; - aged.SeekFirstPage(); + aged->SeekFirstPage(); - while( ( page = aged.GetNextPage() ) != nil ) + while( ( page = aged->GetNextPage() ) != nil ) { if( page->GetName().CompareI( compPBPageName ) == 0 ) { @@ -790,18 +787,16 @@ plAgeDescription *plPageInfoUtils::GetAgeDesc( const plString &ageName ) { plFileName ageFolder = plPageInfoUtils::GetAgeFolder(); if (!ageFolder.IsValid() || ageName.IsNull()) - return nil; - - hsUNIXStream s; - if (!s.Open(plFileName::Join(ageFolder, ageName + ".age"))) - return nil; - - // Create and read the age desc - plAgeDescription *aged = new plAgeDescription; - aged->Read( &s ); - s.Close(); + return nullptr; - return aged; + plAgeDescription* aged = new plAgeDescription; + if (aged->ReadFromFile(plFileName::Join(ageFolder, ageName + ".age"))) + return aged; + else + { + delete aged; + return nullptr; + } } const char* LocCompGetPage(plComponentBase* comp) From ceaa747ff1e704ecccd5682bebc7c1b5af2d9d23 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 26 Jan 2013 23:20:21 -0500 Subject: [PATCH 4/8] Fix Insanity WTF: `IKey* key=(IKey*)(new uint8_t [keys->GetKeySize()]);` --- Sources/Tools/MaxConvert/Pch.h | 2 + .../Tools/MaxConvert/hsControlConverter.cpp | 104 +++++++++--------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/Sources/Tools/MaxConvert/Pch.h b/Sources/Tools/MaxConvert/Pch.h index 475e7a59..46f4a87c 100644 --- a/Sources/Tools/MaxConvert/Pch.h +++ b/Sources/Tools/MaxConvert/Pch.h @@ -51,7 +51,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Standard Library #include #include +#include #include +#include #include #include diff --git a/Sources/Tools/MaxConvert/hsControlConverter.cpp b/Sources/Tools/MaxConvert/hsControlConverter.cpp index a8c81b15..d204f1d4 100644 --- a/Sources/Tools/MaxConvert/hsControlConverter.cpp +++ b/Sources/Tools/MaxConvert/hsControlConverter.cpp @@ -40,12 +40,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ +#include +#include +#include + #include "HeadSpin.h" #include "hsExceptionStack.h" #include "hsTemplates.h" #include "hsWindows.h" #include -#include #include #include #include @@ -72,6 +75,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnSceneObject/plSceneObject.h" #include "pnSceneObject/plCoordinateInterface.h" +typedef std::unique_ptr> ikey_ptr; + +/** Allocates a managed buffer to store derivatives of IKey */ +static ikey_ptr IAllocKey(size_t size) +{ + return ikey_ptr( + reinterpret_cast(new uint8_t[size]), + [](IKey* ptr) { delete[] reinterpret_cast(ptr); }); +} + +////////////////////////////////////////////////////////////////////////// + extern UserPropMgr gUserPropMgr; hsControlConverter& hsControlConverter::Instance() @@ -760,7 +775,7 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con return NULL; } - IKey* key=(IKey*)(new uint8_t[ikeys->GetKeySize()]); + ikey_ptr key = IAllocKey(ikeys->GetKeySize()); plLeafController* pc = new plLeafController; uint8_t compressLevel = node->GetAnimCompress(); @@ -776,7 +791,7 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con for(int i = startIdx; i <= endIdx; i++) { // Get key - ikeys->GetKey(i, key); + ikeys->GetKey(i, key.get()); const float kMaxRads = M_PI* 0.5f; Tab kTimes; kTimes.ZeroCount(); @@ -791,12 +806,12 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con if (keyType == hsKeyFrame::kQuatKeyFrame) { hsQuatKey *hsKey = pc->GetQuatKey(i - startIdx); - ICreateHSInterpKey(control, key, kTimes[k], hsKey, node, camRot); + ICreateHSInterpKey(control, key.get(), kTimes[k], hsKey, node, camRot); } else if (keyType == hsKeyFrame::kCompressedQuatKeyFrame64) { hsQuatKey tempKey; - ICreateHSInterpKey(control, key, kTimes[k], &tempKey, node, camRot); + ICreateHSInterpKey(control, key.get(), kTimes[k], &tempKey, node, camRot); hsCompressedQuatKey64 *compKey = pc->GetCompressedQuatKey64(i - startIdx); compKey->fFrame = tempKey.fFrame; compKey->SetQuat(tempKey.fValue); @@ -804,14 +819,13 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con else { hsQuatKey tempKey; - ICreateHSInterpKey(control, key, kTimes[k], &tempKey, node, camRot); + ICreateHSInterpKey(control, key.get(), kTimes[k], &tempKey, node, camRot); hsCompressedQuatKey32 *compKey = pc->GetCompressedQuatKey32(i - startIdx); compKey->fFrame = tempKey.fFrame; compKey->SetQuat(tempKey.fValue); } } } - delete [] key; return pc; } @@ -840,22 +854,21 @@ plLeafController* hsControlConverter::ICreateScaleValueController(plMaxNode* nod return NULL; } - IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]); + ikey_ptr key = IAllocKey(ikeys->GetKeySize()); plLeafController* pc = new plLeafController; pc->AllocKeys(endIdx - startIdx + 1, GetKeyType(control)); for(int i = startIdx; i <= endIdx; i++) { // Get key - ikeys->GetKey(i, key); + ikeys->GetKey(i, key.get()); hsScaleKey *hsKey = pc->GetScaleKey(i - startIdx); if (hsKey) - ICreateHSInterpKey(control, key, key->time, hsKey, node); + ICreateHSInterpKey(control, key.get(), key->time, hsKey, node); hsBezScaleKey *bezKey = pc->GetBezScaleKey(i - startIdx); if (bezKey) - ICreateHSInterpKey(control, key, key->time, bezKey, node); + ICreateHSInterpKey(control, key.get(), key->time, bezKey, node); } - delete [] key; return pc; } @@ -881,23 +894,22 @@ plLeafController* hsControlConverter::ICreateScalarController(plMaxNode* node, C return NULL; } - IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]); + ikey_ptr key = IAllocKey(ikeys->GetKeySize()); plLeafController* pc = new plLeafController; pc->AllocKeys(endIdx - startIdx + 1, GetKeyType(control)); for(int i = startIdx; i <= endIdx; i++) { // Get key - ikeys->GetKey(i, key); + ikeys->GetKey(i, key.get()); hsScalarKey *hsKey = pc->GetScalarKey(i - startIdx); if (hsKey) - ICreateHSInterpKey(control, key, key->time, hsKey); + ICreateHSInterpKey(control, key.get(), key->time, hsKey); hsBezScalarKey *bezKey = pc->GetBezScalarKey(i - startIdx); if (bezKey) - ICreateHSInterpKey(control, key, key->time, bezKey); + ICreateHSInterpKey(control, key.get(), key->time, bezKey); } - delete [] key; return pc; } return nil; @@ -923,22 +935,21 @@ plLeafController* hsControlConverter::ICreateSimplePosController(plMaxNode* node return NULL; } - IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]); + ikey_ptr key = IAllocKey(ikeys->GetKeySize()); plLeafController* pc = new plLeafController; pc->AllocKeys(endIdx - startIdx + 1, GetKeyType(control)); for(int i = startIdx; i <= endIdx; i++) { // Get key - ikeys->GetKey(i, key); + ikeys->GetKey(i, key.get()); hsPoint3Key *hsKey = pc->GetPoint3Key(i - startIdx); if (hsKey) - ICreateHSInterpKey(control, key, key->time, hsKey); + ICreateHSInterpKey(control, key.get(), key->time, hsKey); hsBezPoint3Key *bezKey = pc->GetBezPoint3Key(i - startIdx); if (bezKey) - ICreateHSInterpKey(control, key, key->time, bezKey); + ICreateHSInterpKey(control, key.get(), key->time, bezKey); } - delete [] key; return pc; } @@ -979,13 +990,13 @@ int hsControlConverter::IAddPartsKeys(Control* control, // // Traverse all keys of controller // - IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]); + ikey_ptr key = IAllocKey(ikeys->GetKeySize()); bool mb=false; plMaxNode* xformParent = GetXformParent(node); for(i = startIdx; i <= endIdx; i++) { // Get key - ikeys->GetKey(i, key); + ikeys->GetKey(i, key.get()); float frameTime = key->time / GetTicksPerSec(); int frameNum = key->time / GetTicksPerFrame(); hsAssert(frameNum <= hsKeyFrame::kMaxFrameNumber, "Anim is too long."); @@ -1023,7 +1034,6 @@ int hsControlConverter::IAddPartsKeys(Control* control, // Add key to list kfArray->Append(hKey); } - delete [] key; } else { @@ -1099,8 +1109,8 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i IKeyControl* ikeys = GetKeyControlInterface(control); - IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]); - IKey* lastKey=(IKey*)(new uint8_t [ikeys->GetKeySize()]); + ikey_ptr key = IAllocKey(ikeys->GetKeySize()); + ikey_ptr lastKey = IAllocKey(ikeys->GetKeySize()); int i; for( i = iLo; i < iHi; i++ ) @@ -1120,17 +1130,17 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i // key[i] = key[i-1] * key[i] // or pass in the previous key and do it here. /////////////////////////////////////// - ikeys->GetKey(i-1, lastKey); - ikeys->GetKey(i, key); + ikeys->GetKey(i-1, lastKey.get()); + ikeys->GetKey(i, key.get()); if( cID == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0) ) { - ITCBRotKey* tcbRotKey = (ITCBRotKey*)key; + ITCBRotKey* tcbRotKey = (ITCBRotKey*)key.get(); rads = tcbRotKey->val.angle; } else if( cID == Class_ID(LININTERP_ROTATION_CLASS_ID, 0) ) { - ILinRotKey* linRotKey = (ILinRotKey*)key; + ILinRotKey* linRotKey = (ILinRotKey*)key.get(); Point3 axis; AngAxisFromQ(linRotKey->val, &rads, axis); @@ -1138,7 +1148,7 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i else if( cID == Class_ID(HYBRIDINTERP_ROTATION_CLASS_ID, 0) ) { - IBezQuatKey* bezRotKey = (IBezQuatKey*)key; + IBezQuatKey* bezRotKey = (IBezQuatKey*)key.get(); Point3 axis; AngAxisFromQ(bezRotKey->val, &rads, axis); @@ -1146,26 +1156,26 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i else if( cID == Class_ID(TCBINTERP_FLOAT_CLASS_ID, 0) ) { - ITCBFloatKey* fKey = (ITCBFloatKey*)key; + ITCBFloatKey* fKey = (ITCBFloatKey*)key.get(); rads = fKey->val; - fKey = (ITCBFloatKey*)lastKey; + fKey = (ITCBFloatKey*)lastKey.get(); rads -= fKey->val; } else if( cID == Class_ID(LININTERP_FLOAT_CLASS_ID, 0) ) { - ILinFloatKey* fKey = (ILinFloatKey*)key; + ILinFloatKey* fKey = (ILinFloatKey*)key.get(); rads = fKey->val; - fKey = (ILinFloatKey*)lastKey; + fKey = (ILinFloatKey*)lastKey.get(); rads -= fKey->val; } else if( cID == Class_ID(HYBRIDINTERP_FLOAT_CLASS_ID, 0) ) { - IBezFloatKey* fKey = (IBezFloatKey*)key; + IBezFloatKey* fKey = (IBezFloatKey*)key.get(); rads = fKey->val; - fKey = (IBezFloatKey*)lastKey; + fKey = (IBezFloatKey*)lastKey.get(); rads -= fKey->val; } @@ -1188,9 +1198,6 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i /////////////////////////////////////// } - delete [] key; - delete [] lastKey; - hsGuardEnd; } @@ -1443,13 +1450,13 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co if (numKeys == 0) return 0; - IKey* key=(IKey*)(new uint8_t [keys->GetKeySize()]); + ikey_ptr key = IAllocKey(keys->GetKeySize()); start = numKeys; for (int i=0; iGetKey(i, key); - if (IIsKeyInRange(key)) + keys->GetKey(i, key.get()); + if (IIsKeyInRange(key.get())) { if (start > i) start = i; @@ -1464,7 +1471,7 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co { for (int i = 0; i < numKeys; i++) { - keys->GetKey(i, key); + keys->GetKey(i, key.get()); if (key->time < fSegStart) start = i; } @@ -1472,7 +1479,6 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co if ((start == numKeys) || // no keys before the start time (start == numKeys - 1)) // no keys after end (since the latest key is before start) { - delete [] key; return 0; } @@ -1480,17 +1486,15 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co } else { - keys->GetKey(start, key); + keys->GetKey(start, key.get()); if (key->time > fSegStart && start > 0) start -= 1; - keys->GetKey(end, key); + keys->GetKey(end, key.get()); if (key->time < fSegEnd && end < numKeys - 1) end += 1; } - delete [] key; - //fErrorMsg->Set(numInRange>1 && numInRange!=numKeys, nodeName ? nodeName : "?", // "Warning: Object has controller with keyframes outside of animation interval").CheckAndAsk(); From c607ea3cf381063d9958a1339942e0129746e555 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 27 Jan 2013 00:00:16 -0500 Subject: [PATCH 5/8] Fix PageInfo component --- Sources/Tools/MaxComponent/plMiscComponents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Tools/MaxComponent/plMiscComponents.cpp b/Sources/Tools/MaxComponent/plMiscComponents.cpp index 395ae812..574fecfb 100644 --- a/Sources/Tools/MaxComponent/plMiscComponents.cpp +++ b/Sources/Tools/MaxComponent/plMiscComponents.cpp @@ -272,7 +272,7 @@ protected: int idx = ComboBox_AddString( hAgeCombo, ageName.c_str() ); // Store the pathas the item data for later (so don't free it yet!) - ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)ageFiles[i].AsString().c_str() ); + ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)hsStrcpy(ageFiles[i].AsString().c_str()) ); if (ageName == curAge) ComboBox_SetCurSel( hAgeCombo, idx ); From 2b03cd7afed88b7f405e5ec8ae325880e34ba279 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Jan 2013 21:20:16 -0500 Subject: [PATCH 6/8] Fix compile for ancient max versions --- Sources/Tools/MaxComponent/Pch.h | 25 +++++------ Sources/Tools/MaxComponent/plComponentBase.h | 3 +- .../Tools/MaxComponent/plMiscComponents.cpp | 2 +- Sources/Tools/MaxComponent/plMiscComponents.h | 2 +- Sources/Tools/MaxConvert/Pch.h | 9 ++-- .../Tools/MaxConvert/hsMaterialConverter.cpp | 6 +-- .../Tools/MaxConvert/hsMaterialConverter.h | 3 +- Sources/Tools/MaxExport/Pch.h | 2 +- Sources/Tools/MaxMain/MaxCompat.h | 41 ++++++++++--------- Sources/Tools/MaxMain/Pch.h | 18 ++++---- Sources/Tools/MaxMain/plComponentDlg.h | 9 +++- Sources/Tools/MaxMain/plMaxNodeBase.cpp | 3 +- Sources/Tools/MaxPlasmaLights/Pch.h | 9 ++-- .../Tools/MaxPlasmaLights/plRTProjDirLight.h | 1 - Sources/Tools/MaxPlasmaMtls/Pch.h | 10 ++--- 15 files changed, 78 insertions(+), 65 deletions(-) diff --git a/Sources/Tools/MaxComponent/Pch.h b/Sources/Tools/MaxComponent/Pch.h index 50773a0f..9de18dd7 100644 --- a/Sources/Tools/MaxComponent/Pch.h +++ b/Sources/Tools/MaxComponent/Pch.h @@ -79,6 +79,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +// 3ds Max SDK +// This stuff should ALWAYS come after hsWindows.h +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + // These MaxComponent headers will trigger a rebuild if they are changed // So it's probably best to precompile them anyway. // Some of these may include 3dsm headers, so ensure they come after hsWindows.h @@ -103,18 +116,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "MaxMain/plMaxNode.h" #include "MaxMain/plMaxNodeData.h" -// 3ds Max SDK -// This stuff should ALWAYS come after hsWindows.h -#include -#include -#include -#include -#include -#include -#include -#include -#include - #if MAX_VERSION_MAJOR >= 13 # include #endif diff --git a/Sources/Tools/MaxComponent/plComponentBase.h b/Sources/Tools/MaxComponent/plComponentBase.h index 841faed7..4a00021f 100644 --- a/Sources/Tools/MaxComponent/plComponentBase.h +++ b/Sources/Tools/MaxComponent/plComponentBase.h @@ -45,8 +45,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/plKey.h" #include "hsWindows.h" -#include #include +#include extern TCHAR *GetString(int id); extern HINSTANCE hInstance; @@ -67,7 +67,6 @@ class INode; class INodeTab; class IObjParam; class ObjectState; -enum IOResult; class IParamBlock2; enum RefResult; class RemapDir; diff --git a/Sources/Tools/MaxComponent/plMiscComponents.cpp b/Sources/Tools/MaxComponent/plMiscComponents.cpp index 574fecfb..c138df01 100644 --- a/Sources/Tools/MaxComponent/plMiscComponents.cpp +++ b/Sources/Tools/MaxComponent/plMiscComponents.cpp @@ -694,7 +694,7 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg ) fCompPB->SetValue( kInfoSeqSuffix, 0, (int)page->GetSeqSuffix() ); // Also re-copy the page name, just to make sure the case is correct - fCompPB->SetValue( kInfoPage, 0, (const char *)page->GetName().c_str() ); + fCompPB->SetValue( kInfoPage, 0, const_cast(page->GetName().c_str()) ); return; } } diff --git a/Sources/Tools/MaxComponent/plMiscComponents.h b/Sources/Tools/MaxComponent/plMiscComponents.h index a2536513..681fda46 100644 --- a/Sources/Tools/MaxComponent/plMiscComponents.h +++ b/Sources/Tools/MaxComponent/plMiscComponents.h @@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define plMiscComponents_inc #include "plComponent.h" +#include #define ROOM_CID Class_ID(0x70a1570d, 0x472f5647) #define PAGEINFO_CID Class_ID(0x54ee40f1, 0x4de45acc) @@ -55,7 +56,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com class plFileName; class plAgeDescription; class plComponentBase; -struct NotifyInfo; const char* LocCompGetPage(plComponentBase* comp); diff --git a/Sources/Tools/MaxConvert/Pch.h b/Sources/Tools/MaxConvert/Pch.h index 46f4a87c..3e488d02 100644 --- a/Sources/Tools/MaxConvert/Pch.h +++ b/Sources/Tools/MaxConvert/Pch.h @@ -77,18 +77,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include -// MaxComponent -#include "MaxComponent/plComponent.h" - // 3ds Max SDK // This stuff should ALWAYS come after hsWindows.h +#include #include #include #include #include +#include // needs to be above ISkin.h for Max 7 #include #include -#include #include #include #include @@ -96,6 +94,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +// MaxComponent +#include "MaxComponent/plComponent.h" + #if MAX_VERSION_MAJOR >= 13 # include #endif diff --git a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp index 0c7f7356..434f634a 100644 --- a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp +++ b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp @@ -3944,7 +3944,7 @@ bool hsMaterialConverter::IClearDoneMaterial(Mtl* mtl, plMaxNode* node) static BMM_Color_64 green64 = BMMCOLOR(0, (1<<16)-1, 0, (1<<16)-1) -BMM_Color_64 hsMaterialConverter::ICubeSample(Bitmap *bitmap[6], double phi, double theta) +static BMM_Color_64 ICubeSample(plErrorMsg* const msg, Bitmap *bitmap[6], double phi, double theta) { hsGuardBegin("hsMaterialConverter::ICubeSample"); @@ -4024,7 +4024,7 @@ BMM_Color_64 hsMaterialConverter::ICubeSample(Bitmap *bitmap[6], double phi, dou iMap = (int)(xMap * (map->Width()-1)); jMap = (int)(yMap * (map->Height()-1)); - fErrorMsg->Set(!map, "CubeSample", "Bad fallthrough in spherefromcube").Check(); + msg->Set(!map, "CubeSample", "Bad fallthrough in spherefromcube").Check(); BMM_Color_64 c; map->GetLinearPixels(iMap,jMap,1,&c); return c; @@ -4050,7 +4050,7 @@ void hsMaterialConverter::IBuildSphereMap(Bitmap *bitmap[6], Bitmap *bm) phi = (0.5 + j) * delPhi; theta = PI - (0.5 + i) * delThe; - pb[i] = ICubeSample(bitmap, phi, theta); + pb[i] = ICubeSample(fErrorMsg, bitmap, phi, theta); } bm->PutPixels(0,j, bm->Width(), pb); } diff --git a/Sources/Tools/MaxConvert/hsMaterialConverter.h b/Sources/Tools/MaxConvert/hsMaterialConverter.h index 2f77f1c3..7ff6f913 100644 --- a/Sources/Tools/MaxConvert/hsMaterialConverter.h +++ b/Sources/Tools/MaxConvert/hsMaterialConverter.h @@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define __HSMATERIALCONVERTER_H #include "HeadSpin.h" +#include class hsStream; class hsScene; @@ -62,7 +63,6 @@ class plString; class plLocation; class Animatable; -struct BMM_Color_64; class Bitmap; class BitmapTex; class Color; @@ -306,7 +306,6 @@ private: hsGMaterial *ICheckForProjectedTexture(plMaxNode *node); hsGMaterial *IWrapTextureInMaterial(Texmap *texMap, plMaxNode *node); - BMM_Color_64 ICubeSample(Bitmap *bitmap[6], double phi, double theta); void IBuildSphereMap(Bitmap *bitmap[6], Bitmap *bm); #if 0 // DEFER_ANIM_MAT void IProcessAnimMaterial(BitmapTex *bitmapTex, hsGAnimLayer* at, uint32_t texFlags, uint32_t procFlags); diff --git a/Sources/Tools/MaxExport/Pch.h b/Sources/Tools/MaxExport/Pch.h index c58286d8..a8cafd05 100644 --- a/Sources/Tools/MaxExport/Pch.h +++ b/Sources/Tools/MaxExport/Pch.h @@ -66,10 +66,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // 3ds Max SDK // This stuff should ALWAYS come after hsWindows.h +#include #include #include #include -#include #include #endif // _MaxExport_Pch_inc_ diff --git a/Sources/Tools/MaxMain/MaxCompat.h b/Sources/Tools/MaxMain/MaxCompat.h index dcd2abdd..2f1700f9 100644 --- a/Sources/Tools/MaxMain/MaxCompat.h +++ b/Sources/Tools/MaxMain/MaxCompat.h @@ -51,43 +51,46 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #if MAX_VERSION_MAJOR <= 9 -#define BMMCOLOR(x, y, z, w) \ - {x, y, x, w}; +# define BMMCOLOR(x, y, z, w) \ + {x, y, x, w}; -#define DEFAULTREMAP NoRemap() +# define DEFAULTREMAP NoRemap() -#define ENUMDEPENDENTS(maxObject, proc) \ - maxObject->EnumDependents(proc); +# define ENUMDEPENDENTS(maxObject, proc) \ + maxObject->EnumDependents(proc); -typedef TCHAR MCHAR; + typedef TCHAR MCHAR; #else -#define BMMCOLOR(x, y, z, w) \ - BMM_Color_64(x, y, z, w); +# define BMMCOLOR(x, y, z, w) \ + BMM_Color_64(x, y, z, w); -#define DEFAULTREMAP DefaultRemapDir() +# define DEFAULTREMAP DefaultRemapDir() -#define ENUMDEPENDENTS(maxObject, proc) \ - maxObject->DoEnumDependents(proc); +# define ENUMDEPENDENTS(maxObject, proc) \ + maxObject->DoEnumDependents(proc); #endif //MAX_VERSION_MAJOR #if MAX_VERSION_MAJOR <= 13 -#define GetParamBlock2Controller(pb, id) pb->GetController(id) -#define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetController(id, tab, ctl) +# define GetParamBlock2Controller(pb, id) pb->GetController(id) +# define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetController(id, tab, ctl) #else -#define GetParamBlock2Controller(pb, id) pb->GetControllerByID(id) -#define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetControllerByID(id, tab, ctl) +# define GetParamBlock2Controller(pb, id) pb->GetControllerByID(id) +# define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetControllerByID(id, tab, ctl) #endif // MAX_VERSION_MAJOR #if MAX_VERSION_MAJOR <= 11 // max 2009. Just a guess, really. 2010 doesn't need this function. -#define INIT_CUSTOM_CONTROLS(instance) InitCustomControls(instance) +# define INIT_CUSTOM_CONTROLS(instance) InitCustomControls(instance) #else -#define INIT_CUSTOM_CONTROLS(instance) +# define INIT_CUSTOM_CONTROLS(instance) #endif #if MAX_VERSION_MAJOR <= 10 // Max 2008 -#define GETNAME_RETURN_TYPE TCHAR* +# define GETNAME_RETURN_TYPE TCHAR* #else -#define GETNAME_RETURN_TYPE const TCHAR* +# define GETNAME_RETURN_TYPE const TCHAR* #endif +// Old versions of Max define this as an integer, not a Class_ID +#define XREFOBJ_COMPAT_CLASS_ID Class_ID(0x92aab38c, 0) + #endif // _PLASMA_MAXCOMPAT_H \ No newline at end of file diff --git a/Sources/Tools/MaxMain/Pch.h b/Sources/Tools/MaxMain/Pch.h index 31b44f0b..3ed12265 100644 --- a/Sources/Tools/MaxMain/Pch.h +++ b/Sources/Tools/MaxMain/Pch.h @@ -78,14 +78,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include -// PlasmaMax Stuff included everywhere -// Some of these files may pull in Max SDK headers, so put this below hsWindows.h! -#include "plMaxNode.h" -#include "plMaxNodeData.h" -#include "MaxComponent/plComponent.h" -#include "MaxComponent/plComponentReg.h" - // Misc Max SDK +#include #include #include #include @@ -93,7 +87,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include #include -#include +#include // above ISkin.h for Max 7 +#include #include #include #include @@ -101,6 +96,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +// PlasmaMax Stuff included everywhere +// Some of these files may pull in Max SDK headers, so put this below hsWindows.h! +#include "plMaxNode.h" +#include "plMaxNodeData.h" +#include "MaxComponent/plComponent.h" +#include "MaxComponent/plComponentReg.h" + // Utility #include "MaxCompat.h" #include "resource.h" diff --git a/Sources/Tools/MaxMain/plComponentDlg.h b/Sources/Tools/MaxMain/plComponentDlg.h index 8bdd5f21..1b2862e9 100644 --- a/Sources/Tools/MaxMain/plComponentDlg.h +++ b/Sources/Tools/MaxMain/plComponentDlg.h @@ -43,7 +43,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com class Class_ID; class Interface; class plMaxNode; -struct NotifyInfo; + +#include +#if MAX_VERSION_MAJOR >= 9 + struct NotifyInfo; +#else + // Max headers are more minimalistic in pre-9 maxes +# include +#endif class plComponentDlg { diff --git a/Sources/Tools/MaxMain/plMaxNodeBase.cpp b/Sources/Tools/MaxMain/plMaxNodeBase.cpp index 408b4d12..7c07917c 100644 --- a/Sources/Tools/MaxMain/plMaxNodeBase.cpp +++ b/Sources/Tools/MaxMain/plMaxNodeBase.cpp @@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plMaxNodeBase.h" #include "plMaxNodeData.h" #include "MaxComponent/plComponentBase.h" +#include "MaxCompat.h" #include #include @@ -483,7 +484,7 @@ bool plMaxNodeBase::IsXRef() { // Is this an XRef'd object? Object *obj = GetObjectRef(); - if (obj->SuperClassID() == SYSTEM_CLASS_ID && obj->ClassID() == XREFOBJ_CLASS_ID) + if (obj->SuperClassID() == SYSTEM_CLASS_ID && obj->ClassID() == XREFOBJ_COMPAT_CLASS_ID) return true; // diff --git a/Sources/Tools/MaxPlasmaLights/Pch.h b/Sources/Tools/MaxPlasmaLights/Pch.h index 62fb1039..21f6dd0b 100644 --- a/Sources/Tools/MaxPlasmaLights/Pch.h +++ b/Sources/Tools/MaxPlasmaLights/Pch.h @@ -54,14 +54,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Windows #include "hsWindows.h" -// Base MaxPlasmaLights stuff... -#include "plRealTimeLightBase.h" -#include "plRealTimeLights.h" - // Max SDK +#include #include #include +// Base MaxPlasmaLights stuff... +#include "plRealTimeLightBase.h" +#include "plRealTimeLights.h" + // Utility #include "MaxMain/MaxCompat.h" #include "resource.h" diff --git a/Sources/Tools/MaxPlasmaLights/plRTProjDirLight.h b/Sources/Tools/MaxPlasmaLights/plRTProjDirLight.h index a84ae4e6..1bcd99e3 100644 --- a/Sources/Tools/MaxPlasmaLights/plRTProjDirLight.h +++ b/Sources/Tools/MaxPlasmaLights/plRTProjDirLight.h @@ -56,7 +56,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com class Class_ID; class IParamBlock2; -struct PB2Value; class ReferenceMaker; diff --git a/Sources/Tools/MaxPlasmaMtls/Pch.h b/Sources/Tools/MaxPlasmaMtls/Pch.h index 58990f75..d9ff94af 100644 --- a/Sources/Tools/MaxPlasmaMtls/Pch.h +++ b/Sources/Tools/MaxPlasmaMtls/Pch.h @@ -59,15 +59,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include -// MaxMain -#include "MaxMain/plMaxNode.h" -#include "MaxMain/MaxCompat.h" - // Misc 3dsm SDK +#include #include #include #include -#include #include #include #include @@ -75,6 +71,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +// MaxMain +#include "MaxMain/plMaxNode.h" +#include "MaxMain/MaxCompat.h" + // Local #include "resource.h" From dcacfc866581868317364554883fd8c24f150ed6 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Jan 2013 23:21:13 -0500 Subject: [PATCH 7/8] Fix export of Emote Anims Bug in the registry key list refactor... We wrote out all the keys in the key list instead of only the keys with objects. This meant we got a lot of garbage (empty) objects when exporting [Fem|M]aleWave. --- .../PubUtilLib/plResMgr/plRegistryKeyList.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp index 6c99b06f..2daca544 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp @@ -217,15 +217,27 @@ void plRegistryKeyList::Write(hsStream* s) s->WriteLE32(0); s->WriteByte(0); // Deprecated flags - s->WriteLE32(fKeys.size()); + // We only write out keys with data. Fill this value in later... + uint32_t countPos = s->GetPosition(); + s->WriteLE32(0); - // Write out all our keys + // Write out all our keys with data + uint32_t keyCount = 0; for (auto it = fKeys.begin(); it != fKeys.end(); ++it) - (*it)->Write(s); + { + plKeyImp* key = *it; + if (key->ObjectIsLoaded()) + { + ++keyCount; + key->Write(s); + } + } - // Go back to the start and write the length of our data + // Rewind and write out data size and key count uint32_t endPos = s->GetPosition(); s->SetPosition(beginPos); s->WriteLE32(endPos-beginPos-sizeof(uint32_t)); + s->SetPosition(countPos); + s->WriteLE32(keyCount); s->SetPosition(endPos); } From ece2b3d4405e0dd7489ec1f845f1760147c8fac5 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Jan 2013 23:23:01 -0500 Subject: [PATCH 8/8] Just enough plFileName to make things interesting. Fixes botched export paths --- Sources/Tools/MaxExport/SimpleExport.cpp | 28 +++++------------------- Sources/Tools/MaxExport/plExportDlg.cpp | 10 ++++----- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/Sources/Tools/MaxExport/SimpleExport.cpp b/Sources/Tools/MaxExport/SimpleExport.cpp index 8af0793e..97eb124a 100644 --- a/Sources/Tools/MaxExport/SimpleExport.cpp +++ b/Sources/Tools/MaxExport/SimpleExport.cpp @@ -192,24 +192,6 @@ void HSExport2::ShowAbout(HWND hWnd) { } -void IGetPath(const char* name, char* path) -{ - int i; - // find the last backslash in the full path - for ( i=strlen(name)-1; i>=0 ; i-- ) - { - if ( name[i] == '\\' ) - break; - } - if ( i >= 0 && i < 256) // if either we couldn't the backslash or the path was too big - { - strncpy(path,name,i+1); - path[i+1] = '\0'; //null terminate string (cause strncpy might not) - } - else - path[0] = '\0'; // otherwise just make it a null string -} - // Another little helper class to help write out a list of textures to a log file class plTextureLoggerCBack : public plRegistryKeyIterator { @@ -269,10 +251,10 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s BroadcastNotification(NOTIFY_PRE_EXPORT); // get just the path (not the file) of where we are going to export to - char out_path[256]; - IGetPath(name, out_path); + plFileName out_path = plFileName(name).StripFileName(); + // Apparently this was implied by the open dialog, but not if you call Max's ExportToFile() func - SetCurrentDirectory(out_path); + SetCurrentDirectoryW(out_path.AsString().ToWchar()); // // Setup ErrorMsg @@ -286,7 +268,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s if (dot) *dot = 0; char ErrorLogName[512]; - sprintf(ErrorLogName, "%s%s.err", out_path, fName); + sprintf(ErrorLogName, "%s%s.err", out_path.AsString().c_str(), fName); plExportLogErrorMsg logonly_errorMessage(ErrorLogName); // This errorMessage just writes it all to a file // now decide which errorMessage object to use @@ -341,7 +323,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s bool convertOK = plConvert::Instance().Convert(); // Free the material cache. This will delete unused materials. - hsMaterialConverter::Instance().FreeMaterialCache(out_path); + hsMaterialConverter::Instance().FreeMaterialCache(out_path.AsString().c_str()); if (convertOK) { diff --git a/Sources/Tools/MaxExport/plExportDlg.cpp b/Sources/Tools/MaxExport/plExportDlg.cpp index b3fa69d5..5af2fb0e 100644 --- a/Sources/Tools/MaxExport/plExportDlg.cpp +++ b/Sources/Tools/MaxExport/plExportDlg.cpp @@ -339,22 +339,22 @@ void plExportDlgImp::IDoExport() ShowWindow(fDlg, SW_HIDE); // Do the export - char exportPath[MAX_PATH]; - GetDlgItemText(fDlg, IDC_CLIENT_PATH, exportPath, sizeof(exportPath)); - strcat(exportPath, "Export.prd"); + wchar_t exportPathTEMP[MAX_PATH]; + GetDlgItemTextW(fDlg, IDC_CLIENT_PATH, exportPathTEMP, arrsize(exportPathTEMP)); + plFileName exportPath = plFileName::Join(plString::FromWchar(exportPathTEMP), "Export.prd"); // For export time stats DWORD exportTime = timeGetTime(); if (fExportFile) - IExportCurrentFile(exportPath); + IExportCurrentFile(exportPath.AsString().c_str()); else { std::vector sources = plFileSystem::ListDir(fExportSourceDir, "*.max"); for (auto iter = sources.begin(); iter != sources.end(); ++iter) { if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str())) - IExportCurrentFile(exportPath); + IExportCurrentFile(exportPath.AsString().c_str()); } }