mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
Fix Endian functions names in hsTypes and hsStream.
Function and macro names for endianness were previously vague, and on big-endian systems entirely misleading. The names are now properly descriptive of what they actually do.
This commit is contained in:
@ -146,7 +146,7 @@ int plSDLMgr::Write(hsStream* s, const plSDL::DescriptorList* dl)
|
||||
dl=&fDescriptors;
|
||||
|
||||
UInt16 num=dl->size();
|
||||
s->WriteSwap(num);
|
||||
s->WriteLE(num);
|
||||
|
||||
plSDL::DescriptorList::const_iterator it;
|
||||
for(it=dl->begin(); it!= dl->end(); it++)
|
||||
@ -178,7 +178,7 @@ int plSDLMgr::Read(hsStream* s, plSDL::DescriptorList* dl)
|
||||
try
|
||||
{
|
||||
// read dtor list
|
||||
s->ReadSwap(&num);
|
||||
s->ReadLE(&num);
|
||||
|
||||
int i;
|
||||
for(i=0;i<num;i++)
|
||||
|
@ -65,9 +65,9 @@ void plSDL::VariableLengthRead(hsStream* s, int size, int* val)
|
||||
*val = s->ReadByte();
|
||||
else
|
||||
if (size < (1<<16))
|
||||
*val = s->ReadSwap16();
|
||||
*val = s->ReadLE16();
|
||||
else
|
||||
*val = s->ReadSwap32();
|
||||
*val = s->ReadLE32();
|
||||
}
|
||||
|
||||
//
|
||||
@ -86,10 +86,10 @@ void plSDL::VariableLengthWrite(hsStream* s, int size, int val)
|
||||
if (size < (1<<16))
|
||||
{
|
||||
hsAssert(val < (1<<16), "SDL data loss");
|
||||
s->WriteSwap16(val);
|
||||
s->WriteLE16(val);
|
||||
}
|
||||
else
|
||||
s->WriteSwap32(val);
|
||||
s->WriteLE32(val);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -236,7 +236,7 @@ bool plStateDataRecord::IHasUsedVars(const VarsList& vars) const
|
||||
//
|
||||
bool plStateDataRecord::Read(hsStream* s, float timeConvert, UInt32 readOptions)
|
||||
{
|
||||
fFlags = s->ReadSwap16();
|
||||
fFlags = s->ReadLE16();
|
||||
UInt8 ioVersion = s->ReadByte();
|
||||
if (ioVersion != kIOVersion)
|
||||
return false;
|
||||
@ -343,7 +343,7 @@ void plStateDataRecord::Write(hsStream* s, float timeConvert, UInt32 writeOption
|
||||
}
|
||||
#endif
|
||||
|
||||
s->WriteSwap16((UInt16)fFlags);
|
||||
s->WriteLE16((UInt16)fFlags);
|
||||
s->WriteByte(kIOVersion);
|
||||
|
||||
//
|
||||
@ -395,7 +395,7 @@ void plStateDataRecord::Write(hsStream* s, float timeConvert, UInt32 writeOption
|
||||
bool plStateDataRecord::ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid)
|
||||
{
|
||||
UInt16 savFlags;
|
||||
s->ReadSwap(&savFlags);
|
||||
s->ReadLE(&savFlags);
|
||||
if (!(savFlags & plSDL::kAddedVarLengthIO)) // using to establish a new version in the header, can delete in 8/03
|
||||
{
|
||||
*name = nil;
|
||||
@ -403,7 +403,7 @@ bool plStateDataRecord::ReadStreamHeader(hsStream* s, char** name, int* version,
|
||||
}
|
||||
|
||||
*name = s->ReadSafeString();
|
||||
*version = s->ReadSwap16();
|
||||
*version = s->ReadLE16();
|
||||
|
||||
if (objUoid)
|
||||
{
|
||||
@ -433,9 +433,9 @@ void plStateDataRecord::WriteStreamHeader(hsStream* s, plUoid* objUoid) const
|
||||
if (objUoid)
|
||||
savFlags |= plSDL::kHasUoid;
|
||||
|
||||
s->WriteSwap(savFlags);
|
||||
s->WriteLE(savFlags);
|
||||
s->WriteSafeString(GetDescriptor()->GetName());
|
||||
s->WriteSwap16((Int16)GetDescriptor()->GetVersion());
|
||||
s->WriteLE16((Int16)GetDescriptor()->GetVersion());
|
||||
if (objUoid)
|
||||
objUoid->Write(s);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ plVarDescriptor* plStateDescriptor::FindVar(const char* name, int* idx) const
|
||||
bool plStateDescriptor::Read(hsStream* s)
|
||||
{
|
||||
UInt8 rwVersion;
|
||||
s->ReadSwap(&rwVersion);
|
||||
s->ReadLE(&rwVersion);
|
||||
if (rwVersion != kVersion)
|
||||
{
|
||||
plNetApp::StaticWarningMsg("StateDescriptor Read/Write version mismatch, mine %d, read %d", kVersion, rwVersion);
|
||||
@ -98,10 +98,10 @@ bool plStateDescriptor::Read(hsStream* s)
|
||||
delete [] fName;
|
||||
fName = s->ReadSafeString();
|
||||
|
||||
UInt16 version=s->ReadSwap16();
|
||||
UInt16 version=s->ReadLE16();
|
||||
fVersion=version;
|
||||
|
||||
UInt16 numVars=s->ReadSwap16();
|
||||
UInt16 numVars=s->ReadLE16();
|
||||
fVarsList.reserve(numVars);
|
||||
|
||||
int i;
|
||||
@ -126,15 +126,15 @@ bool plStateDescriptor::Read(hsStream* s)
|
||||
//
|
||||
void plStateDescriptor::Write(hsStream* s) const
|
||||
{
|
||||
s->WriteSwap(kVersion);
|
||||
s->WriteLE(kVersion);
|
||||
|
||||
s->WriteSafeString(fName);
|
||||
|
||||
UInt16 version=fVersion;
|
||||
s->WriteSwap(version);
|
||||
s->WriteLE(version);
|
||||
|
||||
UInt16 numVars=fVarsList.size();
|
||||
s->WriteSwap(numVars);
|
||||
s->WriteLE(numVars);
|
||||
|
||||
VarsList::const_iterator it;
|
||||
for(it=fVarsList.begin(); it!=fVarsList.end(); it++)
|
||||
|
@ -118,7 +118,7 @@ void plStateVarNotificationInfo::Read(hsStream* s, UInt32 readOptions)
|
||||
void plStateVarNotificationInfo::Write(hsStream* s, UInt32 writeOptions) const
|
||||
{
|
||||
UInt8 saveFlags=0; // unused
|
||||
s->WriteSwap(saveFlags);
|
||||
s->WriteLE(saveFlags);
|
||||
s->WriteSafeString(fHintString.c_str());
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ void plStateVarNotificationInfo::Write(hsStream* s, UInt32 writeOptions) const
|
||||
bool plStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOptions)
|
||||
{
|
||||
UInt8 saveFlags;
|
||||
s->ReadSwap(&saveFlags);
|
||||
s->ReadLE(&saveFlags);
|
||||
if (saveFlags & plSDL::kHasNotificationInfo)
|
||||
{
|
||||
GetNotificationInfo().Read(s, readOptions);
|
||||
@ -144,7 +144,7 @@ bool plStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 writeOpti
|
||||
if (writeNotificationInfo)
|
||||
saveFlags |= plSDL::kHasNotificationInfo;
|
||||
|
||||
s->WriteSwap(saveFlags);
|
||||
s->WriteLE(saveFlags);
|
||||
if (writeNotificationInfo)
|
||||
{
|
||||
GetNotificationInfo().Write(s, writeOptions);
|
||||
@ -1814,11 +1814,11 @@ bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx,
|
||||
break;
|
||||
case plVarDescriptor::kInt:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
s->WriteSwap32(fI[j+i]);
|
||||
s->WriteLE32(fI[j+i]);
|
||||
break;
|
||||
case plVarDescriptor::kShort:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
s->WriteSwap16(fS[j+i]);
|
||||
s->WriteLE16(fS[j+i]);
|
||||
break;
|
||||
case plVarDescriptor::kByte:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
@ -1826,7 +1826,7 @@ bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx,
|
||||
break;
|
||||
case plVarDescriptor::kFloat:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
s->WriteSwapScalar(fF[j+i]);
|
||||
s->WriteLEScalar(fF[j+i]);
|
||||
break;
|
||||
case plVarDescriptor::kTime:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
@ -1846,7 +1846,7 @@ bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx,
|
||||
break;
|
||||
case plVarDescriptor::kDouble:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
s->WriteSwapDouble(fD[j+i]);
|
||||
s->WriteLEDouble(fD[j+i]);
|
||||
break;
|
||||
case plVarDescriptor::kBool:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
@ -1864,12 +1864,12 @@ bool plSimpleStateVariable::IWriteData(hsStream* s, float timeConvert, int idx,
|
||||
{
|
||||
hsAssert(fVar.GetAtomicCount()==1, "invalid atomic count");
|
||||
plCreatable* cre = fC[j];
|
||||
s->WriteSwap16(cre ? cre->ClassIndex() : 0x8000); // creatable class index
|
||||
s->WriteLE16(cre ? cre->ClassIndex() : 0x8000); // creatable class index
|
||||
if (cre)
|
||||
{
|
||||
hsRAMStream ramStream;
|
||||
cre->Write(&ramStream, hsgResMgr::ResMgr());
|
||||
s->WriteSwap32(ramStream.GetEOF()); // write length
|
||||
s->WriteLE32(ramStream.GetEOF()); // write length
|
||||
cre->Write(s, hsgResMgr::ResMgr()); // write data
|
||||
}
|
||||
}
|
||||
@ -1889,11 +1889,11 @@ bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, U
|
||||
break;
|
||||
case plVarDescriptor::kInt:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
fI[j+i]=s->ReadSwap32();
|
||||
fI[j+i]=s->ReadLE32();
|
||||
break;
|
||||
case plVarDescriptor::kShort:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
fS[j+i]=s->ReadSwap16();
|
||||
fS[j+i]=s->ReadLE16();
|
||||
break;
|
||||
case plVarDescriptor::kByte:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
@ -1901,7 +1901,7 @@ bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, U
|
||||
break;
|
||||
case plVarDescriptor::kFloat:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
fF[j+i]=s->ReadSwapScalar();
|
||||
fF[j+i]=s->ReadLEScalar();
|
||||
break;
|
||||
case plVarDescriptor::kTime:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
@ -1919,7 +1919,7 @@ bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, U
|
||||
break;
|
||||
case plVarDescriptor::kDouble:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
fD[j+i]=s->ReadSwapDouble();
|
||||
fD[j+i]=s->ReadLEDouble();
|
||||
break;
|
||||
case plVarDescriptor::kBool:
|
||||
for(i=0;i<fVar.GetAtomicCount();i++)
|
||||
@ -1939,10 +1939,10 @@ bool plSimpleStateVariable::IReadData(hsStream* s, float timeConvert, int idx, U
|
||||
case plVarDescriptor::kCreatable:
|
||||
{
|
||||
hsAssert(fVar.GetAtomicCount()==1, "invalid atomic count");
|
||||
UInt16 hClass = s->ReadSwap16(); // class index
|
||||
UInt16 hClass = s->ReadLE16(); // class index
|
||||
if (hClass != 0x8000)
|
||||
{
|
||||
UInt32 len = s->ReadSwap32(); // length
|
||||
UInt32 len = s->ReadLE32(); // length
|
||||
if (plFactory::CanCreate(hClass))
|
||||
{
|
||||
delete fC[j];
|
||||
@ -2007,7 +2007,7 @@ bool plSimpleStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 wri
|
||||
|
||||
if (sameAsDefaults)
|
||||
saveFlags |= plSDL::kSameAsDefault;
|
||||
s->WriteSwap(saveFlags);
|
||||
s->WriteLE(saveFlags);
|
||||
|
||||
if (needTimeStamp) {
|
||||
// timestamp on write
|
||||
@ -2024,7 +2024,7 @@ bool plSimpleStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 wri
|
||||
{
|
||||
// list size
|
||||
if (GetVarDescriptor()->IsVariableLength())
|
||||
s->WriteSwap32(GetVarDescriptor()->GetCount()); // have to write out as long since we don't know how big the list is
|
||||
s->WriteLE32(GetVarDescriptor()->GetCount()); // have to write out as long since we don't know how big the list is
|
||||
|
||||
// list
|
||||
int i;
|
||||
@ -2046,7 +2046,7 @@ bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 read
|
||||
ut.ToEpoch();
|
||||
|
||||
UInt8 saveFlags;
|
||||
s->ReadSwap(&saveFlags);
|
||||
s->ReadLE(&saveFlags);
|
||||
|
||||
bool isDirty = ( saveFlags & plSDL::kHasDirtyFlag )!=0;
|
||||
bool setDirty = ( isDirty && ( readOptions & plSDL::kKeepDirty ) ) || ( readOptions & plSDL::kMakeDirty );
|
||||
@ -2068,7 +2068,7 @@ bool plSimpleStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 read
|
||||
if (GetVarDescriptor()->IsVariableLength())
|
||||
{
|
||||
UInt32 cnt;
|
||||
s->ReadSwap(&cnt); // have to read as long since we don't know how big the list is
|
||||
s->ReadLE(&cnt); // have to read as long since we don't know how big the list is
|
||||
|
||||
if (cnt>=0 && cnt<plSDL::kMaxListSize)
|
||||
fVar.SetCount(cnt);
|
||||
@ -2602,13 +2602,13 @@ bool plSDStateVariable::ReadData(hsStream* s, float timeConvert, UInt32 readOpti
|
||||
plStateVariable::ReadData(s, timeConvert, readOptions);
|
||||
|
||||
UInt8 saveFlags;
|
||||
s->ReadSwap(&saveFlags); // unused
|
||||
s->ReadLE(&saveFlags); // unused
|
||||
|
||||
// read total list size
|
||||
if (GetVarDescriptor()->IsVariableLength())
|
||||
{
|
||||
UInt32 total;
|
||||
s->ReadSwap(&total);
|
||||
s->ReadLE(&total);
|
||||
Resize(total);
|
||||
}
|
||||
|
||||
@ -2647,12 +2647,12 @@ bool plSDStateVariable::WriteData(hsStream* s, float timeConvert, UInt32 writeOp
|
||||
plStateVariable::WriteData(s, timeConvert, writeOptions);
|
||||
|
||||
UInt8 saveFlags=0; // unused
|
||||
s->WriteSwap(saveFlags);
|
||||
s->WriteLE(saveFlags);
|
||||
|
||||
// write total list size
|
||||
UInt32 total=GetCount();
|
||||
if (GetVarDescriptor()->IsVariableLength())
|
||||
s->WriteSwap(total);
|
||||
s->WriteLE(total);
|
||||
|
||||
// write dirty list size
|
||||
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly) != 0;
|
||||
|
@ -169,7 +169,7 @@ void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
|
||||
bool plVarDescriptor::Read(hsStream* s)
|
||||
{
|
||||
UInt8 version;
|
||||
s->ReadSwap(&version);
|
||||
s->ReadLE(&version);
|
||||
if (version != kVersion)
|
||||
{
|
||||
if (plSDLMgr::GetInstance()->GetNetApp())
|
||||
@ -183,14 +183,14 @@ bool plVarDescriptor::Read(hsStream* s)
|
||||
|
||||
plMsgStdStringHelper::Peek(fDisplayOptions, s);
|
||||
|
||||
fCount=s->ReadSwap32();
|
||||
fCount=s->ReadLE32();
|
||||
|
||||
fType=(Type)s->ReadByte();
|
||||
|
||||
delete [] fDefault;
|
||||
fDefault = s->ReadSafeString();
|
||||
|
||||
fFlags = s->ReadSwap32();
|
||||
fFlags = s->ReadLE32();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -199,13 +199,13 @@ bool plVarDescriptor::Read(hsStream* s)
|
||||
//
|
||||
void plVarDescriptor::Write(hsStream* s) const
|
||||
{
|
||||
s->WriteSwap(kVersion);
|
||||
s->WriteLE(kVersion);
|
||||
s->WriteSafeString(fName);
|
||||
plMsgStdStringHelper::Poke(fDisplayOptions, s);
|
||||
s->WriteSwap32(fCount);
|
||||
s->WriteLE32(fCount);
|
||||
s->WriteByte((UInt8)fType);
|
||||
s->WriteSafeString(fDefault);
|
||||
s->WriteSwap32(fFlags);
|
||||
s->WriteLE32(fFlags);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -363,7 +363,7 @@ bool plSimpleVarDescriptor::Read(hsStream* s)
|
||||
if (!plVarDescriptor::Read(s))
|
||||
return false;
|
||||
|
||||
fAtomicCount=s->ReadSwap16();
|
||||
fAtomicCount=s->ReadLE16();
|
||||
fAtomicType=(Type)s->ReadByte();
|
||||
return true;
|
||||
}
|
||||
@ -375,7 +375,7 @@ void plSimpleVarDescriptor::Write(hsStream* s) const
|
||||
{
|
||||
plVarDescriptor::Write(s);
|
||||
|
||||
s->WriteSwap16((Int16)fAtomicCount);
|
||||
s->WriteLE16((Int16)fAtomicCount);
|
||||
s->WriteByte((UInt8)fAtomicType);
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ bool plSDVarDescriptor::Read(hsStream* s)
|
||||
return false;
|
||||
|
||||
char* sdName=s->ReadSafeString();
|
||||
UInt16 version = s->ReadSwap16();
|
||||
UInt16 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);
|
||||
@ -416,5 +416,5 @@ void plSDVarDescriptor::Write(hsStream* s) const
|
||||
|
||||
s->WriteSafeString(GetStateDescriptor()->GetName());
|
||||
UInt16 version=GetStateDescriptor()->GetVersion();
|
||||
s->WriteSwap(version);
|
||||
s->WriteLE(version);
|
||||
}
|
||||
|
Reference in New Issue
Block a user