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

Diff Legend

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