source: oup/releases/0.22a/Unit10_leveldb.pas@ 1043

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