Browse Source

Allow encrypted age files

Yes, this bit me in the ass.
Adam Johnson 12 years ago
parent
commit
66423478cc
  1. 1
      Sources/Tools/MaxComponent/Pch.h
  2. 37
      Sources/Tools/MaxComponent/plMiscComponents.cpp

1
Sources/Tools/MaxComponent/Pch.h

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Standard Library // Standard Library
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <memory>
#include <set> #include <set>
#include <string> #include <string>
#include <vector> #include <vector>

37
Sources/Tools/MaxComponent/plMiscComponents.cpp

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "resource.h" #include "resource.h"
#include <iparamm2.h> #include <iparamm2.h>
#include <memory>
#include <notify.h> #include <notify.h>
#pragma hdrstop #pragma hdrstop
@ -96,6 +97,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Location Related // Location Related
#include "plAgeDescription/plAgeDescription.h" #include "plAgeDescription/plAgeDescription.h"
#include "plFile/plEncryptedStream.h"
#include "MaxMain/plMaxCFGFile.h" #include "MaxMain/plMaxCFGFile.h"
#include "MaxMain/plAgeDescInterface.h" #include "MaxMain/plAgeDescInterface.h"
#include "plResMgr/plPageInfo.h" #include "plResMgr/plPageInfo.h"
@ -649,9 +651,9 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge)); plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge));
IVerifyLatestAgeAsset( curAge, path, errMsg ); IVerifyLatestAgeAsset( curAge, path, errMsg );
std::unique_ptr<plAgeDescription> aged(plPageInfoUtils::GetAgeDesc(curAge));
hsUNIXStream s; if (!aged)
if (!s.Open(path))
{ {
errMsg->Set( true, errMsg->Set( true,
"PageInfo Convert Error", "PageInfo Convert Error",
@ -664,13 +666,8 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
return; return;
} }
// create and read the age desc
plAgeDescription aged;
aged.Read(&s);
s.Close();
// Update based on the age file now // Update based on the age file now
fCompPB->SetValue( kInfoSeqPrefix, 0, (int)aged.GetSequencePrefix() ); fCompPB->SetValue( kInfoSeqPrefix, 0, (int)aged->GetSequencePrefix() );
// Find our page // Find our page
const char *compPBPageName = fCompPB->GetStr( kInfoPage ); const char *compPBPageName = fCompPB->GetStr( kInfoPage );
@ -688,9 +685,9 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
} }
plAgePage *page; plAgePage *page;
aged.SeekFirstPage(); aged->SeekFirstPage();
while( ( page = aged.GetNextPage() ) != nil ) while( ( page = aged->GetNextPage() ) != nil )
{ {
if( page->GetName().CompareI( compPBPageName ) == 0 ) if( page->GetName().CompareI( compPBPageName ) == 0 )
{ {
@ -790,18 +787,16 @@ plAgeDescription *plPageInfoUtils::GetAgeDesc( const plString &ageName )
{ {
plFileName ageFolder = plPageInfoUtils::GetAgeFolder(); plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid() || ageName.IsNull()) if (!ageFolder.IsValid() || ageName.IsNull())
return nil; return nullptr;
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 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) const char* LocCompGetPage(plComponentBase* comp)

Loading…
Cancel
Save