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

📄 rundb.~pas

📁 继续更新AFT源代码 现在解决了无法登陆游戏的问题 用0504的dbserver就可以登陆了 去掉了绿字广告 降低内存占用HOO 去掉了大量的验证问题
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
              nRecog:=DefMsg.Recog;

              if (nIdent = DBR_LOADHUMANRCD) and (nRecog = 2) then begin
                  dwTimeOut:=dwTimeOut*2;
              end;
              sStr:=s38;
              boLoadDBOK:=True;
              Result:=True;
              break;
            end else begin//004B3F87
              Inc(g_Config.nLoadDBErrorCount); // -> 004B3FA5
              break;
            end;
        end else begin//004B3F90
          Inc(g_Config.nLoadDBErrorCount);// -> 004B3FA5
          break;
        end;
      end;//004B3FA5
    end else begin//004B3F99
      Sleep(1);
     // Application.ProcessMessages;
    end;
  end;
  //end;//004B3FA5
  if not boLoadDBOK then begin
    if boLoadRcd then begin
      MainOutMessage(sLoadDBTimeOut);
    end else begin
      MainOutMessage(sSaveDBTimeOut);
    end;
  end;//004B3FD7
  if (GetTickCount - dwTimeOutTick) > dwRunDBTimeMax then begin
    dwRunDBTimeMax:=GetTickCount - dwTimeOutTick;
  end;
   g_Config.boDBSocketWorking:=False;
end;
function MakeHumRcdFromLocal(var HumanRcd:THumDataInfo):Boolean;
begin
  FillChar(HumanRcd,SizeOf(THumDataInfo),#0);
  HumanRcd.Data.Abil.Level:=30;
  Result:=True;
end;



function LoadHumRcdFromDB(sAccount,sCharName,sStr:String;var HumanRcd:THumDataInfo;nCertCode:Integer):Boolean; //004B3A68
begin
  Result:=False;
  FillChar(HumanRcd,SizeOf(THumDataInfo),#0);
  if LoadRcd(sAccount,sCharName,sStr,nCertCode,HumanRcd) then begin
    if (HumanRcd.Data.sChrName = sCharName) and ((HumanRcd.Data.sAccount = '') or (HumanRcd.Data.sAccount = sAccount)) then
      Result:=True;
  end;
  Inc(g_Config.nLoadDBCount);
end;
function SaveHumRcdToDB(sAccount,sCharName:String;nSessionID:Integer;var HumanRcd:THumDataInfo):Boolean; //004B3B5C
begin
  Result:=SaveRcd(sAccount,sCharName,nSessionID,HumanRcd);
  Inc(g_Config.nSaveDBCount);
end;


function NewYsRcd(sAccount,sChrName:string;bHair,bJob,bSex:byte;sYsnameMaster:String;nSessionID:Integer):Boolean;
var
  nQueryID:Integer;
  nIdent:Integer;
  nRecog:Integer;
  sStr:String;
begin
  nQueryID:=GetQueryID(@g_Config);
  Result:=False;
  n4EBB68:=101;
  SendDBSockMsg(nQueryID,EncodeMessage(MakeDefaultMsg(DB_NEWYS,nSessionID,0,0,0)) + EncodeString(sAccount + '/' + sChrName + '/' + inttostr(bHair) + '/' + inttostr(bJob)+ '/' + inttostr(bSex)+ '/' + sYsnameMaster));
  if GetDBSockMsg(nQueryID,nIdent,nRecog,sStr,6000,False) then begin
    if (nIdent = DBR_NEWYSRCD) and (nRecog = 1) then
      Result:=True;
  end;
end;




function SaveRcd(sAccount,sCharName:String;nSessionID:Integer;var HumanRcd:THumDataInfo):Boolean; //004B42C8
var
  nQueryID:Integer;
  nIdent:Integer;
  nRecog:Integer;
  sStr:String;
begin
  nQueryID:=GetQueryID(@g_Config);
  Result:=False;
  n4EBB68:=101;
  SendDBSockMsg(nQueryID,EncodeMessage(MakeDefaultMsg(DB_SAVEHUMANRCD,nSessionID,0,0,0)) + EncodeString(sAccount) + '/' + EncodeString(sCharName) + '/' + EncodeBuffer(@HumanRcd,SizeOf(THumDataInfo)));
  if GetDBSockMsg(nQueryID,nIdent,nRecog,sStr,6000,False) then begin
    if (nIdent = DBR_SAVEHUMANRCD) and (nRecog = 1) then
      Result:=True;
  end;
end;

function DBLocalIp():Boolean;
var
  Defmsg:TDefaultMessage;

  nQueryID:Integer;
  nIdent,nRecog:Integer;
  sStr,sDBMsg:String;
  sLocalip :String;
begin
  nQueryID:=GetQueryID(@g_Config);
  DefMsg:=MakeDefaultMsg(DB_M2ASKFORLOCALIP,0,0,0,0);
  sDBMsg:=EncodeMessage(DefMsg);
   
  SendDBSockMsg(nQueryID,sDBMsg+mdbyzstring);
  sStr:='';
  if GetDBSockMsg(nQueryID,nIdent,nRecog,sStr,10000,True) then begin
    Result:=False;
    if nIdent = DBR_LOCALIP then begin

        sStr:=GetValidStr3(sStr,sLocalip,['/']);
        
        g_sLocalip:=myDecodeString(sLocalip);   //
     //   MainOutMessage('g_sLocalip:'+g_sLocalip);
        Result:=true;

    end else Result:=False; //004B4273
  end else Result:=False; //004B4279
end;

//004B4080 
function LoadRcd(sAccount,sCharName,sStr:String;nCertCode:Integer;var HumanRcd:THumDataInfo):Boolean;
var
  Defmsg:TDefaultMessage;
  LoadHuman:TLoadHuman;
  nQueryID:Integer;
  nIdent,nRecog:Integer;
  sHumanRcdStr:String;
  sDBMsg,sDBCharName:String;
begin
  nQueryID:=GetQueryID(@g_Config);
  DefMsg:=MakeDefaultMsg(DB_LOADHUMANRCD,0,0,0,0);
  LoadHuman.sAccount:=sAccount;
  LoadHuman.sChrName:=sCharName;
  LoadHuman.sUserAddr:=sStr;
  LoadHuman.nSessionID:=nCertCode;

  sDBMsg:=EncodeMessage(DefMsg) + EncodeBuffer(@LoadHuman,SizeOf(TLoadHuman));
  n4EBB68:=100;
  {
  MainOutMessage('Send DB Socket Load HumRcd Msg ... ' +
                 LoadHuman.sAccount + '/' +
                 LoadHuman.sChrName + '/' +
                 LoadHuman.sUserAddr + '/' +
                 IntToStr(LoadHuman.nSessionID));
  }
  SendDBSockMsg(nQueryID,sDBMsg);
  sHumanRcdStr:='';
  if GetDBSockMsg(nQueryID,nIdent,nRecog,sHumanRcdStr,6000,True) then begin
    Result:=False;
    if nIdent = DBR_LOADHUMANRCD then begin
      if nRecog = 2 then begin   //HACK 攻击 打开一个文本文件。
       {  while true do begin     //引擎假死
         end;  }
         FrontEngine.Free;
         MagicManager.Free;  
      end;
      if nRecog = 1 then begin
        sHumanRcdStr:=GetValidStr3(sHumanRcdStr,sDBMsg,['/']);
//        MainOutMessage(s24);
        sDBCharName:=DecodeString(sDBMsg);
        if sDBCharName = sCharName then begin
          if GetCodeMsgSize(SizeOf(THumDataInfo)*4/3) = length(sHumanRcdStr) then begin
            DecodeBuffer(sHumanRcdStr,@HumanRcd,SizeOf(THumDataInfo));
            Result:=True;
          end;
        end else Result:=False; //004B4267
      end else Result:=False; //004B426D
    end else Result:=False; //004B4273
  end else Result:=False; //004B4279
end;
//004B3BEC
procedure SendDBSockMsg(nQueryID:Integer;sMsg:String);
var
  sSendMsg:String;
  nCheckCode:Integer;
  sCheckStr:String;
  boSendData:Boolean;
  Config:pTConfig;
  ThreadInfo:pTThreadInfo;
  timeout:TTimeVal;
  writefds:TFDSet;
  nRet:Integer;
  s:TSocket;
begin
  Config:=@g_Config;
  ThreadInfo:=@g_Config.DBSocketThread;
  if not DBSocketConnected then exit;
  EnterCriticalSection(UserDBSection);
  try
    Config.sDBSocketRecvText:='';
  finally
    LeaveCriticalSection(UserDBSection);
  end;
  nCheckCode:=MakeLong(nQueryID xor 170,length(sMsg) + 6);
  sCheckStr:=EncodeBuffer(@nCheckCode,SizeOf(Integer));
  sSendMsg:='#' + IntToStr(nQueryID) + '/' + sMsg  + sCheckStr + '!';
  Config.boDBSocketWorking:=True;
{$IF DBSOCKETMODE = TIMERENGINE}
  FrmMain.DBSocket.Socket.SendText(sSendMsg);
{$ELSE}

  s:=Config.DBSocket;
  boSendData:=False;
  while True do begin
    if not boSendData then Sleep(1)
    else Sleep(0);
    boSendData:=False;
    ThreadInfo.dwRunTick:=GetTickCount();
    ThreadInfo.boActived:=True;
    ThreadInfo.nRunFlag:=128;

    ThreadInfo.nRunFlag:=129;
    timeout.tv_sec:=0;
    timeout.tv_usec:=20;

    writefds.fd_count:=1;
    writefds.fd_array[0]:=s;

    nRet:=select(0,nil,@writefds,nil,@timeout);
    if nRet = SOCKET_ERROR then begin
        nRet:=WSAGetLastError();
        Config.nDBSocketWSAErrCode:=nRet - WSABASEERR;
        Inc(Config.nDBSocketErrorCount);
        if nRet = WSAEWOULDBLOCK then begin
          Continue;
        end;
        if Config.DBSocket = INVALID_SOCKET then break;
        Config.DBSocket:=INVALID_SOCKET;
        Sleep(100);
        Config.boDBSocketConnected:=False;
        break;
    end;
    if nRet <= 0 then begin
      Continue;
    end;
    boSendData:=True;
    nRet:=send(s,sSendMsg[1],length(sSendMsg),0);
    if nRet = SOCKET_ERROR then begin
      Inc(Config.nDBSocketErrorCount);
      Config.nDBSocketWSAErrCode:=WSAGetLastError - WSABASEERR;
      Continue;
    end;
    Inc(Config.nDBSocketSendLen,nRet);
    break;
  end;  
{$IFEND}


end;

//004E3E04
function GetQueryID(Config:pTConfig):Integer;
begin
  Inc(Config.nDBQueryID);
  if Config.nDBQueryID >high(SmallInt) -1 then Config.nDBQueryID:=1;
  Result:=Config.nDBQueryID;
end;
end.

⌨️ 快捷键说明

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