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

Diff Legend

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