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

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