kofwoool 发表于 2024-1-13 11:51 g_MapLattice2[nMapLattice] 这个全局的数组存放的是啥呀 |
lzq2024 发表于 2024-5-21 19:06 算是解决了把 |
我是你的天空 发表于 2024-1-12 21:06 请问你解决了吗 |
求一个能看懂的 可以付费 |
大佬 不会Delphi啊 看不懂啊 |
研究了 就是看出字节 第一个是不是可以走 后门 三个字节 还是不知道怎么解析啊 |
我是你的天空 发表于 2024-1-13 21:21 这就是答案了 |
kofwoool 发表于 2024-1-13 11:52 大佬 不会Delphi啊 看不懂啊 |
TMapHeader = packed record //52 Bytes wWidth: word; //宽度 wHeight: word; //高度 sTitle: string[16]; //标题 UpdateDate: TDateTime; //更新日期 Reserved: array[0..22] of char; //保留字节 end; TMapHeader_Wol = packed record nFlag: Integer; nMapType: Integer; nWidth: Integer; nHeight: Integer; Reserved: array[0..15] of char; end; TMirMapHead = packed record wWidth: DWORD; wHeight: DWORD; Title: array[0..15] of char; end; TMapUnitInfo = packed record wBkImg: word; wMidImg: word; wFrImg: word; btDoorIndex: byte; btDoorOffset: byte; btAniFrame: byte; btAniTick: byte; btArea: byte; btLight: byte; end; pTMapUnitInfo = ^TMapUnitInfo; TMap = array[0..1000 * 1000 - 1] of TMapUnitInfo; pTMap = ^TMap; TWolMapLattice = packed record nWidth: Integer; nHeight: Integer; nMapFlag: Integer; end; pTWolMapLattice = ^TWolMapLattice; TMap_Wol = array[0..1000 * 1000 - 1] of byte; pTMap_Wol = ^TMap_Wol; TMapCellinfo = record chFlag: byte; ObjList: TList; end; pTMapCellinfo = ^TMapCellinfo; |
function TEnvirnoment.LoadMapData(sMapFile: string): Boolean; //004B54E0 var fHandle : Integer; Header : TMapHeader; nMapSize : Integer; n24, nW, nH : Integer; MapBuffer : pTMap; Point : Integer; Door : pTDoorInfo; i : Integer; MapCellInfo : pTMapCellinfo; begin Result := False; try if FileExists(sMapFile) then begin fHandle := FileOpen(sMapFile, fmOpenRead or fmShareExclusive); if fHandle > 0 then begin FileRead(fHandle, Header, SizeOf(TMapHeader)); m_nWidth := Header.wWidth; m_nHeight := Header.wHeight; Initialize(m_nWidth, m_nHeight); nMapSize := m_nWidth * SizeOf(TMapUnitInfo) * m_nHeight; MapBuffer := AllocMem(nMapSize); FileRead(fHandle, MapBuffer^, nMapSize); FileClose(fHandle); SetLength(m_MapData, Header.wWidth, Header.wHeight); //路点 for nW := 0 to m_nWidth - 1 do begin n24 := nW * m_nHeight; for nH := 0 to m_nHeight - 1 do begin if (MapBuffer[n24 + nH].wBkImg) and $8000 = 0 then m_MapData[nW, nH] := ttNormal else m_MapData[nW, nH] := ttObstacle; if (MapBuffer[n24 + nH].wBkImg) and $8000 <> 0 then begin //背景图 MapCellInfo := @m_MapCellArray[n24 + nH]; MapCellInfo.chFlag := 1; end; if MapBuffer[n24 + nH].wFrImg and $8000 <> 0 then begin //前景图(障碍物) MapCellInfo := @m_MapCellArray[n24 + nH]; MapCellInfo.chFlag := 2; end; if MapBuffer[n24 + nH].btDoorIndex and $80 <> 0 then begin //门点 Point := (MapBuffer[n24 + nH].btDoorIndex and $7F); if Point > 0 then begin New(Door); Door.nX := nW; Door.nY := nH; Door.n081 := Point; Door.Status := nil; for i := 0 to m_DoorList.Count - 1 do begin if abs(pTDoorInfo(m_DoorList.Items[i]).nX - Door.nX) <= 10 then begin if abs(pTDoorInfo(m_DoorList.Items[i]).nY - Door.nY) <= 10 then begin if pTDoorInfo(m_DoorList.Items[i]).n081 = Point then begin Door.Status := pTDoorInfo(m_DoorList.Items[i]).Status; Inc(Door.Status.nRefCount); Break; end; end; end; end; if Door.Status = nil then begin New(Door.Status); Door.Status.boOpened := False; Door.Status.bo01 := False; Door.Status.n04 := 0; Door.Status.dwOpenTick := 0; Door.Status.nRefCount := 1; end; m_DoorList.Add(Door); end; end; end; end; FreeMem(MapBuffer); Result := True; end; end; except Result := False; end; end; function TEnvirnoment.LoadNmpData(sMapFile: string): Boolean; var fHandle : Integer; Header : TMapHeader_Wol; nMapSize : Integer; nPoint, nW, nH : Integer; MapBuffer : pTMap_Wol; MapCellInfo : pTMapCellinfo; nMapLattice, nMapLattice2 : byte; nCount : Integer; WolMapLattice : pTWolMapLattice; wMapLattice : word; begin Result := False; if FileExists(sMapFile) then begin fHandle := FileOpen(sMapFile, fmOpenRead or fmShareExclusive); if fHandle > 0 then begin FileRead(fHandle, Header, SizeOf(TMapHeader_Wol)); {Read NmpFile Header} if (Header.nMapType in [1, 3, 5..7, 9, $A, $B, $C]) then begin {Filtrate} m_nWidth := Header.nWidth; {Evaluate Width} m_nHeight := Header.nHeight; {Evaluate Height} Initialize(m_nWidth, m_nHeight); {Initialize X Y} nMapSize := FileSize(sMapFile) - SizeOf(TMapHeader_Wol); {Get MapFile Size} MapBuffer := AllocMem(nMapSize); FileRead(fHandle, MapBuffer^, nMapSize); FileClose(fHandle); SetLength(m_MapData, m_nWidth, m_nHeight); //路点 nCount := 0; for nH := 0 to m_nHeight - 1 do begin for nW := 0 to m_nWidth - 1 do begin nPoint := nW * m_nHeight; MapCellInfo := @m_MapCellArray[nPoint + nH]; if nCount <= nMapSize then begin case Header.nMapType of 1: begin {TG MapFile} WolMapLattice := @MapBuffer[nCount]; if WolMapLattice.nMapFlag > 1000 then MapCellInfo.chFlag := 0 else MapCellInfo.chFlag := 1; Inc(nCount, 12); end; 3: begin {Norm MapFile} nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); nMapLattice := nMapLattice and $1F; if nMapLattice > 0 then Inc(nCount, g_MapLattice1[nMapLattice]) else Inc(nCount); end; {HighSpeed MapFile} 5: begin nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); nMapLattice := nMapLattice and $1F; if nMapLattice > 0 then Inc(nCount, g_MapLattice2[nMapLattice]) else Inc(nCount); end; 6: begin {Woool 1.978 MapFile} nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); nMapLattice := nMapLattice and $1F; if nMapLattice > 0 then Inc(nCount, g_MapLattice3[nMapLattice]) else Inc(nCount, 3); end; 7: begin {Woool 1.996 MapFile} nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); nMapLattice := nMapLattice and $1F; if nCount + 1 <= nMapSize then nMapLattice2 := MapBuffer[nCount + 1] else nMapLattice2 := 0; Inc(nCount, g_MapLattice4[nMapLattice and $1F]); if nMapLattice2 > 0 then begin if nMapLattice2 and 1 > 0 then Inc(nCount, 2); if nMapLattice2 and 2 > 0 then Inc(nCount, 4); if nMapLattice2 and 4 > 0 then Inc(nCount, 4); if nMapLattice2 and 8 > 0 then Inc(nCount, 4); if nMapLattice2 and 16 > 0 then Inc(nCount, 4); end; end; 9: begin {Woool 1.998 MapFile} nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); if nCount + 1 <= nMapSize then begin nMapLattice2 := MapBuffer[nCount + 1]; Move(MapBuffer[nCount + 1], wMapLattice, 2); end else nMapLattice2 := 0; Inc(nCount, 3); if nMapLattice and 2 > 0 then Inc(nCount, 4); if nMapLattice and 4 > 0 then Inc(nCount, 4); if nMapLattice and 8 > 0 then Inc(nCount, 4); if nMapLattice and 16 > 0 then Inc(nCount); if nMapLattice and 32 > 0 then Inc(nCount, 4); if nMapLattice and 64 > 0 then Inc(nCount, 4); if nMapLattice2 > 0 then begin if nMapLattice2 and 1 > 0 then Inc(nCount, 2); if nMapLattice2 and 2 > 0 then Inc(nCount, 4); if nMapLattice2 and 4 > 0 then Inc(nCount, 4); if nMapLattice2 and 8 > 0 then Inc(nCount, 4); if nMapLattice2 and 16 > 0 then Inc(nCount, 4); if nMapLattice2 and 32 > 0 then Inc(nCount, 4); end; if (wMapLattice and $2000) > 0 then Inc(nCount, 4); end; 10: begin {Woool 1.999 MapFile} nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); if nCount + 1 <= nMapSize then begin nMapLattice2 := MapBuffer[nCount + 1]; Move(MapBuffer[nCount + 1], wMapLattice, 2); end else nMapLattice2 := 0; Inc(nCount, 3); if nMapLattice and 2 > 0 then Inc(nCount, 4); if nMapLattice and 4 > 0 then Inc(nCount, 4); if nMapLattice and 8 > 0 then Inc(nCount, 4); if nMapLattice and 16 > 0 then Inc(nCount); if nMapLattice and 32 > 0 then Inc(nCount, 4); if nMapLattice and 64 > 0 then Inc(nCount, 4); if nMapLattice2 > 0 then begin if nMapLattice2 and 1 > 0 then Inc(nCount, 4); if nMapLattice2 and 2 > 0 then Inc(nCount, 4); if nMapLattice2 and 4 > 0 then Inc(nCount, 4); if nMapLattice2 and 8 > 0 then Inc(nCount, 4); if nMapLattice2 and 16 > 0 then Inc(nCount, 4); if nMapLattice2 and 32 > 0 then Inc(nCount, 4); end; if (wMapLattice and $2000) > 0 then Inc(nCount, 4); end; $B: begin nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); if nCount + 1 <= nMapSize then begin nMapLattice2 := MapBuffer[nCount + 1]; Move(MapBuffer[nCount + 1], wMapLattice, 2); end else nMapLattice2 := 0; Inc(nCount, 3); if nMapLattice and 2 > 0 then Inc(nCount, 4); if nMapLattice and 4 > 0 then Inc(nCount, 4); if nMapLattice and 8 > 0 then Inc(nCount, 4); if nMapLattice and $10 > 0 then Inc(nCount); if nMapLattice and $20 > 0 then Inc(nCount, 4); if nMapLattice and $40 > 0 then Inc(nCount, 4); if nMapLattice2 and 1 > 0 then Inc(nCount, 4); if nMapLattice2 and 2 > 0 then Inc(nCount, 4); if nMapLattice2 and 4 > 0 then Inc(nCount, 4); if nMapLattice2 and 8 > 0 then Inc(nCount, 4); if nMapLattice2 and $10 > 0 then Inc(nCount, 4); if nMapLattice2 and $20 > 0 then Inc(nCount, 4); if nMapLattice2 and $80 > 0 then Inc(nCount, 4); if wMapLattice and $2000 > 0 then Inc(nCount, 4); if wMapLattice and $4000 > 0 then Inc(nCount); end; $C: begin nMapLattice := MapBuffer[nCount]; MapCellInfo.chFlag := (nMapLattice and $1); if nCount + 1 <= nMapSize then begin nMapLattice2 := MapBuffer[nCount + 1]; Move(MapBuffer[nCount + 1], wMapLattice, 2); end else nMapLattice2 := 0; Inc(nCount, 3); if nMapLattice and 2 > 0 then Inc(nCount, 4); if nMapLattice and 4 > 0 then Inc(nCount, 4); if nMapLattice and 8 > 0 then Inc(nCount, 4); if nMapLattice and $10 > 0 then Inc(nCount); if nMapLattice and $20 > 0 then Inc(nCount, 4); if nMapLattice and $40 > 0 then Inc(nCount, 4); if nMapLattice and $80 > 0 then Inc(nCount, 4); if nMapLattice2 and 1 > 0 then Inc(nCount, 4); if nMapLattice2 and 2 > 0 then Inc(nCount, 4); if nMapLattice2 and 4 > 0 then Inc(nCount, 4); if nMapLattice2 and 8 > 0 then Inc(nCount, 4); if nMapLattice2 and $10 > 0 then Inc(nCount, 4); if nMapLattice2 and $20 > 0 then Inc(nCount, 4); if nMapLattice2 and $80 > 0 then Inc(nCount, 4); if wMapLattice and $2000 > 0 then Inc(nCount, 4); if wMapLattice and $4000 > 0 then Inc(nCount); end; end; end else Break; //路点 if MapCellInfo.chFlag = 0 then m_MapData[nW, nH] := ttNormal else m_MapData[nW, nH] := ttObstacle; end; end; FreeMem(MapBuffer); Result := True; end else FileClose(fHandle); end; end; end; procedure TEnvirnoment.Initialize(nWidth, nHeight: Integer); var nW, nH : Integer; MapCellInfo : pTMapCellinfo; begin if (nWidth > 1) and (nHeight > 1) then begin if m_MapCellArray <> nil then begin for nW := 0 to m_nWidth - 1 do begin for nH := 0 to m_nHeight - 1 do begin MapCellInfo := @m_MapCellArray[nW * m_nHeight + nH]; if MapCellInfo.ObjList <> nil then begin //MapCellInfo.ObjList.free; //MapCellInfo.ObjList := nil; FreeAndNil(MapCellInfo); end; end; end; FreeMem(Pointer(m_MapCellArray)); Pointer(m_MapCellArray) := nil; end; m_nWidth := nWidth; m_nHeight := nHeight; Pointer(m_MapCellArray) := AllocMem((m_nWidth * m_nHeight) * SizeOf(TMapCellinfo)); end; end; |
sitemap|
易语言源码|
易语言教程|
易语言论坛|
易语言模块|
手机版|
广告投放|
精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:[email protected]
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司
( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173