Z
zfine
Unregistered / Unconfirmed
GUEST, unregistred user!
///
..
type
TMapHeader = record //map file header
Width : word;
Height : word;
Title: string[26]
//map tile
Reserved : array[0..19] of char;
end;
TMapInfo = record
BkImg: word;
MidImg: word;
FrImg: word;
DoorIndex: byte;
DoorOffset: byte;
AniFrame: byte;
AniTick: byte;
Area: byte;
light: byte;
end;
....
var
width, height: integer;
MapRec:array of array of TMapInfo ;
function TForm1.loadmapinfo (mapfile: string): Boolean;//装载文件头部信息;
var
fhandle,k: integer
//文件句柄;
header: TMapHeader;//文件头;
begin
if FileExists (mapfile) then
begin //找到文件;
fhandle := FileOpen (mapfile, fmOpenRead )
//打开文件;
if fhandle > 0 then begin
FileRead (fhandle, header, sizeof(TMapHeader));//读文件头
width := header.Width
//地图宽度;
height := header.Height;//得到地图高度
SetLength(MapRec,width,height);
FileSeek (fhandle, sizeof(TMapHeader),0);
k:=fileread(fhandle,MapRec[0,0],sizeof(TMapInfo)*(width)*(height));
end;
FileClose (fhandle);
end;
result:=false;
end;
错误:不能正确读出文件,尤其是文件比较大时可k :=-1
另外多维动态数组怎么才能释放其内存?还请各位高手指点!
..
type
TMapHeader = record //map file header
Width : word;
Height : word;
Title: string[26]
//map tile
Reserved : array[0..19] of char;
end;
TMapInfo = record
BkImg: word;
MidImg: word;
FrImg: word;
DoorIndex: byte;
DoorOffset: byte;
AniFrame: byte;
AniTick: byte;
Area: byte;
light: byte;
end;
....
var
width, height: integer;
MapRec:array of array of TMapInfo ;
function TForm1.loadmapinfo (mapfile: string): Boolean;//装载文件头部信息;
var
fhandle,k: integer
//文件句柄;
header: TMapHeader;//文件头;
begin
if FileExists (mapfile) then
begin //找到文件;
fhandle := FileOpen (mapfile, fmOpenRead )
//打开文件;
if fhandle > 0 then begin
FileRead (fhandle, header, sizeof(TMapHeader));//读文件头
width := header.Width
//地图宽度;
height := header.Height;//得到地图高度
SetLength(MapRec,width,height);
FileSeek (fhandle, sizeof(TMapHeader),0);
k:=fileread(fhandle,MapRec[0,0],sizeof(TMapInfo)*(width)*(height));
end;
FileClose (fhandle);
end;
result:=false;
end;
错误:不能正确读出文件,尤其是文件比较大时可k :=-1
另外多维动态数组怎么才能释放其内存?还请各位高手指点!