Changeset 245 for oup/current/FileClasses
- Timestamp:
- Aug 18, 2007, 5:51:42 PM (17 years ago)
- Location:
- oup/current/FileClasses
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/FileClasses/AKEV.pas
r233 r245 18 18 19 19 procedure TFile_AKEV.InitDataFields; 20 var21 tempi: Integer;22 20 begin 23 21 inherited; 24 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);22 FDataFields := TBlock.Create(Self, nil, 'Base', '', []); 25 23 with FDataFields do 26 24 begin 27 AddField(TFileID, $00, 'FileID', '', nil); 28 AddField(TLevelID, $04, 'LevelID', '', nil); 25 AddField(TFileID, 'FileID', '', []); 26 AddField(TLevelID, 'LevelID', '', []); 27 28 AddField(TLinkByID, 'PNTA-link', 'Link to the 3D Point Array', ['PNTA']); 29 AddField(TLinkByID, 'PLEA-link', 'Link to the Plane Equation Array', ['PLEA']); 30 AddField(TLinkByID, 'TXCA-link', 'Link to the Texture Coordinate Array', ['TXCA']); 31 AddField(TLinkByID, 'AGQG-link', 'Link to the Gunk Quad General Array', ['AGQG']); 32 33 AddField(TLinkByID, 'AGQR-link', 'Link to the Gunk Quad Render Array', ['AGQR']); 34 AddField(TLinkByID, 'AGQC-link', 'Link to the Gunk Quad Collision Array', ['AGQC']); 35 AddField(TLinkByID, 'AGDB-link', 'Link to the Gunk Quad Debug Array', ['AGDB']); 36 AddField(TLinkByID, 'TXMA-link', 'Link to the Texture Map Array', ['TXMA']); 37 38 AddField(TLinkByID, 'AKVA-link', 'Link to the BNV Node Array', ['AKVA']); 39 AddField(TLinkByID, 'AKBA-link', 'Link to the Side Array', ['AKBA']); 40 AddField(TLinkByID, 'IDXA-link', 'Link to the Index Array', ['IDXA']); 41 AddField(TLinkByID, 'IDXA-link', 'Link to the Index Array', ['IDXA']); 42 43 AddField(TLinkByID, 'AKBP-link', 'Link to the BSP Node Array', ['AKBP']); 44 AddField(TLinkByID, 'ABNA-link', 'Link to the BSP Tree Node Array', ['ABNA']); 45 AddField(TLinkByID, 'AKOT-link', 'Link to the Oct Tree', ['AKOT']); 46 AddField(TLinkByID, 'AKAA-link', 'Link to the Adjacency Array', ['AKAA']); 47 48 AddField(TLinkByID, 'AKDA-link', 'Link to the Door Frame Array', ['AKDA']); 49 50 51 AddField(TFloat, 'Neg. x-coordinate', 'Maximal negative x-coordinate of the level model', []); 52 AddField(TFloat, 'Neg. y-coordinate', 'Maximal negative y-coordinate of the level model', []); 53 AddField(TFloat, 'Neg. z-coordinate', 'Maximal negative z-coordinate of the level model', []); 54 55 AddField(TFloat, 'Pos. x-coordinate', 'Maximal positive x-coordinate of the level model', []); 56 AddField(TFloat, 'Pos. y-coordinate', 'Maximal positive y-coordinate of the level model', []); 57 AddField(TFloat, 'Pos. z-coordinate', 'Maximal positive z-coordinate of the level model', []); 58 59 AddField(TUnused, 'Not used', '', [1024]); 60 AddField(TFloat, 'Unknown', 'Unknown; maybe the tolerance', []); 29 61 end; 62 FDataFields.Update(0, -1); 30 63 FFileStream.Free; 31 64 FFileStream := nil; -
oup/current/FileClasses/BINA.pas
r233 r245 4 4 5 5 uses 6 _FileTypes ;6 _FileTypes, Grids; 7 7 8 8 type 9 9 TFile_BINA = class(TFile) 10 procedure SetOpened(Opened: Boolean); override; 11 private 12 maintype: String; 13 subtype: String; 14 grid: TStringGrid; 15 (* panel: TPanel; 16 save: TButton; *) 17 procedure saveclick(Sender: TObject); 10 18 public 11 19 procedure InitDataFields; override; 20 procedure InitEditor; override; 12 21 end; 13 22 … … 15 24 16 25 uses 17 ConnectionManager, Math, Classes, TypeDefs, _DataTypes, Forms, StdCtrls; 26 ConnectionManager, Math, Classes, TypeDefs, _DataTypes, Forms, StdCtrls, 27 Controls, StrUtils, Functions, SysUtils; 18 28 19 29 procedure TFile_BINA.InitDataFields; 20 var21 tempi: Integer;22 30 begin 23 31 inherited; 24 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);32 FDataFields := TBlock.Create(Self, nil, 'Base', '', []); 25 33 with FDataFields do 26 34 begin 27 AddField(TFileID, $00, 'FileID', '', nil); 28 AddField(TLevelID, $04, 'LevelID', '', nil); 29 end; 35 AddField(TFileID, 'FileID', '', []); 36 AddField(TLevelID, 'LevelID', '', []); 37 38 AddField(TInt, 'RawSize', 'Size of the part in the raw file', [4]); 39 AddField(TRawLink, 'RawOffset', 'At this position starts the part in the raw/sep file', []); 40 41 AddField(TUnused, 'Not used', '', [16]); 42 end; 43 FDataFields.Update(0, -1); 30 44 FFileStream.Free; 31 45 FFileStream := nil; 32 46 end; 33 47 48 procedure TFile_BINA.InitEditor; 49 var 50 subsize: Integer; 51 begin 52 CacheAllRawFiles; 53 SetLength(maintype, 4); 54 FRawCaches[0].RawStream.Read(maintype[1], 4); 55 maintype := ReverseString(maintype); 56 if maintype = 'OBJC' then 57 begin 58 FRawCaches[0].RawStream.Seek($0C, soFromBeginning); 59 FRawCaches[0].RawStream.Read(subsize, 4); 60 if subsize > 0 then 61 begin 62 SetLength(subtype, 4); 63 FRawCaches[0].RawStream.Seek($10, soFromBeginning); 64 FRawCaches[0].RawStream.Read(subtype[1], 4); 65 subtype := ReverseString(subtype); 66 if subtype = 'CHAR' then 67 begin 68 end 69 else if subtype = 'CMBT' then 70 begin 71 end 72 else if subtype = 'CONS' then 73 begin 74 end 75 else if subtype = 'DOOR' then 76 begin 77 end 78 else if subtype = 'FLAG' then 79 begin 80 end 81 else if subtype = 'FURN' then 82 begin 83 end 84 else if subtype = 'MELE' then 85 begin 86 end 87 else if subtype = 'NEUT' then 88 begin 89 end 90 else if subtype = 'PART' then 91 begin 92 end 93 else if subtype = 'PATR' then 94 begin 95 end 96 else if subtype = 'PWRU' then 97 begin 98 end 99 else if subtype = 'SNDG' then 100 begin 101 end 102 else if subtype = 'TRGV' then 103 begin 104 FEditor := TFrame.Create(nil); 105 grid := TStringGrid.Create(FEditor); 106 grid.Align := alClient; 107 grid.DefaultRowHeight := 18; 108 grid.DefaultColWidth := 100; 109 grid.ColCount := 8; 110 grid.RowCount := 2; 111 grid.FixedRows := 1; 112 grid.FixedCols := 0; 113 grid.ColWidths[0] := 150; 114 grid.ColWidths[1] := 125; 115 grid.ColWidths[2] := 125; 116 grid.ColWidths[3] := 125; 117 grid.Cells[0, 0] := 'TrgName'; 118 grid.Cells[1, 0] := 'FuncName Enter'; 119 grid.Cells[2, 0] := 'FuncName Inside'; 120 grid.Cells[3, 0] := 'FuncName Leave'; 121 grid.Cells[4, 0] := 'Teams'; 122 grid.Cells[5, 0] := 'Settings'; 123 grid.Cells[6, 0] := 'X, Y, Z'; 124 grid.Cells[7, 0] := 'Size X, Y, Z'; 125 grid.Options := [goColSizing,goEditing, 126 goVertLine,goHorzLine,goFixedVertLine,goFixedHorzLine]; 127 grid.Parent := FEditor; 128 end 129 else if subtype = 'TRIG' then 130 begin 131 end 132 else if subtype = 'TURR' then 133 begin 134 end 135 else if subtype = 'WEAP' then 136 begin 137 end; 138 end; 139 end 140 else if maintype = 'ONIE' then 141 begin 142 end 143 else if maintype = 'PAR3' then 144 begin 145 end 146 else if maintype = 'SABD' then 147 begin 148 end 149 else if maintype = 'TMBD' then 150 begin 151 end; 152 153 DiscardAllRawCaches; 154 155 (* 156 panel := TPanel.Create(FEditor); 157 panel.Align := alBottom; 158 panel.Height := 30; 159 panel.Parent := FEditor; 160 save := TButton.Create(panel); 161 save.Top := 2; 162 save.Left := 2; 163 save.Width := 100; 164 save.Height := 26; 165 save.Caption := 'Save'; 166 save.OnClick := saveclick; 167 save.Parent := panel; *) 168 end; 169 170 procedure TFile_BINA.saveclick(Sender: TObject); 171 var 172 i,j: Integer; 173 temps: String; 174 fs: TFileStream; 175 offset: Integer; 176 begin 177 (* fs := TFileStream.Create('C:\Spiele\Oni\GameDataFolder\tests\messages_raw_recreated.hex', fmCreate); 178 179 i := grid.RowCount - 2; 180 FFileStream.Seek($1C, soFromBeginning); 181 FFileStream.Write(i, 4); 182 FFileStream.Size := $20 + i * 4; 183 184 for i := 0 to grid.RowCount - 2 do 185 begin 186 for j := 0 to 1 do 187 begin 188 if j = 0 then 189 begin 190 offset := fs.Size; 191 FFileStream.Seek($20 + i*4, soFromBeginning); 192 FFileStream.Write(offset, 4); 193 end; 194 temps := grid.Cells[j, i+1]; 195 SetLength(temps, Length(temps)+1); 196 temps[Length(temps)] := #0; 197 fs.Write(temps[1], Length(temps)); 198 end; 199 end; 200 fs.Free; 201 fs := TFileStream.Create('C:\Spiele\Oni\GameDataFolder\tests\messages_dat_recreated.hex', fmCreate); 202 ReCreateFile(fs); 203 fs.Free; 204 *)end; 205 206 207 procedure TFile_BINA.SetOpened(Opened: Boolean); 208 var 209 i: Integer; 210 cursize: Integer; 211 curoffset: Integer; 212 raw: TMemoryStream; 213 tempi: Integer; 214 temps: String; 215 j: Integer; 216 tempf: Single; 217 begin 218 inherited; 219 if Opened then 220 begin 221 CacheAllRawFiles; 222 raw := FRawCaches[0].RawStream; 223 224 if maintype = 'OBJC' then 225 begin 226 if subtype = 'TRGV' then 227 begin 228 i := 0; 229 curoffset := $0C; 230 raw.Seek(curoffset, soFromBeginning); 231 raw.Read(cursize, 4); 232 233 while cursize > 0 do 234 begin 235 Inc(i); 236 grid.RowCount := 1 + i; 237 grid.Cells[0, i] := ReadString(raw, curoffset + 4 + $24); 238 grid.Cells[1, i] := ReadString(raw, curoffset + 4 + $63); 239 grid.Cells[2, i] := ReadString(raw, curoffset + 4 + $83); 240 grid.Cells[3, i] := ReadString(raw, curoffset + 4 + $A3); 241 242 raw.Seek(curoffset + 4 + $C3, soFromBeginning); 243 tempi := 0; 244 raw.Read(tempi, 1); 245 if tempi > 0 then 246 begin 247 temps := ''; 248 for j := 0 to 7 do 249 begin 250 if tempi and (1 shl j) > 0 then 251 begin 252 if Length(temps) > 0 then 253 temps := temps + ', ' + IntToStr(1 shl j) 254 else 255 temps := IntToStr(1 shl j); 256 end; 257 end; 258 end 259 else 260 temps := '0'; 261 grid.Cells[4, i] := temps; 262 263 raw.Seek(curoffset + 4 + $15C, soFromBeginning); 264 tempi := 0; 265 raw.Read(tempi, 1); 266 if tempi > 0 then 267 begin 268 temps := ''; 269 for j := 0 to 7 do 270 begin 271 if tempi and (1 shl j) > 0 then 272 begin 273 if Length(temps) > 0 then 274 temps := temps + ', ' + IntToStr(1 shl j) 275 else 276 temps := IntToStr(1 shl j); 277 end; 278 end; 279 end 280 else 281 temps := '0'; 282 grid.Cells[5, i] := temps; 283 284 raw.Seek(curoffset + 4 + $0C, soFromBeginning); 285 raw.Read(tempf, 4); 286 temps := FormatFloat('#0', tempf); 287 raw.Seek(curoffset + 4 + $10, soFromBeginning); 288 raw.Read(tempf, 4); 289 temps := temps + ', ' + FormatFloat('#0', tempf); 290 raw.Seek(curoffset + 4 + $14, soFromBeginning); 291 raw.Read(tempf, 4); 292 temps := temps + ', ' + FormatFloat('#0', tempf); 293 grid.Cells[6, i] := temps; 294 295 raw.Seek(curoffset + 4 + $C7, soFromBeginning); 296 raw.Read(tempf, 4); 297 temps := FormatFloat('#0', tempf); 298 raw.Seek(curoffset + 4 + $CB, soFromBeginning); 299 raw.Read(tempf, 4); 300 temps := temps + ', ' + FormatFloat('#0', tempf); 301 raw.Seek(curoffset + 4 + $CF, soFromBeginning); 302 raw.Read(tempf, 4); 303 temps := temps + ', ' + FormatFloat('#0', tempf); 304 grid.Cells[7, i] := temps; 305 306 curoffset := curoffset + cursize + 4; 307 raw.Seek(curoffset, soFromBeginning); 308 raw.Read(cursize, 4); 309 end; 310 end; 311 end; 312 end else 313 begin 314 Exit; 315 end; 316 end; 34 317 35 318 end. -
oup/current/FileClasses/SUBT.pas
r241 r245 129 129 begin 130 130 CacheFile; 131 Cache RawFile($18);131 CacheAllRawFiles; 132 132 133 133 FFileStream.Seek($1C, soFromBeginning); … … 144 144 FFileStream.Seek($20 + i*4, soFromBeginning); 145 145 FFileStream.Read(offset, 4); 146 FRawCaches[0]. Seek(offset, soFromBeginning);146 FRawCaches[0].RawStream.Seek(offset, soFromBeginning); 147 147 end; 148 148 SetLength(temps, 200); … … 150 150 repeat 151 151 Inc(pos); 152 FRawCaches[0].R ead(temps[pos], 1);152 FRawCaches[0].RawStream.Read(temps[pos], 1); 153 153 until temps[pos] = #0; 154 154 SetLength(temps, pos - 1); -
oup/current/FileClasses/_FileTypes.pas
r241 r245 8 8 9 9 type 10 TRawCache = record 11 DatOffset: Integer; 12 RawStream: TMemoryStream; 13 end; 14 10 15 TFile = class(TTreeElement) 11 16 protected 12 17 FFileInfo: TFileInfo; 13 18 FFileStream: TMemoryStream; 14 FRawCaches: array of T MemoryStream;19 FRawCaches: array of TRawCache; 15 20 16 21 FCached: Boolean; … … 28 33 function GetEditor: TFrame; 29 34 function GetFieldByOffset(Offset: Integer): TDataField; 35 function GetRawCacheID(Offset: Integer): Integer; 30 36 procedure SetOpened(Opened: Boolean); virtual; 31 37 published … … 41 47 procedure CacheFile; 42 48 procedure CacheRawFile(Offset: Integer); 49 procedure CacheAllRawFiles; 50 procedure DiscardFileCache; 51 procedure DiscardRawCache(Offset: Integer); 52 procedure DiscardAllRawCaches; 53 procedure StoreFileCache; 54 procedure StoreRawCache(Offset: Integer); 55 procedure StoreAllRawCaches; 43 56 44 57 property FileStream: TMemoryStream read FFileStream; … … 79 92 procedure TFile.CacheRawFile(Offset: Integer); 80 93 var 81 rawlist: TRawDataList; 82 i: Integer; 83 begin 84 rawlist := ConManager.Connection[ConnectionID].GetRawList(FFileInfo.ID); 85 if Length(rawlist) > 0 then 94 i: Integer; 95 begin 96 for i := 0 to High(FRawCaches) do 86 97 begin 87 for i := 0 to High(rawlist) do98 if FRawCaches[i].DatOffset = Offset then 88 99 begin 89 if rawlist[i].SrcOffset = Offsetthen100 if not Assigned(FRawCaches[i].RawStream) then 90 101 begin 91 if not Assigned(FRawCaches[i]) then 92 begin 93 FRawCaches[i] := TMemoryStream.Create; 94 ConManager.Connection[ConnectionID].LoadRawFile(FFileInfo.ID, Offset, TStream(FRawCaches[i])); 95 end; 102 FRawCaches[i].RawStream := TMemoryStream.Create; 103 ConManager.Connection[ConnectionID].LoadRawFile(FFileInfo.ID, Offset, TStream(FRawCaches[i].RawStream)); 96 104 end; 97 105 end; … … 99 107 end; 100 108 109 procedure TFile.CacheAllRawFiles; 110 var 111 i: Integer; 112 begin 113 for i := 0 to High(FRawCaches) do 114 CacheRawFile(FRawCaches[i].DatOffset); 115 end; 116 117 118 119 procedure TFile.DiscardFileCache; 120 begin 121 if Assigned(FFileStream) then 122 FFileStream.Free; 123 FFileStream := nil; 124 end; 125 126 procedure TFile.DiscardRawCache(Offset: Integer); 127 var 128 i: Integer; 129 begin 130 for i := 0 to High(FRawCaches) do 131 begin 132 if FRawCaches[i].DatOffset = Offset then 133 begin 134 if Assigned(FRawCaches[i].RawStream) then 135 FRawCaches[i].RawStream.Free; 136 FRawCaches[i].RawStream := nil; 137 end; 138 end; 139 end; 140 141 procedure TFile.DiscardAllRawCaches; 142 var 143 i: Integer; 144 begin 145 for i := 0 to High(FRawCaches) do 146 DiscardRawCache(FRawCaches[i].DatOffset); 147 end; 148 149 procedure TFile.StoreFileCache; 150 begin 151 Exit; 152 end; 153 154 procedure TFile.StoreRawCache(Offset: Integer); 155 begin 156 Exit; 157 end; 158 159 procedure TFile.StoreAllRawCaches; 160 var 161 i: Integer; 162 begin 163 for i := 0 to High(FRawCaches) do 164 StoreRawCache(FRawCaches[i].DatOffset); 165 end; 166 167 168 169 101 170 102 171 procedure TFile.SetOpened(Opened: Boolean); … … 107 176 108 177 constructor TFile.Create(ConnectionID, FileID: Integer); 178 var 179 rawlist: TRawDataList; 180 i: Integer; 109 181 begin 110 182 FConnectionID := ConnectionID; 111 183 FFileInfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID); 112 184 113 SetLength(FRawCaches, Length(ConManager.Connection[ConnectionID].GetRawList(FileID))); 185 rawlist := ConManager.Connection[ConnectionID].GetRawList(FileID); 186 SetLength(FRawCaches, Length(rawlist)); 187 for i := 0 to High(rawlist) do 188 FRawCaches[i].DatOffset := rawlist[i].SrcOffset; 114 189 115 190 FCached := False; … … 135 210 end; 136 211 212 213 function TFile.GetRawCacheID(Offset: Integer): Integer; 214 var 215 i: Integer; 216 begin 217 Result := -1; 218 for i := 0 to High(FRawCaches) do 219 if FRawCaches[i].DatOffset = Offset then 220 Result := i; 221 end; 137 222 138 223 function TFile.GetType: String; -
oup/current/FileClasses/_MetaTypes.pas
r241 r245 5 5 uses 6 6 _FileTypes, _EmptyFile, _DataTypes, _Extensions, _TreeElement, 7 AK VA, SUBT, TXAN, TXMP;7 AKEV, AKVA, BINA, SUBT, TXAN, TXMP; 8 8 // ABNA, AGDB, AGQC, AGQG, AGQM, AGQR, AISA, AITR, AIWA, AKAA, AKBA, AKBP, AKDA, 9 9 // AKEV, AKOT, AKVA, BINA, CBPI, CBPM, CONS, CRSA, DOOR, DPge, EDIA, ENVP, FILM, … … 46 46 47 47 const 48 FileDescs: array[0..3] of TFileDesc = ( 48 FileDescs: array[0..5] of TFileDesc = ( 49 (ext: 'AKEV'; ftype: TFile_AKEV), 49 50 (ext: 'AKVA'; ftype: TFile_AKVA), 51 (ext: 'BINA'; ftype: TFile_BINA), 50 52 (ext: 'SUBT'; ftype: TFile_SUBT), 51 53 (ext: 'TXAN'; ftype: TFile_TXAN),
Note:
See TracChangeset
for help on using the changeset viewer.