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 112 by alloc, Thu Feb 22 00:37:39 2007 UTC vs.
Revision 142 by alloc, Fri Mar 30 02:08:49 2007 UTC

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

Diff Legend

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