source: oup/releases/0.30a/Unit10_leveldb.pas@ 356

Last change on this file since 356 was 33, checked in by alloc, 18 years ago
File size: 28.9 KB
RevLine 
[33]1UNIT Unit10_leveldb;
2INTERFACE
3USES
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, ComCtrls, StdCtrls, StrUtils;
6
7TYPE
8 TForm10 = 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:LongWord; dir_dat2db:Boolean);
17 PROCEDURE stop_convert;
18 PUBLIC
19 PROCEDURE CreateDatabase(source,target:String);
20 PROCEDURE CreateLevel(source,target:String);
21 END;
22
23
24VAR
25 Form10: TForm10;
26
27IMPLEMENTATION
28{$R *.dfm}
29USES ABSMain, ABSDecUtil, Unit1_main, Unit2_functions, Unit3_data, Unit9_data_structures;
30TYPE
31 THandler=PROCEDURE(fileid:LongWord; dir_dat2db:Boolean);
32 TConvertHandlers=RECORD
33 Ext:String[4];
34 needed:Boolean;
35 Handler:THandler;
36 END;
37VAR
38 ConvertHandlers:Array OF TConvertHandlers;
39 loaded_filename:String;
40 converting:Boolean=False;
41 abort:Boolean=False;
42 filestream:TFileStream;
43 dat_stream:TMemoryStream;
44 raw_stream:TMemoryStream;
45 mem:TMemoryStream;
46 DataBase:TABSDatabase;
47 Query:TABSQuery;
48 MimeCoder: TStringFormat_MIME64;
49
50PROCEDURE TForm10.HandleFile;
51 VAR
52 i:Byte;
53 BEGIN
54 FOR i:=1 TO Length(ConvertHandlers) DO
55 IF UpperCase(ConvertHandlers[i].Ext)=UpperCase(ext) THEN
56 IF ConvertHandlers[i].needed THEN BEGIN
57 ConvertHandlers[i].Handler(fileid, dir_dat2db);
58 Break;
59 END ELSE
60 Break;
61 END;
62
63PROCEDURE TForm10.CreateLevel(source,target:String);
64 VAR
65 i:LongWord;
66 BEGIN
67 END;
68
69PROCEDURE TForm10.CreateDatabase(source,target:String);
70{ VAR
71 i,j:LongWord;
72 temps,temps2:String;
73 data:Tdata;
74 absolutebegintime,begintime:Double;
75 step:Byte;
76 rawlist:TRawList;
77 CONST
78 steps:Byte=4;
79 PROCEDURE DoStep(stepname:String);
80 BEGIN
81 Inc(step);
82 IF stepname<>'FIN' THEN
83 group_progress.Caption:='Creating DB (Step '+IntToStr(step)+'/'+IntToStr(steps)+': '+stepname+')'
84 ELSE
85 group_progress.Caption:='Creating DB (FINISHED)';
86 END;
87 BEGIN
88 Form10.Visible:=True;
89 Form1.Visible:=False;
90 step:=0;
91 converting:=True;
92 abort:=False;
93 loaded_filename:=target;
94 btn_abortok.Caption:='&Abort...';
95 btn_abortok.Default:=False;
96
97 absolutebegintime:=Time;
98
99 DataBase:=TABSDatabase.Create(Self);
100 DataBase.DatabaseName:='OLDB';
101 DataBase.DatabaseFileName:=loaded_filename;
102 DataBase.CreateDatabase;
103
104 DoStep('Creating tables');
105 progress.Position:=0;
106 lbl_progress.Caption:='';
107 lbl_estimation.Caption:='Estimated finishing time: unknown';
108 Application.ProcessMessages;
109
110 Query:=TABSQuery.Create(Self);
111 Query.DatabaseName:='OLDB';
112 Query.SQL.Text:='CREATE TABLE globals ( id AUTOINC PRIMARY KEY, name STRING(128), value STRING(128) );';
113 Query.ExecSQL;
114 Query.SQL.Text:='CREATE TABLE linkmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, target_id INTEGER );';
115 Query.ExecSQL;
116 Query.SQL.Text:='CREATE TABLE rawmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib );';
117// Query.SQL.Text:='CREATE TABLE rawmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
118 Query.ExecSQL;
119 Query.SQL.Text:='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 );';
120// Query.SQL.Text:='CREATE TABLE datfiles ( id INTEGER PRIMARY KEY, extension CHAR(4), name STRING(128), contenttype INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
121 Query.ExecSQL;
122 Query.SQL.Text:='CREATE TABLE extlist ( id AUTOINC PRIMARY KEY, ext CHAR(4), ident CHAR(16) );';
123 Query.ExecSQL;
124
125 Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("dbversion","'+dbversion+'");';
126 Query.ExecSQL;
127 SetLength(data,Length(dat_header.Ident));
128 FOR i:=0 TO High(dat_header.Ident) DO data[i]:=dat_header.Ident[i];
129 temps:=CreateHexString(data,True);
130 Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("ident","'+temps+'");';
131 Query.ExecSQL;
132 data:=LoadDatFile(0);
133 i:=data[7];
134 i:=i DIV 2;
135 Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("lvl","'+IntToStr(i)+'");';
136 Query.ExecSQL;
137 IF dat_os_mac THEN
138 Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("os","MAC");'
139 ELSE
140 Query.SQL.Text:='INSERT INTO globals (name,value) VALUES ("os","PC");';
141 Query.ExecSQL;
142
143 DoStep('Writing extensionslist');
144 progress.Max:=dat_header.Extensions;
145 Application.ProcessMessages;
146
147 FOR i:=0 TO dat_header.Extensions-1 DO BEGIN
148 SetLength(data,Length(dat_extensionsmap[i].Ident));
149 FOR j:=0 TO High(dat_extensionsmap[i].Ident) DO data[j]:=dat_extensionsmap[i].Ident[j];
150 temps:=CreateHexString(data,True);
151 temps2:=dat_extensionsmap[i].Extension[3]+dat_extensionsmap[i].Extension[2]+dat_extensionsmap[i].Extension[1]+dat_extensionsmap[i].Extension[0];
152 Query.SQL.Text:='INSERT INTO extlist (ext,ident) VALUES ("'+temps2+'","'+temps+'");';
153 Query.ExecSQL;
154 progress.Position:=i;
155 lbl_progress.Caption:='Extensions done: '+IntToStr(i)+'/'+IntToStr(dat_header.Extensions);
156 Application.ProcessMessages;
157 IF abort THEN BEGIN
158 stop_convert;
159 Exit;
160 END;
161 END;
162 lbl_progress.Caption:='';
163
164 progress.Position:=0;
165 lbl_progress.Caption:='Files done: '+IntToStr(0)+'/'+IntToStr(dat_header.Files);
166 lbl_estimation.Caption:='Estimated finishing time: unknown';
167
168 DoStep('Loading .dat into memory');
169 Application.ProcessMessages;
170
171 filestream:=TFileStream.Create(dat_filename, fmOpenRead);
172 dat_stream:=TMemoryStream.Create;
173 dat_stream.CopyFrom(filestream,0);
174 dat_stream.Seek(0,soFromBeginning);
175 filestream.Free;
176
177 progress.Max:=dat_header.Files;
178 begintime:=Time;
179 DoStep('Writing .dat-fileslist');
180 Application.ProcessMessages;
181
182 Database.StartTransaction;
183 FOR i:=0 TO dat_header.Files-1 DO BEGIN
184 IF (dat_files[i].FileType AND $02)=0 THEN BEGIN
185 dat_stream.Seek(dat_files[i].DatAddr,soFromBeginning);
186 mimecoder:=TStringFormat_MIME64.Create;
187 mem:=TMemoryStream.Create;
188 mem.CopyFrom(dat_stream,dat_files[i].Size);
189 Query.SQL.Text:='INSERT INTO datfiles (id,extension,name,contenttype,size,data) VALUES ('+IntToStr(i)+',"'+dat_files[i].Extension+'","'+dat_files[i].Name+'","'+IntToHex(dat_files[i].FileType,8)+'",'+IntToStr(dat_files[i].size)+',MimeToBin("'+MimeCoder.StrTo(mem.Memory, mem.Size)+'") );';
190 Query.ExecSQL;
191 mem.Free;
192 mimecoder.Free;
193
194 rawlist:=GetRawList(i);
195 IF Length(rawlist)>0 THEN BEGIN
196 FOR j:=0 TO High(rawlist) DO BEGIN
197 IF rawlist[j].raw_size>0 THEN BEGIN
198 mem:=TMemoryStream.Create;
199 filestream:=TFileStream.Create(raw_filename,fmOpenRead);
200 filestream.Seek(rawlist[j].raw_addr,soFromBeginning);
201 mem.CopyFrom(filestream,rawlist[j].raw_size);
202 filestream.Free;
203 mimecoder:=TStringFormat_MIME64.Create;
204 Query.SQL.Text:='INSERT INTO rawmap (src_id,src_link_offset,size,data) VALUES ('+IntToStr(i)+','+IntToStr(rawlist[j].src_offset)+','+IntToStr(rawlist[j].raw_size)+',MimeToBin("'+MimeCoder.StrTo(mem.Memory, mem.Size)+'") );';
205 Query.ExecSQL;
206 mem.Free;
207 mimecoder.Free;
208 END ELSE BEGIN
209 Query.SQL.Text:='INSERT INTO rawmap (src_id,src_link_offset,size) VALUES ('+IntToStr(i)+','+IntToStr(rawlist[j].src_offset)+',0);';
210 Query.ExecSQL;
211 END;
212 END;
213 END;
214
215 HandleFile(dat_files[i].Extension,i,True);
216 END ELSE BEGIN
217 Query.SQL.Text:='INSERT INTO datfiles (id,extension,name,contenttype,size) VALUES ('+IntToStr(i)+',"'+dat_files[i].Extension+'","'+dat_files[i].Name+'","'+IntToHex(dat_files[i].FileType,8)+'",0);';
218 Query.ExecSQL;
219 END;
220 IF ( (i MOD 100)=0 ) AND (i>0) THEN BEGIN
221 Database.Commit(False);
222 Database.StartTransaction;
223 END;
224 IF ( (i MOD 25)=0 ) AND (i>=100) THEN
225 lbl_estimation.Caption:='Estimated finishing time: '+TimeToStr((Time-begintime)/i*dat_header.Files+begintime);
226 progress.Position:=i;
227 lbl_progress.Caption:='Files done: '+IntToStr(i)+'/'+IntToStr(dat_header.Files);
228 Application.ProcessMessages;
229 IF abort THEN BEGIN
230 stop_convert;
231 Exit;
232 END;
233 END;
234 Database.Commit(False);
235 progress.Position:=dat_header.Files;
236 lbl_progress.Caption:='Files done: '+IntToStr(dat_header.Files)+'/'+IntToStr(dat_header.Files);
237 lbl_estimation.Caption:='FINISHED (duration: '+TimeToStr(Time-absolutebegintime)+')';
238
239 DoStep('FIN');
240 btn_abortok.Caption:='&OK';
241 btn_abortok.Default:=True;
242
243 loaded_filename:='';
244 converting:=False;
245 dat_stream.Free;
246
247 database.Close;
248 database.Free;
249}begin END;
250
251PROCEDURE TForm10.stop_convert;
252 BEGIN
253 btn_abortok.Caption:='&Close';
254 btn_abortok.Default:=True;
255 converting:=False;
256 lbl_estimation.Caption:='ABORTED';
257 group_progress.Caption:='Creating DB (ABORTED)';
258 DataBase.Close;
259 IF MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'), PChar('Delete file?'), MB_YESNO)=IDYES THEN BEGIN
260 DeleteFile(loaded_filename);
261 END;
262 END;
263
264PROCEDURE TForm10.btn_abortokClick(Sender: TObject);
265 BEGIN
266 IF converting THEN BEGIN
267 IF MessageBox(Self.Handle, PChar('Do you really want to cancel the convert-progress?'), PChar('Warning: Converting'), MB_YESNO)=IDYES THEN
268 abort:=True;
269 END ELSE BEGIN
270 Form10.Visible:=False;
271 Form1.Visible:=True;
272 END;
273 END;
274
275
276PROCEDURE LoadFilePart(fileid,offset,size:LongWord; target:Pointer);
277 BEGIN
278 dat_stream.Seek(dat_files[fileid].DatAddr+offset,soFromBeginning);
279 dat_stream.Read(target^,size);
280 END;
281
282PROCEDURE InsertDatLinkToDB(fileid:LongWord; offset:LongWord);
283 VAR
284 link:LongWord;
285 BEGIN
286 LoadFilePart(fileid,offset,4,@link);
287 IF link=0 THEN
288 link:=$FFFFFFFF
289 ELSE
290 link:=link DIV 256;
291 Query.SQL.Text:='INSERT INTO linkmap (src_id,src_link_offset,target_id) VALUES ('+IntToStr(fileid)+','+IntToStr(offset)+','+IntToStr(link)+');';
292 Query.ExecSQL;
293 END;
294(*
295PROCEDURE InsertRawFileToDB(fileid:LongWord; src_offset,raw_addr,size:LongWord);
296 VAR
297 localmem:TMemoryStream;
298// temps:String;
299 BEGIN
300 IF size>0 THEN BEGIN
301 localmem:=TMemoryStream.Create;
302 filestream:=TFileStream.Create(raw_filename,fmOpenRead);
303 filestream.Seek(raw_addr,soFromBeginning);
304 localmem.CopyFrom(filestream,size);
305 filestream.Free;
306 mimecoder:=TStringFormat_MIME64.Create;
307 Query.SQL.Text:='INSERT INTO rawmap (src_id,src_link_offset,size,data) VALUES ('+IntToStr(fileid)+','+IntToStr(src_offset)+','+IntToStr(size)+',MimeToBin("'+MimeCoder.StrTo(localmem.Memory, localmem.Size)+'") );';
308 Query.ExecSQL;
309 localmem.Free;
310 mimecoder.Free;
311 END ELSE BEGIN
312 Query.SQL.Text:='INSERT INTO rawmap (src_id,src_link_offset,size) VALUES ('+IntToStr(fileid)+','+IntToStr(src_offset)+',0);';
313 Query.ExecSQL;
314 END;
315{ IF (raw_addr MOD 32)>0 THEN BEGIN
316 temps:='FileID='+FormatNumber(fileid,5,'0')+' - dat-Offset=0x'+IntToHex(src_offset,8)+' - raw-address=0x'+IntToHex(raw_addr,8)+#13+#10;
317 filestream:=TFileStream.Create('D:\not32.txt',fmOpenReadWrite);
318 filestream.Seek(0,soFromEnd);
319 filestream.Write(temps[1],Length(temps));
320 filestream.Free;
321 END; }
322 END;
323*)
324
325
326PROCEDURE AKEV(fileid:LongWord; dir_dat2db:Boolean);
327 VAR
328 i:LongWord;
329 BEGIN
330 IF dir_dat2db THEN BEGIN
331 FOR i:=0 TO 16 DO InsertDatLinkToDB(fileid,$8+i*4);
332 END ELSE BEGIN
333 END;
334 END;
335PROCEDURE AKOT(fileid:LongWord; dir_dat2db:Boolean);
336 VAR
337 i:LongWord;
338 BEGIN
339 IF dir_dat2db THEN BEGIN
340 FOR i:=0 TO 4 DO InsertDatLinkToDB(fileid,$8+i*4);
341 END ELSE BEGIN
342 END;
343 END;
344PROCEDURE CBPI(fileid:LongWord; dir_dat2db:Boolean);
345 VAR
346 i:LongWord;
347 BEGIN
348 IF dir_dat2db THEN BEGIN
349 FOR i:=0 TO 56 DO InsertDatLinkToDB(fileid,$8+i*4);
350 END ELSE BEGIN
351 END;
352 END;
353PROCEDURE CBPM(fileid:LongWord; dir_dat2db:Boolean);
354 VAR
355 i:LongWord;
356 BEGIN
357 IF dir_dat2db THEN BEGIN
358 FOR i:=0 TO 18 DO InsertDatLinkToDB(fileid,$8+i*4);
359 END ELSE BEGIN
360 END;
361 END;
362PROCEDURE CONS(fileid:LongWord; dir_dat2db:Boolean);
363 VAR
364 i:LongWord;
365 BEGIN
366 IF dir_dat2db THEN BEGIN
367 FOR i:=0 TO 1 DO InsertDatLinkToDB(fileid,$24+i*4);
368 END ELSE BEGIN
369 END;
370 END;
371PROCEDURE CRSA(fileid:LongWord; dir_dat2db:Boolean);
372 VAR
373 packages:LongWord;
374 i:LongWord;
375 BEGIN
376 IF dir_dat2db THEN BEGIN
377 LoadFilePart(fileid,$14,4,@packages);
378 IF packages>0 THEN
379 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*1100+$A0);
380 END ELSE BEGIN
381 END;
382 END;
383PROCEDURE DOOR(fileid:LongWord; dir_dat2db:Boolean);
384 BEGIN
385 IF dir_dat2db THEN BEGIN
386 InsertDatLinkToDB(fileid,$08);
387 InsertDatLinkToDB(fileid,$10);
388 END ELSE BEGIN
389 END;
390 END;
391PROCEDURE DPGE(fileid:LongWord; dir_dat2db:Boolean);
392 BEGIN
393 IF dir_dat2db THEN BEGIN
394 InsertDatLinkToDB(fileid,$40);
395 END ELSE BEGIN
396 END;
397 END;
398PROCEDURE HPGE(fileid:LongWord; dir_dat2db:Boolean);
399 BEGIN
400 IF dir_dat2db THEN BEGIN
401 InsertDatLinkToDB(fileid,$0C);
402 END ELSE BEGIN
403 END;
404 END;
405PROCEDURE IGHH(fileid:LongWord; dir_dat2db:Boolean);
406 BEGIN
407 IF dir_dat2db THEN BEGIN
408 InsertDatLinkToDB(fileid,$24);
409 InsertDatLinkToDB(fileid,$28);
410 END ELSE BEGIN
411 END;
412 END;
413PROCEDURE IGPA(fileid:LongWord; dir_dat2db:Boolean);
414 VAR
415 links:LongWord;
416 i:LongWord;
417 BEGIN
418 IF dir_dat2db THEN BEGIN
419 LoadFilePart(fileid,$1C,4,@links);
420 IF links>0 THEN
421 FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
422 END ELSE BEGIN
423 END;
424 END;
425PROCEDURE IGPG(fileid:LongWord; dir_dat2db:Boolean);
426 VAR
427 i:LongWord;
428 BEGIN
429 IF dir_dat2db THEN BEGIN
430 FOR i:=0 TO 1 DO InsertDatLinkToDB(fileid,$1C+i*4);
431 END ELSE BEGIN
432 END;
433 END;
434PROCEDURE IGSA(fileid:LongWord; dir_dat2db:Boolean);
435 VAR
436 links:LongWord;
437 i:LongWord;
438 BEGIN
439 IF dir_dat2db THEN BEGIN
440 LoadFilePart(fileid,$1C,4,@links);
441 IF links>0 THEN
442 FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
443 END ELSE BEGIN
444 END;
445 END;
446PROCEDURE IMPT(fileid:LongWord; dir_dat2db:Boolean);
447 BEGIN
448 IF dir_dat2db THEN BEGIN
449 InsertDatLinkToDB(fileid,$10);
450 END ELSE BEGIN
451 END;
452 END;
453PROCEDURE IPGE(fileid:LongWord; dir_dat2db:Boolean);
454 BEGIN
455 IF dir_dat2db THEN BEGIN
456 InsertDatLinkToDB(fileid,$0C);
457 END ELSE BEGIN
458 END;
459 END;
460PROCEDURE KEYI(fileid:LongWord; dir_dat2db:Boolean);
461 VAR
462 i:LongWord;
463 BEGIN
464 IF dir_dat2db THEN BEGIN
465 FOR i:=0 TO 9 DO InsertDatLinkToDB(fileid,$08+i*4);
466 END ELSE BEGIN
467 END;
468 END;
469PROCEDURE M3GA(fileid:LongWord; dir_dat2db:Boolean);
470 VAR
471 links:LongWord;
472 i:LongWord;
473 BEGIN
474 IF dir_dat2db THEN BEGIN
475 LoadFilePart(fileid,$1C,4,@links);
476 IF links>0 THEN
477 FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
478 END ELSE BEGIN
479 END;
480 END;
481PROCEDURE M3GM(fileid:LongWord; dir_dat2db:Boolean);
482 VAR
483 i:LongWord;
484 BEGIN
485 IF dir_dat2db THEN BEGIN
486 FOR i:=0 TO 6 DO InsertDatLinkToDB(fileid,$0C+i*4);
487 END ELSE BEGIN
488 END;
489 END;
490PROCEDURE MTRL(fileid:LongWord; dir_dat2db:Boolean);
491 BEGIN
492 IF dir_dat2db THEN BEGIN
493 InsertDatLinkToDB(fileid,$10);
494 END ELSE BEGIN
495 END;
496 END;
497PROCEDURE OBOA(fileid:LongWord; dir_dat2db:Boolean);
498 VAR
499 packages:Word;
500 i:LongWord;
501 BEGIN
502 IF dir_dat2db THEN BEGIN
503 LoadFilePart(fileid,$1E,2,@packages);
504 IF packages>0 THEN
505 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*240);
506 END ELSE BEGIN
507 END;
508 END;
509PROCEDURE OFGA(fileid:LongWord; dir_dat2db:Boolean);
510 VAR
511 packages:LongWord;
512 i:LongWord;
513 BEGIN
514 IF dir_dat2db THEN BEGIN
515 LoadFilePart(fileid,$1C,4,@packages);
516 IF packages>0 THEN
517 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*12+$04);
518 END ELSE BEGIN
519 END;
520 END;
521PROCEDURE ONCC(fileid:LongWord; dir_dat2db:Boolean);
522 VAR
523 i:LongWord;
524 BEGIN
525 IF dir_dat2db THEN BEGIN
526 END ELSE BEGIN
527 END;
528 END;
529PROCEDURE ONCV(fileid:LongWord; dir_dat2db:Boolean);
530 BEGIN
531 IF dir_dat2db THEN BEGIN
532 InsertDatLinkToDB(fileid,$08);
533 END ELSE BEGIN
534 END;
535 END;
536PROCEDURE ONLV(fileid:LongWord; dir_dat2db:Boolean);
537 VAR
538 i:LongWord;
539 BEGIN
540 IF dir_dat2db THEN BEGIN
541 FOR i:=0 TO 5 DO InsertDatLinkToDB(fileid,$48+i*4);
542 FOR i:=0 TO 5 DO InsertDatLinkToDB(fileid,$64+i*4);
543 InsertDatLinkToDB(fileid,$300);
544 END ELSE BEGIN
545 END;
546 END;
547PROCEDURE ONOA(fileid:LongWord; dir_dat2db:Boolean);
548 VAR
549 packages:LongWord;
550 i:LongWord;
551 BEGIN
552 IF dir_dat2db THEN BEGIN
553 LoadFilePart(fileid,$1C,4,@packages);
554 IF packages>0 THEN
555 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*8+$04);
556 END ELSE BEGIN
557 END;
558 END;
559PROCEDURE ONSK(fileid:LongWord; dir_dat2db:Boolean);
560 BEGIN
561 IF dir_dat2db THEN BEGIN
562 InsertDatLinkToDB(fileid,$08);
563 InsertDatLinkToDB(fileid,$0C);
564 InsertDatLinkToDB(fileid,$10);
565 InsertDatLinkToDB(fileid,$14);
566 InsertDatLinkToDB(fileid,$18);
567 InsertDatLinkToDB(fileid,$20);
568 InsertDatLinkToDB(fileid,$44);
569 END ELSE BEGIN
570 END;
571 END;
572PROCEDURE ONVL(fileid:LongWord; dir_dat2db:Boolean);
573 VAR
574 packages:LongWord;
575 i:LongWord;
576 BEGIN
577 IF dir_dat2db THEN BEGIN
578 LoadFilePart(fileid,$1C,4,@packages);
579 IF packages>0 THEN
580 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
581 END ELSE BEGIN
582 END;
583 END;
584PROCEDURE ONWC(fileid:LongWord; dir_dat2db:Boolean);
585 BEGIN
586 IF dir_dat2db THEN BEGIN
587 InsertDatLinkToDB(fileid,$28);
588 InsertDatLinkToDB(fileid,$34);
589 InsertDatLinkToDB(fileid,$54);
590 InsertDatLinkToDB(fileid,$58);
591 InsertDatLinkToDB(fileid,$5C);
592 InsertDatLinkToDB(fileid,$60);
593 InsertDatLinkToDB(fileid,$6FC);
594 InsertDatLinkToDB(fileid,$700);
595 END ELSE BEGIN
596 END;
597 END;
598PROCEDURE OPGE(fileid:LongWord; dir_dat2db:Boolean);
599 BEGIN
600 IF dir_dat2db THEN BEGIN
601 InsertDatLinkToDB(fileid,$1C);
602 END ELSE BEGIN
603 END;
604 END;
605PROCEDURE PSPC(fileid:LongWord; dir_dat2db:Boolean);
606 BEGIN
607 IF dir_dat2db THEN BEGIN
608 InsertDatLinkToDB(fileid,$50);
609 END ELSE BEGIN
610 END;
611 END;
612PROCEDURE PSPL(fileid:LongWord; dir_dat2db:Boolean);
613 VAR
614 packages:LongWord;
615 i:LongWord;
616 BEGIN
617 IF dir_dat2db THEN BEGIN
618 LoadFilePart(fileid,$1C,4,@packages);
619 IF packages>0 THEN
620 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$24+i*8);
621 END ELSE BEGIN
622 END;
623 END;
624PROCEDURE PSUI(fileid:LongWord; dir_dat2db:Boolean);
625 VAR
626 i:LongWord;
627 BEGIN
628 IF dir_dat2db THEN BEGIN
629 FOR i:=0 TO 43 DO InsertDatLinkToDB(fileid,$08+i*4);
630 END ELSE BEGIN
631 END;
632 END;
633PROCEDURE STNA(fileid:LongWord; dir_dat2db:Boolean);
634 VAR
635 packages:Word;
636 i:LongWord;
637 BEGIN
638 IF dir_dat2db THEN BEGIN
639 LoadFilePart(fileid,$1E,2,@packages);
640 IF packages>0 THEN
641 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
642 END ELSE BEGIN
643 END;
644 END;
645PROCEDURE TRAC(fileid:LongWord; dir_dat2db:Boolean);
646 VAR
647 packages:Word;
648 i:LongWord;
649 BEGIN
650 IF dir_dat2db THEN BEGIN
651 InsertDatLinkToDB(fileid,$18);
652 LoadFilePart(fileid,$1E,2,@packages);
653 IF packages>0 THEN
654 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*12+8);
655 END ELSE BEGIN
656 END;
657 END;
658PROCEDURE TRAM(fileid:LongWord; dir_dat2db:Boolean);
659 BEGIN
660 IF dir_dat2db THEN BEGIN
661 InsertDatLinkToDB(fileid,$40);
662 InsertDatLinkToDB(fileid,$44);
663 END ELSE BEGIN
664 END;
665 END;
666PROCEDURE TRAS(fileid:LongWord; dir_dat2db:Boolean);
667 BEGIN
668 IF dir_dat2db THEN BEGIN
669 InsertDatLinkToDB(fileid,$08);
670 END ELSE BEGIN
671 END;
672 END;
673PROCEDURE TRBS(fileid:LongWord; dir_dat2db:Boolean);
674 VAR
675 i:LongWord;
676 BEGIN
677 IF dir_dat2db THEN BEGIN
678 FOR i:=0 TO 4 DO InsertDatLinkToDB(fileid,$08+i*4);
679 END ELSE BEGIN
680 END;
681 END;
682PROCEDURE TRCM(fileid:LongWord; dir_dat2db:Boolean);
683 VAR
684 i:LongWord;
685 BEGIN
686 IF dir_dat2db THEN BEGIN
687 FOR i:=0 TO 2 DO InsertDatLinkToDB(fileid,$5C+i*4);
688 END ELSE BEGIN
689 END;
690 END;
691PROCEDURE TRGA(fileid:LongWord; dir_dat2db:Boolean);
692 VAR
693 i:LongWord;
694 packages:Word;
695 BEGIN
696 IF dir_dat2db THEN BEGIN
697 LoadFilePart(fileid,$1E,2,@packages);
698 IF packages>0 THEN
699 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
700 END ELSE BEGIN
701 END;
702 END;
703PROCEDURE TRGE(fileid:LongWord; dir_dat2db:Boolean);
704 BEGIN
705 IF dir_dat2db THEN BEGIN
706 InsertDatLinkToDB(fileid,$20);
707 END ELSE BEGIN
708 END;
709 END;
710PROCEDURE TRIG(fileid:LongWord; dir_dat2db:Boolean);
711 BEGIN
712 IF dir_dat2db THEN BEGIN
713 InsertDatLinkToDB(fileid,$18);
714 InsertDatLinkToDB(fileid,$24);
715 InsertDatLinkToDB(fileid,$28);
716 END ELSE BEGIN
717 END;
718 END;
719PROCEDURE TRMA(fileid:LongWord; dir_dat2db:Boolean);
720 VAR
721 i:LongWord;
722 packages:Word;
723 BEGIN
724 IF dir_dat2db THEN BEGIN
725 LoadFilePart(fileid,$1E,2,@packages);
726 IF packages>0 THEN
727 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
728 END ELSE BEGIN
729 END;
730 END;
731PROCEDURE TRSC(fileid:LongWord; dir_dat2db:Boolean);
732 VAR
733 i:LongWord;
734 packages:Word;
735 BEGIN
736 IF dir_dat2db THEN BEGIN
737 LoadFilePart(fileid,$1E,2,@packages);
738 IF packages>0 THEN
739 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
740 END ELSE BEGIN
741 END;
742 END;
743PROCEDURE TSFF(fileid:LongWord; dir_dat2db:Boolean);
744 VAR
745 i:LongWord;
746 packages:LongWord;
747 BEGIN
748 IF dir_dat2db THEN BEGIN
749 LoadFilePart(fileid,$1C,4,@packages);
750 IF packages>0 THEN
751 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
752 END ELSE BEGIN
753 END;
754 END;
755PROCEDURE TSFT(fileid:LongWord; dir_dat2db:Boolean);
756 BEGIN
757 IF dir_dat2db THEN BEGIN
758 InsertDatLinkToDB(fileid,$1C);
759 END ELSE BEGIN
760 END;
761 END;
762PROCEDURE TURR(fileid:LongWord; dir_dat2db:Boolean);
763 BEGIN
764 IF dir_dat2db THEN BEGIN
765 InsertDatLinkToDB(fileid,$60);
766 InsertDatLinkToDB(fileid,$6C);
767 InsertDatLinkToDB(fileid,$74);
768 END ELSE BEGIN
769 END;
770 END;
771PROCEDURE TXAN(fileid:LongWord; dir_dat2db:Boolean);
772 VAR
773 i:LongWord;
774 packages:LongWord;
775 BEGIN
776 IF dir_dat2db THEN BEGIN
777 LoadFilePart(fileid,$1C,4,@packages);
778 IF packages>0 THEN
779 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
780 END ELSE BEGIN
781 END;
782 END;
783PROCEDURE TXMA(fileid:LongWord; dir_dat2db:Boolean);
784 VAR
785 i:LongWord;
786 packages:LongWord;
787 BEGIN
788 IF dir_dat2db THEN BEGIN
789 LoadFilePart(fileid,$1C,4,@packages);
790 IF packages>0 THEN
791 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
792 END ELSE BEGIN
793 END;
794 END;
795PROCEDURE TXMB(fileid:LongWord; dir_dat2db:Boolean);
796 VAR
797 i:LongWord;
798 packages:LongWord;
799 BEGIN
800 IF dir_dat2db THEN BEGIN
801 LoadFilePart(fileid,$1C,4,@packages);
802 IF packages>0 THEN
803 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
804 END ELSE BEGIN
805 END;
806 END;
807PROCEDURE TXMP(fileid:LongWord; dir_dat2db:Boolean);
808 BEGIN
809 IF dir_dat2db THEN BEGIN
810 InsertDatLinkToDB(fileid,$94);
811 InsertDatLinkToDB(fileid,$98);
812 END ELSE BEGIN
813 END;
814 END;
815PROCEDURE TXTC(fileid:LongWord; dir_dat2db:Boolean);
816 BEGIN
817 IF dir_dat2db THEN BEGIN
818 InsertDatLinkToDB(fileid,$08);
819 END ELSE BEGIN
820 END;
821 END;
822PROCEDURE WMCL(fileid:LongWord; dir_dat2db:Boolean);
823 BEGIN
824 IF dir_dat2db THEN BEGIN
825 InsertDatLinkToDB(fileid,$24);
826 END ELSE BEGIN
827 END;
828 END;
829PROCEDURE WMMB(fileid:LongWord; dir_dat2db:Boolean);
830 VAR
831 i:LongWord;
832 packages:LongWord;
833 BEGIN
834 IF dir_dat2db THEN BEGIN
835 LoadFilePart(fileid,$1C,4,@packages);
836 IF packages>0 THEN
837 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
838 END ELSE BEGIN
839 END;
840 END;
841PROCEDURE WPGE(fileid:LongWord; dir_dat2db:Boolean);
842 BEGIN
843 IF dir_dat2db THEN BEGIN
844 InsertDatLinkToDB(fileid,$08);
845 InsertDatLinkToDB(fileid,$0C);
846 END ELSE BEGIN
847 END;
848 END;
849
850PROCEDURE InsertHandler(ext:String; needed:Boolean; handler:THandler);
851 BEGIN
852 SetLength(ConvertHandlers,Length(ConvertHandlers)+1);
853 ConvertHandlers[High(ConvertHandlers)].Ext:=ext;
854 ConvertHandlers[High(ConvertHandlers)].needed:=needed;
855 ConvertHandlers[High(ConvertHandlers)].handler:=handler;
856 END;
857
858BEGIN
859 InsertHandler('ABNA',False,NIL);
860// InsertHandler('AGDB',True,AGDB);
861 InsertHandler('AGDB',False,NIL);
862 InsertHandler('AGQC',False,NIL);
863 InsertHandler('AGQG',False,NIL);
864 InsertHandler('AGQR',False,NIL);
865 InsertHandler('AISA',False,NIL);
866 InsertHandler('AITR',False,NIL);
867 InsertHandler('AKAA',False,NIL);
868 InsertHandler('AKBA',False,NIL);
869 InsertHandler('AKBP',False,NIL);
870 InsertHandler('AKDA',False,NIL);
871 InsertHandler('AKEV',True,AKEV);
872 InsertHandler('AKOT',True,AKOT);
873 InsertHandler('AKVA',False,NIL);
874 InsertHandler('BINA',False,NIL);
875 InsertHandler('CBPI',True,CBPI);
876 InsertHandler('CBPM',True,CBPM);
877 InsertHandler('CONS',True,CONS);
878 InsertHandler('CRSA',True,CRSA);
879 InsertHandler('DOOR',True,DOOR);
880 InsertHandler('DPGE',True,DPGE);
881 InsertHandler('ENVP',False,NIL);
882 InsertHandler('FILM',False,NIL);
883 InsertHandler('HPGE',True,HPGE);
884 InsertHandler('IDXA',False,NIL);
885 InsertHandler('IGHH',True,IGHH);
886 InsertHandler('IGPA',True,IGPA);
887 InsertHandler('IGPG',True,IGPG);
888 InsertHandler('IGSA',True,IGSA);
889 InsertHandler('IMPT',True,IMPT);
890 InsertHandler('IPGE',True,IPGE);
891 InsertHandler('KEYI',True,KEYI);
892 InsertHandler('M3GA',True,M3GA);
893 InsertHandler('M3GM',True,M3GM);
894 InsertHandler('MTRL',True,MTRL);
895 InsertHandler('OBAN',False,NIL);
896 InsertHandler('OBDC',False,NIL);
897 InsertHandler('OBOA',True,OBOA);
898 InsertHandler('OFGA',True,OFGA);
899 InsertHandler('ONCC',True,ONCC);
900 InsertHandler('ONCP',False,NIL);
901 InsertHandler('ONCV',True,ONCV);
902 InsertHandler('ONFA',False,NIL);
903 InsertHandler('ONGS',False,NIL);
904 InsertHandler('ONIA',False,NIL);
905 InsertHandler('ONLD',False,NIL);
906 InsertHandler('ONLV',True,ONLV);
907 InsertHandler('ONMA',False,NIL);
908 InsertHandler('ONOA',True,ONOA);
909 InsertHandler('ONSA',False,NIL);
910 InsertHandler('ONSK',True,ONSK);
911 InsertHandler('ONTA',False,NIL);
912 InsertHandler('ONVL',True,ONVL);
913 InsertHandler('ONWC',True,ONWC);
914 InsertHandler('OPGE',True,OPGE);
915 InsertHandler('OSBD',False,NIL);
916 InsertHandler('OTIT',False,NIL);
917 InsertHandler('OTLF',False,NIL);
918 InsertHandler('PLEA',False,NIL);
919 InsertHandler('PNTA',False,NIL);
920 InsertHandler('PSPC',True,PSPC);
921 InsertHandler('PSPL',True,PSPL);
922 InsertHandler('PSUI',True,PSUI);
923 InsertHandler('QTNA',False,NIL);
924 InsertHandler('SNDD',False,NIL);
925 InsertHandler('STNA',True,STNA);
926 InsertHandler('SUBT',False,NIL);
927 InsertHandler('TRAC',True,TRAC);
928 InsertHandler('TRAM',True,TRAM);
929 InsertHandler('TRAS',True,TRAS);
930 InsertHandler('TRBS',True,TRBS);
931 InsertHandler('TRCM',True,TRCM);
932 InsertHandler('TRGA',True,TRGA);
933 InsertHandler('TRGE',True,TRGE);
934 InsertHandler('TRIA',False,NIL);
935 InsertHandler('TRIG',True,TRIG);
936 InsertHandler('TRMA',True,TRMA);
937 InsertHandler('TRSC',True,TRSC);
938 InsertHandler('TRTA',False,NIL);
939 InsertHandler('TSFF',True,TSFF);
940 InsertHandler('TSFL',False,NIL);
941 InsertHandler('TSFT',True,TSFT);
942 InsertHandler('TSGA',False,NIL);
943 InsertHandler('TSTR',False,NIL);
944 InsertHandler('TURR',True,TURR);
945 InsertHandler('TXAN',True,TXAN);
946 InsertHandler('TXCA',False,NIL);
947 InsertHandler('TXMA',True,TXMA);
948 InsertHandler('TXMB',True,TXMB);
949 InsertHandler('TXMP',True,TXMP);
950 InsertHandler('TXTC',True,TXTC);
951 InsertHandler('VCRA',False,NIL);
952 InsertHandler('WMCL',True,WMCL);
953 InsertHandler('WMDD',False,NIL);
954 InsertHandler('WMM_',False,NIL);
955 InsertHandler('WMMB',True,WMMB);
956 InsertHandler('WPGE',True,WPGE);
957END.
Note: See TracBrowser for help on using the repository browser.