update serialization mainly for Blender .blend reading, it has to do with pointer arrays not being swapped properly (Bullet .bullet doesn't use pointer arrays so it isn't affected)
Thanks a lot to Charlie/snailrose for the fix
This commit is contained in:
@@ -295,8 +295,9 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
|||||||
|
|
||||||
numallocs++;
|
numallocs++;
|
||||||
// numBlocks * length
|
// numBlocks * length
|
||||||
char *dataAlloc = new char[(dataChunk.nr*curLen)+1];
|
int allocLen = curLen > oldLen ? curLen : oldLen;
|
||||||
memset(dataAlloc, 0, (dataChunk.nr*curLen)+1);
|
char *dataAlloc = new char[(dataChunk.nr*allocLen)+1];
|
||||||
|
memset(dataAlloc, 0, (dataChunk.nr*allocLen)+1);
|
||||||
|
|
||||||
// track allocated
|
// track allocated
|
||||||
addDataBlock(dataAlloc);
|
addDataBlock(dataAlloc);
|
||||||
@@ -552,8 +553,8 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
|||||||
if (name[0] == '*')
|
if (name[0] == '*')
|
||||||
{
|
{
|
||||||
// cast pointers
|
// cast pointers
|
||||||
//int ptrFile = mFileDNA->getPointerSize();
|
int ptrFile = mFileDNA->getPointerSize();
|
||||||
//int ptrMem = mMemoryDNA->getPointerSize();
|
int ptrMem = mMemoryDNA->getPointerSize();
|
||||||
|
|
||||||
swapPtr(strcData, data);
|
swapPtr(strcData, data);
|
||||||
|
|
||||||
@@ -561,13 +562,19 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
|||||||
{
|
{
|
||||||
if (arrayLen > 1)
|
if (arrayLen > 1)
|
||||||
{
|
{
|
||||||
void **sarray = (void**)strcData;
|
//void **sarray = (void**)strcData;
|
||||||
void **darray = (void**)data;
|
//void **darray = (void**)data;
|
||||||
|
|
||||||
|
char *cpc, *cpo;
|
||||||
|
cpc = (char*)strcData;
|
||||||
|
cpo = (char*)data;
|
||||||
|
|
||||||
for (int a=0; a<arrayLen; a++)
|
for (int a=0; a<arrayLen; a++)
|
||||||
{
|
{
|
||||||
swapPtr((char*)&sarray[a], (char*)&darray[a]);
|
swapPtr(cpc, cpo);
|
||||||
m_pointerFixupArray.push_back((char*)&sarray[a]);
|
m_pointerFixupArray.push_back(cpc);
|
||||||
|
cpc += ptrMem;
|
||||||
|
cpo += ptrFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -698,7 +705,6 @@ void bFile::resolvePointersMismatch()
|
|||||||
// printf("pointer not found: %x\n",cur);
|
// printf("pointer not found: %x\n",cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i< m_pointerPtrFixupArray.size();i++)
|
for (i=0;i< m_pointerPtrFixupArray.size();i++)
|
||||||
{
|
{
|
||||||
char* cur= m_pointerPtrFixupArray.at(i);
|
char* cur= m_pointerPtrFixupArray.at(i);
|
||||||
@@ -709,16 +715,28 @@ void bFile::resolvePointersMismatch()
|
|||||||
(*ptrptr) = ptr;
|
(*ptrptr) = ptr;
|
||||||
|
|
||||||
void **array= (void**)(*(ptrptr));
|
void **array= (void**)(*(ptrptr));
|
||||||
|
int ptrMem = mMemoryDNA->getPointerSize();
|
||||||
|
int ptrFile = mFileDNA->getPointerSize();
|
||||||
|
|
||||||
|
|
||||||
int n=0, n2=0;
|
int n=0, n2=0;
|
||||||
int swapoffs = mFileDNA->getPointerSize() > mMemoryDNA->getPointerSize() ? 2 : 1;
|
int swapoffs = 2;
|
||||||
void *np = array[n];
|
void *np = array[n];
|
||||||
while(np)
|
while(np)
|
||||||
{
|
{
|
||||||
if (mFlags & FD_BITS_VARIES)
|
if (ptrMem > ptrFile)
|
||||||
|
{
|
||||||
|
swapPtr((char*)&array[n2], (char*)&array[n]);
|
||||||
|
np = findLibPointer(array[n2]);
|
||||||
|
}
|
||||||
|
else if (ptrMem < ptrFile)
|
||||||
|
{
|
||||||
swapPtr((char*)&array[n], (char*)&array[n2]);
|
swapPtr((char*)&array[n], (char*)&array[n2]);
|
||||||
|
|
||||||
np = findLibPointer(array[n]);
|
np = findLibPointer(array[n]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
np = findLibPointer(array[n]);
|
||||||
|
|
||||||
if (np)
|
if (np)
|
||||||
array[n] = np;
|
array[n] = np;
|
||||||
++n;
|
++n;
|
||||||
|
|||||||
Reference in New Issue
Block a user