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

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