开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1396|回复: 15
打印 上一主题 下一主题
收起左侧

[易语言] 求个解析传世nmp文件读取那个补丁和图片编号

[复制链接]
结帖率:77% (17/22)
跳转到指定楼层
楼主
发表于 2024-1-12 00:09:54 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式   河北省保定市
100精币
求个解析传世nmp文件读取那个补丁和图片编号


回答提醒:如果本帖被关闭无法回复,您有更好的答案帮助楼主解决,请发表至 源码区 可获得加分喔。
友情提醒:本版被采纳的主题可在 申请荣誉值 页面申请荣誉值,获得 1点 荣誉值,荣誉值可兑换荣誉会员、终身vip用户组。
快捷通道:申请荣誉值无答案申请取消悬赏投诉有答案未采纳为最佳
结帖率:100% (1/1)

签到天数: 1 天

沙发
发表于 2024-1-12 09:06:29 | 只看该作者   吉林省长春市
出门左转取定制吧
回复

使用道具 举报

结帖率:93% (142/152)

签到天数: 13 天

板凳
发表于 2024-1-12 11:45:14 | 只看该作者   浙江省杭州市
从小图开始分析
回复

使用道具 举报

结帖率:93% (142/152)

签到天数: 13 天

地板
发表于 2024-1-12 11:48:17 | 只看该作者   浙江省杭州市
  
文件号 = 打开文件 (路径, #读入, #无限制 )
移到文件首 (文件号)
数据 = 读入字节集 (文件号, 32)
标识 = 取字节集数据 (数据, 3, 5)
标识类型 = { 1, 3, 5, 6, 7, 9, 10, 11, 12 }
确认标识 = 假
计次循环首 (取数组成员数 (标识类型), i)
如果真 (标识 = 标识类型 [i])
确认标识 = 真

计次循环尾 ()
如果真 (确认标识 = )
信息框 (“不是支持的地图类型!”, 64, , )
返回 ()

宽 = 取字节集数据 (数据, 2, 9)
高 = 取字节集数据 (数据, 2, 13)

回复

使用道具 举报

结帖率:77% (17/22)
地下
 楼主| 发表于 2024-1-12 20:55:58 | 只看该作者   河北省保定市
kofwoool 发表于 2024-1-12 11:48
[e=0].版本 2

文件号 = 打开文件 (路径, #读入, #无限制)

没有获取素材编号的代码啊?
回复

使用道具 举报

结帖率:77% (17/22)
6
 楼主| 发表于 2024-1-12 21:06:40 | 只看该作者   河北省保定市
kofwoool 发表于 2024-1-12 11:48
[e=0].版本 2

文件号 = 打开文件 (路径, #读入, #无限制)




补充内容 (2024-1-12 21:07):
文件头 信息 我已经实现了
回复

使用道具 举报

结帖率:93% (142/152)

签到天数: 13 天

7
发表于 2024-1-13 11:51:31 | 只看该作者   浙江省杭州市
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;
回复

使用道具 举报

结帖率:93% (142/152)

签到天数: 13 天

8
发表于 2024-1-13 11:52:41 | 只看该作者   浙江省杭州市
  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;
回复

使用道具 举报

结帖率:77% (17/22)
9
 楼主| 发表于 2024-1-13 21:21:40 | 只看该作者   河北省保定市
kofwoool 发表于 2024-1-13 11:52
TMapHeader = packed record                                                                         ...

大佬 不会Delphi啊 看不懂啊
回复

使用道具 举报

结帖率:93% (142/152)

签到天数: 13 天

10
发表于 2024-1-14 12:59:35 | 只看该作者   浙江省杭州市
我是你的天空 发表于 2024-1-13 21:21
大佬 不会Delphi啊 看不懂啊

这就是答案了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:[email protected]
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表