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

Diff Legend

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