diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp index 0367ebed..d80f89d1 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp @@ -164,26 +164,27 @@ bool plRegistryKeyList::SetKeyUnused(plKeyImp* key, LoadStatus& loadStatusChange } uint32_t id = key->GetUoid().GetObjectID(); - hsAssert(id <= fKeys.size(), "Bad static key id"); + plKeyImp* foundKey = nullptr; - // Fixed Keys will have id == 0. Let's just make sure we have it before we toss it. + // Fixed Keys use ID == 0 if (id == 0) - { hsAssert(key->GetUoid().GetLocation() == plLocation::kGlobalFixedLoc, "key id == 0 but not fixed?"); - if (!FindKey(key->GetName())) - { - hsAssert(false, "Couldn't find fixed key!"); - return false; - } + else if (id < fKeys.size()) { + if (fKeys[id]->GetUoid().GetObjectID() == id) + foundKey = fKeys[id]; } - else if (id > fKeys.size()) - return false; + + // Last chance: do a slow name search for that key. + if (!foundKey) + foundKey = FindKey(key->GetUoid().GetObjectName()); // Got that key, decrement the key counter - --fReffedKeys; - if (fReffedKeys == 0) - loadStatusChange = kTypeUnloaded; - return true; + if (foundKey) { + --fReffedKeys; + if (fReffedKeys == 0) + loadStatusChange = kTypeUnloaded; + } + return foundKey != nullptr; } void plRegistryKeyList::Read(hsStream* s) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp index 6d170b16..c723af06 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp @@ -1665,16 +1665,13 @@ void plResManager::IKeyReffed(plKeyImp* key) void plResManager::IKeyUnreffed(plKeyImp* key) { plRegistryPageNode* page = FindPage(key->GetUoid().GetLocation()); - if (page == nil) + if (!page) { hsAssert(0, "Couldn't find page that key belongs to"); return; } - bool removed = page->SetKeyUnused(key); - hsAssert(removed, "Key wasn't removed from page"); - - if (removed) + if (page->SetKeyUnused(key)) { if (!page->IsLoaded()) { diff --git a/Sources/Tools/MaxConvert/plLayerConverter.cpp b/Sources/Tools/MaxConvert/plLayerConverter.cpp index 0373606a..701a9c3d 100644 --- a/Sources/Tools/MaxConvert/plLayerConverter.cpp +++ b/Sources/Tools/MaxConvert/plLayerConverter.cpp @@ -1003,7 +1003,7 @@ plDynamicTextMap *plLayerConverter::ICreateDynTextMap( const plString &layerN // Need a unique key name for every layer that uses one. We could also key // off of width and height, but layerName should be more than plenty - plString texName = plString::Format( "%s_dynText", layerName ); + plString texName = plString::Format( "%s_dynText", layerName.c_str() ); // Does it already exist? key = node->FindPageKey( plDynamicTextMap::Index(), texName ); diff --git a/Sources/Tools/MaxMain/GlobalUtility.cpp b/Sources/Tools/MaxMain/GlobalUtility.cpp index 9ffd9176..f258a7a5 100644 --- a/Sources/Tools/MaxMain/GlobalUtility.cpp +++ b/Sources/Tools/MaxMain/GlobalUtility.cpp @@ -63,6 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plMaxCFGFile.h" #include "pfLocalizationMgr/pfLocalizationMgr.h" +#include "plGImage/plFontCache.h" extern plActionTableMgr theActionTableMgr; extern HINSTANCE hInstance; @@ -208,14 +209,6 @@ DWORD PlasmaMax::Start() SceneSync::Instance(); #endif - plComponentShow::Init(); - - plCreateMenu(); - - RegisterNotification(NotifyProc, 0, NOTIFY_FILE_POST_OPEN); - - RegisterNotification(NotifyProc, 0, NOTIFY_SYSTEM_STARTUP); - #ifdef MAXSCENEVIEWER_ENABLED InitMaxFileData(); #endif @@ -225,14 +218,26 @@ DWORD PlasmaMax::Start() plFileName pathTemp = plMaxConfig::GetClientPath(false, true); if (!pathTemp.IsValid()) { - hsMessageBox("PlasmaMAX2.ini is missing or invalid", "Plasma/2.0 Error", hsMessageBoxNormal); - } - else - { - plFileName clientPath = plFileName::Join(pathTemp, "dat"); - pfLocalizationMgr::Initialize(clientPath); + hsMessageBox("PlasmaMAX2.ini is missing or invalid.\nPlasmaMAX will be unavailable until this file is added.", + "PlasmaMAX2 Error", hsMessageBoxNormal, hsMessageBoxIconExclamation); + return GUPRESULT_NOKEEP; } + // Setup the doggone plugin + plComponentShow::Init(); + plCreateMenu(); + + RegisterNotification(NotifyProc, 0, NOTIFY_FILE_POST_OPEN); + RegisterNotification(NotifyProc, 0, NOTIFY_SYSTEM_STARTUP); + + // Now we have to init like we're a real doggone client... + plFileName clientPath = plFileName::Join(pathTemp, "dat"); + pfLocalizationMgr::Initialize(clientPath); + + // init font cache singleton + plFontCache* fonts = new plFontCache(); + fonts->LoadCustomFonts(clientPath); + return GUPRESULT_KEEP; } @@ -241,6 +246,7 @@ void PlasmaMax::Stop() UnRegisterNotification(NotifyProc, 0, NOTIFY_FILE_POST_OPEN); pfLocalizationMgr::Shutdown(); + plFontCache::GetInstance().UnRegisterAs(kFontCache_KEY); PythonInterface::WeAreInShutdown(); PythonInterface::finiPython(); diff --git a/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.cpp b/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.cpp index a173087c..797715e8 100644 --- a/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.cpp @@ -186,7 +186,7 @@ BOOL plLayerTex::SetDlgThing(ParamDlg* dlg) int plLayerTex::NumRefs() { - return 2; + return 3; } //From ReferenceMaker @@ -223,15 +223,19 @@ void plLayerTex::SetReference(int i, RefTargetHandle rtarg) int plLayerTex::NumParamBlocks() { - return 1; + return 2; } IParamBlock2* plLayerTex::GetParamBlock(int i) { switch (i) { - case 0: return fBitmapPB; - default: return NULL; + case kRefBasic: + // So this was something... a long time ago. It probably doesn't exist anymore. + // We'll pretend it's a bitmap to keep everyone happy. + case kRefBitmap: + return fBitmapPB; + default: return nullptr; } } @@ -256,7 +260,7 @@ RefTargetHandle plLayerTex::Clone(RemapDir &remap) int plLayerTex::NumSubs() { - return 2; + return 3; } Animatable* plLayerTex::SubAnim(int i) diff --git a/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.h b/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.h index ce5a8bf5..7361e3a9 100644 --- a/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.h +++ b/Sources/Tools/MaxPlasmaMtls/Layers/plLayerTex.h @@ -76,12 +76,14 @@ public: enum { kRefUVGen, + kRefBasic, // DEAD, but left in so we don't die. kRefBitmap, }; // Block ID's enum { + kBlkBasic, kBlkBitmap, }; diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp index fca882e5..5950a892 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp @@ -410,10 +410,7 @@ RefTargetHandle plPassMtlBase::GetReference( int i ) { if( i >= kRefNotetracks && i < kRefNotetracks + fNotetracks.GetCount() ) return fNotetracks[ i - kRefNotetracks ]; - else - hsAssert(false, "shit"); - - return nil; + return nullptr; } //// SetReference ////////////////////////////////////////////////////////////