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

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