source: oup/current/Helper/LevelDB.pas@ 112

Last change on this file since 112 was 112, checked in by alloc, 18 years ago
File size: 42.4 KB
Line 
1unit LevelDB;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, StrUtils;
8
9type
10 TForm_LevelDB = class(TForm)
11 group_progress: TGroupBox;
12 progress: TProgressBar;
13 lbl_progress: TLabel;
14 btn_abortok: TButton;
15 lbl_estimation: TLabel;
16 procedure btn_abortokClick(Sender: TObject);
17 private
18 procedure HandleFile(Ext: String; FileID: Integer);
19 procedure StopConvert;
20 public
21 procedure CreateDatabase(Source, Target: String);
22 procedure CreateLevel(Source, Target: String);
23 end;
24
25
26var
27 Form_LevelDB: TForm_LevelDB;
28
29implementation
30
31{$R *.dfm}
32
33uses ABSMain, ABSDecUtil, Main,
34 ConnectionManager, TypeDefs, DataAccess, OniImgClass;
35
36type
37 THandler = procedure(FileID: Integer);
38 TConvertHandler = record
39 Ext: String[4];
40 Handler: THandler;
41 end;
42
43var
44 ConvertHandlers: array of TConvertHandler;
45// loaded_filename: String;
46 Converting: Boolean = False;
47 Abort: Boolean = False;
48
49
50function GetOpenMsg(msg: TStatusMessages): String;
51begin
52 case msg of
53 SM_AlreadyOpened: Result := 'File already opened.';
54 SM_FileNotFound: Result := 'File not found.';
55 SM_UnknownExtension: Result := 'Unknown extension.';
56 SM_IncompatibleFile: Result := 'Incompatible file format.';
57 SM_UnknownError: Result := 'Unknown error.';
58 end;
59end;
60
61
62procedure TForm_LevelDB.CreateLevel(Source, Target: String);
63var
64 DatHeader: THeader;
65 FilesHeader: TFilesMap;
66 NamedFilesHeader: TNamedFilesMap;
67 ExtensionsHeader: TExtensionsMap;
68
69 Stream_Body, Stream_Names: TMemoryStream;
70 Stream_Dat, Stream_Raw, Stream_Sep: TFileStream;
71
72// FileCount: Integer;
73// temps, temps2: String;
74// Data, rawdata: Tdata;
75 BeginTime, FileTime: Double;
76 Step: Integer;
77// rawlist: TRawDataList;
78// extlist: TExtensionsMap;
79// fileinfo: TFileInfo;
80// datlinks: TDatLinks;
81 OniImage: TOniImage;
82 LevelID: Integer;
83 TimeFormat: TFormatSettings;
84
85 ConID: Integer;
86 Connection: TDataAccess;
87 ConRepMsg: TStatusMessages;
88
89 Strings: TStrings;
90 i, j: Integer;
91const
92 Steps: Byte = 3;
93
94
95 procedure DoStep(StepName: String);
96 begin
97 Inc(Step);
98 if StepName <> 'FIN' then
99 group_progress.Caption :=
100 'Creating Dat (Step ' + IntToStr(Step) + '/' + IntToStr(Steps) + ': ' + StepName + ')'
101 else
102 group_progress.Caption := 'Creating Dat (FINISHED)';
103 end;
104
105begin
106
107 //
108 // FILE EXISTS CHECK FÜR DAT/RAW/SEP!!!
109 //
110
111 TimeFormat.ShortTimeFormat := 'hh:nn:ss';
112 TimeFormat.LongTimeFormat := 'hh:nn:ss';
113 TimeFormat.TimeSeparator := ':';
114
115 ConID := ConManager.OpenConnection(Source, ConRepMsg);
116 if not (ConRepMsg in [SM_OK, SM_AlreadyOpened]) then
117 begin
118 ShowMessage('Source-file couldn''t be opened! Aborting' + CrLf + GetOpenMsg(ConRepMsg));
119 Exit;
120 end else
121 Connection := ConManager.Connection[ConID];
122
123 ConID := ConManager.FileOpened(Target);
124 if ConID >= 0 then
125 begin
126 if MessageBox(Self.Handle, PChar('Destination-file is opened, close it in ' +
127 'order to proceed conversion?'), PChar('Destination-file opened'),
128 MB_YESNO + MB_ICONQUESTION) = ID_YES then
129 begin
130 if Form_Main.CheckConnectionCloseable(ConID) then
131 if not ConManager.CloseConnection(ConID, ConRepMsg) then
132 begin
133 ShowMessage('Couldn''t close destination-file. Aborting');
134 Exit;
135 end;
136 end else begin
137 ShowMessage('Aborting');
138 Exit;
139 end;
140 end;
141
142 if FileExists(Target) then
143 begin
144 if MessageBox(Self.Handle, PChar('Destination-file exists. ' +
145 'Overwrite it?'), PChar('Destination-file exists'),
146 MB_YESNO + MB_ICONWARNING) = ID_YES then
147 begin
148 if not DeleteFile(Target) then
149 begin
150 ShowMessage('Couldn''t delete file. Aborting');
151 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;
160 end;
161 end else begin
162 ShowMessage('Aborting');
163 Exit;
164 end;
165 end;
166
167 LevelID := Connection.LevelNumber;
168 LevelID := (LevelID * 2) * 256 * 256 * 256 + $01;
169 OniImage := TOniImage.Create;
170
171 Self.Visible := True;
172 Form_Main.Visible := False;
173 Step := 0;
174 Converting := True;
175 Abort := False;
176 btn_abortok.Caption := '&Abort...';
177 btn_abortok.Default := False;
178 BeginTime := Time;
179
180 Stream_Body := TMemoryStream.Create;
181 Stream_Names := TMemoryStream.Create;
182 Stream_Dat := TFileStream.Create(Target, fmCreate);
183 Stream_Raw := TFileStream.Create(AnsiReplaceStr(Target, '.dat', '.raw'), fmCreate);
184 if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
185 Stream_Sep := TFileStream.Create(AnsiReplaceStr(Target, '.dat', '.sep'), fmCreate);
186
187 DoStep('Creating header');
188 progress.Position := 0;
189 lbl_progress.Caption := '';
190 lbl_estimation.Caption := 'Estimated finishing time: unknown';
191 Application.ProcessMessages;
192
193 SetLength(NamedFilesHeader, 0);
194 Strings := TStringList.Create;
195 Strings := Connection.GetFilesList('', '', False, ST_ExtNameAsc);
196 for i := 0 to Strings.Count - 1 do
197 begin
198 if MidStr(Strings.Strings[i],
199 Pos('-', Strings.Strings[i]) + 1,
200 Length(Strings.Strings[i]) -
201 Pos('.', ReverseString(Strings.Strings[i])) -
202 Pos('-', Strings.Strings[i])
203 ) <> '' then
204 begin
205 SetLength(NamedFilesHeader, Length(NamedFilesHeader) + 1);
206 NamedFilesHeader[High(NamedFilesHeader)].FileNumber := StrToInt(MidStr(Strings.Strings[i], 1, 5));
207 NamedFilesHeader[High(NamedFilesHeader)].blubb := 0;
208 end;
209 end;
210
211
212 extlist := OniDataConnection.GetExtendedExtensionsList;
213 for i := 0 to High(DatHeader.Ident) do
214 DatHeader.Ident[i] := OniDataConnection.LevelInfo.Ident[i];
215 DatHeader.Files := OniDataConnection.GetFilesCount;
216 DatHeader.NamedFiles := Length(NamedFilesHeader);
217 DatHeader.Extensions := Length(extlist);
218 DatHeader.DataAddr := 0;
219 DatHeader.DataSize := 0;
220 DatHeader.NamesAddr := 0;
221 DatHeader.NamesSize := 0;
222 for i := 0 to High(DatHeader.Ident2) do
223 DatHeader.Ident2[i] := 0;
224 SetLength(FilesHeader, DatHeader.Files);
225 SetLength(ExtensionsHeader, DatHeader.Extensions);
226
227
228 DoStep('Writing extensions-header');
229 progress.Max := Length(OniDataConnection.GetExtensionsList);
230 Application.ProcessMessages;
231
232 for i := 0 to High(ExtensionsHeader) do
233 begin
234 ExtensionsHeader[i].Ident := extlist[i].Ident;
235 ExtensionsHeader[i].Extension := extlist[i].Extension;
236 SetLength(temps, 4);
237 for j := 0 to 3 do
238 temps[j + 1] := ExtensionsHeader[i].Extension[3 - j];
239 ExtensionsHeader[i].ExtCount :=
240 Length(OniDataConnection.GetFilesList(temps, '', False, stIDAsc));
241 progress.Position := i + 1;
242 lbl_progress.Caption := 'Extensions done: ' + IntToStr(i + 1) + '/' +
243 IntToStr(Length(extlist));
244 Application.ProcessMessages;
245 end;
246
247
248 DoStep('Storing files-data');
249 progress.Position := 0;
250 progress.Max := DatHeader.Files;
251 lbl_progress.Caption := '';
252 lbl_estimation.Caption := 'Estimated finishing time: unknown';
253 Application.ProcessMessages;
254
255 begintime := Time;
256 for i := 0 to DatHeader.Files - 1 do
257 begin
258 fileinfo := OniDataConnection.GetFileInfo(i);
259 for j := 0 to 3 do
260 FilesHeader[i].Extension[j] := fileinfo.Extension[4 - j];
261 if fileinfo.Size > 0 then
262 begin
263 // DatLinks:=;
264 FilesHeader[i].DataAddr := Stream_Body.Size + 8;
265 Data := OniDataConnection.LoadDatFile(i);
266 Data[4] := (levelid) and $FF;
267 Data[5] := (levelid shr 8) and $FF;
268 Data[6] := (levelid shr 16) and $FF;
269 Data[7] := (levelid shr 24) and $FF;
270
271 if (Pos(UpperCase(fileinfo.Extension), UpperCase(raws)) mod 4) = 1 then
272 begin
273 rawlist := OniDataConnection.GetRawList(i);
274 if Length(rawlist) > 0 then
275 begin
276 for j := 0 to High(rawlist) do
277 begin
278 if rawlist[j].raw_size > 0 then
279 begin
280 if (UpperCase(fileinfo.Extension) = 'TXMP') and
281 ((Data[$88] and $01) > 0) then
282 begin
283 OniImage.LoadFromTXMP(Connection, i);
284 OniImage.GetMipMappedImage(rawdata);
285 rawlist[j].raw_size := OniImage.GetImageDataSize(True);
286 Data[$90] := $08;
287 Data[$89] := 32;
288{ if data[$90]<>OniImage.StoreType then begin
289 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;
318 end;
319 end;
320
321 Stream_Body.Write(Data[0], Length(Data));
322 //
323 end
324 else
325 FilesHeader[i].DataAddr := 0;
326 if Length(fileinfo.Name) > 0 then
327 begin
328 FilesHeader[i].NameAddr := Stream_Names.Size;
329 temps := fileinfo.Extension + fileinfo.Name + Chr(0);
330 Stream_Names.Write(temps[1], Length(temps));
331 end
332 else
333 FilesHeader[i].NameAddr := 0;
334 FilesHeader[i].FileSize := fileinfo.Size;
335 FilesHeader[i].FileType := fileinfo.FileType;
336
337 if ((i mod 10) = 0) and (i >= 100) then
338 lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
339 (Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat );
340 progress.Position := i + 1;
341 lbl_progress.Caption := 'Files done: ' + IntToStr(i + 1) + '/' + IntToStr(progress.Max);
342 Application.ProcessMessages;
343 end;
344
345 Stream_Dat.Write(DatHeader, SizeOf(DatHeader));
346 for i := 0 to High(FilesHeader) do
347 Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i]));
348 for i := 0 to High(NamedFilesHeader) do
349 Stream_Dat.Write(NamedFilesHeader[i], SizeOf(NamedFilesHeader[i]));
350 for i := 0 to High(ExtensionsHeader) do
351 Stream_Dat.Write(ExtensionsHeader[i], SizeOf(ExtensionsHeader[i]));
352
353 DatHeader.DataSize := Stream_Body.Size;
354 DatHeader.NamesSize := Stream_Names.Size;
355 DatHeader.DataAddr := Stream_Dat.Size;
356 Stream_Body.Seek(0, soFromBeginning);
357 Stream_Dat.CopyFrom(Stream_Body, Stream_Body.Size);
358 DatHeader.NamesAddr := Stream_Dat.Size;
359 Stream_Names.Seek(0, soFromBeginning);
360 Stream_Dat.CopyFrom(Stream_Names, Stream_Names.Size);
361
362 Stream_Dat.Seek(0, soFromBeginning);
363 Stream_Dat.Write(DatHeader, SizeOf(DatHeader));
364
365 Stream_Dat.Free;
366 Stream_Body.Free;
367 Stream_Names.Free;
368 Stream_Raw.Free;
369 if OniDataConnection.OSisMac then
370 Stream_Sep.Free;
371
372 progress.Position := progress.Max;
373 lbl_progress.Caption := 'Files done: ' + IntToStr(progress.Max) + '/' +
374 IntToStr(progress.Max);
375 lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')';
376
377 DoStep('FIN');
378 btn_abortok.Caption := '&OK';
379 btn_abortok.Default := True;
380
381 OniImage.Free;
382
383 converting := False;
384
385 CloseDataConnection(DataConnections[conIndex]);
386end;
387
388
389
390
391procedure TForm_LevelDB.HandleFile;
392var
393 i: Byte;
394begin
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;
404end;
405
406
407
408
409procedure TForm_LevelDB.CreateDatabase(Source, target: String);
410var
411 DataBase: TABSDatabase;
412 Query: TABSQuery;
413 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;
424
425 conIndex: Integer;
426const
427 steps: Byte = 4;
428
429
430
431
432 procedure DoStep(stepname: String);
433 begin
434 Inc(step);
435 if stepname <> 'FIN' then
436 group_progress.Caption :=
437 'Creating DB (Step ' + IntToStr(step) + '/' + IntToStr(steps) + ': ' + stepname + ')'
438 else
439 group_progress.Caption := 'Creating DB (FINISHED)';
440 end;
441
442begin
443 if CreateDataConnection(Source, ODB_Dat) = nil then
444 begin
445 ShowMessage('Could not connect to .dat-file');
446 Exit;
447 end
448 else
449 begin
450 TOniDataDat(OniDataConnection).UnloadWhenUnused := False;
451 end;
452
453 timeformat.LongTimeFormat := 'hh:nn:ss';
454 timeformat.ShortTimeFormat := 'hh:nn:ss';
455 timeformat.TimeSeparator := ':';
456
457 Self.Visible := True;
458 Form_Main.Visible := False;
459 step := 0;
460 converting := True;
461 abort := False;
462 btn_abortok.Caption := '&Abort...';
463 btn_abortok.Default := False;
464 loaded_filename := target;
465
466 absolutebegintime := Time;
467
468 DataBase := TABSDatabase.Create(Self);
469 DataBase.DatabaseName := 'OLDB';
470 DataBase.DatabaseFileName := target;
471 DataBase.CreateDatabase;
472
473 DoStep('Creating tables');
474 progress.Position := 0;
475 lbl_progress.Caption := '';
476 lbl_estimation.Caption := 'Estimated finishing time: unknown';
477 Application.ProcessMessages;
478
479 Query := TABSQuery.Create(Self);
480 Query.DatabaseName := 'OLDB';
481 Query.SQL.Text :=
482 'CREATE TABLE globals ( id AUTOINC PRIMARY KEY, name STRING(128), value STRING(128) );';
483 Query.ExecSQL;
484 Query.SQL.Text :=
485 'CREATE TABLE linkmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, target_id INTEGER );';
486 Query.ExecSQL;
487 Query.SQL.Text :=
488 '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 );';
489 // Query.SQL.Text:='CREATE TABLE rawmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
490 Query.ExecSQL;
491 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 );';
494 Query.ExecSQL;
495 Query.SQL.Text :=
496 'CREATE TABLE extlist ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
497 Query.ExecSQL;
498
499 Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("dbversion","' +
500 dbversion + '");';
501 Query.ExecSQL;
502 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;
508 Query.SQL.Text := 'INSERT INTO globals (name,value) VALUES ("lvl","' +
509 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");';
515 Query.ExecSQL;
516
517 DoStep('Writing extensionslist');
518 progress.Max := Length(OniDataConnection.GetExtensionsList);
519 Application.ProcessMessages;
520
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;
542 end;
543 lbl_progress.Caption := '';
544
545 progress.Position := 0;
546 lbl_progress.Caption := 'Files done: ' + IntToStr(0) + '/' + IntToStr(
547 OniDataConnection.GetFilesCount);
548 lbl_estimation.Caption := 'Estimated finishing time: unknown';
549
550 DoStep('Loading .dat into memory');
551 Application.ProcessMessages;
552
553 progress.Max := OniDataConnection.GetFilesCount;
554 begintime := Time;
555 DoStep('Writing .dat-fileslist');
556 Application.ProcessMessages;
557
558 Database.StartTransaction;
559 for i := 0 to OniDataConnection.GetFilesCount - 1 do
560 begin
561 fileinfo := OniDataConnection.GetFileInfo(i);
562 if (fileinfo.FileType and $02) = 0 then
563 begin
564 mimecoder := TStringFormat_MIME64.Create;
565 Data := OniDataConnection.LoadDatFile(i);
566 Query.SQL.Text :=
567 'INSERT INTO datfiles (id,extension,name,contenttype,size,data) VALUES (' +
568 IntToStr(i) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
569 fileinfo.FileType, 8) + '",' + IntToStr(fileinfo.Size) + ',MimeToBin("' +
570 MimeCoder.StrTo(@Data[0], Length(Data)) + '") );';
571 Query.ExecSQL;
572 mimecoder.Free;
573
574 rawlist := OniDataConnection.GetRawList(i);
575 if Length(rawlist) > 0 then
576 begin
577 for j := 0 to High(rawlist) do
578 begin
579 if rawlist[j].raw_size > 0 then
580 begin
581 SetLength(Data, rawlist[j].raw_size);
582 OniDataConnection.LoadRawFile(i, rawlist[j].src_offset, Data);
583 mimecoder := TStringFormat_MIME64.Create;
584 Query.SQL.Text :=
585 'INSERT INTO rawmap (src_id,src_link_offset,sep,size,data) VALUES (' +
586 IntToStr(i) + ',' + IntToStr(rawlist[j].src_offset) + ',' + BoolToStr(
587 rawlist[j].loc_sep) + ',' + IntToStr(rawlist[j].raw_size) + ',MimeToBin("' +
588 MimeCoder.StrTo(@Data[0], rawlist[j].raw_size) + '") );';
589 Query.ExecSQL;
590 mimecoder.Free;
591 end
592 else
593 begin
594 Query.SQL.Text :=
595 'INSERT INTO rawmap (src_id,src_link_offset,sep,size) VALUES (' +
596 IntToStr(i) + ',' + IntToStr(rawlist[j].src_offset) + ',' + BoolToStr(rawlist[j].loc_sep) + ',0);';
597 Query.ExecSQL;
598 end;
599 end;
600 end;
601
602 HandleFile(fileinfo.Extension, i, True);
603 end
604 else
605 begin
606 Query.SQL.Text :=
607 'INSERT INTO datfiles (id,extension,name,contenttype,size) VALUES (' +
608 IntToStr(i) + ',"' + fileinfo.Extension + '","' + fileinfo.Name + '","' + IntToHex(
609 fileinfo.FileType, 8) + '",0);';
610 Query.ExecSQL;
611 end;
612 if ((i mod 100) = 0) and (i > 0) then
613 begin
614 Database.Commit(False);
615 Database.StartTransaction;
616 end;
617 if ((i mod 10) = 0) and (i >= 100) then
618 lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
619 (Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat );
620 progress.Position := i;
621 lbl_progress.Caption := 'Files done: ' + IntToStr(i) + '/' + IntToStr(progress.Max);
622 Application.ProcessMessages;
623 if abort then
624 begin
625 stop_convert;
626 Exit;
627 end;
628 end;
629 Database.Commit(False);
630 progress.Position := progress.Max;
631 lbl_progress.Caption := 'Files done: ' + IntToStr(progress.Max) + '/' +
632 IntToStr(progress.Max);
633
634 lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')';
635
636 DoStep('FIN');
637 btn_abortok.Caption := '&OK';
638 btn_abortok.Default := True;
639
640 converting := False;
641
642 database.Close;
643 database.Free;
644
645 CloseDataConnection(DataConnections[conIndex]);
646end;
647
648
649
650
651procedure TForm_LevelDB.stop_convert;
652begin
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)';
658 DataBase.Close;
659 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;
664end;
665
666
667
668
669procedure TForm_LevelDB.btn_abortokClick(Sender: TObject);
670begin
671 if converting then
672 begin
673 if MessageBox(Self.Handle,
674 PChar('Do you really want to cancel the convert-progress?'),
675 PChar('Warning: Converting'), MB_YESNO) = idYes then
676 abort := True;
677 end
678 else
679 begin
680 Self.Visible := False;
681 Form_Main.Visible := True;
682 end;
683end;
684
685
686
687
688procedure InsertDatLinkToDB(fileid: LongWord; offset: LongWord);
689var
690 link: LongWord;
691begin
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;
700end;
701
702
703
704
705procedure AISA(fileid: LongWord; dir_dat2db: Boolean);
706var
707 packages: Word;
708 i: LongWord;
709begin
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;
724end;
725
726
727
728
729procedure AKEV(fileid: LongWord; dir_dat2db: Boolean);
730var
731 i: LongWord;
732begin
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;
741end;
742
743
744
745
746procedure AKOT(fileid: LongWord; dir_dat2db: Boolean);
747var
748 i: LongWord;
749begin
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;
758end;
759
760
761
762
763procedure CBPI(fileid: LongWord; dir_dat2db: Boolean);
764var
765 i: LongWord;
766begin
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;
775end;
776
777
778
779
780procedure CBPM(fileid: LongWord; dir_dat2db: Boolean);
781var
782 i: LongWord;
783begin
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;
792end;
793
794
795
796
797procedure CONS(fileid: LongWord; dir_dat2db: Boolean);
798var
799 i: LongWord;
800begin
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;
809end;
810
811
812
813
814procedure CRSA(fileid: LongWord; dir_dat2db: Boolean);
815var
816 packages: LongWord;
817 i: LongWord;
818begin
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;
829end;
830
831
832
833
834procedure DOOR(fileid: LongWord; dir_dat2db: Boolean);
835begin
836 if dir_dat2db then
837 begin
838 InsertDatLinkToDB(fileid, $08);
839 InsertDatLinkToDB(fileid, $10);
840 end
841 else
842 begin
843 end;
844end;
845
846
847
848
849procedure DPGE(fileid: LongWord; dir_dat2db: Boolean);
850begin
851 if dir_dat2db then
852 begin
853 InsertDatLinkToDB(fileid, $40);
854 end
855 else
856 begin
857 end;
858end;
859
860
861
862
863procedure HPGE(fileid: LongWord; dir_dat2db: Boolean);
864begin
865 if dir_dat2db then
866 begin
867 InsertDatLinkToDB(fileid, $0C);
868 end
869 else
870 begin
871 end;
872end;
873
874
875
876
877procedure IGHH(fileid: LongWord; dir_dat2db: Boolean);
878begin
879 if dir_dat2db then
880 begin
881 InsertDatLinkToDB(fileid, $24);
882 InsertDatLinkToDB(fileid, $28);
883 end
884 else
885 begin
886 end;
887end;
888
889
890
891
892procedure IGPA(fileid: LongWord; dir_dat2db: Boolean);
893var
894 links: LongWord;
895 i: LongWord;
896begin
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;
907end;
908
909
910
911
912procedure IGPG(fileid: LongWord; dir_dat2db: Boolean);
913var
914 i: LongWord;
915begin
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;
924end;
925
926
927
928
929procedure IGSA(fileid: LongWord; dir_dat2db: Boolean);
930var
931 links: LongWord;
932 i: LongWord;
933begin
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;
944end;
945
946
947
948
949procedure IMPT(fileid: LongWord; dir_dat2db: Boolean);
950begin
951 if dir_dat2db then
952 begin
953 InsertDatLinkToDB(fileid, $10);
954 end
955 else
956 begin
957 end;
958end;
959
960
961
962
963procedure IPGE(fileid: LongWord; dir_dat2db: Boolean);
964begin
965 if dir_dat2db then
966 begin
967 InsertDatLinkToDB(fileid, $0C);
968 end
969 else
970 begin
971 end;
972end;
973
974
975
976
977procedure KEYI(fileid: LongWord; dir_dat2db: Boolean);
978var
979 i: LongWord;
980begin
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;
989end;
990
991
992
993
994procedure M3GA(fileid: LongWord; dir_dat2db: Boolean);
995var
996 links: LongWord;
997 i: LongWord;
998begin
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;
1009end;
1010
1011
1012
1013
1014procedure M3GM(fileid: LongWord; dir_dat2db: Boolean);
1015var
1016 i: LongWord;
1017begin
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;
1026end;
1027
1028
1029
1030
1031procedure MTRL(fileid: LongWord; dir_dat2db: Boolean);
1032begin
1033 if dir_dat2db then
1034 begin
1035 InsertDatLinkToDB(fileid, $10);
1036 end
1037 else
1038 begin
1039 end;
1040end;
1041
1042
1043
1044
1045procedure OBDC(fileid: LongWord; dir_dat2db: Boolean);
1046var
1047 packages: Word;
1048 i: LongWord;
1049begin
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;
1060end;
1061
1062
1063
1064
1065procedure OBOA(fileid: LongWord; dir_dat2db: Boolean);
1066var
1067 packages: Word;
1068 i: LongWord;
1069begin
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;
1084end;
1085
1086
1087
1088
1089procedure OFGA(fileid: LongWord; dir_dat2db: Boolean);
1090var
1091 packages: LongWord;
1092 i: LongWord;
1093begin
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;
1104end;
1105
1106
1107
1108
1109procedure ONCC(fileid: LongWord; dir_dat2db: Boolean);
1110var
1111 i: LongWord;
1112begin
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;
1129end;
1130
1131
1132
1133
1134procedure ONCV(fileid: LongWord; dir_dat2db: Boolean);
1135begin
1136 if dir_dat2db then
1137 begin
1138 InsertDatLinkToDB(fileid, $08);
1139 end
1140 else
1141 begin
1142 end;
1143end;
1144
1145
1146
1147
1148procedure ONLV(fileid: LongWord; dir_dat2db: Boolean);
1149var
1150 i: LongWord;
1151begin
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;
1163end;
1164
1165
1166
1167
1168procedure ONOA(fileid: LongWord; dir_dat2db: Boolean);
1169var
1170 packages: LongWord;
1171 i: LongWord;
1172begin
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;
1183end;
1184
1185
1186
1187
1188procedure ONSK(fileid: LongWord; dir_dat2db: Boolean);
1189begin
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;
1203end;
1204
1205
1206
1207
1208procedure ONVL(fileid: LongWord; dir_dat2db: Boolean);
1209var
1210 packages: LongWord;
1211 i: LongWord;
1212begin
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;
1223end;
1224
1225
1226
1227
1228procedure ONWC(fileid: LongWord; dir_dat2db: Boolean);
1229begin
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;
1245end;
1246
1247
1248
1249
1250procedure OPGE(fileid: LongWord; dir_dat2db: Boolean);
1251begin
1252 if dir_dat2db then
1253 begin
1254 InsertDatLinkToDB(fileid, $0C);
1255 end
1256 else
1257 begin
1258 end;
1259end;
1260
1261
1262
1263
1264procedure PSPC(fileid: LongWord; dir_dat2db: Boolean);
1265begin
1266 if dir_dat2db then
1267 begin
1268 InsertDatLinkToDB(fileid, $50);
1269 end
1270 else
1271 begin
1272 end;
1273end;
1274
1275
1276
1277
1278procedure PSPL(fileid: LongWord; dir_dat2db: Boolean);
1279var
1280 packages: LongWord;
1281 i: LongWord;
1282begin
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;
1293end;
1294
1295
1296
1297
1298procedure PSUI(fileid: LongWord; dir_dat2db: Boolean);
1299var
1300 i: LongWord;
1301begin
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;
1310end;
1311
1312
1313
1314
1315procedure STNA(fileid: LongWord; dir_dat2db: Boolean);
1316var
1317 packages: Word;
1318 i: LongWord;
1319begin
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;
1330end;
1331
1332
1333
1334
1335procedure TRAC(fileid: LongWord; dir_dat2db: Boolean);
1336var
1337 packages: Word;
1338 i: LongWord;
1339begin
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;
1351end;
1352
1353
1354
1355
1356procedure TRAM(fileid: LongWord; dir_dat2db: Boolean);
1357begin
1358 if dir_dat2db then
1359 begin
1360 InsertDatLinkToDB(fileid, $40);
1361 InsertDatLinkToDB(fileid, $44);
1362 end
1363 else
1364 begin
1365 end;
1366end;
1367
1368
1369
1370
1371procedure TRAS(fileid: LongWord; dir_dat2db: Boolean);
1372begin
1373 if dir_dat2db then
1374 begin
1375 InsertDatLinkToDB(fileid, $08);
1376 end
1377 else
1378 begin
1379 end;
1380end;
1381
1382
1383
1384
1385procedure TRBS(fileid: LongWord; dir_dat2db: Boolean);
1386var
1387 i: LongWord;
1388begin
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;
1397end;
1398
1399
1400
1401
1402procedure TRCM(fileid: LongWord; dir_dat2db: Boolean);
1403var
1404 i: LongWord;
1405begin
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;
1414end;
1415
1416
1417
1418
1419procedure TRGA(fileid: LongWord; dir_dat2db: Boolean);
1420var
1421 i: LongWord;
1422 packages: Word;
1423begin
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;
1434end;
1435
1436
1437
1438
1439procedure TRGE(fileid: LongWord; dir_dat2db: Boolean);
1440begin
1441 if dir_dat2db then
1442 begin
1443 InsertDatLinkToDB(fileid, $20);
1444 end
1445 else
1446 begin
1447 end;
1448end;
1449
1450
1451
1452
1453procedure TRIG(fileid: LongWord; dir_dat2db: Boolean);
1454begin
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;
1464end;
1465
1466
1467
1468
1469procedure TRMA(fileid: LongWord; dir_dat2db: Boolean);
1470var
1471 i: LongWord;
1472 packages: Word;
1473begin
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;
1484end;
1485
1486
1487
1488
1489procedure TRSC(fileid: LongWord; dir_dat2db: Boolean);
1490var
1491 i: LongWord;
1492 packages: Word;
1493begin
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;
1504end;
1505
1506
1507
1508
1509procedure TSFF(fileid: LongWord; dir_dat2db: Boolean);
1510var
1511 i: LongWord;
1512 packages: LongWord;
1513begin
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;
1524end;
1525
1526
1527
1528
1529procedure TSFT(fileid: LongWord; dir_dat2db: Boolean);
1530begin
1531 if dir_dat2db then
1532 begin
1533 InsertDatLinkToDB(fileid, $1C);
1534 end
1535 else
1536 begin
1537 end;
1538end;
1539
1540
1541
1542
1543procedure TURR(fileid: LongWord; dir_dat2db: Boolean);
1544begin
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;
1554end;
1555
1556
1557
1558
1559procedure TXAN(fileid: LongWord; dir_dat2db: Boolean);
1560var
1561 i: LongWord;
1562 packages: LongWord;
1563begin
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;
1574end;
1575
1576
1577
1578
1579procedure TXMA(fileid: LongWord; dir_dat2db: Boolean);
1580var
1581 i: LongWord;
1582 packages: LongWord;
1583begin
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;
1594end;
1595
1596
1597
1598
1599procedure TXMB(fileid: LongWord; dir_dat2db: Boolean);
1600var
1601 i: LongWord;
1602 packages: LongWord;
1603begin
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;
1614end;
1615
1616
1617
1618
1619procedure TXMP(fileid: LongWord; dir_dat2db: Boolean);
1620begin
1621 if dir_dat2db then
1622 begin
1623 InsertDatLinkToDB(fileid, $94);
1624 InsertDatLinkToDB(fileid, $98);
1625 end
1626 else
1627 begin
1628 end;
1629end;
1630
1631
1632
1633
1634procedure TXTC(fileid: LongWord; dir_dat2db: Boolean);
1635begin
1636 if dir_dat2db then
1637 begin
1638 InsertDatLinkToDB(fileid, $08);
1639 end
1640 else
1641 begin
1642 end;
1643end;
1644
1645
1646
1647
1648procedure WMCL(fileid: LongWord; dir_dat2db: Boolean);
1649var
1650 i: LongWord;
1651 packages: LongWord;
1652begin
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;
1663end;
1664
1665
1666
1667
1668procedure WMDD(fileid: LongWord; dir_dat2db: Boolean);
1669var
1670 i: LongWord;
1671 packages: LongWord;
1672begin
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;
1683end;
1684
1685
1686
1687
1688procedure WMMB(fileid: LongWord; dir_dat2db: Boolean);
1689var
1690 i: LongWord;
1691 packages: LongWord;
1692begin
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;
1703end;
1704
1705
1706
1707
1708procedure WPGE(fileid: LongWord; dir_dat2db: Boolean);
1709begin
1710 if dir_dat2db then
1711 begin
1712 InsertDatLinkToDB(fileid, $08);
1713 InsertDatLinkToDB(fileid, $0C);
1714 end
1715 else
1716 begin
1717 end;
1718end;
1719
1720
1721
1722
1723procedure InsertHandler(ext: String; needed: Boolean; handler: THandler);
1724begin
1725 SetLength(ConvertHandlers, Length(ConvertHandlers) + 1);
1726 ConvertHandlers[High(ConvertHandlers)].Ext := ext;
1727 ConvertHandlers[High(ConvertHandlers)].needed := needed;
1728 ConvertHandlers[High(ConvertHandlers)].handler := handler;
1729end;
1730
1731begin
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);
1830end.
Note: See TracBrowser for help on using the repository browser.