Changeset 87 for oup/current/Code
- Timestamp:
- Jan 14, 2007, 11:59:34 PM (18 years ago)
- Location:
- oup/current/Code
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Code/DataStructures.pas
r46 r87 3 3 interface 4 4 5 uses SysUtils, Classes, Data, Dialogs, StrUtils ;5 uses SysUtils, Classes, Data, Dialogs, StrUtils, OniDataClass; 6 6 7 7 type … … 34 34 Subs: array of TStructDefSub; 35 35 end; 36 THandler = function( fileid: LongWord): TRawList;36 THandler = function(connection: TOniData; fileid: LongWord): TRawList; 37 37 38 38 TRawListHandlers = record … … 47 47 48 48 49 function LoadStructureDefinition( fileid: LongWord): TStructDef;49 function LoadStructureDefinition(connection: TOniData; fileid: LongWord): TStructDef; 50 50 function GetDataType(typeid: Word): String; 51 51 function GetTypeDataLength(datatype: Word): Word; … … 53 53 implementation 54 54 55 uses Functions, OniDataClass,Forms, Template;55 uses Functions, Forms, Template; 56 56 57 57 … … 120 120 121 121 122 function AGDB( fileid: LongWord): TRawList;122 function AGDB(connection: TOniData; fileid: LongWord): TRawList; 123 123 var 124 124 link: LongWord; … … 126 126 i: LongWord; 127 127 begin 128 if not OniDataConnection.OSisMac then129 begin 130 OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);128 if not connection.OSisMac then 129 begin 130 connection.LoadDatFilePart(fileid, $1C, 4, @links); 131 131 links := links * 2; 132 132 SetLength(Result, links); … … 134 134 begin 135 135 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); 137 137 Result[i].raw_addr := link; 138 138 Result[i].raw_size := 0{????????????????????????????????}; … … 145 145 146 146 147 function AKVA( fileid: LongWord): TRawList;147 function AKVA(connection: TOniData; fileid: LongWord): TRawList; 148 148 var 149 149 link: LongWord; … … 151 151 i: LongWord; 152 152 begin 153 if not OniDataConnection.OSisMac then154 begin 155 OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);153 if not connection.OSisMac then 154 begin 155 connection.LoadDatFilePart(fileid, $1C, 4, @links); 156 156 SetLength(Result, links); 157 157 for i := 0 to links - 1 do 158 158 begin 159 159 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); 161 161 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); 163 163 Result[i].raw_size := link; 164 164 Result[i].loc_sep := False; … … 170 170 171 171 172 function BINA( fileid: LongWord): TRawList;172 function BINA(connection: TOniData; fileid: LongWord): TRawList; 173 173 var 174 174 link: LongWord; 175 175 datasize: LongWord; 176 176 begin 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; 184 end; 185 186 187 188 189 function OSBD(connection: TOniData; fileid: LongWord): TRawList; 190 var 191 link: LongWord; 192 datasize: LongWord; 193 begin 194 connection.LoadDatFilePart(fileid, $08, 4, @datasize); 195 connection.LoadDatFilePart(fileid, $0C, 4, @link); 179 196 SetLength(Result, 1); 180 197 Result[0].src_offset := $0C; … … 187 204 188 205 189 function OSBD(fileid: LongWord): TRawList;206 function SNDD(connection: TOniData; fileid: LongWord): TRawList; 190 207 var 191 208 link: LongWord; 192 209 datasize: LongWord; 193 210 begin 194 OniDataConnection.LoadDatFilePart(fileid, $08, 4, @datasize);195 OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);196 211 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); 216 216 Result[0].src_offset := $44; 217 217 end 218 218 else 219 219 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); 222 222 Result[0].src_offset := $14; 223 223 end; … … 230 230 231 231 232 function SUBT( fileid: LongWord): TRawList;232 function SUBT(connection: TOniData; fileid: LongWord): TRawList; 233 233 var 234 234 baselink, lastlink: LongWord; … … 237 237 Data: Tdata; 238 238 begin 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); 241 241 if links > 0 then 242 242 begin 243 OniDataConnection.LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);243 connection.LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink); 244 244 SetLength(Data, lastlink + 1024); 245 TOniDataDat( OniDataConnection).LoadRawOffset(False,245 TOniDataDat(connection).LoadRawOffset(False, 246 246 baselink, lastlink + 1024, Data); 247 247 // OniDataConnection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]); … … 274 274 275 275 276 function TRAM( fileid: LongWord): TRawList;276 function TRAM(connection: TOniData; fileid: LongWord): TRawList; 277 277 var 278 278 i: Integer; … … 287 287 begin 288 288 SetLength(Result, 13); 289 OniDataConnection.LoadDatFilePart(fileid, $16C, 2, @frames);289 connection.LoadDatFilePart(fileid, $16C, 2, @frames); 290 290 {y-pos} 291 OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);291 connection.LoadDatFilePart(fileid, $0C, 4, @link); 292 292 Result[0].src_offset := $0C; 293 293 Result[0].raw_addr := link; 294 294 Result[0].raw_size := frames * 4; 295 295 {x-z-pos} 296 OniDataConnection.LoadDatFilePart(fileid, $10, 4, @link);296 connection.LoadDatFilePart(fileid, $10, 4, @link); 297 297 Result[1].src_offset := $10; 298 298 Result[1].raw_addr := link; 299 299 Result[1].raw_size := frames * 8; 300 300 {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); 303 303 Result[2].src_offset := $14; 304 304 Result[2].raw_addr := link; 305 305 Result[2].raw_size := tempb * 32; 306 306 {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); 309 309 Result[3].src_offset := $18; 310 310 Result[3].raw_addr := link; 311 311 Result[3].raw_size := tempb * 8; 312 312 {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); 315 315 Result[4].src_offset := $1C; 316 316 Result[4].raw_addr := link; 317 317 Result[4].raw_size := tempb * 8; 318 318 {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); 321 321 Result[5].src_offset := $20; 322 322 Result[5].raw_addr := link; 323 323 Result[5].raw_size := tempb * 8; 324 324 {throw} 325 OniDataConnection.LoadDatFilePart(fileid, $24, 4, @link);325 connection.LoadDatFilePart(fileid, $24, 4, @link); 326 326 Result[6].src_offset := $24; 327 327 Result[6].raw_addr := link; … … 331 331 Result[6].raw_size := 0; 332 332 {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); 335 335 Result[7].src_offset := $28; 336 336 Result[7].raw_addr := link; 337 337 Result[7].raw_size := tempb * 4; 338 338 {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); 341 341 Result[8].src_offset := $2C; 342 342 Result[8].raw_addr := link; 343 343 Result[8].raw_size := tempb * 24; 344 344 {position} 345 OniDataConnection.LoadDatFilePart(fileid, $30, 4, @link);345 connection.LoadDatFilePart(fileid, $30, 4, @link); 346 346 Result[9].src_offset := $30; 347 347 Result[9].raw_addr := link; 348 348 Result[9].raw_size := frames * 8; 349 349 {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); 352 352 Result[11].src_offset := $38; 353 353 Result[11].raw_addr := link; 354 354 Result[11].raw_size := tempw * 34; 355 355 {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); 358 358 Result[12].src_offset := $13C; 359 359 Result[12].raw_addr := link; 360 360 Result[12].raw_size := templ * 12; 361 361 362 OniDataConnection.LoadDatFilePart(fileid, $34, 4, @link);362 connection.LoadDatFilePart(fileid, $34, 4, @link); 363 363 if link > 0 then 364 364 begin 365 OniDataConnection.LoadDatFilePart(fileid, $160, 2, @tempw);365 connection.LoadDatFilePart(fileid, $160, 2, @tempw); 366 366 frame_count := 0; 367 367 i := 0; 368 368 SetLength(Data, $FFFF); 369 TOniDataDat( OniDataConnection).LoadRawOffset(False, link, $FFFF, Data);369 TOniDataDat(connection).LoadRawOffset(False, link, $FFFF, Data); 370 370 offset := Data[$24] + Data[$25] * 256; 371 371 while (offset + i < Length(Data)) and (frame_count < frames - 1) do … … 392 392 393 393 394 function TXMP( fileid: LongWord): TRawList;394 function TXMP(connection: TOniData; fileid: LongWord): TRawList; 395 395 var 396 396 link_pc: LongWord; … … 400 400 datasize: LongWord; 401 401 begin 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); 407 407 case storetype of 408 408 0, 1, 2: … … 414 414 end; 415 415 SetLength(Result, 1); 416 if not OniDataConnection.OSisMac then416 if not connection.OSisMac then 417 417 begin 418 418 Result[0].src_offset := $9C; … … 425 425 end; 426 426 Result[0].raw_size := datasize; 427 Result[0].loc_sep := OniDataConnection.OSisMac;427 Result[0].loc_sep := connection.OSisMac; 428 428 end; 429 429 … … 444 444 445 445 446 function LoadStructureDefinition( fileid: LongWord): TStructDef;446 function LoadStructureDefinition(connection: TOniData; fileid: LongWord): TStructDef; 447 447 var 448 448 i: LongWord; … … 461 461 SetLength(Result.Subs, 0); 462 462 Result.Data := False; 463 ext := OniDataConnection.GetFileInfo(fileid).Extension;463 ext := connection.GetFileInfo(fileid).Extension; 464 464 filename := ExtractFilePath(Application.ExeName) + '\StructDefs\' + ext + '.txt'; 465 465 if FileExists(filename) then 466 466 begin 467 Data := OniDataConnection.LoadDatFile(fileid);467 Data := connection.LoadDatFile(fileid); 468 468 AssignFile(deffile, filename); 469 469 Reset(deffile); -
oup/current/Code/OniDataClass.pas
r86 r87 1 1 unit OniDataClass; 2 2 interface 3 uses Data, DataStructures,Classes, SysUtils, StrUtils,3 uses Data, Classes, SysUtils, StrUtils, 4 4 Dialogs, ABSDecUtil, ABSMain, DB, Windows; 5 5 … … 21 21 procedure Close; virtual; abstract; 22 22 23 function GetFileInfo(fileid: LongWord): TFileInfo; virtual; abstract;23 function GetFileInfo(fileid: Integer): TFileInfo; virtual; 24 24 function GetFilesList(ext: String; pattern: String; 25 25 NoEmptyFiles: Boolean; sort: TSortType): TStringArray; virtual; abstract; … … 73 73 procedure Close; override; 74 74 75 function GetFileInfo(fileid: LongWord): TFileInfo; override;75 function GetFileInfo(fileid: Integer): TFileInfo; override; 76 76 function GetFilesList(ext: String; pattern: String; 77 77 NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override; … … 112 112 procedure UpdateListCache; 113 113 // function GetDatLinks(srcid:LongWord):TDatLinks; 114 function GetFileInfo(fileid: LongWord): TFileInfo; override;114 function GetFileInfo(fileid: Integer): TFileInfo; override; 115 115 function GetFilesList(ext: String; pattern: String; 116 116 NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override; … … 142 142 constructor Create(OLDBFilename: String; var Result: Boolean); override; 143 143 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 169 145 end; 170 146 … … 181 157 function CreateDataConnection(filename: String; backend: Integer): TOniData; 182 158 procedure CloseDataConnection(connection: TOniData); 159 function GetEmptyFileInfo: TFileInfo; 183 160 184 161 … … 187 164 188 165 implementation 189 uses Functions;166 uses DataStructures, Functions; 190 167 191 168 … … 252 229 253 230 231 function TOniData.GetFileInfo(fileid: Integer): TFileInfo; 232 begin 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; 242 end; 254 243 255 244 … … 378 367 379 368 380 function TOniDataDat.GetFileInfo(fileid: LongWord): TFileInfo; 381 begin 369 function TOniDataDat.GetFileInfo(fileid: Integer): TFileInfo; 370 begin 371 if fileid = -1 then 372 begin 373 Result := inherited GetFileInfo(fileid); 374 Exit; 375 end; 382 376 if fileid < Self.GetFilesCount then 383 377 Result := Fdat_files[fileid] … … 592 586 if RawListHandlers[i].needed then 593 587 begin 594 Result := RawListHandlers[i].Handler( fileid);588 Result := RawListHandlers[i].Handler(Self, fileid); 595 589 Break; 596 590 end … … 961 955 962 956 963 function TOniDataADB.GetFileInfo(fileid: LongWord): TFileInfo;957 function TOniDataADB.GetFileInfo(fileid: Integer): TFileInfo; 964 958 var 965 959 i: Integer; 966 960 begin 961 if fileid = -1 then 962 begin 963 Result := inherited GetFileInfo(fileid); 964 Exit; 965 end; 967 966 if fileid < Self.GetFilesCount then 968 967 begin … … 1484 1483 begin 1485 1484 DataConnections[i].Close; 1486 DataConnections[i].Free;1485 // DataConnections[i].Free; 1487 1486 DataConnections[i] := nil; 1488 1487 found := True; … … 1500 1499 1501 1500 1501 function GetEmptyFileInfo: TFileInfo; 1502 begin 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; 1512 end; 1513 1514 1502 1515 1503 1516
Note:
See TracChangeset
for help on using the changeset viewer.