mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Fix line endings and tabs
This commit is contained in:
@ -1,21 +1,21 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../FeatureLib")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
set(plAgeDescription_SOURCES
|
||||
plAgeDescription.cpp
|
||||
plAgeManifest.cpp
|
||||
)
|
||||
|
||||
set(plAgeDescription_HEADERS
|
||||
plAgeDescription.h
|
||||
plAgeManifest.h
|
||||
)
|
||||
|
||||
add_library(plAgeDescription STATIC ${plAgeDescription_SOURCES} ${plAgeDescription_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plAgeDescription_SOURCES})
|
||||
source_group("Header Files" FILES ${plAgeDescription_HEADERS})
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../FeatureLib")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
set(plAgeDescription_SOURCES
|
||||
plAgeDescription.cpp
|
||||
plAgeManifest.cpp
|
||||
)
|
||||
|
||||
set(plAgeDescription_HEADERS
|
||||
plAgeDescription.h
|
||||
plAgeManifest.h
|
||||
)
|
||||
|
||||
add_library(plAgeDescription STATIC ${plAgeDescription_SOURCES} ${plAgeDescription_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plAgeDescription_SOURCES})
|
||||
source_group("Header Files" FILES ${plAgeDescription_HEADERS})
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,196 +1,196 @@
|
||||
/*==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/>.
|
||||
|
||||
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==*/
|
||||
#ifndef PL_AGE_DESCRIPTION_H
|
||||
#define PL_AGE_DESCRIPTION_H
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsUtils.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "pnKeyedObject/plUoid.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
|
||||
//
|
||||
// Age Definition File Reader/Writer
|
||||
//
|
||||
class hsStream;
|
||||
|
||||
class plAgePage
|
||||
{
|
||||
protected:
|
||||
char *fName;
|
||||
UInt32 fSeqSuffix;
|
||||
Byte fFlags;
|
||||
|
||||
public:
|
||||
|
||||
static const UInt32 kInvalidSeqSuffix;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
kPreventAutoLoad = 0x01,
|
||||
kLoadIfSDLPresent = 0x02,
|
||||
kIsLocalOnly = 0x04,
|
||||
kIsVolatile = 0x08,
|
||||
};
|
||||
|
||||
plAgePage( const char *name, UInt32 seqSuffix, Byte flags );
|
||||
plAgePage( char *stringFrom );
|
||||
plAgePage( const plAgePage &src );
|
||||
plAgePage();
|
||||
~plAgePage();
|
||||
|
||||
const char *GetName( void ) const { return fName; }
|
||||
UInt32 GetSeqSuffix( void ) const { return fSeqSuffix; }
|
||||
Byte GetFlags( void ) const { return fFlags; }
|
||||
|
||||
void SetSeqSuffix( UInt32 s ) { fSeqSuffix = s; }
|
||||
void SetFlags(Byte f, bool on=true);
|
||||
|
||||
hsBool SetFromString( const char *string );
|
||||
char *GetAsString( void ) const;
|
||||
|
||||
plAgePage &operator=( const plAgePage &src );
|
||||
};
|
||||
|
||||
// Derived from plInitSectionTokenReader so we can do nifty things with reading the files
|
||||
|
||||
class plAgeDescription : public plInitSectionTokenReader
|
||||
{
|
||||
private:
|
||||
|
||||
char *fName;
|
||||
|
||||
Int32 fPageIterator;
|
||||
hsTArray<plAgePage> fPages;
|
||||
|
||||
plUnifiedTime fStart;
|
||||
|
||||
float fDayLength;
|
||||
short fMaxCapacity;
|
||||
short fLingerTime; // seconds game instance should linger after last player leaves. -1 means never exit.
|
||||
|
||||
Int32 fSeqPrefix;
|
||||
UInt32 fReleaseVersion; // 0 for pre-release, 1+ for actual released ages
|
||||
|
||||
static char *fCommonPages[];
|
||||
|
||||
void IInit( void );
|
||||
void IDeInit( void );
|
||||
|
||||
// Overload for plInitSectionTokenReader
|
||||
virtual hsBool IParseToken( const char *token, hsStringTokenizer *tokenizer, UInt32 userData );
|
||||
|
||||
public:
|
||||
static char kAgeDescPath[];
|
||||
|
||||
plAgeDescription();
|
||||
plAgeDescription( const char *fileNameToReadFrom );
|
||||
plAgeDescription( const plAgeDescription &src )
|
||||
{
|
||||
IInit();
|
||||
CopyFrom( src );
|
||||
}
|
||||
~plAgeDescription();
|
||||
|
||||
bool ReadFromFile( const char *fileNameToReadFrom ) ;
|
||||
void Read(hsStream* stream);
|
||||
void Write(hsStream* stream) const;
|
||||
|
||||
// Overload for plInitSectionTokenReader
|
||||
virtual const char *GetSectionName( void ) const;
|
||||
|
||||
const char *GetAgeName( void ) const { return fName; }
|
||||
void SetAgeNameFromPath( const char *path );
|
||||
void SetAgeName(const char* ageName) { delete [] fName; fName=hsStrcpy(ageName); }
|
||||
|
||||
// Page list
|
||||
void ClearPageList();
|
||||
void RemovePage( const char *page );
|
||||
void AppendPage( const char *name, int seqSuffix = -1, Byte flags = 0 );
|
||||
|
||||
void SeekFirstPage( void );
|
||||
plAgePage *GetNextPage( void );
|
||||
int GetNumPages() const { return fPages.GetCount(); }
|
||||
plAgePage *FindPage( const char *name ) const;
|
||||
bool FindLocation(const plLocation& loc) const;
|
||||
plLocation CalcPageLocation( const char *page ) const;
|
||||
|
||||
// Getters
|
||||
short GetStartMonth() const { return fStart.GetMonth(); }
|
||||
short GetStartDay() const { return fStart.GetDay(); }
|
||||
short GetStartYear() const { return fStart.GetYear(); }
|
||||
short GetStartHour() const { return fStart.GetHour(); }
|
||||
short GetStartMinute() const { return fStart.GetMinute(); }
|
||||
short GetStartSecond() const { return fStart.GetSecond(); }
|
||||
short GetMaxCapacity() const { return fMaxCapacity; }
|
||||
short GetLingerTime() const { return fLingerTime;}
|
||||
|
||||
float GetDayLength() const { return fDayLength; }
|
||||
|
||||
Int32 GetSequencePrefix( void ) const { return fSeqPrefix; }
|
||||
UInt32 GetReleaseVersion( void ) const { return fReleaseVersion; }
|
||||
hsBool IsGlobalAge( void ) const { return ( fSeqPrefix < 0 ) ? true : false; }
|
||||
|
||||
// Setters
|
||||
hsBool SetStart(short year, short month, short day, short hour, short minute, short second)
|
||||
{ return fStart.SetTime(year,month,day,hour,minute,second); }
|
||||
|
||||
void SetDayLength(const float l) { fDayLength = l; }
|
||||
void SetMaxCapacity(const short m) { fMaxCapacity=m; }
|
||||
void SetLingerTime(const short v) { fLingerTime=v;}
|
||||
void SetSequencePrefix( Int32 p ) { fSeqPrefix = p; }
|
||||
void SetReleaseVersion( UInt32 v ) { fReleaseVersion = v; }
|
||||
|
||||
// calculations
|
||||
double GetAgeElapsedDays(plUnifiedTime earthCurrentTime) const;
|
||||
double GetAgeElapsedSeconds(const plUnifiedTime & earthCurrentTime) const;
|
||||
int GetAgeTimeOfDaySecs(const plUnifiedTime& earthCurrentTime) const;
|
||||
float GetAgeTimeOfDayPercent(const plUnifiedTime& earthCurrentTime) const;
|
||||
|
||||
// Static functions for the available common pages
|
||||
enum CommonPages
|
||||
{
|
||||
kTextures = 0,
|
||||
kGlobal,
|
||||
kNumCommonPages
|
||||
};
|
||||
|
||||
static const char *GetCommonPage( int pageType );
|
||||
|
||||
void AppendCommonPages( void );
|
||||
void CopyFrom(const plAgeDescription& other);
|
||||
|
||||
plAgeDescription &operator=( const plAgeDescription &src )
|
||||
{
|
||||
CopyFrom( src );
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //PL_AGE_DESCRIPTION_H
|
||||
/*==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/>.
|
||||
|
||||
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==*/
|
||||
#ifndef PL_AGE_DESCRIPTION_H
|
||||
#define PL_AGE_DESCRIPTION_H
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsUtils.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "pnKeyedObject/plUoid.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
|
||||
//
|
||||
// Age Definition File Reader/Writer
|
||||
//
|
||||
class hsStream;
|
||||
|
||||
class plAgePage
|
||||
{
|
||||
protected:
|
||||
char *fName;
|
||||
UInt32 fSeqSuffix;
|
||||
Byte fFlags;
|
||||
|
||||
public:
|
||||
|
||||
static const UInt32 kInvalidSeqSuffix;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
kPreventAutoLoad = 0x01,
|
||||
kLoadIfSDLPresent = 0x02,
|
||||
kIsLocalOnly = 0x04,
|
||||
kIsVolatile = 0x08,
|
||||
};
|
||||
|
||||
plAgePage( const char *name, UInt32 seqSuffix, Byte flags );
|
||||
plAgePage( char *stringFrom );
|
||||
plAgePage( const plAgePage &src );
|
||||
plAgePage();
|
||||
~plAgePage();
|
||||
|
||||
const char *GetName( void ) const { return fName; }
|
||||
UInt32 GetSeqSuffix( void ) const { return fSeqSuffix; }
|
||||
Byte GetFlags( void ) const { return fFlags; }
|
||||
|
||||
void SetSeqSuffix( UInt32 s ) { fSeqSuffix = s; }
|
||||
void SetFlags(Byte f, bool on=true);
|
||||
|
||||
hsBool SetFromString( const char *string );
|
||||
char *GetAsString( void ) const;
|
||||
|
||||
plAgePage &operator=( const plAgePage &src );
|
||||
};
|
||||
|
||||
// Derived from plInitSectionTokenReader so we can do nifty things with reading the files
|
||||
|
||||
class plAgeDescription : public plInitSectionTokenReader
|
||||
{
|
||||
private:
|
||||
|
||||
char *fName;
|
||||
|
||||
Int32 fPageIterator;
|
||||
hsTArray<plAgePage> fPages;
|
||||
|
||||
plUnifiedTime fStart;
|
||||
|
||||
float fDayLength;
|
||||
short fMaxCapacity;
|
||||
short fLingerTime; // seconds game instance should linger after last player leaves. -1 means never exit.
|
||||
|
||||
Int32 fSeqPrefix;
|
||||
UInt32 fReleaseVersion; // 0 for pre-release, 1+ for actual released ages
|
||||
|
||||
static char *fCommonPages[];
|
||||
|
||||
void IInit( void );
|
||||
void IDeInit( void );
|
||||
|
||||
// Overload for plInitSectionTokenReader
|
||||
virtual hsBool IParseToken( const char *token, hsStringTokenizer *tokenizer, UInt32 userData );
|
||||
|
||||
public:
|
||||
static char kAgeDescPath[];
|
||||
|
||||
plAgeDescription();
|
||||
plAgeDescription( const char *fileNameToReadFrom );
|
||||
plAgeDescription( const plAgeDescription &src )
|
||||
{
|
||||
IInit();
|
||||
CopyFrom( src );
|
||||
}
|
||||
~plAgeDescription();
|
||||
|
||||
bool ReadFromFile( const char *fileNameToReadFrom ) ;
|
||||
void Read(hsStream* stream);
|
||||
void Write(hsStream* stream) const;
|
||||
|
||||
// Overload for plInitSectionTokenReader
|
||||
virtual const char *GetSectionName( void ) const;
|
||||
|
||||
const char *GetAgeName( void ) const { return fName; }
|
||||
void SetAgeNameFromPath( const char *path );
|
||||
void SetAgeName(const char* ageName) { delete [] fName; fName=hsStrcpy(ageName); }
|
||||
|
||||
// Page list
|
||||
void ClearPageList();
|
||||
void RemovePage( const char *page );
|
||||
void AppendPage( const char *name, int seqSuffix = -1, Byte flags = 0 );
|
||||
|
||||
void SeekFirstPage( void );
|
||||
plAgePage *GetNextPage( void );
|
||||
int GetNumPages() const { return fPages.GetCount(); }
|
||||
plAgePage *FindPage( const char *name ) const;
|
||||
bool FindLocation(const plLocation& loc) const;
|
||||
plLocation CalcPageLocation( const char *page ) const;
|
||||
|
||||
// Getters
|
||||
short GetStartMonth() const { return fStart.GetMonth(); }
|
||||
short GetStartDay() const { return fStart.GetDay(); }
|
||||
short GetStartYear() const { return fStart.GetYear(); }
|
||||
short GetStartHour() const { return fStart.GetHour(); }
|
||||
short GetStartMinute() const { return fStart.GetMinute(); }
|
||||
short GetStartSecond() const { return fStart.GetSecond(); }
|
||||
short GetMaxCapacity() const { return fMaxCapacity; }
|
||||
short GetLingerTime() const { return fLingerTime;}
|
||||
|
||||
float GetDayLength() const { return fDayLength; }
|
||||
|
||||
Int32 GetSequencePrefix( void ) const { return fSeqPrefix; }
|
||||
UInt32 GetReleaseVersion( void ) const { return fReleaseVersion; }
|
||||
hsBool IsGlobalAge( void ) const { return ( fSeqPrefix < 0 ) ? true : false; }
|
||||
|
||||
// Setters
|
||||
hsBool SetStart(short year, short month, short day, short hour, short minute, short second)
|
||||
{ return fStart.SetTime(year,month,day,hour,minute,second); }
|
||||
|
||||
void SetDayLength(const float l) { fDayLength = l; }
|
||||
void SetMaxCapacity(const short m) { fMaxCapacity=m; }
|
||||
void SetLingerTime(const short v) { fLingerTime=v;}
|
||||
void SetSequencePrefix( Int32 p ) { fSeqPrefix = p; }
|
||||
void SetReleaseVersion( UInt32 v ) { fReleaseVersion = v; }
|
||||
|
||||
// calculations
|
||||
double GetAgeElapsedDays(plUnifiedTime earthCurrentTime) const;
|
||||
double GetAgeElapsedSeconds(const plUnifiedTime & earthCurrentTime) const;
|
||||
int GetAgeTimeOfDaySecs(const plUnifiedTime& earthCurrentTime) const;
|
||||
float GetAgeTimeOfDayPercent(const plUnifiedTime& earthCurrentTime) const;
|
||||
|
||||
// Static functions for the available common pages
|
||||
enum CommonPages
|
||||
{
|
||||
kTextures = 0,
|
||||
kGlobal,
|
||||
kNumCommonPages
|
||||
};
|
||||
|
||||
static const char *GetCommonPage( int pageType );
|
||||
|
||||
void AppendCommonPages( void );
|
||||
void CopyFrom(const plAgeDescription& other);
|
||||
|
||||
plAgeDescription &operator=( const plAgeDescription &src )
|
||||
{
|
||||
CopyFrom( src );
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //PL_AGE_DESCRIPTION_H
|
||||
|
@ -1,248 +1,248 @@
|
||||
/*==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/>.
|
||||
|
||||
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==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plManifest - Collection of version-specific info about an age, such //
|
||||
// as the actual files constructing it, timestamps, and //
|
||||
// release versions. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plAgeManifest.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plFileUtils.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
#include "hsStringTokenizer.h"
|
||||
|
||||
|
||||
//// plManifestFile ///////////////////////////////////////////////////////
|
||||
|
||||
plManifestFile::plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, UInt32 size, UInt32 zippedSize, UInt32 flags, bool md5Now) :
|
||||
fChecksum(check),
|
||||
fSize(size),
|
||||
fZippedSize(zippedSize),
|
||||
fFlags(flags),
|
||||
fMd5Checked(md5Now)
|
||||
{
|
||||
fName = name;
|
||||
fServerPath = serverPath;
|
||||
|
||||
if (md5Now)
|
||||
{
|
||||
DoMd5Check();
|
||||
}
|
||||
}
|
||||
|
||||
plManifestFile::~plManifestFile()
|
||||
{
|
||||
}
|
||||
|
||||
void plManifestFile::DoMd5Check()
|
||||
{
|
||||
if (plFileUtils::FileExists(fName.c_str()))
|
||||
{
|
||||
plMD5Checksum localFile(fName.c_str());
|
||||
fIsLocalUpToDate = (localFile == fChecksum);
|
||||
fLocalExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fIsLocalUpToDate = false;
|
||||
fLocalExists = false;
|
||||
}
|
||||
|
||||
fMd5Checked = true;
|
||||
}
|
||||
|
||||
bool plManifestFile::IsLocalUpToDate()
|
||||
{
|
||||
if (!fMd5Checked)
|
||||
DoMd5Check();
|
||||
|
||||
return fIsLocalUpToDate;
|
||||
}
|
||||
|
||||
bool plManifestFile::LocalExists()
|
||||
{
|
||||
if (!fMd5Checked)
|
||||
DoMd5Check();
|
||||
|
||||
return fLocalExists;
|
||||
}
|
||||
|
||||
//// plManifest ///////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* plManifest::fTimeFormat = "%m/%d/%y %H:%M:%S";
|
||||
static const UInt32 kLatestFormatVersion = 5;
|
||||
|
||||
plManifest::plManifest()
|
||||
{
|
||||
fFormatVersion = kLatestFormatVersion;
|
||||
fAgeName = nil;
|
||||
}
|
||||
|
||||
plManifest::~plManifest()
|
||||
{
|
||||
IReset();
|
||||
}
|
||||
|
||||
void plManifest::IReset()
|
||||
{
|
||||
fFormatVersion = 0;
|
||||
|
||||
delete [] fAgeName;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < fFiles.GetCount(); i++)
|
||||
delete fFiles[i];
|
||||
fFiles.Reset();
|
||||
}
|
||||
|
||||
//// Read and helpers ////////////////////////////////////////////////////////
|
||||
|
||||
class plVersSection : public plInitSectionTokenReader
|
||||
{
|
||||
protected:
|
||||
plManifest* fDest;
|
||||
|
||||
virtual const char* GetSectionName() const { return "version"; }
|
||||
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, UInt32 userData)
|
||||
{
|
||||
if (stricmp(token, "format") == 0)
|
||||
fDest->SetFormatVersion(atoi(tokenizer->next()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
plVersSection(plManifest* dest) : plInitSectionTokenReader(), fDest(dest) {}
|
||||
};
|
||||
|
||||
class plGenericSection : public plInitSectionTokenReader
|
||||
{
|
||||
protected:
|
||||
plManifest* fDest;
|
||||
|
||||
virtual void AddFile(plManifestFile* file) = 0;
|
||||
|
||||
plManifestFile* IReadManifestFile(const char* token, hsStringTokenizer* tokenizer, UInt32 userData, bool isPage)
|
||||
{
|
||||
char name[256];
|
||||
strcpy(name, token);
|
||||
UInt32 size = atoi(tokenizer->next());
|
||||
plMD5Checksum sum;
|
||||
sum.SetFromHexString(tokenizer->next());
|
||||
UInt32 flags = atoi(tokenizer->next());
|
||||
UInt32 zippedSize = 0;
|
||||
if (hsCheckBits(flags, plManifestFile::kFlagZipped))
|
||||
zippedSize = atoi(tokenizer->next());
|
||||
|
||||
return TRACKED_NEW plManifestFile(name, "", sum, size, zippedSize, flags);
|
||||
}
|
||||
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, UInt32 userData)
|
||||
{
|
||||
plManifestFile* file = IReadManifestFile(token, tokenizer, userData, false);
|
||||
AddFile(file);
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
plGenericSection(plManifest* dest) : plInitSectionTokenReader(), fDest(dest) {}
|
||||
};
|
||||
|
||||
class plBaseSection : public plGenericSection
|
||||
{
|
||||
public:
|
||||
plBaseSection(plManifest* dest) : plGenericSection(dest) {}
|
||||
|
||||
protected:
|
||||
virtual void AddFile(plManifestFile* file) { fDest->AddFile(file); }
|
||||
virtual const char* GetSectionName() const { return "base"; }
|
||||
};
|
||||
|
||||
|
||||
bool plManifest::Read(hsStream* stream)
|
||||
{
|
||||
plVersSection versReader(this);
|
||||
plBaseSection baseReader(this);
|
||||
|
||||
plInitSectionReader* readers[] = { &versReader, &baseReader, nil };
|
||||
|
||||
plInitFileReader reader(readers, 4096); // Allow extra long lines
|
||||
reader.SetUnhandledSectionReader(&baseReader);
|
||||
|
||||
// manifests don't need to be encrypted
|
||||
reader.SetRequireEncrypted(false);
|
||||
|
||||
if (!reader.Open(stream))
|
||||
return false;
|
||||
|
||||
// Clear out before we read
|
||||
IReset();
|
||||
|
||||
if (!reader.Parse())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool plManifest::Read(const char* filename)
|
||||
{
|
||||
plVersSection versReader(this);
|
||||
plBaseSection baseReader(this);
|
||||
|
||||
plInitSectionReader* readers[] = { &versReader, &baseReader, nil };
|
||||
|
||||
plInitFileReader reader(readers, 4096); // Allow extra long lines
|
||||
reader.SetUnhandledSectionReader(&baseReader);
|
||||
|
||||
// manifests don't need to be encrypted
|
||||
reader.SetRequireEncrypted(false);
|
||||
|
||||
if (!reader.Open(filename))
|
||||
return false;
|
||||
|
||||
// Clear out before we read
|
||||
IReset();
|
||||
|
||||
if (!reader.Parse())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void plManifest::AddFile(plManifestFile* file)
|
||||
{
|
||||
fFiles.Append(file);
|
||||
}
|
||||
|
||||
/*==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/>.
|
||||
|
||||
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==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plManifest - Collection of version-specific info about an age, such //
|
||||
// as the actual files constructing it, timestamps, and //
|
||||
// release versions. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plAgeManifest.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plFileUtils.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
#include "hsStringTokenizer.h"
|
||||
|
||||
|
||||
//// plManifestFile ///////////////////////////////////////////////////////
|
||||
|
||||
plManifestFile::plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, UInt32 size, UInt32 zippedSize, UInt32 flags, bool md5Now) :
|
||||
fChecksum(check),
|
||||
fSize(size),
|
||||
fZippedSize(zippedSize),
|
||||
fFlags(flags),
|
||||
fMd5Checked(md5Now)
|
||||
{
|
||||
fName = name;
|
||||
fServerPath = serverPath;
|
||||
|
||||
if (md5Now)
|
||||
{
|
||||
DoMd5Check();
|
||||
}
|
||||
}
|
||||
|
||||
plManifestFile::~plManifestFile()
|
||||
{
|
||||
}
|
||||
|
||||
void plManifestFile::DoMd5Check()
|
||||
{
|
||||
if (plFileUtils::FileExists(fName.c_str()))
|
||||
{
|
||||
plMD5Checksum localFile(fName.c_str());
|
||||
fIsLocalUpToDate = (localFile == fChecksum);
|
||||
fLocalExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fIsLocalUpToDate = false;
|
||||
fLocalExists = false;
|
||||
}
|
||||
|
||||
fMd5Checked = true;
|
||||
}
|
||||
|
||||
bool plManifestFile::IsLocalUpToDate()
|
||||
{
|
||||
if (!fMd5Checked)
|
||||
DoMd5Check();
|
||||
|
||||
return fIsLocalUpToDate;
|
||||
}
|
||||
|
||||
bool plManifestFile::LocalExists()
|
||||
{
|
||||
if (!fMd5Checked)
|
||||
DoMd5Check();
|
||||
|
||||
return fLocalExists;
|
||||
}
|
||||
|
||||
//// plManifest ///////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* plManifest::fTimeFormat = "%m/%d/%y %H:%M:%S";
|
||||
static const UInt32 kLatestFormatVersion = 5;
|
||||
|
||||
plManifest::plManifest()
|
||||
{
|
||||
fFormatVersion = kLatestFormatVersion;
|
||||
fAgeName = nil;
|
||||
}
|
||||
|
||||
plManifest::~plManifest()
|
||||
{
|
||||
IReset();
|
||||
}
|
||||
|
||||
void plManifest::IReset()
|
||||
{
|
||||
fFormatVersion = 0;
|
||||
|
||||
delete [] fAgeName;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < fFiles.GetCount(); i++)
|
||||
delete fFiles[i];
|
||||
fFiles.Reset();
|
||||
}
|
||||
|
||||
//// Read and helpers ////////////////////////////////////////////////////////
|
||||
|
||||
class plVersSection : public plInitSectionTokenReader
|
||||
{
|
||||
protected:
|
||||
plManifest* fDest;
|
||||
|
||||
virtual const char* GetSectionName() const { return "version"; }
|
||||
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, UInt32 userData)
|
||||
{
|
||||
if (stricmp(token, "format") == 0)
|
||||
fDest->SetFormatVersion(atoi(tokenizer->next()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
plVersSection(plManifest* dest) : plInitSectionTokenReader(), fDest(dest) {}
|
||||
};
|
||||
|
||||
class plGenericSection : public plInitSectionTokenReader
|
||||
{
|
||||
protected:
|
||||
plManifest* fDest;
|
||||
|
||||
virtual void AddFile(plManifestFile* file) = 0;
|
||||
|
||||
plManifestFile* IReadManifestFile(const char* token, hsStringTokenizer* tokenizer, UInt32 userData, bool isPage)
|
||||
{
|
||||
char name[256];
|
||||
strcpy(name, token);
|
||||
UInt32 size = atoi(tokenizer->next());
|
||||
plMD5Checksum sum;
|
||||
sum.SetFromHexString(tokenizer->next());
|
||||
UInt32 flags = atoi(tokenizer->next());
|
||||
UInt32 zippedSize = 0;
|
||||
if (hsCheckBits(flags, plManifestFile::kFlagZipped))
|
||||
zippedSize = atoi(tokenizer->next());
|
||||
|
||||
return TRACKED_NEW plManifestFile(name, "", sum, size, zippedSize, flags);
|
||||
}
|
||||
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, UInt32 userData)
|
||||
{
|
||||
plManifestFile* file = IReadManifestFile(token, tokenizer, userData, false);
|
||||
AddFile(file);
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
plGenericSection(plManifest* dest) : plInitSectionTokenReader(), fDest(dest) {}
|
||||
};
|
||||
|
||||
class plBaseSection : public plGenericSection
|
||||
{
|
||||
public:
|
||||
plBaseSection(plManifest* dest) : plGenericSection(dest) {}
|
||||
|
||||
protected:
|
||||
virtual void AddFile(plManifestFile* file) { fDest->AddFile(file); }
|
||||
virtual const char* GetSectionName() const { return "base"; }
|
||||
};
|
||||
|
||||
|
||||
bool plManifest::Read(hsStream* stream)
|
||||
{
|
||||
plVersSection versReader(this);
|
||||
plBaseSection baseReader(this);
|
||||
|
||||
plInitSectionReader* readers[] = { &versReader, &baseReader, nil };
|
||||
|
||||
plInitFileReader reader(readers, 4096); // Allow extra long lines
|
||||
reader.SetUnhandledSectionReader(&baseReader);
|
||||
|
||||
// manifests don't need to be encrypted
|
||||
reader.SetRequireEncrypted(false);
|
||||
|
||||
if (!reader.Open(stream))
|
||||
return false;
|
||||
|
||||
// Clear out before we read
|
||||
IReset();
|
||||
|
||||
if (!reader.Parse())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool plManifest::Read(const char* filename)
|
||||
{
|
||||
plVersSection versReader(this);
|
||||
plBaseSection baseReader(this);
|
||||
|
||||
plInitSectionReader* readers[] = { &versReader, &baseReader, nil };
|
||||
|
||||
plInitFileReader reader(readers, 4096); // Allow extra long lines
|
||||
reader.SetUnhandledSectionReader(&baseReader);
|
||||
|
||||
// manifests don't need to be encrypted
|
||||
reader.SetRequireEncrypted(false);
|
||||
|
||||
if (!reader.Open(filename))
|
||||
return false;
|
||||
|
||||
// Clear out before we read
|
||||
IReset();
|
||||
|
||||
if (!reader.Parse())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void plManifest::AddFile(plManifestFile* file)
|
||||
{
|
||||
fFiles.Append(file);
|
||||
}
|
||||
|
||||
|
@ -1,118 +1,118 @@
|
||||
/*==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/>.
|
||||
|
||||
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==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plAgeManifest - Collection of version-specific info about an age, such //
|
||||
// as the actual files constructing it, timestamps, and //
|
||||
// release versions. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _plAgeManifest_h
|
||||
#define _plAgeManifest_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsUtils.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
#include "plEncryption/plChecksum.h"
|
||||
|
||||
|
||||
//// Small Container Classes for a Single File ///////////////////////////////
|
||||
|
||||
class plManifestFile
|
||||
{
|
||||
protected:
|
||||
std::string fName;
|
||||
std::string fServerPath;
|
||||
plMD5Checksum fChecksum;
|
||||
UInt32 fSize;
|
||||
UInt32 fZippedSize;
|
||||
UInt32 fFlags;
|
||||
|
||||
bool fMd5Checked;
|
||||
bool fIsLocalUpToDate;
|
||||
bool fLocalExists;
|
||||
|
||||
public:
|
||||
// fUser flags
|
||||
enum
|
||||
{
|
||||
// Sound files only
|
||||
kSndFlagCacheSplit = 1<<0,
|
||||
kSndFlagStreamCompressed = 1<<1,
|
||||
kSndFlagCacheStereo = 1<<2,
|
||||
// Any file
|
||||
kFlagZipped = 1<<3,
|
||||
};
|
||||
|
||||
plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, UInt32 size, UInt32 zippedSize, UInt32 flags, bool md5Now = true);
|
||||
virtual ~plManifestFile();
|
||||
|
||||
const char* GetName() const { return fName.c_str(); }
|
||||
const char* GetServerPath() const { return fServerPath.c_str(); }
|
||||
const plMD5Checksum& GetChecksum() const { return fChecksum; }
|
||||
UInt32 GetDiskSize() const { return fSize; }
|
||||
UInt32 GetDownloadSize() const { return hsCheckBits(fFlags, kFlagZipped) ? fZippedSize : fSize; }
|
||||
UInt32 GetFlags() const { return fFlags; }
|
||||
|
||||
void DoMd5Check();
|
||||
bool IsLocalUpToDate();
|
||||
bool LocalExists();
|
||||
};
|
||||
|
||||
//// Actual Manifest Class ///////////////////////////////////////////////////
|
||||
|
||||
class plManifest
|
||||
{
|
||||
protected:
|
||||
UInt32 fFormatVersion;
|
||||
char* fAgeName; // Mostly just for debugging
|
||||
|
||||
hsTArray<plManifestFile*> fFiles;
|
||||
|
||||
void IReset();
|
||||
|
||||
public:
|
||||
static char* fTimeFormat; // Standard string for the printed version of our timestamps
|
||||
|
||||
void SetFormatVersion(UInt32 v) { fFormatVersion = v; }
|
||||
void AddFile(plManifestFile* file);
|
||||
|
||||
plManifest();
|
||||
virtual ~plManifest();
|
||||
|
||||
bool Read(const char* filename);
|
||||
bool Read(hsStream* stream);
|
||||
|
||||
UInt32 GetFormatVersion() const { return fFormatVersion; }
|
||||
|
||||
UInt32 GetNumFiles() const { return fFiles.GetCount(); }
|
||||
const plManifestFile& GetFile(UInt32 i) const { return *fFiles[i]; }
|
||||
};
|
||||
|
||||
#endif //_plAgeManifest_h
|
||||
/*==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/>.
|
||||
|
||||
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==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plAgeManifest - Collection of version-specific info about an age, such //
|
||||
// as the actual files constructing it, timestamps, and //
|
||||
// release versions. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _plAgeManifest_h
|
||||
#define _plAgeManifest_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsUtils.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
#include "plEncryption/plChecksum.h"
|
||||
|
||||
|
||||
//// Small Container Classes for a Single File ///////////////////////////////
|
||||
|
||||
class plManifestFile
|
||||
{
|
||||
protected:
|
||||
std::string fName;
|
||||
std::string fServerPath;
|
||||
plMD5Checksum fChecksum;
|
||||
UInt32 fSize;
|
||||
UInt32 fZippedSize;
|
||||
UInt32 fFlags;
|
||||
|
||||
bool fMd5Checked;
|
||||
bool fIsLocalUpToDate;
|
||||
bool fLocalExists;
|
||||
|
||||
public:
|
||||
// fUser flags
|
||||
enum
|
||||
{
|
||||
// Sound files only
|
||||
kSndFlagCacheSplit = 1<<0,
|
||||
kSndFlagStreamCompressed = 1<<1,
|
||||
kSndFlagCacheStereo = 1<<2,
|
||||
// Any file
|
||||
kFlagZipped = 1<<3,
|
||||
};
|
||||
|
||||
plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, UInt32 size, UInt32 zippedSize, UInt32 flags, bool md5Now = true);
|
||||
virtual ~plManifestFile();
|
||||
|
||||
const char* GetName() const { return fName.c_str(); }
|
||||
const char* GetServerPath() const { return fServerPath.c_str(); }
|
||||
const plMD5Checksum& GetChecksum() const { return fChecksum; }
|
||||
UInt32 GetDiskSize() const { return fSize; }
|
||||
UInt32 GetDownloadSize() const { return hsCheckBits(fFlags, kFlagZipped) ? fZippedSize : fSize; }
|
||||
UInt32 GetFlags() const { return fFlags; }
|
||||
|
||||
void DoMd5Check();
|
||||
bool IsLocalUpToDate();
|
||||
bool LocalExists();
|
||||
};
|
||||
|
||||
//// Actual Manifest Class ///////////////////////////////////////////////////
|
||||
|
||||
class plManifest
|
||||
{
|
||||
protected:
|
||||
UInt32 fFormatVersion;
|
||||
char* fAgeName; // Mostly just for debugging
|
||||
|
||||
hsTArray<plManifestFile*> fFiles;
|
||||
|
||||
void IReset();
|
||||
|
||||
public:
|
||||
static char* fTimeFormat; // Standard string for the printed version of our timestamps
|
||||
|
||||
void SetFormatVersion(UInt32 v) { fFormatVersion = v; }
|
||||
void AddFile(plManifestFile* file);
|
||||
|
||||
plManifest();
|
||||
virtual ~plManifest();
|
||||
|
||||
bool Read(const char* filename);
|
||||
bool Read(hsStream* stream);
|
||||
|
||||
UInt32 GetFormatVersion() const { return fFormatVersion; }
|
||||
|
||||
UInt32 GetNumFiles() const { return fFiles.GetCount(); }
|
||||
const plManifestFile& GetFile(UInt32 i) const { return *fFiles[i]; }
|
||||
};
|
||||
|
||||
#endif //_plAgeManifest_h
|
||||
|
Reference in New Issue
Block a user