Changeset 87 for oup/current/Code


Ignore:
Timestamp:
Jan 14, 2007, 11:59:34 PM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/current/Code
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Code/DataStructures.pas

    r46 r87  
    33interface
    44
    5 uses SysUtils, Classes, Data, Dialogs, StrUtils;
     5uses SysUtils, Classes, Data, Dialogs, StrUtils, OniDataClass;
    66
    77type
     
    3434    Subs:   array of TStructDefSub;
    3535  end;
    36   THandler = function(fileid: LongWord): TRawList;
     36  THandler = function(connection: TOniData; fileid: LongWord): TRawList;
    3737
    3838  TRawListHandlers = record
     
    4747
    4848
    49 function LoadStructureDefinition(fileid: LongWord): TStructDef;
     49function LoadStructureDefinition(connection: TOniData; fileid: LongWord): TStructDef;
    5050function GetDataType(typeid: Word): String;
    5151function GetTypeDataLength(datatype: Word): Word;
     
    5353implementation
    5454
    55 uses Functions, OniDataClass, Forms, Template;
     55uses Functions, Forms, Template;
    5656
    5757
     
    120120
    121121
    122 function AGDB(fileid: LongWord): TRawList;
     122function AGDB(connection: TOniData; fileid: LongWord): TRawList;
    123123var
    124124  link:  LongWord;
     
    126126  i:     LongWord;
    127127begin
    128   if not OniDataConnection.OSisMac then
    129   begin
    130     OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
     128  if not connection.OSisMac then
     129  begin
     130    connection.LoadDatFilePart(fileid, $1C, 4, @links);
    131131    links := links * 2;
    132132    SetLength(Result, links);
     
    134134    begin
    135135      Result[i].src_offset := $20 + i * 4;
    136       OniDataConnection.LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
     136      connection.LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
    137137      Result[i].raw_addr := link;
    138138      Result[i].raw_size := 0{????????????????????????????????};
     
    145145
    146146
    147 function AKVA(fileid: LongWord): TRawList;
     147function AKVA(connection: TOniData; fileid: LongWord): TRawList;
    148148var
    149149  link:  LongWord;
     
    151151  i:     LongWord;
    152152begin
    153   if not OniDataConnection.OSisMac then
    154   begin
    155     OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
     153  if not connection.OSisMac then
     154  begin
     155    connection.LoadDatFilePart(fileid, $1C, 4, @links);
    156156    SetLength(Result, links);
    157157    for i := 0 to links - 1 do
    158158    begin
    159159      Result[i].src_offset := $20 + i * $74 + $24;
    160       OniDataConnection.LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link);
     160      connection.LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link);
    161161      Result[i].raw_addr := link;
    162       OniDataConnection.LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link);
     162      connection.LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link);
    163163      Result[i].raw_size := link;
    164164      Result[i].loc_sep  := False;
     
    170170
    171171
    172 function BINA(fileid: LongWord): TRawList;
     172function BINA(connection: TOniData; fileid: LongWord): TRawList;
    173173var
    174174  link:     LongWord;
    175175  datasize: LongWord;
    176176begin
    177   OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);
    178   OniDataConnection.LoadDatFilePart(fileid, $08, 4, @datasize);
     177  connection.LoadDatFilePart(fileid, $0C, 4, @link);
     178  connection.LoadDatFilePart(fileid, $08, 4, @datasize);
     179  SetLength(Result, 1);
     180  Result[0].src_offset := $0C;
     181  Result[0].raw_addr   := link;
     182  Result[0].raw_size   := datasize;
     183  Result[0].loc_sep    := connection.OSisMac;
     184end;
     185
     186
     187
     188
     189function OSBD(connection: TOniData; fileid: LongWord): TRawList;
     190var
     191  link:     LongWord;
     192  datasize: LongWord;
     193begin
     194  connection.LoadDatFilePart(fileid, $08, 4, @datasize);
     195  connection.LoadDatFilePart(fileid, $0C, 4, @link);
    179196  SetLength(Result, 1);
    180197  Result[0].src_offset := $0C;
     
    187204
    188205
    189 function OSBD(fileid: LongWord): TRawList;
     206function SNDD(connection: TOniData; fileid: LongWord): TRawList;
    190207var
    191208  link:     LongWord;
    192209  datasize: LongWord;
    193210begin
    194   OniDataConnection.LoadDatFilePart(fileid, $08, 4, @datasize);
    195   OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);
    196211  SetLength(Result, 1);
    197   Result[0].src_offset := $0C;
    198   Result[0].raw_addr   := link;
    199   Result[0].raw_size   := datasize;
    200   Result[0].loc_sep    := OniDataConnection.OSisMac;
    201 end;
    202 
    203 
    204 
    205 
    206 function SNDD(fileid: LongWord): TRawList;
    207 var
    208   link:     LongWord;
    209   datasize: LongWord;
    210 begin
    211   SetLength(Result, 1);
    212   if not OniDataConnection.OSisMac then
    213   begin
    214     OniDataConnection.LoadDatFilePart(fileid, $40, 4, @datasize);
    215     OniDataConnection.LoadDatFilePart(fileid, $44, 4, @link);
     212  if not connection.OSisMac then
     213  begin
     214    connection.LoadDatFilePart(fileid, $40, 4, @datasize);
     215    connection.LoadDatFilePart(fileid, $44, 4, @link);
    216216    Result[0].src_offset := $44;
    217217  end
    218218  else
    219219  begin
    220     OniDataConnection.LoadDatFilePart(fileid, $10, 4, @datasize);
    221     OniDataConnection.LoadDatFilePart(fileid, $14, 4, @link);
     220    connection.LoadDatFilePart(fileid, $10, 4, @datasize);
     221    connection.LoadDatFilePart(fileid, $14, 4, @link);
    222222    Result[0].src_offset := $14;
    223223  end;
     
    230230
    231231
    232 function SUBT(fileid: LongWord): TRawList;
     232function SUBT(connection: TOniData; fileid: LongWord): TRawList;
    233233var
    234234  baselink, lastlink: LongWord;
     
    237237  Data:  Tdata;
    238238begin
    239   OniDataConnection.LoadDatFilePart(fileid, $18, 4, @baselink);
    240   OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
     239  connection.LoadDatFilePart(fileid, $18, 4, @baselink);
     240  connection.LoadDatFilePart(fileid, $1C, 4, @links);
    241241  if links > 0 then
    242242  begin
    243     OniDataConnection.LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
     243    connection.LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
    244244    SetLength(Data, lastlink + 1024);
    245     TOniDataDat(OniDataConnection).LoadRawOffset(False,
     245    TOniDataDat(connection).LoadRawOffset(False,
    246246      baselink, lastlink + 1024, Data);
    247247    //      OniDataConnection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
     
    274274
    275275
    276 function TRAM(fileid: LongWord): TRawList;
     276function TRAM(connection: TOniData; fileid: LongWord): TRawList;
    277277var
    278278  i:      Integer;
     
    287287begin
    288288  SetLength(Result, 13);
    289   OniDataConnection.LoadDatFilePart(fileid, $16C, 2, @frames);
     289  connection.LoadDatFilePart(fileid, $16C, 2, @frames);
    290290  {y-pos}
    291   OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);
     291  connection.LoadDatFilePart(fileid, $0C, 4, @link);
    292292  Result[0].src_offset := $0C;
    293293  Result[0].raw_addr   := link;
    294294  Result[0].raw_size   := frames * 4;
    295295  {x-z-pos}
    296   OniDataConnection.LoadDatFilePart(fileid, $10, 4, @link);
     296  connection.LoadDatFilePart(fileid, $10, 4, @link);
    297297  Result[1].src_offset := $10;
    298298  Result[1].raw_addr   := link;
    299299  Result[1].raw_size   := frames * 8;
    300300  {attacks}
    301   OniDataConnection.LoadDatFilePart(fileid, $182, 1, @tempb);
    302   OniDataConnection.LoadDatFilePart(fileid, $14, 4, @link);
     301  connection.LoadDatFilePart(fileid, $182, 1, @tempb);
     302  connection.LoadDatFilePart(fileid, $14, 4, @link);
    303303  Result[2].src_offset := $14;
    304304  Result[2].raw_addr   := link;
    305305  Result[2].raw_size   := tempb * 32;
    306306  {damage}
    307   OniDataConnection.LoadDatFilePart(fileid, $183, 1, @tempb);
    308   OniDataConnection.LoadDatFilePart(fileid, $18, 4, @link);
     307  connection.LoadDatFilePart(fileid, $183, 1, @tempb);
     308  connection.LoadDatFilePart(fileid, $18, 4, @link);
    309309  Result[3].src_offset := $18;
    310310  Result[3].raw_addr   := link;
    311311  Result[3].raw_size   := tempb * 8;
    312312  {motionblur}
    313   OniDataConnection.LoadDatFilePart(fileid, $184, 1, @tempb);
    314   OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @link);
     313  connection.LoadDatFilePart(fileid, $184, 1, @tempb);
     314  connection.LoadDatFilePart(fileid, $1C, 4, @link);
    315315  Result[4].src_offset := $1C;
    316316  Result[4].raw_addr   := link;
    317317  Result[4].raw_size   := tempb * 8;
    318318  {shortcut}
    319   OniDataConnection.LoadDatFilePart(fileid, $185, 1, @tempb);
    320   OniDataConnection.LoadDatFilePart(fileid, $20, 4, @link);
     319  connection.LoadDatFilePart(fileid, $185, 1, @tempb);
     320  connection.LoadDatFilePart(fileid, $20, 4, @link);
    321321  Result[5].src_offset := $20;
    322322  Result[5].raw_addr   := link;
    323323  Result[5].raw_size   := tempb * 8;
    324324  {throw}
    325   OniDataConnection.LoadDatFilePart(fileid, $24, 4, @link);
     325  connection.LoadDatFilePart(fileid, $24, 4, @link);
    326326  Result[6].src_offset := $24;
    327327  Result[6].raw_addr   := link;
     
    331331    Result[6].raw_size := 0;
    332332  {footstep}
    333   OniDataConnection.LoadDatFilePart(fileid, $186, 1, @tempb);
    334   OniDataConnection.LoadDatFilePart(fileid, $28, 4, @link);
     333  connection.LoadDatFilePart(fileid, $186, 1, @tempb);
     334  connection.LoadDatFilePart(fileid, $28, 4, @link);
    335335  Result[7].src_offset := $28;
    336336  Result[7].raw_addr   := link;
    337337  Result[7].raw_size   := tempb * 4;
    338338  {particle}
    339   OniDataConnection.LoadDatFilePart(fileid, $187, 1, @tempb);
    340   OniDataConnection.LoadDatFilePart(fileid, $2C, 4, @link);
     339  connection.LoadDatFilePart(fileid, $187, 1, @tempb);
     340  connection.LoadDatFilePart(fileid, $2C, 4, @link);
    341341  Result[8].src_offset := $2C;
    342342  Result[8].raw_addr   := link;
    343343  Result[8].raw_size   := tempb * 24;
    344344  {position}
    345   OniDataConnection.LoadDatFilePart(fileid, $30, 4, @link);
     345  connection.LoadDatFilePart(fileid, $30, 4, @link);
    346346  Result[9].src_offset := $30;
    347347  Result[9].raw_addr   := link;
    348348  Result[9].raw_size   := frames * 8;
    349349  {particle}
    350   OniDataConnection.LoadDatFilePart(fileid, $154, 2, @tempw);
    351   OniDataConnection.LoadDatFilePart(fileid, $38, 4, @link);
     350  connection.LoadDatFilePart(fileid, $154, 2, @tempw);
     351  connection.LoadDatFilePart(fileid, $38, 4, @link);
    352352  Result[11].src_offset := $38;
    353353  Result[11].raw_addr   := link;
    354354  Result[11].raw_size   := tempw * 34;
    355355  {extent}
    356   OniDataConnection.LoadDatFilePart(fileid, $138, 4, @templ);
    357   OniDataConnection.LoadDatFilePart(fileid, $13C, 4, @link);
     356  connection.LoadDatFilePart(fileid, $138, 4, @templ);
     357  connection.LoadDatFilePart(fileid, $13C, 4, @link);
    358358  Result[12].src_offset := $13C;
    359359  Result[12].raw_addr   := link;
    360360  Result[12].raw_size   := templ * 12;
    361361
    362   OniDataConnection.LoadDatFilePart(fileid, $34, 4, @link);
     362  connection.LoadDatFilePart(fileid, $34, 4, @link);
    363363  if link > 0 then
    364364  begin
    365     OniDataConnection.LoadDatFilePart(fileid, $160, 2, @tempw);
     365    connection.LoadDatFilePart(fileid, $160, 2, @tempw);
    366366    frame_count := 0;
    367367    i := 0;
    368368    SetLength(Data, $FFFF);
    369     TOniDataDat(OniDataConnection).LoadRawOffset(False, link, $FFFF, Data);
     369    TOniDataDat(connection).LoadRawOffset(False, link, $FFFF, Data);
    370370    offset := Data[$24] + Data[$25] * 256;
    371371    while (offset + i < Length(Data)) and (frame_count < frames - 1) do
     
    392392
    393393
    394 function TXMP(fileid: LongWord): TRawList;
     394function TXMP(connection: TOniData; fileid: LongWord): TRawList;
    395395var
    396396  link_pc:   LongWord;
     
    400400  datasize:  LongWord;
    401401begin
    402   OniDataConnection.LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
    403   OniDataConnection.LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
    404   OniDataConnection.LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
    405   OniDataConnection.LoadDatFilePart(fileid, $9C, 4, @link_pc);
    406   OniDataConnection.LoadDatFilePart(fileid, $A0, 4, @link_mac);
     402  connection.LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
     403  connection.LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
     404  connection.LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
     405  connection.LoadDatFilePart(fileid, $9C, 4, @link_pc);
     406  connection.LoadDatFilePart(fileid, $A0, 4, @link_mac);
    407407  case storetype of
    408408    0, 1, 2:
     
    414414  end;
    415415  SetLength(Result, 1);
    416   if not OniDataConnection.OSisMac then
     416  if not connection.OSisMac then
    417417  begin
    418418    Result[0].src_offset := $9C;
     
    425425  end;
    426426  Result[0].raw_size := datasize;
    427   Result[0].loc_sep  := OniDataConnection.OSisMac;
     427  Result[0].loc_sep  := connection.OSisMac;
    428428end;
    429429
     
    444444
    445445
    446 function LoadStructureDefinition(fileid: LongWord): TStructDef;
     446function LoadStructureDefinition(connection: TOniData; fileid: LongWord): TStructDef;
    447447var
    448448  i:      LongWord;
     
    461461  SetLength(Result.Subs, 0);
    462462  Result.Data := False;
    463   ext      := OniDataConnection.GetFileInfo(fileid).Extension;
     463  ext      := connection.GetFileInfo(fileid).Extension;
    464464  filename := ExtractFilePath(Application.ExeName) + '\StructDefs\' + ext + '.txt';
    465465  if FileExists(filename) then
    466466  begin
    467     Data := OniDataConnection.LoadDatFile(fileid);
     467    Data := connection.LoadDatFile(fileid);
    468468    AssignFile(deffile, filename);
    469469    Reset(deffile);
  • oup/current/Code/OniDataClass.pas

    r86 r87  
    11unit OniDataClass;
    22interface
    3 uses Data, DataStructures, Classes, SysUtils, StrUtils,
     3uses Data, Classes, SysUtils, StrUtils,
    44  Dialogs, ABSDecUtil, ABSMain, DB, Windows;
    55
     
    2121    procedure Close; virtual; abstract;
    2222
    23     function GetFileInfo(fileid: LongWord): TFileInfo; virtual; abstract;
     23    function GetFileInfo(fileid: Integer): TFileInfo; virtual;
    2424    function GetFilesList(ext: String; pattern: String;
    2525      NoEmptyFiles: Boolean; sort: TSortType): TStringArray; virtual; abstract;
     
    7373    procedure Close; override;
    7474
    75     function GetFileInfo(fileid: LongWord): TFileInfo; override;
     75    function GetFileInfo(fileid: Integer): TFileInfo; override;
    7676    function GetFilesList(ext: String; pattern: String;
    7777      NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
     
    112112    procedure UpdateListCache;
    113113    //      function GetDatLinks(srcid:LongWord):TDatLinks;
    114     function GetFileInfo(fileid: LongWord): TFileInfo; override;
     114    function GetFileInfo(fileid: Integer): TFileInfo; override;
    115115    function GetFilesList(ext: String; pattern: String;
    116116      NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
     
    142142    constructor Create(OLDBFilename: String; var Result: Boolean); override;
    143143    procedure Close; override;
    144 {
    145     procedure UpdateListCache;
    146     //      function GetDatLinks(srcid:LongWord):TDatLinks;
    147     function GetFileInfo(fileid: LongWord): TFileInfo; override;
    148     function GetFilesList(ext: String; pattern: String;
    149       NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
    150     function GetFilesCount: LongWord; override;
    151     function GetExtensionsList: TStringArray; override;
    152     function GetExtendedExtensionsList: TExtensionsMap; override;
    153     function GetNamedFilesMap: TNamedFilesMap;
    154 
    155     function LoadDatFile(fileid: LongWord): Tdata; override;
    156     procedure UpdateDatFile(fileid: LongWord; Data: Tdata); override;
    157     procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
    158     procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
    159 
    160     function GetRawList(fileid: LongWord): TRawList; override;
    161     procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer); override;
    162     procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord;
    163       target: Pointer); override;
    164     procedure LoadRawFilePart(fileid, dat_offset: LongWord;
    165       offset, size: LongWord; target: Pointer); override;
    166     procedure UpdateRawFilePart(fileid, dat_offset: LongWord;
    167       offset, size: LongWord; target: Pointer); override;
    168 }  published
     144  published
    169145  end;
    170146
     
    181157function CreateDataConnection(filename: String; backend: Integer): TOniData;
    182158procedure CloseDataConnection(connection: TOniData);
     159function GetEmptyFileInfo: TFileInfo;
    183160
    184161
     
    187164
    188165implementation
    189 uses Functions;
     166uses DataStructures, Functions;
    190167
    191168
     
    252229
    253230
     231function TOniData.GetFileInfo(fileid: Integer): TFileInfo;
     232begin
     233  Result.ID := -1;
     234  Result.FileName := '';
     235  Result.FileNameHex := '';
     236  Result.Extension := '';
     237  Result.Name := '';
     238  Result.Size := 0;
     239  Result.FileType := 0;
     240  Result.DatAddr := 0;
     241  Result.opened := False;
     242end;
    254243
    255244
     
    378367
    379368
    380 function TOniDataDat.GetFileInfo(fileid: LongWord): TFileInfo;
    381 begin
     369function TOniDataDat.GetFileInfo(fileid: Integer): TFileInfo;
     370begin
     371  if fileid = -1 then
     372  begin
     373    Result := inherited GetFileInfo(fileid);
     374    Exit;
     375  end;
    382376  if fileid < Self.GetFilesCount then
    383377    Result    := Fdat_files[fileid]
     
    592586      if RawListHandlers[i].needed then
    593587      begin
    594         Result := RawListHandlers[i].Handler(fileid);
     588        Result := RawListHandlers[i].Handler(Self, fileid);
    595589        Break;
    596590      end
     
    961955
    962956
    963 function TOniDataADB.GetFileInfo(fileid: LongWord): TFileInfo;
     957function TOniDataADB.GetFileInfo(fileid: Integer): TFileInfo;
    964958var
    965959  i: Integer;
    966960begin
     961  if fileid = -1 then
     962  begin
     963    Result := inherited GetFileInfo(fileid);
     964    Exit;
     965  end;
    967966  if fileid < Self.GetFilesCount then
    968967  begin
     
    14841483        begin
    14851484          DataConnections[i].Close;
    1486           DataConnections[i].Free;
     1485//          DataConnections[i].Free;
    14871486          DataConnections[i] := nil;
    14881487          found := True;
     
    15001499
    15011500
     1501function GetEmptyFileInfo: TFileInfo;
     1502begin
     1503  Result.ID := -1;
     1504  Result.FileName := '';
     1505  Result.FileNameHex := '';
     1506  Result.Extension := '';
     1507  Result.Name := '';
     1508  Result.Size := 0;
     1509  Result.FileType := 0;
     1510  Result.DatAddr := 0;
     1511  Result.opened := False;
     1512end;
     1513
     1514
    15021515
    15031516
Note: See TracChangeset for help on using the changeset viewer.