mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +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:
@ -87,7 +87,7 @@ plDiffBuffer::plDiffBuffer( UInt32 newLength, UInt32 oldLength )
|
||||
|
||||
fNewLength = newLength;
|
||||
fStream = TRACKED_NEW hsRAMStream();
|
||||
fStream->WriteSwap32( fNewLength );
|
||||
fStream->WriteLE32( fNewLength );
|
||||
fStream->WriteBool( f16BitMode );
|
||||
fWriting = true;
|
||||
}
|
||||
@ -118,7 +118,7 @@ plDiffBuffer::plDiffBuffer( void *buffer, UInt32 length )
|
||||
fStream->Write( length, buffer );
|
||||
fStream->Rewind();
|
||||
|
||||
fNewLength = fStream->ReadSwap32();
|
||||
fNewLength = fStream->ReadLE32();
|
||||
f16BitMode = fStream->ReadBool();
|
||||
}
|
||||
}
|
||||
@ -148,9 +148,9 @@ void plDiffBuffer::Add( Int32 length, void *newData )
|
||||
// We flag our two different op types by the sign of the length. Negative
|
||||
// lengths are an add operation, positive ones are copy ops.
|
||||
if( f16BitMode )
|
||||
fStream->WriteSwap16( -( (Int16)length ) );
|
||||
fStream->WriteLE16( -( (Int16)length ) );
|
||||
else
|
||||
fStream->WriteSwap32( -length );
|
||||
fStream->WriteLE32( -length );
|
||||
fStream->Write( length, newData );
|
||||
}
|
||||
|
||||
@ -165,13 +165,13 @@ void plDiffBuffer::Copy( Int32 length, UInt32 oldOffset )
|
||||
// lengths are an add operation, positive ones are copy ops.
|
||||
if( f16BitMode )
|
||||
{
|
||||
fStream->WriteSwap16( (Int16)length );
|
||||
fStream->WriteSwap16( (UInt16)oldOffset );
|
||||
fStream->WriteLE16( (Int16)length );
|
||||
fStream->WriteLE16( (UInt16)oldOffset );
|
||||
}
|
||||
else
|
||||
{
|
||||
fStream->WriteSwap32( length );
|
||||
fStream->WriteSwap32( oldOffset );
|
||||
fStream->WriteLE32( length );
|
||||
fStream->WriteLE32( oldOffset );
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,14 +231,14 @@ void plDiffBuffer::Apply( UInt32 oldLength, void *oldBuffer, UInt32 &newLengt
|
||||
// Read in the op length
|
||||
if( f16BitMode )
|
||||
{
|
||||
Int16 opLen16 = fStream->ReadSwap16();
|
||||
Int16 opLen16 = fStream->ReadLE16();
|
||||
if( opLen16 < 0 )
|
||||
opLength = -( (Int32)( -opLen16 ) );
|
||||
else
|
||||
opLength = (UInt32)opLen16;
|
||||
}
|
||||
else
|
||||
opLength = fStream->ReadSwap32();
|
||||
opLength = fStream->ReadLE32();
|
||||
|
||||
// As defined, negative ops are add ops, positive ones are copys
|
||||
if( opLength < 0 )
|
||||
@ -252,7 +252,7 @@ void plDiffBuffer::Apply( UInt32 oldLength, void *oldBuffer, UInt32 &newLengt
|
||||
else
|
||||
{
|
||||
// Copy op, so get the old offset and copy from there
|
||||
UInt32 oldOffset = f16BitMode ? fStream->ReadSwap16() : fStream->ReadSwap32();
|
||||
UInt32 oldOffset = f16BitMode ? fStream->ReadLE16() : fStream->ReadLE32();
|
||||
|
||||
hsAssertAndBreak( newBufferPos + opLength > newLength, "Destination buffer offset in plDiffBuffer() is out of range!" );
|
||||
hsAssertAndBreak( oldOffset + opLength > oldLength, "Difference buffer offset in plDiffBuffer() is out of range of the old buffer!" );
|
||||
|
@ -135,7 +135,7 @@ void plPageInfo::Read( hsStream *s )
|
||||
// 5 is the earliest version since we began working again on the P20 codebase in Sep 2005,
|
||||
// after Uru's online component was cancelled in Feb 2004, so I've removed support for
|
||||
// anything prior to that to clean things up a bit.
|
||||
UInt32 version = s->ReadSwap32();
|
||||
UInt32 version = s->ReadLE32();
|
||||
if (version > sCurrPageInfoVersion || version < 5)
|
||||
{
|
||||
hsAssert( false, "Invalid header version in plPageInfo::Read()" );
|
||||
@ -149,32 +149,32 @@ void plPageInfo::Read( hsStream *s )
|
||||
delete s->ReadSafeString(); // fChapter was never used, and always "District".
|
||||
fPage = s->ReadSafeString();
|
||||
|
||||
s->ReadSwap( &fMajorVersion );
|
||||
s->ReadLE( &fMajorVersion );
|
||||
|
||||
if (version < 6)
|
||||
{
|
||||
UInt16 unusedMinorVersion;
|
||||
s->ReadSwap(&unusedMinorVersion);
|
||||
s->ReadLE(&unusedMinorVersion);
|
||||
Int32 unusedReleaseVersion;
|
||||
s->ReadSwap(&unusedReleaseVersion); // This was always zero... yanked.
|
||||
s->ReadLE(&unusedReleaseVersion); // This was always zero... yanked.
|
||||
UInt32 unusedFlags;
|
||||
s->ReadSwap(&unusedFlags);
|
||||
s->ReadLE(&unusedFlags);
|
||||
}
|
||||
|
||||
s->ReadSwap( &fChecksum );
|
||||
s->ReadSwap( &fDataStart );
|
||||
s->ReadSwap( &fIndexStart );
|
||||
s->ReadLE( &fChecksum );
|
||||
s->ReadLE( &fDataStart );
|
||||
s->ReadLE( &fIndexStart );
|
||||
}
|
||||
|
||||
if (version >= 6)
|
||||
{
|
||||
UInt16 numClassVersions = s->ReadSwap16();
|
||||
UInt16 numClassVersions = s->ReadLE16();
|
||||
fClassVersions.reserve(numClassVersions);
|
||||
for (UInt16 i = 0; i < numClassVersions; i++)
|
||||
{
|
||||
ClassVersion cv;
|
||||
cv.Class = s->ReadSwap16();
|
||||
cv.Version = s->ReadSwap16();
|
||||
cv.Class = s->ReadLE16();
|
||||
cv.Version = s->ReadLE16();
|
||||
fClassVersions.push_back(cv);
|
||||
}
|
||||
}
|
||||
@ -182,21 +182,21 @@ void plPageInfo::Read( hsStream *s )
|
||||
|
||||
void plPageInfo::Write( hsStream *s )
|
||||
{
|
||||
s->WriteSwap32( sCurrPageInfoVersion );
|
||||
s->WriteLE32( sCurrPageInfoVersion );
|
||||
fLocation.Write( s );
|
||||
s->WriteSafeString( fAge );
|
||||
s->WriteSafeString( fPage );
|
||||
s->WriteSwap( fMajorVersion );
|
||||
s->WriteSwap( fChecksum );
|
||||
s->WriteSwap( fDataStart );
|
||||
s->WriteSwap( fIndexStart );
|
||||
s->WriteLE( fMajorVersion );
|
||||
s->WriteLE( fChecksum );
|
||||
s->WriteLE( fDataStart );
|
||||
s->WriteLE( fIndexStart );
|
||||
UInt16 numClassVersions = UInt16(fClassVersions.size());
|
||||
s->WriteSwap16(numClassVersions);
|
||||
s->WriteLE16(numClassVersions);
|
||||
for (UInt16 i = 0; i < numClassVersions; i++)
|
||||
{
|
||||
ClassVersion& cv = fClassVersions[i];
|
||||
s->WriteSwap16(cv.Class);
|
||||
s->WriteSwap16(cv.Version);
|
||||
s->WriteLE16(cv.Class);
|
||||
s->WriteLE16(cv.Version);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ void plRegistryKeyList::PrepForWrite()
|
||||
|
||||
void plRegistryKeyList::Read(hsStream* s)
|
||||
{
|
||||
UInt32 keyListLen = s->ReadSwap32();
|
||||
UInt32 keyListLen = s->ReadLE32();
|
||||
if (!fStaticKeys.empty())
|
||||
{
|
||||
s->Skip(keyListLen);
|
||||
@ -327,7 +327,7 @@ void plRegistryKeyList::Read(hsStream* s)
|
||||
|
||||
fFlags = s->ReadByte();
|
||||
|
||||
UInt32 numKeys = s->ReadSwap32();
|
||||
UInt32 numKeys = s->ReadLE32();
|
||||
fStaticKeys.resize(numKeys);
|
||||
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
@ -342,11 +342,11 @@ void plRegistryKeyList::Write(hsStream* s)
|
||||
{
|
||||
// Save space for the length of our data
|
||||
UInt32 beginPos = s->GetPosition();
|
||||
s->WriteSwap32(0);
|
||||
s->WriteLE32(0);
|
||||
s->WriteByte(fFlags);
|
||||
|
||||
int numKeys = fStaticKeys.size();
|
||||
s->WriteSwap32(numKeys);
|
||||
s->WriteLE32(numKeys);
|
||||
|
||||
// Write out all our keys (anything in dynamic is unused, so just ignore those)
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
@ -358,6 +358,6 @@ void plRegistryKeyList::Write(hsStream* s)
|
||||
// Go back to the start and write the length of our data
|
||||
UInt32 endPos = s->GetPosition();
|
||||
s->SetPosition(beginPos);
|
||||
s->WriteSwap32(endPos-beginPos-sizeof(UInt32));
|
||||
s->WriteLE32(endPos-beginPos-sizeof(UInt32));
|
||||
s->SetPosition(endPos);
|
||||
}
|
||||
|
@ -179,10 +179,10 @@ void plRegistryPageNode::LoadKeys()
|
||||
stream->SetPosition(GetPageInfo().GetIndexStart());
|
||||
|
||||
// Read in the number of key types
|
||||
UInt32 numTypes = stream->ReadSwap32();
|
||||
UInt32 numTypes = stream->ReadLE32();
|
||||
for (UInt32 i = 0; i < numTypes; i++)
|
||||
{
|
||||
UInt16 classType = stream->ReadSwap16();
|
||||
UInt16 classType = stream->ReadLE16();
|
||||
plRegistryKeyList* keyList = IGetKeyList(classType);
|
||||
if (!keyList)
|
||||
{
|
||||
@ -265,11 +265,11 @@ void plRegistryPageNode::Write()
|
||||
fPageInfo.SetIndexStart(fStream.GetPosition());
|
||||
|
||||
// Write our keys
|
||||
fStream.WriteSwap32(fKeyLists.size());
|
||||
fStream.WriteLE32(fKeyLists.size());
|
||||
for (it = fKeyLists.begin(); it != fKeyLists.end(); it++)
|
||||
{
|
||||
plRegistryKeyList* keyList = it->second;
|
||||
fStream.WriteSwap16(keyList->GetClassType());
|
||||
fStream.WriteLE16(keyList->GetClassType());
|
||||
keyList->Write(&fStream);
|
||||
}
|
||||
|
||||
|
@ -951,7 +951,7 @@ hsBool plResManager::Unload(const plKey& objKey)
|
||||
|
||||
plCreatable* plResManager::IReadCreatable(hsStream* s) const
|
||||
{
|
||||
UInt16 hClass = s->ReadSwap16();
|
||||
UInt16 hClass = s->ReadLE16();
|
||||
plCreatable* pCre = plFactory::Create(hClass);
|
||||
if (!pCre)
|
||||
hsAssert( hClass == 0x8000, "Invalid creatable index" );
|
||||
@ -979,7 +979,7 @@ inline void IWriteCreatable(hsStream* s, plCreatable* pCre)
|
||||
{
|
||||
Int16 hClass = pCre ? pCre->ClassIndex() : 0x8000;
|
||||
hsAssert(pCre == nil || plFactory::IsValidClassIndex(hClass), "Invalid class index on write");
|
||||
s->WriteSwap16(hClass);
|
||||
s->WriteLE16(hClass);
|
||||
}
|
||||
|
||||
void plResManager::WriteCreatable(hsStream* s, plCreatable* pCre)
|
||||
|
Reference in New Issue
Block a user