Mercurial > mm7
changeset 2176:2f9689a85c31
Слияние
author | Ritor1 |
---|---|
date | Tue, 21 Jan 2014 18:32:43 +0600 |
parents | 5261002b7d39 (diff) 5ca3251ea543 (current diff) |
children | e1199b655710 |
files | LOD.cpp |
diffstat | 1 files changed, 28 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/LOD.cpp Tue Jan 21 16:37:23 2014 +0600 +++ b/LOD.cpp Tue Jan 21 18:32:43 2014 +0600 @@ -1504,7 +1504,7 @@ char Filename[256]; char NewFilename[256]; FILE *tmp_file; - //int comp_res; + int comp_res; bool bRewrite_data; int offset_to_data; int total_data_size; @@ -1517,7 +1517,7 @@ //insert new data in sorted index lod file bRewrite_data = false; insert_index = -1; - if (!isFileOpened)//sometimes gives crash + if ( !isFileOpened )//sometimes gives crash return 1; if ( !pSubIndices ) return 2; @@ -1526,8 +1526,8 @@ for ( int i = 0; i < uNumSubDirs; i++ ) { - //comp_res = _stricmp(pSubIndices[i].pFilename, pDir->pFilename ); - if( !_stricmp(pSubIndices[i].pFilename, pDir->pFilename) ) + comp_res = _stricmp(pSubIndices[i].pFilename, pDir->pFilename); + if( comp_res == 0 ) { insert_index = i; if ( a4 == 0 ) @@ -1537,23 +1537,23 @@ } if ( a4 == 1 ) { - if(pSubIndices[i].uNumSubIndices<pDir->uNumSubIndices) + if ( pSubIndices[i].uNumSubIndices < pDir->uNumSubIndices ) { - if (pSubIndices[i].word_00001E<pDir->word_00001E) + if ( pSubIndices[i].word_00001E < pDir->word_00001E ) return 4; } else - bRewrite_data = true; + bRewrite_data=true; break; } if ( a4 == 2 ) return 4; } - else + else if ( comp_res > 0 ) { if ( insert_index == -1 ) { - insert_index = i; + insert_index=i; break; } } @@ -1563,7 +1563,7 @@ if ( !tmp_file ) return 5; if (!bRewrite_data) - size_correction = 0; + size_correction=0; else size_correction=pSubIndices[insert_index].uDataSize; @@ -1573,37 +1573,37 @@ Lindx.dword_000018 = 0; Lindx.word_00001E = 0; Lindx.uNumSubIndices = uNumSubDirs; - Lindx.uOfsetFromSubindicesStart=sizeof(LOD::FileHeader)+sizeof(LOD::Directory); - total_data_size=uLODDataSize+pDir->uDataSize-size_correction; + Lindx.uOfsetFromSubindicesStart = sizeof(LOD::FileHeader) + sizeof(LOD::Directory); + total_data_size = uLODDataSize + pDir->uDataSize-size_correction; if (!bRewrite_data) { - total_data_size+=sizeof(LOD::Directory); + total_data_size += sizeof(LOD::Directory); Lindx.uNumSubIndices++; } - Lindx.uDataSize=total_data_size; + Lindx.uDataSize = total_data_size; uNumSubDirs = Lindx.uNumSubIndices; //move indexes +1 after insert point - if (!bRewrite_data&&(insert_index<uNumSubDirs)) + if ( !bRewrite_data && (insert_index < uNumSubDirs) ) { - for(int i=uNumSubDirs;i>insert_index; --i) - memcpy(&pSubIndices[i],&pSubIndices[i - 1],sizeof(LOD::Directory)); + for( int i = uNumSubDirs; i > insert_index; --i ) + memcpy(&pSubIndices[i], &pSubIndices[i-1], sizeof(LOD::Directory)); } //insert - memcpy(&pSubIndices[insert_index],pDir,sizeof(LOD::Directory)); + memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory)); //correct offsets to data if (uNumSubDirs > 0) { - offset_to_data=sizeof(LOD::Directory)*uNumSubDirs; - for (int i=0;i<uNumSubDirs; i++) + offset_to_data = sizeof(LOD::Directory) * uNumSubDirs; + for ( int i = 0; i < uNumSubDirs; i++ ) { - pSubIndices[i].uOfsetFromSubindicesStart=offset_to_data; - offset_to_data+=pSubIndices[i].uDataSize; + pSubIndices[i].uOfsetFromSubindicesStart = offset_to_data; + offset_to_data += pSubIndices[i].uDataSize; } } //construct lod file with added data - fwrite( &header, sizeof(LOD::FileHeader), 1, tmp_file); + fwrite(&header, sizeof(LOD::FileHeader), 1, tmp_file); fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); fseek(pFile,Lindx.uOfsetFromSubindicesStart, SEEK_SET); fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); @@ -1614,15 +1614,15 @@ fseek(pFile, offset_to_data, SEEK_CUR); //copy from open lod to temp lod first half - to_copy_size=pSubIndices[insert_index].uOfsetFromSubindicesStart-pSubIndices[0].uOfsetFromSubindicesStart; - while(to_copy_size>0) + to_copy_size = pSubIndices[insert_index].uOfsetFromSubindicesStart - pSubIndices[0].uOfsetFromSubindicesStart; + while(to_copy_size > 0) { read_size = uIOBufferSize; if ( to_copy_size <= uIOBufferSize ) read_size = to_copy_size; fread(pIOBuffer, 1, read_size, pFile); fwrite(pIOBuffer, 1, read_size, tmp_file); - to_copy_size-=read_size; + to_copy_size -= read_size; } // add container data fwrite(pDirData, 1, pDir->uDataSize, tmp_file); @@ -1641,23 +1641,19 @@ read_size = to_copy_size; fread(pIOBuffer, 1, read_size, pFile); fwrite(pIOBuffer, 1, read_size, tmp_file); - to_copy_size-=read_size; + to_copy_size -= read_size; } //replace old file by new with added data strcpy(NewFilename, pLODName); - bool temp_isFileOpened3 = isFileOpened; fclose(tmp_file); - bool temp_isFileOpened2 = isFileOpened; CloseWriteFile(); //isFileOpened == false, current file remove(NewFilename); rename(Filename, NewFilename); - bool temp_isFileOpened1 = isFileOpened; CloseWriteFile(); - bool temp_isFileOpened = isFileOpened; //reload new LoadFile(pLODName, 0);//isFileOpened == true, next file if (isFileOpened == false) - __debugbreak(); + __debugbreak(); return 0; }