Changeset 113 for oup/current/Helper


Ignore:
Timestamp:
Feb 25, 2007, 6:20:22 PM (18 years ago)
Author:
alloc
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Helper/LevelDB.pas

    r112 r113  
    11unit LevelDB;
    2 
    32interface
    4 
    53uses
    64  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
     
    2826
    2927implementation
    30 
    3128{$R *.dfm}
    32 
    3329uses ABSMain, ABSDecUtil, Main,
    34     ConnectionManager, TypeDefs, DataAccess, OniImgClass;
     30    ConnectionManager, TypeDefs, DataAccess, OniImgClass, Data;
    3531
    3632type
     
    7066  Stream_Dat, Stream_Raw, Stream_Sep: TFileStream;
    7167
    72 //  FileCount: Integer;
    73 //  temps, temps2: String;
    7468//  Data, rawdata: Tdata;
    7569  BeginTime, FileTime: Double;
    7670  Step:     Integer;
    7771//  rawlist:  TRawDataList;
    78 //  extlist:  TExtensionsMap;
    79 //  fileinfo: TFileInfo;
    8072//  datlinks: TDatLinks;
    8173  OniImage:   TOniImage;
     
    8981  Strings:    TStrings;
    9082  i, j:       Integer;
     83  temps:      String;
     84  FileInfo:   TFileInfo;
     85
     86  DatFileStream, RawFileStream: TMemoryStream;
    9187const
    9288  Steps: Byte = 3;
     
    209205  end;
    210206
    211  
    212   extlist := OniDataConnection.GetExtendedExtensionsList;
    213   for i := 0 to High(DatHeader.Ident) do
    214     DatHeader.Ident[i] := OniDataConnection.LevelInfo.Ident[i];
    215   DatHeader.Files := OniDataConnection.GetFilesCount;
     207  for i := 0 to High(DatHeader.OSIdent) do
     208    case Connection.DataOS of
     209      DOS_WIN: DatHeader.OSIdent[i] := HeaderOSIdentWin[i];
     210      DOS_MAC: DatHeader.OSIdent[i] := HeaderOSIdentMac[i];
     211      DOS_MACBETA: DatHeader.OSIdent[i] := HeaderOSIdentMacBeta[i];
     212    end;
     213  for i := 0 to High(DatHeader.GlobalIdent) do
     214    DatHeader.GlobalIdent[i] := HeaderGlobalIdent[i];
     215  DatHeader.Files := Connection.GetFileCount;
    216216  DatHeader.NamedFiles := Length(NamedFilesHeader);
    217   DatHeader.Extensions := Length(extlist);
     217
     218  Strings := Connection.GetExtensionsList(EF_ExtCount);
     219
     220  DatHeader.Extensions := Strings.Count;
    218221  DatHeader.DataAddr   := 0;
    219222  DatHeader.DataSize   := 0;
     
    227230
    228231  DoStep('Writing extensions-header');
    229   progress.Max := Length(OniDataConnection.GetExtensionsList);
     232  progress.Max := Strings.Count;
    230233  Application.ProcessMessages;
    231 
    232   for i := 0 to High(ExtensionsHeader) do
    233   begin
    234     ExtensionsHeader[i].Ident     := extlist[i].Ident;
    235     ExtensionsHeader[i].Extension := extlist[i].Extension;
    236     SetLength(temps, 4);
     234  for i := 0 to Strings.Count - 1 do
     235  begin
     236    temps := Strings.Strings[i];
     237    ExtensionsHeader[i].ExtCount := StrToInt( MidStr(
     238            temps,
     239            Pos('(', temps) + 1,
     240            Pos(')', temps) - Pos('(', temps) - 1 ) );
     241    temps := MidStr(temps, 1, 4);
    237242    for j := 0 to 3 do
    238       temps[j + 1] := ExtensionsHeader[i].Extension[3 - j];
    239     ExtensionsHeader[i].ExtCount :=
    240       Length(OniDataConnection.GetFilesList(temps, '', False, stIDAsc));
     243      ExtensionsHeader[i].Extension[j] := temps[4-j];
     244    for j := 0 to High(FileTypes) do
     245      if FileTypes[j].Extension = temps then
     246        Break;
     247    if j < Length(FileTypes) then
     248    begin
     249      case Connection.DataOS of
     250        DOS_WIN:     ExtensionsHeader[i].Ident := FileTypes[j].IdentWin;
     251        DOS_WINDEMO: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
     252        DOS_MAC:     ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
     253        DOS_MACBETA: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac;
     254      end;
     255    end else begin
     256      ShowMessage('Unknown Extension: ' + Strings.Strings[i]);
     257      Exit;
     258    end;
    241259    progress.Position    := i + 1;
    242260    lbl_progress.Caption := 'Extensions done: ' + IntToStr(i + 1) + '/' +
    243       IntToStr(Length(extlist));
     261      IntToStr(Strings.Count);
    244262    Application.ProcessMessages;
    245263  end;
    246 
    247264
    248265  DoStep('Storing files-data');
     
    253270  Application.ProcessMessages;
    254271
    255   begintime := Time;
     272  FileTime := Time;
    256273  for i := 0 to DatHeader.Files - 1 do
    257274  begin
    258     fileinfo := OniDataConnection.GetFileInfo(i);
     275    FileInfo := Connection.GetFileInfo(i);
    259276    for j := 0 to 3 do
    260       FilesHeader[i].Extension[j] := fileinfo.Extension[4 - j];
    261     if fileinfo.Size > 0 then
     277      FilesHeader[i].Extension[j] := FileInfo.Extension[4 - j];
     278    if FileInfo.Size > 0 then
    262279    begin
    263280      //        DatLinks:=;
    264281      FilesHeader[i].DataAddr := Stream_Body.Size + 8;
    265       Data    := OniDataConnection.LoadDatFile(i);
    266       Data[4] := (levelid) and $FF;
    267       Data[5] := (levelid shr 8) and $FF;
    268       Data[6] := (levelid shr 16) and $FF;
    269       Data[7] := (levelid shr 24) and $FF;
     282      DatFileStream := TMemoryStream.Create;
     283      Connection.LoadDatFile(i, DatFileStream);
     284      DatFileStream.Seek(4, soFromBeginning);
     285      DatFileStream.Write(LevelID, 4);
    270286
    271287      if (Pos(UpperCase(fileinfo.Extension), UpperCase(raws)) mod 4) = 1 then
     
    337353    if ((i mod 10) = 0) and (i >= 100) then
    338354      lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
    339         (Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat );
     355        (Time - FileTime) / i * (progress.Max - i + 1) * 1.1, TimeFormat );
    340356    progress.Position := i + 1;
    341357    lbl_progress.Caption := 'Files done: ' + IntToStr(i + 1) + '/' + IntToStr(progress.Max);
     
    373389  lbl_progress.Caption   := 'Files done: ' + IntToStr(progress.Max) + '/' +
    374390    IntToStr(progress.Max);
    375   lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')';
     391  lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - Begintime, TimeFormat) + ')';
    376392
    377393  DoStep('FIN');
Note: See TracChangeset for help on using the changeset viewer.