| 65 |
|
Stream_Body, Stream_Names: TMemoryStream; |
| 66 |
|
Stream_Dat, Stream_Raw, Stream_Sep: TFileStream; |
| 67 |
|
|
| 68 |
– |
// Data, rawdata: Tdata; |
| 68 |
|
BeginTime, FileTime: Double; |
| 69 |
|
Step: Integer; |
| 71 |
– |
// rawlist: TRawDataList; |
| 72 |
– |
// datlinks: TDatLinks; |
| 70 |
|
OniImage: TOniImage; |
| 71 |
|
LevelID: Integer; |
| 72 |
|
TimeFormat: TFormatSettings; |
| 87 |
|
RawLinks: TRawDataList; |
| 88 |
|
|
| 89 |
|
DatFileStream, RawFileStream: TMemoryStream; |
| 90 |
+ |
|
| 91 |
+ |
// ########################### |
| 92 |
+ |
datsum, linksum, rawsum: Int64; |
| 93 |
+ |
freq: Int64; |
| 94 |
+ |
tempticks1, tempticks2: Int64; |
| 95 |
+ |
// ########################### |
| 96 |
|
const |
| 97 |
|
Steps: Byte = 3; |
| 98 |
|
|
| 154 |
|
begin |
| 155 |
|
ShowMessage('Couldn''t delete file. Aborting'); |
| 156 |
|
Exit; |
| 154 |
– |
end else if not DeleteFile(AnsiReplaceStr(Target, '.dat', '.raw')) then |
| 155 |
– |
begin |
| 156 |
– |
ShowMessage('Couldn''t delete file. Aborting'); |
| 157 |
– |
Exit; |
| 158 |
– |
end else if not DeleteFile(AnsiReplaceStr(Target, '.dat', '.sep')) then |
| 159 |
– |
begin |
| 160 |
– |
ShowMessage('Couldn''t delete file. Aborting'); |
| 161 |
– |
Exit; |
| 157 |
|
end; |
| 158 |
+ |
if FileExists(AnsiReplaceStr(Target, '.dat', '.raw')) then |
| 159 |
+ |
if not DeleteFile(AnsiReplaceStr(Target, '.dat', '.raw')) then |
| 160 |
+ |
begin |
| 161 |
+ |
ShowMessage('Couldn''t delete file. Aborting'); |
| 162 |
+ |
Exit; |
| 163 |
+ |
end; |
| 164 |
+ |
if FileExists(AnsiReplaceStr(Target, '.dat', '.sep')) then |
| 165 |
+ |
if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then |
| 166 |
+ |
if not DeleteFile(AnsiReplaceStr(Target, '.dat', '.sep')) then |
| 167 |
+ |
begin |
| 168 |
+ |
ShowMessage('Couldn''t delete file. Aborting'); |
| 169 |
+ |
Exit; |
| 170 |
+ |
end; |
| 171 |
|
end else begin |
| 172 |
|
ShowMessage('Aborting'); |
| 173 |
|
Exit; |
| 283 |
|
lbl_estimation.Caption := 'Estimated finishing time: unknown'; |
| 284 |
|
Application.ProcessMessages; |
| 285 |
|
|
| 286 |
+ |
QueryPerformanceFrequency(freq); |
| 287 |
+ |
datsum := 0; |
| 288 |
+ |
linksum := 0; |
| 289 |
+ |
rawsum := 0; |
| 290 |
+ |
|
| 291 |
|
FileTime := Time; |
| 292 |
|
for FileID := 0 to DatHeader.Files - 1 do |
| 293 |
|
begin |
| 296 |
|
FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j]; |
| 297 |
|
if FileInfo.Size > 0 then |
| 298 |
|
begin |
| 299 |
+ |
QueryPerformanceCounter(tempticks1); |
| 300 |
+ |
|
| 301 |
|
FilesHeader[FileID].DataAddr := Stream_Body.Size + 8; |
| 302 |
|
DatFileStream := TMemoryStream.Create; |
| 303 |
|
Connection.LoadDatFile(FileID, TStream(DatFileStream)); |
| 304 |
< |
DatFileStream.Seek(4, soFromBeginning); |
| 304 |
> |
DatFileStream.Seek(0, soFromBeginning); |
| 305 |
> |
DatFileStream.Write(FileID, 4); |
| 306 |
|
DatFileStream.Write(LevelID, 4); |
| 307 |
|
|
| 308 |
+ |
QueryPerformanceCounter(tempticks2); |
| 309 |
+ |
datsum := datsum + (tempticks2 - tempticks1); |
| 310 |
+ |
|
| 311 |
|
DatLinks := Connection.GetDatLinks(FileID); |
| 312 |
|
if Length(DatLinks) > 0 then |
| 313 |
|
begin |
| 322 |
|
end; |
| 323 |
|
end; |
| 324 |
|
|
| 325 |
+ |
QueryPerformanceCounter(tempticks1); |
| 326 |
+ |
linksum := linksum + (tempticks1 - tempticks2); |
| 327 |
+ |
|
| 328 |
|
RawLinks := Connection.GetRawList(FileID); |
| 329 |
|
if Length(RawLinks) > 0 then |
| 330 |
|
begin |
| 345 |
|
end; |
| 346 |
|
end else |
| 347 |
|
RawLinks[i].RawAddr := 0; |
| 348 |
+ |
DatFileStream.Seek(RawLinks[i].SrcOffset, soFromBeginning); |
| 349 |
+ |
DatFileStream.Write(RawLinks[i].RawAddr, 4); |
| 350 |
|
end; |
| 351 |
|
end; |
| 352 |
+ |
DatFileStream.Seek(0, soFromBeginning); |
| 353 |
+ |
Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size); |
| 354 |
|
|
| 355 |
< |
{ |
| 356 |
< |
Data[rawlist[j].src_offset + 0] := (rawlist[j].raw_addr) and $FF; |
| 331 |
< |
Data[rawlist[j].src_offset + 1] := (rawlist[j].raw_addr shr 8) and $FF; |
| 332 |
< |
Data[rawlist[j].src_offset + 2] := (rawlist[j].raw_addr shr 16) and $FF; |
| 333 |
< |
Data[rawlist[j].src_offset + 3] := (rawlist[j].raw_addr shr 24) and $FF; |
| 334 |
< |
} |
| 335 |
< |
Stream_Body.Write(Data[0], Length(Data)); |
| 336 |
< |
// |
| 355 |
> |
QueryPerformanceCounter(tempticks2); |
| 356 |
> |
rawsum := rawsum + (tempticks2 - tempticks1); |
| 357 |
|
end |
| 358 |
|
else |
| 359 |
|
FilesHeader[i].DataAddr := 0; |
| 368 |
|
FilesHeader[i].FileSize := fileinfo.Size; |
| 369 |
|
FilesHeader[i].FileType := fileinfo.FileType; |
| 370 |
|
|
| 371 |
< |
if ((i mod 10) = 0) and (i >= 100) then |
| 371 |
> |
if ((FileID mod 10) = 0) and (FileID >= 100) then |
| 372 |
|
lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr( |
| 373 |
< |
(Time - FileTime) / i * (progress.Max - i + 1) * 1.1, TimeFormat ); |
| 374 |
< |
progress.Position := i + 1; |
| 375 |
< |
lbl_progress.Caption := 'Files done: ' + IntToStr(i + 1) + '/' + IntToStr(progress.Max); |
| 373 |
> |
(Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, TimeFormat ); |
| 374 |
> |
progress.Position := FileID + 1; |
| 375 |
> |
lbl_progress.Caption := 'Files done: ' + IntToStr(FileID + 1) + '/' + IntToStr(progress.Max); |
| 376 |
|
Application.ProcessMessages; |
| 377 |
|
end; |
| 378 |
|
|
| 379 |
+ |
ShowMessage('AvgDats: ' + FloatToStr((datsum / progress.Max) / freq) + #13#10 + |
| 380 |
+ |
'AvgLinks: ' + FloatToStr((linksum / progress.Max) / freq) + #13#10 + |
| 381 |
+ |
'AvgRaws: ' + FloatToStr((rawsum / progress.Max) / freq) |
| 382 |
+ |
); |
| 383 |
+ |
|
| 384 |
|
Stream_Dat.Write(DatHeader, SizeOf(DatHeader)); |
| 385 |
|
for i := 0 to High(FilesHeader) do |
| 386 |
|
Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i])); |
| 392 |
|
DatHeader.DataSize := Stream_Body.Size; |
| 393 |
|
DatHeader.NamesSize := Stream_Names.Size; |
| 394 |
|
DatHeader.DataAddr := Stream_Dat.Size; |
| 395 |
+ |
|
| 396 |
|
Stream_Body.Seek(0, soFromBeginning); |
| 397 |
|
Stream_Dat.CopyFrom(Stream_Body, Stream_Body.Size); |
| 398 |
|
DatHeader.NamesAddr := Stream_Dat.Size; |
| 406 |
|
Stream_Body.Free; |
| 407 |
|
Stream_Names.Free; |
| 408 |
|
Stream_Raw.Free; |
| 409 |
< |
if OniDataConnection.OSisMac then |
| 409 |
> |
|
| 410 |
> |
if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then |
| 411 |
|
Stream_Sep.Free; |
| 412 |
|
|
| 413 |
|
progress.Position := progress.Max; |
| 423 |
|
|
| 424 |
|
converting := False; |
| 425 |
|
|
| 426 |
< |
CloseDataConnection(DataConnections[conIndex]); |
| 426 |
> |
// CloseDataConnection(DataConnections[conIndex]); |
| 427 |
|
end; |
| 428 |
|
|
| 429 |
|
|
| 433 |
|
var |
| 434 |
|
i: Byte; |
| 435 |
|
begin |
| 436 |
< |
for i := 1 to Length(ConvertHandlers) do |
| 436 |
> |
{ for i := 1 to Length(ConvertHandlers) do |
| 437 |
|
if UpperCase(ConvertHandlers[i].Ext) = UpperCase(ext) then |
| 438 |
|
if ConvertHandlers[i].needed then |
| 439 |
|
begin |
| 442 |
|
end |
| 443 |
|
else |
| 444 |
|
Break; |
| 445 |
< |
end; |
| 445 |
> |
}end; |
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
procedure TForm_LevelDB.CreateDatabase(Source, target: String); |
| 451 |
+ |
{ |
| 452 |
|
var |
| 453 |
|
DataBase: TABSDatabase; |
| 454 |
|
Query: TABSQuery; |
| 480 |
|
else |
| 481 |
|
group_progress.Caption := 'Creating DB (FINISHED)'; |
| 482 |
|
end; |
| 483 |
+ |
} |
| 484 |
|
|
| 485 |
|
begin |
| 486 |
< |
if CreateDataConnection(Source, ODB_Dat) = nil then |
| 486 |
> |
{ if CreateDataConnection(Source, ODB_Dat) = nil then |
| 487 |
|
begin |
| 488 |
|
ShowMessage('Could not connect to .dat-file'); |
| 489 |
|
Exit; |
| 686 |
|
database.Free; |
| 687 |
|
|
| 688 |
|
CloseDataConnection(DataConnections[conIndex]); |
| 689 |
+ |
} |
| 690 |
|
end; |
| 691 |
|
|
| 692 |
|
|
| 693 |
|
|
| 694 |
|
|
| 695 |
< |
procedure TForm_LevelDB.stop_convert; |
| 695 |
> |
procedure TForm_LevelDB.StopConvert; |
| 696 |
|
begin |
| 697 |
< |
btn_abortok.Caption := '&Close'; |
| 697 |
> |
{ btn_abortok.Caption := '&Close'; |
| 698 |
|
btn_abortok.Default := True; |
| 699 |
|
converting := False; |
| 700 |
|
lbl_estimation.Caption := 'ABORTED'; |
| 705 |
|
begin |
| 706 |
|
DeleteFile(loaded_filename); |
| 707 |
|
end; |
| 708 |
< |
end; |
| 708 |
> |
}end; |
| 709 |
|
|
| 710 |
|
|
| 711 |
|
|
| 728 |
|
|
| 729 |
|
|
| 730 |
|
|
| 731 |
< |
|
| 731 |
> |
{ |
| 732 |
|
procedure InsertDatLinkToDB(fileid: LongWord; offset: LongWord); |
| 733 |
|
var |
| 734 |
|
link: LongWord; |
| 1760 |
|
begin |
| 1761 |
|
end; |
| 1762 |
|
end; |
| 1763 |
+ |
} |
| 1764 |
|
|
| 1765 |
|
|
| 1766 |
< |
|
| 1736 |
< |
|
| 1766 |
> |
{ |
| 1767 |
|
procedure InsertHandler(ext: String; needed: Boolean; handler: THandler); |
| 1768 |
|
begin |
| 1769 |
|
SetLength(ConvertHandlers, Length(ConvertHandlers) + 1); |
| 1771 |
|
ConvertHandlers[High(ConvertHandlers)].needed := needed; |
| 1772 |
|
ConvertHandlers[High(ConvertHandlers)].handler := handler; |
| 1773 |
|
end; |
| 1774 |
< |
|
| 1774 |
> |
} |
| 1775 |
|
begin |
| 1776 |
< |
InsertHandler('ABNA', False, nil); |
| 1776 |
> |
{ InsertHandler('ABNA', False, nil); |
| 1777 |
|
// InsertHandler('AGDB',True,AGDB); |
| 1778 |
|
InsertHandler('AGDB', False, nil); |
| 1779 |
|
InsertHandler('AGQC', False, nil); |
| 1871 |
|
InsertHandler('WMM_', False, nil); |
| 1872 |
|
InsertHandler('WMMB', True, WMMB); |
| 1873 |
|
InsertHandler('WPGE', True, WPGE); |
| 1874 |
< |
end. |
| 1874 |
> |
}end. |