奇迹Mu登陆实现封包协议

一、选择大区

procedure TGameFunMgr.SelectServerArea;
type
  _Buffer = Packed Record
    _C1:Byte;
    Len:Byte;
    Cmd:Byte;
    Flag:Byte;
  end;
var
  Buffer:_Buffer;
begin
  Buffer._C1:=$C1;
  Buffer.Len:=4;
  Buffer.Cmd:=$F4;
  Buffer.Flag:=6;
  pNtGameSend(Buffer,Buffer.Len,0,0);
end;

二、选择线

procedure TGameFunMgr.SelectLine(Id:Word);
type
  _Buffer = Packed Record
    _C1:Byte;
    Len:Byte;
    Cmd:Byte;
    Flag:Byte;
    Id:Word;
  end;
var
  Buffer:_Buffer;
begin
  Buffer._C1:=$C1;
  Buffer.Len:=6;
  Buffer.Cmd:=$F4;
  Buffer.Flag:=3;
  Buffer.Id:=Id;
  pNtGameSend(Buffer,Buffer.Len,0,0);
end;

三、登陆账号

procedure TGameFunMgr.Login(Account, Psw: PChar);
type
  _Buffer = packed Record
    _C1:Byte;
    Len:Byte;
    Cmd:Byte;
    Flag:Byte;//1
    Account:array [0..9] of Byte;
    Psw:array [0..9] of Byte;
    LTime:Cardinal;
    Ver:array [0..4] of Byte;
    Key:array [0..15] of Byte;
  end;
var
  Buffer:_Buffer;
begin
 
  ZeroMemory(@Buffer,SizeOf(_Buffer));
  Buffer._C1:=$C1;
  Buffer.Len:=49;
  Buffer.Cmd:=$F1;
  Buffer.Flag:=1;
  Buffer.LTime:=GetTickCount();
  CopyMemory(Pointer(Account),Account,Length(Account));
  CopyMemory(@Buffer.Account[0],Account,Length(Account));
  MyLoginEnCode(@Buffer.Account[0],10);
  CopyMemory(@Buffer.Psw[0],Psw,Length(Psw));
  MyLoginEnCode(@Buffer.Psw[0],10);
  CopyMemory(@Buffer.Ver[0],PChar(c_ver),Length(c_ver));
  CopyMemory(@Buffer.Key[0],PChar(c_clientkey),Length(c_clientkey));
  MyEncode(@Buffer,SizeOf(_Buffer));
  pLogin(Buffer.Flag,Buffer.Len-3);
  pNtGameSend(Buffer,Buffer.Len,1,0);
end;

四、创建角色

procedure TGameFunMgr.CreateRole(Name: Pchar);
type
  _Buffer = Packed record
    _C1:Byte;    //C1
    Len:Byte;
    cmd:byte;    //F3
    flag:Byte;   //01
    Name:array [0..9] of Byte;
    Job:Byte;    //$10法师  $20剑士   $30弓箭
  end;
var
  Buffer:_Buffer;
begin
  ZeroMemory(@Buffer,SizeOf(_Buffer));
  Buffer._C1:=$C1;
  Buffer.Len:=$F;
  Buffer.cmd:=$F3;
  Buffer.flag:=1;
  CopyMemory(@Buffer.Name[0],Name,Length(Name));
  Buffer.Job:=$10;
  MyEncode(@Buffer,SizeOf(_Buffer));
  pCreateRole(Buffer.flag,SizeOf(_Buffer) - 3);
  pNtGameSend(Buffer,Buffer.Len,0,0);
end;

五、删除角色

procedure TGameFunMgr.DeleteRole(Name, Key: Pchar;Slot:Integer);
type
  _Buffer = Packed record
    _C1:Byte;    //C1
    Len:Byte;
    cmd:byte;    //F3
    flag:Byte;   //02
    Name:array [0..9] of Byte;
    Key:array [0..6] of Byte;     //身份证后7位
  end;
var
  Buffer:_Buffer;
begin
  PCardinal(RoleSlot)^:= Slot; //对应角色序号
  ZeroMemory(@Buffer,SizeOf(_Buffer));
  Buffer._C1:=$C1;
  Buffer.Len:=$15;
  Buffer.cmd:=$F3;
  Buffer.flag:=2;
  CopyMemory(@Buffer.Name[0],Name,Length(Name));
  CopyMemory(@Buffer.Key[0],Key,Length(Key));
  MyEncode(@Buffer,SizeOf(_Buffer));
  pCreateRole(Buffer.flag,SizeOf(_Buffer) - 3);
  pNtGameSend(Buffer,Buffer.Len,0,0);
end;

六、选角色进入游戏

procedure TGameFunMgr.EnterInGame(Name:Pchar;Slot:Integer);
type
  _Buffer = Packed record
    _C1:Byte;    //C1
    Len:Byte;
    cmd:byte;    //F3
    flag:Byte;   //15
    Name:array [0..9] of Byte;
  end;
var
  Buffer:_Buffer;
begin
  PCardinal(RoleSlot)^:= Slot; //对应角色序号
  ZeroMemory(@Buffer,SizeOf(_Buffer));
  Buffer._C1:=$C1;
  Buffer.Len:=$E;
  Buffer.cmd:=$F3;
  Buffer.flag:=$15;
  CopyMemory(@Buffer.Name[0],Name,Length(Name));
  MyEncode(@Buffer,SizeOf(_Buffer));
  pCreateRole(Buffer.flag,SizeOf(_Buffer) - 3);
  pNtGameSend(Buffer,Buffer.Len,0,0);
end;

七、登出游戏

procedure TGameFunMgr.ExitGame;
type
  _Buffer = Packed record
    _C1:Byte;    //C1
    Len:Byte;
    cmd:byte;    //F1
    data:Word;
  end;
var
  Buffer:_Buffer;
begin
  Buffer._C1:=$c1;
  Buffer.Len:=5;
  Buffer.cmd:=$F1;
  Buffer.data:=$102;
  MyEncode(@Buffer,SizeOf(_Buffer));
  pNtGameSend(Buffer,Buffer.Len,1,0);
end;

 

 

阅读剩余
THE END