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

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