From 4dd06d1e7ea1f39028ef604b6d688c8ffa91a942 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 5 Jan 2013 20:21:33 -0800 Subject: [PATCH 1/5] Convert plRegistryNode stuff to plString. --- Sources/Plasma/Apps/plClient/plClient.cpp | 4 +- Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp | 4 +- .../FeatureLib/pfConsole/pfConsoleDirSrc.h | 1 + .../FeatureLib/pfConsole/pfDispatchLog.cpp | 2 +- .../PubUtilLib/plAgeLoader/plAgeLoader.cpp | 4 +- .../plNetClient/plNetClientGroup.cpp | 4 +- .../PubUtilLib/plNetClient/plNetClientMgr.cpp | 2 +- .../Plasma/PubUtilLib/plResMgr/CMakeLists.txt | 9 +++- .../PubUtilLib/plResMgr/plKeyFinder.cpp | 9 ++-- .../Plasma/PubUtilLib/plResMgr/plPageInfo.cpp | 12 ++---- .../Plasma/PubUtilLib/plResMgr/plPageInfo.h | 18 ++++---- .../PubUtilLib/plResMgr/plRegistryNode.cpp | 36 ++++++++-------- .../PubUtilLib/plResMgr/plRegistryNode.h | 9 ++-- .../PubUtilLib/plResMgr/plResManager.cpp | 41 +++++++++---------- .../Plasma/PubUtilLib/plResMgr/plResManager.h | 4 +- .../plResMgr/plResManagerHelper.cpp | 21 +++++----- .../Tools/MaxComponent/plMiscComponents.cpp | 4 +- Sources/Tools/MaxConvert/plLightMapGen.cpp | 4 +- Sources/Tools/MaxMain/plPluginResManager.cpp | 24 +++++------ Sources/Tools/MaxMain/plPluginResManager.h | 11 ++--- Sources/Tools/plResBrowser/plResTreeView.cpp | 6 +-- 21 files changed, 114 insertions(+), 115 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 05c2b428..b0e895d5 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1006,9 +1006,9 @@ void plClient::IQueueRoomLoad(const std::vector& locs, bool hold) if (!info) hsStatusMessageF("Ignoring LoadRoom request for location 0x%x because we can't find the location", loc.GetSequenceNumber()); else if (alreadyLoaded) - hsStatusMessageF("Ignoring LoadRoom request for %s-%s, since room is already loaded", info->GetAge(), info->GetPage()); + hsStatusMessageF("Ignoring LoadRoom request for %s-%s, since room is already loaded", info->GetAge().c_str(), info->GetPage().c_str()); else if (isLoading) - hsStatusMessageF("Ignoring LoadRoom request for %s-%s, since room is currently loading", info->GetAge(), info->GetPage()); + hsStatusMessageF("Ignoring LoadRoom request for %s-%s, since room is currently loading", info->GetAge().c_str(), info->GetPage().c_str()); #endif continue; diff --git a/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp b/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp index 0ec17dc2..34ef6d07 100644 --- a/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp +++ b/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp @@ -95,7 +95,7 @@ int PrintHelp( void ) int main(int argc, char* argv[]) { - if (argc >= 1 && strcmp(argv[1], "-v") == 0) + if (argc >= 2 && strcmp(argv[1], "-v") == 0) { PrintVersion(); return 0; @@ -249,7 +249,7 @@ public: const plPageInfo& info = page->GetPageInfo(); char fileName[256]; - sprintf(fileName, "%s%s_%s.csv", fOutputDir, info.GetAge(), info.GetPage()); + sprintf(fileName, "%s%s_%s.csv", fOutputDir, info.GetAge().c_str(), info.GetPage().c_str()); fStream.Open(fileName, "wt"); page->LoadKeys(); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h index b245f463..4b968ab0 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h @@ -57,6 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "HeadSpin.h" #include +#include #include "pfConsoleCore/pfConsoleEngine.h" diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp index 96521fbd..ffc5cf29 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp @@ -298,7 +298,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info) const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc); if (pageInfo) - info += plString::Format("%s-%s ", pageInfo->GetAge(), pageInfo->GetPage()); + info += plString::Format("%s-%s ", pageInfo->GetAge().c_str(), pageInfo->GetPage().c_str()); } } break; diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp index 29815160..06df966d 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp @@ -337,7 +337,7 @@ class plUnloadAgeCollector : public plRegistryPageIterator virtual bool EatPage( plRegistryPageNode *page ) { - if( fAge && stricmp( page->GetPageInfo().GetAge(), fAge ) == 0 ) + if( fAge && page->GetPageInfo().GetAge().CompareI(fAge) == 0 ) { fPages.Append( page ); } @@ -382,7 +382,7 @@ bool plAgeLoader::IUnloadAge() plKey roomKey = plKeyFinder::Instance().FindSceneNodeKey( page->GetPageInfo().GetLocation() ); if( roomKey != nil && roomKey->ObjectIsLoaded() ) { - nc->DebugMsg( "\tPaging out room %s\n", page->GetPageInfo().GetPage() ); + nc->DebugMsg( "\tPaging out room %s\n", page->GetPageInfo().GetPage().c_str() ); newPageOuts.push_back(roomKey); } } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientGroup.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientGroup.cpp index dc8d5815..9e31fc54 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientGroup.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientGroup.cpp @@ -66,6 +66,6 @@ void plNetClientGroups::ISetGroupDesc(plNetGroupId& grpId) else { const plPageInfo* pageInfo=plKeyFinder::Instance().GetLocationInfo(grpId.Room()); - grpId.SetDesc(pageInfo->GetPage()); + grpId.SetDesc(pageInfo->GetPage().c_str()); } -} \ No newline at end of file +} diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 4d0d66b1..3fb23b59 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -1237,7 +1237,7 @@ bool plNetClientMgr::ObjectInLocalAge(const plSynchedObject* obj) const { plLocation loc = obj->GetKey()->GetUoid().GetLocation(); const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc); - bool ret= IsLocalAge(pageInfo->GetAge()); + bool ret= IsLocalAge(pageInfo->GetAge().c_str()); return ret; } diff --git a/Sources/Plasma/PubUtilLib/plResMgr/CMakeLists.txt b/Sources/Plasma/PubUtilLib/plResMgr/CMakeLists.txt index 54b59dee..0760b92d 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/CMakeLists.txt +++ b/Sources/Plasma/PubUtilLib/plResMgr/CMakeLists.txt @@ -34,7 +34,14 @@ set(plResMgr_HEADERS ) add_library(plResMgr STATIC ${plResMgr_SOURCES} ${plResMgr_HEADERS}) -target_link_libraries(plResMgr CoreLib pnDispatch pnFactory pnKeyedObject pnMessage pnTimer plFile plStatusLog) +target_link_libraries(plResMgr CoreLib) +target_link_libraries(plResMgr pnDispatch) +target_link_libraries(plResMgr pnFactory) +target_link_libraries(plResMgr pnKeyedObject) +target_link_libraries(plResMgr pnMessage) +target_link_libraries(plResMgr pnTimer) +target_link_libraries(plResMgr plFile) +target_link_libraries(plResMgr plStatusLog) source_group("Source Files" FILES ${plResMgr_SOURCES}) source_group("Header Files" FILES ${plResMgr_HEADERS}) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp index 1204b3fe..08748969 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp @@ -159,7 +159,7 @@ public: try { #endif - if( stricmp( pageNode->GetPageInfo().GetAge(), fAgeName ) == 0 ) + if (pageNode->GetPageInfo().GetAge().CompareI(fAgeName) == 0) { // Try loading and searching thru this page hsTArray keyRefs; @@ -353,8 +353,7 @@ class plPageFinder : public plRegistryPageIterator // Are we searching by age/page? if( fAgeString != nil ) { - if( stricmp( info.GetAge(), fAgeString ) == 0 && - stricmp( info.GetPage(), fFindString ) == 0 ) + if (info.GetAge().CompareI(fAgeString) == 0 && info.GetPage().CompareI(fFindString) == 0) { *fPagePtr = node; return false; @@ -363,14 +362,14 @@ class plPageFinder : public plRegistryPageIterator } // Try for page only - if( stricmp( info.GetPage(), fFindString ) == 0 ) + if (info.GetPage().CompareI(fFindString) == 0) { *fPagePtr = node; return false; } // Try for full location - sprintf( str, "%s_%s", info.GetAge(), info.GetPage() ); + sprintf( str, "%s_%s", info.GetAge().c_str(), info.GetPage().c_str() ); if( stricmp( str, fFindString ) == 0 ) { *fPagePtr = node; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp index fb95245e..a7a15db7 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp @@ -98,13 +98,10 @@ void plPageInfo::ISetFrom( const plPageInfo &src ) fIndexStart = src.fIndexStart; } -void plPageInfo::SetStrings( const char *age, const char *page ) +void plPageInfo::SetStrings(const plString& age, const plString& page) { - delete [] fAge; - delete [] fPage; - - fAge = ( age == nil ) ? nil : hsStrcpy( age ); - fPage = ( page == nil ) ? nil : hsStrcpy( page ); + fAge = age; + fPage = page; } void plPageInfo::SetLocation( const plLocation &loc ) @@ -122,9 +119,6 @@ void plPageInfo::AddClassVersion(uint16_t classIdx, uint16_t version) void plPageInfo::Read( hsStream *s ) { - delete [] fAge; - delete [] fPage; - IInit(); // 5 is the earliest version since we began working again on the P20 codebase in Sep 2005, diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.h b/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.h index 0c1ccb41..b3798c17 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.h @@ -53,6 +53,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com class hsStream; class plLocation; +class plString; + class plPageInfo { public: @@ -61,12 +63,12 @@ public: protected: plLocation fLocation; - char* fAge; - char* fPage; - uint16_t fMajorVersion; + plString fAge; + plString fPage; + uint16_t fMajorVersion; ClassVerVec fClassVersions; - uint32_t fChecksum; - uint32_t fDataStart, fIndexStart; + uint32_t fChecksum; + uint32_t fDataStart, fIndexStart; void IInit( void ); void ISetFrom( const plPageInfo &src ); @@ -78,8 +80,8 @@ public: plPageInfo( const plPageInfo &src ); virtual ~plPageInfo(); - const char* GetAge() const { return fAge; } - const char* GetPage() const { return fPage; } + const plString& GetAge() const { return fAge; } + const plString& GetPage() const { return fPage; } plPageInfo &operator=( const plPageInfo &src ); @@ -87,7 +89,7 @@ public: void AddClassVersion(uint16_t classIdx, uint16_t version); const ClassVerVec& GetClassVersions() const { return fClassVersions; } - void SetStrings( const char *age, const char *page ); + void SetStrings(const plString& age, const plString& page); void SetLocation(const plLocation& loc); const plLocation& GetLocation() const { return fLocation; } diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp index 21136278..42717e55 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp @@ -43,23 +43,23 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plRegistryKeyList.h" #include "plRegistryHelpers.h" +#include "plString.h" #include "pnKeyedObject/plKeyImp.h" #include "plStatusLog/plStatusLog.h" #include "pnFactory/plFactory.h" +#include "plFile/hsFiles.h" #include "plFile/plFileUtils.h" #include "plVersion.h" -plRegistryPageNode::plRegistryPageNode(const char* path) +plRegistryPageNode::plRegistryPageNode(const plString& path) : fValid(kPageCorrupt) - , fPath(nil) + , fPath(path) , fDynLoadedTypes(0) , fStaticLoadedTypes(0) , fOpenRequests(0) , fIsNewPage(false) { - fPath = hsStrcpy(path); - hsStream* stream = OpenStream(); if (stream) { @@ -69,7 +69,7 @@ plRegistryPageNode::plRegistryPageNode(const char* path) } } -plRegistryPageNode::plRegistryPageNode(const plLocation& location, const char* age, const char* page, const char* dataPath) +plRegistryPageNode::plRegistryPageNode(const plLocation& location, const plString& age, const plString& page, const plString& dataPath) : fValid(kPageOk) , fPath(nil) , fPageInfo(location) @@ -80,25 +80,21 @@ plRegistryPageNode::plRegistryPageNode(const plLocation& location, const char* a { fPageInfo.SetStrings(age, page); - char filePath[512]; - - // Copy the path over - strncpy(filePath, dataPath, sizeof(filePath)); - plFileUtils::AddSlash(filePath); + plString path = dataPath; + path += PATH_SEPARATOR_STR; // Time to construct our actual file name. For now, we'll use the same old format // of age_page.extension - strncat(filePath, fPageInfo.GetAge(), sizeof(filePath)); - strncat(filePath, "_District_", sizeof(filePath)); - strncat(filePath, fPageInfo.GetPage(), sizeof(filePath)); - strncat(filePath, ".prp", sizeof(filePath)); + path += fPageInfo.GetAge(); + path += "_District_"; + path += fPageInfo.GetPage(); + path += ".prp"; - fPath = hsStrcpy(filePath); + fPath = path; } plRegistryPageNode::~plRegistryPageNode() { - delete [] fPath; UnloadKeys(); } @@ -141,7 +137,7 @@ hsStream* plRegistryPageNode::OpenStream() { if (fOpenRequests == 0) { - if (!fStream.Open(fPath, "rb")) + if (!fStream.Open(fPath.c_str(), "rb")) return nil; } fOpenRequests++; @@ -168,7 +164,7 @@ void plRegistryPageNode::LoadKeys() if (!stream) { hsAssert(0, plString::Format("plRegistryPageNode::LoadKeysFromSource - bad stream %s,%s", - GetPageInfo().GetAge(), GetPageInfo().GetPage()).c_str()); + GetPageInfo().GetAge().c_str(), GetPageInfo().GetPage().c_str()).c_str()); return; } @@ -232,7 +228,7 @@ void plRegistryPageNode::Write() { hsAssert(fOpenRequests == 0, "Trying to write while the page is open for reading"); - if (!fStream.Open(fPath, "wb")) + if (!fStream.Open(fPath.c_str(), "wb")) { hsAssert(0, "Couldn't open file for writing"); return; @@ -412,6 +408,6 @@ plRegistryKeyList* plRegistryPageNode::IGetKeyList(uint16_t classType) const void plRegistryPageNode::DeleteSource() { hsAssert(fOpenRequests == 0, "Deleting a stream that's open for reading"); - plFileUtils::RemoveFile(fPath); + plFileUtils::RemoveFile(fPath.c_str()); } diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h index b3674b7f..917adbc9 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h @@ -52,6 +52,7 @@ class plRegistryKeyList; class hsStream; class plKeyImp; class plRegistryKeyIterator; +class plString; enum PageCond { @@ -77,7 +78,7 @@ protected: int fStaticLoadedTypes; // The number of key types that have all their keys loaded PageCond fValid; // Condition of the page - char* fPath; // Path to the page file + plString fPath; // Path to the page file plPageInfo fPageInfo; // Info about this page hsBufferedStream fStream; // Stream for reading/writing our page @@ -92,10 +93,10 @@ protected: public: // For reading a page off disk - plRegistryPageNode(const char* path); + plRegistryPageNode(const plString& path); // For creating a new page. - plRegistryPageNode(const plLocation& location, const char* age, const char* page, const char* dataPath); + plRegistryPageNode(const plLocation& location, const plString& age, const plString& page, const plString& dataPath); ~plRegistryPageNode(); bool IsValid() const { return fValid == kPageOk; } @@ -142,7 +143,7 @@ public: void Write(); void DeleteSource(); - const char* GetPagePath() const { return fPath; } + const plString& GetPagePath() const { return fPath; } }; #endif // plRegistryNode_h_inc diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp index ad7205fd..37552374 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp @@ -243,7 +243,7 @@ plRegistryPageNode* plResManager::FindSinglePage(const char* path) const PageMap::const_iterator it; for (it = fAllPages.begin(); it != fAllPages.end(); it++) { - if (stricmp((it->second)->GetPagePath(), path) == 0) + if ((it->second)->GetPagePath().CompareI(path) == 0) return it->second; } @@ -626,9 +626,9 @@ void plResManager::GetLocationStrings(const plLocation& loc, char* ageBuffer, ch // Those buffers better be big enough... if (ageBuffer) - hsStrcpy(ageBuffer, info.GetAge()); + hsStrcpy(ageBuffer, info.GetAge().c_str()); if (pageBuffer) - hsStrcpy(pageBuffer, info.GetPage()); + hsStrcpy(pageBuffer, info.GetPage().c_str()); } bool plResManager::AddViaNotify(plRefMsg* msg, plRefFlags::Type flags) @@ -1041,7 +1041,7 @@ public: virtual bool EatPage(plRegistryPageNode* page) { - if (stricmp(page->GetPageInfo().GetAge(), fAgeName) == 0) + if (page->GetPageInfo().GetAge().CompareI(fAgeName) == 0) { fResMgr->LoadPageKeys(page); plKeyCollector collector(fKeys); @@ -1176,25 +1176,25 @@ void plResManager::PageInRoom(const plLocation& page, uint16_t objClassToRef, pl return; } - kResMgrLog(2, ILog(2, "...Found, page is ID'd as %s>%s", pageNode->GetPageInfo().GetAge(), pageNode->GetPageInfo().GetPage())); + kResMgrLog(2, ILog(2, "...Found, page is ID'd as %s>%s", pageNode->GetPageInfo().GetAge().c_str(), pageNode->GetPageInfo().GetPage().c_str())); // Step 0.5: Verify the page, just to make sure we really should be loading it PageCond cond = pageNode->GetPageCondition(); if (cond != kPageOk) { - std::string condStr ="Checksum invalid"; - if (cond == kPageTooNew) + plString condStr = "Checksum invalid"; + if (cond == kPageTooNew) { condStr = "Page Version too new"; - else - if (cond == kPageOutOfDate) + } else if (cond == kPageOutOfDate) { condStr = "Page Version out of date"; - + } + kResMgrLog(1, ILog(1, "...IGNORING pageIn request; verification failed! (%s)", condStr.c_str())); plString msg = plString::Format("Data Problem: Age:%s Page:%s Error:%s", - pageNode->GetPageInfo().GetAge(), pageNode->GetPageInfo().GetPage(), condStr.c_str()); + pageNode->GetPageInfo().GetAge().c_str(), pageNode->GetPageInfo().GetPage().c_str(), condStr.c_str()); hsMessageBox(msg.c_str(), "Error", hsMessageBoxNormal, hsMessageBoxIconError); - + hsRefCnt_SafeUnRef(refMsg); return; } @@ -1250,7 +1250,7 @@ void plResManager::PageInRoom(const plLocation& page, uint16_t objClassToRef, pl readRoomTime = hsTimer::GetFullTickCount() - readRoomTime; plStatusLog::AddLineS("readtimings.log", plStatusLog::kWhite, "----- Reading page %s>%s took %.1f ms", - pageNode->GetPageInfo().GetAge(), pageNode->GetPageInfo().GetPage(), + pageNode->GetPageInfo().GetAge().c_str(), pageNode->GetPageInfo().GetPage().c_str(), hsTimer::FullTicksToMs(readRoomTime)); } } @@ -1275,7 +1275,7 @@ public: } virtual bool EatPage(plRegistryPageNode* page) { - if (stricmp(page->GetPageInfo().GetAge(), fAgeName) == 0) + if (page->GetPageInfo().GetAge().CompareI(fAgeName) == 0) { plUoid uoid(page->GetPageInfo().GetLocation(), 0, ""); fLocations.push_back(uoid.GetLocation()); @@ -1406,7 +1406,7 @@ static void ICatPageNames(hsTArray& pages, char* buf, int b break; } - const char* pagePath = pages[i]->GetPagePath(); + const char* pagePath = pages[i]->GetPagePath().c_str(); const char* pageFile = plFileUtils::GetFileName(pagePath); if (strlen(buf) + strlen(pageFile) > bufSize - 5) @@ -1578,7 +1578,7 @@ static void sIReportLeak(plKeyImp* key, plRegistryPageNode* page) if (!alreadyDone) { // Print out page header - hsStatusMessageF(" Leaks in page %s>%s[%08x]:\n", lastPage->GetPageInfo().GetAge(), lastPage->GetPageInfo().GetPage(), lastPage->GetPageInfo().GetLocation().GetSequenceNumber()); + hsStatusMessageF(" Leaks in page %s>%s[%08x]:\n", lastPage->GetPageInfo().GetAge().c_str(), lastPage->GetPageInfo().GetPage().c_str(), lastPage->GetPageInfo().GetLocation().GetSequenceNumber()); alreadyDone = true; } @@ -1650,14 +1650,13 @@ plRegistryPageNode* plResManager::FindPage(const plLocation& location) const //// FindPage //////////////////////////////////////////////////////////////// -plRegistryPageNode* plResManager::FindPage(const char* age, const char* page) const +plRegistryPageNode* plResManager::FindPage(const plString& age, const plString& page) const { PageMap::const_iterator it; for (it = fAllPages.begin(); it != fAllPages.end(); ++it) { const plPageInfo& info = (it->second)->GetPageInfo(); - if (stricmp(info.GetAge(), age) == 0 && - stricmp(info.GetPage(), page) == 0) + if (info.GetAge().CompareI(age) == 0 && info.GetPage().CompareI(page) == 0) return it->second; } @@ -1760,7 +1759,7 @@ bool plResManager::IterateKeys(plRegistryKeyIterator* iterator, const plLocation //// IteratePages //////////////////////////////////////////////////////////// // Iterate through all LOADED pages -bool plResManager::IteratePages(plRegistryPageIterator* iterator, const char* ageToRestrictTo) +bool plResManager::IteratePages(plRegistryPageIterator* iterator, const plString& ageToRestrictTo) { ILockPages(); @@ -1771,7 +1770,7 @@ bool plResManager::IteratePages(plRegistryPageIterator* iterator, const char* ag if (page->GetPageInfo().GetLocation() == plLocation::kGlobalFixedLoc) continue; - if (!ageToRestrictTo || stricmp(page->GetPageInfo().GetAge(), ageToRestrictTo) == 0) + if (!ageToRestrictTo.IsNull() || page->GetPageInfo().GetAge().CompareI(ageToRestrictTo) == 0) { if (!iterator->EatPage(page)) { diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h index 9d77f4ec..8209b777 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h @@ -155,7 +155,7 @@ public: // Single page version bool IterateKeys(plRegistryKeyIterator* iterator, const plLocation& pageToRestrictTo); // Iterate through loaded pages - bool IteratePages(plRegistryPageIterator* iterator, const char* ageToRestrictTo = nil); + bool IteratePages(plRegistryPageIterator* iterator, const plString& ageToRestrictTo = nil); // Iterate through ALL pages, loaded or not bool IterateAllPages(plRegistryPageIterator* iterator); @@ -164,7 +164,7 @@ public: void UnloadPageObjects(plRegistryPageNode* pageNode, uint16_t classIndexHint); void DumpUnusedKeys(plRegistryPageNode* page) const; plRegistryPageNode* FindPage(const plLocation& location) const; - plRegistryPageNode* FindPage(const char* age, const char* page) const; + plRegistryPageNode* FindPage(const plString& age, const plString& page) const; // Runs through all the pages and verifies that the data versions are good bool VerifyPages(); diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManagerHelper.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManagerHelper.cpp index 74f592f2..24e30e98 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManagerHelper.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManagerHelper.cpp @@ -183,10 +183,10 @@ void plResManagerHelper::LoadAndHoldPageKeys( plRegistryPageNode *page ) // Load and ref the keys #ifdef HS_DEBUGGING char msg[ 256 ]; - sprintf( msg, "*** Temporarily loading keys for room %s>%s based on FindKey() query, will drop in 1 sec ***", page->GetPageInfo().GetAge(), page->GetPageInfo().GetPage() ); + sprintf( msg, "*** Temporarily loading keys for room %s>%s based on FindKey() query, will drop in 1 sec ***", page->GetPageInfo().GetAge().c_str(), page->GetPageInfo().GetPage().c_str()); hsStatusMessage( msg ); #endif - kResMgrLog( 2 ) 0xff80ff80, "Temporarily loading keys for room %s>%s, will drop in 1 sec", page->GetPageInfo().GetAge(), page->GetPageInfo().GetPage() ); + kResMgrLog( 2 ) 0xff80ff80, "Temporarily loading keys for room %s>%s, will drop in 1 sec", page->GetPageInfo().GetAge().c_str(), page->GetPageInfo().GetPage().c_str()); // Deliver the message to ourselves! refferMsg->SetTimeStamp( hsTimer::GetSysSeconds() + 1.f ); @@ -359,7 +359,7 @@ class plDebugPrintIterator : public plRegistryPageIterator, plRegistryKeyIterato fHoldingCount++; // Changed ages? - if( page == nil || strcmp( fCurrAge, page->GetPageInfo().GetAge() ) != 0 ) + if( page == nil || page->GetPageInfo().GetAge() != fCurrAge ) { // Print some info for the last age we were on if( fCurrAge[ 0 ] != 0 ) @@ -385,7 +385,7 @@ class plDebugPrintIterator : public plRegistryPageIterator, plRegistryKeyIterato } fPageCount = 0; if( page != nil ) - strncpy( fCurrAge, page->GetPageInfo().GetAge(), sizeof( fCurrAge ) - 1 ); + strncpy( fCurrAge, page->GetPageInfo().GetAge().c_str(), sizeof( fCurrAge ) - 1 ); else fCurrAge[ 0 ] = 0; @@ -417,9 +417,9 @@ class plDebugPrintIterator : public plRegistryPageIterator, plRegistryKeyIterato if( fLines < kLogSize - 4 ) { if( fParent->fDebugDisplayType == plResManagerHelper::kSizes ) - fLog->AddLineF( plStatusLog::kWhite, " %s (%d keys @ %4.1fk, %d loaded @ %4.1fk)", page->GetPageInfo().GetPage(), fTotalKeys, fTotalSize / 1024.f, fLoadedKeys, fLoadedSize / 1024.f ); + fLog->AddLineF( plStatusLog::kWhite, " %s (%d keys @ %4.1fk, %d loaded @ %4.1fk)", page->GetPageInfo().GetPage().c_str(), fTotalKeys, fTotalSize / 1024.f, fLoadedKeys, fLoadedSize / 1024.f ); else if( fParent->fDebugDisplayType == plResManagerHelper::kPercents ) - fLog->AddLineF( plStatusLog::kWhite, " %s (%d%% loaded of %d keys @ %4.1fk)", page->GetPageInfo().GetPage(), fLoadedSize * 100 / ( fTotalSize > 0 ? fTotalSize : -1 ), fTotalKeys, fTotalSize / 1024.f ); + fLog->AddLineF( plStatusLog::kWhite, " %s (%d%% loaded of %d keys @ %4.1fk)", page->GetPageInfo().GetPage().c_str(), fLoadedSize * 100 / ( fTotalSize > 0 ? fTotalSize : -1 ), fTotalKeys, fTotalSize / 1024.f ); else //if( fParent->fDebugDisplayType == plResManagerHelper::kBars ) { const int startPos = 20, length = 32; @@ -427,10 +427,10 @@ class plDebugPrintIterator : public plRegistryPageIterator, plRegistryKeyIterato char line[ 128 ]; memset( line, ' ', sizeof( line ) - 1 ); line[ 127 ] = 0; - if( strlen( page->GetPageInfo().GetPage() ) < startPos - 2 ) - memcpy( line + 2, page->GetPageInfo().GetPage(), strlen( page->GetPageInfo().GetPage() ) ); + if(page->GetPageInfo().GetPage().GetSize() < startPos - 2 ) + memcpy( line + 2, page->GetPageInfo().GetPage().c_str(), page->GetPageInfo().GetPage().GetSize() ); else - memcpy( line + 2, page->GetPageInfo().GetPage(), startPos - 2 ); + memcpy( line + 2, page->GetPageInfo().GetPage().c_str(), startPos - 2 ); line[ startPos ] = '|'; if( fTotalSize == 0 ) @@ -490,13 +490,12 @@ void plResManagerHelper::IUpdateDebugScreen( bool force ) if( !fRefreshing ) return; - plRegistry *reg = fResManager->IGetRegistry(); uint32_t loadedCnt, holdingCnt; fDebugScreen->Clear(); plDebugPrintIterator iter( this, fDebugScreen, loadedCnt, holdingCnt ); - reg->IterateAllPages( &iter ); + fResManager->IterateAllPages( &iter ); iter.EatPage( nil ); // Force a final update fDebugScreen->AddLineF( plStatusLog::kGreen, "%d pages loaded, %d holding", loadedCnt, holdingCnt ); diff --git a/Sources/Tools/MaxComponent/plMiscComponents.cpp b/Sources/Tools/MaxComponent/plMiscComponents.cpp index 56aa71f8..afdbf340 100644 --- a/Sources/Tools/MaxComponent/plMiscComponents.cpp +++ b/Sources/Tools/MaxComponent/plMiscComponents.cpp @@ -472,7 +472,7 @@ bool plPageInfoComponent::SetupProperties(plMaxNode *pNode, plErrorMsg *pErrMsg) "for playing over the network or released for external use.\n\n" "\t(Original sequence #: 0x%X)\n\t(Temporary sequence #: 0x%X)", age, room, pNode->GetName(), - lastPage->GetAge(), lastPage->GetPage(), age, room, seqNum, newNum ); + lastPage->GetAge().c_str(), lastPage->GetPage().c_str(), age, room, seqNum, newNum ); } else if( plPluginResManager::ResMgr()->GetLastVerifyError() == plPluginResManager::kErrSeqAlreadyTaken ) { @@ -485,7 +485,7 @@ bool plPageInfoComponent::SetupProperties(plMaxNode *pNode, plErrorMsg *pErrMsg) "for playing over the network or released for external use.\n\n" "\t(Original sequence #: 0x%X)\n\t(Temporary sequence #: 0x%X)", age, room, pNode->GetName(), - lastPage->GetAge(), lastPage->GetPage(), age, room, seqNum, newNum ); + lastPage->GetAge().c_str(), lastPage->GetPage().c_str(), age, room, seqNum, newNum ); } else if( plPluginResManager::ResMgr()->GetLastVerifyError() == plPluginResManager::kErrCantFindValid ) { diff --git a/Sources/Tools/MaxConvert/plLightMapGen.cpp b/Sources/Tools/MaxConvert/plLightMapGen.cpp index 2adf7606..93867ec1 100644 --- a/Sources/Tools/MaxConvert/plLightMapGen.cpp +++ b/Sources/Tools/MaxConvert/plLightMapGen.cpp @@ -1293,7 +1293,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS // Make sure layer (and mip) name are unique across pages by putting the page name in const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(node->GetLocation()); - plString layName = plString::Format("%s_%s_LIGHTMAPGEN", pageInfo->GetPage(), node->GetName()); + plString layName = plString::Format("%s_%s_LIGHTMAPGEN", pageInfo->GetPage().c_str(), node->GetName()); plKey layKey = node->FindPageKey(plLayer::Index(), layName); @@ -1626,4 +1626,4 @@ int plLightMapGen::IPowerOfTwo(int sz) const p2sz >>= 1; return p2sz; -} \ No newline at end of file +} diff --git a/Sources/Tools/MaxMain/plPluginResManager.cpp b/Sources/Tools/MaxMain/plPluginResManager.cpp index 70d2e923..d6f9281d 100644 --- a/Sources/Tools/MaxMain/plPluginResManager.cpp +++ b/Sources/Tools/MaxMain/plPluginResManager.cpp @@ -58,7 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/plKeyImp.h" #include "plAgeDescription/plAgeDescription.h" -plKey plPluginResManager::NameToLoc(const char* age, const char* page, int32_t sequenceNumber, bool itinerant) +plKey plPluginResManager::NameToLoc(const plString& age, const plString& page, int32_t sequenceNumber, bool itinerant) { // Hack for now--always prefer paging out sceneNodes first fPageOutHint = plSceneNode::Index(); @@ -68,7 +68,7 @@ plKey plPluginResManager::NameToLoc(const char* age, const char* page, int32_t s hsAssert(pageNode != nil, "No page returned from INameToPage(), shouldn't be possible"); // Go find the sceneNode now, since we know the page exists (go through our normal channels, though) - plString keyName = plString::Format("%s_%s", age, page); + plString keyName = plString::Format("%s_%s", age.c_str(), page.c_str()); plUoid nodeUoid(pageNode->GetPageInfo().GetLocation(), plSceneNode::Index(), keyName); @@ -110,7 +110,7 @@ plKey plPluginResManager::NameToLoc(const char* age, const char* page, int32_t s // seqNumber, returns the page for that combo (either by preloading it or // by creating it). -plRegistryPageNode* plPluginResManager::INameToPage(const char* age, const char* page, int32_t sequenceNumber, bool itinerant) +plRegistryPageNode* plPluginResManager::INameToPage(const plString& age, const plString& page, int32_t sequenceNumber, bool itinerant) { // Find the location first, to see if it already exists plRegistryPageNode* pageNode = FindPage(age, page); @@ -196,7 +196,7 @@ void plPluginResManager::IPreLoadTextures(plRegistryPageNode* pageNode, int32_t bool common = false; for (int i = 0; i < plAgeDescription::kNumCommonPages; i++) { - if (strcmpi(plAgeDescription::GetCommonPage(i), pageNode->GetPageInfo().GetPage()) == 0) + if (pageNode->GetPageInfo().GetPage().CompareI(plAgeDescription::GetCommonPage(i)) == 0) { common = true; break; @@ -320,15 +320,15 @@ public: }; -plLocation plPluginResManager::ICreateLocation(const char* age, const char* page, bool itinerant) +plLocation plPluginResManager::ICreateLocation(const plString& age, const plString& page, bool itinerant) { int32_t seqNum = VerifySeqNumber(0, age, page); return ICreateLocation(age, page, seqNum, itinerant); } -plLocation plPluginResManager::ICreateLocation(const char* age, const char* page, int32_t seqNum, bool itinerant) +plLocation plPluginResManager::ICreateLocation(const plString& age, const plString& page, int32_t seqNum, bool itinerant) { - bool willBeReserved = strcmpi(age, "global") == 0; + bool willBeReserved = age.CompareI("global") == 0; int32_t oldNum = seqNum; seqNum = VerifySeqNumber(seqNum, age, page); @@ -352,7 +352,7 @@ plLocation plPluginResManager::ICreateLocation(const char* age, const char* page // Flag common pages for (int i = 0; i < plAgeDescription::kNumCommonPages; i++) { - if (strcmp(plAgeDescription::GetCommonPage(i), page) == 0) + if (page.Compare(plAgeDescription::GetCommonPage(i)) == 0) { newLoc.SetFlags(plLocation::kBuiltIn); break; @@ -361,8 +361,8 @@ plLocation plPluginResManager::ICreateLocation(const char* age, const char* page // If we have an age description file for the age we're creating a location // for, grab some extra flags from it - plAgeDescription* ageDesc = plPageInfoUtils::GetAgeDesc(age); - plAgePage* agePage = ageDesc ? ageDesc->FindPage(page) : nil; + plAgeDescription* ageDesc = plPageInfoUtils::GetAgeDesc(age.c_str()); + plAgePage* agePage = ageDesc ? ageDesc->FindPage(page.c_str()) : nil; if (agePage) { if (agePage->GetFlags() & plAgePage::kIsLocalOnly) @@ -427,9 +427,9 @@ void plPluginResManager::AddLooseEnd(plKey key) } } // Verifies that the given sequence number belongs to the given string combo and ONLY that combo. Returns a new, unique sequenceNumber if not -int32_t plPluginResManager::VerifySeqNumber(int32_t sequenceNumber, const char* age, const char* page) +int32_t plPluginResManager::VerifySeqNumber(int32_t sequenceNumber, const plString& age, const plString& page) { - bool negated = false, willBeReserved = strcmpi(age, "global") == 0; + bool negated = false, willBeReserved = age.CompareI("global") == 0; if (sequenceNumber < 0) { sequenceNumber = -sequenceNumber; diff --git a/Sources/Tools/MaxMain/plPluginResManager.h b/Sources/Tools/MaxMain/plPluginResManager.h index 392b4c03..7dce5698 100644 --- a/Sources/Tools/MaxMain/plPluginResManager.h +++ b/Sources/Tools/MaxMain/plPluginResManager.h @@ -50,6 +50,7 @@ class plLocation; class plPageInfo; class plRegistryPageNode; class plSceneNode; +class plString; class plPluginResManager : public plResManager { @@ -61,10 +62,10 @@ public: //------------------------ // Given a page string combo, returns the key of the sceneNode for that page. If the page does not exist, it creates one. - plKey NameToLoc(const char* age, const char* page, int32_t sequenceNumber, bool itinerant = false); + plKey NameToLoc(const plString& age, const plString& page, int32_t sequenceNumber, bool itinerant = false); // Verifies that the given sequence number belongs to the given string combo and ONLY that combo. Returns a new, unique sequenceNumber if not - int32_t VerifySeqNumber(int32_t sequenceNumber, const char* age, const char* page); + int32_t VerifySeqNumber(int32_t sequenceNumber, const plString& age, const plString& page); enum VerifyErrors { @@ -97,10 +98,10 @@ public: void EndExport(); protected: - plLocation ICreateLocation(const char* age, const char* page, bool itinerant); - plLocation ICreateLocation(const char* age, const char* page, int32_t seqNum, bool itinerant); + plLocation ICreateLocation(const plString& age, const plString& page, bool itinerant); + plLocation ICreateLocation(const plString& age, const plString& page, int32_t seqNum, bool itinerant); - plRegistryPageNode* INameToPage(const char* age, const char* page, int32_t sequenceNumber, bool itinerant = false); + plRegistryPageNode* INameToPage(const plString& age, const plString& page, int32_t sequenceNumber, bool itinerant = false); void IPreLoadTextures(plRegistryPageNode* pageNode, int32_t origSeqNumber); diff --git a/Sources/Tools/plResBrowser/plResTreeView.cpp b/Sources/Tools/plResBrowser/plResTreeView.cpp index 87c13e5f..dc2bd1dd 100644 --- a/Sources/Tools/plResBrowser/plResTreeView.cpp +++ b/Sources/Tools/plResBrowser/plResTreeView.cpp @@ -145,7 +145,7 @@ class plResDlgLoader : public plRegistryPageIterator, public plRegistryKeyIterat fCurrPage = page; const plPageInfo &info = page->GetPageInfo(); - sprintf( str, "%s->%s", info.GetAge(), info.GetPage() ); + sprintf( str, "%s->%s", info.GetAge().c_str(), info.GetPage().c_str()); fCurrItem = AddLeaf( fTree, NULL, str, new plKeyInfo( nil, fCurrPage ) ); fCurrType = (uint16_t)-1; @@ -393,8 +393,8 @@ void plResTreeView::UpdateInfoDlg( HWND treeCtrl ) const plPageInfo &pageInfo = info->fPage->GetPageInfo(); char tempStr[ 32 ]; - SetDlgItemText( fInfoDlg, IDC_AGE, pageInfo.GetAge() ); - SetDlgItemText( fInfoDlg, IDC_PAGE, pageInfo.GetPage() ); + SetDlgItemText( fInfoDlg, IDC_AGE, pageInfo.GetAge().c_str()); + SetDlgItemText( fInfoDlg, IDC_PAGE, pageInfo.GetPage().c_str()); SetDlgItemText( fInfoDlg, IDC_LOCATION, pageInfo.GetLocation().StringIze().c_str() ); From cd53cf180d4e7b04baaac4040c726797b4655a8e Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 5 Jan 2013 22:42:55 -0800 Subject: [PATCH 2/5] Fix issues pointed out in code review. --- .../Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp | 12 ++---------- Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp | 2 +- Sources/Plasma/PubUtilLib/plResMgr/plResManager.h | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp index 42717e55..dca9034d 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp @@ -80,17 +80,9 @@ plRegistryPageNode::plRegistryPageNode(const plLocation& location, const plStrin { fPageInfo.SetStrings(age, page); - plString path = dataPath; - path += PATH_SEPARATOR_STR; - // Time to construct our actual file name. For now, we'll use the same old format // of age_page.extension - path += fPageInfo.GetAge(); - path += "_District_"; - path += fPageInfo.GetPage(); - path += ".prp"; - - fPath = path; + fPath = plString::Format("%s%x%s_District_%s.prp", dataPath.c_str(), PATH_SEPARATOR_STR, fPageInfo.GetAge().c_str(), fPageInfo.GetPage().c_str()); } plRegistryPageNode::~plRegistryPageNode() @@ -137,7 +129,7 @@ hsStream* plRegistryPageNode::OpenStream() { if (fOpenRequests == 0) { - if (!fStream.Open(fPath.c_str(), "rb")) + if (!fStream.Open_TEMP(fPath, "rb")) return nil; } fOpenRequests++; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp index 37552374..eda1d7ae 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp @@ -1770,7 +1770,7 @@ bool plResManager::IteratePages(plRegistryPageIterator* iterator, const plString if (page->GetPageInfo().GetLocation() == plLocation::kGlobalFixedLoc) continue; - if (!ageToRestrictTo.IsNull() || page->GetPageInfo().GetAge().CompareI(ageToRestrictTo) == 0) + if (ageToRestrictTo.IsNull() || page->GetPageInfo().GetAge().CompareI(ageToRestrictTo) == 0) { if (!iterator->EatPage(page)) { diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h index 8209b777..306ed0c1 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h @@ -155,7 +155,7 @@ public: // Single page version bool IterateKeys(plRegistryKeyIterator* iterator, const plLocation& pageToRestrictTo); // Iterate through loaded pages - bool IteratePages(plRegistryPageIterator* iterator, const plString& ageToRestrictTo = nil); + bool IteratePages(plRegistryPageIterator* iterator, const plString& ageToRestrictTo = ""); // Iterate through ALL pages, loaded or not bool IterateAllPages(plRegistryPageIterator* iterator); From 9a579d6af78abbc6831caf4ad2542fa3d8848c11 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 5 Jan 2013 22:46:27 -0800 Subject: [PATCH 3/5] Fix memory leaks. --- Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp index a7a15db7..a135aaca 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plPageInfo.cpp @@ -133,10 +133,10 @@ void plPageInfo::Read( hsStream *s ) if (version >= 5) { fLocation.Read( s ); - fAge = s->ReadSafeString(); + fAge = s->ReadSafeString_TEMP(); if (version < 6) - delete s->ReadSafeString(); // fChapter was never used, and always "District". - fPage = s->ReadSafeString(); + s->ReadSafeString_TEMP(); // fChapter was never used, and always "District". + fPage = s->ReadSafeString_TEMP(); s->ReadLE( &fMajorVersion ); From c448d11209db73b1f104f041ebabe2d93b81dfd7 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Mon, 7 Jan 2013 20:30:18 -0800 Subject: [PATCH 4/5] Fix format string here. --- Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp index dca9034d..e9a1f4e8 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp @@ -82,7 +82,7 @@ plRegistryPageNode::plRegistryPageNode(const plLocation& location, const plStrin // Time to construct our actual file name. For now, we'll use the same old format // of age_page.extension - fPath = plString::Format("%s%x%s_District_%s.prp", dataPath.c_str(), PATH_SEPARATOR_STR, fPageInfo.GetAge().c_str(), fPageInfo.GetPage().c_str()); + fPath = plString::Format("%s" PATH_SEPARATOR_STR "%s_District_%s.prp", dataPath.c_str(), fPageInfo.GetAge().c_str(), fPageInfo.GetPage().c_str()); } plRegistryPageNode::~plRegistryPageNode() From cb9dab2ccac52ba3c60844751d27a79981ee85f1 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Mon, 7 Jan 2013 21:56:14 -0800 Subject: [PATCH 5/5] Some fixes to make it all compile. --- Sources/Plasma/Apps/plClient/plClient.cpp | 4 ++-- Sources/Tools/MaxComponent/plClothingComponent.cpp | 2 +- Sources/Tools/MaxMain/plPluginResManager.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index b0e895d5..a1dc8e5c 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -990,7 +990,7 @@ void plClient::SetHoldLoadRequests(bool hold) void plClient::IQueueRoomLoad(const std::vector& locs, bool hold) { bool allSameAge = true; - const char* lastAgeName = nil; + plString lastAgeName; uint32_t numRooms = 0; for (int i = 0; i < locs.size(); i++) @@ -1016,7 +1016,7 @@ void plClient::IQueueRoomLoad(const std::vector& locs, bool hold) fLoadRooms.push_back(new LoadRequest(loc, hold)); - if (!lastAgeName || strcmp(info->GetAge(), lastAgeName) == 0) + if (lastAgeName.IsNull() || info->GetAge() == lastAgeName) lastAgeName = info->GetAge(); else allSameAge = false; diff --git a/Sources/Tools/MaxComponent/plClothingComponent.cpp b/Sources/Tools/MaxComponent/plClothingComponent.cpp index a9d30419..f8552b6a 100644 --- a/Sources/Tools/MaxComponent/plClothingComponent.cpp +++ b/Sources/Tools/MaxComponent/plClothingComponent.cpp @@ -233,7 +233,7 @@ bool plClothingComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) } const plPageInfo* thisInfo = plKeyFinder::Instance().GetLocationInfo(locationNode ? locationNode->GetLocation() : node->GetLocation()); - const plLocation &loc = plKeyFinder::Instance().FindLocation("GlobalClothing", thisInfo->GetPage()); + const plLocation &loc = plKeyFinder::Instance().FindLocation("GlobalClothing", thisInfo->GetPage().c_str()); for (i = 0; i < fCompPB->Count(plClothingComponent::kMaterials); i++) { diff --git a/Sources/Tools/MaxMain/plPluginResManager.cpp b/Sources/Tools/MaxMain/plPluginResManager.cpp index d6f9281d..596ef6e1 100644 --- a/Sources/Tools/MaxMain/plPluginResManager.cpp +++ b/Sources/Tools/MaxMain/plPluginResManager.cpp @@ -120,12 +120,12 @@ plRegistryPageNode* plPluginResManager::INameToPage(const plString& age, const p if (sequenceNumber != uint32_t(-1)) { const plLocation& newLoc = ICreateLocation(age, page, sequenceNumber, itinerant); - pageNode = CreatePage(newLoc, age, page); + pageNode = CreatePage(newLoc, age.c_str(), page.c_str()); } else { const plLocation& newLoc = ICreateLocation(age, page, itinerant); - pageNode = CreatePage(newLoc, age, page); + pageNode = CreatePage(newLoc, age.c_str(), page.c_str()); } // Still preload textures on this guy. This should be a no-op for this page since it's new, but won't be // for the shared textures page