comparison LOD.cpp @ 415:49158f2cc88d

little lod refactor
author Gloval
date Sat, 23 Feb 2013 19:35:15 +0400
parents 96bc024a5fed
children 6f7d936edc9b
comparison
equal deleted inserted replaced
413:111f25d1cc04 415:49158f2cc88d
1945 1945
1946 1946
1947 //----- (0046188A) -------------------------------------------------------- 1947 //----- (0046188A) --------------------------------------------------------
1948 int LOD::File::LoadSubIndices(const char *pContainer) 1948 int LOD::File::LoadSubIndices(const char *pContainer)
1949 { 1949 {
1950 LOD::File *v2; // esi@1 1950
1951 unsigned int uDir; // edi@1 1951 unsigned int uDir; // edi@1
1952 int uDir_dup; // ebx@2 1952 LOD::Directory *curr_index; // eax@7
1953 int result; // eax@5 1953
1954 LOD::Directory *v6; // eax@7 1954
1955 LOD::Directory *v7; // eax@7
1956 __int32 v8; // edx@7
1957 FILE *v9; // ST00_4@7
1958 LOD::Directory *pSubIndices_dup; // eax@7
1959
1960 v2 = this;
1961 ResetSubIndices(); 1955 ResetSubIndices();
1962 uDir = 0; 1956 uDir = 0;
1963 if ( (signed int)v2->header.uNumIndices <= 0 ) 1957
1964 { 1958 if ( header.uNumIndices <= 0)
1965 LABEL_5: 1959 return 3;
1966 result = 3;
1967 }
1968 else 1960 else
1969 { 1961 {
1970 uDir_dup = 0; 1962 while (stricmp(pContainer, pRoot[uDir].pFilename))
1971 while ( _strcmpi(pContainer, (const char *)&v2->pRoot[uDir_dup]) ) 1963 {
1972 { 1964 ++uDir;
1973 ++uDir; 1965 if (uDir >= header.uNumIndices )
1974 ++uDir_dup; 1966 return 3;
1975 if ( (signed int)uDir >= (signed int)v2->header.uNumIndices ) 1967 }
1976 goto LABEL_5; 1968 strcpy( pContainerName, pContainer);
1977 } 1969 uCurrentIndexDir = uDir;
1978 strcpy((char *)v2->pContainerName, pContainer); 1970 curr_index=(LOD::Directory *)&pRoot[uDir];
1979 v6 = v2->pRoot; 1971 uOffsetToSubIndex =curr_index->uOfsetFromSubindicesStart ;
1980 v2->uCurrentIndexDir = uDir; 1972 uNumSubIndices =curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28);
1981 v7 = &v6[uDir]; 1973 fseek( pFile, uOffsetToSubIndex, 0);
1982 v8 = v7->uOfsetFromSubindicesStart; 1974 pSubIndices = (LOD::Directory *)pAllocator->AllocNamedChunk(pSubIndices, sizeof(LOD::Directory)*(uNumSubIndices + 5), "LOD Index");
1983 v2->uOffsetToSubIndex = v8; 1975
1984 v9 = v2->pFile; 1976 if ( pSubIndices)
1985 v2->uNumSubIndices = v7->uNumSubIndices; 1977 fread( pSubIndices, sizeof(LOD::Directory), uNumSubIndices, pFile);
1986 fseek(v9, v8, 0); 1978 return 0;
1987 pSubIndices_dup = (LOD::Directory *)pAllocator->AllocNamedChunk( 1979 }
1988 v2->pSubIndices,
1989 32 * (v2->uNumSubIndices + 5),
1990 "LOD Index");
1991 v2->pSubIndices = pSubIndices_dup;
1992 if ( pSubIndices_dup )
1993 fread(pSubIndices_dup, 0x20u, v2->uNumSubIndices, v2->pFile);
1994 result = 0;
1995 }
1996 return result;
1997 } 1980 }
1998 1981
1999 //----- (004617D5) -------------------------------------------------------- 1982 //----- (004617D5) --------------------------------------------------------
2000 bool LOD::File::LoadHeader(const char *pFilename, bool bWriting) 1983 bool LOD::File::LoadHeader(const char *pFilename, bool bWriting)
2001 { 1984 {