comparison LOD.cpp @ 2178:43175acce099

savegame fix
author Ritor1
date Wed, 22 Jan 2014 00:05:10 +0600
parents e1199b655710
children f0b5ca2dfb73
comparison
equal deleted inserted replaced
2177:e1199b655710 2178:43175acce099
1458 memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory)); 1458 memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory));
1459 fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle); 1459 fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle);
1460 return true; 1460 return true;
1461 } 1461 }
1462 1462
1463
1464 //----- (00461F1E) -------------------------------------------------------- 1463 //----- (00461F1E) --------------------------------------------------------
1465 int LODWriteableFile::CreateTempFile() 1464 int LODWriteableFile::CreateTempFile()
1466 { 1465 {
1467 if (!isFileOpened) 1466 if (!isFileOpened)
1468 return 1; 1467 return 1;
1475 return pOutputFileHandle ? 1 : 7; 1474 return pOutputFileHandle ? 1 : 7;
1476 } 1475 }
1477 else 1476 else
1478 return 5; 1477 return 5;
1479 } 1478 }
1480
1481
1482 1479
1483 //----- (00461EE9) -------------------------------------------------------- 1480 //----- (00461EE9) --------------------------------------------------------
1484 void LODWriteableFile::CloseWriteFile() 1481 void LODWriteableFile::CloseWriteFile()
1485 { 1482 {
1486 if (isFileOpened) 1483 if (isFileOpened)
1541 { 1538 {
1542 if ( pSubIndices[i].word_00001E < pDir->word_00001E ) 1539 if ( pSubIndices[i].word_00001E < pDir->word_00001E )
1543 return 4; 1540 return 4;
1544 } 1541 }
1545 else 1542 else
1546 bRewrite_data=true; 1543 bRewrite_data = true;
1547 break; 1544 break;
1548 } 1545 }
1549 if ( a4 == 2 ) 1546 if ( a4 == 2 )
1550 return 4; 1547 return 4;
1551 } 1548 }
1582 } 1579 }
1583 1580
1584 Lindx.uDataSize = total_data_size; 1581 Lindx.uDataSize = total_data_size;
1585 uNumSubDirs = Lindx.uNumSubIndices; 1582 uNumSubDirs = Lindx.uNumSubIndices;
1586 //move indexes +1 after insert point 1583 //move indexes +1 after insert point
1587 if ( !bRewrite_data && (insert_index < uNumSubDirs) ) 1584 if ( !bRewrite_data && (insert_index < uNumSubDirs) )//перезаписывание файлов для освобождения места для нового ф-ла
1588 { 1585 {
1589 for( int i = uNumSubDirs; i > insert_index; --i ) 1586 for( int i = uNumSubDirs; i > insert_index; --i )
1590 memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory)); 1587 memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory));
1591 } 1588 }
1592 //insert 1589 //insert
1593 memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory)); 1590 memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory));//записать текущий файл
1594 //correct offsets to data 1591 //correct offsets to data
1595 if (uNumSubDirs > 0) 1592 if (uNumSubDirs > 0)
1596 { 1593 {
1597 offset_to_data = sizeof(LOD::Directory) * uNumSubDirs; 1594 offset_to_data = sizeof(LOD::Directory) * uNumSubDirs;
1598 for ( int i = 0; i < uNumSubDirs; i++ ) 1595 for ( int i = 0; i < uNumSubDirs; i++ )