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 137 by alloc, Fri Mar 30 00:00:10 2007 UTC vs.
Revision 145 by alloc, Sun Apr 1 15:14:09 2007 UTC

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

Diff Legend

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