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

📄 parse.pas

📁 传奇服务端代码 LoginSrvSQL 通讯部分
💻 PAS
字号:
unit Parse;

interface

uses Windows, Classes, SysUtils, MudUtil;

type
  TThreadParseList = class(TThread)
  private
    AccountLoadList: TStringList;
    IPaddrLoadList: TStringList;
    AccountCostList: TQuickList;
    IPaddrCostList: TQuickList;
    bo40: boolean;
    { Private declarations }

  protected
    procedure Execute; override;
  public
    constructor Create(CreateSuspended: boolean);
    destructor Destroy; override;
  end;

implementation

uses LSShare, HUtil32, LMain;



{ Important: Methods and properties of objects in VCL or CLX can only be used
  in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure ThreadParseList.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ ThreadParseList }

constructor TThreadParseList.Create(CreateSuspended: boolean);
begin
  inherited;
  AccountLoadList := TStringList.Create;
  IPaddrLoadList := TStringList.Create;
  AccountCostList := TQuickList.Create;
  IPaddrCostList := TQuickList.Create;
  bo40 := False;
end;

destructor TThreadParseList.Destroy;
begin
  AccountLoadList.Free;
  IPaddrLoadList.Free;
  AccountCostList.Free;
  IPaddrCostList.Free;
  inherited;
end;

procedure TThreadParseList.Execute;
var
  I:      integer;
  dwTick2C: longword;
  s18, s1C, s24, s28: string;
  nC, n10, n14: integer;
  Config: pTConfig;
begin
  Config   := @g_Config;
  dwTick2C := 0;
  while (True) do begin
    if (GetTickCount - dwTick2C) > 5 * 60 * 1000 then begin
      dwTick2C := GetTickCount();
      try
        if FileExists(Config.sFeedIDList) then begin
          AccountLoadList.Clear;
          AccountLoadList.LoadFromFile(Config.sFeedIDList);
          if AccountLoadList.Count > 0 then begin
            AccountCostList.Clear;
            for I := 0 to AccountLoadList.Count - 1 do begin
              s18 := Trim(AccountLoadList.Strings[i]);
              s18 := GetValidStr3(s18, s1C, [' ', #9]);
              s18 := GetValidStr3(s18, s24, [' ', #9]);
              s18 := GetValidStr3(s18, s28, [' ', #9]);
              n10 := Str_ToInt(s24, 0);
              n14 := Str_ToInt(s28, 0);
              nC  := MakeLong(_MAX(n14, 0), _MAX(n10, 0));
              AccountCostList.AddRecord(s1C, nC);
              if not bo40 then begin
                if (i mod 100) = 0 then Sleep(1);
              end;
            end;
          end;
          LoadAccountCostList(Config, AccountCostList);
        end;
      except
        MainOutMessage('Exception] loading on IDStrList.');
      end;

      try
        if FileExists(Config.sFeedIPList) then begin
          IPaddrLoadList.Clear;
          IPaddrLoadList.LoadFromFile(Config.sFeedIPList);
          if IPaddrLoadList.Count > 0 then begin
            IPaddrCostList.Clear;
            for I := 0 to IPaddrLoadList.Count - 1 do begin
              s18 := Trim(IPaddrLoadList.Strings[i]);
              s18 := GetValidStr3(s18, s1C, [' ', #9]);
              s18 := GetValidStr3(s18, s24, [' ', #9]);
              s18 := GetValidStr3(s18, s28, [' ', #9]);
              n10 := Str_ToInt(s24, 0);
              n14 := Str_ToInt(s28, 0);
              nC  := MakeLong(_MAX(n14, 0), _MAX(n10, 0));
              IPaddrCostList.AddRecord(s1C, nC);
              if not bo40 then begin
                if (i mod 100) = 0 then Sleep(1);
              end;
            end;
          end;
          LoadIPaddrCostList(Config, IPaddrCostList);
        end;
      except
        MainOutMessage('Exception] loading on IPStrList.');
      end;
    end;
    Sleep(10);
    if Self.Terminated then break;
  end;
end;

end.

⌨️ 快捷键说明

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