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 248 by alloc, Mon Nov 26 11:02:28 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;
28 <
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 >  Access_OniArchive;
29  
30   var
40  ConvertHandlers: array of TConvertHandler;
41 //  loaded_filename: String;
31    Converting:  Boolean = False;
32    Abort:       Boolean = False;
33  
# Line 56 | Line 45 | end;
45  
46  
47   procedure TForm_LevelDB.CreateLevel(Source, Target: String);
48 + const
49 +  EmptyBytes: Array[0..31] of Byte = (
50 +      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 );
51   var
52    DatHeader:        THeader;
53    FilesHeader:      TFilesMap;
# Line 67 | Line 59 | var
59  
60    BeginTime, FileTime: Double;
61    Step:     Integer;
70  OniImage:   TOniImage;
62    LevelID:    Integer;
63    TimeFormat: TFormatSettings;
64  
# Line 87 | Line 78 | var
78    RawLinks:   TRawDataList;
79  
80    DatFileStream, RawFileStream: TMemoryStream;
90
91 // ###########################
92  datsum, linksum, rawsum: Int64;
93  freq: Int64;
94  tempticks1, tempticks2: Int64;
95 // ###########################
81   const
82    Steps: Byte = 3;
83  
# Line 107 | Line 92 | const
92        group_progress.Caption := 'Creating Dat (FINISHED)';
93    end;
94  
95 +  procedure StopConvert;
96 +  begin
97 +    btn_abortok.Caption := '&Close';
98 +    btn_abortok.Default := True;
99 +    converting := False;
100 +    lbl_estimation.Caption := 'ABORTED';
101 +    group_progress.Caption := 'Creating Level (ABORTED)';
102 +
103 +    Stream_Body.Free;
104 +    Stream_Names.Free;
105 +    DatFileStream.Free;
106 +    RawFileStream.Free;
107 +    
108 +    Stream_Dat.Free;
109 +    Stream_Raw.Free;
110 +    if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
111 +      Stream_Sep.Free;
112 +    
113 +    if MessageBox(Self.Handle, PChar('Delete the unfinished level-files?'),
114 +      PChar('Delete files?'), MB_YESNO) = idYes then
115 +    begin
116 +      DeleteFile(target);
117 +      DeleteFile(AnsiReplaceStr(Target, '.dat', '.raw'));
118 +      if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
119 +        DeleteFile(AnsiReplaceStr(Target, '.dat', '.sep'));
120 +    end;
121 +  end;
122 +
123   begin
124  
125    //
# Line 176 | Line 189 | begin
189  
190    LevelID  := Connection.LevelNumber;
191    LevelID  := (LevelID * 2) * 256 * 256 * 256 + $01;
179  OniImage := TOniImage.Create;
192  
193    Self.Visible := True;
194    Form_Main.Visible := False;
# Line 191 | Line 203 | begin
203    Stream_Names := TMemoryStream.Create;
204    Stream_Dat   := TFileStream.Create(Target, fmCreate);
205    Stream_Raw   := TFileStream.Create(AnsiReplaceStr(Target, '.dat', '.raw'), fmCreate);
206 +  Stream_Raw.Write(EmptyBytes[0], 32);
207    if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
208 +  begin
209      Stream_Sep := TFileStream.Create(AnsiReplaceStr(Target, '.dat', '.sep'), fmCreate);
210 +    Stream_Sep.Write(EmptyBytes[0], 32);
211 +  end;
212 +
213  
214    DoStep('Creating header');
215    progress.Position      := 0;
# Line 221 | Line 238 | begin
238    for i := 0 to High(DatHeader.OSIdent) do
239      case Connection.DataOS of
240        DOS_WIN: DatHeader.OSIdent[i] := HeaderOSIdentWin[i];
241 <      DOS_MAC: DatHeader.OSIdent[i] := HeaderOSIdentMac[i];
241 >      DOS_MAC, DOS_WINDEMO: DatHeader.OSIdent[i] := HeaderOSIdentMac[i];
242        DOS_MACBETA: DatHeader.OSIdent[i] := HeaderOSIdentMacBeta[i];
243      end;
244    for i := 0 to High(DatHeader.GlobalIdent) do
# Line 262 | Line 279 | begin
279      begin
280        case Connection.DataOS of
281          DOS_WIN:     ExtensionsHeader[i].Ident := FileTypes[j].IdentWin;
282 <        DOS_WINDEMO: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
282 >        DOS_WINDEMO:
283 >            if FileTypes[j].Extension = 'SNDD' then
284 >              ExtensionsHeader[i].Ident := FileTypes[j].IdentWin
285 >            else
286 >              ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
287          DOS_MAC:     ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
288          DOS_MACBETA: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
289        end;
# Line 283 | Line 304 | begin
304    lbl_estimation.Caption := 'Estimated finishing time: unknown';
305    Application.ProcessMessages;
306  
286  QueryPerformanceFrequency(freq);
287  datsum := 0;
288  linksum := 0;
289  rawsum := 0;
290
307    FileTime := Time;
308    for FileID := 0 to DatHeader.Files - 1 do
309    begin
# Line 296 | Line 312 | begin
312        FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j];
313      if FileInfo.Size > 0 then
314      begin
299      QueryPerformanceCounter(tempticks1);
300
315        FilesHeader[FileID].DataAddr := Stream_Body.Size + 8;
316        DatFileStream := TMemoryStream.Create;
317        Connection.LoadDatFile(FileID, TStream(DatFileStream));
318        DatFileStream.Seek(0, soFromBeginning);
319 <      DatFileStream.Write(FileID, 4);
319 >      tempi := FileID * 256 + 1;
320 >      DatFileStream.Write(tempi, 4);
321        DatFileStream.Write(LevelID, 4);
322  
308      QueryPerformanceCounter(tempticks2);
309      datsum := datsum + (tempticks2 - tempticks1);
310
323        DatLinks := Connection.GetDatLinks(FileID);
324        if Length(DatLinks) > 0 then
325        begin
# Line 322 | Line 334 | begin
334          end;
335        end;
336  
325      QueryPerformanceCounter(tempticks1);
326      linksum := linksum + (tempticks1 - tempticks2);
327
337        RawLinks := Connection.GetRawList(FileID);
338        if Length(RawLinks) > 0 then
339        begin
# Line 339 | Line 348 | begin
348              begin
349                RawLinks[i].RawAddr := Stream_Sep.Size;
350                Stream_sep.CopyFrom(RawFileStream, RawFileStream.Size);
351 +              if (Stream_Sep.Size mod 32) > 0 then
352 +                Stream_Sep.Write(EmptyBytes[0], 32 - (Stream_Sep.Size mod 32));
353              end else begin
354                RawLinks[i].RawAddr := Stream_Raw.Size;
355                Stream_Raw.CopyFrom(RawFileStream, RawFileStream.Size);
356 +              if (Stream_Raw.Size mod 32) > 0 then
357 +                Stream_Raw.Write(EmptyBytes[0], 32 - (Stream_Raw.Size mod 32));
358              end;
359            end else
360              RawLinks[i].RawAddr := 0;
# Line 351 | Line 364 | begin
364        end;
365        DatFileStream.Seek(0, soFromBeginning);
366        Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size);
367 <
368 <      QueryPerformanceCounter(tempticks2);
369 <      rawsum := rawsum + (tempticks2 - tempticks1);
367 >      if (Stream_Body.Size mod 32) > 0 then
368 >      begin
369 >        ShowMessage(
370 >            IntToStr(FileID) + '-' + FileInfo.Name + '.' + FileInfo.Extension + #13#10 +
371 >            IntToStr(FileInfo.Size) + ' - 0x' + IntToHex(FileInfo.Size, 6) + ' - real: ' + IntToStr(DatFileStream.Size) + ' - 0x' + IntToHex(DatFileStream.Size, 6) + #13#10 +
372 >            IntToStr(Stream_Body.Size) + ' - 0x' + IntToHex(Stream_Body.Size, 6) );
373 >        Stream_Body.Write(EmptyBytes[0], 32 - (Stream_Body.Size mod 32));
374 >      end;
375      end
376      else
377 <      FilesHeader[i].DataAddr := 0;
377 >      FilesHeader[FileID].DataAddr := 0;
378      if Length(fileinfo.Name) > 0 then
379      begin
380 <      FilesHeader[i].NameAddr := Stream_Names.Size;
380 >      FilesHeader[FileID].NameAddr := Stream_Names.Size;
381        temps := fileinfo.Extension + fileinfo.Name + Chr(0);
382        Stream_Names.Write(temps[1], Length(temps));
383      end
384      else
385 <      FilesHeader[i].NameAddr := 0;
386 <    FilesHeader[i].FileSize := fileinfo.Size;
387 <    FilesHeader[i].FileType := fileinfo.FileType;
385 >      FilesHeader[FileID].NameAddr := 0;
386 >    FilesHeader[FileID].FileSize := fileinfo.Size;
387 >    FilesHeader[FileID].FileType := fileinfo.FileType;
388  
389      if ((FileID mod 10) = 0) and (FileID >= 100) then
390        lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
# Line 376 | Line 394 | begin
394      Application.ProcessMessages;
395    end;
396  
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
397    Stream_Dat.Write(DatHeader, SizeOf(DatHeader));
398    for i := 0 to High(FilesHeader) do
399      Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i]));
# Line 389 | Line 402 | begin
402    for i := 0 to High(ExtensionsHeader) do
403      Stream_Dat.Write(ExtensionsHeader[i], SizeOf(ExtensionsHeader[i]));
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.DataSize  := Stream_Body.Size;
409    DatHeader.NamesSize := Stream_Names.Size;
410    DatHeader.DataAddr  := Stream_Dat.Size;
411  
412    Stream_Body.Seek(0, soFromBeginning);
413    Stream_Dat.CopyFrom(Stream_Body, Stream_Body.Size);
414 +
415 +  if (Stream_Dat.Size mod 32) > 0 then
416 +    Stream_Dat.Write(EmptyBytes[0], 32 - (Stream_Dat.Size mod 32));
417 +
418    DatHeader.NamesAddr := Stream_Dat.Size;
419    Stream_Names.Seek(0, soFromBeginning);
420    Stream_Dat.CopyFrom(Stream_Names, Stream_Names.Size);
# Line 419 | Line 439 | begin
439    btn_abortok.Caption := '&OK';
440    btn_abortok.Default := True;
441  
422  OniImage.Free;
423
442    converting := False;
443  
444   //  CloseDataConnection(DataConnections[conIndex]);
# Line 429 | Line 447 | end;
447  
448  
449  
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
450   procedure TForm_LevelDB.CreateDatabase(Source, target: String);
451 {
451   var
452 <  DataBase:    TABSDatabase;
453 <  Query:       TABSQuery;
454 <  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;
452 >  DataBase:  TABSDatabase;
453 >  Query:     TABSQuery;
454 >  MimeCoder: TStringFormat_MIME64;
455  
456 <  conIndex: Integer;
457 < const
458 <  steps: Byte = 4;
456 >  BeginTime, FileTime: Double;
457 >  Step:       Integer;
458 >  TimeFormat: TFormatSettings;
459  
460 +  ConID:      Integer;
461 +  Connection: TDataAccess;
462 +  ConRepMsg:  TStatusMessages;
463  
464 +  FileID:     Integer;
465  
466 +  i:          Integer;
467 +  temps:      String;
468 +  tempdata:   TByteData;
469 +  FileInfo:   TFileInfo;
470 +  DatLinks:   TDatLinkList;
471 +  RawLinks:   TRawDataList;
472 + const
473 +  steps: Byte = 2;
474  
475    procedure DoStep(stepname: String);
476    begin
# Line 480 | Line 481 | const
481      else
482        group_progress.Caption := 'Creating DB (FINISHED)';
483    end;
484 < }
484 >
485 >  procedure StopConvert;
486 >  begin
487 >    btn_abortok.Caption := '&Close';
488 >    btn_abortok.Default := True;
489 >    converting := False;
490 >    lbl_estimation.Caption := 'ABORTED';
491 >    group_progress.Caption := 'Creating DB (ABORTED)';
492 >    DataBase.Close;
493 >    if MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'),
494 >      PChar('Delete file?'), MB_YESNO) = idYes then
495 >    begin
496 >      DeleteFile(target);
497 >    end;
498 >  end;
499 >
500 >
501  
502   begin
503 < {  if CreateDataConnection(Source, ODB_Dat) = nil then
503 >
504 >  //
505 >  // FILE EXISTS CHECK FÜR DAT/RAW/SEP!!!
506 >  //
507 >
508 >  TimeFormat.ShortTimeFormat := 'hh:nn:ss';
509 >  TimeFormat.LongTimeFormat  := 'hh:nn:ss';
510 >  TimeFormat.TimeSeparator   := ':';
511 >
512 >  ConID := ConManager.OpenConnection(Source, ConRepMsg);
513 >  if not (ConRepMsg in [SM_OK, SM_AlreadyOpened]) then
514    begin
515 <    ShowMessage('Could not connect to .dat-file');
515 >    ShowMessage('Source-file couldn''t be opened! Aborting' + CrLf + GetOpenMsg(ConRepMsg));
516      Exit;
517 <  end
518 <  else
517 >  end else
518 >    Connection := ConManager.Connection[ConID];
519 >
520 >  ConID := ConManager.FileOpened(Target);
521 >  if ConID >= 0 then
522    begin
523 <    TOniDataDat(OniDataConnection).UnloadWhenUnused := False;
523 >    if MessageBox(Self.Handle, PChar('Destination-file is opened, close it in ' +
524 >          'order to proceed conversion?'), PChar('Destination-file opened'),
525 >          MB_YESNO + MB_ICONQUESTION) = ID_YES then
526 >    begin
527 >      if Form_Main.CheckConnectionCloseable(ConID) then
528 >        if not ConManager.CloseConnection(ConID, ConRepMsg) then
529 >        begin
530 >          ShowMessage('Couldn''t close destination-file. Aborting');
531 >          Exit;
532 >        end;
533 >    end else begin
534 >      ShowMessage('Aborting');
535 >      Exit;
536 >    end;
537    end;
538  
539 <  timeformat.LongTimeFormat := 'hh:nn:ss';
540 <  timeformat.ShortTimeFormat := 'hh:nn:ss';
541 <  timeformat.TimeSeparator := ':';
539 >  if FileExists(Target) then
540 >  begin
541 >    if MessageBox(Self.Handle, PChar('Destination-file exists. ' +
542 >          'Overwrite it?'), PChar('Destination-file exists'),
543 >          MB_YESNO + MB_ICONWARNING) = ID_YES then
544 >    begin
545 >      if not DeleteFile(Target) then
546 >      begin
547 >        ShowMessage('Couldn''t delete file. Aborting');
548 >        Exit;
549 >      end;
550 >    end else begin
551 >      ShowMessage('Aborting');
552 >      Exit;
553 >    end;
554 >  end;
555  
556    Self.Visible := True;
557    Form_Main.Visible := False;
# Line 504 | Line 560 | begin
560    abort := False;
561    btn_abortok.Caption := '&Abort...';
562    btn_abortok.Default := False;
507  loaded_filename := target;
563  
564 <  absolutebegintime := Time;
564 >  BeginTime := Time;
565  
566    DataBase := TABSDatabase.Create(Self);
567 +  DataBase.MaxConnections := 1;
568 +  DataBase.PageSize := 8112;
569 +  DataBase.PageCountInExtent := 8;
570 +
571    DataBase.DatabaseName := 'OLDB';
572    DataBase.DatabaseFileName := target;
573    DataBase.CreateDatabase;
# Line 522 | Line 581 | begin
581    Query := TABSQuery.Create(Self);
582    Query.DatabaseName := 'OLDB';
583    Query.SQL.Text :=
584 <    'CREATE TABLE globals  ( id AUTOINC PRIMARY KEY, name STRING(128), value STRING(128) );';
584 >    'CREATE TABLE globals  ( id AUTOINC PRIMARY KEY, name STRING(128), ' +
585 >    'value STRING(128) );';
586    Query.ExecSQL;
587    Query.SQL.Text :=
588 <    'CREATE TABLE linkmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, target_id INTEGER );';
588 >    'CREATE TABLE linkmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' +
589 >    'src_link_offset INTEGER, target_id INTEGER);';
590 >  Query.ExecSQL;
591 >  Query.SQL.Text := 'CREATE INDEX idsrcid ON linkmap (src_id);';
592 >  Query.ExecSQL;
593 >  Query.SQL.Text := 'CREATE INDEX idtargetid ON linkmap (target_id);';
594    Query.ExecSQL;
595    Query.SQL.Text :=
596 <    '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 );';
596 >    'CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, name STRING(32), src_id INTEGER, ' +
597 >    'src_link_offset INTEGER, sep BOOLEAN, type STRING(8), size INTEGER, ' +
598 >    'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib);';
599    //    Query.SQL.Text:='CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
600    Query.ExecSQL;
601 <  Query.SQL.Text :=
602 <    '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 );';
603 <  //    Query.SQL.Text:='CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
601 >  Query.SQL.Text := 'CREATE INDEX idsrcid ON rawmap (src_id);';
602 >  Query.ExecSQL;
603 >  Query.SQL.Text := 'CREATE INDEX idtype ON rawmap (type);';
604    Query.ExecSQL;
605    Query.SQL.Text :=
606 <    'CREATE TABLE extlist  ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
606 >    'CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), ' +
607 >    'name STRING(128), contenttype INTEGER, size INTEGER, ' +
608 >    'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
609 >  //    Query.SQL.Text:='CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
610    Query.ExecSQL;
611 + //  Query.SQL.Text :=
612 + //    'CREATE TABLE extlist  ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
613 + //  Query.ExecSQL;
614  
615    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("dbversion","' +
616      dbversion + '");';
617    Query.ExecSQL;
618 <  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;
618 >
619    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("lvl","' +
620 <    IntToStr(OniDataConnection.LevelInfo.LevelNumber) + '");';
620 >    IntToStr(Connection.LevelNumber) + '");';
621    Query.ExecSQL;
622 <  if OniDataConnection.OSisMAC then
623 <    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","MAC");'
624 <  else
625 <    Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","PC");';
626 <  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;
622 >  case Connection.DataOS of
623 >    DOS_WIN: temps := 'WIN';
624 >    DOS_WINDEMO: temps := 'WINDEMO';
625 >    DOS_MAC: temps := 'MAC';
626 >    DOS_MACBETA: temps := 'MACBETA';
627    end;
628 <  lbl_progress.Caption := '';
628 >  Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("os","' + temps + '");';
629 >  Query.ExecSQL;
630  
631    progress.Position      := 0;
632    lbl_progress.Caption   := 'Files done: ' + IntToStr(0) + '/' + IntToStr(
633 <    OniDataConnection.GetFilesCount);
633 >    Connection.GetFileCount);
634    lbl_estimation.Caption := 'Estimated finishing time: unknown';
635  
636 <  DoStep('Loading .dat into memory');
594 <  Application.ProcessMessages;
595 <
596 <  progress.Max := OniDataConnection.GetFilesCount;
636 >  progress.Max := Connection.GetFileCount;
637    begintime    := Time;
638    DoStep('Writing .dat-fileslist');
639    Application.ProcessMessages;
640  
641 +  FileTime := Time;
642    Database.StartTransaction;
643 <  for i := 0 to OniDataConnection.GetFilesCount - 1 do
643 >  for FileID := 0 to Connection.GetFileCount - 1 do
644    begin
645 <    fileinfo := OniDataConnection.GetFileInfo(i);
645 >    fileinfo := Connection.GetFileInfo(FileID);
646      if (fileinfo.FileType and $02) = 0 then
647      begin
648        mimecoder := TStringFormat_MIME64.Create;
649 <      Data      := OniDataConnection.LoadDatFile(i);
649 >      Connection.LoadDatFile(FileID, tempdata);
650        Query.SQL.Text :=
651          'INSERT INTO datfiles (id,extension,name,contenttype,size,data) VALUES (' +
652 <        IntToStr(i) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
652 >        IntToStr(FileID) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
653          fileinfo.FileType, 8) + '",' + IntToStr(fileinfo.Size) + ',MimeToBin("' +
654 <        MimeCoder.StrTo(@Data[0], Length(Data)) + '") );';
654 >        MimeCoder.StrTo(@tempdata[0], Length(tempdata)) + '") );';
655        Query.ExecSQL;
656        mimecoder.Free;
657  
658 <      rawlist := OniDataConnection.GetRawList(i);
659 <      if Length(rawlist) > 0 then
658 >      RawLinks := Connection.GetRawList(FileID);
659 >      if Length(RawLinks) > 0 then
660        begin
661 <        for j := 0 to High(rawlist) do
661 >        for i := 0 to High(RawLinks) do
662          begin
663 <          if rawlist[j].raw_size > 0 then
663 >          if RawLinks[i].RawSize > 0 then
664            begin
665 <            SetLength(Data, rawlist[j].raw_size);
666 <            OniDataConnection.LoadRawFile(i, rawlist[j].src_offset, Data);
665 >            SetLength(tempdata, RawLinks[i].RawSize);
666 >            Connection.LoadRawFile(FileID, RawLinks[i].SrcOffset, tempdata);
667              mimecoder      := TStringFormat_MIME64.Create;
668              Query.SQL.Text :=
669 <              'INSERT INTO rawmap (src_id,src_link_offset,sep,size,data) VALUES (' +
670 <              IntToStr(i) + ',' + IntToStr(rawlist[j].src_offset) + ',' + BoolToStr(
671 <              rawlist[j].loc_sep) + ',' + IntToStr(rawlist[j].raw_size) + ',MimeToBin("' +
672 <              MimeCoder.StrTo(@Data[0], rawlist[j].raw_size) + '") );';
669 >              'INSERT INTO rawmap (name,src_id,src_link_offset,sep,type,size,data) VALUES (' +
670 >              '"' + RawLinks[i].Name + '", ' +
671 >              IntToStr(FileID) + ', ' + IntToStr(RawLinks[i].SrcOffset) + ',' +
672 >              BoolToStr(RawLinks[i].LocSep) + ', ' +
673 >              '"' + RawLinks[i].RawType + '", ' +
674 >              IntToStr(RawLinks[i].RawSize) + ', ' +
675 >              'MimeToBin("' + MimeCoder.StrTo(@tempdata[0], RawLinks[i].RawSize) + '") );';
676              Query.ExecSQL;
677              mimecoder.Free;
678            end
679            else
680            begin
681              Query.SQL.Text :=
682 <              'INSERT INTO rawmap (src_id,src_link_offset,sep,size) VALUES (' +
683 <              IntToStr(i) + ',' + IntToStr(rawlist[j].src_offset) + ',' + BoolToStr(rawlist[j].loc_sep) + ',0);';
682 >              'INSERT INTO rawmap (name,src_id,src_link_offset,sep,type,size) VALUES (' +
683 >              '"' + RawLinks[i].Name + '", ' +
684 >              IntToStr(FileID) + ', ' + IntToStr(RawLinks[i].SrcOffset) + ', ' +
685 >              BoolToStr(RawLinks[i].LocSep) + ', ' +
686 >              '"' + RawLinks[i].RawType + '", ' +
687 >              '0);';
688              Query.ExecSQL;
689            end;
690          end;
691        end;
692  
693 <      HandleFile(fileinfo.Extension, i, True);
693 >      DatLinks := Connection.GetDatLinks(FileID);
694 >      if Length(DatLinks) > 0 then
695 >      begin
696 >        for i := 0 to High(DatLinks) do
697 >        begin
698 >          Query.SQL.Text :=
699 >            'INSERT INTO linkmap (src_id, src_link_offset, target_id) VALUES (' +
700 >            IntToStr(FileID) + ', ' + IntToStr(DatLinks[i].SrcOffset) + ', ' +
701 >            IntToStr(DatLinks[i].DestID) + ');';
702 >          Query.ExecSQL;
703 >        end;
704 >      end;
705      end
706      else
707      begin
708        Query.SQL.Text :=
709          'INSERT INTO datfiles (id,extension,name,contenttype,size) VALUES (' +
710 <        IntToStr(i) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
711 <        fileinfo.FileType, 8) + '",0);';
710 >        IntToStr(FileID) + ', "' + fileinfo.Extension + '", ' +
711 >        '"' + fileinfo.Name + '", "' + IntToHex(fileinfo.FileType, 8) + '", 0);';
712        Query.ExecSQL;
713      end;
714 <    if ((i mod 100) = 0) and (i > 0) then
714 >    if ((FileID mod 100) = 0) and (FileID > 0) then
715      begin
716        Database.Commit(False);
717        Database.StartTransaction;
718      end;
719 <    if ((i mod 10) = 0) and (i >= 100) then
719 >    if ((FileID mod 10) = 0) and (FileID >= 100) then
720        lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
721 <        (Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat );
722 <    progress.Position := i;
723 <    lbl_progress.Caption := 'Files done: ' + IntToStr(i) + '/' + IntToStr(progress.Max);
721 >        (Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat );
722 >    progress.Position := FileID;
723 >    lbl_progress.Caption := 'Files done: ' + IntToStr(FileID) + '/' + IntToStr(progress.Max);
724      Application.ProcessMessages;
725      if abort then
726      begin
727 <      stop_convert;
727 >      StopConvert;
728        Exit;
729      end;
730    end;
# Line 674 | Line 733 | begin
733    lbl_progress.Caption   := 'Files done: ' + IntToStr(progress.Max) + '/' +
734      IntToStr(progress.Max);
735  
736 <  lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')';
736 >  lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - BeginTime, timeformat) + ')';
737  
738    DoStep('FIN');
739    btn_abortok.Caption := '&OK';
# Line 682 | Line 741 | begin
741  
742    converting := False;
743  
744 <  database.Close;
745 <  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)';
744 >  Query.Close;
745 >  Query.Free;
746    DataBase.Close;
747 <  if MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'),
748 <    PChar('Delete file?'), MB_YESNO) = idYes then
705 <  begin
706 <    DeleteFile(loaded_filename);
707 <  end;
708 < }end;
747 >  DataBase.Free;
748 > end;
749  
750  
751  
# Line 727 | Line 767 | begin
767   end;
768  
769  
770 <
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.
770 > end.

Diff Legend

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