📄 dbsmain.pas
字号:
end;
//004A9104
procedure TFrmDBSrv.SaveHumanRcdEx(sMsg:String;nRecog:Integer;Socket:TCustomWinSocket);
var
sChrName :String;
sUserID :String;
sHumanRCD :String;
I :Integer;
bo21 :Boolean;
DefMsg :TDefaultMessage;
HumanRCD :THumDataInfo;
HumSession :pTHumSession;
begin
sHumanRCD:=GetValidStr3(sMsg,sUserID,['/']);
sHumanRCD:=GetValidStr3(sHumanRCD,sChrName,['/']);
sUserID:=DecodeString(sUserID);
sChrName:=DecodeString(sChrName);
for i := 0 to HumSessionList.Count - 1 do begin
HumSession:=HumSessionList.Items[i];
if (HumSession.sChrName = sChrName) and (HumSession.nIndex = nRecog) then begin
HumSession.bo24:=False;
HumSession.Socket:=Socket;
HumSession.bo2C:=True;
HumSession.dwTick30:=GetTickCount();
break;
end;
end;
SaveHumanRcd(nRecog,sMsg,Socket);
end;
procedure TFrmDBSrv.Timer1Timer(Sender : TObject);
begin
LbTransCount.Caption:=IntToStr(n348);
n348:=0;
if ServerList.Count > 0 then
Label1.Caption:='已连接...'
else Label1.Caption:='未连接...';
Label2.Caption:='连接数: ' + IntToStr(ServerList.Count);
LbUserCount.Caption:=IntToStr(FrmUserSoc.GetUserCount);
if boOpenDBBusy then begin
if n4ADB18 > 0 then begin
if not bo4ADB1C then begin
Label4.Caption:='[1/4] ' + IntToStr(ROUND((n4ADB10/n4ADB18) * 1.0e2)) + '% ' +
IntToStr(n4ADB14) + '/' +
IntToStr(n4ADB18);
end;//004A82CA
end;//004A82CA
if n4ADB04 > 0 then begin
if not boHumDBReady then begin
Label4.Caption:='[3/4] ' + IntToStr(ROUND((n4ADAFC/n4ADB04) * 1.0e2)) + '% ' +
IntToStr(n4ADB00) + '/' +
IntToStr(n4ADB04);
end;//004A835B
end;//004A835B
if n4ADAF0 > 0 then begin
if not boDataDBReady then begin
Label4.Caption:='[4/4] ' + IntToStr(ROUND((n4ADAE4/n4ADAF0) * 1.0e2)) + '% ' +
IntToStr(n4ADAE8) + '/' +
IntToStr(n4ADAEC) + '/' +
IntToStr(n4ADAF0);
end;
end;
end;//004A8407
LbAutoClean.Caption:=IntToStr(g_nClearIndex) + '/(' + IntToStr(g_nClearCount) + '/' + IntToStr(g_nClearItemIndexCount) + ')/' + IntToStr(g_nClearRecordCount);
Label8.Caption:='查询角色=' + IntToStr(g_nQueryChrCount);
Label9.Caption:='新建角色=' + IntToStr(nHackerNewChrCount);
Label10.Caption:='删除角色=' + IntToStr(nHackerDelChrCount);
Label11.Caption:='重复角色=' + IntToStr(nHackerSelChrCount);
if MemoLog.Lines.Count > 500 then MemoLog.Lines.Clear;
end;
procedure TFrmDBSrv.FormCreate(Sender : TObject);
var
Conf:TIniFile;
nX,nY:Integer;
begin
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;
m_boRemoteClose:=False;
// SendGameCenterMsg(SG_FORMHANDLE,IntToStr(Self.Handle));
boOpenDBBusy:=True;
label4.Caption:='';
LbAutoClean.Caption:='-/-';
HumChrDB:=nil;
HumDataDB:=nil;
{
Conf:=TIniFile.Create('sConfFileName');
if Conf <> nil then begin
sDataDBFilePath:=Conf.ReadString('DB','Dir',sDataDBFilePath);
sHumDBFilePath:=Conf.ReadString('DB','HumDir',sHumDBFilePath);
sFeedPath:=Conf.ReadString('DB','FeeDir',sFeedPath);
sBackupPath:=Conf.ReadString('DB','Backup',sBackupPath);
sConnectPath:=Conf.ReadString('DB','ConnectDir',sConnectPath);
sLogPath:=Conf.ReadString('DB','LogDir',sLogPath);
nServerPort:=Conf.ReadInteger('Setup','ServerPort',nServerPort);
sServerAddr:=Conf.ReadString('Setup','ServerAddr',sServerAddr);
boViewHackMsg:=Conf.ReadBool('Setup','ViewHackMsg',boViewHackMsg);
sServerName:=Conf.ReadString('Setup','ServerName',sServerName);
Conf.Free;
end;
}
LoadConfig();
ServerList:=TList.Create;
HumSessionList:=TList.Create;
Label5.Caption:='FDB: ' + sDataDBFilePath + 'Mir.DB ' + 'Backup: ' + sBackupPath;
n334:=0;
ServerSocket.Address:=sServerAddr;
ServerSocket.Port:=nServerPort;
ServerSocket.Active:=True;
n4ADBF4:=0;
n4ADBF8:=0;
n4ADBFC:=0;
n4ADC00:=0;
n4ADC04:=0;
n344:=2;
n348:=0;
nHackerNewChrCount:=0;
nHackerDelChrCount:=0;
nHackerSelChrCount:=0;
n4ADC1C:=0;
n4ADC20:=0;
n4ADC24:=0;
n4ADC28:=0;
end;
procedure TFrmDBSrv.FormDestroy(Sender : TObject);
var
i:Integer;
ServerInfo: pTServerInfo;
HumSession:pTHumSession;
begin
if HumDataDB <> nil then HumDataDB.Free;
if HumChrDB <> nil then HumChrDB.Free;
for i:=0 to ServerList.Count -1 do begin
ServerInfo:=ServerList.Items[i];
Dispose(ServerInfo);
end;
ServerList.Free;
for i:=0 to HumSessionList.Count -1 do begin
HumSession:=HumSessionList.Items[i];
Dispose(HumSession);
end;
HumSessionList.Free;
end;
procedure TFrmDBSrv.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if m_boRemoteClose then exit;
// if MessageDlg('是否确定退出数据库服务器?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
if Application.MessageBox('是否确定退出数据库服务器?','确认信息',MB_YESNO + MB_ICONQUESTION) = mrYes then begin
CanClose:=True;
ServerSocket.Active:=False;
MainOutMessage('正在关闭服务器...');
end else begin
CanClose:=False;
end;
end;
procedure TFrmDBSrv.AniTimerTimer(Sender : TObject);
begin
if n334 > 7 then
n334:=0
else
Inc(n334);
case n334 of
0: Label3.Caption:='|';
1: Label3.Caption:='/';
2: Label3.Caption:='--';
3: Label3.Caption:='\';
4: Label3.Caption:='|';
5: Label3.Caption:='/';
6: Label3.Caption:='--';
7: Label3.Caption:='\';
end;
end;
procedure TFrmDBSrv.FormShow(Sender : TObject);
begin
StartTimer.Enabled:=True;
end;
procedure TFrmDBSrv.StartTimerTimer(Sender : TObject);
//0x004A79DC
begin
SendGameCenterMsg(SG_STARTNOW,'正在启动数据库服务器...');
StartTimer.Enabled:=False;
boOpenDBBusy:=True;
HumChrDB:=TFileHumDB.Create(sHumDBFilePath + 'Hum.DB');
HumDataDB:=TFileDB.Create(sDataDBFilePath + 'Mir.DB');
boOpenDBBusy:=False;
boAutoClearDB:=True;
Label4.Caption:='';
FrmIDSoc.OpenConnect();
OutMainMessage('欢迎使用老毒系统软件…');
OutMainMessage('服务器已启动...');
SendGameCenterMsg(SG_STARTOK,'数据库服务器启动完成...');
SendGameCenterMsg(SG_CHECKCODEADDR,IntToStr(Integer(@g_CheckCode)));
end;
procedure TFrmDBSrv.Timer2Timer(Sender : TObject);
var
i:Integer;
HumSession:pTHumSession;
begin
i:=0;
while (True) do begin
if HumSessionList.Count <= i then break;
HumSession:= HumSessionList.Items[i];
if not HumSession.bo24 then begin
if HumSession.bo2C then begin
if (GetTickCount - HumSession.dwTick30) > 20 * 1000 then begin
Dispose(HumSession);
HumSessionList.Delete(i);
Continue;
end;
end else begin//004A868F
if (GetTickCount - HumSession.dwTick30) > 2 * 60 * 1000 then begin
Dispose(HumSession);
HumSessionList.Delete(i);
Continue;
end;
end;
end;//004A86D2
if (GetTickCount - HumSession.dwTick30) > 40 * 60 * 1000 then begin
Dispose(HumSession);
HumSessionList.Delete(i);
Continue;
end;
Inc(i);
end;
end;
procedure TFrmDBSrv.BtnUserDBToolClick(Sender : TObject);
begin
if boHumDBReady and boDataDBReady then
FrmIDHum.Show;
end;
procedure TFrmDBSrv.BtnReloadAddrClick(Sender : TObject);
begin
FrmUserSoc.LoadServerInfo();
LoadIPTable();
LoadGateID();
OutMainMessage('重新加载网关完成...');
end;
procedure TFrmDBSrv.BtnEditAddrsClick(Sender : TObject);
begin
FrmEditAddr.Open();
end;
procedure TFrmDBSrv.CkViewHackMsgClick(Sender : TObject);
var
Conf:TIniFile;
begin
Conf:=TIniFile.Create(sConfFileName);
if Conf <> nil then begin
Conf.WriteBool('Setup','ViewHackMsg',CkViewHackMsg.Checked);
Conf.Free;
end;
end;
procedure TFrmDBSrv.MainOutMessage(sMsg: String);
begin
MemoLog.Lines.Add(sMsg)
end;
//004A80DC
procedure TFrmDBSrv.ClearSocket(Socket: TCustomWinSocket);
var
nIndex:integer;
HumSession:pTHumSession;
begin
nIndex:=0;
while (True) do begin
if HumSessionList.Count <= nIndex then break;
HumSession:=HumSessionList.Items[nIndex];
if HumSession.Socket = Socket then begin
Dispose(HumSession);
HumSessionList.Delete(nIndex);
Continue;
end;
Inc(nIndex);
end;
end;
function TFrmDBSrv.CopyHumData(sSrcChrName, sDestChrName,
sUserID: String): Boolean;//0x004A8864
var
n14 :Integer;
bo15 :Boolean;
HumanRCD :THumDataInfo;
begin
Result:=False;
bo15:=False;
try
if HumDataDB.Open then begin
n14:=HumDataDB.Index(sSrcChrName);
if (n14 >= 0) and (HumDataDB.Get(n14,HumanRCD) >= 0) then bo15:=True;
if bo15 then begin
n14:=HumDataDB.Index(sDestChrName);
if (n14 >= 0) then begin
HumanRCD.Header.sName := sDestChrName;
HumanRCD.Data.sChrName := sDestChrName;
HumanRCD.Data.sAccount := sUserID;
HumDataDB.Update(n14,HumanRCD);
Result:=True;
end;
end;
end;
finally
HumDataDB.Close;
end;
end;
procedure TFrmDBSrv.DelHum(sChrName: String);
//0x004A89F4
begin
try
if HumChrDB.Open then HumChrDB.Delete(sChrName);
finally
HumChrDB.Close;
end;
end;
procedure TFrmDBSrv.MENU_MANAGE_DATAClick(Sender: TObject);
begin
if boHumDBReady and boDataDBReady then
FrmIDHum.Show;
end;
procedure TFrmDBSrv.MENU_MANAGE_TOOLClick(Sender: TObject);
begin
frmDBTool.Top:=Self.Top + 20;
frmDBTool.Left:=Self.Left;
frmDBTool.Open();
end;
procedure TFrmDBSrv.MyMessage(var MsgData: TWmCopyData);
var
sData:String;
ProgramType:TProgamType;
wIdent:Word;
begin
wIdent:=HiWord(MsgData.From);
// ProgramType:=TProgamType(LoWord(MsgData.From));
sData:=StrPas(MsgData.CopyDataStruct^.lpData);
case wIdent of //
GS_QUIT: begin
ServerSocket.Active:=False;
m_boRemoteClose:=True;
Close();
end;
1: ;
2: ;
3: ;
end; // case
end;
procedure TFrmDBSrv.MENU_CONTROL_STARTClick(Sender: TObject);
begin
if Sender = MENU_CONTROL_START then begin
end else
if Sender = MENU_OPTION_GAMEGATE then begin
frmRouteManage.Open;
end;
end;
procedure TFrmDBSrv.Exit1Click(Sender: TObject);
begin
Close;
end;
procedure TFrmDBSrv.N2Click(Sender: TObject);
begin
//showmessage(BoolToStr(CheckChrName('老毒')));
end;
procedure TFrmDBSrv.N4Click(Sender: TObject);
begin
MainOutMessage('欢迎使用老毒系统软件…');
MainOutMessage('引擎版本: 1.10 Build 20090909');
MainOutMessage('更新日期: 2009/09/09');
MainOutMessage('程序制作: 老毒(Colin)');
end;
procedure TFrmDBSrv.MENU_TEST_SELGATEClick(Sender: TObject);
begin
frmTestSelGate:=TfrmTestSelGate.Create(Owner);
frmTestSelGate.ShowModal;
frmTestSelGate.Free;
end;
procedure TFrmDBSrv.MENU_OPTION_GENERALClick(Sender: TObject);
begin
FrmSetting := TFrmSetting.Create(Owner);
FrmSetting.Open;
FrmSetting.Free;
end;
procedure TFrmDBSrv.G1Click(Sender: TObject);
begin
try
FrmUserSoc.LoadServerInfo();
LoadIPTable();
LoadGateID();
MainOutMessage('加载网关设置完成...');
except
MainOutMessage('加载网关设置失败...');
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -