source: oup/releases/0.29a/Unit10_leveldb.pas@ 1157

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