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

Comparing oup/current/DataAccess/Access_OniArchive.pas (file contents):
Revision 112 by alloc, Thu Feb 22 00:37:39 2007 UTC vs.
Revision 116 by alloc, Mon Feb 26 22:57:02 2007 UTC

# Line 33 | Line 33 | type
33      procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream); overload; override;
34      procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; override;
35  
36 +    function GetDatLinks(FileID: Integer): TDatLinkList; override;
37 +    function GetDatLink(FileID, DatOffset: Integer): TDatLink; override;
38      function GetRawList(FileID: Integer): TRawDataList; override;
39      function GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo; override;
40  
# Line 49 | Line 51 | type
51   implementation
52  
53   uses
54 <  SysUtils, StrUtils, Data, Functions, RawList;
54 >  SysUtils, StrUtils, Data, Functions, RawList, DatLinks;
55  
56  
57   (*
# Line 59 | Line 61 | uses
61  
62  
63   constructor TAccess_OniArchive.Create(DatFilename: String; ConnectionID: Integer; var Msg: TStatusMessages);
62 const
63  header_ident1_pc: array[0..$13] of Byte =
64    ($1F, $27, $DC, $33, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
65    $14, $00, $10, $00, $08, $00);
66  header_ident1_mac: array[0..$13] of Byte =
67    ($61, $30, $C1, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
68    $14, $00, $10, $00, $08, $00);
69  header_ident1_macbeta: array[0..$13] of Byte =
70    ($81, $11, $8D, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
71    $14, $00, $10, $00, $08, $00);
72  header_ident2: array[0..$F] of Byte =
73    ($99, $CF, $40, $00, $90, $4F, $63, $00, $F4, $55, $5F, $00, $90, $4F, $63, $00);
64   var
65    i: Integer;
66    header_pc, header_mac, header_macbeta: Boolean;
# Line 93 | Line 83 | begin
83    header_pc  := True;
84    header_mac := True;
85    header_macbeta := True;
86 <  for i := 0 to High(Fdat_header.Ident) do
86 >  for i := 0 to High(Fdat_header.GlobalIdent) do
87 >    if Fdat_header.GlobalIdent[i] <> HeaderGlobalIdent[i] then
88 >    begin
89 >      Msg := SM_IncompatibleFile;
90 >      Exit;
91 >    end;
92 >
93 >  for i := 0 to High(Fdat_header.OSIdent) do
94    begin
95 < //    FLevelInfo.Ident[i] := Fdat_header.Ident[i];
99 <    if Fdat_header.Ident[i] <> header_ident1_pc[i] then
95 >    if Fdat_header.OSIdent[i] <> HeaderOSIdentWin[i] then
96        header_pc := False;
97 <    if Fdat_header.Ident[i] <> header_ident1_mac[i] then
97 >    if Fdat_header.OSIdent[i] <> HeaderOSIdentMac[i] then
98        header_mac := False;
99 <    if Fdat_header.Ident[i] <> header_ident1_macbeta[i] then
99 >    if Fdat_header.OSIdent[i] <> HeaderOSIdentMacBeta[i] then
100        header_macbeta := False;
101    end;
102    if not (header_pc xor header_mac xor header_macbeta) then
# Line 258 | Line 254 | begin
254        end;
255      end;
256    end;
257 <  Result := TStringList.Create;
257 >  if not Assigned(Result) then
258 >    Result := TStringList.Create;
259    if list.Count > 0 then
260    begin
261      fields := TStringList.Create;
# Line 294 | Line 291 | function TAccess_OniArchive.GetExtension
291   var
292    i: Integer;
293   begin
294 <  Result := TStringList.Create;
294 >  if not Assigned(Result) then
295 >    Result := TStringList.Create;
296 >  if Result is TStringList then
297 >    TStringList(Result).Sorted := True;
298    for i := 0 to Length(Fdat_extensionsmap) - 1 do
299    begin
300      with Fdat_extensionsmap[i] do
# Line 398 | Line 398 | end;
398  
399  
400  
401 + function TAccess_OniArchive.GetDatLink(FileID, DatOffset: Integer): TDatLink;
402 + var
403 +  link: Integer;
404 + begin
405 +  Result := DatLinksManager.GetDatLink(FConnectionID, FileID, DatOffset);
406 +  LoadDatFilePart(fileid, Result.SrcOffset, 4, @link);
407 +  if link > 0 then
408 +    Result.DestID := link div 256
409 +  else
410 +    Result.DestID := -1;
411 + end;
412 +
413 +
414 + function TAccess_OniArchive.GetDatLinks(FileID: Integer): TDatLinkList;
415 + var
416 +  i: Integer;
417 +  link: Integer;
418 + begin
419 +  Result := DatLinksManager.GetDatLinks(FConnectionID, FileID);
420 +  if Length(Result) > 0 then
421 +  begin
422 +    for i := 0 to High(Result) do
423 +    begin
424 +      LoadDatFilePart(fileid, Result[i].SrcOffset, 4, @link);
425 +      if link > 0 then
426 +        Result[i].DestID := link div 256
427 +      else
428 +        Result[i].DestID := -1;
429 +    end;
430 +  end;
431 + end;
432 +
433 +
434   function TAccess_OniArchive.GetRawList(FileID: Integer): TRawDataList;
435   begin
436    Result := RawLists.GetRawList(FConnectionID, FileID);

Diff Legend

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