unit RawList; interface uses TypeDefs, ConnectionManager; type THandler = function(ConnectionID, FileID: Integer): TRawDataList; TRawListHandlers = record Ext: String[4]; needed: Boolean; Handler: THandler; end; TRawLists = class private FRawListHandlers: TRawListHandlers; public procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler); function GetRawList(ConnectionID, FileID: Integer): TRawDataList; function GetRawInfo(ConnectionID, FileID, DatOffset: Integer): TRawDataInfo; end; var RawLists: TRawLists; implementation uses Template; function AGDB(ConnectionID, FileID: Integer): TRawDataList; var link: Integer; links: Integer; i: Integer; begin if not connection.OSisMac then begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); links := links * 2; SetLength(Result, links); for i := 0 to links - 1 do begin Result[i].src_offset := $20 + i * 4; ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * 4, 4, @link); Result[i].raw_addr := link; Result[i].raw_size := 32; Result[i].loc_sep := False; end; end; end; function AKVA(ConnectionID, FileID: Integer): TRawDataList; var link: Integer; links: Integer; i: Integer; begin if not connection.OSisMac then begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); SetLength(Result, links); for i := 0 to links - 1 do begin Result[i].src_offset := $20 + i * $74 + $24; ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link); Result[i].raw_addr := link; ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link); Result[i].raw_size := link; Result[i].loc_sep := False; end; end; end; function BINA(ConnectionID, FileID: Integer): TRawDataList; var link: Integer; datasize: Integer; begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize); SetLength(Result, 1); Result[0].src_offset := $0C; Result[0].raw_addr := link; Result[0].raw_size := datasize; Result[0].loc_sep := connection.OSisMac; end; function OSBD(ConnectionID, FileID: Integer): TRawDataList; var link: Integer; datasize: Integer; begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link); SetLength(Result, 1); Result[0].src_offset := $0C; Result[0].raw_addr := link; Result[0].raw_size := datasize; Result[0].loc_sep := connection.OSisMac; end; function SNDD(ConnectionID, FileID: Integer): TRawDataList; var link: Integer; datasize: Integer; begin SetLength(Result, 1); if not connection.OSisMac then begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $40, 4, @datasize); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link); Result[0].src_offset := $44; end else begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link); Result[0].src_offset := $14; end; Result[0].raw_addr := link; Result[0].raw_size := datasize; Result[0].loc_sep := False; end; function SUBT(ConnectionID, FileID: Integer): TRawDataList; var baselink, lastlink: Integer; links: Integer; j, k: Integer; Data: TByteData; begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @baselink); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); if links > 0 then begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink); SetLength(Data, lastlink + 1024); TOniDataDat(connection).LoadRawOffset(False, baselink, lastlink + 1024, Data); // connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]); k := 0; for j := 0 to 1024 do begin if (Data[lastlink + j] = $00) or (j = 1024) then begin if j < 1024 then begin if k = 0 then begin k := 1; end else begin SetLength(Result, 1); Result[0].src_offset := $18; Result[0].raw_addr := baselink; Result[0].raw_size := lastlink + j; Break; end; end; end; end; end; end; function TRAM(ConnectionID, FileID: Integer): TRawDataList; var i: Integer; link: Integer; frames: Word; tempb: Byte; tempw: Word; templ: Integer; Data: TByteData; offset: Word; frame_count: Byte; begin SetLength(Result, 13); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $16C, 2, @frames); {y-pos} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link); Result[0].src_offset := $0C; Result[0].raw_addr := link; Result[0].raw_size := frames * 4; {x-z-pos} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @link); Result[1].src_offset := $10; Result[1].raw_addr := link; Result[1].raw_size := frames * 8; {attacks} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $182, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link); Result[2].src_offset := $14; Result[2].raw_addr := link; Result[2].raw_size := tempb * 32; {damage} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $183, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @link); Result[3].src_offset := $18; Result[3].raw_addr := link; Result[3].raw_size := tempb * 8; {motionblur} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $184, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link); Result[4].src_offset := $1C; Result[4].raw_addr := link; Result[4].raw_size := tempb * 8; {shortcut} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link); Result[5].src_offset := $20; Result[5].raw_addr := link; Result[5].raw_size := tempb * 8; {throw} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $24, 4, @link); Result[6].src_offset := $24; Result[6].raw_addr := link; if link > 0 then Result[6].raw_size := 24 else Result[6].raw_size := 0; {footstep} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $186, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $28, 4, @link); Result[7].src_offset := $28; Result[7].raw_addr := link; Result[7].raw_size := tempb * 4; {particle} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $187, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $2C, 4, @link); Result[8].src_offset := $2C; Result[8].raw_addr := link; Result[8].raw_size := tempb * 24; {position} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $30, 4, @link); Result[9].src_offset := $30; Result[9].raw_addr := link; Result[9].raw_size := frames * 8; {particle} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $154, 2, @tempw); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $38, 4, @link); Result[11].src_offset := $38; Result[11].raw_addr := link; Result[11].raw_size := tempw * 34; {extent} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $138, 4, @templ); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $13C, 4, @link); Result[12].src_offset := $13C; Result[12].raw_addr := link; Result[12].raw_size := templ * 12; ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $34, 4, @link); if link > 0 then begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $160, 2, @tempw); frame_count := 0; i := 0; SetLength(Data, $FFFF); TOniDataDat(connection).LoadRawOffset(False, link, $FFFF, Data); offset := Data[$24] + Data[$25] * 256; while (offset + i < Length(Data)) and (frame_count < frames - 1) do begin Inc(i, tempw); frame_count := frame_count + Data[offset + i]; Inc(i); end; if offset + i < Length(Data) then begin Inc(i, tempw); Result[10].raw_size := offset + i; end else begin Result[10].raw_size := 0; end; end; Result[10].src_offset := $34; Result[10].raw_addr := link; end; function TXMP(ConnectionID, FileID: Integer): TRawDataList; var link_pc: Integer; link_mac: Integer; x, y: Word; storetype: Byte; datasize: Integer; begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac); case storetype of 0, 1, 2: datasize := x * y * 2; 8: datasize := x * y * 4; 9: datasize := x * y div 2; end; SetLength(Result, 1); if not connection.OSisMac then begin Result[0].src_offset := $9C; Result[0].raw_addr := link_pc; end else begin Result[0].src_offset := $A0; Result[0].raw_addr := link_mac; end; Result[0].raw_size := datasize; Result[0].loc_sep := connection.OSisMac; end; function TRawLists.GetRawInfo(ConnectionID, FileID, DatOffset: Integer): TRawDataInfo; var i: Integer; RawList: TRawDataList; begin RawList := GetRawList(ConnectionID, FileID); Result.SrcID := -1; Result.SrcOffset := -1; Result.RawAddr := -1; Result.RawSize := -1; if Length(RawList) > 0 then begin for i := 0 to High(RawList) do begin if RawList[i].SrcOffset = DatOffset then begin Result.SrcID := FileID; Result.SrcOffset := RawList[i].SrcOffset; Result.RawAddr := RawList[i].RawAddr; Result.RawSize := RawList[i].RawSize; Result.LocSep := RawList[i].LocSep; Break; end; end; end; end; function TRawLists.GetRawList(ConnectionID, FileID: Integer): TRawDataList; var i: Integer; fileinfo: TFileInfo; begin SetLength(Result, 0); fileinfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID); for i := 0 to High(FRawListHandlers) do if UpperCase(FRawListHandlers[i].Ext) = UpperCase(fileinfo.extension) then begin if FRawListHandlers[i].needed then Result := FRawListHandlers[i].Handler(ConnectionID, FileID); Break; end; end; procedure TRawLists.InsertRawListHandler(ext: String; needed: Boolean; handler: THandler); begin SetLength(FRawListHandlers, Length(FRawListHandlers) + 1); FRawListHandlers[High(FRawListHandlers)].Ext := ext; FRawListHandlers[High(FRawListHandlers)].needed := needed; FRawListHandlers[High(FRawListHandlers)].handler := handler; // Raws := Raws + ext; AddToolListEntry('rawedit', '', ext); end; initialization RawLists := TRawLists.Create; RawLists.InsertRawListHandler('AGDB',False,AGDB); RawLists.InsertRawListHandler('AKVA', True, AKVA); RawLists.InsertRawListHandler('BINA', True, BINA); RawLists.InsertRawListHandler('OSBD', True, OSBD); RawLists.InsertRawListHandler('SNDD', True, SNDD); RawLists.InsertRawListHandler('SUBT', True, SUBT); RawLists.InsertRawListHandler('TRAM', True, TRAM); RawLists.InsertRawListHandler('TXMP', True, TXMP); end.