source: oup/releases/0.20a/Unit10_leveldb.pas@ 907

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