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

📄 massock.pas

📁 乐都SQL版传奇全套代码,绝对可编译
💻 PAS
📖 第 1 页 / 共 2 页
字号:
          begin                                             //Jacky 增加
            for n10 := nNewIndex to m_ServerList.Count - 1 do
            begin
              MsgServer := m_ServerList.Items[n10];
              if MsgServer.sServerName = MsgServerSort.sServerName then
              begin
                if MsgServer.nServerIndex < MsgServerSort.nServerIndex then
                begin
                  m_ServerList.Insert(n10, MsgServerSort);
                  for n14 := n10 + 1 to m_ServerList.Count - 1 do
                  begin
                    MsgServer := m_ServerList.Items[n14];
                    if (MsgServer.sServerName = MsgServerSort.sServerName) and
                      (MsgServer.nServerIndex = MsgServerSort.nServerIndex) then
                    begin
                      m_ServerList.Delete(n14);
                      exit;
                    end;
                  end;
                  exit;
                end
                else
                begin                                       //004660D1
                  nNewIndex := n10 + 1;
                end;
              end;
            end;                                            //00465FF1
            m_ServerList.Insert(nNewIndex, MsgServerSort);
            exit;
          end;
        end;
      end;
    end;
    m_ServerList.Add(MsgServerSort);
  except
    MainOutMessage('TFrmMasSoc.SortServerList');
  end;
end;


//004665BD

procedure TFrmMasSoc.SendServerMsg(wIdent: Word; sServerName, sMsg: string);
var
  I                                     : Integer;
  MsgServer                             : pTMsgServerInfo;
  sSendMsg                              : string;
  s18                                   : string;
resourcestring
  sFormatMsg                            = '(%d/%s)';
begin
  try
    s18 := LimitName(sServerName);
    sSendMsg := format(sFormatMsg, [wIdent, sMsg]);
    for I := 0 to m_ServerList.Count - 1 do
    begin
      MsgServer := pTMsgServerInfo(m_ServerList.Items[I]);
      if MsgServer.Socket.Connected then
      begin
        if (s18 = '') or (MsgServer.sServerName = '') or
          (CompareText(MsgServer.sServerName, s18) = 0) or (MsgServer.nServerIndex
          = 99) then
        begin
          MsgServer.Socket.SendText(sSendMsg);
        end;
      end;
    end;
  except
    MainOutMessage('TFrmMasSoc.SendServerMsg');
  end;
end;
//004659BC

procedure TFrmMasSoc.LoadServerAddr();
var
  sFileName                             : string;
  LoadList                              : TStringList;
  I, nServerIdx                         : Integer;
  sLineText                             : string;
begin
  sFileName := '.\!ServerAddr.txt';
  nServerIdx := 0;
  FillChar(ServerAddr, SizeOf(ServerAddr), #0);
  if FileExists(sFileName) then
  begin
    LoadList := TStringList.Create;
    LoadList.LoadFromFile(sFileName);
    for I := 0 to LoadList.Count - 1 do
    begin
      sLineText := Trim(LoadList.Strings[I]);
      if (sLineText <> '') and (sLineText[I] <> ';') then
      begin
        if TagCount(sLineText, '.') = 3 then
        begin
          ServerAddr[nServerIdx] := sLineText;
          Inc(nServerIdx);
          if nServerIdx >= 100 then
            break;
        end;
      end;
    end;
    LoadList.Free;
  end;
end;


//00466460

function TFrmMasSoc.GetOnlineHumCount(): Integer;
var
  I, nCount                             : Integer;
  MsgServer                             : pTMsgServerInfo;
begin
  try
    nCount := 0;
    for I := 0 to m_ServerList.Count - 1 do
    begin
      MsgServer := m_ServerList.Items[I];
      if MsgServer.nServerIndex <> 99 then
        Inc(nCount, MsgServer.nOnlineCount);
    end;
    Result := nCount;
  except
    MainOutMessage('TFrmMasSoc.GetOnlineHumCount');
  end;
end;
//00465AD8

function TFrmMasSoc.CheckReadyServers: Boolean;
var
  Config                                : pTConfig;
begin
  Config := @g_Config;
  Result := False;
  if m_ServerList.Count >= Config.nReadyServers then
    Result := true;
end;

//004664B0

procedure TFrmMasSoc.SendServerMsgA(wIdent: Word; sMsg: string);
var
  I                                     : Integer;
  sSendMsg                              : string;
  MsgServer                             : pTMsgServerInfo;
resourcestring
  sFormatMsg                            = '(%d/%s)';
begin
  try
    sSendMsg := format(sFormatMsg, [wIdent, sMsg]);
    for I := 0 to m_ServerList.Count - 1 do
    begin
      MsgServer := pTMsgServerInfo(m_ServerList.Items[I]);
      if MsgServer.Socket.Connected then
        MsgServer.Socket.SendText(sSendMsg);
    end;
  except
    on e: Exception do
    begin
      MainOutMessage('TFrmMasSoc.SendServerMsgA');
      MainOutMessage(e.Message);
    end;
  end;
end;
//00465DE0

function TFrmMasSoc.LimitName(sServerName: string): string;
var
  I                                     : Integer;
begin
  try
    Result := '';
    for I := Low(UserLimit) to High(UserLimit) do
    begin
      if CompareText(UserLimit[I].sServerName, sServerName) = 0 then
      begin
        Result := UserLimit[I].sName;
        break;
      end;
    end;
  except
    MainOutMessage('TFrmMasSoc.LimitName');
  end;
end;
//00465730

procedure TFrmMasSoc.LoadUserLimit();
var
  LoadList                              : TStringList;
  sFileName                             : string;
  I, nC                                 : Integer;
  sLineText, sServerName, s10, s14      : string;

begin
  nC := 0;
  sFileName := '.\!UserLimit.txt';
  if FileExists(sFileName) then
  begin
    LoadList := TStringList.Create;
    LoadList.LoadFromFile(sFileName);
    for I := 0 to LoadList.Count - 1 do
    begin
      sLineText := LoadList.Strings[I];
      sLineText := GetValidStr3(sLineText, sServerName, [' ', #9]);
      sLineText := GetValidStr3(sLineText, s10, [' ', #9]);
      sLineText := GetValidStr3(sLineText, s14, [' ', #9]);
      if sServerName <> '' then
      begin
        UserLimit[nC].sServerName := sServerName;
        UserLimit[nC].sName := s10;
        UserLimit[nC].nLimitCountMax := Str_ToInt(s14, 3000);
        UserLimit[nC].nLimitCountMin := 0;
        Inc(nC);
      end;
    end;
    nUserLimit := nC;
    LoadList.Free;
  end
  else
    ShowMessage('[Critical Failure] file not found. .\!UserLimit.txt');
end;

function TFrmMasSoc.ServerStatus(sServerName: string): Integer;
var
  I                                     : Integer;
  nStatus                               : Integer;
  MsgServer                             : pTMsgServerInfo;
  boServerOnLine                        : Boolean;
begin
  try
    Result := 0;
    boServerOnLine := False;
    for I := 0 to m_ServerList.Count - 1 do
    begin
      MsgServer := m_ServerList.Items[I];
      if (MsgServer.nServerIndex <> 99) and (MsgServer.sServerName = sServerName)
        then
      begin
        boServerOnLine := true;
      end;
    end;
    if not boServerOnLine then
      exit;

    for I := Low(UserLimit) to High(UserLimit) do
    begin
      if UserLimit[I].sServerName = sServerName then
      begin
        if UserLimit[I].nLimitCountMin <= UserLimit[I].nLimitCountMax div 2 then
        begin
          nStatus := 1;                                     //空闲
          break;
        end;

        if UserLimit[I].nLimitCountMin <= UserLimit[I].nLimitCountMax -
          (UserLimit[I].nLimitCountMax div 5) then
        begin
          nStatus := 2;                                     //良好
          break;
        end;
        if UserLimit[I].nLimitCountMin < UserLimit[I].nLimitCountMax then
        begin
          nStatus := 3;                                     //繁忙
          break;
        end;
        if UserLimit[I].nLimitCountMin >= UserLimit[I].nLimitCountMax then
        begin
          nStatus := 4;                                     //满员
          break;
        end;
      end;
    end;
    Result := nStatus;
  except
    MainOutMessage('TFrmMasSoc.ServerStatus');
  end;
end;

end.

⌨️ 快捷键说明

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