Mercurial > mm7
diff LOD.cpp @ 415:49158f2cc88d
little lod refactor
author | Gloval |
---|---|
date | Sat, 23 Feb 2013 19:35:15 +0400 |
parents | 96bc024a5fed |
children | 6f7d936edc9b |
line wrap: on
line diff
--- a/LOD.cpp Sat Feb 23 16:39:32 2013 +0200 +++ b/LOD.cpp Sat Feb 23 19:35:15 2013 +0400 @@ -1947,53 +1947,36 @@ //----- (0046188A) -------------------------------------------------------- int LOD::File::LoadSubIndices(const char *pContainer) { - LOD::File *v2; // esi@1 + unsigned int uDir; // edi@1 - int uDir_dup; // ebx@2 - int result; // eax@5 - LOD::Directory *v6; // eax@7 - LOD::Directory *v7; // eax@7 - __int32 v8; // edx@7 - FILE *v9; // ST00_4@7 - LOD::Directory *pSubIndices_dup; // eax@7 + LOD::Directory *curr_index; // eax@7 - v2 = this; + ResetSubIndices(); uDir = 0; - if ( (signed int)v2->header.uNumIndices <= 0 ) - { -LABEL_5: - result = 3; - } + + if ( header.uNumIndices <= 0) + return 3; else - { - uDir_dup = 0; - while ( _strcmpi(pContainer, (const char *)&v2->pRoot[uDir_dup]) ) - { - ++uDir; - ++uDir_dup; - if ( (signed int)uDir >= (signed int)v2->header.uNumIndices ) - goto LABEL_5; - } - strcpy((char *)v2->pContainerName, pContainer); - v6 = v2->pRoot; - v2->uCurrentIndexDir = uDir; - v7 = &v6[uDir]; - v8 = v7->uOfsetFromSubindicesStart; - v2->uOffsetToSubIndex = v8; - v9 = v2->pFile; - v2->uNumSubIndices = v7->uNumSubIndices; - fseek(v9, v8, 0); - pSubIndices_dup = (LOD::Directory *)pAllocator->AllocNamedChunk( - v2->pSubIndices, - 32 * (v2->uNumSubIndices + 5), - "LOD Index"); - v2->pSubIndices = pSubIndices_dup; - if ( pSubIndices_dup ) - fread(pSubIndices_dup, 0x20u, v2->uNumSubIndices, v2->pFile); - result = 0; - } - return result; + { + while (stricmp(pContainer, pRoot[uDir].pFilename)) + { + ++uDir; + if (uDir >= header.uNumIndices ) + return 3; + } + strcpy( pContainerName, pContainer); + uCurrentIndexDir = uDir; + curr_index=(LOD::Directory *)&pRoot[uDir]; + uOffsetToSubIndex =curr_index->uOfsetFromSubindicesStart ; + uNumSubIndices =curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28); + fseek( pFile, uOffsetToSubIndex, 0); + pSubIndices = (LOD::Directory *)pAllocator->AllocNamedChunk(pSubIndices, sizeof(LOD::Directory)*(uNumSubIndices + 5), "LOD Index"); + + if ( pSubIndices) + fread( pSubIndices, sizeof(LOD::Directory), uNumSubIndices, pFile); + return 0; + } } //----- (004617D5) --------------------------------------------------------