CScanCooking: Make use of unsigned stream helpers

This commit is contained in:
Lioncash 2020-06-19 03:40:31 -04:00
parent 61ec2f2e08
commit 125da2d930
1 changed files with 16 additions and 16 deletions

View File

@ -8,37 +8,37 @@ bool CScanCooker::CookSCAN(CScan* pScan, IOutputStream& SCAN)
if (pScan->Game() <= EGame::Prime)
{
// We currently do not support cooking for the MP1 demo build
ASSERT( pScan->Game() != EGame::PrimeDemo );
SCAN.WriteLong( 5 ); // Version number; must be 5
SCAN.WriteLong( 0x0BADBEEF ); // SCAN magic
ASSERT(pScan->Game() != EGame::PrimeDemo);
SCAN.WriteLong(5); // Version number; must be 5
SCAN.WriteLong(0x0BADBEEF); // SCAN magic
CStructRef ScanProperties = pScan->ScanData();
const CStructRef ScanProperties = pScan->ScanData();
CScriptCooker Cooker(pScan->Game());
Cooker.WriteProperty(SCAN, ScanProperties.Property(), ScanProperties.DataPointer(), true);
}
else
{
SCAN.WriteFourCC( FOURCC('SCAN') ); // SCAN magic
SCAN.WriteLong( 2 ); // Version number; must be 2
SCAN.WriteByte( 1 ); // Layer version number; must be 1
SCAN.WriteLong( 1 ); // Instance count
SCAN.WriteLong(2); // Version number; must be 2
SCAN.WriteByte(1) ; // Layer version number; must be 1
SCAN.WriteLong(1); // Instance count
// Scans in MP2/3 are saved with the script object data format
// Write a dummy script object header here
SCAN.WriteLong( FOURCC('SNFO') ); // ScannableObjectInfo object ID
uint ScanInstanceSizeOffset = SCAN.Tell();
SCAN.WriteShort( 0 ); // Object size
SCAN.WriteLong( 0 ); // Instance ID
SCAN.WriteShort( 0 ); // Link count
const uint32 ScanInstanceSizeOffset = SCAN.Tell();
SCAN.WriteShort(0); // Object size
SCAN.WriteLong(0); // Instance ID
SCAN.WriteShort(0); // Link count
CStructRef ScanProperties = pScan->ScanData();
const CStructRef ScanProperties = pScan->ScanData();
CScriptCooker Cooker(pScan->Game());
Cooker.WriteProperty(SCAN, ScanProperties.Property(), ScanProperties.DataPointer(), false);
uint ScanInstanceEnd = SCAN.Tell();
uint ScanInstanceSize = ScanInstanceEnd - ScanInstanceSizeOffset - 2;
const uint32 ScanInstanceEnd = SCAN.Tell();
const uint32 ScanInstanceSize = ScanInstanceEnd - ScanInstanceSizeOffset - 2;
SCAN.GoTo(ScanInstanceSizeOffset);
SCAN.WriteShort( (uint16) ScanInstanceSize );
SCAN.WriteUShort(static_cast<uint16>(ScanInstanceSize));
SCAN.GoTo(ScanInstanceEnd);
// Write dependency list
@ -47,7 +47,7 @@ bool CScanCooker::CookSCAN(CScan* pScan, IOutputStream& SCAN)
std::vector<CAssetID> Dependencies;
CAssetDependencyListBuilder Builder(pScan->Entry());
Builder.BuildDependencyList(Dependencies);
SCAN.WriteLong(Dependencies.size());
SCAN.WriteULong(static_cast<uint32>(Dependencies.size()));
for (const CAssetID& kID : Dependencies)
{