ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Helper/LevelDB.pas
(Generate patch)

Comparing oup/current/Helper/LevelDB.pas (file contents):
Revision 132 by alloc, Wed Mar 28 01:41:10 2007 UTC vs.
Revision 154 by alloc, Sun Apr 1 20:36:23 2007 UTC

# Line 12 | Line 12 | type
12      btn_abortok:  TButton;
13      lbl_estimation: TLabel;
14      procedure btn_abortokClick(Sender: TObject);
15  private
16    procedure HandleFile(Ext: String; FileID: Integer);
17    procedure StopConvert;
15    public
16      procedure CreateDatabase(Source, Target: String);
17      procedure CreateLevel(Source, Target: String);
# Line 27 | Line 24 | var
24   implementation
25   {$R *.dfm}
26   uses ABSMain, ABSDecUtil, Main,
27 <    ConnectionManager, TypeDefs, DataAccess, OniImgClass, Data;
31 <
32 < type
33 <  THandler = procedure(FileID: Integer);
34 <  TConvertHandler = record
35 <    Ext:     String[4];
36 <    Handler: THandler;
37 <  end;
27 >    ConnectionManager, TypeDefs, DataAccess, OniImgClass, Data, RawList;
28  
29   var
40  ConvertHandlers: array of TConvertHandler;
41 //  loaded_filename: String;
30    Converting:  Boolean = False;
31    Abort:       Boolean = False;
32  
# Line 56 | Line 44 | end;
44  
45  
46   procedure TForm_LevelDB.CreateLevel(Source, Target: String);
47 + const
48 +  EmptyBytes: Array[0..31] of Byte = (
49 +      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 );
50   var
51    DatHeader:        THeader;
52    FilesHeader:      TFilesMap;
# Line 67 | Line 58 | var
58  
59    BeginTime, FileTime: Double;
60    Step:     Integer;
70  OniImage:   TOniImage;
61    LevelID:    Integer;
62    TimeFormat: TFormatSettings;
63  
# Line 87 | Line 77 | var
77    RawLinks:   TRawDataList;
78  
79    DatFileStream, RawFileStream: TMemoryStream;
90
91 // ###########################
92  datsum, linksum, rawsum: Int64;
93  freq: Int64;
94  tempticks1, tempticks2: Int64;
95 // ###########################
80   const
81    Steps: Byte = 3;
82  
# Line 107 | Line 91 | const
91        group_progress.Caption := 'Creating Dat (FINISHED)';
92    end;
93  
94 +  procedure StopConvert;
95 +  begin
96 +    btn_abortok.Caption := '&Close';
97 +    btn_abortok.Default := True;
98 +    converting := False;
99 +    lbl_estimation.Caption := 'ABORTED';
100 +    group_progress.Caption := 'Creating Level (ABORTED)';
101 +
102 +    Stream_Body.Free;
103 +    Stream_Names.Free;
104 +    DatFileStream.Free;
105 +    RawFileStream.Free;
106 +    
107 +    Stream_Dat.Free;
108 +    Stream_Raw.Free;
109 +    if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
110 +      Stream_Sep.Free;
111 +    
112 +    if MessageBox(Self.Handle, PChar('Delete the unfinished level-files?'),
113 +      PChar('Delete files?'), MB_YESNO) = idYes then
114 +    begin
115 +      DeleteFile(target);
116 +      DeleteFile(AnsiReplaceStr(Target, '.dat', '.raw'));
117 +      if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
118 +        DeleteFile(AnsiReplaceStr(Target, '.dat', '.sep'));
119 +    end;
120 +  end;
121 +
122   begin
123  
124    //
# Line 176 | Line 188 | begin
188  
189    LevelID  := Connection.LevelNumber;
190    LevelID  := (LevelID * 2) * 256 * 256 * 256 + $01;
179  OniImage := TOniImage.Create;
191  
192    Self.Visible := True;
193    Form_Main.Visible := False;
# Line 191 | Line 202 | begin
202    Stream_Names := TMemoryStream.Create;
203    Stream_Dat   := TFileStream.Create(Target, fmCreate);
204    Stream_Raw   := TFileStream.Create(AnsiReplaceStr(Target, '.dat', '.raw'), fmCreate);
205 +  Stream_Raw.Write(EmptyBytes[0], 32);
206    if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
207 +  begin
208      Stream_Sep := TFileStream.Create(AnsiReplaceStr(Target, '.dat', '.sep'), fmCreate);
209 +    Stream_Sep.Write(EmptyBytes[0], 32);
210 +  end;
211 +
212  
213    DoStep('Creating header');
214    progress.Position      := 0;
# Line 283 | Line 299 | begin
299    lbl_estimation.Caption := 'Estimated finishing time: unknown';
300    Application.ProcessMessages;
301  
286  QueryPerformanceFrequency(freq);
287  datsum := 0;
288  linksum := 0;
289  rawsum := 0;
290
302    FileTime := Time;
303    for FileID := 0 to DatHeader.Files - 1 do
304    begin
# Line 296 | Line 307 | begin
307        FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j];
308      if FileInfo.Size > 0 then
309      begin
299      QueryPerformanceCounter(tempticks1);
300
310        FilesHeader[FileID].DataAddr := Stream_Body.Size + 8;
311        DatFileStream := TMemoryStream.Create;
312        Connection.LoadDatFile(FileID, TStream(DatFileStream));
313 <      DatFileStream.Seek(4, soFromBeginning);
313 >      DatFileStream.Seek(0, soFromBeginning);
314 >      tempi := FileID * 256 + 1;
315 >      DatFileStream.Write(tempi, 4);
316        DatFileStream.Write(LevelID, 4);
317  
307      QueryPerformanceCounter(tempticks2);
308      datsum := datsum + (tempticks2 - tempticks1);
309
318        DatLinks := Connection.GetDatLinks(FileID);
319        if Length(DatLinks) > 0 then
320        begin
# Line 321 | Line 329 | begin
329          end;
330        end;
331  
324      QueryPerformanceCounter(tempticks1);
325      linksum := linksum + (tempticks1 - tempticks2);
326
332        RawLinks := Connection.GetRawList(FileID);
333        if Length(RawLinks) > 0 then
334        begin
# Line 338 | Line 343 | begin
343              begin
344                RawLinks[i].RawAddr := Stream_Sep.Size;
345                Stream_sep.CopyFrom(RawFileStream, RawFileStream.Size);
346 +              if (Stream_Sep.Size mod 32) > 0 then
347 +                Stream_Sep.Write(EmptyBytes[0], 32 - (Stream_Sep.Size mod 32));
348              end else begin
349                RawLinks[i].RawAddr := Stream_Raw.Size;
350                Stream_Raw.CopyFrom(RawFileStream, RawFileStream.Size);
351 +              if (Stream_Raw.Size mod 32) > 0 then
352 +                Stream_Raw.Write(EmptyBytes[0], 32 - (Stream_Raw.Size mod 32));
353              end;
354            end else
355              RawLinks[i].RawAddr := 0;
# Line 350 | Line 359 | begin
359        end;
360        DatFileStream.Seek(0, soFromBeginning);
361        Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size);
362 <
363 <      QueryPerformanceCounter(tempticks2);
364 <      rawsum := rawsum + (tempticks2 - tempticks1);
362 >      if (Stream_Body.Size mod 32) > 0 then
363 >      begin
364 >        ShowMessage(
365 >            IntToStr(FileID) + '-' + FileInfo.Name + '.' + FileInfo.Extension + #13#10 +
366 >            IntToStr(FileInfo.Size) + ' - 0x' + IntToHex(FileInfo.Size, 6) + ' - real: ' + IntToStr(DatFileStream.Size) + ' - 0x' + IntToHex(DatFileStream.Size, 6) + #13#10 +
367 >            IntToStr(Stream_Body.Size) + ' - 0x' + IntToHex(Stream_Body.Size, 6) );
368 >        Stream_Body.Write(EmptyBytes[0], 32 - (Stream_Body.Size mod 32));
369 >      end;
370      end
371      else
372 <      FilesHeader[i].DataAddr := 0;
372 >      FilesHeader[FileID].DataAddr := 0;
373      if Length(fileinfo.Name) > 0 then
374      begin
375 <      FilesHeader[i].NameAddr := Stream_Names.Size;
375 >      FilesHeader[FileID].NameAddr := Stream_Names.Size;
376        temps := fileinfo.Extension + fileinfo.Name + Chr(0);
377        Stream_Names.Write(temps[1], Length(temps));
378      end
379      else
380 <      FilesHeader[i].NameAddr := 0;
381 <    FilesHeader[i].FileSize := fileinfo.Size;
382 <    FilesHeader[i].FileType := fileinfo.FileType;
380 >      FilesHeader[FileID].NameAddr := 0;
381 >    FilesHeader[FileID].FileSize := fileinfo.Size;
382 >    FilesHeader[FileID].FileType := fileinfo.FileType;
383  
384      if ((FileID mod 10) = 0) and (FileID >= 100) then
385        lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
# Line 375 | Line 389 | begin
389      Application.ProcessMessages;
390    end;
391  
378  ShowMessage('AvgDats: ' + FloatToStr((datsum / progress.Max) / freq) + #13#10 +
379      'AvgLinks: ' + FloatToStr((linksum / progress.Max) / freq) + #13#10 +
380      'AvgRaws: ' + FloatToStr((rawsum / progress.Max) / freq)
381   );
382
392    Stream_Dat.Write(DatHeader, SizeOf(DatHeader));
393    for i := 0 to High(FilesHeader) do
394      Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i]));
# Line 388 | Line 397 | begin
397    for i := 0 to High(ExtensionsHeader) do
398      Stream_Dat.Write(ExtensionsHeader[i], SizeOf(ExtensionsHeader[i]));
399  
400 +  if (Stream_Dat.Size mod 32) > 0 then
401 +    Stream_Dat.Write(EmptyBytes[0], 32 - (Stream_Dat.Size mod 32));
402 +
403    DatHeader.DataSize  := Stream_Body.Size;
404    DatHeader.NamesSize := Stream_Names.Size;
405    DatHeader.DataAddr  := Stream_Dat.Size;
406 +
407    Stream_Body.Seek(0, soFromBeginning);
408    Stream_Dat.CopyFrom(Stream_Body, Stream_Body.Size);
409 +
410 +  if (Stream_Dat.Size mod 32) > 0 then
411 +    Stream_Dat.Write(EmptyBytes[0], 32 - (Stream_Dat.Size mod 32));
412 +
413    DatHeader.NamesAddr := Stream_Dat.Size;
414    Stream_Names.Seek(0, soFromBeginning);
415    Stream_Dat.CopyFrom(Stream_Names, Stream_Names.Size);
# Line 417 | Line 434 | begin
434    btn_abortok.Caption := '&OK';
435    btn_abortok.Default := True;
436  
420  OniImage.Free;
421
437    converting := False;
438  
439   //  CloseDataConnection(DataConnections[conIndex]);
# Line 427 | Line 442 | end;
442  
443  
444  
430 procedure TForm_LevelDB.HandleFile;
431 var
432  i: Byte;
433 begin
434 {  for i := 1 to Length(ConvertHandlers) do
435    if UpperCase(ConvertHandlers[i].Ext) = UpperCase(ext) then
436      if ConvertHandlers[i].needed then
437      begin
438        ConvertHandlers[i].Handler(fileid, dir_dat2db);
439        Break;
440      end
441      else
442        Break;
443 }end;
444
445
446
447
445   procedure TForm_LevelDB.CreateDatabase(Source, target: String);
449 {
446   var
447 <  DataBase:    TABSDatabase;
448 <  Query:       TABSQuery;
449 <  MimeCoder:   TStringFormat_MIME64;
454 <
455 <  i, j:     LongWord;
456 <  temps, temps2: String;
457 <  Data:     Tdata;
458 <  absolutebegintime, begintime: Double;
459 <  step:     Byte;
460 <  rawlist:  TRawList;
461 <  extlist:  TExtensionsMap;
462 <  fileinfo: TFileInfo;
463 <  timeformat: TFormatSettings;
447 >  DataBase:  TABSDatabase;
448 >  Query:     TABSQuery;
449 >  MimeCoder: TStringFormat_MIME64;
450  
451 <  conIndex: Integer;
452 < const
453 <  steps: Byte = 4;
451 >  BeginTime, FileTime: Double;
452 >  Step:       Integer;
453 >  TimeFormat: TFormatSettings;
454  
455 +  ConID:      Integer;
456 +  Connection: TDataAccess;
457 +  ConRepMsg:  TStatusMessages;
458  
459 +  FileID:     Integer;
460  
461 +  i:          Integer;
462 +  temps:      String;
463 +  tempdata:   TByteData;
464 +  FileInfo:   TFileInfo;
465 +  DatLinks:   TDatLinkList;
466 +  RawLinks:   TRawDataList;
467 + const
468 +  steps: Byte = 2;
469  
470    procedure DoStep(stepname: String);
471    begin
# Line 478 | Line 476 | const
476      else
477        group_progress.Caption := 'Creating DB (FINISHED)';
478    end;
479 < }
479 >
480 >  procedure StopConvert;
481 >  begin
482 >    btn_abortok.Caption := '&Close';
483 >    btn_abortok.Default := True;
484 >    converting := False;
485 >    lbl_estimation.Caption := 'ABORTED';
486 >    group_progress.Caption := 'Creating DB (ABORTED)';
487 >    DataBase.Close;
488 >    if MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'),
489 >      PChar('Delete file?'), MB_YESNO) = idYes then
490 >    begin
491 >      DeleteFile(target);
492 >    end;
493 > end;
494 >
495 >
496  
497   begin
498 < {  if CreateDataConnection(Source, ODB_Dat) = nil then
498 >
499 >  //
500 >  // FILE EXISTS CHECK FÜR DAT/RAW/SEP!!!
501 >  //
502 >
503 >  TimeFormat.ShortTimeFormat := 'hh:nn:ss';
504 >  TimeFormat.LongTimeFormat  := 'hh:nn:ss';
505 >  TimeFormat.TimeSeparator   := ':';
506 >
507 >  ConID := ConManager.OpenConnection(Source, ConRepMsg);
508 >  if not (ConRepMsg in [SM_OK, SM_AlreadyOpened]) then
509    begin
510 <    ShowMessage('Could not connect to .dat-file');
510 >    ShowMessage('Source-file couldn''t be opened! Aborting' + CrLf + GetOpenMsg(ConRepMsg));
511      Exit;
512 <  end
513 <  else
512 >  end else
513 >    Connection := ConManager.Connection[ConID];
514 >
515 >  ConID := ConManager.FileOpened(Target);
516 >  if ConID >= 0 then
517    begin
518 <    TOniDataDat(OniDataConnection).UnloadWhenUnused := False;
518 >    if MessageBox(Self.Handle, PChar('Destination-file is opened, close it in ' +
519 >          'order to proceed conversion?'), PChar('Destination-file opened'),
520 >          MB_YESNO + MB_ICONQUESTION) = ID_YES then
521 >    begin
522 >      if Form_Main.CheckConnectionCloseable(ConID) then
523 >        if not ConManager.CloseConnection(ConID, ConRepMsg) then
524 >        begin
525 >          ShowMessage('Couldn''t close destination-file. Aborting');
526 >          Exit;
527 >        end;
528 >    end else begin
529 >      ShowMessage('Aborting');
530 >      Exit;
531 >    end;
532    end;
533  
534 <  timeformat.LongTimeFormat := 'hh:nn:ss';
535 <  timeformat.ShortTimeFormat := 'hh:nn:ss';
536 <  timeformat.TimeSeparator := ':';
534 >  if FileExists(Target) then
535 >  begin
536 >    if MessageBox(Self.Handle, PChar('Destination-file exists. ' +
537 >          'Overwrite it?'), PChar('Destination-file exists'),
538 >          MB_YESNO + MB_ICONWARNING) = ID_YES then
539 >    begin
540 >      if not DeleteFile(Target) then
541 >      begin
542 >        ShowMessage('Couldn''t delete file. Aborting');
543 >        Exit;
544 >      end;
545 >    end else begin
546 >      ShowMessage('Aborting');
547 >      Exit;
548 >    end;
549 >  end;
550  
551    Self.Visible := True;
552    Form_Main.Visible := False;
# Line 502 | Line 555 | begin
555    abort := False;
556    btn_abortok.Caption := '&Abort...';
557    btn_abortok.Default := False;
505  loaded_filename := target;
558  
559 <  absolutebegintime := Time;
559 >  BeginTime := Time;
560  
561    DataBase := TABSDatabase.Create(Self);
562 +  DataBase.MaxConnections := 1;
563 +  DataBase.PageSize := 8112;
564 +  DataBase.PageCountInExtent := 8;
565 +
566    DataBase.DatabaseName := 'OLDB';
567    DataBase.DatabaseFileName := target;
568    DataBase.CreateDatabase;
# Line 520 | Line 576 | begin
576    Query := TABSQuery.Create(Self);
577    Query.DatabaseName := 'OLDB';
578    Query.SQL.Text :=
579 <    'CREATE TABLE globals  ( id AUTOINC PRIMARY KEY, name STRING(128), value STRING(128) );';
579 >    'CREATE TABLE globals  ( id AUTOINC PRIMARY KEY, name STRING(128), ' +
580 >    'value STRING(128) );';
581    Query.ExecSQL;
582    Query.SQL.Text :=
583 <    'CREATE TABLE linkmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, target_id INTEGER );';
583 >    'CREATE TABLE linkmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' +
584 >    'src_link_offset INTEGER, target_id INTEGER);';
585 >  Query.ExecSQL;
586 >  Query.SQL.Text := 'CREATE INDEX idsrcid ON linkmap (src_id);';
587 >  Query.ExecSQL;
588 >  Query.SQL.Text := 'CREATE INDEX idtargetid ON linkmap (target_id);';
589    Query.ExecSQL;
590    Query.SQL.Text :=
591 <    'CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, sep BOOLEAN, size INTEGER, data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
591 >    'CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' +
592 >    'src_link_offset INTEGER, sep BOOLEAN, size INTEGER, ' +
593 >    'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib);';
594    //    Query.SQL.Text:='CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
595    Query.ExecSQL;
596 <  Query.SQL.Text :=
533 <    'CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
534 <  //    Query.SQL.Text:='CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
596 >  Query.SQL.Text := 'CREATE INDEX idsrcid ON rawmap (src_id);';
597    Query.ExecSQL;
598    Query.SQL.Text :=
599 <    'CREATE TABLE extlist  ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
599 >    'CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), ' +
600 >    'name STRING(128), contenttype INTEGER, size INTEGER, ' +
601 >    'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
602 >  //    Query.SQL.Text:='CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
603    Query.ExecSQL;
604 + //  Query.SQL.Text :=
605 + //    'CREATE TABLE extlist  ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
606 + //  Query.ExecSQL;
607  
608    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("dbversion","' +
609      dbversion + '");';
610    Query.ExecSQL;
611 <  SetLength(Data, Length(OniDataConnection.LevelInfo.Ident));
544 <  for i := 0 to High(OniDataConnection.LevelInfo.Ident) do
545 <    Data[i] := OniDataConnection.LevelInfo.Ident[i];
546 <  temps := CreateHexString(Data, True);
547 <  Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("ident","' + temps + '");';
548 <  Query.ExecSQL;
611 >
612    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("lvl","' +
613 <    IntToStr(OniDataConnection.LevelInfo.LevelNumber) + '");';
613 >    IntToStr(Connection.LevelNumber) + '");';
614    Query.ExecSQL;
615 <  if OniDataConnection.OSisMAC then
616 <    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","MAC");'
617 <  else
618 <    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","PC");';
619 <  Query.ExecSQL;
557 <
558 <  DoStep('Writing extensionslist');
559 <  progress.Max := Length(OniDataConnection.GetExtensionsList);
560 <  Application.ProcessMessages;
561 <
562 <  extlist := OniDataConnection.GetExtendedExtensionsList;
563 <  for i := 0 to High(extlist) do
564 <  begin
565 <    SetLength(Data, Length(extlist[i].Ident));
566 <    for j := 0 to High(extlist[i].Ident) do
567 <      Data[j] := extlist[i].Ident[j];
568 <    temps := CreateHexString(Data, True);
569 <    temps2 := extlist[i].Extension[3] + extlist[i].Extension[2] +
570 <      extlist[i].Extension[1] + extlist[i].Extension[0];
571 <    Query.SQL.Text := 'INSERT INTO extlist (ext,ident) VALUES ("' +
572 <      temps2 + '","' + temps + '");';
573 <    Query.ExecSQL;
574 <    progress.Position    := i;
575 <    lbl_progress.Caption := 'Extensions done: ' + IntToStr(i) + '/' +
576 <      IntToStr(Length(extlist));
577 <    Application.ProcessMessages;
578 <    if abort then
579 <    begin
580 <      stop_convert;
581 <      Exit;
582 <    end;
615 >  case Connection.DataOS of
616 >    DOS_WIN: temps := 'WIN';
617 >    DOS_WINDEMO: temps := 'WINDEMO';
618 >    DOS_MAC: temps := 'MAC';
619 >    DOS_MACBETA: temps := 'MACBETA';
620    end;
621 <  lbl_progress.Caption := '';
621 >  Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","' + temps + '");';
622 >  Query.ExecSQL;
623  
624    progress.Position      := 0;
625    lbl_progress.Caption   := 'Files done: ' + IntToStr(0) + '/' + IntToStr(
626 <    OniDataConnection.GetFilesCount);
626 >    Connection.GetFileCount);
627    lbl_estimation.Caption := 'Estimated finishing time: unknown';
628  
629 <  DoStep('Loading .dat into memory');
592 <  Application.ProcessMessages;
593 <
594 <  progress.Max := OniDataConnection.GetFilesCount;
629 >  progress.Max := Connection.GetFileCount;
630    begintime    := Time;
631    DoStep('Writing .dat-fileslist');
632    Application.ProcessMessages;
633  
634 +  FileTime := Time;
635    Database.StartTransaction;
636 <  for i := 0 to OniDataConnection.GetFilesCount - 1 do
636 >  for FileID := 0 to Connection.GetFileCount - 1 do
637    begin
638 <    fileinfo := OniDataConnection.GetFileInfo(i);
638 >    fileinfo := Connection.GetFileInfo(FileID);
639      if (fileinfo.FileType and $02) = 0 then
640      begin
641        mimecoder := TStringFormat_MIME64.Create;
642 <      Data      := OniDataConnection.LoadDatFile(i);
642 >      Connection.LoadDatFile(FileID, tempdata);
643        Query.SQL.Text :=
644          'INSERT INTO datfiles (id,extension,name,contenttype,size,data) VALUES (' +
645 <        IntToStr(i) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
645 >        IntToStr(FileID) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
646          fileinfo.FileType, 8) + '",' + IntToStr(fileinfo.Size) + ',MimeToBin("' +
647 <        MimeCoder.StrTo(@Data[0], Length(Data)) + '") );';
647 >        MimeCoder.StrTo(@tempdata[0], Length(tempdata)) + '") );';
648        Query.ExecSQL;
649        mimecoder.Free;
650  
651 <      rawlist := OniDataConnection.GetRawList(i);
652 <      if Length(rawlist) > 0 then
651 >      RawLinks := Connection.GetRawList(FileID);
652 >      if Length(RawLinks) > 0 then
653        begin
654 <        for j := 0 to High(rawlist) do
654 >        for i := 0 to High(RawLinks) do
655          begin
656 <          if rawlist[j].raw_size > 0 then
656 >          if RawLinks[i].RawSize > 0 then
657            begin
658 <            SetLength(Data, rawlist[j].raw_size);
659 <            OniDataConnection.LoadRawFile(i, rawlist[j].src_offset, Data);
658 >            SetLength(tempdata, RawLinks[i].RawSize);
659 >            Connection.LoadRawFile(FileID, RawLinks[i].SrcOffset, tempdata);
660              mimecoder      := TStringFormat_MIME64.Create;
661              Query.SQL.Text :=
662                'INSERT INTO rawmap (src_id,src_link_offset,sep,size,data) VALUES (' +
663 <              IntToStr(i) + ',' + IntToStr(rawlist[j].src_offset) + ',' + BoolToStr(
664 <              rawlist[j].loc_sep) + ',' + IntToStr(rawlist[j].raw_size) + ',MimeToBin("' +
665 <              MimeCoder.StrTo(@Data[0], rawlist[j].raw_size) + '") );';
663 >              IntToStr(FileID) + ', ' + IntToStr(RawLinks[i].SrcOffset) + ',' +
664 >              BoolToStr(RawLinks[i].LocSep) + ', ' +
665 >              IntToStr(RawLinks[i].RawSize) + ', ' +
666 >              'MimeToBin("' + MimeCoder.StrTo(@tempdata[0], RawLinks[i].RawSize) + '") );';
667              Query.ExecSQL;
668              mimecoder.Free;
669            end
# Line 634 | Line 671 | begin
671            begin
672              Query.SQL.Text :=
673                'INSERT INTO rawmap (src_id,src_link_offset,sep,size) VALUES (' +
674 <              IntToStr(i) + ',' + IntToStr(rawlist[j].src_offset) + ',' + BoolToStr(rawlist[j].loc_sep) + ',0);';
674 >              IntToStr(FileID) + ', ' + IntToStr(RawLinks[i].SrcOffset) + ', ' +
675 >              BoolToStr(RawLinks[i].LocSep) + ', 0);';
676              Query.ExecSQL;
677            end;
678          end;
679        end;
680  
681 <      HandleFile(fileinfo.Extension, i, True);
681 >      DatLinks := Connection.GetDatLinks(FileID);
682 >      if Length(DatLinks) > 0 then
683 >      begin
684 >        for i := 0 to High(DatLinks) do
685 >        begin
686 >          Query.SQL.Text :=
687 >            'INSERT INTO linkmap (src_id, src_link_offset, target_id) VALUES (' +
688 >            IntToStr(FileID) + ', ' + IntToStr(DatLinks[i].SrcOffset) + ', ' +
689 >            IntToStr(DatLinks[i].DestID) + ');';
690 >          Query.ExecSQL;
691 >        end;
692 >      end;
693      end
694      else
695      begin
696        Query.SQL.Text :=
697          'INSERT INTO datfiles (id,extension,name,contenttype,size) VALUES (' +
698 <        IntToStr(i) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
699 <        fileinfo.FileType, 8) + '",0);';
698 >        IntToStr(FileID) + ', "' + fileinfo.Extension + '", ' +
699 >        '"' + fileinfo.Name + '", "' + IntToHex(fileinfo.FileType, 8) + '", 0);';
700        Query.ExecSQL;
701      end;
702 <    if ((i mod 100) = 0) and (i > 0) then
702 >    if ((FileID mod 100) = 0) and (FileID > 0) then
703      begin
704        Database.Commit(False);
705        Database.StartTransaction;
706      end;
707 <    if ((i mod 10) = 0) and (i >= 100) then
707 >    if ((FileID mod 10) = 0) and (FileID >= 100) then
708        lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
709 <        (Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat );
710 <    progress.Position := i;
711 <    lbl_progress.Caption := 'Files done: ' + IntToStr(i) + '/' + IntToStr(progress.Max);
709 >        (Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat );
710 >    progress.Position := FileID;
711 >    lbl_progress.Caption := 'Files done: ' + IntToStr(FileID) + '/' + IntToStr(progress.Max);
712      Application.ProcessMessages;
713      if abort then
714      begin
715 <      stop_convert;
715 >      StopConvert;
716        Exit;
717      end;
718    end;
# Line 672 | Line 721 | begin
721    lbl_progress.Caption   := 'Files done: ' + IntToStr(progress.Max) + '/' +
722      IntToStr(progress.Max);
723  
724 <  lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')';
724 >  lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - BeginTime, timeformat) + ')';
725  
726    DoStep('FIN');
727    btn_abortok.Caption := '&OK';
# Line 680 | Line 729 | begin
729  
730    converting := False;
731  
732 <  database.Close;
733 <  database.Free;
685 <
686 <  CloseDataConnection(DataConnections[conIndex]);
687 < }
688 < end;
689 <
690 <
691 <
692 <
693 < procedure TForm_LevelDB.StopConvert;
694 < begin
695 < {  btn_abortok.Caption := '&Close';
696 <  btn_abortok.Default := True;
697 <  converting := False;
698 <  lbl_estimation.Caption := 'ABORTED';
699 <  group_progress.Caption := 'Creating DB (ABORTED)';
732 >  Query.Close;
733 >  Query.Free;
734    DataBase.Close;
735 <  if MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'),
736 <    PChar('Delete file?'), MB_YESNO) = idYes then
703 <  begin
704 <    DeleteFile(loaded_filename);
705 <  end;
706 < }end;
735 >  DataBase.Free;
736 > end;
737  
738  
739  
# Line 725 | Line 755 | begin
755   end;
756  
757  
758 <
729 < {
730 < procedure InsertDatLinkToDB(fileid: LongWord; offset: LongWord);
731 < var
732 <  link: LongWord;
733 < begin
734 <  OniDataConnection.LoadDatFilePart(fileid, offset, 4, @link);
735 <  if link = 0 then
736 <    link := $FFFFFFFF
737 <  else
738 <    link := link div 256;
739 <  Query.SQL.Text := 'INSERT INTO linkmap (src_id,src_link_offset,target_id) VALUES (' +
740 <    IntToStr(fileid) + ',' + IntToStr(offset) + ',' + IntToStr(link) + ');';
741 <  Query.ExecSQL;
742 < end;
743 <
744 <
745 <
746 <
747 < procedure AISA(fileid: LongWord; dir_dat2db: Boolean);
748 < var
749 <  packages: Word;
750 <  i: LongWord;
751 < begin
752 <  if dir_dat2db then
753 <  begin
754 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
755 <    if packages > 0 then
756 <    begin
757 <      for i := 0 to packages - 1 do
758 <        InsertDatLinkToDB(fileid, $20 + i * $160 + $28);
759 <      for i := 0 to packages - 1 do
760 <        InsertDatLinkToDB(fileid, $20 + i * $160 + $150);
761 <    end;
762 <  end
763 <  else
764 <  begin
765 <  end;
766 < end;
767 <
768 <
769 <
770 <
771 < procedure AKEV(fileid: LongWord; dir_dat2db: Boolean);
772 < var
773 <  i: LongWord;
774 < begin
775 <  if dir_dat2db then
776 <  begin
777 <    for i := 0 to 16 do
778 <      InsertDatLinkToDB(fileid, $8 + i * 4);
779 <  end
780 <  else
781 <  begin
782 <  end;
783 < end;
784 <
785 <
786 <
787 <
788 < procedure AKOT(fileid: LongWord; dir_dat2db: Boolean);
789 < var
790 <  i: LongWord;
791 < begin
792 <  if dir_dat2db then
793 <  begin
794 <    for i := 0 to 4 do
795 <      InsertDatLinkToDB(fileid, $8 + i * 4);
796 <  end
797 <  else
798 <  begin
799 <  end;
800 < end;
801 <
802 <
803 <
804 <
805 < procedure CBPI(fileid: LongWord; dir_dat2db: Boolean);
806 < var
807 <  i: LongWord;
808 < begin
809 <  if dir_dat2db then
810 <  begin
811 <    for i := 0 to 56 do
812 <      InsertDatLinkToDB(fileid, $8 + i * 4);
813 <  end
814 <  else
815 <  begin
816 <  end;
817 < end;
818 <
819 <
820 <
821 <
822 < procedure CBPM(fileid: LongWord; dir_dat2db: Boolean);
823 < var
824 <  i: LongWord;
825 < begin
826 <  if dir_dat2db then
827 <  begin
828 <    for i := 0 to 18 do
829 <      InsertDatLinkToDB(fileid, $8 + i * 4);
830 <  end
831 <  else
832 <  begin
833 <  end;
834 < end;
835 <
836 <
837 <
838 <
839 < procedure CONS(fileid: LongWord; dir_dat2db: Boolean);
840 < var
841 <  i: LongWord;
842 < begin
843 <  if dir_dat2db then
844 <  begin
845 <    for i := 0 to 1 do
846 <      InsertDatLinkToDB(fileid, $24 + i * 4);
847 <  end
848 <  else
849 <  begin
850 <  end;
851 < end;
852 <
853 <
854 <
855 <
856 < procedure CRSA(fileid: LongWord; dir_dat2db: Boolean);
857 < var
858 <  packages: LongWord;
859 <  i: LongWord;
860 < begin
861 <  if dir_dat2db then
862 <  begin
863 <    OniDataConnection.LoadDatFilePart(fileid, $14, 4, @packages);
864 <    if packages > 0 then
865 <      for i := 0 to packages - 1 do
866 <        InsertDatLinkToDB(fileid, $20 + i * 1100 + $A0);
867 <  end
868 <  else
869 <  begin
870 <  end;
871 < end;
872 <
873 <
874 <
875 <
876 < procedure DOOR(fileid: LongWord; dir_dat2db: Boolean);
877 < begin
878 <  if dir_dat2db then
879 <  begin
880 <    InsertDatLinkToDB(fileid, $08);
881 <    InsertDatLinkToDB(fileid, $10);
882 <  end
883 <  else
884 <  begin
885 <  end;
886 < end;
887 <
888 <
889 <
890 <
891 < procedure DPGE(fileid: LongWord; dir_dat2db: Boolean);
892 < begin
893 <  if dir_dat2db then
894 <  begin
895 <    InsertDatLinkToDB(fileid, $40);
896 <  end
897 <  else
898 <  begin
899 <  end;
900 < end;
901 <
902 <
903 <
904 <
905 < procedure HPGE(fileid: LongWord; dir_dat2db: Boolean);
906 < begin
907 <  if dir_dat2db then
908 <  begin
909 <    InsertDatLinkToDB(fileid, $0C);
910 <  end
911 <  else
912 <  begin
913 <  end;
914 < end;
915 <
916 <
917 <
918 <
919 < procedure IGHH(fileid: LongWord; dir_dat2db: Boolean);
920 < begin
921 <  if dir_dat2db then
922 <  begin
923 <    InsertDatLinkToDB(fileid, $24);
924 <    InsertDatLinkToDB(fileid, $28);
925 <  end
926 <  else
927 <  begin
928 <  end;
929 < end;
930 <
931 <
932 <
933 <
934 < procedure IGPA(fileid: LongWord; dir_dat2db: Boolean);
935 < var
936 <  links: LongWord;
937 <  i:     LongWord;
938 < begin
939 <  if dir_dat2db then
940 <  begin
941 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
942 <    if links > 0 then
943 <      for i := 0 to links - 1 do
944 <        InsertDatLinkToDB(fileid, $20 + i * 4);
945 <  end
946 <  else
947 <  begin
948 <  end;
949 < end;
950 <
951 <
952 <
953 <
954 < procedure IGPG(fileid: LongWord; dir_dat2db: Boolean);
955 < var
956 <  i: LongWord;
957 < begin
958 <  if dir_dat2db then
959 <  begin
960 <    for i := 0 to 1 do
961 <      InsertDatLinkToDB(fileid, $1C + i * 4);
962 <  end
963 <  else
964 <  begin
965 <  end;
966 < end;
967 <
968 <
969 <
970 <
971 < procedure IGSA(fileid: LongWord; dir_dat2db: Boolean);
972 < var
973 <  links: LongWord;
974 <  i:     LongWord;
975 < begin
976 <  if dir_dat2db then
977 <  begin
978 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
979 <    if links > 0 then
980 <      for i := 0 to links - 1 do
981 <        InsertDatLinkToDB(fileid, $20 + i * 4);
982 <  end
983 <  else
984 <  begin
985 <  end;
986 < end;
987 <
988 <
989 <
990 <
991 < procedure IMPT(fileid: LongWord; dir_dat2db: Boolean);
992 < begin
993 <  if dir_dat2db then
994 <  begin
995 <    InsertDatLinkToDB(fileid, $10);
996 <  end
997 <  else
998 <  begin
999 <  end;
1000 < end;
1001 <
1002 <
1003 <
1004 <
1005 < procedure IPGE(fileid: LongWord; dir_dat2db: Boolean);
1006 < begin
1007 <  if dir_dat2db then
1008 <  begin
1009 <    InsertDatLinkToDB(fileid, $0C);
1010 <  end
1011 <  else
1012 <  begin
1013 <  end;
1014 < end;
1015 <
1016 <
1017 <
1018 <
1019 < procedure KEYI(fileid: LongWord; dir_dat2db: Boolean);
1020 < var
1021 <  i: LongWord;
1022 < begin
1023 <  if dir_dat2db then
1024 <  begin
1025 <    for i := 0 to 9 do
1026 <      InsertDatLinkToDB(fileid, $08 + i * 4);
1027 <  end
1028 <  else
1029 <  begin
1030 <  end;
1031 < end;
1032 <
1033 <
1034 <
1035 <
1036 < procedure M3GA(fileid: LongWord; dir_dat2db: Boolean);
1037 < var
1038 <  links: LongWord;
1039 <  i:     LongWord;
1040 < begin
1041 <  if dir_dat2db then
1042 <  begin
1043 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
1044 <    if links > 0 then
1045 <      for i := 0 to links - 1 do
1046 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1047 <  end
1048 <  else
1049 <  begin
1050 <  end;
1051 < end;
1052 <
1053 <
1054 <
1055 <
1056 < procedure M3GM(fileid: LongWord; dir_dat2db: Boolean);
1057 < var
1058 <  i: LongWord;
1059 < begin
1060 <  if dir_dat2db then
1061 <  begin
1062 <    for i := 0 to 6 do
1063 <      InsertDatLinkToDB(fileid, $0C + i * 4);
1064 <  end
1065 <  else
1066 <  begin
1067 <  end;
1068 < end;
1069 <
1070 <
1071 <
1072 <
1073 < procedure MTRL(fileid: LongWord; dir_dat2db: Boolean);
1074 < begin
1075 <  if dir_dat2db then
1076 <  begin
1077 <    InsertDatLinkToDB(fileid, $10);
1078 <  end
1079 <  else
1080 <  begin
1081 <  end;
1082 < end;
1083 <
1084 <
1085 <
1086 <
1087 < procedure OBDC(fileid: LongWord; dir_dat2db: Boolean);
1088 < var
1089 <  packages: Word;
1090 <  i: LongWord;
1091 < begin
1092 <  if dir_dat2db then
1093 <  begin
1094 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1095 <    if packages > 0 then
1096 <      for i := 0 to packages - 1 do
1097 <        InsertDatLinkToDB(fileid, $20 + i * $18 + $4);
1098 <  end
1099 <  else
1100 <  begin
1101 <  end;
1102 < end;
1103 <
1104 <
1105 <
1106 <
1107 < procedure OBOA(fileid: LongWord; dir_dat2db: Boolean);
1108 < var
1109 <  packages: Word;
1110 <  i: LongWord;
1111 < begin
1112 <  if dir_dat2db then
1113 <  begin
1114 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1115 <    if packages > 0 then
1116 <      for i := 0 to packages - 1 do
1117 <      begin
1118 <        InsertDatLinkToDB(fileid, $20 + i * 240 + $0);
1119 <        InsertDatLinkToDB(fileid, $20 + i * 240 + $4);
1120 <        InsertDatLinkToDB(fileid, $20 + i * 240 + $8);
1121 <      end;
1122 <  end
1123 <  else
1124 <  begin
1125 <  end;
1126 < end;
1127 <
1128 <
1129 <
1130 <
1131 < procedure OFGA(fileid: LongWord; dir_dat2db: Boolean);
1132 < var
1133 <  packages: LongWord;
1134 <  i: LongWord;
1135 < begin
1136 <  if dir_dat2db then
1137 <  begin
1138 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1139 <    if packages > 0 then
1140 <      for i := 0 to packages - 1 do
1141 <        InsertDatLinkToDB(fileid, $20 + i * 12 + $04);
1142 <  end
1143 <  else
1144 <  begin
1145 <  end;
1146 < end;
1147 <
1148 <
1149 <
1150 <
1151 < procedure ONCC(fileid: LongWord; dir_dat2db: Boolean);
1152 < var
1153 <  i: LongWord;
1154 < begin
1155 <  if dir_dat2db then
1156 <  begin
1157 <    InsertDatLinkToDB(fileid, $28);
1158 <    InsertDatLinkToDB(fileid, $434);
1159 <    InsertDatLinkToDB(fileid, $438);
1160 <    InsertDatLinkToDB(fileid, $43C);
1161 <    InsertDatLinkToDB(fileid, $C3C);
1162 <    InsertDatLinkToDB(fileid, $C40);
1163 <    InsertDatLinkToDB(fileid, $C44);
1164 <    InsertDatLinkToDB(fileid, $C48);
1165 <    InsertDatLinkToDB(fileid, $C88);
1166 <    InsertDatLinkToDB(fileid, $C8C);
1167 <  end
1168 <  else
1169 <  begin
1170 <  end;
1171 < end;
1172 <
1173 <
1174 <
1175 <
1176 < procedure ONCV(fileid: LongWord; dir_dat2db: Boolean);
1177 < begin
1178 <  if dir_dat2db then
1179 <  begin
1180 <    InsertDatLinkToDB(fileid, $08);
1181 <  end
1182 <  else
1183 <  begin
1184 <  end;
1185 < end;
1186 <
1187 <
1188 <
1189 <
1190 < procedure ONLV(fileid: LongWord; dir_dat2db: Boolean);
1191 < var
1192 <  i: LongWord;
1193 < begin
1194 <  if dir_dat2db then
1195 <  begin
1196 <    for i := 0 to 5 do
1197 <      InsertDatLinkToDB(fileid, $48 + i * 4);
1198 <    for i := 0 to 5 do
1199 <      InsertDatLinkToDB(fileid, $64 + i * 4);
1200 <    InsertDatLinkToDB(fileid, $300);
1201 <  end
1202 <  else
1203 <  begin
1204 <  end;
1205 < end;
1206 <
1207 <
1208 <
1209 <
1210 < procedure ONOA(fileid: LongWord; dir_dat2db: Boolean);
1211 < var
1212 <  packages: LongWord;
1213 <  i: LongWord;
1214 < begin
1215 <  if dir_dat2db then
1216 <  begin
1217 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1218 <    if packages > 0 then
1219 <      for i := 0 to packages - 1 do
1220 <        InsertDatLinkToDB(fileid, $20 + i * 8 + $04);
1221 <  end
1222 <  else
1223 <  begin
1224 <  end;
1225 < end;
1226 <
1227 <
1228 <
1229 <
1230 < procedure ONSK(fileid: LongWord; dir_dat2db: Boolean);
1231 < begin
1232 <  if dir_dat2db then
1233 <  begin
1234 <    InsertDatLinkToDB(fileid, $08);
1235 <    InsertDatLinkToDB(fileid, $0C);
1236 <    InsertDatLinkToDB(fileid, $10);
1237 <    InsertDatLinkToDB(fileid, $14);
1238 <    InsertDatLinkToDB(fileid, $18);
1239 <    InsertDatLinkToDB(fileid, $20);
1240 <    InsertDatLinkToDB(fileid, $44);
1241 <  end
1242 <  else
1243 <  begin
1244 <  end;
1245 < end;
1246 <
1247 <
1248 <
1249 <
1250 < procedure ONVL(fileid: LongWord; dir_dat2db: Boolean);
1251 < var
1252 <  packages: LongWord;
1253 <  i: LongWord;
1254 < begin
1255 <  if dir_dat2db then
1256 <  begin
1257 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1258 <    if packages > 0 then
1259 <      for i := 0 to packages - 1 do
1260 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1261 <  end
1262 <  else
1263 <  begin
1264 <  end;
1265 < end;
1266 <
1267 <
1268 <
1269 <
1270 < procedure ONWC(fileid: LongWord; dir_dat2db: Boolean);
1271 < begin
1272 <  if dir_dat2db then
1273 <  begin
1274 <    InsertDatLinkToDB(fileid, $28);
1275 <    InsertDatLinkToDB(fileid, $34);
1276 <    InsertDatLinkToDB(fileid, $40);
1277 <    InsertDatLinkToDB(fileid, $54);
1278 <    InsertDatLinkToDB(fileid, $58);
1279 <    InsertDatLinkToDB(fileid, $5C);
1280 <    InsertDatLinkToDB(fileid, $60);
1281 <    InsertDatLinkToDB(fileid, $6FC);
1282 <    InsertDatLinkToDB(fileid, $700);
1283 <  end
1284 <  else
1285 <  begin
1286 <  end;
1287 < end;
1288 <
1289 <
1290 <
1291 <
1292 < procedure OPGE(fileid: LongWord; dir_dat2db: Boolean);
1293 < begin
1294 <  if dir_dat2db then
1295 <  begin
1296 <    InsertDatLinkToDB(fileid, $0C);
1297 <  end
1298 <  else
1299 <  begin
1300 <  end;
1301 < end;
1302 <
1303 <
1304 <
1305 <
1306 < procedure PSPC(fileid: LongWord; dir_dat2db: Boolean);
1307 < begin
1308 <  if dir_dat2db then
1309 <  begin
1310 <    InsertDatLinkToDB(fileid, $50);
1311 <  end
1312 <  else
1313 <  begin
1314 <  end;
1315 < end;
1316 <
1317 <
1318 <
1319 <
1320 < procedure PSPL(fileid: LongWord; dir_dat2db: Boolean);
1321 < var
1322 <  packages: LongWord;
1323 <  i: LongWord;
1324 < begin
1325 <  if dir_dat2db then
1326 <  begin
1327 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1328 <    if packages > 0 then
1329 <      for i := 0 to packages - 1 do
1330 <        InsertDatLinkToDB(fileid, $20 + i * 8 + $4);
1331 <  end
1332 <  else
1333 <  begin
1334 <  end;
1335 < end;
1336 <
1337 <
1338 <
1339 <
1340 < procedure PSUI(fileid: LongWord; dir_dat2db: Boolean);
1341 < var
1342 <  i: LongWord;
1343 < begin
1344 <  if dir_dat2db then
1345 <  begin
1346 <    for i := 0 to 43 do
1347 <      InsertDatLinkToDB(fileid, $08 + i * 4);
1348 <  end
1349 <  else
1350 <  begin
1351 <  end;
1352 < end;
1353 <
1354 <
1355 <
1356 <
1357 < procedure STNA(fileid: LongWord; dir_dat2db: Boolean);
1358 < var
1359 <  packages: Word;
1360 <  i: LongWord;
1361 < begin
1362 <  if dir_dat2db then
1363 <  begin
1364 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1365 <    if packages > 0 then
1366 <      for i := 0 to packages - 1 do
1367 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1368 <  end
1369 <  else
1370 <  begin
1371 <  end;
1372 < end;
1373 <
1374 <
1375 <
1376 <
1377 < procedure TRAC(fileid: LongWord; dir_dat2db: Boolean);
1378 < var
1379 <  packages: Word;
1380 <  i: LongWord;
1381 < begin
1382 <  if dir_dat2db then
1383 <  begin
1384 <    InsertDatLinkToDB(fileid, $18);
1385 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1386 <    if packages > 0 then
1387 <      for i := 0 to packages - 1 do
1388 <        InsertDatLinkToDB(fileid, $20 + i * 12 + 8);
1389 <  end
1390 <  else
1391 <  begin
1392 <  end;
1393 < end;
1394 <
1395 <
1396 <
1397 <
1398 < procedure TRAM(fileid: LongWord; dir_dat2db: Boolean);
1399 < begin
1400 <  if dir_dat2db then
1401 <  begin
1402 <    InsertDatLinkToDB(fileid, $40);
1403 <    InsertDatLinkToDB(fileid, $44);
1404 <  end
1405 <  else
1406 <  begin
1407 <  end;
1408 < end;
1409 <
1410 <
1411 <
1412 <
1413 < procedure TRAS(fileid: LongWord; dir_dat2db: Boolean);
1414 < begin
1415 <  if dir_dat2db then
1416 <  begin
1417 <    InsertDatLinkToDB(fileid, $08);
1418 <  end
1419 <  else
1420 <  begin
1421 <  end;
1422 < end;
1423 <
1424 <
1425 <
1426 <
1427 < procedure TRBS(fileid: LongWord; dir_dat2db: Boolean);
1428 < var
1429 <  i: LongWord;
1430 < begin
1431 <  if dir_dat2db then
1432 <  begin
1433 <    for i := 0 to 4 do
1434 <      InsertDatLinkToDB(fileid, $08 + i * 4);
1435 <  end
1436 <  else
1437 <  begin
1438 <  end;
1439 < end;
1440 <
1441 <
1442 <
1443 <
1444 < procedure TRCM(fileid: LongWord; dir_dat2db: Boolean);
1445 < var
1446 <  i: LongWord;
1447 < begin
1448 <  if dir_dat2db then
1449 <  begin
1450 <    for i := 0 to 2 do
1451 <      InsertDatLinkToDB(fileid, $5C + i * 4);
1452 <  end
1453 <  else
1454 <  begin
1455 <  end;
1456 < end;
1457 <
1458 <
1459 <
1460 <
1461 < procedure TRGA(fileid: LongWord; dir_dat2db: Boolean);
1462 < var
1463 <  i: LongWord;
1464 <  packages: Word;
1465 < begin
1466 <  if dir_dat2db then
1467 <  begin
1468 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1469 <    if packages > 0 then
1470 <      for i := 0 to packages - 1 do
1471 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1472 <  end
1473 <  else
1474 <  begin
1475 <  end;
1476 < end;
1477 <
1478 <
1479 <
1480 <
1481 < procedure TRGE(fileid: LongWord; dir_dat2db: Boolean);
1482 < begin
1483 <  if dir_dat2db then
1484 <  begin
1485 <    InsertDatLinkToDB(fileid, $20);
1486 <  end
1487 <  else
1488 <  begin
1489 <  end;
1490 < end;
1491 <
1492 <
1493 <
1494 <
1495 < procedure TRIG(fileid: LongWord; dir_dat2db: Boolean);
1496 < begin
1497 <  if dir_dat2db then
1498 <  begin
1499 <    InsertDatLinkToDB(fileid, $18);
1500 <    InsertDatLinkToDB(fileid, $24);
1501 <    InsertDatLinkToDB(fileid, $28);
1502 <  end
1503 <  else
1504 <  begin
1505 <  end;
1506 < end;
1507 <
1508 <
1509 <
1510 <
1511 < procedure TRMA(fileid: LongWord; dir_dat2db: Boolean);
1512 < var
1513 <  i: LongWord;
1514 <  packages: Word;
1515 < begin
1516 <  if dir_dat2db then
1517 <  begin
1518 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1519 <    if packages > 0 then
1520 <      for i := 0 to packages - 1 do
1521 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1522 <  end
1523 <  else
1524 <  begin
1525 <  end;
1526 < end;
1527 <
1528 <
1529 <
1530 <
1531 < procedure TRSC(fileid: LongWord; dir_dat2db: Boolean);
1532 < var
1533 <  i: LongWord;
1534 <  packages: Word;
1535 < begin
1536 <  if dir_dat2db then
1537 <  begin
1538 <    OniDataConnection.LoadDatFilePart(fileid, $1E, 2, @packages);
1539 <    if packages > 0 then
1540 <      for i := 0 to packages - 1 do
1541 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1542 <  end
1543 <  else
1544 <  begin
1545 <  end;
1546 < end;
1547 <
1548 <
1549 <
1550 <
1551 < procedure TSFF(fileid: LongWord; dir_dat2db: Boolean);
1552 < var
1553 <  i: LongWord;
1554 <  packages: LongWord;
1555 < begin
1556 <  if dir_dat2db then
1557 <  begin
1558 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1559 <    if packages > 0 then
1560 <      for i := 0 to packages - 1 do
1561 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1562 <  end
1563 <  else
1564 <  begin
1565 <  end;
1566 < end;
1567 <
1568 <
1569 <
1570 <
1571 < procedure TSFT(fileid: LongWord; dir_dat2db: Boolean);
1572 < begin
1573 <  if dir_dat2db then
1574 <  begin
1575 <    InsertDatLinkToDB(fileid, $1C);
1576 <  end
1577 <  else
1578 <  begin
1579 <  end;
1580 < end;
1581 <
1582 <
1583 <
1584 <
1585 < procedure TURR(fileid: LongWord; dir_dat2db: Boolean);
1586 < begin
1587 <  if dir_dat2db then
1588 <  begin
1589 <    InsertDatLinkToDB(fileid, $60);
1590 <    InsertDatLinkToDB(fileid, $6C);
1591 <    InsertDatLinkToDB(fileid, $74);
1592 <  end
1593 <  else
1594 <  begin
1595 <  end;
1596 < end;
1597 <
1598 <
1599 <
1600 <
1601 < procedure TXAN(fileid: LongWord; dir_dat2db: Boolean);
1602 < var
1603 <  i: LongWord;
1604 <  packages: LongWord;
1605 < begin
1606 <  if dir_dat2db then
1607 <  begin
1608 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1609 <    if packages > 0 then
1610 <      for i := 0 to packages - 1 do
1611 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1612 <  end
1613 <  else
1614 <  begin
1615 <  end;
1616 < end;
1617 <
1618 <
1619 <
1620 <
1621 < procedure TXMA(fileid: LongWord; dir_dat2db: Boolean);
1622 < var
1623 <  i: LongWord;
1624 <  packages: LongWord;
1625 < begin
1626 <  if dir_dat2db then
1627 <  begin
1628 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1629 <    if packages > 0 then
1630 <      for i := 0 to packages - 1 do
1631 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1632 <  end
1633 <  else
1634 <  begin
1635 <  end;
1636 < end;
1637 <
1638 <
1639 <
1640 <
1641 < procedure TXMB(fileid: LongWord; dir_dat2db: Boolean);
1642 < var
1643 <  i: LongWord;
1644 <  packages: LongWord;
1645 < begin
1646 <  if dir_dat2db then
1647 <  begin
1648 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1649 <    if packages > 0 then
1650 <      for i := 0 to packages - 1 do
1651 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1652 <  end
1653 <  else
1654 <  begin
1655 <  end;
1656 < end;
1657 <
1658 <
1659 <
1660 <
1661 < procedure TXMP(fileid: LongWord; dir_dat2db: Boolean);
1662 < begin
1663 <  if dir_dat2db then
1664 <  begin
1665 <    InsertDatLinkToDB(fileid, $94);
1666 <    InsertDatLinkToDB(fileid, $98);
1667 <  end
1668 <  else
1669 <  begin
1670 <  end;
1671 < end;
1672 <
1673 <
1674 <
1675 <
1676 < procedure TXTC(fileid: LongWord; dir_dat2db: Boolean);
1677 < begin
1678 <  if dir_dat2db then
1679 <  begin
1680 <    InsertDatLinkToDB(fileid, $08);
1681 <  end
1682 <  else
1683 <  begin
1684 <  end;
1685 < end;
1686 <
1687 <
1688 <
1689 <
1690 < procedure WMCL(fileid: LongWord; dir_dat2db: Boolean);
1691 < var
1692 <  i: LongWord;
1693 <  packages: LongWord;
1694 < begin
1695 <  if dir_dat2db then
1696 <  begin
1697 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1698 <    if packages > 0 then
1699 <      for i := 0 to packages - 1 do
1700 <        InsertDatLinkToDB(fileid, $20 + i * 8 + $4);
1701 <  end
1702 <  else
1703 <  begin
1704 <  end;
1705 < end;
1706 <
1707 <
1708 <
1709 <
1710 < procedure WMDD(fileid: LongWord; dir_dat2db: Boolean);
1711 < var
1712 <  i: LongWord;
1713 <  packages: LongWord;
1714 < begin
1715 <  if dir_dat2db then
1716 <  begin
1717 <    OniDataConnection.LoadDatFilePart(fileid, $11C, 4, @packages);
1718 <    if packages > 0 then
1719 <      for i := 0 to packages - 1 do
1720 <        InsertDatLinkToDB(fileid, $120 + i * $124 + $114);
1721 <  end
1722 <  else
1723 <  begin
1724 <  end;
1725 < end;
1726 <
1727 <
1728 <
1729 <
1730 < procedure WMMB(fileid: LongWord; dir_dat2db: Boolean);
1731 < var
1732 <  i: LongWord;
1733 <  packages: LongWord;
1734 < begin
1735 <  if dir_dat2db then
1736 <  begin
1737 <    OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @packages);
1738 <    if packages > 0 then
1739 <      for i := 0 to packages - 1 do
1740 <        InsertDatLinkToDB(fileid, $20 + i * 4);
1741 <  end
1742 <  else
1743 <  begin
1744 <  end;
1745 < end;
1746 <
1747 <
1748 <
1749 <
1750 < procedure WPGE(fileid: LongWord; dir_dat2db: Boolean);
1751 < begin
1752 <  if dir_dat2db then
1753 <  begin
1754 <    InsertDatLinkToDB(fileid, $08);
1755 <    InsertDatLinkToDB(fileid, $0C);
1756 <  end
1757 <  else
1758 <  begin
1759 <  end;
1760 < end;
1761 < }
1762 <
1763 <
1764 < {
1765 < procedure InsertHandler(ext: String; needed: Boolean; handler: THandler);
1766 < begin
1767 <  SetLength(ConvertHandlers, Length(ConvertHandlers) + 1);
1768 <  ConvertHandlers[High(ConvertHandlers)].Ext     := ext;
1769 <  ConvertHandlers[High(ConvertHandlers)].needed  := needed;
1770 <  ConvertHandlers[High(ConvertHandlers)].handler := handler;
1771 < end;
1772 < }
1773 < begin
1774 < {  InsertHandler('ABNA', False, nil);
1775 <  //  InsertHandler('AGDB',True,AGDB);
1776 <  InsertHandler('AGDB', False, nil);
1777 <  InsertHandler('AGQC', False, nil);
1778 <  InsertHandler('AGQG', False, nil);
1779 <  InsertHandler('AGQR', False, nil);
1780 <  InsertHandler('AISA', True, AISA);
1781 <  InsertHandler('AITR', False, nil);
1782 <  InsertHandler('AKAA', False, nil);
1783 <  InsertHandler('AKBA', False, nil);
1784 <  InsertHandler('AKBP', False, nil);
1785 <  InsertHandler('AKDA', False, nil);
1786 <  InsertHandler('AKEV', True, AKEV);
1787 <  InsertHandler('AKOT', True, AKOT);
1788 <  InsertHandler('AKVA', False, nil);
1789 <  InsertHandler('BINA', False, nil);
1790 <  InsertHandler('CBPI', True, CBPI);
1791 <  InsertHandler('CBPM', True, CBPM);
1792 <  InsertHandler('CONS', True, CONS);
1793 <  InsertHandler('CRSA', True, CRSA);
1794 <  InsertHandler('DOOR', True, DOOR);
1795 <  InsertHandler('DPGE', True, DPGE);
1796 <  InsertHandler('ENVP', False, nil);
1797 <  InsertHandler('FILM', False, nil);
1798 <  InsertHandler('HPGE', True, HPGE);
1799 <  InsertHandler('IDXA', False, nil);
1800 <  InsertHandler('IGHH', True, IGHH);
1801 <  InsertHandler('IGPA', True, IGPA);
1802 <  InsertHandler('IGPG', True, IGPG);
1803 <  InsertHandler('IGSA', True, IGSA);
1804 <  InsertHandler('IMPT', True, IMPT);
1805 <  InsertHandler('IPGE', True, IPGE);
1806 <  InsertHandler('KEYI', True, KEYI);
1807 <  InsertHandler('M3GA', True, M3GA);
1808 <  InsertHandler('M3GM', True, M3GM);
1809 <  InsertHandler('MTRL', True, MTRL);
1810 <  InsertHandler('OBAN', False, nil);
1811 <  InsertHandler('OBDC', True, OBDC);
1812 <  InsertHandler('OBOA', True, OBOA);
1813 <  InsertHandler('OFGA', True, OFGA);
1814 <  InsertHandler('ONCC', True, ONCC);
1815 <  InsertHandler('ONCP', False, nil);
1816 <  InsertHandler('ONCV', True, ONCV);
1817 <  InsertHandler('ONFA', False, nil);
1818 <  InsertHandler('ONGS', False, nil);
1819 <  InsertHandler('ONIA', False, nil);
1820 <  InsertHandler('ONLD', False, nil);
1821 <  InsertHandler('ONLV', True, ONLV);
1822 <  InsertHandler('ONMA', False, nil);
1823 <  InsertHandler('ONOA', True, ONOA);
1824 <  InsertHandler('ONSA', False, nil);
1825 <  InsertHandler('ONSK', True, ONSK);
1826 <  InsertHandler('ONTA', False, nil);
1827 <  InsertHandler('ONVL', True, ONVL);
1828 <  InsertHandler('ONWC', True, ONWC);
1829 <  InsertHandler('OPGE', True, OPGE);
1830 <  InsertHandler('OSBD', False, nil);
1831 <  InsertHandler('OTIT', False, nil);
1832 <  InsertHandler('OTLF', False, nil);
1833 <  InsertHandler('PLEA', False, nil);
1834 <  InsertHandler('PNTA', False, nil);
1835 <  InsertHandler('PSPC', True, PSPC);
1836 <  InsertHandler('PSPL', True, PSPL);
1837 <  InsertHandler('PSUI', True, PSUI);
1838 <  InsertHandler('QTNA', False, nil);
1839 <  InsertHandler('SNDD', False, nil);
1840 <  InsertHandler('STNA', True, STNA);
1841 <  InsertHandler('SUBT', False, nil);
1842 <  InsertHandler('TRAC', True, TRAC);
1843 <  InsertHandler('TRAM', True, TRAM);
1844 <  InsertHandler('TRAS', True, TRAS);
1845 <  InsertHandler('TRBS', True, TRBS);
1846 <  InsertHandler('TRCM', True, TRCM);
1847 <  InsertHandler('TRGA', True, TRGA);
1848 <  InsertHandler('TRGE', True, TRGE);
1849 <  InsertHandler('TRIA', False, nil);
1850 <  InsertHandler('TRIG', True, TRIG);
1851 <  InsertHandler('TRMA', True, TRMA);
1852 <  InsertHandler('TRSC', True, TRSC);
1853 <  InsertHandler('TRTA', False, nil);
1854 <  InsertHandler('TSFF', True, TSFF);
1855 <  InsertHandler('TSFL', False, nil);
1856 <  InsertHandler('TSFT', True, TSFT);
1857 <  InsertHandler('TSGA', False, nil);
1858 <  InsertHandler('TSTR', False, nil);
1859 <  InsertHandler('TURR', True, TURR);
1860 <  InsertHandler('TXAN', True, TXAN);
1861 <  InsertHandler('TXCA', False, nil);
1862 <  InsertHandler('TXMA', True, TXMA);
1863 <  InsertHandler('TXMB', True, TXMB);
1864 <  InsertHandler('TXMP', True, TXMP);
1865 <  InsertHandler('TXTC', True, TXTC);
1866 <  InsertHandler('VCRA', False, nil);
1867 <  InsertHandler('WMCL', True, WMCL);
1868 <  InsertHandler('WMDD', True, WMDD);
1869 <  InsertHandler('WMM_', False, nil);
1870 <  InsertHandler('WMMB', True, WMMB);
1871 <  InsertHandler('WPGE', True, WPGE);
1872 < }end.
758 > end.

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)