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

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