| 3 |  | interface | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 4 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 |  | uses | 
 
 
 
 
 
 
 
 
 
 
 | 6 | < | _FileTypes; | 
 
 
 
 
 
 
 
 
 | 6 | > | _FileTypes, Grids, StdCtrls, ExtCtrls; | 
 
 
 
 
 
 
 
 
 
 
 | 7 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 |  | type | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 9 |  | TFile_SUBT = class(TFile) | 
 
 
 
 
 
 
 
 | 10 | + | procedure SetOpened(Opened: Boolean); override; | 
 
 
 
 
 
 
 
 | 11 | + | private | 
 
 
 
 
 
 
 
 | 12 | + | grid: TStringGrid; | 
 
 
 
 
 
 
 
 | 13 | + | panel: TPanel; | 
 
 
 
 
 
 
 
 | 14 | + | save: TButton; | 
 
 
 
 
 
 
 
 | 15 | + | procedure saveclick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 |  | public | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 17 |  | procedure InitDataFields; override; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 18 |  | procedure InitEditor; override; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 |  | implementation | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 22 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 23 |  | uses | 
 
 
 
 
 
 
 
 
 
 
 | 24 | < | ConnectionManager, Math, Classes, TypeDefs, _DataTypes, Forms, StdCtrls, Grids; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 24 | > | ConnectionManager, Math, Classes, TypeDefs, _DataTypes, Forms, | 
 
 
 
 
 | 25 | > | Controls; | 
 
 
 
 
 
 
 
 
 
 
 | 26 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 27 |  | procedure TFile_SUBT.InitDataFields; | 
 
 
 
 
 
 
 
 
 | 21 | – | var | 
 
 
 
 
 
 
 
 
 | 22 | – | tempi: Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 28 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 29 |  | inherited; | 
 
 
 
 
 
 
 
 
 
 
 | 30 | < | FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil); | 
 
 
 
 
 
 
 
 
 | 30 | > | FDataFields := TBlock.Create(Self, nil, 'Base', '', []); | 
 
 
 
 
 
 
 
 
 
 
 | 31 |  | with FDataFields do | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 | 33 | < | AddField(TFileID, $00, 'FileID', '', nil); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 35 | < | AddField(TLevelID, $04, 'LevelID', '', nil); | 
 
 
 
 
 
 
 
 
 | 33 | > | AddField(TFileID, 'FileID', '', []); | 
 
 
 
 
 | 34 | > | AddField(TLevelID, 'LevelID', '', []); | 
 
 
 
 
 | 35 | > | AddField(TUnused, 'Unused data', '', [16]); | 
 
 
 
 
 
 
 
 
 
 
 | 36 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 37 | < | tempi := 16; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 | < | AddField(TUnused, $08, 'Unused data', '', @tempi); | 
 
 
 
 
 
 
 
 
 | 37 | > | AddField(TRawLink, 'Raw Address', '', []); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 38 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 39 | < | AddField(TRawLink, $18, 'Raw Address', '', nil); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 36 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 37 | < | tempi := 4; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 38 | < | with AddField(TArray, $1C, 'SUBT offsets array', '', @tempi) do | 
 
 
 
 
 
 
 
 
 | 39 | > | with TArray(AddField(TArray, 'SUBT offsets array', '', [4])) do | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 | 41 | < | tempi := 4; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 | < | AddField(TInt, $00, 'Offset', '', @tempi); | 
 
 
 
 
 
 
 
 
 | 41 | > | AddField(TInt, 'Offset', '', [4]); | 
 
 
 
 
 | 42 | > | SetCount; | 
 
 
 
 
 
 
 
 
 
 
 | 43 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 |  | end; | 
 
 
 
 
 
 
 
 | 45 | + | FDataFields.Update(0, -1); | 
 
 
 
 
 
 
 
 | 46 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 |  | FFileStream.Free; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 |  | FFileStream := nil; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 |  |  | 
 
 
 
 
 
 
 
 
 | 48 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 |  | procedure TFile_SUBT.InitEditor; | 
 
 
 
 
 
 
 
 
 | 50 | – | var | 
 
 
 
 
 
 
 
 
 | 51 | – | grid: TStringGrid; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 |  | FEditor := TFrame.Create(nil); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 |  | grid := TStringGrid.Create(FEditor); | 
 
 
 
 
 
 
 
 | 55 | + | grid.Align := alClient; | 
 
 
 
 
 
 
 
 | 56 | + | grid.DefaultRowHeight := 18; | 
 
 
 
 
 
 
 
 | 57 | + | grid.DefaultColWidth := 100; | 
 
 
 
 
 
 
 
 | 58 | + | grid.ColCount := 2; | 
 
 
 
 
 
 
 
 | 59 | + | grid.RowCount := 4; | 
 
 
 
 
 
 
 
 | 60 | + | grid.FixedRows := 1; | 
 
 
 
 
 
 
 
 | 61 | + | grid.FixedCols := 0; | 
 
 
 
 
 
 
 
 | 62 | + | grid.ColWidths[0] := 80; | 
 
 
 
 
 
 
 
 | 63 | + | grid.ColWidths[1] := 200; | 
 
 
 
 
 
 
 
 | 64 | + | grid.Cells[0, 0] := 'Name'; | 
 
 
 
 
 
 
 
 | 65 | + | grid.Cells[1, 0] := 'Content'; | 
 
 
 
 
 
 
 
 | 66 | + | grid.Options := [goColSizing,goEditing, | 
 
 
 
 
 
 
 
 | 67 | + | goVertLine,goHorzLine,goFixedVertLine,goFixedHorzLine]; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 68 |  | grid.Parent := FEditor; | 
 
 
 
 
 
 
 
 | 69 | + | panel := TPanel.Create(FEditor); | 
 
 
 
 
 
 
 
 | 70 | + | panel.Align := alBottom; | 
 
 
 
 
 
 
 
 | 71 | + | panel.Height := 30; | 
 
 
 
 
 
 
 
 | 72 | + | panel.Parent := FEditor; | 
 
 
 
 
 
 
 
 | 73 | + | save := TButton.Create(panel); | 
 
 
 
 
 
 
 
 | 74 | + | save.Top := 2; | 
 
 
 
 
 
 
 
 | 75 | + | save.Left := 2; | 
 
 
 
 
 
 
 
 | 76 | + | save.Width := 100; | 
 
 
 
 
 
 
 
 | 77 | + | save.Height := 26; | 
 
 
 
 
 
 
 
 | 78 | + | save.Caption := 'Save'; | 
 
 
 
 
 
 
 
 | 79 | + | save.OnClick := saveclick; | 
 
 
 
 
 
 
 
 | 80 | + | save.Parent := panel; | 
 
 
 
 
 
 
 
 | 81 | + | end; | 
 
 
 
 
 
 
 
 | 82 | + |  | 
 
 
 
 
 
 
 
 | 83 | + | procedure TFile_SUBT.saveclick(Sender: TObject); | 
 
 
 
 
 
 
 
 | 84 | + | var | 
 
 
 
 
 
 
 
 | 85 | + | i,j: Integer; | 
 
 
 
 
 
 
 
 | 86 | + | temps: String; | 
 
 
 
 
 
 
 
 | 87 | + | fs: TFileStream; | 
 
 
 
 
 
 
 
 | 88 | + | offset: Integer; | 
 
 
 
 
 
 
 
 | 89 | + | begin | 
 
 
 
 
 
 
 
 | 90 | + | fs := TFileStream.Create('C:\Spiele\Oni\GameDataFolder\tests\messages_raw_recreated.hex', fmCreate); | 
 
 
 
 
 
 
 
 | 91 | + |  | 
 
 
 
 
 
 
 
 | 92 | + | i := grid.RowCount - 2; | 
 
 
 
 
 
 
 
 | 93 | + | FFileStream.Seek($1C, soFromBeginning); | 
 
 
 
 
 
 
 
 | 94 | + | FFileStream.Write(i, 4); | 
 
 
 
 
 
 
 
 | 95 | + | FFileStream.Size := $20 + i * 4; | 
 
 
 
 
 
 
 
 | 96 | + |  | 
 
 
 
 
 
 
 
 | 97 | + | for i := 0 to grid.RowCount - 2 do | 
 
 
 
 
 
 
 
 | 98 | + | begin | 
 
 
 
 
 
 
 
 | 99 | + | for j := 0 to 1 do | 
 
 
 
 
 
 
 
 | 100 | + | begin | 
 
 
 
 
 
 
 
 | 101 | + | if j = 0 then | 
 
 
 
 
 
 
 
 | 102 | + | begin | 
 
 
 
 
 
 
 
 | 103 | + | offset := fs.Size; | 
 
 
 
 
 
 
 
 | 104 | + | FFileStream.Seek($20 + i*4, soFromBeginning); | 
 
 
 
 
 
 
 
 | 105 | + | FFileStream.Write(offset, 4); | 
 
 
 
 
 
 
 
 | 106 | + | end; | 
 
 
 
 
 
 
 
 | 107 | + | temps := grid.Cells[j, i+1]; | 
 
 
 
 
 
 
 
 | 108 | + | SetLength(temps, Length(temps)+1); | 
 
 
 
 
 
 
 
 | 109 | + | temps[Length(temps)] := #0; | 
 
 
 
 
 
 
 
 | 110 | + | fs.Write(temps[1], Length(temps)); | 
 
 
 
 
 
 
 
 | 111 | + | end; | 
 
 
 
 
 
 
 
 | 112 | + | end; | 
 
 
 
 
 
 
 
 | 113 | + | fs.Free; | 
 
 
 
 
 
 
 
 | 114 | + | fs := TFileStream.Create('C:\Spiele\Oni\GameDataFolder\tests\messages_dat_recreated.hex', fmCreate); | 
 
 
 
 
 
 
 
 | 115 | + | ReCreateFile(fs); | 
 
 
 
 
 
 
 
 | 116 | + | fs.Free; | 
 
 
 
 
 
 
 
 | 117 | + | end; | 
 
 
 
 
 
 
 
 | 118 | + |  | 
 
 
 
 
 
 
 
 | 119 | + |  | 
 
 
 
 
 
 
 
 | 120 | + | procedure TFile_SUBT.SetOpened(Opened: Boolean); | 
 
 
 
 
 
 
 
 | 121 | + | var | 
 
 
 
 
 
 
 
 | 122 | + | i,j: Integer; | 
 
 
 
 
 
 
 
 | 123 | + | offset: Integer; | 
 
 
 
 
 
 
 
 | 124 | + | temps: String; | 
 
 
 
 
 
 
 
 | 125 | + | pos: Integer; | 
 
 
 
 
 
 
 
 | 126 | + | begin | 
 
 
 
 
 
 
 
 | 127 | + | inherited; | 
 
 
 
 
 
 
 
 | 128 | + | if Opened then | 
 
 
 
 
 
 
 
 | 129 | + | begin | 
 
 
 
 
 
 
 
 | 130 | + | CacheFile; | 
 
 
 
 
 
 
 
 | 131 | + | CacheRawFile($18); | 
 
 
 
 
 
 
 
 | 132 | + |  | 
 
 
 
 
 
 
 
 | 133 | + | FFileStream.Seek($1C, soFromBeginning); | 
 
 
 
 
 
 
 
 | 134 | + | FFileStream.Read(i, 4); | 
 
 
 
 
 
 
 
 | 135 | + |  | 
 
 
 
 
 
 
 
 | 136 | + | grid.RowCount := 1 + i; | 
 
 
 
 
 
 
 
 | 137 | + |  | 
 
 
 
 
 
 
 
 | 138 | + | for i := 0 to grid.RowCount - 2 do | 
 
 
 
 
 
 
 
 | 139 | + | begin | 
 
 
 
 
 
 
 
 | 140 | + | for j := 0 to 1 do | 
 
 
 
 
 
 
 
 | 141 | + | begin | 
 
 
 
 
 
 
 
 | 142 | + | if j = 0 then | 
 
 
 
 
 
 
 
 | 143 | + | begin | 
 
 
 
 
 
 
 
 | 144 | + | FFileStream.Seek($20 + i*4, soFromBeginning); | 
 
 
 
 
 
 
 
 | 145 | + | FFileStream.Read(offset, 4); | 
 
 
 
 
 
 
 
 | 146 | + | FRawCaches[0].Seek(offset, soFromBeginning); | 
 
 
 
 
 
 
 
 | 147 | + | end; | 
 
 
 
 
 
 
 
 | 148 | + | SetLength(temps, 200); | 
 
 
 
 
 
 
 
 | 149 | + | pos := 0; | 
 
 
 
 
 
 
 
 | 150 | + | repeat | 
 
 
 
 
 
 
 
 | 151 | + | Inc(pos); | 
 
 
 
 
 
 
 
 | 152 | + | FRawCaches[0].Read(temps[pos], 1); | 
 
 
 
 
 
 
 
 | 153 | + | until temps[pos] = #0; | 
 
 
 
 
 
 
 
 | 154 | + | SetLength(temps, pos - 1); | 
 
 
 
 
 
 
 
 | 155 | + | grid.Cells[j, i+1] := temps; | 
 
 
 
 
 
 
 
 | 156 | + | end; | 
 
 
 
 
 
 
 
 | 157 | + | end; | 
 
 
 
 
 
 
 
 | 158 | + |  | 
 
 
 
 
 
 
 
 | 159 | + | end else | 
 
 
 
 
 
 
 
 | 160 | + | begin | 
 
 
 
 
 
 
 
 | 161 | + | Exit; | 
 
 
 
 
 
 
 
 | 162 | + | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 163 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 164 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 165 |  | end. |