⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 humdb.~pa

📁 飘飘的传奇服务端院代码 能编译的 要控件 老大就让我传上去吧
💻 ~PA
📖 第 1 页 / 共 3 页
字号:
unit HumDB;

interface
uses
  Windows,Classes,SysUtils,Forms,MudUtil,Grobal2;
ResourceString
  sDBHeaderDesc     = '传奇游戏数据库文件 2006/07/01';
  sDBIdxHeaderDesc  = '传奇游戏数据库索引文件 2006/07/01';

type
  TDBHeader = packed record  //Size 124
    sDesc       :String[$23]; //0x00    36
    n24         :Integer;    //0x24
    n28         :Integer;    //0x28
    n2C         :Integer;    //0x2C
    n30         :Integer;    //0x30
    n34         :Integer;    //0x34
    n38         :Integer;    //0x38
    n3C         :Integer;    //0x3C
    n40         :Integer;    //0x40
    n44         :Integer;    //0x44
    n48         :Integer;    //0x48
    n4C         :Integer;    //0x4C
    n50         :Integer;    //0x50
    n54         :Integer;    //0x54
    n58         :Integer;    //0x58
    nLastIndex  :Integer;    //0x5C
    dLastDate   :TDateTime;  //0x60
    nHumCount   :Integer;    //0x68
    n6C         :Integer;    //0x6C
    n70         :Integer;    //0x70
    dUpdateDate :TDateTime;  //0x74
  end;
  pTDBHeader = ^TDBHeader;

  TIdxHeader = packed record //Size 124
    sDesc       :String[39]; //0x00
    n2C         :Integer;    //0x2C
    n30         :Integer;    //0x30
    n34         :Integer;    //0x34
    n38         :Integer;    //0x38
    n3C         :Integer;    //0x3C
    n40         :Integer;    //0x40
    n44         :Integer;    //0x44
    n48         :Integer;    //0x48
    n4C         :Integer;    //0x4C
    n50         :Integer;    //0x50
    n54         :Integer;    //0x54
    n58         :Integer;    //0x58
    n5C         :Integer;    //0x5C
    n60         :Integer;    //0x60  95
    n70         :Integer;    //0x70  99
    nQuickCount :Integer;    //0x74  100
    nHumCount   :Integer;    //0x78
    nDeleteCount:Integer;    //0x7C
    nLastIndex  :Integer;    //0x80
    dUpdateDate :TDateTime;  //0x84
  end;
  pTIdxHeader = ^TIdxHeader;

  TNakedAbility = packed record  //Size 20
    DC    :Word;
    MC    :Word;
    SC    :Word;
    AC    :Word;
    MAC   :Word;
    HP    :Word;
    MP    :Word;
    Hit   :Word;
    Speed :Word;
    X2    :Word;
  end;
  pTNakedAbility = ^TNakedAbility;

  TAbility = packed record  //OK    //Size 44
    Level         :Word;  //0x198
    AC            :Word;  //0x19A
    MAC           :Word;  //0x19C
    DC            :Word;  //0x19E
    MC            :Word;  //0x1A0
    SC            :Word;  //0x1A2
    HP            :Word;  //0x1A4
    MP            :Word;  //0x1A6
    MaxHP         :Word;  //0x1A8
    MaxMP         :Word;  //0x1AA
    dw1AC         :Longword;  //0x1AC
    Exp           :Longword;  //0x1B0
    MaxExp        :Longword;  //0x1B4
    Weight        :Word;  //0x1B8
    MaxWeight     :Word;  //0x1BA
    WearWeight    :Word;  //0x1BC
    MaxWearWeight :Word;  //0x1BD
    HandWeight    :Word;  //0x1BE
    MaxHandWeight :Word;  //0x1BF
  end;

  THumItems = record
    MakeIndex :Integer;
    wIndex    :Word;   //物品id
    Dura      :Word;   //当前持久值
    DuraMax   :Word;   //最大持久值
    btValue   :array [0..13] of Byte;
  end;
  pTHumItems = ^THumItems;

  TMagic = record
     wMagIdx   :Word;
     btLevel   :Byte;
     btKey     :Byte;
     nTranPoint:Integer;  //当前持久值
  end;
  pTMagic = ^TMagic;

  TRecordHeader = packed record    //Size 12
     boDeleted     :Boolean;
     nSelectID     :Byte;
     w1            :Word;
     dCreateDate   :TDateTime;  //创建时间
     sName         :String[15]; //0x15  //角色名称   28
  end;
  pTRecordHeader = ^TRecordHeader;

  TQuestUnit  = array [0..34] of Byte;
  TQuestFlag  = array [0..82] of Byte;
  TStatusTime = array [0..11] of Word;

  THumData    = packed record
    sChrName       :String[14]; //0x14  //角色名称
    sCurMap        :String[16]; //0x04  //返城地图   57
    wCurX          :Word;       //0x24  人物所在座标X(2字节) 59
    wCurY          :Word;       //0x28  人物所在座标Y(2字节) 61
    btDir          :Byte;       //0x2C  人物所在方向(1字节) 62
    btHair         :Byte;       //0x2E  人物的头发(1字节)   63
    btSex          :Byte;       //0x2D  人物的性别(1字节)   64
    btJob          :Byte;       //0x2F  人物的职业(1字节)   65
    nGold          :Integer;    //0x30  人物金币数(4字节)   69
    Abil           :TAbility;   //0x34 -> 0x5B    //44 人物属性  113    50
    BonusAbil      :TNakedAbility;          //20                 133
    sHomeMap       :String[17]; //17  0x78  //回城地图               150
    wHomeX         :Word;       //0x8C  //回城座标X                 152
    wHomeY         :Word;       //0x90  //回城座标Y                 154
    n1             :array[0..14] of Byte; //未知
    sMasterName    :String[14];
    boMaster       :Boolean;    //是否是师傅
    btCreditPoint  :Byte;       //声望
    n2             :Word;       //未知
    sStoragePwd    :String[7];  //仓库密码
    btReLevel      :Byte;       //转生等级
    n3             :array[0..22] of Byte; //未知
    nBonusPoint    :Integer;        //属性点
    nGameGold      :Integer;        //元宝
    nGamePoint     :Integer;        //泡点
    nPayMentPoint  :Integer;        //冲值点
    n4             :array[0..3] of Byte;
    nPKPoint       :Word;                //PK值
    btAllowGroup   :Byte;       //允许组队
    btF9           :Byte;
    btAttatckMode  :Byte;
    btIncHealth    :Byte;
    btIncSpell     :Byte;
    btIncHealing   :Byte;
    btFightZoneDieCount:Byte;
    n5             :array[0..1] of Byte;
    sAccount       :String[10];//账号
    btEE           :Byte;
    boLockLogon    :Boolean;
    wContribution  :Word;                //贡献度
    btEF           :Byte;
    nHungerStatus  :Integer;
    boAllowGuildReCall :Boolean;
    wGroupRcallTime    :Word;
    dBodyLuck          :Double;
    boAllowGroupReCall :Boolean;       //17
    QuestUnitOpen  :TQuestUnit;    //35
    QuestUnit      :TQuestUnit;    //35
    sDearName      :String[14];          //老婆名称
    n8             :Word;
    btDivorce      :Byte;                //是否结婚
    n9             :Byte;
    btMarryCount   :Byte;                //结婚次数
    wStatusTimeArr :TStatusTime; //24
    QuestFlag      :TQuestFlag;  //61
    HumItems       :array [0..8]   of THumItems;  //9格装备 衣服  武器  蜡烛 头盔 项链 手镯 手镯 戒指 戒指
    BagItems       :array [0..45]  of THumItems;  //包裹装备
    Magic          :array [0..19]  of TMagic;     //魔法
    StorageItems   :array [0..45]  of THumItems;  //仓库物品
    HumAddItems    :array [0..3]   of THumItems;  //新增4格 护身符 腰带 鞋子 宝石
  end;
  pTHumData = ^THumData;

  {TQuestUnit = array  [0..29] of Byte;
  TQuestFlag = array  [0..9]  of Byte;
  TStatusTime = array [0..11] of Word;

  THumData    = packed record
    sChrName       :String[14]; //0x14  //角色名称
    sCurMap        :String[16]; //0x04  //返城地图   57
    wCurX          :Word;       //0x24  人物所在座标X(2字节) 59
    wCurY          :Word;       //0x28  人物所在座标Y(2字节) 61
    btDir          :Byte;       //0x2C  人物所在方向(1字节) 62
    btHair         :Byte;       //0x2E  人物的头发(1字节)   63
    btSex          :Byte;       //0x2D  人物的性别(1字节)   64
    btJob          :Byte;       //0x2F  人物的职业(1字节)   65
    nGold          :Integer;    //0x30  人物金币数(4字节)   69
    Abil           :TAbility;   //0x34 -> 0x5B    //44 人物属性  113
    BonusAbil      :TNakedAbility;          //20                 133

    sHomeMap       :String[17]; //17  0x78  //回城地图               150
    wHomeX         :Word;       //0x8C  //回城座标X                 152
    wHomeY         :Word;       //0x90  //回城座标Y                 154
    n1             :array[0..14] of Byte; //未知
    sMasterName    :String[14];
    boMaster       :Boolean;    //是否是师傅
    btCreditPoint  :Byte;       //声望
    n2             :Word;       //未知
    sStoragePwd    :String[7];  //仓库密码
    btReLevel      :Byte;       //转生等级
    n3             :array[0..22] of Byte; //未知
    nBonusPoint    :Integer;        //属性点
    nGameGold      :Integer;        //元宝
    nGamePoint     :Integer;        //泡点
    nPayMentPoint  :Integer;        //冲值点
    n4             :array[0..3] of Byte;
    nPKPoint       :Word;                //PK值

    btAllowGroup   :Byte;       //允许组队
    btF9           :Byte;
    btAttatckMode  :Byte;
    btIncHealth    :Byte;
    btIncSpell     :Byte;
    btIncHealing   :Byte;
    btFightZoneDieCount:Byte;
    n5             :array[0..1] of Byte;
    sAccount       :String[10];//账号
    //n5             :array[0..8] of Byte;     //0..8
    btEE           :Byte;
    boLockLogon    :Boolean;
    //n6             :Word;
    wContribution  :Word;                //贡献度
    btEF           :Byte;
    nHungerStatus  :Integer;
    boAllowGuildReCall :Boolean;
    wGroupRcallTime    :Word;//Double
    dBodyLuck          :Double;
    boAllowGroupReCall :Boolean;       //17

    QuestUnitOpen  :TQuestUnit;    //72
    QuestUnit      :TQuestUnit;
    QuestFlag      :TQuestFlag;
    //n7             :array[0..86] of Byte;//未知
    sDearName      :String[14];          //老婆名称
    n8             :Word;
    btDivorce      :Byte;                //是否结婚
    n9             :Byte;
    btMarryCount   :Byte;                //结婚次数
    wStatusTimeArr :TStatusTime; //? //24  12 * 2
    n10            :array [0..82]  of Byte;//未知
    HumItems       :array [0..8]   of THumItems;  //9格装备 衣服  武器  蜡烛 头盔 项链 手镯 手镯 戒指 戒指
    BagItems       :array [0..45]  of THumItems;  //包裹装备
    Magic          :array [0..19]  of TMagic;     //魔法
    StorageItems   :array [0..45]  of THumItems;  //仓库物品
    HumAddItems    :array [0..3]   of THumItems;  //新增4格 护身符 腰带 鞋子 宝石
  end; }

  THumDataInfo   = packed record  //Size 3164
    Header  :TRecordHeader;
    Data    :THumData;
  end;
  pTHumDataInfo = ^THumDataInfo;

  THumInfo = packed record  //Size 72
     Header        :TRecordHeader;
     sChrName      :String[14]; //0x14  //角色名称   44
     sAccount      :String[10]; //账号
     boDeleted     :Boolean;    //是否删除
     bt1           :Byte;       //未知
     dModDate      :TDateTime;
     btCount       :Byte;     //操作计次
     boSelected    :Boolean;  //是否选择
     n6            :array[0..5] of Byte;
  end;
  pTHumInfo = ^THumInfo;

  TIdxRecord = record
    sChrName    :String[15];
    nIndex      :Integer;
  end;
  pTIdxRecord = ^TIdxRecord;


  TFileHumDB = class
    n4               :Integer;      //0x04
    m_nFileHandle    :Integer;      //0x08
    n0C              :Integer;      //0x0C
    m_OnChange       :TNotifyEvent;

    m_boChanged      :Boolean;      //0x18
    m_Header         :TDBHeader;    //0x1C
    m_QuickList      :TQuickList;   //0x98
    m_QuickIDList    :TQuickIDList; //0x9C
    m_DeletedList    :TList;        //0xA0 已被删除的记录号
    m_sDBFileName    :String;       //0xA4
  private
    procedure LoadQuickList;
    procedure Lock;
    procedure UnLock;
    function  UpdateRecord(nIndex:Integer;HumRecord:THumInfo;boNew:Boolean):Boolean;
    function  DeleteRecord(nIndex:Integer):Boolean;
    function  GetRecord(n08:Integer;var HumDBRecord:THumInfo):Boolean;
  public
    constructor Create(sFileName:String);
    destructor Destroy; override;

    function  Open():Boolean;
    function  OpenEx():Boolean;
    procedure Close();
    function  Index(sName:String):Integer;
    function  Get(n08:Integer;var HumDBRecord:THumInfo):Integer;
    function  GetBy(n08:Integer;var HumDBRecord:THumInfo):Boolean;
    function  FindByName(sChrName:String;ChrList:TStringList):Integer;
    function  FindByAccount(sAccount:String;var ChrList:TStringList):Integer;
    function  ChrCountOfAccount(sAccount:String):Integer;
    function  Add(HumRecord:THumInfo):Boolean;
    function  Delete(sName:String):Boolean;
    function  Update(nIndex:Integer;var HumDBRecord:THumInfo):Boolean;
    function  UpdateBy(nIndex:Integer;var HumDBRecord:THumInfo):Boolean;

  end;
  TFileDB = class
    n4          :Integer;        //0x4
    m_nFileHandle :Integer;        //0x08
    nC            :Integer;
    m_OnChange    :TNotifyEvent;   //0x10
    m_boChanged   :Boolean;        //0x18
    m_nLastIndex  :Integer;        //0x1C
    m_dUpdateTime :TDateTime;      //0x20
    m_Header      :TDBHeader;      //0x28
    m_QuickList   :TQuickList;     //0xA4
    m_DeletedList :TList;          //0xA8 已被删除的记录号
    m_sDBFileName :String;         //0xAC
    m_sIdxFileName:String;         //0xB0
  private
    procedure LoadQuickList;
    function  LoadDBIndex():Boolean;
    procedure SaveIndex();
    function  GetRecord(nIndex:Integer;var HumanRCD:THumDataInfo):Boolean;
    function  UpdateRecord(nIndex:Integer;var HumanRCD:THumDataInfo;boNew:Boolean):Boolean;
    function  DeleteRecord(nIndex:Integer):Boolean;
  public
    constructor Create(sFileName:String);
    destructor Destroy; override;
    procedure Lock;
    procedure UnLock;
    function  Open():Boolean;
    function  OpenEx():Boolean;
    procedure Close();
    function  Index(sName:String):Integer;
    function  Get(nIndex:Integer;var HumanRCD:THumDataInfo):Integer;
    function  Update(nIndex:Integer;var HumanRCD:THumDataInfo):Boolean;
    function  Add(var HumanRCD:THumDataInfo):Boolean;
    function  Find(sChrName:String;List:TStrings):Integer;
    procedure Rebuild();
    function  Count():Integer;
    function  Delete(sChrName:String):Boolean;overload;
    function  Delete(nIndex:Integer):Boolean;overload;
  end;
var
  HumChrDB              :TFileHumDB;
  HumDataDB             :TFileDB;
implementation

uses DBShare, HUtil32;

{ TFileHumDB }

constructor TFileHumDB.Create(sFileName: String);//0x0048B73C
begin
  m_sDBFileName := sFileName;
  m_QuickList   := TQuickList.Create;
  m_QuickIDList := TQuickIDList.Create;
  m_DeletedList := TList.Create;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -