Merge pull request #2948 from malortie/update-texture-format-size

Updated places where read/write for achFormatHint (Redone).
pull/2952/head
Kim Kulling 2020-01-24 11:27:00 +01:00 committed by GitHub
commit dbee3807b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 6 deletions

View File

@ -413,7 +413,8 @@ protected:
Write<unsigned int>(&chunk,tex->mWidth); Write<unsigned int>(&chunk,tex->mWidth);
Write<unsigned int>(&chunk,tex->mHeight); Write<unsigned int>(&chunk,tex->mHeight);
chunk.Write( tex->achFormatHint, sizeof(char), 4 ); // Write the texture format, but don't include the null terminator.
chunk.Write( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
if(!shortened) { if(!shortened) {
if (!tex->mHeight) { if (!tex->mHeight) {

View File

@ -535,7 +535,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
tex->mWidth = Read<unsigned int>(stream); tex->mWidth = Read<unsigned int>(stream);
tex->mHeight = Read<unsigned int>(stream); tex->mHeight = Read<unsigned int>(stream);
stream->Read( tex->achFormatHint, sizeof(char), 4 ); stream->Read( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
if(!shortened) { if(!shortened) {
if (!tex->mHeight) { if (!tex->mHeight) {

View File

@ -798,7 +798,7 @@ void ValidateDSProcess::Validate( const aiTexture* pTexture)
if (!pTexture->mWidth) { if (!pTexture->mWidth) {
ReportError("aiTexture::mWidth is zero (compressed texture)"); ReportError("aiTexture::mWidth is zero (compressed texture)");
} }
if ('\0' != pTexture->achFormatHint[3]) { if ('\0' != pTexture->achFormatHint[HINTMAXTEXTURELEN - 1]) {
ReportWarning("aiTexture::achFormatHint must be zero-terminated"); ReportWarning("aiTexture::achFormatHint must be zero-terminated");
} }
else if ('.' == pTexture->achFormatHint[0]) { else if ('.' == pTexture->achFormatHint[0]) {

View File

@ -207,8 +207,7 @@ struct aiTexture {
, mHeight(0) , mHeight(0)
, pcData(nullptr) , pcData(nullptr)
, mFilename() { , mFilename() {
achFormatHint[0] = achFormatHint[1] = 0; memset(achFormatHint, 0, sizeof(achFormatHint));
achFormatHint[2] = achFormatHint[3] = 0;
} }
// Destruction // Destruction

View File

@ -800,6 +800,10 @@ void CompareOnTheFlyTexture(comparer_context& comp) {
comp.cmp<char>("achFormatHint[1]"); comp.cmp<char>("achFormatHint[1]");
comp.cmp<char>("achFormatHint[2]"); comp.cmp<char>("achFormatHint[2]");
comp.cmp<char>("achFormatHint[3]"); comp.cmp<char>("achFormatHint[3]");
comp.cmp<char>("achFormatHint[4]");
comp.cmp<char>("achFormatHint[5]");
comp.cmp<char>("achFormatHint[6]");
comp.cmp<char>("achFormatHint[7]");
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -312,7 +312,8 @@ uint32_t WriteBinaryTexture(const aiTexture* tex)
len += Write<unsigned int>(tex->mWidth); len += Write<unsigned int>(tex->mWidth);
len += Write<unsigned int>(tex->mHeight); len += Write<unsigned int>(tex->mHeight);
len += static_cast<uint32_t>(fwrite(tex->achFormatHint,1,4,out)); // Write the texture format, but don't include the null terminator.
len += static_cast<uint32_t>(fwrite(tex->achFormatHint,sizeof(char),HINTMAXTEXTURELEN - 1,out));
if(!shortened) { if(!shortened) {
if (!tex->mHeight) { if (!tex->mHeight) {