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

📄 lmain.~pas

📁 2009最新 传奇汉化0599代码 传奇汉化
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
unit LMain;

interface

uses
  svn, Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, ExtCtrls, JSocket, SyncObjs, Grids, Buttons,IniFiles,MudUtil,Parse,
  Menus,Grobal2,LSShare, SDK;
type
  TConnInfo = record //Size 0x20 Address: 0x00468601
    sAccount      :String;  //0x00
    sIPaddr       :String;  //0x04
    sServerName   :String;  //0x08
    nSessionID    :Integer; //0x0C
    boPayCost     :Boolean; //0x10
    bo11          :Boolean; //0x11
    dwKickTick    :LongWord;//0x14
    dwStartTick   :LongWord;//0x18
    boKicked      :Boolean; //0x1C
    nLockCount    :Integer;
  end;
  pTConnInfo = ^TConnInfo;
  TGateInfo = record //Size 0x14 Address: 0x004686A0
    Socket          :TCustomWinSocket; //0x00
    sIPaddr         :String;           //0x04
    sReceiveMsg     :String;           //0x08
    UserList        :TList;            //0x0C
    dwKeepAliveTick :LongWord;         //0x10
  end;

  pTGateInfo =^TGateInfo;
  TUserInfo = record //Size 0x68 Address: 0x004686C8
    sAccount          :String;            //0x00
    sUserIPaddr       :String;            //0x0B
    sGateIPaddr       :String;            //用户连接到网关,网关的连接IP
    sSockIndex        :String;            //0x20
    nVersionDate      :Integer;           //0x24
    boCertificationOK :Boolean;           //0x28
    bo29           :Boolean;           //0x29
    bo2A           :Boolean;           //0x2A
    bo2B           :Boolean;           //0x2B
    nSessionID     :Integer;           //0x2C
    boPayCost      :Boolean;           //0x30
    nIDDay         :Integer;           //0x34
    nIDHour        :Integer;           //0x38
    nIPDay         :Integer;           //0x3C
    nIPHour        :Integer;           //0x40
    dtDateTime     :TDateTime;         //0x48
    boSelServer    :Boolean;           //0x50
    bo51           :Boolean;           //0x51
    Socket         :TCustomWinSocket;  //0x54
    sReceiveMsg    :String;            //0x58
    dwTime5C       :LongWord;          //0x5C
    bo60           :Boolean;           //0x60
    bo61           :Boolean;           //0x61
    bo62           :Boolean;           //0x62
    bo63           :Boolean;           //0x63
    dwClientTick   :LongWord;          //0x64
    Gate           :pTGateInfo
  end;
  pTUserInfo = ^TUserInfo;
  TFrmMain=class(TForm)
    GSocket: TServerSocket;
    ExecTimer: TTimer;
    Panel1: TPanel;
    Memo1: TMemo;
    Timer1: TTimer;
    StartTimer: TTimer;
    WebLogTimer: TTimer;
    BtnDump: TSpeedButton;
    LogTimer: TTimer;
    MonitorGrid: TStringGrid;
    Panel2: TPanel;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    LbMasCount: TLabel;
    CkLogin: TCheckBox;
    CbViewLog: TCheckBox;
    BtnView: TSpeedButton;
    CountLogTimer: TTimer;
    BtnShowServerUsers: TSpeedButton;
    MonitorTimer: TTimer;
    SpeedButton2: TSpeedButton;
    MainMenu: TMainMenu;
    MENU_CONTROL: TMenuItem;
    MENU_CONTROL_EXIT: TMenuItem;
    MENU_VIEW: TMenuItem;
    MENU_OPTION: TMenuItem;
    MENU_OPTION_ROUTE: TMenuItem;
    MENU_VIEW_SESSION: TMenuItem;

    procedure FormCreate(Sender : TObject);
    procedure FormDestroy(Sender : TObject);
    procedure ExecTimerTimer(Sender : TObject);
    procedure Memo1DblClick(Sender : TObject);
    procedure Timer1Timer(Sender : TObject);
    procedure StartTimerTimer(Sender : TObject);
    procedure SpeedButton1Click(Sender : TObject);
    procedure BtnViewClick(Sender : TObject);
    procedure CountLogTimerTimer(Sender : TObject);
    procedure BtnShowServerUsersClick(Sender : TObject);
    procedure MonitorTimerTimer(Sender : TObject);
    procedure SpeedButton2Click(Sender : TObject);

    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure GSocketClientConnect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure GSocketClientDisconnect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure GSocketClientError(Sender: TObject; Socket: TCustomWinSocket;
      ErrorEvent: TErrorEvent; var ErrorCode: Integer);
    procedure GSocketClientRead(Sender: TObject; Socket: TCustomWinSocket);
    procedure Panel2DblClick(Sender: TObject);
    procedure CbViewLogClick(Sender: TObject);
    procedure MENU_CONTROL_EXITClick(Sender: TObject);
    procedure MENU_OPTION_ROUTEClick(Sender: TObject);
    procedure MENU_VIEW_SESSIONClick(Sender: TObject);
  
  private
    //sGateIPaddr     :String;      //0x334
    //GateList        :TList;  //0x338
    //SessionList     :TList; //0x33C
    //ServerNameList  :TStringList;   //0x340
    SList_0344      :TStringList;   //0x344
    //AccountCostList :TQuickList;   //0x348
    //IPaddrCostList  :TQuickList;   //0x34C
    ParseList       :TThreadParseList;   //0x350
    //m_boRemoteClose :Boolean;

    procedure GameCenterGetUserAccount(sData:String);
    procedure GameCenterChangeAccountInfo(sData:String);
    procedure OpenRouteConfig();
    { Private declarations }
  public



    procedure MyMessage(var MsgData:TWmCopyData);message WM_COPYDATA;

    { Public declarations }
  end;
  procedure StartService(Config:pTConfig);
  procedure StopService(Config:pTConfig);
  procedure InitializeConfig(Config:pTConfig);
  procedure UnInitializeConfig(Config:pTConfig);
  procedure LoadConfig(Config:pTConfig);
  procedure LoadAddrTable(Config:pTConfig);
  procedure GenServerNameList(Config:pTConfig);

  procedure WriteLogMsg(Config:pTConfig;sType:String;var UserEntry:TUserEntry;var UserAddEntry:TUserEntryAdd);
  procedure SaveContLogMsg(Config:pTConfig;sLogMsg:String);
  
  procedure SendGateMsg(Socket: TCustomWinSocket; sSockIndex,sMsg: String);
  procedure SendGateKickMsg(Socket: TCustomWinSocket;sSockIndex: String);
  procedure SendKeepAlivePacket(Socket:TCustomWinSocket);
  
  procedure SessionAdd(Config:pTConfig;sAccount,sIPaddr:String;nSessionID:Integer;boPayCost,bo11:Boolean);
  procedure SessionDel(Config:pTConfig;nSessionID:Integer);
  procedure SessionKick(Config:pTConfig;sLoginID:String);
  procedure SessionUpdate(Config:pTConfig;nSessionID: Integer; sServerName: String;boPayCost: Boolean);
  procedure SessionClearKick(Config:pTConfig);
  function  IsPayMent(Config:pTConfig;sIPaddr,sAccount:String):Boolean;
  procedure SessionClearNoPayMent(Config:pTConfig);
  function  IsLogin(Config:pTConfig;sLoginID:String):Boolean;overload;
  function  IsLogin(Config:pTConfig;nSessionID:Integer):Boolean;overload;

  function  GetServerListInfo():String;
  procedure GetSelGateInfo(Config:pTConfig;sServerName, sIPaddr: String;var sSelGateIP: String; var nSelGatePort: Integer);
  
  function  KickUser(Config:pTConfig;UserInfo:pTUserInfo):Boolean;
  procedure CloseUser(Config:pTConfig;sAccount: String; nSessionID: Integer);
  
  procedure AccountCreate(Config:pTConfig;UserInfo:pTUserInfo;sData:String);
  procedure AccountChangePassword(Config:pTConfig;UserInfo:pTUserInfo;sData:String);
  procedure AccountCheckProtocol(UserInfo:pTUserInfo;nDate:Integer);
  procedure AccountLogin(Config:pTConfig;UserInfo:pTUserInfo;sData:String);
  procedure AccountSelectServer(Config:pTConfig;UserInfo:pTUserInfo;sData:String);
  procedure AccountUpdateUserInfo(Config:pTConfig;UserInfo:pTUserInfo;sData:String);
  procedure AccountGetBackPassword(UserInfo:pTUserInfo;sData:String);
  
  procedure ReceiveSendUser(Config:pTConfig;sSockIndex:String;GateInfo:pTGateInfo;sData:String);
  procedure ReceiveOpenUser(Config:pTConfig;sSockIndex:String;sIPaddr:String;GateInfo:pTGateInfo);
  procedure ReceiveCloseUser(Config:pTConfig;sSockIndex:String;GateInfo:pTGateInfo);

  procedure ProcessUserMsg(Config:pTConfig;UserInfo:pTUserInfo;sMsg:String);

  procedure DecodeGateData(Config:pTConfig;GateInfo:pTGateInfo);
  procedure DecodeUserData(Config:pTConfig;UserInfo:pTUserInfo);
  procedure ProcessGate(Config:pTConfig);
  
  procedure LoadAccountCostList(Config:pTConfig;QuickList: TQuickList);
  procedure LoadIPaddrCostList(Config:pTConfig;QuickList: TQuickList);
var
  FrmMain: TFrmMain;


implementation

uses IDDB, MasSock, FrmFindId, HUtil32, EDcode, GateSet,
  FAccountView, GrobalSession;

{$R *.DFM}
procedure TFrmMain.OpenRouteConfig;
begin
  FrmGateSetting:=TFrmGateSetting.Create(nil);
  FrmGateSetting.Open;
  FrmGateSetting.Free;
end;
{
procedure TFrmMain.OpenRouteConfig;
var
  Config  :pTConfig;
begin
  Config:=@g_Config;
  if FrmGateSetting.Open then begin
    LoadAddrTable(Config);
  end;
end;
}
procedure TFrmMain.MENU_OPTION_ROUTEClick(Sender: TObject);
begin
  OpenRouteConfig();
end;

procedure TFrmMain.MENU_VIEW_SESSIONClick(Sender: TObject);
begin
  frmGrobalSession:=TfrmGrobalSession.Create(nil);
  frmGrobalSession.Open;
  frmGrobalSession.Free;
end;

procedure TFrmMain.CbViewLogClick(Sender: TObject);
var
  Config  :pTConfig;
begin
  Config:=@g_Config;
  Config.boShowDetailMsg:=CbViewLog.Checked;
end;

//00469778
procedure TFrmMain.GSocketClientConnect(Sender: TObject;
  Socket: TCustomWinSocket);
var
  GateInfo:pTGateInfo;
  Config  :pTConfig;
begin
  Config:=@g_Config;
  if not ExecTimer.Enabled then begin
    Socket.Close;
    exit;
  end;
  New(GateInfo);
  GateInfo.Socket          := Socket;
  GateInfo.sIPaddr         := GetGatePublicAddr(Config,Socket.RemoteAddress);
  GateInfo.sReceiveMsg     := '';
  GateInfo.UserList        := TList.Create;
  GateInfo.dwKeepAliveTick := GetTickCount();
  EnterCriticalSection(Config.GateCriticalSection);
  try
    Config.GateList.Add(GateInfo);
  finally
    LeaveCriticalSection(Config.GateCriticalSection);
  end;
end;
//0x00469898
procedure TFrmMain.GSocketClientDisconnect(Sender: TObject;
  Socket: TCustomWinSocket);
var
  I        :Integer;
  II       :Integer;
  GateInfo :pTGateInfo;
  UserInfo :pTUserInfo;
  Config   :pTConfig;
begin
  Config:=@g_Config;
  EnterCriticalSection(Config.GateCriticalSection);
  try
    for I:= 0 to Config.GateList.Count - 1 do begin
      GateInfo:=Config.GateList.Items[I];
      if GateInfo.Socket = Socket then begin
        for II:=0 to GateInfo.UserList.Count -1 do begin
          UserInfo:=GateInfo.UserList.Items[II];
          if Config.boShowDetailMsg then
            MainOutMessage('Close: ' + UserInfo.sUserIPaddr);
          Dispose(UserInfo);
        end;
        GateInfo.UserList.Free;
        Dispose(GateInfo);
        Config.GateList.Delete(i);
        break;
      end;
    end;
  finally
    LeaveCriticalSection(Config.GateCriticalSection);
  end;
end;

procedure TFrmMain.GSocketClientError(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  ErrorCode:=0;
  Socket.Close;
end;
//00469A60
procedure TFrmMain.GSocketClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  I        :Integer;
  GateInfo :pTGateInfo;
  Config   :pTConfig;
begin
  Config:=@g_Config;
  EnterCriticalSection(Config.GateCriticalSection);
  try
    for I:=0 to Config.GateList.Count -1 do begin
      GateInfo:=Config.GateList.Items[I];
      if GateInfo.Socket = Socket then begin
        GateInfo.sReceiveMsg:=GateInfo.sReceiveMsg + Socket.ReceiveText;
        break;
      end;
    end;
  finally
    LeaveCriticalSection(Config.GateCriticalSection);
  end;
end;

//0046D19C
procedure LoadAddrTable(Config:pTConfig);
var
  LoadList    :TStringList;
  sFileName   :String;
  i           :Integer;
  nRouteIdx   :Integer;
  nSelGateIdx :Integer;
  sLineText,sTitle,sServerName,sGate,sRemote,sPublic,sGatePort:String;
begin
  sFileName:='.\!addrtable.txt';
  LoadList:=TStringList.Create;
  if FileExists(sFileName) then begin
    LoadList.LoadFromFile(sFileName);
    nRouteIdx:=0;
    for i:= 0 to LoadList.Count - 1 do begin
      sLineText:=LoadList.Strings[i];
      if (sLineText <> '') and (sLineText[1] <> ';') then begin
        sLineText:=GetValidStr3(sLineText,sServerName,[' ']);
        sLineText:=GetValidStr3(sLineText,sTitle,[' ']);
        sLineText:=GetValidStr3(sLineText,sRemote,[' ']);
        sLineText:=GetValidStr3(sLineText,sPublic,[' ']);
        sLineText:=Trim(sLineText);
        if (sTitle <> '') and (sRemote <> '') and (sPublic <> '') and (nRouteIdx < 60)then begin
          Config.GateRoute[nRouteIdx].sServerName := sServerName;
          Config.GateRoute[nRouteIdx].sTitle      := sTitle;
          Config.GateRoute[nRouteIdx].sRemoteAddr := sRemote;
          Config.GateRoute[nRouteIdx].sPublicAddr := sPublic;
          nSelGateIdx:=0;
          while (sLineText <> '') do begin
            if nSelGateIdx > 9 then break;
            sLineText:=GetValidStr3(sLineText,sGate,[' ']);
            if sGate <> '' then begin
              if sGate[1] = '*' then begin
                sGate:=Copy(sGate,2,length(sGate) - 1);
                Config.GateRoute[nRouteIdx].Gate[nSelGateIdx].boEnable:=False;
              end else begin
                Config.GateRoute[nRouteIdx].Gate[nSelGateIdx].boEnable:=True;
              end;
              sGatePort:=GetValidStr3(sGate,sGate,[':']);
              Config.GateRoute[nRouteIdx].Gate[nSelGateIdx].sIPaddr := sGate;
              Config.GateRoute[nRouteIdx].Gate[nSelGateIdx].nPort   := Str_ToInt(sGatePort,0);
              Config.GateRoute[nRouteIdx].nSelIdx                   := 0;
              Inc(nSelGateIdx);
            end;//0046D44B
            sLineText:=Trim(sLineText);
          end;
          Inc(nRouteIdx);
        end;
      end;
    end;
    Config.nRouteCount:=nRouteIdx;
  end;//0046D482
  LoadList.Free;
  GenServerNameList(Config);
end;
//00468F84
procedure TFrmMain.FormCreate(Sender : TObject);
var
  nX,nY:Integer;
  Config  :pTConfig;
begin
  Config:=@g_Config;
  g_dwGameCenterHandle:=Str_ToInt(ParamStr(1),0);
  nX:=Str_ToInt(ParamStr(2),-1);
  nY:=Str_ToInt(ParamStr(3),-1);
  if (nX >= 0) or (nY >= 0) then begin
    Left:=nX;
    Top:=nY;
  end;
  Config.boRemoteClose:=False;

⌨️ 快捷键说明

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