mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
Convert custom HeadSpin integer types to standard types from stdint.h
This commit is contained in:
@ -52,9 +52,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
const UInt32 plAgePage::kInvalidSeqSuffix = (UInt32)-1;
|
||||
const uint32_t plAgePage::kInvalidSeqSuffix = (uint32_t)-1;
|
||||
|
||||
plAgePage::plAgePage( const char *name, UInt32 seqSuffix, Byte flags )
|
||||
plAgePage::plAgePage( const char *name, uint32_t seqSuffix, uint8_t flags )
|
||||
{
|
||||
fName = name != nil ? hsStrcpy( name ) : nil;
|
||||
fSeqSuffix = seqSuffix;
|
||||
@ -95,7 +95,7 @@ plAgePage &plAgePage::operator=( const plAgePage &src )
|
||||
return *this;
|
||||
}
|
||||
|
||||
void plAgePage::SetFlags(Byte f, bool on)
|
||||
void plAgePage::SetFlags(uint8_t f, bool on)
|
||||
{
|
||||
if (on)
|
||||
hsSetBits(fFlags, f);
|
||||
@ -256,9 +256,9 @@ void plAgeDescription::ClearPageList()
|
||||
}
|
||||
|
||||
|
||||
void plAgeDescription::AppendPage( const char *name, int seqSuffix, Byte flags )
|
||||
void plAgeDescription::AppendPage( const char *name, int seqSuffix, uint8_t flags )
|
||||
{
|
||||
fPages.Append( plAgePage( name, ( seqSuffix == -1 ) ? fPages.GetCount() : (UInt32)seqSuffix, flags ) );
|
||||
fPages.Append( plAgePage( name, ( seqSuffix == -1 ) ? fPages.GetCount() : (uint32_t)seqSuffix, flags ) );
|
||||
}
|
||||
|
||||
void plAgeDescription::SeekFirstPage( void )
|
||||
@ -315,23 +315,23 @@ plLocation plAgeDescription::CalcPageLocation( const char *page ) const
|
||||
if( ap != nil )
|
||||
{
|
||||
// Combine our sequence # together
|
||||
Int32 combined;
|
||||
hsAssert(fSeqPrefix > -255 && fSeqPrefix <= 0xFEFF, "Age sequence prefex is out of range!"); // sequence prefix can NOT be larger or equal to 1-byte max value
|
||||
UInt32 suffix = ap->GetSeqSuffix();
|
||||
hsAssert(suffix <= 0xFFFF, "Page sequence number is out of range!"); // page sequence number can NOT be larger then 2-byte max value
|
||||
int32_t combined;
|
||||
hsAssert(fSeqPrefix > -255 && fSeqPrefix <= 0xFEFF, "Age sequence prefex is out of range!"); // sequence prefix can NOT be larger or equal to 1-uint8_t max value
|
||||
uint32_t suffix = ap->GetSeqSuffix();
|
||||
hsAssert(suffix <= 0xFFFF, "Page sequence number is out of range!"); // page sequence number can NOT be larger then 2-uint8_t max value
|
||||
if( fSeqPrefix < 0 ) // we are a global age
|
||||
combined = -(Int32)( ( ( -fSeqPrefix ) << 16 ) + suffix );
|
||||
combined = -(int32_t)( ( ( -fSeqPrefix ) << 16 ) + suffix );
|
||||
else
|
||||
combined = ( fSeqPrefix << 16 ) + suffix;
|
||||
|
||||
// Now, our 32 bit number looks like the following:
|
||||
// 0xRRAAPPPP
|
||||
// - RR is FF when reserved, and 00-FE when normal
|
||||
// - AA is the low byte of the age sequence prefix (FF not allowed on a negative prefix because 0xFFFFFFFFFF is reserved for invalid sequence number)
|
||||
// - AA is the low uint8_t of the age sequence prefix (FF not allowed on a negative prefix because 0xFFFFFFFFFF is reserved for invalid sequence number)
|
||||
// - PPPP is the two bytes for page sequence number
|
||||
|
||||
if( IsGlobalAge() )
|
||||
return plLocation::MakeReserved( (UInt32)combined );
|
||||
return plLocation::MakeReserved( (uint32_t)combined );
|
||||
else
|
||||
{
|
||||
plLocation ret = plLocation::MakeNormal( combined );
|
||||
@ -396,7 +396,7 @@ const char *plAgeDescription::GetSectionName( void ) const
|
||||
return "AgeInfo";
|
||||
}
|
||||
|
||||
hsBool plAgeDescription::IParseToken( const char *token, hsStringTokenizer *tokenizer, UInt32 userData )
|
||||
hsBool plAgeDescription::IParseToken( const char *token, hsStringTokenizer *tokenizer, uint32_t userData )
|
||||
{
|
||||
char *tok;
|
||||
|
||||
@ -525,7 +525,7 @@ const char *plAgeDescription::GetCommonPage( int pageType )
|
||||
|
||||
void plAgeDescription::AppendCommonPages( void )
|
||||
{
|
||||
UInt32 startSuffix = 0xffff, i;
|
||||
uint32_t startSuffix = 0xffff, i;
|
||||
|
||||
|
||||
if( IsGlobalAge() )
|
||||
|
@ -58,12 +58,12 @@ class plAgePage
|
||||
{
|
||||
protected:
|
||||
char *fName;
|
||||
UInt32 fSeqSuffix;
|
||||
Byte fFlags;
|
||||
uint32_t fSeqSuffix;
|
||||
uint8_t fFlags;
|
||||
|
||||
public:
|
||||
|
||||
static const UInt32 kInvalidSeqSuffix;
|
||||
static const uint32_t kInvalidSeqSuffix;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
@ -73,18 +73,18 @@ class plAgePage
|
||||
kIsVolatile = 0x08,
|
||||
};
|
||||
|
||||
plAgePage( const char *name, UInt32 seqSuffix, Byte flags );
|
||||
plAgePage( const char *name, uint32_t seqSuffix, uint8_t 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; }
|
||||
uint32_t GetSeqSuffix( void ) const { return fSeqSuffix; }
|
||||
uint8_t GetFlags( void ) const { return fFlags; }
|
||||
|
||||
void SetSeqSuffix( UInt32 s ) { fSeqSuffix = s; }
|
||||
void SetFlags(Byte f, bool on=true);
|
||||
void SetSeqSuffix( uint32_t s ) { fSeqSuffix = s; }
|
||||
void SetFlags(uint8_t f, bool on=true);
|
||||
|
||||
hsBool SetFromString( const char *string );
|
||||
char *GetAsString( void ) const;
|
||||
@ -100,7 +100,7 @@ private:
|
||||
|
||||
char *fName;
|
||||
|
||||
Int32 fPageIterator;
|
||||
int32_t fPageIterator;
|
||||
hsTArray<plAgePage> fPages;
|
||||
|
||||
plUnifiedTime fStart;
|
||||
@ -109,8 +109,8 @@ private:
|
||||
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
|
||||
int32_t fSeqPrefix;
|
||||
uint32_t fReleaseVersion; // 0 for pre-release, 1+ for actual released ages
|
||||
|
||||
static const char* fCommonPages[];
|
||||
|
||||
@ -118,7 +118,7 @@ private:
|
||||
void IDeInit( void );
|
||||
|
||||
// Overload for plInitSectionTokenReader
|
||||
virtual hsBool IParseToken( const char *token, hsStringTokenizer *tokenizer, UInt32 userData );
|
||||
virtual hsBool IParseToken( const char *token, hsStringTokenizer *tokenizer, uint32_t userData );
|
||||
|
||||
public:
|
||||
static char kAgeDescPath[];
|
||||
@ -146,7 +146,7 @@ public:
|
||||
// Page list
|
||||
void ClearPageList();
|
||||
void RemovePage( const char *page );
|
||||
void AppendPage( const char *name, int seqSuffix = -1, Byte flags = 0 );
|
||||
void AppendPage( const char *name, int seqSuffix = -1, uint8_t flags = 0 );
|
||||
|
||||
void SeekFirstPage( void );
|
||||
plAgePage *GetNextPage( void );
|
||||
@ -167,8 +167,8 @@ public:
|
||||
|
||||
float GetDayLength() const { return fDayLength; }
|
||||
|
||||
Int32 GetSequencePrefix( void ) const { return fSeqPrefix; }
|
||||
UInt32 GetReleaseVersion( void ) const { return fReleaseVersion; }
|
||||
int32_t GetSequencePrefix( void ) const { return fSeqPrefix; }
|
||||
uint32_t GetReleaseVersion( void ) const { return fReleaseVersion; }
|
||||
hsBool IsGlobalAge( void ) const { return ( fSeqPrefix < 0 ) ? true : false; }
|
||||
|
||||
// Setters
|
||||
@ -178,8 +178,8 @@ public:
|
||||
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; }
|
||||
void SetSequencePrefix( int32_t p ) { fSeqPrefix = p; }
|
||||
void SetReleaseVersion( uint32_t v ) { fReleaseVersion = v; }
|
||||
|
||||
// calculations
|
||||
double GetAgeElapsedDays(plUnifiedTime earthCurrentTime) const;
|
||||
|
@ -59,7 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//// plManifestFile ///////////////////////////////////////////////////////
|
||||
|
||||
plManifestFile::plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, UInt32 size, UInt32 zippedSize, UInt32 flags, bool md5Now) :
|
||||
plManifestFile::plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, uint32_t size, uint32_t zippedSize, uint32_t flags, bool md5Now) :
|
||||
fChecksum(check),
|
||||
fSize(size),
|
||||
fZippedSize(zippedSize),
|
||||
@ -117,7 +117,7 @@ bool plManifestFile::LocalExists()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char* plManifest::fTimeFormat = "%m/%d/%y %H:%M:%S";
|
||||
static const UInt32 kLatestFormatVersion = 5;
|
||||
static const uint32_t kLatestFormatVersion = 5;
|
||||
|
||||
plManifest::plManifest()
|
||||
{
|
||||
@ -151,7 +151,7 @@ protected:
|
||||
|
||||
virtual const char* GetSectionName() const { return "version"; }
|
||||
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, UInt32 userData)
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, uint32_t userData)
|
||||
{
|
||||
if (stricmp(token, "format") == 0)
|
||||
fDest->SetFormatVersion(atoi(tokenizer->next()));
|
||||
@ -170,22 +170,22 @@ protected:
|
||||
|
||||
virtual void AddFile(plManifestFile* file) = 0;
|
||||
|
||||
plManifestFile* IReadManifestFile(const char* token, hsStringTokenizer* tokenizer, UInt32 userData, bool isPage)
|
||||
plManifestFile* IReadManifestFile(const char* token, hsStringTokenizer* tokenizer, uint32_t userData, bool isPage)
|
||||
{
|
||||
char name[256];
|
||||
strcpy(name, token);
|
||||
UInt32 size = atoi(tokenizer->next());
|
||||
uint32_t size = atoi(tokenizer->next());
|
||||
plMD5Checksum sum;
|
||||
sum.SetFromHexString(tokenizer->next());
|
||||
UInt32 flags = atoi(tokenizer->next());
|
||||
UInt32 zippedSize = 0;
|
||||
uint32_t flags = atoi(tokenizer->next());
|
||||
uint32_t 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)
|
||||
virtual hsBool IParseToken(const char* token, hsStringTokenizer* tokenizer, uint32_t userData)
|
||||
{
|
||||
plManifestFile* file = IReadManifestFile(token, tokenizer, userData, false);
|
||||
AddFile(file);
|
||||
|
@ -66,9 +66,9 @@ protected:
|
||||
std::string fName;
|
||||
std::string fServerPath;
|
||||
plMD5Checksum fChecksum;
|
||||
UInt32 fSize;
|
||||
UInt32 fZippedSize;
|
||||
UInt32 fFlags;
|
||||
uint32_t fSize;
|
||||
uint32_t fZippedSize;
|
||||
uint32_t fFlags;
|
||||
|
||||
bool fMd5Checked;
|
||||
bool fIsLocalUpToDate;
|
||||
@ -86,15 +86,15 @@ public:
|
||||
kFlagZipped = 1<<3,
|
||||
};
|
||||
|
||||
plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, UInt32 size, UInt32 zippedSize, UInt32 flags, bool md5Now = true);
|
||||
plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, uint32_t size, uint32_t zippedSize, uint32_t 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; }
|
||||
uint32_t GetDiskSize() const { return fSize; }
|
||||
uint32_t GetDownloadSize() const { return hsCheckBits(fFlags, kFlagZipped) ? fZippedSize : fSize; }
|
||||
uint32_t GetFlags() const { return fFlags; }
|
||||
|
||||
void DoMd5Check();
|
||||
bool IsLocalUpToDate();
|
||||
@ -106,7 +106,7 @@ public:
|
||||
class plManifest
|
||||
{
|
||||
protected:
|
||||
UInt32 fFormatVersion;
|
||||
uint32_t fFormatVersion;
|
||||
char* fAgeName; // Mostly just for debugging
|
||||
|
||||
hsTArray<plManifestFile*> fFiles;
|
||||
@ -116,7 +116,7 @@ protected:
|
||||
public:
|
||||
static const char* fTimeFormat; // Standard string for the printed version of our timestamps
|
||||
|
||||
void SetFormatVersion(UInt32 v) { fFormatVersion = v; }
|
||||
void SetFormatVersion(uint32_t v) { fFormatVersion = v; }
|
||||
void AddFile(plManifestFile* file);
|
||||
|
||||
plManifest();
|
||||
@ -125,10 +125,10 @@ public:
|
||||
bool Read(const char* filename);
|
||||
bool Read(hsStream* stream);
|
||||
|
||||
UInt32 GetFormatVersion() const { return fFormatVersion; }
|
||||
uint32_t GetFormatVersion() const { return fFormatVersion; }
|
||||
|
||||
UInt32 GetNumFiles() const { return fFiles.GetCount(); }
|
||||
const plManifestFile& GetFile(UInt32 i) const { return *fFiles[i]; }
|
||||
uint32_t GetNumFiles() const { return fFiles.GetCount(); }
|
||||
const plManifestFile& GetFile(uint32_t i) const { return *fFiles[i]; }
|
||||
};
|
||||
|
||||
#endif //_plAgeManifest_h
|
||||
|
Reference in New Issue
Block a user