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

Comparing:
oup/rewrite/Global/RawList.pas (file contents), Revision 97 by alloc, Mon Jan 22 23:05:45 2007 UTC vs.
oup/current/Global/RawList.pas (file contents), Revision 209 by alloc, Mon Jun 4 22:07:29 2007 UTC

# Line 1 | Line 1
1   unit RawList;
2
2   interface
3 <
5 < uses TypeDefs, ConnectionManager;
3 > uses TypeDefs;
4  
5   type
6    THandler = function(ConnectionID, FileID: Integer): TRawDataList;
7 <  TRawListHandlers = record
7 >  TRawListHandler = record
8      Ext:     String[4];
9      needed:  Boolean;
10      Handler: THandler;
11    end;
12 +  TRawListHandlers = array of TRawListHandler;
13  
14    TRawLists = class
15      private
16        FRawListHandlers: TRawListHandlers;
17      public
18 +      property RawListHandlers: TRawListHandlers read FRawListHandlers;
19        procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler);
20        function GetRawList(ConnectionID, FileID: Integer): TRawDataList;
21        function GetRawInfo(ConnectionID, FileID, DatOffset: Integer): TRawDataInfo;
# Line 24 | Line 24 | type
24  
25   var
26    RawLists: TRawLists;
27 <  
27 >
28  
29   implementation
30  
31   uses
32 <  Template;
32 >  Template, ConnectionManager, Access_OniArchive, Classes, SysUtils, Math;
33  
34  
35   function AGDB(ConnectionID, FileID: Integer): TRawDataList;
# Line 38 | Line 38 | var
38    links: Integer;
39    i:     Integer;
40   begin
41 <  if not connection.OSisMac then
41 >  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
42 >  links := links * 2;
43 >  SetLength(Result, links);
44 >  for i := 0 to links - 1 do
45    begin
46 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
47 <    links := links * 2;
48 <    SetLength(Result, links);
49 <    for i := 0 to links - 1 do
50 <    begin
48 <      Result[i].src_offset := $20 + i * 4;
49 <      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
50 <      Result[i].raw_addr := link;
51 <      Result[i].raw_size := 32;
52 <      Result[i].loc_sep  := False;
53 <    end;
46 >    Result[i].SrcOffset := $20 + i * 4;
47 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
48 >    Result[i].RawAddr := link;
49 >    Result[i].RawSize := 32;
50 >    Result[i].LocSep  := False;
51    end;
52   end;
53  
# Line 63 | Line 60 | var
60    links: Integer;
61    i:     Integer;
62   begin
63 <  if not connection.OSisMac then
63 >  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
64 >  SetLength(Result, links);
65 >  for i := 0 to links - 1 do
66    begin
67 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
68 <    SetLength(Result, links);
69 <    for i := 0 to links - 1 do
70 <    begin
71 <      Result[i].src_offset := $20 + i * $74 + $24;
72 <      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link);
74 <      Result[i].raw_addr := link;
75 <      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link);
76 <      Result[i].raw_size := link;
77 <      Result[i].loc_sep  := False;
78 <    end;
67 >    Result[i].SrcOffset := $20 + i * $74 + $24;
68 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link);
69 >    Result[i].RawAddr := link;
70 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link);
71 >    Result[i].RawSize := link;
72 >    Result[i].LocSep  := False;
73    end;
74   end;
75  
# Line 90 | Line 84 | begin
84    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
85    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize);
86    SetLength(Result, 1);
87 <  Result[0].src_offset := $0C;
88 <  Result[0].raw_addr   := link;
89 <  Result[0].raw_size   := datasize;
90 <  Result[0].loc_sep    := connection.OSisMac;
87 >  Result[0].SrcOffset := $0C;
88 >  Result[0].RawAddr   := link;
89 >  Result[0].RawSize   := datasize;
90 >  Result[0].LocSep    := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
91   end;
92  
93  
# Line 107 | Line 101 | begin
101    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize);
102    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
103    SetLength(Result, 1);
104 <  Result[0].src_offset := $0C;
105 <  Result[0].raw_addr   := link;
106 <  Result[0].raw_size   := datasize;
107 <  Result[0].loc_sep    := connection.OSisMac;
104 >  Result[0].SrcOffset := $0C;
105 >  Result[0].RawAddr   := link;
106 >  Result[0].RawSize   := datasize;
107 >  Result[0].LocSep     := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
108   end;
109  
110  
# Line 122 | Line 116 | var
116    datasize: Integer;
117   begin
118    SetLength(Result, 1);
119 <  if not connection.OSisMac then
119 >  if ConManager.Connection[ConnectionID].DataOS in [DOS_MACBETA, DOS_MAC] then
120    begin
121 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $40, 4, @datasize);
122 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link);
123 <    Result[0].src_offset := $44;
121 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize);
122 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
123 >    Result[0].SrcOffset := $14;
124    end
125    else
126    begin
127 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize);
128 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
129 <    Result[0].src_offset := $14;
127 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $40, 4, @datasize);
128 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link);
129 >    Result[0].SrcOffset := $44;
130    end;
131 <  Result[0].raw_addr := link;
132 <  Result[0].raw_size := datasize;
133 <  Result[0].loc_sep  := False;
131 >  Result[0].RawAddr := link;
132 >  Result[0].RawSize := datasize;
133 >  Result[0].LocSep  := False;
134   end;
135  
136  
# Line 146 | Line 140 | function SUBT(ConnectionID, FileID: Inte
140   var
141    baselink, lastlink: Integer;
142    links: Integer;
143 <  j, k:  Integer;
144 <  Data:  TByteData;
143 >  Data:  TStream;
144 >  read:  Integer;
145 >  char:  Byte;
146 >  foundzeros: Byte;
147   begin
148 +  SetLength(Result, 0);
149 +
150    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @baselink);
151    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
152    if links > 0 then
153    begin
154      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
155 <    SetLength(Data, lastlink + 1024);
156 <    TOniDataDat(connection).LoadRawOffset(False,
157 <      baselink, lastlink + 1024, Data);
158 <    //      connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
159 <    k := 0;
160 <    for j := 0 to 1024 do
161 <    begin
162 <      if (Data[lastlink + j] = $00) or (j = 1024) then
155 >    Data := nil;
156 >    TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset(
157 >          False, baselink, lastlink + 1024, Data);
158 >    Data.Seek(lastlink, soFromBeginning);
159 >
160 >    foundzeros := 0;
161 >    repeat
162 >      read := Data.Read(char, 1);
163 >      if (read > 0) and (char = 0) then
164        begin
165 <        if j < 1024 then
167 <        begin
168 <          if k = 0 then
169 <          begin
170 <            k := 1;
171 <          end
172 <          else
173 <          begin
174 <            SetLength(Result, 1);
175 <            Result[0].src_offset := $18;
176 <            Result[0].raw_addr   := baselink;
177 <            Result[0].raw_size   := lastlink + j;
178 <            Break;
179 <          end;
180 <        end;
165 >        Inc(foundzeros);
166        end;
167 +    until (read = 0) or (foundzeros = 2);
168 +
169 +    if foundzeros = 2 then
170 +    begin
171 +      SetLength(Result, 1);
172 +      Result[0].SrcID     := FileID;
173 +      Result[0].SrcOffset := $18;
174 +      Result[0].RawAddr   := baselink;
175 +      Result[0].RawSize   := Data.Position;
176 +      Result[0].LocSep    := False;
177      end;
178    end;
179   end;
# Line 196 | Line 191 | var
191    templ:  Integer;
192    Data:   TByteData;
193    offset: Word;
194 <  frame_count: Byte;
194 >  frame_count: Integer;
195   begin
196    SetLength(Result, 13);
197    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $16C, 2, @frames);
203  {y-pos}
204  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
205  Result[0].src_offset := $0C;
206  Result[0].raw_addr   := link;
207  Result[0].raw_size   := frames * 4;
198    {x-z-pos}
199 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
200 +  Result[0].SrcOffset := $0C;
201 +  Result[0].RawAddr   := link;
202 +  Result[0].RawSize := frames * 4;
203 +  {y-pos}
204    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @link);
205 <  Result[1].src_offset := $10;
206 <  Result[1].raw_addr   := link;
207 <  Result[1].raw_size   := frames * 8;
205 >  Result[1].SrcOffset := $10;
206 >  Result[1].RawAddr   := link;
207 >  Result[1].RawSize := frames * 8;
208    {attacks}
209    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $182, 1, @tempb);
210    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
211 <  Result[2].src_offset := $14;
212 <  Result[2].raw_addr   := link;
213 <  Result[2].raw_size   := tempb * 32;
211 >  Result[2].SrcOffset := $14;
212 >  Result[2].RawAddr   := link;
213 >  Result[2].RawSize   := tempb * 32;
214    {damage}
215    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $183, 1, @tempb);
216    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @link);
217 <  Result[3].src_offset := $18;
218 <  Result[3].raw_addr   := link;
219 <  Result[3].raw_size   := tempb * 8;
217 >  Result[3].SrcOffset := $18;
218 >  Result[3].RawAddr   := link;
219 >  Result[3].RawSize   := tempb * 8;
220    {motionblur}
221    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $184, 1, @tempb);
222    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link);
223 <  Result[4].src_offset := $1C;
224 <  Result[4].raw_addr   := link;
225 <  Result[4].raw_size   := tempb * 8;
223 >  Result[4].SrcOffset := $1C;
224 >  Result[4].RawAddr   := link;
225 >  Result[4].RawSize   := tempb * 12;
226    {shortcut}
227    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb);
228    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link);
229 <  Result[5].src_offset := $20;
230 <  Result[5].raw_addr   := link;
231 <  Result[5].raw_size   := tempb * 8;
229 >  Result[5].SrcOffset := $20;
230 >  Result[5].RawAddr   := link;
231 >  Result[5].RawSize   := tempb * 8;
232    {throw}
233    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $24, 4, @link);
234 <  Result[6].src_offset := $24;
235 <  Result[6].raw_addr   := link;
236 <  if link > 0 then
242 <    Result[6].raw_size := 24
243 <  else
244 <    Result[6].raw_size := 0;
234 >  Result[6].SrcOffset := $24;
235 >  Result[6].RawAddr   := link;
236 >  Result[6].RawSize := 24;
237    {footstep}
238    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $186, 1, @tempb);
239    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $28, 4, @link);
240 <  Result[7].src_offset := $28;
241 <  Result[7].raw_addr   := link;
242 <  Result[7].raw_size   := tempb * 4;
240 >  Result[7].SrcOffset := $28;
241 >  Result[7].RawAddr   := link;
242 >  Result[7].RawSize   := tempb * 4;
243    {particle}
244    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $187, 1, @tempb);
245    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $2C, 4, @link);
246 <  Result[8].src_offset := $2C;
247 <  Result[8].raw_addr   := link;
248 <  Result[8].raw_size   := tempb * 24;
246 >  Result[8].SrcOffset := $2C;
247 >  Result[8].RawAddr   := link;
248 >  Result[8].RawSize   := tempb * 24;
249    {position}
250    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $30, 4, @link);
251 <  Result[9].src_offset := $30;
252 <  Result[9].raw_addr   := link;
253 <  Result[9].raw_size   := frames * 8;
251 >  Result[9].SrcOffset := $30;
252 >  Result[9].RawAddr   := link;
253 >  Result[9].RawSize   := frames * 8;
254    {particle}
255    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $154, 2, @tempw);
256    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $38, 4, @link);
257 <  Result[11].src_offset := $38;
258 <  Result[11].raw_addr   := link;
259 <  Result[11].raw_size   := tempw * 34;
257 >  Result[11].SrcOffset := $38;
258 >  Result[11].RawAddr   := link;
259 >  Result[11].RawSize   := tempw * 34;
260    {extent}
261    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $138, 4, @templ);
262    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $13C, 4, @link);
263 <  Result[12].src_offset := $13C;
264 <  Result[12].raw_addr   := link;
265 <  Result[12].raw_size   := templ * 12;
263 >  Result[12].SrcOffset := $13C;
264 >  Result[12].RawAddr   := link;
265 >  Result[12].RawSize   := templ * 12;
266  
267    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $34, 4, @link);
268    if link > 0 then
# Line 279 | Line 271 | begin
271      frame_count := 0;
272      i := 0;
273      SetLength(Data, $FFFF);
274 <    TOniDataDat(connection).LoadRawOffset(False, link, $FFFF, Data);
274 >    TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset(
275 >          False, link, $FFFF, Data);
276      offset := Data[$24] + Data[$25] * 256;
277      while (offset + i < Length(Data)) and (frame_count < frames - 1) do
278      begin
# Line 290 | Line 283 | begin
283      if offset + i < Length(Data) then
284      begin
285        Inc(i, tempw);
286 <      Result[10].raw_size := offset + i;
286 >      Result[10].RawSize := offset + i;
287      end
288      else
289      begin
290 <      Result[10].raw_size := 0;
290 >      Result[10].RawSize := 0;
291      end;
292    end;
293 <  Result[10].src_offset := $34;
294 <  Result[10].raw_addr   := link;
293 >  Result[10].SrcOffset := $34;
294 >  Result[10].RawAddr   := link;
295   end;
296  
297  
# Line 311 | Line 304 | var
304    x, y:      Word;
305    storetype: Byte;
306    datasize:  Integer;
307 +  mipmap:    Byte;
308 +
309 +  function GetImgSize(w,h, storetype: Integer): Integer;
310 +  begin
311 +    case storetype of
312 +      0, 1, 2:
313 +        Result := w*h*2;
314 +      8:
315 +        Result := w*h*4;
316 +      9:
317 +        Result :=  Max(1, w div 4) * Max(1, h div 4) * 8;
318 +    else
319 +      Result := -1;
320 +    end;
321 +  end;
322 +
323   begin
324 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap);
325    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
326    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
327    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
328    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc);
329    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
330 <  case storetype of
331 <    0, 1, 2:
332 <      datasize := x * y * 2;
333 <    8:
334 <      datasize := x * y * 4;
335 <    9:
336 <      datasize := x * y div 2;
330 >
331 >
332 >  datasize := GetImgSize(x, y, storetype);
333 >  if (mipmap and $01) > 0 then
334 >  begin
335 >    repeat
336 >      x    := Max(x div 2, 1);
337 >      y    := Max(y div 2, 1);
338 >      datasize := datasize + GetImgSize(x, y, storetype);
339 >    until (x = 1) and (y = 1);
340    end;
341 +
342    SetLength(Result, 1);
343 <  if not connection.OSisMac then
343 >  if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then
344    begin
345 <    Result[0].src_offset := $9C;
346 <    Result[0].raw_addr   := link_pc;
345 >    Result[0].SrcOffset := $9C;
346 >    Result[0].RawAddr   := link_pc;
347    end
348    else
349    begin
350 <    Result[0].src_offset := $A0;
351 <    Result[0].raw_addr   := link_mac;
350 >    Result[0].SrcOffset := $A0;
351 >    Result[0].RawAddr   := link_mac;
352    end;
353 <  Result[0].raw_size := datasize;
354 <  Result[0].loc_sep  := connection.OSisMac;
353 >  Result[0].RawSize := datasize;
354 >  Result[0].LocSep  := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
355   end;
356  
357  
# Line 386 | Line 400 | begin
400          Result := FRawListHandlers[i].Handler(ConnectionID, FileID);
401        Break;
402      end;
403 +  if Length(Result) > 0 then
404 +    for i := 0 to High(Result) do
405 +      if Result[i].RawAddr = 0 then
406 +        Result[i].RawSize := 0;
407   end;
408  
409   procedure TRawLists.InsertRawListHandler(ext: String; needed: Boolean; handler: THandler);
# Line 403 | Line 421 | end;
421  
422   initialization
423    RawLists := TRawLists.Create;
424 <  RawLists.InsertRawListHandler('AGDB',False,AGDB);
424 >  RawLists.InsertRawListHandler('AGDB', False, AGDB);
425    RawLists.InsertRawListHandler('AKVA', True, AKVA);
426    RawLists.InsertRawListHandler('BINA', True, BINA);
427    RawLists.InsertRawListHandler('OSBD', True, OSBD);

Diff Legend

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