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 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 65 | Line 56 | var
56    Stream_Body, Stream_Names:          TMemoryStream;
57    Stream_Dat, Stream_Raw, Stream_Sep: TFileStream;
58  
68 //  Data, rawdata: Tdata;
59    BeginTime, FileTime: Double;
60    Step:     Integer;
71 //  rawlist:  TRawDataList;
72 //  datlinks: TDatLinks;
73  OniImage:   TOniImage;
61    LevelID:    Integer;
62    TimeFormat: TFormatSettings;
63  
# Line 104 | 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 173 | Line 188 | begin
188  
189    LevelID  := Connection.LevelNumber;
190    LevelID  := (LevelID * 2) * 256 * 256 * 256 + $01;
176  OniImage := TOniImage.Create;
191  
192    Self.Visible := True;
193    Form_Main.Visible := False;
# Line 188 | 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 291 | Line 310 | begin
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  
318        DatLinks := Connection.GetDatLinks(FileID);
# Line 322 | 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 334 | Line 359 | begin
359        end;
360        DatFileStream.Seek(0, soFromBeginning);
361        Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size);
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 364 | 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 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 >  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 454 | 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 478 | Line 555 | begin
555    abort := False;
556    btn_abortok.Caption := '&Abort...';
557    btn_abortok.Default := False;
481  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 496 | 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 :=
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 );';
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));
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;
611 >
612    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("lvl","' +
613 <    IntToStr(OniDataConnection.LevelInfo.LevelNumber) + '");';
527 <  Query.ExecSQL;
528 <  if OniDataConnection.OSisMAC then
529 <    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","MAC");'
530 <  else
531 <    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","PC");';
613 >    IntToStr(Connection.LevelNumber) + '");';
614    Query.ExecSQL;
615 <
616 <  DoStep('Writing extensionslist');
617 <  progress.Max := Length(OniDataConnection.GetExtensionsList);
618 <  Application.ProcessMessages;
619 <
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;
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');
568 <  Application.ProcessMessages;
569 <
570 <  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 610 | 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 648 | 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 656 | Line 729 | begin
729  
730    converting := False;
731  
732 <  database.Close;
733 <  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)';
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
679 <  begin
680 <    DeleteFile(loaded_filename);
681 <  end;
682 < }end;
735 >  DataBase.Free;
736 > end;
737  
738  
739  
# Line 701 | Line 755 | begin
755   end;
756  
757  
758 <
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.
758 > end.

Diff Legend

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