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 113 by alloc, Sun Feb 25 17:20:22 2007 UTC vs.
Revision 129 by alloc, Wed Mar 28 01:12:22 2007 UTC

# Line 78 | Line 78 | var
78    Connection: TDataAccess;
79    ConRepMsg:  TStatusMessages;
80  
81 +  FileID:     Integer;
82 +
83    Strings:    TStrings;
84    i, j:       Integer;
85    temps:      String;
86 +  tempi:      Integer;
87 +  tempb:      Byte;
88    FileInfo:   TFileInfo;
89 +  DatLinks:   TDatLinkList;
90 +  RawLinks:   TRawDataList;
91  
92    DatFileStream, RawFileStream: TMemoryStream;
93   const
# Line 270 | Line 276 | begin
276    Application.ProcessMessages;
277  
278    FileTime := Time;
279 <  for i := 0 to DatHeader.Files - 1 do
279 >  for FileID := 0 to DatHeader.Files - 1 do
280    begin
281 <    FileInfo := Connection.GetFileInfo(i);
281 >    FileInfo := Connection.GetFileInfo(FileID);
282      for j := 0 to 3 do
283 <      FilesHeader[i].Extension[j] := FileInfo.Extension[4 - j];
283 >      FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j];
284      if FileInfo.Size > 0 then
285      begin
286 <      //        DatLinks:=;
281 <      FilesHeader[i].DataAddr := Stream_Body.Size + 8;
286 >      FilesHeader[FileID].DataAddr := Stream_Body.Size + 8;
287        DatFileStream := TMemoryStream.Create;
288 <      Connection.LoadDatFile(i, DatFileStream);
288 >      Connection.LoadDatFile(FileID, TStream(DatFileStream));
289        DatFileStream.Seek(4, soFromBeginning);
290        DatFileStream.Write(LevelID, 4);
291  
292 <      if (Pos(UpperCase(fileinfo.Extension), UpperCase(raws)) mod 4) = 1 then
292 >      DatLinks := Connection.GetDatLinks(FileID);
293 >      if Length(DatLinks) > 0 then
294        begin
295 <        rawlist := OniDataConnection.GetRawList(i);
290 <        if Length(rawlist) > 0 then
295 >        for i := 0 to High(DatLinks) do
296          begin
297 <          for j := 0 to High(rawlist) do
297 >          DatFileStream.Seek(DatLinks[i].SrcOffset, soFromBeginning);
298 >          if DatLinks[i].DestID < 0 then
299 >            tempi := 0
300 >          else
301 >            tempi := DatLinks[i].DestID * 256 + 1;
302 >          DatFileStream.Write(tempi, 4);
303 >        end;
304 >      end;
305 >
306 >      RawLinks := Connection.GetRawList(FileID);
307 >      if Length(RawLinks) > 0 then
308 >      begin
309 >        for i := 0 to High(RawLinks) do
310 >        begin
311 >          if RawLinks[i].RawSize > 0 then
312            begin
313 <            if rawlist[j].raw_size > 0 then
313 >            RawFileStream := TMemoryStream.Create;
314 >            Connection.LoadRawFile(FileID, RawLinks[i].SrcOffset, TStream(RawFileStream));
315 >            RawFileStream.Seek(0, soFromBeginning);
316 >            if RawLinks[i].LocSep then
317              begin
318 <              if (UpperCase(fileinfo.Extension) = 'TXMP') and
319 <                ((Data[$88] and $01) > 0) then
320 <              begin
321 <                OniImage.LoadFromTXMP(Connection, i);
322 <                OniImage.GetMipMappedImage(rawdata);
323 <                rawlist[j].raw_size := OniImage.GetImageDataSize(True);
324 <                Data[$90] := $08;
325 <                Data[$89] := 32;
326 < {                  if data[$90]<>OniImage.StoreType then begin
327 <                    data[$90]:=OniImage.StoreType;
306 <                    data[$89]:=(data[$89] and $CF) or $20;
307 <                  end;
308 < }                end
309 <              else
310 <              begin
311 <                SetLength(rawdata, rawlist[j].raw_size);
312 <                OniDataConnection.LoadRawFile(i, rawlist[j].src_offset, @rawdata[0]);
313 <              end;
314 <              //                data[$88]:=data[$88] and $FE;
315 <
316 <              if rawlist[j].loc_sep then
317 <              begin
318 <                rawlist[j].raw_addr := Stream_Sep.Size;
319 <                Stream_Sep.Write(rawdata[0], Length(rawdata));
320 <              end
321 <              else
322 <              begin
323 <                rawlist[j].raw_addr := Stream_Raw.Size;
324 <                Stream_Raw.Write(rawdata[0], Length(rawdata));
325 <              end;
326 <            end
327 <            else
328 <              rawlist[j].raw_addr := 0;
329 <            Data[rawlist[j].src_offset + 0] := (rawlist[j].raw_addr) and $FF;
330 <            Data[rawlist[j].src_offset + 1] := (rawlist[j].raw_addr shr 8) and $FF;
331 <            Data[rawlist[j].src_offset + 2] := (rawlist[j].raw_addr shr 16) and $FF;
332 <            Data[rawlist[j].src_offset + 3] := (rawlist[j].raw_addr shr 24) and $FF;
333 <          end;
318 >              RawLinks[i].RawAddr := Stream_Sep.Size;
319 >              Stream_sep.CopyFrom(RawFileStream, RawFileStream.Size);
320 >            end else begin
321 >              RawLinks[i].RawAddr := Stream_Raw.Size;
322 >              Stream_Raw.CopyFrom(RawFileStream, RawFileStream.Size);
323 >            end;
324 >          end else
325 >            RawLinks[i].RawAddr := 0;
326 >          DatFileStream.Seek(RawLinks[i].SrcOffset, soFromBeginning);
327 >          DatFileStream.Write(RawLinks[i].RawAddr, 4);
328          end;
329        end;
330 <
331 <      Stream_Body.Write(Data[0], Length(Data));
338 <      //
330 >      DatFileStream.Seek(0, soFromBeginning);
331 >      Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size);
332      end
333      else
334        FilesHeader[i].DataAddr := 0;
# Line 382 | Line 375 | begin
375    Stream_Body.Free;
376    Stream_Names.Free;
377    Stream_Raw.Free;
378 <  if OniDataConnection.OSisMac then
378 >
379 >  if Connection.DataOS in [DOS_WINDEMO, DOS_MAC, DOS_MACBETA] then
380      Stream_Sep.Free;
381  
382    progress.Position      := progress.Max;
# Line 398 | Line 392 | begin
392  
393    converting := False;
394  
395 <  CloseDataConnection(DataConnections[conIndex]);
395 > //  CloseDataConnection(DataConnections[conIndex]);
396   end;
397  
398  
# Line 408 | Line 402 | procedure TForm_LevelDB.HandleFile;
402   var
403    i: Byte;
404   begin
405 <  for i := 1 to Length(ConvertHandlers) do
405 > {  for i := 1 to Length(ConvertHandlers) do
406      if UpperCase(ConvertHandlers[i].Ext) = UpperCase(ext) then
407        if ConvertHandlers[i].needed then
408        begin
# Line 417 | Line 411 | begin
411        end
412        else
413          Break;
414 < end;
414 > }end;
415  
416  
417  
418  
419   procedure TForm_LevelDB.CreateDatabase(Source, target: String);
420 + {
421   var
422    DataBase:    TABSDatabase;
423    Query:       TABSQuery;
# Line 454 | Line 449 | const
449      else
450        group_progress.Caption := 'Creating DB (FINISHED)';
451    end;
452 + }
453  
454   begin
455 <  if CreateDataConnection(Source, ODB_Dat) = nil then
455 > {  if CreateDataConnection(Source, ODB_Dat) = nil then
456    begin
457      ShowMessage('Could not connect to .dat-file');
458      Exit;
# Line 659 | Line 655 | begin
655    database.Free;
656  
657    CloseDataConnection(DataConnections[conIndex]);
658 + }
659   end;
660  
661  
662  
663  
664 < procedure TForm_LevelDB.stop_convert;
664 > procedure TForm_LevelDB.StopConvert;
665   begin
666 <  btn_abortok.Caption := '&Close';
666 > {  btn_abortok.Caption := '&Close';
667    btn_abortok.Default := True;
668    converting := False;
669    lbl_estimation.Caption := 'ABORTED';
# Line 677 | Line 674 | begin
674    begin
675      DeleteFile(loaded_filename);
676    end;
677 < end;
677 > }end;
678  
679  
680  
# Line 700 | Line 697 | end;
697  
698  
699  
700 <
700 > {
701   procedure InsertDatLinkToDB(fileid: LongWord; offset: LongWord);
702   var
703    link: LongWord;
# Line 1732 | Line 1729 | begin
1729    begin
1730    end;
1731   end;
1732 + }
1733  
1734  
1735 <
1738 <
1735 > {
1736   procedure InsertHandler(ext: String; needed: Boolean; handler: THandler);
1737   begin
1738    SetLength(ConvertHandlers, Length(ConvertHandlers) + 1);
# Line 1743 | Line 1740 | begin
1740    ConvertHandlers[High(ConvertHandlers)].needed  := needed;
1741    ConvertHandlers[High(ConvertHandlers)].handler := handler;
1742   end;
1743 <
1743 > }
1744   begin
1745 <  InsertHandler('ABNA', False, nil);
1745 > {  InsertHandler('ABNA', False, nil);
1746    //  InsertHandler('AGDB',True,AGDB);
1747    InsertHandler('AGDB', False, nil);
1748    InsertHandler('AGQC', False, nil);
# Line 1843 | Line 1840 | begin
1840    InsertHandler('WMM_', False, nil);
1841    InsertHandler('WMMB', True, WMMB);
1842    InsertHandler('WPGE', True, WPGE);
1843 < end.
1843 > }end.

Diff Legend

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