Hi there.
I have this dynamic 2d array of records:
TTerrainCell = record
Index : integer;
end;
Terrain : array of array of TTCell;
And a loading procedure:
var
f : file of byte;
begin
assignfile(f,filename);
reset(f);
blockread(f,Header,sizeof(TMapHeader));
setlength(Terrain,header.WIDTH,header.HEIGHT);
blockread(f,Terrain[0],sizeof(TTerrainCell)*header.width*Header.Height,readed);
showmessage(inttostr(terrain[9,0].index));
closefile(f);
Header holds the dimensions of the array: width and height.
The saving procedure is ok, I guess. The size of a saved file is correct.
The header is read correctly, it finds out the dimensions.
The problem is when I try to use the Terrain data i get an access violation error. I'm using Turbo Delphi.
It seems this whole thing has to do with the data type. If i change that Record to a simple Integer it's ok. (array of array of integer)
I have this dynamic 2d array of records:
TTerrainCell = record
Index : integer;
end;
Terrain : array of array of TTCell;
And a loading procedure:
var
f : file of byte;
begin
assignfile(f,filename);
reset(f);
blockread(f,Header,sizeof(TMapHeader));
setlength(Terrain,header.WIDTH,header.HEIGHT);
blockread(f,Terrain[0],sizeof(TTerrainCell)*header.width*Header.Height,readed);
showmessage(inttostr(terrain[9,0].index));
closefile(f);
Header holds the dimensions of the array: width and height.
The saving procedure is ok, I guess. The size of a saved file is correct.
The header is read correctly, it finds out the dimensions.
The problem is when I try to use the Terrain data i get an access violation error. I'm using Turbo Delphi.
It seems this whole thing has to do with the data type. If i change that Record to a simple Integer it's ok. (array of array of integer)