1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 18:59:09 +00:00

Convert custom HeadSpin integer types to standard types from stdint.h

This commit is contained in:
2012-01-19 21:19:26 -05:00
parent a0d54e2644
commit 5027b5a4ac
1301 changed files with 14497 additions and 14532 deletions

View File

@ -112,8 +112,8 @@ public:
void SetHintString(const char* c) { fHintString=c; }
const char* GetHintString() const { return fHintString.c_str(); }
void Read(hsStream* s, UInt32 readOptions);
void Write(hsStream* s, UInt32 writeOptions) const;
void Read(hsStream* s, uint32_t readOptions);
void Write(hsStream* s, uint32_t writeOptions) const;
};
//
@ -131,7 +131,7 @@ public:
kUsed = 0x2 // true when it contains some value (either by Set(...) or Read() )
};
protected:
UInt32 fFlags;
uint32_t fFlags;
plStateVarNotificationInfo fNotificationInfo;
public:
plStateVariable() : fFlags(0) {}
@ -164,8 +164,8 @@ public:
virtual void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const {}
// IO
virtual bool ReadData(hsStream* s, float timeConvert, UInt32 readOptions);
virtual bool WriteData(hsStream* s, float timeConvert, UInt32 writeOptions) const;
virtual bool ReadData(hsStream* s, float timeConvert, uint32_t readOptions);
virtual bool WriteData(hsStream* s, float timeConvert, uint32_t writeOptions) const;
};
//
@ -180,7 +180,7 @@ private:
float fDelta;
typedef std::vector<plKey> KeyList;
KeyList fKeys; // the objects to notify on change>delta
static UInt32 fCurrentPlayerID;
static uint32_t fCurrentPlayerID;
void IAddKey(plKey k);
int IRemoveKey(plKey k);
@ -198,8 +198,8 @@ public:
bool GetValue(float* i) const;
bool SetValue(float i);
static UInt32 GetCurrentPlayerID() { return fCurrentPlayerID; }
static void SetCurrentPlayerID(UInt32 p) { fCurrentPlayerID=p; }
static uint32_t GetCurrentPlayerID() { return fCurrentPlayerID; }
static void SetCurrentPlayerID(uint32_t p) { fCurrentPlayerID=p; }
bool operator==(const plStateChangeNotifier &) const;
};
@ -210,7 +210,6 @@ public:
class plUoid;
class plKey;
class plClientUnifiedTime;
typedef unsigned char byte;
class plSimpleStateVariable : public plStateVariable
{
protected:
@ -218,7 +217,7 @@ protected:
{
int* fI; // array of int
short* fS; // array of short
byte* fBy; // array of byte
uint8_t* fBy; // array of byte
float* fF; // array of float
double* fD; // array of double
bool* fB; // array of bool
@ -250,8 +249,8 @@ protected:
bool IConvertFromRGB8(plVarDescriptor::Type newType);
bool IConvertFromRGBA8(plVarDescriptor::Type newType);
bool IReadData(hsStream* s, float timeConvert, int idx, UInt32 readOptions);
bool IWriteData(hsStream* s, float timeConvert, int idx, UInt32 writeOptions) const;
bool IReadData(hsStream* s, float timeConvert, int idx, uint32_t readOptions);
bool IWriteData(hsStream* s, float timeConvert, int idx, uint32_t writeOptions) const;
public:
@ -266,7 +265,7 @@ public:
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() );
void CopyFrom(plVarDescriptor* v);
void CopyData(const plSimpleStateVariable* other, UInt32 writeOptions=0);
void CopyData(const plSimpleStateVariable* other, uint32_t writeOptions=0);
bool SetFromString(const char* value, int idx, bool timeStampNow); // set value from string, type. return false on err
char* GetAsString(int idx) const;
bool ConvertTo(plSimpleVarDescriptor* toVar, bool force=false); // return false on err
@ -280,8 +279,8 @@ public:
bool Set(double* v, int idx=0); // doubleVector
bool Set(int v, int idx=0);
bool Set(int* v, int idx=0) { return Set(*v, idx); } // helper since there is no int vec type
bool Set(byte v, int idx=0);
bool Set(byte* v, int idx=0); // byteVector
bool Set(uint8_t v, int idx=0);
bool Set(uint8_t* v, int idx=0); // uint8_tVector
bool Set(short v, int idx=0);
bool Set(short* v, int idx=0) { return Set(*v, idx); } // helper since there is no short vec type
bool Set(bool v, int idx=0);
@ -294,7 +293,7 @@ public:
// getters
bool Get(int* value, int idx=0) const;
bool Get(short* value, int idx=0) const;
bool Get(byte* value, int idx=0) const; // returns byte or byteVector
bool Get(uint8_t* value, int idx=0) const; // returns uint8_t or uint8_tVector
bool Get(float* value, int idx=0) const; // returns float or floatVector
bool Get(double* value, int idx=0) const; // returns double or doubleVector
bool Get(bool* value, int idx=0) const;
@ -322,8 +321,8 @@ public:
void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const;
// IO
bool ReadData(hsStream* s, float timeConvert, UInt32 readOptions);
bool WriteData(hsStream* s, float timeConvert, UInt32 writeOptions) const;
bool ReadData(hsStream* s, float timeConvert, uint32_t readOptions);
bool WriteData(hsStream* s, float timeConvert, uint32_t writeOptions) const;
};
//
@ -351,8 +350,8 @@ public:
bool operator==(const plSDStateVariable &other) const; // assumes matching var descriptors
void ConvertTo(plSDStateVariable* otherSDVar, bool force=false);
void CopyFrom(plSDStateVariable* other, UInt32 writeOptions=0);
void UpdateFrom(plSDStateVariable* other, UInt32 writeOptions=0);
void CopyFrom(plSDStateVariable* other, uint32_t writeOptions=0);
void UpdateFrom(plSDStateVariable* other, uint32_t writeOptions=0);
void AddStateDataRecord(plStateDataRecord *sdr) { fDataRecList.push_back(sdr); SetDirty(true); SetUsed(true); }
void InsertStateDataRecord(plStateDataRecord *sdr, int i) { fDataRecList[i] = sdr; SetDirty(true); SetUsed(true);}
void SetFromDefaults(bool timeStampNow);
@ -384,8 +383,8 @@ public:
void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const;
// IO
bool ReadData(hsStream* s, float timeConvert, UInt32 readOptions);
bool WriteData(hsStream* s, float timeConvert, UInt32 writeOptions) const;
bool ReadData(hsStream* s, float timeConvert, uint32_t readOptions);
bool WriteData(hsStream* s, float timeConvert, uint32_t writeOptions) const;
};
//
@ -408,8 +407,8 @@ protected:
plUoid fAssocObject; // optional
VarsList fVarsList; // list of variables
VarsList fSDVarsList; // list of nested data records
UInt32 fFlags;
static const UInt8 kIOVersion; // I/O Version
uint32_t fFlags;
static const uint8_t kIOVersion; // I/O Version
void IDeleteVarsList(VarsList& vars);
void IInitDescriptor(const char* name, int version); // or plSDL::kLatestVersion
@ -433,22 +432,22 @@ public:
plStateDataRecord(const char* sdName, int version=plSDL::kLatestVersion);
plStateDataRecord(plStateDescriptor* sd);
plStateDataRecord(const plStateDataRecord &other, UInt32 writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); }
plStateDataRecord(const plStateDataRecord &other, uint32_t writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); }
plStateDataRecord():fFlags(0) {}
~plStateDataRecord();
bool ConvertTo(plStateDescriptor* other, bool force=false );
bool operator==(const plStateDataRecord &other) const; // assumes matching state descriptors
UInt32 GetFlags() const { return fFlags; }
void SetFlags(UInt32 f) { fFlags =f; }
uint32_t GetFlags() const { return fFlags; }
void SetFlags(uint32_t f) { fFlags =f; }
plSimpleStateVariable* FindVar(const char* name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); }
plSDStateVariable* FindSDVar(const char* name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); }
plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; }
void CopyFrom(const plStateDataRecord& other, UInt32 writeOptions=0);
void UpdateFrom(const plStateDataRecord& other, UInt32 writeOptions=0);
void CopyFrom(const plStateDataRecord& other, uint32_t writeOptions=0);
void UpdateFrom(const plStateDataRecord& other, uint32_t writeOptions=0);
void SetFromDefaults(bool timeStampNow);
void TimeStampDirtyVars();
@ -482,7 +481,7 @@ public:
const plStateDescriptor* GetDescriptor() const { return fDescriptor; }
void SetDescriptor(const char* sdName, int version);
plNetMsgSDLState* PrepNetMsg(float timeConvert, UInt32 writeOptions) const; // create/prep a net msg with this data
plNetMsgSDLState* PrepNetMsg(float timeConvert, uint32_t writeOptions) const; // create/prep a net msg with this data
void SetAssocObject(const plUoid& u) { fAssocObject=u; } // optional
plUoid* GetAssocObject() { return &fAssocObject; } // optional
@ -496,8 +495,8 @@ public:
void DumpToStream(hsStream* stream, const char* msg, bool dirtyOnly=false, int level=0) const;
// IO
bool Read(hsStream* s, float timeConvert, UInt32 readOptions=0);
void Write(hsStream* s, float timeConvert, UInt32 writeOptions=0) const;
bool Read(hsStream* s, float timeConvert, uint32_t readOptions=0);
void Write(hsStream* s, float timeConvert, uint32_t writeOptions=0) const;
static bool ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid=nil);
void WriteStreamHeader(hsStream* s, plUoid* objUoid=nil) const;
@ -536,7 +535,7 @@ private:
std::string fSDLDir;
plSDL::DescriptorList fDescriptors;
plNetApp* fNetApp;
UInt32 fBehaviorFlags;
uint32_t fBehaviorFlags;
void IDeleteDescriptors(plSDL::DescriptorList* dl);
public:
@ -554,10 +553,10 @@ public:
void SetNetApp(plNetApp* a) { fNetApp=a; }
plNetApp* GetNetApp() const { return fNetApp; }
bool Init( UInt32 behaviorFlags=0 ); // parse sdl folder
bool Init( uint32_t behaviorFlags=0 ); // parse sdl folder
void DeInit();
UInt32 GetBehaviorFlags() const { return fBehaviorFlags; }
void SetBehaviorFlags(UInt32 v) { fBehaviorFlags=v; }
uint32_t GetBehaviorFlags() const { return fBehaviorFlags; }
void SetBehaviorFlags(uint32_t v) { fBehaviorFlags=v; }
bool AllowTimeStamping() const { return ! ( fBehaviorFlags&plSDL::kDisallowTimeStamping ); }
// I/O - return # of bytes read/written

View File

@ -98,13 +98,13 @@ public:
kVariableLength = 0x4 // Var is defined as int foo[], so it's length is variable, starting at 0
};
protected:
static const UInt8 kVersion; // for Read/Write format
static const uint8_t kVersion; // for Read/Write format
char* fDefault; // set by .sdl
char* fName; // set by .sdl
int fCount; // set by .sdl
Type fType; // set by .sdl
char* fTypeString; // string version of fType
UInt32 fFlags;
uint32_t fFlags;
std::string fDisplayOptions; // set by .sdl
public:
plVarDescriptor();
@ -221,7 +221,7 @@ class plKey;
class plStateDescriptor
{
private:
static const UInt8 kVersion; // for Read/Write format
static const uint8_t kVersion; // for Read/Write format
typedef std::vector<plVarDescriptor*> VarsList;
VarsList fVarsList;
int fVersion;

View File

@ -66,7 +66,7 @@ plSDLMgr::~plSDLMgr()
DeInit();
}
bool plSDLMgr::Init( UInt32 behaviorFlags )
bool plSDLMgr::Init( uint32_t behaviorFlags )
{
fBehaviorFlags = behaviorFlags;
plSDLParser parser;
@ -145,7 +145,7 @@ int plSDLMgr::Write(hsStream* s, const plSDL::DescriptorList* dl)
if (dl==nil)
dl=&fDescriptors;
UInt16 num=dl->size();
uint16_t num=dl->size();
s->WriteLE(num);
plSDL::DescriptorList::const_iterator it;
@ -174,7 +174,7 @@ int plSDLMgr::Read(hsStream* s, plSDL::DescriptorList* dl)
// clear dl
IDeleteDescriptors(dl);
UInt16 num;
uint16_t num;
try
{
// read dtor list

View File

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <algorithm>
// static
UInt32 plStateChangeNotifier::fCurrentPlayerID = 0;
uint32_t plStateChangeNotifier::fCurrentPlayerID = 0;
plStateChangeNotifier::plStateChangeNotifier() :
fDelta(0)

View File

@ -52,7 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
const char* plSDL::kAgeSDLObjectName = {"AgeSDLHook"};
// static
const UInt8 plStateDataRecord::kIOVersion=6;
const uint8_t plStateDataRecord::kIOVersion=6;
//
// helper
@ -234,10 +234,10 @@ bool plStateDataRecord::IHasUsedVars(const VarsList& vars) const
//
// read state vars and indices, return true on success
//
bool plStateDataRecord::Read(hsStream* s, float timeConvert, UInt32 readOptions)
bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOptions)
{
fFlags = s->ReadLE16();
UInt8 ioVersion = s->ReadByte();
uint8_t ioVersion = s->ReadByte();
if (ioVersion != kIOVersion)
return false;
@ -333,7 +333,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, UInt32 readOptions)
//
// write out the state vars, along with their index
//
void plStateDataRecord::Write(hsStream* s, float timeConvert, UInt32 writeOptions) const
void plStateDataRecord::Write(hsStream* s, float timeConvert, uint32_t writeOptions) const
{
#ifdef HS_DEBUGGING
if ( !plSDLMgr::GetInstance()->AllowTimeStamping() && (writeOptions & plSDL::kWriteTimeStamps) )
@ -343,7 +343,7 @@ void plStateDataRecord::Write(hsStream* s, float timeConvert, UInt32 writeOption
}
#endif
s->WriteLE16((UInt16)fFlags);
s->WriteLE16((uint16_t)fFlags);
s->WriteByte(kIOVersion);
//
@ -394,7 +394,7 @@ void plStateDataRecord::Write(hsStream* s, float timeConvert, UInt32 writeOption
//
bool plStateDataRecord::ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid)
{
UInt16 savFlags;
uint16_t savFlags;
s->ReadLE(&savFlags);
if (!(savFlags & plSDL::kAddedVarLengthIO)) // using to establish a new version in the header, can delete in 8/03
{
@ -429,13 +429,13 @@ bool plStateDataRecord::ReadStreamHeader(hsStream* s, char** name, int* version,
//
void plStateDataRecord::WriteStreamHeader(hsStream* s, plUoid* objUoid) const
{
UInt16 savFlags=plSDL::kAddedVarLengthIO; // using to establish a new version in the header, can delete in 8/03
uint16_t savFlags=plSDL::kAddedVarLengthIO; // using to establish a new version in the header, can delete in 8/03
if (objUoid)
savFlags |= plSDL::kHasUoid;
s->WriteLE(savFlags);
s->WriteSafeString(GetDescriptor()->GetName());
s->WriteLE16((Int16)GetDescriptor()->GetVersion());
s->WriteLE16((int16_t)GetDescriptor()->GetVersion());
if (objUoid)
objUoid->Write(s);
}
@ -443,7 +443,7 @@ void plStateDataRecord::WriteStreamHeader(hsStream* s, plUoid* objUoid) const
//
// create and prepare a net msg with this data
//
plNetMsgSDLState* plStateDataRecord::PrepNetMsg(float timeConvert, UInt32 writeOptions) const
plNetMsgSDLState* plStateDataRecord::PrepNetMsg(float timeConvert, uint32_t writeOptions) const
{
// save to stream
hsRAMStream stream;
@ -464,7 +464,7 @@ plNetMsgSDLState* plStateDataRecord::PrepNetMsg(float timeConvert, UInt32 writeO
//
// Destroys 'this' and makes a total copy of other
//
void plStateDataRecord::CopyFrom(const plStateDataRecord& other, UInt32 writeOptions/*=0*/)
void plStateDataRecord::CopyFrom(const plStateDataRecord& other, uint32_t writeOptions/*=0*/)
{
fFlags = other.GetFlags();
IInitDescriptor(other.GetDescriptor());
@ -487,7 +487,7 @@ void plStateDataRecord::CopyFrom(const plStateDataRecord& other, UInt32 writeOpt
// copy them to my corresponding item.
// Requires that records have the same descriptor.
//
void plStateDataRecord::UpdateFrom(const plStateDataRecord& other, UInt32 writeOptions/*=0*/)
void plStateDataRecord::UpdateFrom(const plStateDataRecord& other, uint32_t writeOptions/*=0*/)
{
if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() )
{

View File

@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSDL.h"
#include "pnNetCommon/plNetApp.h"
const UInt8 plStateDescriptor::kVersion=1; // for Read/Write format
const uint8_t plStateDescriptor::kVersion=1; // for Read/Write format
/////////////////////////////////////////////////////////////////////////////////
// STATE DESC
@ -85,7 +85,7 @@ plVarDescriptor* plStateDescriptor::FindVar(const char* name, int* idx) const
//
bool plStateDescriptor::Read(hsStream* s)
{
UInt8 rwVersion;
uint8_t rwVersion;
s->ReadLE(&rwVersion);
if (rwVersion != kVersion)
{
@ -98,16 +98,16 @@ bool plStateDescriptor::Read(hsStream* s)
delete [] fName;
fName = s->ReadSafeString();
UInt16 version=s->ReadLE16();
uint16_t version=s->ReadLE16();
fVersion=version;
UInt16 numVars=s->ReadLE16();
uint16_t numVars=s->ReadLE16();
fVarsList.reserve(numVars);
int i;
for(i=0;i<numVars; i++)
{
UInt8 SDVar=s->ReadByte();
uint8_t SDVar=s->ReadByte();
plVarDescriptor* var = nil;
if (SDVar)
var = TRACKED_NEW plSDVarDescriptor;
@ -130,16 +130,16 @@ void plStateDescriptor::Write(hsStream* s) const
s->WriteSafeString(fName);
UInt16 version=fVersion;
uint16_t version=fVersion;
s->WriteLE(version);
UInt16 numVars=fVarsList.size();
uint16_t numVars=fVarsList.size();
s->WriteLE(numVars);
VarsList::const_iterator it;
for(it=fVarsList.begin(); it!=fVarsList.end(); it++)
{
UInt8 SDVar = ((*it)->GetAsSDVarDescriptor() != nil);
uint8_t SDVar = ((*it)->GetAsSDVarDescriptor() != nil);
s->WriteByte(SDVar);
(*it)->Write(s);
}

View File

@ -86,16 +86,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plSDLCreatableStub : public plCreatable
{
private:
UInt16 fClassIndex;
uint16_t fClassIndex;
public:
void* fData;
int fDataLen;
plSDLCreatableStub(UInt16 classIndex, int len) : fClassIndex(classIndex),fData(nil),fDataLen(len) {}
plSDLCreatableStub(uint16_t classIndex, int len) : fClassIndex(classIndex),fData(nil),fDataLen(len) {}
~plSDLCreatableStub() { delete[] (char*)fData; }
const char* ClassName() const { return "SDLCreatable"; }
UInt16 ClassIndex() const { return fClassIndex; }
uint16_t ClassIndex() const { return fClassIndex; }
void Read(hsStream* s, hsResMgr* mgr) { delete[] (char*)fData; fData = new char[fDataLen]; s->Read(fDataLen, fData); }
void Write(hsStream* s, hsResMgr* mgr) { s->Write(fDataLen, fData); }
@ -105,9 +105,9 @@ public:
// plStateVarNotificationInfo
/////////////////////////////////////////////////////
void plStateVarNotificationInfo::Read(hsStream* s, UInt32 readOptions)
void plStateVarNotificationInfo::Read(hsStream* s, uint32_t readOptions)
{
UInt8 saveFlags=s->ReadByte(); // unused
uint8_t saveFlags=s->ReadByte(); // unused
char* hint=s->ReadSafeString();
if (hint && !(readOptions & plSDL::kSkipNotificationInfo))
fHintString = (const char*)hint;
@ -115,9 +115,9 @@ void plStateVarNotificationInfo::Read(hsStream* s, UInt32 readOptions)
delete[] hint;
}
void plStateVarNotificationInfo::Write(hsStream* s, UInt32 writeOptions) const
void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const
{
UInt8 saveFlags=0; // unused
uint8_t saveFlags=0; // unused
s->WriteLE(saveFlags);
s->WriteSafeString(fHintString.c_str());
}
@ -125,9 +125,9 @@ void plStateVarNotificationInfo::Write(hsStream* s, UInt32 writeOptions) const
/////////////////////////////////////////////////////
// plStateVariable
/////////////////////////////////////////////////////
bool plStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOptions)
bool plStateVariable::ReadData(hsStream* s, float timeConvert, uint32_t readOptions)
{
UInt8 saveFlags;
uint8_t saveFlags;
s->ReadLE(&saveFlags);
if (saveFlags & plSDL::kHasNotificationInfo)
{
@ -136,11 +136,11 @@ bool plStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOption
return true;
}
bool plStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 writeOptions) const
bool plStateVariable::WriteData(hsStream* s, float timeConvert, uint32_t writeOptions) const
{
bool writeNotificationInfo = ((writeOptions & plSDL::kSkipNotificationInfo)==0);
UInt8 saveFlags=0;
uint8_t saveFlags=0;
if (writeNotificationInfo)
saveFlags |= plSDL::kHasNotificationInfo;
@ -244,7 +244,7 @@ void plSimpleStateVariable::Alloc(int listSize)
{
SDLALLOC(plVarDescriptor::kInt, int, fI)
SDLALLOC(plVarDescriptor::kAgeTimeOfDay, float, fF)
SDLALLOC(plVarDescriptor::kByte, byte, fBy)
SDLALLOC(plVarDescriptor::kByte, uint8_t, fBy)
SDLALLOC(plVarDescriptor::kShort, short, fS)
SDLALLOC(plVarDescriptor::kFloat, float, fF)
SDLALLOC(plVarDescriptor::kDouble, double, fD)
@ -282,7 +282,7 @@ void plSimpleStateVariable::Reset()
{
RESET(plVarDescriptor::kInt, int, fI)
RESET(plVarDescriptor::kAgeTimeOfDay, float, fF)
RESET(plVarDescriptor::kByte, byte, fBy)
RESET(plVarDescriptor::kByte, uint8_t, fBy)
RESET(plVarDescriptor::kShort, short, fS)
RESET(plVarDescriptor::kFloat, float, fF)
RESET(plVarDescriptor::kDouble, double, fD)
@ -356,7 +356,7 @@ bool plSimpleStateVariable::SetFromString(const char* valueConst, int idx, bool
else if (type==plVarDescriptor::kShort && fS)
fS[i++] = (short)atoi(ptr);
else if (type==plVarDescriptor::kByte && fBy)
fBy[i++] = (byte)atoi(ptr);
fBy[i++] = (uint8_t)atoi(ptr);
else if ( (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay) && fF)
fF[i++] = (float)atof(ptr);
else if ( (type==plVarDescriptor::kDouble || type==plVarDescriptor::kTime) && fD)
@ -554,12 +554,12 @@ bool plSimpleStateVariable::IConvertFromRGB(plVarDescriptor::Type newType)
{
// rgb to rgba8
int i,j;
byte * newB = TRACKED_NEW byte [fVar.GetCount()*4]; // make more space
uint8_t * newB = TRACKED_NEW uint8_t [fVar.GetCount()*4]; // make more space
for(j=0;j<fVar.GetCount(); j++)
{
// recopy with alpha=0 by default
for(i=0;i<3;i++)
newB[j*4+i] = byte(fF[j*fVar.GetAtomicCount()+i]*255+.5);
newB[j*4+i] = uint8_t(fF[j*fVar.GetAtomicCount()+i]*255+.5);
newB[j*4+3] = 0;
}
delete [] fF; // delete old
@ -570,12 +570,12 @@ bool plSimpleStateVariable::IConvertFromRGB(plVarDescriptor::Type newType)
{
// rgb to rgb8
int i,j;
byte * newB = TRACKED_NEW byte [fVar.GetCount()*3]; // make space
uint8_t * newB = TRACKED_NEW uint8_t [fVar.GetCount()*3]; // make space
for(j=0;j<fVar.GetCount(); j++)
{
// recopy with alpha=0 by default
for(i=0;i<3;i++)
newB[j*3+i] = byte(fF[j*fVar.GetAtomicCount()+i]*255+.5);
newB[j*3+i] = uint8_t(fF[j*fVar.GetAtomicCount()+i]*255+.5);
}
delete [] fF; // delete old
fBy = newB; // use new
@ -626,7 +626,7 @@ bool plSimpleStateVariable::IConvertFromRGB8(plVarDescriptor::Type newType)
{
// rgb8 to rgba8
int i,j;
byte * newB = TRACKED_NEW byte [fVar.GetCount()*4]; // make more space
uint8_t * newB = TRACKED_NEW uint8_t [fVar.GetCount()*4]; // make more space
for(j=0;j<fVar.GetCount(); j++)
{
// recopy with alpha=0 by default
@ -670,12 +670,12 @@ bool plSimpleStateVariable::IConvertFromRGBA(plVarDescriptor::Type newType)
{
// rgba to rgb8
int i,j;
byte* newB = TRACKED_NEW byte[fVar.GetCount()*3]; // make less space
uint8_t* newB = TRACKED_NEW uint8_t[fVar.GetCount()*3]; // make less space
for(j=0;j<fVar.GetCount(); j++)
{
// recopy and ignore alpha
for(i=0;i<3;i++)
newB[j*3+i] = byte(fF[j*fVar.GetAtomicCount()+i]*255+.5);
newB[j*3+i] = uint8_t(fF[j*fVar.GetAtomicCount()+i]*255+.5);
}
delete [] fF; // delete old
fBy = newB; // use new
@ -685,12 +685,12 @@ bool plSimpleStateVariable::IConvertFromRGBA(plVarDescriptor::Type newType)
{
// rgba to rgba8
int i,j;
byte* newBy = TRACKED_NEW byte [fVar.GetCount()*4]; // make less space
uint8_t* newBy = TRACKED_NEW uint8_t [fVar.GetCount()*4]; // make less space
for(j=0;j<fVar.GetCount(); j++)
{
// recopy and ignore alpha
for(i=0;i<4;i++)
newBy[j*4+i] = byte(fF[j*fVar.GetAtomicCount()+i]*255+.5);
newBy[j*4+i] = uint8_t(fF[j*fVar.GetAtomicCount()+i]*255+.5);
}
delete [] fF; // delete old
fBy = newBy; // use new
@ -728,7 +728,7 @@ bool plSimpleStateVariable::IConvertFromRGBA8(plVarDescriptor::Type newType)
{
// rgba8 to rgb8
int i,j;
byte* newB = TRACKED_NEW byte[fVar.GetCount()*3]; // make less space
uint8_t* newB = TRACKED_NEW uint8_t[fVar.GetCount()*3]; // make less space
for(j=0;j<fVar.GetCount(); j++)
{
// recopy and ignore alpha
@ -791,9 +791,9 @@ bool plSimpleStateVariable::IConvertFromInt(plVarDescriptor::Type newType)
case plVarDescriptor::kByte:
{
// int to byte
byte* newBy = TRACKED_NEW byte[fVar.GetCount()];
uint8_t* newBy = TRACKED_NEW uint8_t[fVar.GetCount()];
for(j=0;j<fVar.GetCount(); j++)
newBy[j] = byte(fI[j]);
newBy[j] = uint8_t(fI[j]);
delete [] fI;
fBy = newBy;
}
@ -851,9 +851,9 @@ bool plSimpleStateVariable::IConvertFromShort(plVarDescriptor::Type newType)
}
case plVarDescriptor::kByte:
{
byte* newBy = TRACKED_NEW byte[fVar.GetCount()];
uint8_t* newBy = TRACKED_NEW uint8_t[fVar.GetCount()];
for(j=0;j<fVar.GetCount(); j++)
newBy[j] = byte(fS[j]);
newBy[j] = uint8_t(fS[j]);
delete [] fS;
fBy = newBy;
}
@ -968,9 +968,9 @@ bool plSimpleStateVariable::IConvertFromFloat(plVarDescriptor::Type newType)
break;
case plVarDescriptor::kByte:
{
byte* newBy = TRACKED_NEW byte[fVar.GetCount()];
uint8_t* newBy = TRACKED_NEW uint8_t[fVar.GetCount()];
for(j=0;j<fVar.GetCount(); j++)
newBy[j] = (byte)(fF[j]+.5f); // round to nearest int
newBy[j] = (uint8_t)(fF[j]+.5f); // round to nearest int
delete [] fF;
fBy = newBy;
}
@ -1027,9 +1027,9 @@ bool plSimpleStateVariable::IConvertFromDouble(plVarDescriptor::Type newType)
break;
case plVarDescriptor::kByte:
{
byte* newBy = TRACKED_NEW byte[fVar.GetCount()];
uint8_t* newBy = TRACKED_NEW uint8_t[fVar.GetCount()];
for(j=0;j<fVar.GetCount(); j++)
newBy[j] = (byte)(fD[j]+.5f); // round to nearest int
newBy[j] = (uint8_t)(fD[j]+.5f); // round to nearest int
delete [] fD;
fBy = newBy;
}
@ -1086,7 +1086,7 @@ bool plSimpleStateVariable::IConvertFromBool(plVarDescriptor::Type newType)
break;
case plVarDescriptor::kByte:
{
byte* newBy = TRACKED_NEW byte[fVar.GetCount()];
uint8_t* newBy = TRACKED_NEW uint8_t[fVar.GetCount()];
for(j=0;j<fVar.GetCount(); j++)
newBy[j] = (fB[j] == true ? 1 : 0);
delete [] fB;
@ -1236,7 +1236,7 @@ bool plSimpleStateVariable::ConvertTo(plSimpleVarDescriptor* toVar, bool force )
return false;
break;
// FROM Byte
// FROM byte
case plVarDescriptor::kByte:
if (!IConvertFromByte(newType))
return false;
@ -1346,7 +1346,7 @@ bool plSimpleStateVariable::Set(float* v, int idx)
}
// bytevector
bool plSimpleStateVariable::Set(byte* v, int idx)
bool plSimpleStateVariable::Set(uint8_t* v, int idx)
{
VALIDATE_WITH_FALSE_RETURN(idx < fVar.GetCount());
@ -1411,7 +1411,7 @@ bool plSimpleStateVariable::Set(int v, int idx)
return Set((short)v, idx);
else
if (fVar.GetType()==plVarDescriptor::kByte)
return Set((byte)v, idx);
return Set((uint8_t)v, idx);
hsAssert(false, "passing wrong value type to SDL variable");
return false;
@ -1432,13 +1432,13 @@ bool plSimpleStateVariable::Set(short v, int idx)
return Set((int)v, idx);
else
if (fVar.GetType()==plVarDescriptor::kByte)
return Set((byte)v, idx);
return Set((uint8_t)v, idx);
hsAssert(false, "passing wrong value type to SDL variable");
return false;
}
bool plSimpleStateVariable::Set(byte v, int idx)
bool plSimpleStateVariable::Set(uint8_t v, int idx)
{
VALIDATE_WITH_FALSE_RETURN(idx < fVar.GetCount());
@ -1591,7 +1591,7 @@ bool plSimpleStateVariable::Get(short* value, int idx) const
return false;
}
bool plSimpleStateVariable::Get(byte* value, int idx) const
bool plSimpleStateVariable::Get(uint8_t* value, int idx) const
{
VALIDATE_WITH_FALSE_RETURN(idx < fVar.GetCount());
@ -1794,7 +1794,7 @@ const char* plSimpleStateVariable::GetKeyName(int idx) const
}
#pragma optimize( "g", off ) // disable float optimizations
bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx, UInt32 writeOptions) const
bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx, uint32_t writeOptions) const
{
#ifdef HS_DEBUGGING
if (!IsUsed())
@ -1880,7 +1880,7 @@ bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx,
return true;
}
bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, UInt32 readOptions)
bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, uint32_t readOptions)
{
int j=idx*fVar.GetAtomicCount();
int i;
@ -1941,10 +1941,10 @@ bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, U
case plVarDescriptor::kCreatable:
{
hsAssert(fVar.GetAtomicCount()==1, "invalid atomic count");
UInt16 hClass = s->ReadLE16(); // class index
uint16_t hClass = s->ReadLE16(); // class index
if (hClass != 0x8000)
{
UInt32 len = s->ReadLE32(); // length
uint32_t len = s->ReadLE32(); // length
if (plFactory::CanCreate(hClass))
{
delete fC[j];
@ -1968,7 +1968,7 @@ bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, U
}
#pragma optimize( "", on ) // restore optimizations to their defaults
bool plSimpleStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 writeOptions) const
bool plSimpleStateVariable::WriteData(hsStream* s, float timeConvert, uint32_t writeOptions) const
{
#ifdef HS_DEBUGGING
if (!IsUsed())
@ -2001,7 +2001,7 @@ bool plSimpleStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 wri
forceDirtyFlags = forceDirtyFlags || (!sameAsDefaults && (writeOptions & plSDL::kDirtyNonDefaults)!=0);
// write save flags
UInt8 saveFlags = 0;
uint8_t saveFlags = 0;
saveFlags |= writeTimeStamps ? plSDL::kHasTimeStamp : 0;
saveFlags |= forceDirtyFlags || (writeDirtyFlags && IsDirty()) ? plSDL::kHasDirtyFlag : 0;
saveFlags |= wantTimeStamp ? plSDL::kWantTimeStamp : 0;
@ -2039,7 +2039,7 @@ bool plSimpleStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 wri
}
// assumes var is created from the right type of descriptor (count, type, etc.)
bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOptions)
bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, uint32_t readOptions)
{
// read base class data
plStateVariable::ReadData(s, timeConvert, readOptions);
@ -2047,7 +2047,7 @@ bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 read
plUnifiedTime ut;
ut.ToEpoch();
UInt8 saveFlags;
uint8_t saveFlags;
s->ReadLE(&saveFlags);
bool isDirty = ( saveFlags & plSDL::kHasDirtyFlag )!=0;
@ -2069,7 +2069,7 @@ bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 read
// read list size
if (GetVarDescriptor()->IsVariableLength())
{
UInt32 cnt;
uint32_t cnt;
s->ReadLE(&cnt); // have to read as long since we don't know how big the list is
if (cnt>=0 && cnt<plSDL::kMaxListSize)
@ -2112,7 +2112,7 @@ bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 read
return true;
}
void plSimpleStateVariable::CopyData(const plSimpleStateVariable* other, UInt32 writeOptions/*=0*/)
void plSimpleStateVariable::CopyData(const plSimpleStateVariable* other, uint32_t writeOptions/*=0*/)
{
// use stream as a medium
hsRAMStream stream;
@ -2485,7 +2485,7 @@ void plSDStateVariable::IDeInit()
//
// Make 'this' into a copy of 'other'.
//
void plSDStateVariable::CopyFrom(plSDStateVariable* other, UInt32 writeOptions/*=0*/)
void plSDStateVariable::CopyFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/)
{
// IDeInit();
Alloc(other->GetSDVarDescriptor(), other->GetCount());
@ -2499,7 +2499,7 @@ void plSDStateVariable::CopyFrom(plSDStateVariable* other, UInt32 writeOptions/*
// copy them to my corresponding item.
// Requires that records have the same descriptor.
//
void plSDStateVariable::UpdateFrom(plSDStateVariable* other, UInt32 writeOptions/*=0*/)
void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/)
{
hsAssert(!stricmp(other->GetSDVarDescriptor()->GetName(), fVarDescriptor->GetName()),
xtl::format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d",
@ -2600,17 +2600,17 @@ void plSDStateVariable::GetDirtyDataRecords(ConstDataRecList* recList) const
//
// read all SDVars
//
bool plSDStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOptions)
bool plSDStateVariable::ReadData(hsStream* s, float timeConvert, uint32_t readOptions)
{
plStateVariable::ReadData(s, timeConvert, readOptions);
UInt8 saveFlags;
uint8_t saveFlags;
s->ReadLE(&saveFlags); // unused
// read total list size
if (GetVarDescriptor()->IsVariableLength())
{
UInt32 total;
uint32_t total;
s->ReadLE(&total);
Resize(total);
}
@ -2645,15 +2645,15 @@ bool plSDStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOpti
//
// write all SDVars
//
bool plSDStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 writeOptions) const
bool plSDStateVariable::WriteData(hsStream* s, float timeConvert, uint32_t writeOptions) const
{
plStateVariable::WriteData(s, timeConvert, writeOptions);
UInt8 saveFlags=0; // unused
uint8_t saveFlags=0; // unused
s->WriteLE(saveFlags);
// write total list size
UInt32 total=GetCount();
uint32_t total=GetCount();
if (GetVarDescriptor()->IsVariableLength())
s->WriteLE(total);

View File

@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h"
const UInt8 plVarDescriptor::kVersion=3; // for Read/Write format
const uint8_t plVarDescriptor::kVersion=3; // for Read/Write format
/////////////////////////////////////////////////////////////////////////////////
// State Var
@ -168,7 +168,7 @@ void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
//
bool plVarDescriptor::Read(hsStream* s)
{
UInt8 version;
uint8_t version;
s->ReadLE(&version);
if (version != kVersion)
{
@ -203,7 +203,7 @@ void plVarDescriptor::Write(hsStream* s) const
s->WriteSafeString(fName);
plMsgStdStringHelper::Poke(fDisplayOptions, s);
s->WriteLE32(fCount);
s->WriteByte((UInt8)fType);
s->WriteByte((uint8_t)fType);
s->WriteSafeString(fDefault);
s->WriteLE32(fFlags);
}
@ -227,7 +227,7 @@ int plSimpleVarDescriptor::GetAtomicSize() const
case kInt:
return sizeof(int)*GetAtomicCount();
case kByte:
return sizeof(byte)*GetAtomicCount();
return sizeof(uint8_t)*GetAtomicCount();
case kShort:
return sizeof(short)*GetAtomicCount();
case kAgeTimeOfDay:
@ -375,8 +375,8 @@ void plSimpleVarDescriptor::Write(hsStream* s) const
{
plVarDescriptor::Write(s);
s->WriteLE16((Int16)fAtomicCount);
s->WriteByte((UInt8)fAtomicType);
s->WriteLE16((int16_t)fAtomicCount);
s->WriteByte((uint8_t)fAtomicType);
}
/////////////////////////////////////////////////////////////////////////////////
@ -399,7 +399,7 @@ bool plSDVarDescriptor::Read(hsStream* s)
return false;
char* sdName=s->ReadSafeString();
UInt16 version = s->ReadLE16();
uint16_t version = s->ReadLE16();
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version);
hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName, version ).c_str() );
SetStateDesc(sd);
@ -415,6 +415,6 @@ void plSDVarDescriptor::Write(hsStream* s) const
plVarDescriptor::Write(s);
s->WriteSafeString(GetStateDescriptor()->GetName());
UInt16 version=GetStateDescriptor()->GetVersion();
uint16_t version=GetStateDescriptor()->GetVersion();
s->WriteLE(version);
}