ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Helper/LevelDB.pas
(Generate patch)

Comparing oup/current/Helper/LevelDB.pas (file contents):
Revision 120 by alloc, Fri Mar 23 00:59:01 2007 UTC vs.
Revision 130 by alloc, Wed Mar 28 01:17:24 2007 UTC

# Line 1 | Line 1
1 {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
2 {$MINSTACKSIZE $00004000}
3 {$MAXSTACKSIZE $00100000}
4 {$IMAGEBASE $00400000}
5 {$APPTYPE GUI}
6 {$WARN SYMBOL_DEPRECATED ON}
7 {$WARN SYMBOL_LIBRARY ON}
8 {$WARN SYMBOL_PLATFORM ON}
9 {$WARN SYMBOL_EXPERIMENTAL ON}
10 {$WARN UNIT_LIBRARY ON}
11 {$WARN UNIT_PLATFORM ON}
12 {$WARN UNIT_DEPRECATED ON}
13 {$WARN UNIT_EXPERIMENTAL ON}
14 {$WARN HRESULT_COMPAT ON}
15 {$WARN HIDING_MEMBER ON}
16 {$WARN HIDDEN_VIRTUAL ON}
17 {$WARN GARBAGE ON}
18 {$WARN BOUNDS_ERROR ON}
19 {$WARN ZERO_NIL_COMPAT ON}
20 {$WARN STRING_CONST_TRUNCED ON}
21 {$WARN FOR_LOOP_VAR_VARPAR ON}
22 {$WARN TYPED_CONST_VARPAR ON}
23 {$WARN ASG_TO_TYPED_CONST ON}
24 {$WARN CASE_LABEL_RANGE ON}
25 {$WARN FOR_VARIABLE ON}
26 {$WARN CONSTRUCTING_ABSTRACT ON}
27 {$WARN COMPARISON_FALSE ON}
28 {$WARN COMPARISON_TRUE ON}
29 {$WARN COMPARING_SIGNED_UNSIGNED ON}
30 {$WARN COMBINING_SIGNED_UNSIGNED ON}
31 {$WARN UNSUPPORTED_CONSTRUCT ON}
32 {$WARN FILE_OPEN ON}
33 {$WARN FILE_OPEN_UNITSRC ON}
34 {$WARN BAD_GLOBAL_SYMBOL ON}
35 {$WARN DUPLICATE_CTOR_DTOR ON}
36 {$WARN INVALID_DIRECTIVE ON}
37 {$WARN PACKAGE_NO_LINK ON}
38 {$WARN PACKAGED_THREADVAR ON}
39 {$WARN IMPLICIT_IMPORT ON}
40 {$WARN HPPEMIT_IGNORED ON}
41 {$WARN NO_RETVAL ON}
42 {$WARN USE_BEFORE_DEF ON}
43 {$WARN FOR_LOOP_VAR_UNDEF ON}
44 {$WARN UNIT_NAME_MISMATCH ON}
45 {$WARN NO_CFG_FILE_FOUND ON}
46 {$WARN IMPLICIT_VARIANTS ON}
47 {$WARN UNICODE_TO_LOCALE ON}
48 {$WARN LOCALE_TO_UNICODE ON}
49 {$WARN IMAGEBASE_MULTIPLE ON}
50 {$WARN SUSPICIOUS_TYPECAST ON}
51 {$WARN PRIVATE_PROPACCESSOR ON}
52 {$WARN UNSAFE_TYPE OFF}
53 {$WARN UNSAFE_CODE OFF}
54 {$WARN UNSAFE_CAST OFF}
55 {$WARN OPTION_TRUNCATED ON}
56 {$WARN WIDECHAR_REDUCED ON}
57 {$WARN DUPLICATES_IGNORED ON}
58 {$WARN UNIT_INIT_SEQ ON}
59 {$WARN LOCAL_PINVOKE ON}
60 {$WARN MESSAGE_DIRECTIVE ON}
1   unit LevelDB;
2   interface
3   uses
# Line 215 | Line 155 | begin
155        begin
156          ShowMessage('Couldn''t delete file. Aborting');
157          Exit;
158 <      end else if not DeleteFile(AnsiReplaceStr(Target, '.dat', '.sep')) then
158 >      end else if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
159        begin
160 <        ShowMessage('Couldn''t delete file. Aborting');
161 <        Exit;
160 >        if not DeleteFile(AnsiReplaceStr(Target, '.dat', '.sep')) then
161 >        begin
162 >          ShowMessage('Couldn''t delete file. Aborting');
163 >          Exit;
164 >        end;
165        end;
166      end else begin
167        ShowMessage('Aborting');
# Line 371 | Line 314 | begin
314            if RawLinks[i].RawSize > 0 then
315            begin
316              RawFileStream := TMemoryStream.Create;
317 <            if UpperCase(fileinfo.Extension) = 'TXMP' then
317 >            Connection.LoadRawFile(FileID, RawLinks[i].SrcOffset, TStream(RawFileStream));
318 >            RawFileStream.Seek(0, soFromBeginning);
319 >            if RawLinks[i].LocSep then
320              begin
321 <              DatFileStream.Seek($88, soFromBeginning);
322 <              DatFileStream.Read(tempb, 1);
378 <              if (tempb and $01) > 0 then
379 <              begin
380 <                OniImage.Load(Connection.ConnectionID, FileID);
381 <                if not OniImage.GetMipMappedImage(TStream(RawFileStream)) then
382 <                begin
383 <                  ShowMessage('MipMapping-Error');
384 <                  RawFileStream.Seek(0, soFromBeginning);
385 <                  tempb := tempb and $FE;
386 <                  DatFileStream.Seek($88, soFromBeginning);
387 <                  DatFileStream.Write(tempb, 1);
388 <                  OniImage.Load(Connection.ConnectionID, FileID);
389 <                  OniImage.GetAsData(TStream(RawFileStream));
390 <                end else
391 <                begin
392 <                  // Change of Depth($89), Storetype ($90)
393 <                  DatFileStream.Seek($89, soFromBeginning);
394 <                  DatFileStream.Read(tempb, 1);
395 <
396 <                  DatFileStream.Seek($90, soFromBeginning);
397 <                  DatFileStream.Read(tempb, 1);
398 <                  Exit;
399 <                end;
400 <              end else
401 <                OniImage.GetAsData(TStream(RawFileStream));
321 >              RawLinks[i].RawAddr := Stream_Sep.Size;
322 >              Stream_sep.CopyFrom(RawFileStream, RawFileStream.Size);
323              end else begin
324 <              Connection.LoadRawFile(FileID, RawLinks[i].SrcOffset, TStream(RawFileStream));
324 >              RawLinks[i].RawAddr := Stream_Raw.Size;
325 >              Stream_Raw.CopyFrom(RawFileStream, RawFileStream.Size);
326              end;
405            RawFileStream.Seek(0, soFromBeginning);
327            end else
328              RawLinks[i].RawAddr := 0;
329 +          DatFileStream.Seek(RawLinks[i].SrcOffset, soFromBeginning);
330 +          DatFileStream.Write(RawLinks[i].RawAddr, 4);
331          end;
332        end;
333 <
334 < {
412 <            if rawlist[j].raw_size > 0 then
413 <            begin
414 <              if (UpperCase(fileinfo.Extension) = 'TXMP') and
415 <                ((Data[$88] and $01) > 0) then
416 <              begin
417 <                OniImage.LoadFromTXMP(Connection, i);
418 <                OniImage.GetMipMappedImage(rawdata);
419 <                rawlist[j].raw_size := OniImage.GetImageDataSize(True);
420 <                Data[$90] := $08;
421 <                Data[$89] := 32;
422 < (*                  if data[$90]<>OniImage.StoreType then begin
423 <                    data[$90]:=OniImage.StoreType;
424 <                    data[$89]:=(data[$89] and $CF) or $20;
425 <                  end;
426 < *)                end
427 <              else
428 <              begin
429 <                SetLength(rawdata, rawlist[j].raw_size);
430 <                OniDataConnection.LoadRawFile(i, rawlist[j].src_offset, @rawdata[0]);
431 <              end;
432 <              //                data[$88]:=data[$88] and $FE;
433 <
434 <              if rawlist[j].loc_sep then
435 <              begin
436 <                rawlist[j].raw_addr := Stream_Sep.Size;
437 <                Stream_Sep.Write(rawdata[0], Length(rawdata));
438 <              end
439 <              else
440 <              begin
441 <                rawlist[j].raw_addr := Stream_Raw.Size;
442 <                Stream_Raw.Write(rawdata[0], Length(rawdata));
443 <              end;
444 <            end
445 <            else
446 <              rawlist[j].raw_addr := 0;
447 <            Data[rawlist[j].src_offset + 0] := (rawlist[j].raw_addr) and $FF;
448 <            Data[rawlist[j].src_offset + 1] := (rawlist[j].raw_addr shr 8) and $FF;
449 <            Data[rawlist[j].src_offset + 2] := (rawlist[j].raw_addr shr 16) and $FF;
450 <            Data[rawlist[j].src_offset + 3] := (rawlist[j].raw_addr shr 24) and $FF;
451 < }
452 <      Stream_Body.Write(Data[0], Length(Data));
453 <      //
333 >      DatFileStream.Seek(0, soFromBeginning);
334 >      Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size);
335      end
336      else
337        FilesHeader[i].DataAddr := 0;
# Line 465 | Line 346 | begin
346      FilesHeader[i].FileSize := fileinfo.Size;
347      FilesHeader[i].FileType := fileinfo.FileType;
348  
349 <    if ((i mod 10) = 0) and (i >= 100) then
349 >    if ((FileID mod 10) = 0) and (FileID >= 100) then
350        lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
351 <        (Time - FileTime) / i * (progress.Max - i + 1) * 1.1, TimeFormat );
352 <    progress.Position := i + 1;
353 <    lbl_progress.Caption := 'Files done: ' + IntToStr(i + 1) + '/' + IntToStr(progress.Max);
351 >        (Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, TimeFormat );
352 >    progress.Position := FileID + 1;
353 >    lbl_progress.Caption := 'Files done: ' + IntToStr(FileID + 1) + '/' + IntToStr(progress.Max);
354      Application.ProcessMessages;
355    end;
356  
# Line 497 | Line 378 | begin
378    Stream_Body.Free;
379    Stream_Names.Free;
380    Stream_Raw.Free;
381 <  if OniDataConnection.OSisMac then
381 >
382 >  if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
383      Stream_Sep.Free;
384  
385    progress.Position      := progress.Max;
# Line 513 | Line 395 | begin
395  
396    converting := False;
397  
398 <  CloseDataConnection(DataConnections[conIndex]);
398 > //  CloseDataConnection(DataConnections[conIndex]);
399   end;
400  
401  
# Line 523 | Line 405 | procedure TForm_LevelDB.HandleFile;
405   var
406    i: Byte;
407   begin
408 <  for i := 1 to Length(ConvertHandlers) do
408 > {  for i := 1 to Length(ConvertHandlers) do
409      if UpperCase(ConvertHandlers[i].Ext) = UpperCase(ext) then
410        if ConvertHandlers[i].needed then
411        begin
# Line 532 | Line 414 | begin
414        end
415        else
416          Break;
417 < end;
417 > }end;
418  
419  
420  
421  
422   procedure TForm_LevelDB.CreateDatabase(Source, target: String);
423 + {
424   var
425    DataBase:    TABSDatabase;
426    Query:       TABSQuery;
# Line 569 | Line 452 | const
452      else
453        group_progress.Caption := 'Creating DB (FINISHED)';
454    end;
455 + }
456  
457   begin
458 <  if CreateDataConnection(Source, ODB_Dat) = nil then
458 > {  if CreateDataConnection(Source, ODB_Dat) = nil then
459    begin
460      ShowMessage('Could not connect to .dat-file');
461      Exit;
# Line 774 | Line 658 | begin
658    database.Free;
659  
660    CloseDataConnection(DataConnections[conIndex]);
661 + }
662   end;
663  
664  
665  
666  
667 < procedure TForm_LevelDB.stop_convert;
667 > procedure TForm_LevelDB.StopConvert;
668   begin
669 <  btn_abortok.Caption := '&Close';
669 > {  btn_abortok.Caption := '&Close';
670    btn_abortok.Default := True;
671    converting := False;
672    lbl_estimation.Caption := 'ABORTED';
# Line 792 | Line 677 | begin
677    begin
678      DeleteFile(loaded_filename);
679    end;
680 < end;
680 > }end;
681  
682  
683  
# Line 815 | Line 700 | end;
700  
701  
702  
703 <
703 > {
704   procedure InsertDatLinkToDB(fileid: LongWord; offset: LongWord);
705   var
706    link: LongWord;
# Line 1847 | Line 1732 | begin
1732    begin
1733    end;
1734   end;
1735 + }
1736  
1737  
1738 <
1853 <
1738 > {
1739   procedure InsertHandler(ext: String; needed: Boolean; handler: THandler);
1740   begin
1741    SetLength(ConvertHandlers, Length(ConvertHandlers) + 1);
# Line 1858 | Line 1743 | begin
1743    ConvertHandlers[High(ConvertHandlers)].needed  := needed;
1744    ConvertHandlers[High(ConvertHandlers)].handler := handler;
1745   end;
1746 <
1746 > }
1747   begin
1748 <  InsertHandler('ABNA', False, nil);
1748 > {  InsertHandler('ABNA', False, nil);
1749    //  InsertHandler('AGDB',True,AGDB);
1750    InsertHandler('AGDB', False, nil);
1751    InsertHandler('AGQC', False, nil);
# Line 1958 | Line 1843 | begin
1843    InsertHandler('WMM_', False, nil);
1844    InsertHandler('WMMB', True, WMMB);
1845    InsertHandler('WPGE', True, WPGE);
1846 < end.
1846 > }end.

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)