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

📄 mirunit.pas

📁 蓝月英雄版合区工具
💻 PAS
字号:
unit MirUnit;

interface

uses
  Windows, Messages, SysUtils, Classes;

type
  TMirHead = packed record
    Ver: array[0..91] of char;
    UnKown1: Integer;
    UpTime: TDateTime;
    Count: Integer;
    UnKown2: array[0..7] of char;
    UpTime2: TDateTime;
    UnKown3: Integer;
  end;

type
  PMirUser = ^TMirUser;
  TMirUser = packed record
    LoginTime: TDateTime;
    name1Long: ShortInt;
    name1: array[0..14] of char;
    name2Long: ShortInt;
    name2: array[0..13] of char;
    MapLong: Byte;
    Map: array[0..15] of char;
    CX: Word;
    CY: Word;
    Direction: Byte; //方向
    Hair: Byte;
    Sex: Byte;
    Job: Byte;
    Gold: Integer;
    Level: Integer;
    AC: Byte;
    MAC: Byte;
    DC1: Byte;
    DC2: Byte;
    MC1: Byte;
    MC2: Byte;
    SC1: Byte;
    SC2: Byte;
    Hp: Word;
    Mp: Word;
    MaxHp: Word;
    MaxMp: Word;
    Reserved2: Integer;
    Exp: Integer;
    AdExp: Integer;
    UnKown1: array[0..53] of char;
    WifeNameLong: Byte;
    WifeName: array[0..13] of char;
    WifeUnKown: array[0..81] of char;
    IDlong: Byte;
    ID: array[0..9] of char;
    UnKown2: array[0..28] of char;
    HeroNameLong: Byte;
    HeroName: array[0..13] of char;
    MasterLong : Byte;
    Master: array[0..16] of char; //如果是英雄,则是宿主信息
    other: array[0..2839] of char;
  end;

type
  TMirDB = class
  private
    FS: TFileStream;
    FHead: TMirHead;
  public
    MirList: TList;
    tmpList: TList;
    NameList: TStringList;
    IDList: TStringList;
    WifeList: TStringList;
    HeroList: TStringList;
    constructor Create(MirFile: string);
    destructor Destroy; override;
    property MirHead: TMirHead read Fhead;
    procedure Read;
    procedure PosRead(var Buffer; OffSet: Integer; Count: Integer);
    procedure AppendWrite;
  end;

implementation

constructor TMirDB.Create(MirFile: string);
begin
  MirList := TList.Create;
  NameList := TStringList.Create;
  IDList := TStringList.Create;
  WifeList := TStringList.Create;
  HeroList := TStringList.Create;
  FS := TFileStream.Create(MirFile, fmCreate and fmOpenReadWrite or fmShareDenyNone);
  FS.Read(Fhead, SizeOf(TMirHead));
end;

destructor TMirDB.Destroy;
begin
  FS.Free;
end;

procedure TMirDB.PosRead(var Buffer; OffSet: Integer; Count: Integer);
begin
  FS.Position := OffSet;
  FS.Read(Buffer, Count);
end;

procedure TMirDB.Read;
var
  MirUser: PMirUser;
  Index: Integer;
begin
  while FS.Position < FS.Size do
  begin
    New(MirUser);
    FS.Read(MirUser^, SizeOf(TMirUser));
    MirList.Add(MirUser);
    Index := NameList.IndexOf(MirUser^.name1);
    if Index > -1 then Continue;
    NameList.Add(MirUser^.name1);
    IDList.Add(MirUser^.ID);
    WifeList.Add(MirUser^.WifeName);
    HeroList.Add(MirUser^.HeroName);
  end;
end;

procedure TMirDB.AppendWrite;
var
  MirUser: PMirUser;
  AllCount: Integer;
  Nothing: Integer;
begin
  AllCount := MirList.Count + tmpList.Count;
  FS.Seek(104, 0); //设置记录数
  FS.Write(AllCount, SizeOf(Integer));
  FS.Seek(0, soFromEnd);
  FS.Write(Nothing, SizeOF(Integer)); //填充最后4字节
  while tmpList.Count > 0 do
  begin
    MirUser := PMirUser(tmpList[0]);
    FS.Write(MirUser^, SizeOf(TMirUser));
    tmpList.Delete(0);
  end;
end;

end.

⌨️ 快捷键说明

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