2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-13 18:17:49 -04:00

CWE Directory Reorganization

Rearrange directory structure of CWE to be loosely equivalent to
the H'uru Plasma repository.

Part 1: Movement of directories and files.
This commit is contained in:
rarified
2021-05-15 12:49:46 -06:00
parent c3f4a640a3
commit 96903e8dca
4002 changed files with 159 additions and 644 deletions

View File

@ -0,0 +1,74 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "../pnFactory/plCreator.h"
#include "plAudible.h"
REGISTER_NONCREATABLE( plAudible );
#include "plDrawable.h"
REGISTER_NONCREATABLE( plDrawable );
#include "plPhysical.h"
REGISTER_NONCREATABLE( plPhysical );
#include "plgDispatch.h"
REGISTER_NONCREATABLE( plDispatchBase );
#include "../pnDispatch/pnDispatchCreatable.h"
#include "../pnKeyedObject/pnKeyedObjectCreatable.h"
#include "../pnMessage/pnMessageCreatable.h"
#include "../pnModifier/pnModifierCreatable.h"
#include "../pnNetCommon/pnNetCommonCreatable.h"
#include "../plNetMessage/plNetMessageCreatable.h"
#include "../pnTimer/pnTimerCreatable.h"
#include "../plVault/plVaultCreatable.h"
#include "../plNetCommon/plNetCommonCreatable.h"
#include "../plResMgr/plResMgrCreatable.h"
#include "../plMessage/plResMgrHelperMsg.h"
REGISTER_CREATABLE(plResMgrHelperMsg);
#include "../plUnifiedTime/plUnifiedTime.h"
REGISTER_CREATABLE( plUnifiedTime );

View File

@ -0,0 +1,445 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plDatMerger - Command line utility app that takes multiple dat files
// and merges them into one
//
//////////////////////////////////////////////////////////////////////////////
#include "hsTypes.h"
#include "hsStream.h"
#include "hsUtils.h"
#include "hsTimer.h"
#include "../plFile/hsFiles.h"
#include "plRawResManager.h"
#include "plRawPageAccessor.h"
#include "../plResMgr/plRegistryDiskSource.h"
#include "../plResMgr/plRegistryDiskMergedSourceData.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plRegistry.h"
#include "../plResMgr/plRegistryNode.h"
#include "../plResMgr/plResMgrSettings.h"
#include "../plResMgr/plPageInfo.h"
#include "../plAgeDescription/plAgeDescription.h"
#include "../plFile/hsFiles.h"
#include "../plFile/plFileUtils.h"
#include "../pnKeyedObject/plKey.h"
#include <stdio.h>
#include <stdlib.h>
//// Tiny String Filter Class ////////////////////////////////////////////////
class plStrFilter
{
protected:
hsBool fWildCardSuffix, fInvert;
char *fStr;
plStrFilter *fChapFilter, *fPageFilter;
hsBool IPass( const char *string )
{
if( fWildCardSuffix )
{
if( strnicmp( fStr, string, strlen( fStr ) ) == 0 )
return true;
}
else
{
if( stricmp( fStr, string ) == 0 )
return true;
}
return false;
}
public:
plStrFilter() { fWildCardSuffix = fInvert = false; fStr = nil; fChapFilter = fPageFilter = nil; }
plStrFilter( const char *initLine )
{
if( initLine[ 0 ] == '-' )
{
fInvert = true;
initLine++;
}
else if( initLine[ 0 ] == '+' )
{
initLine++;
fInvert = false;
}
else
fInvert = false;
fWildCardSuffix = false;
fStr = hsStrcpy( initLine );
fChapFilter = fPageFilter = nil;
char *comma = strchr( fStr, ',' );
if( comma != nil )
{
char *next = comma + 1;
*comma = 0;
comma = strchr( next, ',' );
if( comma != nil )
{
fPageFilter = new plStrFilter( comma + 1 );
*comma = 0;
}
fChapFilter = new plStrFilter( next );
}
if( fStr[ strlen( fStr ) - 1 ] == '*' )
{
fWildCardSuffix = true;
fStr[ strlen( fStr ) - 1 ] = 0;
}
}
~plStrFilter()
{
delete [] fStr;
delete fChapFilter;
delete fPageFilter;
}
hsBool Pass( const char *string )
{
hsBool ret = IPass( string );
if( fInvert )
ret = !ret;
return ret;
}
hsBool Pass( const plPageInfo &page )
{
hsBool ret = IPass( page.GetAge() ) &&
fChapFilter->IPass( page.GetChapter() ) &&
fPageFilter->IPass( page.GetPage() );
if( fInvert )
ret = !ret;
return ret;
}
static hsBool Passes( const char *string, hsTArray<plStrFilter *> &filters )
{
UInt32 i;
for( i = 0; i < filters.GetCount(); i++ )
{
if( !filters[ i ]->Pass( string ) )
return false;
}
return true;
}
static hsBool Passes( const plPageInfo &page, hsTArray<plStrFilter *> &filters )
{
UInt32 i;
for( i = 0; i < filters.GetCount(); i++ )
{
if( !filters[ i ]->Pass( page ) )
return false;
}
return true;
}
};
//// Globals /////////////////////////////////////////////////////////////////
plRawResManager *gResManager = nil;
char gDatDirectory[ kFolderIterator_MaxPath ] = ".";
char gDestFileName[ kFolderIterator_MaxPath ];
hsTArray<plStrFilter *> fPageFilters;
hsTArray<plStrFilter *> *fCurrFilterList = nil;
hsTArray<plRegistryPageNode *> fSourcePages;
plRegistryDiskMergedSourceData *gDestMergeData = nil;
//// PrintHelp ///////////////////////////////////////////////////////////////
int PrintHelp( void )
{
puts( "" );
puts( "Usage:\tplDatMerger [oldDir] [newDir] [patchDir] |-na| |-np| |-fp| |-lAgeName| |-anewAgeDir|" );
puts( "Where:" );
puts( "\toldDir is the directory containing the old data files" );
puts( "\tnewDir is the directory containing the new data files" );
puts( "\tpatchDir is the directory where the patch files will go" );
puts( "\t WARNING: This should point to a 'patches'" );
puts( "\t subdir under 'newDir'; don't use anything else" );
puts( "\t unless you REALLY know what you're doing." );
puts( "\t-na is a flag that keeps the builder from updating the" );
puts( "\t version numbers in the age files (for generating" );
puts( "\t previous patch versions, for example." );
puts( "\t-np is a flag that keeps the builder from actually creating the" );
puts( "\t patch files. Usually helpful when you want to" );
puts( "\t only update version numbers in the dat files" );
puts( "\t and the age files. -na and -np are mutually" );
puts( "\t exclusive." );
puts( "\t-fp forces writing of entire objects instead of just difference" );
puts( "\t buffers, for debugging purposes." );
puts( "\t-l limits processing to the single age given. Don't put a space between the l." );
puts( "\t and the age name." );
puts( "\t-a specifies a different directory to put the modified age files in. If not" );
puts( "\t specified, age files are overwritten in the newDir." );
puts( "" );
return -1;
}
hsBool ReadConfig( const char *filename )
{
hsUNIXStream config;
if( !config.Open( filename, "rt" ) )
return false;
char line[ 512 ];
int lineNum = 1;
while( config.ReadLn( line, sizeof( line ) ) )
{
// Switch based on command
if( stricmp( line, "[pageFilters]" ) == 0 )
fCurrFilterList = &fPageFilters;
else if( fCurrFilterList != nil )
{
fCurrFilterList->Append( new plStrFilter( line ) );
}
else
{
char *tok = strtok( line, " \t=" );
if( tok != nil )
{
if( stricmp( tok, "datDir" ) == 0 )
{
tok = strtok( nil, " \t=" );
if( tok != nil )
strcpy( gDatDirectory, tok );
else
{
printf( "Parse error in init file, line %d", lineNum );
return false;
}
}
else if( stricmp( tok, "destFile" ) == 0 )
{
tok = strtok( nil, "\n\r" );
if( tok == nil )
{
printf( "Parse error in init file, line %d", lineNum );
return false;
}
strcpy( gDestFileName, tok );
}
else
{
printf( "Parse error in init file, line %d", lineNum );
}
}
}
lineNum++;
}
config.Close();
return true;
}
//// Our Main Page Iterator //////////////////////////////////////////////////
class plPageStuffer : public plRegistryPageIterator
{
public:
virtual hsBool EatPage( plRegistryPageNode *page )
{
const plPageInfo &info = page->GetPageInfo();
if( plStrFilter::Passes( info, fPageFilters ) )
fSourcePages.Append( page );
return true;
}
};
//// IShutdown ///////////////////////////////////////////////////////////////
void IShutdown( int retCode )
{
UInt32 i;
for( i = 0; i < fPageFilters.GetCount(); i++ )
delete fPageFilters[ i ];
delete gDestMergeData;
hsgResMgr::Shutdown();
if( retCode == 0 )
printf( "Finished!\n" );
else
exit( retCode );
}
//// main ////////////////////////////////////////////////////////////////////
int main( int argc, char *argv[] )
{
puts( "-----------------------------------------------------" );
puts( "plDatMerger - Plasma 2 dat file merging utility" );
puts( "-----------------------------------------------------" );
if( argc < 1 || argc > 8 )
return PrintHelp();
// Read our config
ReadConfig( argv[ 1 ] );
plResMgrSettings::Get().SetFilterNewerPageVersions( false );
plResMgrSettings::Get().SetFilterOlderPageVersions( false );
// Init our special resMgr
puts( "Initializing resManager..." );
gResManager = new plRawResManager;
hsgResMgr::Init( gResManager );
// Load the registry in to work with
printf( "Loading registry from directory \"%s\"...\n", gDatDirectory );
gResManager->AddSource( new plRegistryDiskSource( gDatDirectory ) );
// Iterate and collect pages to merge
printf( "Collecting pages...\n" );
plPageStuffer pageIter;
gResManager->IterateAllPages( &pageIter );
if( fSourcePages.GetCount() == 0 )
{
puts( "ERROR: No source pages found to merge!" );
IShutdown( -1 );
}
// Create a merged data source to represent our dest page
printf( "Merging %d pages to file(s) %s...\n", fSourcePages.GetCount(), gDestFileName );
gDestMergeData = new plRegistryDiskMergedSourceData( gDestFileName );
gDestMergeData->SetNumEntries( fSourcePages.GetCount() );
// Open the dest merged streams and write out our initial, incorrect, entry table so we can get positions right
hsStream *destIdxStream = gDestMergeData->WriteEntries( true );
hsStream *destDatStream = gDestMergeData->OpenData( (UInt32)-1, "wb" );
UInt32 i, bytesRead;
static UInt8 scratchBuffer[ 1024 * 64 ]; // 32k in size
for( i = 0; i < fSourcePages.GetCount(); i++ )
{
printf( " Merging %s>%s...\n", fSourcePages[ i ]->GetPageInfo().GetAge(), fSourcePages[ i ]->GetPageInfo().GetPage() );
// For each page, we open the source streams, read the ENTIRE thing in, front to back, and append it
// to the dest stream. We then update the entry in the mergeData to reflect our info
plMSDEntry &entry = gDestMergeData->GetEntry( i );
entry.fIdxOffset = destIdxStream->GetPosition();
entry.fDatOffset = destDatStream->GetPosition();
/// Actually transfer the data
plRegistrySource *srcSource = fSourcePages[ i ]->GetSource();
// Idx first
hsStream *srcStream = srcSource->OpenIndexStream( fSourcePages[ i ] );
UInt32 size = srcStream->GetEOF();
do
{
bytesRead = srcStream->Read( size > sizeof( scratchBuffer ) ? sizeof( scratchBuffer ) : size, scratchBuffer );
if( bytesRead > 0 )
destIdxStream->Write( bytesRead, scratchBuffer );
size -= bytesRead;
} while( size > 0 && bytesRead > 0 );
srcSource->CloseIndexStream( fSourcePages[ i ] );
// Now dat
srcStream = srcSource->OpenDataStream( fSourcePages[ i ] );
size = srcStream->GetEOF();
do
{
bytesRead = srcStream->Read( size > sizeof( scratchBuffer ) ? sizeof( scratchBuffer ) : size, scratchBuffer );
if( bytesRead > 0 )
destDatStream->Write( bytesRead, scratchBuffer );
size -= bytesRead;
} while( size > 0 && bytesRead > 0 );
srcSource->CloseDataStream( fSourcePages[ i ] );
// Update lengths
entry.fIdxLength = destIdxStream->GetPosition() - entry.fIdxOffset;
entry.fDatLength = destDatStream->GetPosition() - entry.fDatOffset;
}
printf( "Closing destination files...\n" );
destIdxStream->Close();
destDatStream->Close();
// Re-write the entry table, now that it's correct
printf( "Updating merged table...\n" );
gDestMergeData->WriteEntries( false );
puts( "Shutting down..." );
IShutdown( 0 );
return 0;
}

View File

@ -0,0 +1,225 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plRawPageAccessor - Dangerous little class that lets you take a
// plRegistryPageNode and load the objects in raw (i.e.
// as block memory buffers).
// This should NOT be used in any normal app, only
// utility apps that don't want to load objects in
// normally (which basically means if you're not mcn,
// don't use this!)
//
//// Why We're Bad ///////////////////////////////////////////////////////////
//
// To store all the raw buffers, we stuff them as pointers into the keys
// themselves. This is Way Bad(tm) because those pointers are expecting
// hsKeyedObjects, and what we're giving them certainly ain't those.
// This is why it's only safe to use this class in a very small, controlled
// environment, one where we know the keys won't be accessed in a normal
// fashion so we know nobody will try to use our pointers in a bad way.
//
//////////////////////////////////////////////////////////////////////////////
#include "hsTypes.h"
#include "hsStream.h"
#include "hsResMgr.h"
#include "plRawKeyedObject.h"
#include "../pnKeyedObject/plKeyImp.h"
//// Tiny Yet Now Famous Key Hack ////////////////////////////////////////////
class plPublicKeyImp : public plKeyImp
{
public:
void SetObjectPtrDirect( hsKeyedObject *obj )
{
fObjectPtr = obj;
}
void SetAsEmpty( void )
{
fStartPos = (UInt32)-1;
fDataLen = (UInt32)-1;
}
void SetStartPosFromStream( hsStream *stream )
{
fStartPos = stream->GetPosition();
}
void SetLengthFromStream( hsStream *stream )
{
fDataLen = stream->GetPosition() - fStartPos;
}
};
//// Constructor/Destructor //////////////////////////////////////////////////
plRawKeyedObject::plRawKeyedObject()
{
fSrcKey = nil;
fBuffer = nil;
fBufferSize = 0;
}
plRawKeyedObject::plRawKeyedObject( const plKey &key, UInt32 size, UInt8 *data )
{
fSrcKey = key;
( (plPublicKeyImp *)(plKeyImp *)key )->SetObjectPtrDirect( this );
fBuffer = nil;
fBufferSize = 0;
SetBuffer( size, data );
}
plRawKeyedObject::~plRawKeyedObject()
{
if( fSrcKey != nil )
{
( (plPublicKeyImp *)(plKeyImp *)fSrcKey )->SetObjectPtrDirect( nil );
fSrcKey = nil;
}
delete [] fBuffer;
}
void plRawKeyedObject::SetBuffer( UInt32 size, UInt8 *data )
{
delete [] fBuffer;
if( data == nil )
{
fBufferSize = 0;
fBuffer = nil;
return;
}
fBufferSize = size;
fBuffer = new UInt8[ size ];
memcpy( fBuffer, data, size );
}
void plRawKeyedObject::SetKey( plKey k )
{
if( fSrcKey != nil )
{
( (plPublicKeyImp *)(plKeyImp *)fSrcKey )->SetObjectPtrDirect( nil );
}
fSrcKey = k;
if( fSrcKey != nil )
{
( (plPublicKeyImp *)(plKeyImp *)fSrcKey )->SetObjectPtrDirect( this );
}
}
void plRawKeyedObject::MarkAsEmpty( plKey &key )
{
( (plPublicKeyImp *)(plKeyImp *)key )->SetAsEmpty();
}
void plRawKeyedObject::Write( hsStream *stream )
{
// BEFORE we write out, somewhere at the top of our buffer is the key to ourselves
// that all hsKeyedObjects write out as part of their Write() function. We need
// to REPLACE that key with our new key, since our location has now changed. Note
// that this will ONLY work if our location changes, NOT if our name changes,
// because we're relying on the fact that the written size of our key is not
// going to change!!!
{
hsWriteOnlyStream replaceStream( fBufferSize, fBuffer );
// Here's the part that REALLY sucks, 'cause it assumes our written format will never change!!!!
// It ALSO assumes, VERY dangerously, that ReadSwap16() will ALWAYS read a size UInt16
replaceStream.SetPosition( sizeof( UInt16 ) ); // Get past creatable class that resManager writes out
hsgResMgr::ResMgr()->WriteKey( &replaceStream, fSrcKey, hsResMgr::kWriteNoCheck );
}
( (plPublicKeyImp *)(plKeyImp *)fSrcKey )->SetStartPosFromStream( stream );
stream->Write( fBufferSize, fBuffer );
( (plPublicKeyImp *)(plKeyImp *)fSrcKey )->SetLengthFromStream( stream );
}
//// Warning Stubs ///////////////////////////////////////////////////////////
void plRawKeyedObject::Validate()
{
hsAssert( false, "Invalid call on plRawKeyedObject" );
}
hsBool plRawKeyedObject::IsFinal()
{
hsAssert( false, "Invalid call on plRawKeyedObject" );
return false;
}
void plRawKeyedObject::Read(hsStream *s, hsResMgr *mgr )
{
hsAssert( false, "Invalid call on plRawKeyedObject" );
}
void plRawKeyedObject::Write(hsStream *s, hsResMgr *mgr )
{
hsAssert( false, "Invalid call on plRawKeyedObject" );
}
hsBool plRawKeyedObject::MsgReceive( plMessage *msg )
{
hsAssert( false, "Invalid call on plRawKeyedObject" );
return false;
}
hsKeyedObject *plRawKeyedObject::GetSharedObject()
{
hsAssert( false, "Invalid call on plRawKeyedObject" );
return nil;
}

View File

@ -0,0 +1,92 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plRawKeyedObject - A fake keyed object type that really just stores itself
// as a raw data buffer. See plRawPageAccessor for details.
//
// Derived from hsKeyedObject so we can try to put some
// warning asserts in where needed.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _plRawKeyedObject_h
#define _plRawKeyedObject_h
#include "hsTypes.h"
#include "hsStream.h"
#include "../pnKeyedObject/hsKeyedObject.h"
class plRawKeyedObject : public hsKeyedObject
{
protected:
plKey fSrcKey;
UInt32 fBufferSize;
UInt8 *fBuffer;
public:
plRawKeyedObject();
plRawKeyedObject( const plKey &key, UInt32 size, UInt8 *buffer );
virtual ~plRawKeyedObject();
void SetBuffer( UInt32 size, UInt8 *data );
UInt32 GetBufferSize( void ) const { return fBufferSize; }
UInt8 *GetBuffer( void ) const { return fBuffer; }
void SetKey( plKey k );
void Write( hsStream *stream );
static void MarkAsEmpty( plKey &key );
// None of the following should ever be called (hence our asserts)
virtual void Validate();
virtual hsBool IsFinal();
virtual void Read(hsStream *s, hsResMgr *mgr );
virtual void Write(hsStream *s, hsResMgr *mgr );
virtual hsBool MsgReceive( plMessage *msg );
virtual hsKeyedObject *GetSharedObject();
};
#endif //_plRawKeyedObject_h

View File

@ -0,0 +1,240 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plRawPageAccessor - Dangerous little class that lets you take a
// plRegistryPageNode and load the objects in raw (i.e.
// as block memory buffers).
// This should NOT be used in any normal app, only
// utility apps that don't want to load objects in
// normally (which basically means if you're not mcn,
// don't use this!)
//
//// Why We're Bad ///////////////////////////////////////////////////////////
//
// To store all the raw buffers, we stuff them as pointers into the keys
// themselves. This is Way Bad(tm) because those pointers are expecting
// hsKeyedObjects, and what we're giving them certainly ain't those.
// This is why it's only safe to use this class in a very small, controlled
// environment, one where we know the keys won't be accessed in a normal
// fashion so we know nobody will try to use our pointers in a bad way.
//
// Also assumes the current global resManager is a plRawResManager!
//
//////////////////////////////////////////////////////////////////////////////
#include "hsTypes.h"
#include "hsStream.h"
#include "plRawPageAccessor.h"
#include "plRawResManager.h"
#include "plRawKeyedObject.h"
#include "hsTemplates.h"
#include "../pnKeyedObject/plKeyImp.h"
#include "../plResMgr/plRegistryNode.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plRegistrySource.h"
//// Constructor/Destructor //////////////////////////////////////////////////
plRawPageAccessor::plRawPageAccessor( plRegistryPageNode *source, hsBool read )
{
fSource = source;
if( read )
ReadFromSource();
}
plRawPageAccessor::~plRawPageAccessor()
{
Release();
}
//// Iterators ///////////////////////////////////////////////////////////////
class plRawReaderIter : public plRegistryKeyIterator
{
public:
virtual hsBool EatKey( plKey key )
{
plRawResManager *mgr = (plRawResManager *)hsgResMgr::ResMgr();
UInt32 len;
plKeyImp *imp = (plKeyImp *)key;
UInt8 *buffer = mgr->ReadObjectBuffer( imp, len );
// This will also set the object ptr in the key
plRawKeyedObject *obj = new plRawKeyedObject( key, len, buffer );
delete [] buffer; // rawKeyedObject keeps a copy
return true;
}
};
class plRawWriterIter : public plRegistryKeyIterator
{
hsStream *fStream;
public:
plRawWriterIter( hsStream *stream ) : fStream( stream ) {}
virtual hsBool EatKey( plKey key )
{
plRawResManager *mgr = (plRawResManager *)hsgResMgr::ResMgr();
plRawKeyedObject *obj = (plRawKeyedObject *)key->ObjectIsLoaded();
if( obj == nil )
{
// Mark the key as not written
plRawKeyedObject::MarkAsEmpty( key );
return true;
}
obj->Write( fStream );
return true;
}
};
class plRawReleaseIter : public plRegistryKeyIterator
{
public:
virtual hsBool EatKey( plKey key )
{
plRawKeyedObject *obj = (plRawKeyedObject *)key->ObjectIsLoaded();
delete obj;
return true;
}
};
//// Various Functions ///////////////////////////////////////////////////////
void plRawPageAccessor::ReadFromSource( void )
{
if( !fSource->IsLoaded() )
fSource->LoadKeysFromSource();
plRawReaderIter iter;
fSource->IterateKeys( &iter );
}
void plRawPageAccessor::WriteToSource( void )
{
if( fSource->GetSource() == nil )
{
hsAssert( false, "Unable to write accessor to disk; no source defined!" );
return;
}
// Write out objects first
hsStream *stream = fSource->GetSource()->OpenDataStream( fSource, true );
if( stream == nil )
return;
plRawWriterIter writer( stream );
fSource->IterateKeys( &writer );
fSource->GetSource()->CloseDataStream( fSource );
// Now write out the keys
fSource->WriteKeysToSource();
}
void plRawPageAccessor::Release( void )
{
plRawReleaseIter iter;
fSource->IterateKeys( &iter );
fSource->ClearKeyLists();
}
void plRawPageAccessor::AddCopy( const plKey &origKey )
{
plRawResManager *mgr = (plRawResManager *)hsgResMgr::ResMgr();
plKey newKey;
// Get the source object
plRawKeyedObject *srcObj = (plRawKeyedObject *)origKey->ObjectIsLoaded();
// Construct a new uoid
plUoid newUoid( fSource->GetPageInfo().GetLocation(),
origKey->GetUoid().GetClassType(),
origKey->GetUoid().GetObjectName() );
// Does it already exist?
newKey = mgr->FindKey( newUoid );
if( newKey != nil )
{
// Yup, gotta get rid of old object (if there is one)
plRawKeyedObject *obj = (plRawKeyedObject *)newKey->ObjectIsLoaded();
delete obj;
}
else
{
// Nope, gotta create key first
newKey = mgr->NewBlankKey( newUoid );
}
// Force the key's uoid to the right uoid, now that it's in the right page
( (plKeyImp *)newKey )->SetUoid( origKey->GetUoid() );
// Assign a new buffer to the key
if( srcObj != nil )
{
// Will set obj pointer in key
plRawKeyedObject *obj = new plRawKeyedObject( newKey, srcObj->GetBufferSize(), srcObj->GetBuffer() );
}
}
void plRawPageAccessor::UpdateDataVersion( plRegistryPageNode *from )
{
plPageInfo &orig = from->GetPageInfo();
fSource->GetPageInfo().SetVersion( orig.GetMajorVersion(), orig.GetMinorVersion() );
fSource->GetPageInfo().SetReleaseVersion( orig.GetReleaseVersion() );
}

View File

@ -0,0 +1,85 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plRawPageAccessor - Dangerous little class that lets you take a
// plRegistryPageNode and load the objects in raw (i.e.
// as block memory buffers).
// This should NOT be used in any normal app, only
// utility apps that don't want to load objects in
// normally (which basically means if you're not mcn,
// don't use this!)
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _plRawPageAccessor_h
#define _plRawPageAccessor_h
#include "hsTypes.h"
#include "hsStream.h"
class plRegistryPageNode;
class plKey;
class plRawPageAccessor
{
protected:
plRegistryPageNode *fSource;
public:
plRawPageAccessor( plRegistryPageNode *source, hsBool read = true );
virtual ~plRawPageAccessor();
void ReadFromSource( void );
void WriteToSource( void );
void Release( void );
void UpdateDataVersion( plRegistryPageNode *from );
void AddCopy( const plKey &origKey );
};
#endif //_plRawPageAccessor_h

View File

@ -0,0 +1,132 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plRawResManager - Small public resManager thingy for reading/writing
// objects raw.
//
//////////////////////////////////////////////////////////////////////////////
#include "hsTypes.h"
#include "hsStream.h"
#include "plRawResManager.h"
#include "../plResMgr/plRegistry.h"
#include "../plResMgr/plPageInfo.h"
#include "../plResMgr/plRegistrySource.h"
#include "../plResMgr/plRegistryNode.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../pnKeyedObject/plKeyImp.h"
plRegistryPageNode *plRawResManager::FindPage( const char *age, const char *chapter, const char *page )
{
return fRegistry->FindPage( age, chapter, page );
}
plRegistryPageNode *plRawResManager::CreatePage( const plPageInfo &info )
{
plRegistryPageNode *page = fRegistry->CreatePage( info.GetLocation(), info.GetAge(), info.GetChapter(), info.GetPage() );
if( page != nil )
{
page->SetLoaded( true ); // We're "loaded", i.e. constructing this at runtime
fIOSources[ 0 ]->AddLocToSource( page );
}
return page;
}
UInt8 *plRawResManager::ReadObjectBuffer( plKeyImp *pKey, UInt32 &retBuffLength )
{
UInt8 *buffer = nil;
hsAssert( pKey, "Null Key" );
hsAssert( pKey->GetStartPos() != (UInt32)-1, "Missing StartPos" );
hsAssert( pKey->GetDataLen() != (UInt32)-1, "Missing Data Length" );
if( pKey->GetStartPos() == (UInt32)-1 || pKey->GetDataLen() == (UInt32)-1 )
{
// Try to recover from this by just not reading an object
retBuffLength = 0;
return nil;
}
plRegistryDataStream *dataStream = fRegistry->OpenPageDataStream( pKey->GetUoid().GetLocation(), false );
if( dataStream != nil && dataStream->GetStream() != nil )
{
hsStream *stream = dataStream->GetStream();
UInt32 oldPos = stream->GetPosition();
stream->SetPosition( pKey->GetStartPos() );
buffer = new UInt8[ pKey->GetDataLen() ];
if( buffer != nil )
{
*( (UInt32 *)buffer ) = pKey->GetDataLen();
stream->Read( pKey->GetDataLen(), (UInt8 *)buffer );
retBuffLength = pKey->GetDataLen();
}
else
retBuffLength = 0;
// Restore old position now
stream->SetPosition( oldPos );
}
delete dataStream;
return buffer;
}
plKey plRawResManager::NewBlankKey( const plUoid &newUoid )
{
plKeyImp *newKey = new plKeyImp;
newKey->SetUoid( newUoid );
fRegistry->AddKey( newKey );
plKey keyPtr = plKey::Make( newKey );
return keyPtr;
}

View File

@ -0,0 +1,72 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plRawResManager - Small public resManager thingy for reading/writing
// objects raw.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _plRawResManager_h
#define _plRawResManager_h
#include "hsTypes.h"
#include "hsStream.h"
#include "../plResMgr/plResManager.h"
class plPageInfo;
class plKeyImp;
class plRawResManager : public plResManager
{
public:
plRegistryPageNode *FindPage( const char *age, const char *chapter, const char *page );
plRegistryPageNode *CreatePage( const plPageInfo &info );
UInt8 *ReadObjectBuffer( plKeyImp *key, UInt32 &retLength );
plKey NewBlankKey( const plUoid &newUoid );
};
#endif //_plRawResManager_h