📄 dbsmain.pas
字号:
if HumDataDB.Get(nIndex,HumanRCD) < 0 then nCheckCode:= -2;
end else nCheckCode:= -3;
end else nCheckCode:= -4;
finally
HumDataDB.Close();
end;
end;
if nCheckCode = 1 then begin
m_DefMsg:=MakeDefaultMsg(DBR_LOADHUMANRCD,1,0,0,1);
SendSocket(Socket, EncodeMessage(m_DefMsg) + EncodeString(sHumName) + '/' + EncodeBuffer(@HumanRCD.Data,SizeOf(THumData)));
end else begin //0x004A8C7E
m_DefMsg:=MakeDefaultMsg(DBR_LOADHUMANRCD,nCheckCode,0,0,0);
SendSocket(Socket,EncodeMessage(m_DefMsg));
end;
end;
//004A8D38
procedure TFrmDBSrv.SaveHumanRcd(nRecog:Integer;sMsg: String;Socket:TCustomWinSocket);
var
sChrName :String;
sUserID :String;
sHumanRCD :String;
I :Integer;
nIndex :Integer;
bo21 :Boolean;
HumData :THumData;
HumanRCD :THumDataInfo;
HumSession :pTHumSession;
begin
sHumanRCD :=GetValidStr3(sMsg,sUserID,['/']);
sHumanRCD :=GetValidStr3(sHumanRCD,sChrName,['/']);
sUserID :=DecodeString(sUserID);
sChrName :=DecodeString(sChrName);
bo21 :=False;
FillChar(HumData,SizeOf(THumData),#0);
FillChar(HumanRCD,SizeOf(THumDataInfo),#0);
if Length(sHumanRCD) = GetCodeMsgSize(SizeOf(THumData)*4/3) then
DecodeBuffer(sHumanRCD,@HumData,SizeOf(THumData))
else bo21:=True;
if not bo21 then begin
bo21:=True;
try
if HumDataDB.Open then begin
nIndex:=HumDataDB.Index(sChrName);
if nIndex < 0 then begin
HumanRCD.Header.sChrName:=sChrName;
HumanRCD.Data := HumData;
HumDataDB.Add(HumanRCD);
nIndex:=HumDataDB.Index(sChrName);
end;
if nIndex >= 0 then begin
HumDataDB.Get(nIndex, HumanRCD);
HumanRCD.Header.sChrName:=sChrName;
HumanRCD.Data := HumData;
HumDataDB.Update(nIndex,HumanRCD);
bo21:=False;
end;
end;
finally
HumDataDB.Close;
end;
FrmIDSoc.SetSessionSaveRcd(sUserID);
end;
if not bo21 then begin
for i := 0 to HumSessionList.Count - 1 do begin
HumSession:=HumSessionList.Items[i];
if (HumSession.sChrName = sChrName) and (HumSession.nIndex = nRecog) then begin
HumSession.dwTick30:=GetTickCount();
break;
end;
end;
m_DefMsg:=MakeDefaultMsg(DBR_SAVEHUMANRCD,1,0,0,0);
SendSocket(Socket,EncodeMessage(m_DefMsg));
end else begin
m_DefMsg:=MakeDefaultMsg(DBR_LOADHUMANRCD,0,0,0,0);
SendSocket(Socket,EncodeMessage(m_DefMsg));
end;
end;
//004A9104
procedure TFrmDBSrv.SaveHumanRcdEx(sMsg:String;nRecog:Integer;Socket:TCustomWinSocket);
var
sChrName :String;
sUserID :String;
sHumanRCD :String;
I :Integer;
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);
var
i: Integer;
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:='H-QyChr=' + IntToStr(g_nQueryChrCount);
Label9.Caption:='H-NwChr=' + IntToStr(nHackerNewChrCount);
Label10.Caption:='H-DlChr=' + IntToStr(nHackerDelChrCount);
Label11.Caption:='Dubb-Sl=' + IntToStr(nHackerSelChrCount);
try
ShowModule();
//for i := 0 to g_MainMsgList.Count - 1 do begin
// MemoLog.Lines.Add('[' + DateTimeToStr(Now) + '] ' + g_MainMsgList.Strings[i]);
//end;
// g_MainMsgList.Clear;
finally
//LeaveCriticalSection(g_OutMessageCS);
end;
if MemoLog.Lines.Count > 500 then MemoLog.Lines.Clear;
end;
procedure TFrmDBSrv.ShowModule();
var
nIndex: Integer;
dwTempTick, dwAliveTick: LongWord;
function GetModule(nPort: Integer): Boolean;
var
i: Integer;
Items: TListItem;
begin
Result := False;
ListView.Items.BeginUpdate;
try
for i := 0 to FrmDBSrv.ListView.Items.Count - 1 do begin
Items := ListView.Items.Item[i];
if Items.Data <> nil then begin
if Integer(Items.Data) = nPort then begin
Result := True;
break;
end;
end;
end;
finally
ListView.Items.EndUpdate;
end;
end;
procedure DelModule(nPort: Integer);
var
i: Integer;
DelItems: TListItem;
begin
ListView.Items.BeginUpdate;
try
for i := ListView.Items.Count - 1 downto 0 do begin
DelItems := ListView.Items.Item[i];
if DelItems.Data <> nil then begin
if Integer(DelItems.Data) = nPort then begin
ListView.Items.Delete(i);
break;
end;
end;
end;
finally
ListView.Items.EndUpdate;
end;
end;
procedure UpDateModule(nPort: Integer; sName, sAddr, sTimeTick: string);
var
UpDateItems: TListItem;
i: Integer;
begin
ListView.Items.BeginUpdate;
try
if sTimeTick <> '' then begin
for i := 0 to ListView.Items.Count - 1 do begin
UpDateItems := ListView.Items.Item[i];
if UpDateItems.Data <> nil then begin
if Integer(UpDateItems.Data) = nPort then begin
// UpDateItems.Caption := sName;
//UpDateItems.SubItems[0] := sAddr;
UpDateItems.SubItems[1] := sTimeTick;
break;
end;
end;
end;
end;
finally
ListView.Items.EndUpdate;
end;
end;
procedure AddModule(nPort: Integer; sName, sAddr, sTimeTick: string);
var
AddItems: TListItem;
begin
ListView.Items.BeginUpdate;
try
if (nPort > 0) and (sName <> '') and (sAddr <> '') then begin
AddItems := ListView.Items.Add;
AddItems.Data := TObject(nPort);
AddItems.Caption := sName;
AddItems.SubItems.Add(sAddr);
AddItems.SubItems.Add(sTimeTick);
end;
finally
ListView.Items.EndUpdate;
end;
end;
function GetSelectTickStr(): string;
var
s01, s02: string;
begin
s01 := IntToStr(dwKeepAliveTick);
s01 := Copy(s01, Length(s01) - 4, 4);
s02 := IntToStr(GetTickCount + dwKeepAliveTick);
s02 := Copy(s02, Length(s02) - 4, 4);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
Result := format('%s%s%s', [s01, '/', s02]);
end;
function GetIDServerTickStr(): string;
var
s01, s02: string;
begin
s01 := IntToStr(dwKeepIDAliveTick);
s01 := Copy(s01, Length(s01) - 4, 4);
s02 := IntToStr(GetTickCount + dwKeepIDAliveTick);
s02 := Copy(s02, Length(s02) - 4, 4);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
Result := format('%s%s%s', [s01, '/', s02]);
end;
function GetM2ServerTickStr(): string;
var
s01, s02: string;
begin
s01 := IntToStr(dwKeepServerAliveTick);
s01 := Copy(s01, Length(s01) - 4, 4);
s02 := IntToStr(GetTickCount + dwKeepServerAliveTick);
s02 := Copy(s02, Length(s02) - 4, 4);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s01) > 1) and (s01[1] = '0') then s01 := Copy(s01, 2, Length(s01) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
if (Length(s02) > 1) and (s02[1] = '0') then s02 := Copy(s02, 2, Length(s02) - 1);
Result := format('%s%s%s', [s01, '/', s02]);
end;
begin
if UserSocketClientConnected then begin
if GetModule(g_nGatePort) then
UpDateModule(g_nGatePort, '角色网关', User_sRemoteAddress + ':' + IntToStr(User_nRemotePort) + ' → ' + User_sRemoteAddress + ':' + IntToStr(g_nGatePort), GetSelectTickStr())
else AddModule(g_nGatePort, '角色网关', User_sRemoteAddress + ':' + IntToStr(User_nRemotePort) + ' → ' + User_sRemoteAddress + ':' + IntToStr(g_nGatePort), GetSelectTickStr());
end else begin
if GetModule(g_nGatePort) then DelModule(g_nGatePort);
end;
if IDSocketConnected then begin
if GetModule(nIDServerPort) then
UpDateModule(nIDServerPort, sServerName, ID_sRemoteAddress + ':' + IntToStr(ID_nRemotePort) + ' → ' + ID_sRemoteAddress + ':' + IntToStr(nIDServerPort), GetIDServerTickStr())
else AddModule(nIDServerPort, sServerName, ID_sRemoteAddress + ':' + IntToStr(ID_nRemotePort) + ' → ' + ID_sRemoteAddress + ':' + IntToStr(nIDServerPort), GetIDServerTickStr());
end else begin
if GetModule(nIDServerPort) then DelModule(nIDServerPort);
end;
if ServerSocketClientConnected then begin
if GetModule(nServerPort) then
UpDateModule(nServerPort, '游戏中心', Server_sRemoteAddress + ':' + IntToStr(Server_nRemotePort) + ' → ' + Server_sRemoteAddress + ':' + IntToStr(nServerPort), GetM2ServerTickStr())
else AddModule(nServerPort, '游戏中心', Server_sRemoteAddress + ':' + IntToStr(Server_nRemotePort) + ' → ' + Server_sRemoteAddress + ':' + IntToStr(nServerPort), GetM2ServerTickStr());
end else begin
if GetModule(nServerPort) then DelModule(nServerPort);
end;
{if DataManageSocketClientConnected then begin
if GetModule(nDataManagePort) then
UpDateModule(nDataManagePort, '数据管理', DataManage_sRemoteAddress + ':' + IntToStr(DataManage_nRemotePort) + ' → ' + DataManage_sRemoteAddress + ':' + IntToStr(nServerPort), '')
else AddModule(nDataManagePort, '数据管理', DataManage_sRemoteAddress + ':' + IntToStr(DataManage_nRemotePort) + ' → ' + DataManage_sRemoteAddress + ':' + IntToStr(nServerPort), '');
end else begin
if GetModule(nDataManagePort) then DelModule(nDataManagePort);
end;}
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:='-/-';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -