AGS: in asset library files treat offsets & sizes as unsigned values
From upstream 603c5c27165e46afc52b06eed2a9f798ae2ecf4e
This commit is contained in:
parent
a8f4d9dc5b
commit
7d01f1dc1f
1 changed files with 21 additions and 21 deletions
|
@ -165,7 +165,7 @@ MFLUtil::MFLError MFLUtil::ReadSingleFileLib(AssetLibInfo &lib, Stream *in, MFLV
|
|||
int passwmodifier = in->ReadByte();
|
||||
in->ReadInt8(); // unused byte
|
||||
lib.LibFileNames.resize(1); // only one library part
|
||||
size_t asset_count = in->ReadInt16();
|
||||
size_t asset_count = (uint16)in->ReadInt16();
|
||||
lib.AssetInfos.resize(asset_count);
|
||||
|
||||
in->Seek(SingleFilePswLen, kSeekCurrent); // skip password dooberry
|
||||
|
@ -180,7 +180,7 @@ MFLUtil::MFLError MFLUtil::ReadSingleFileLib(AssetLibInfo &lib, Stream *in, MFLV
|
|||
lib.AssetInfos[i].LibUid = 0;
|
||||
}
|
||||
for (size_t i = 0; i < asset_count; ++i) {
|
||||
lib.AssetInfos[i].Size = in->ReadInt32();
|
||||
lib.AssetInfos[i].Size = (uint32)in->ReadInt32();
|
||||
}
|
||||
in->Seek(2 * asset_count, kSeekCurrent); // skip flags & ratio
|
||||
lib.AssetInfos[0].Offset = in->GetPosition();
|
||||
|
@ -213,7 +213,7 @@ MFLUtil::MFLError MFLUtil::ReadMultiFileLib(AssetLibInfo &lib, Stream *in, MFLVe
|
|||
|
||||
MFLUtil::MFLError MFLUtil::ReadV10(AssetLibInfo &lib, Stream *in, MFLVersion lib_version) {
|
||||
// number of clib parts
|
||||
size_t mf_count = in->ReadInt32();
|
||||
size_t mf_count = (uint32)in->ReadInt32();
|
||||
lib.LibFileNames.resize(mf_count);
|
||||
// filenames for all clib parts; filenames are only 20 chars long in this format version
|
||||
for (size_t i = 0; i < mf_count; ++i) {
|
||||
|
@ -221,7 +221,7 @@ MFLUtil::MFLError MFLUtil::ReadV10(AssetLibInfo &lib, Stream *in, MFLVersion lib
|
|||
}
|
||||
|
||||
// number of files in clib
|
||||
size_t asset_count = in->ReadInt32();
|
||||
size_t asset_count = (uint32)in->ReadInt32();
|
||||
// read information on clib contents
|
||||
lib.AssetInfos.resize(asset_count);
|
||||
// filename array is only 25 chars long in this format version
|
||||
|
@ -233,17 +233,17 @@ MFLUtil::MFLError MFLUtil::ReadV10(AssetLibInfo &lib, Stream *in, MFLVersion lib
|
|||
lib.AssetInfos[i].FileName = fn_buf;
|
||||
}
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].Offset = in->ReadInt32();
|
||||
lib.AssetInfos[i].Offset = (uint32)in->ReadInt32();
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].Size = in->ReadInt32();
|
||||
lib.AssetInfos[i].Size = (uint32)in->ReadInt32();
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].LibUid = in->ReadInt8();
|
||||
lib.AssetInfos[i].LibUid = (uint32)in->ReadInt8();
|
||||
return kMFLNoError;
|
||||
}
|
||||
|
||||
MFLUtil::MFLError MFLUtil::ReadV20(AssetLibInfo &lib, Stream *in) {
|
||||
// number of clib parts
|
||||
size_t mf_count = in->ReadInt32();
|
||||
size_t mf_count = (uint32)in->ReadInt32();
|
||||
lib.LibFileNames.resize(mf_count);
|
||||
// filenames for all clib parts
|
||||
for (size_t i = 0; i < mf_count; ++i) {
|
||||
|
@ -251,12 +251,12 @@ MFLUtil::MFLError MFLUtil::ReadV20(AssetLibInfo &lib, Stream *in) {
|
|||
}
|
||||
|
||||
// number of files in clib
|
||||
size_t asset_count = in->ReadInt32();
|
||||
size_t asset_count = (uint32)in->ReadInt32();
|
||||
// read information on clib contents
|
||||
lib.AssetInfos.resize(asset_count);
|
||||
char fn_buf[MaxAssetFileLen];
|
||||
for (size_t i = 0; i < asset_count; ++i) {
|
||||
short len = in->ReadInt16();
|
||||
size_t len = in->ReadInt16();
|
||||
len /= 5; // CHECKME: why 5?
|
||||
if (len > MaxAssetFileLen)
|
||||
return kMFLErrAssetNameLong;
|
||||
|
@ -266,11 +266,11 @@ MFLUtil::MFLError MFLUtil::ReadV20(AssetLibInfo &lib, Stream *in) {
|
|||
lib.AssetInfos[i].FileName = fn_buf;
|
||||
}
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].Offset = in->ReadInt32();
|
||||
lib.AssetInfos[i].Offset = (uint32)in->ReadInt32();
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].Size = in->ReadInt32();
|
||||
lib.AssetInfos[i].Size = (uint32)in->ReadInt32();
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].LibUid = in->ReadInt8();
|
||||
lib.AssetInfos[i].LibUid = (uint32)in->ReadInt8();
|
||||
return kMFLNoError;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ MFLUtil::MFLError MFLUtil::ReadV21(AssetLibInfo &lib, Stream *in) {
|
|||
// init randomizer
|
||||
int rand_val = in->ReadInt32() + EncryptionRandSeed;
|
||||
// number of clib parts
|
||||
size_t mf_count = ReadEncInt32(in, rand_val);
|
||||
size_t mf_count = (uint32)ReadEncInt32(in, rand_val);
|
||||
lib.LibFileNames.resize(mf_count);
|
||||
// filenames for all clib parts
|
||||
char fn_buf[MaxDataFileLen > MaxAssetFileLen ? MaxDataFileLen : MaxAssetFileLen];
|
||||
|
@ -288,7 +288,7 @@ MFLUtil::MFLError MFLUtil::ReadV21(AssetLibInfo &lib, Stream *in) {
|
|||
}
|
||||
|
||||
// number of files in clib
|
||||
size_t asset_count = ReadEncInt32(in, rand_val);
|
||||
size_t asset_count = (uint32)ReadEncInt32(in, rand_val);
|
||||
// read information on clib contents
|
||||
lib.AssetInfos.resize(asset_count);
|
||||
for (size_t i = 0; i < asset_count; ++i) {
|
||||
|
@ -296,11 +296,11 @@ MFLUtil::MFLError MFLUtil::ReadV21(AssetLibInfo &lib, Stream *in) {
|
|||
lib.AssetInfos[i].FileName = fn_buf;
|
||||
}
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].Offset = ReadEncInt32(in, rand_val);
|
||||
lib.AssetInfos[i].Offset = (uint32)ReadEncInt32(in, rand_val);
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].Size = ReadEncInt32(in, rand_val);
|
||||
lib.AssetInfos[i].Size = (uint32)ReadEncInt32(in, rand_val);
|
||||
for (size_t i = 0; i < asset_count; ++i)
|
||||
lib.AssetInfos[i].LibUid = ReadEncInt8(in, rand_val);
|
||||
lib.AssetInfos[i].LibUid = (uint32)ReadEncInt8(in, rand_val);
|
||||
return kMFLNoError;
|
||||
}
|
||||
|
||||
|
@ -310,19 +310,19 @@ MFLUtil::MFLError MFLUtil::ReadV30(AssetLibInfo &lib, Stream *in, MFLVersion /*
|
|||
// as one of the options here.
|
||||
/* int flags = */ in->ReadInt32(); // reserved options
|
||||
// number of clib parts
|
||||
size_t mf_count = in->ReadInt32();
|
||||
size_t mf_count = (uint32)in->ReadInt32();
|
||||
lib.LibFileNames.resize(mf_count);
|
||||
// filenames for all clib parts
|
||||
for (size_t i = 0; i < mf_count; ++i)
|
||||
lib.LibFileNames[i] = String::FromStream(in);
|
||||
|
||||
// number of files in clib
|
||||
size_t asset_count = in->ReadInt32();
|
||||
size_t asset_count = (uint32)in->ReadInt32();
|
||||
// read information on clib contents
|
||||
lib.AssetInfos.resize(asset_count);
|
||||
for (auto &asset : lib.AssetInfos) {
|
||||
asset.FileName = String::FromStream(in);
|
||||
asset.LibUid = in->ReadInt8();
|
||||
asset.LibUid = (uint8)in->ReadInt8();
|
||||
asset.Offset = in->ReadInt64();
|
||||
asset.Size = in->ReadInt64();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue