📄 lmain.pas
字号:
boPayCost : Boolean;
nPayMode : Integer;
sSelGateIP : string;
nSelGatePort : Integer;
resourcestring
sSelServerMsg = 'Server: %s/%s-%s:%d';
begin
sServerName := DecodeString(sData);
if (UserInfo.sAccount <> '') and (sServerName <> '') and IsLogin(Config,
UserInfo.nSessionID) then
begin
//MainOutMessage('DBIndex :'+Inttostr(Userinfo.DBIndex));
GetSelGateInfo(Config, sServerName, UserInfo.sGateIPaddr, sSelGateIP,
nSelGatePort);
if (sSelGateIP <> '') and (nSelGatePort > 0) then
begin
if Config.boDynamicIPMode then
sSelGateIP := UserInfo.sGateIPaddr; //增加支动态IP
if Config.boShowDetailMsg then
MainOutMessage(format(sSelServerMsg, [sServerName, Config.sGateIPaddr,
sSelGateIP, nSelGatePort]));
UserInfo.boSelServer := true;
boPayCost := False;
nPayMode := 5;
if UserInfo.nIDHour > 0 then
nPayMode := 2;
if UserInfo.nIPHour > 0 then
nPayMode := 4;
if UserInfo.nIPDay > 0 then
nPayMode := 3;
if UserInfo.nIDDay > 0 then
nPayMode := 1;
if FrmMasSoc.IsNotUserFull(sServerName) then
begin
SessionUpdate(Config, UserInfo.nSessionID, sServerName, boPayCost);
FrmMasSoc.SendServerMsg(SS_OPENSESSION, sServerName,
UserInfo.sAccount + '/' + IntToStr(UserInfo.nSessionID) + '/' +
IntToStr(Integer(UserInfo.boPayCost)) + '/' + IntToStr(Userinfo.DBIndex) + '/'
+ UserInfo.sUserIPaddr+'/'+UserInfo.sGateIPaddr);
DefMsg := MakeDefaultMsg(SM_SELECTSERVER_OK, UserInfo.nSessionID, 0, 0,
0);
SendGateMsg(UserInfo.Socket, UserInfo.sSockIndex, EncodeMessage(DefMsg)
+ EncodeString(sSelGateIP + '/' + IntToStr(nSelGatePort) + '/' +
IntToStr(UserInfo.nSessionID)));
end
else
begin
UserInfo.boSelServer := False;
SessionDel(Config, UserInfo.nSessionID);
DefMsg := MakeDefaultMsg(SM_STARTFAIL, 0, 0, 0, 0);
SendGateMsg(UserInfo.Socket, UserInfo.sSockIndex,
EncodeMessage(DefMsg));
end;
end;
end;
end;
//0046C570
procedure AccountUpdateUserInfo(Config: pTConfig; UserInfo: pTUserInfo; sData:
string);
var
UserEntry : TUserEntry;
UserAddEntry : TUserEntryAdd;
DBRecord : TAccountDBRecord;
nLen : Integer;
sUserEntryMsg : string;
sUserAddEntryMsg : string;
nCode : Integer;
DefMsg : TDefaultMessage;
n10 : Integer;
begin
try
FillChar(UserEntry, SizeOf(TUserEntry), #0);
FillChar(UserAddEntry, SizeOf(TUserEntryAdd), #0);
nLen := GetCodeMsgSize(SizeOf(TUserEntry) * 4 / 3);
sUserEntryMsg := Copy(sData, 1, nLen);
sUserAddEntryMsg := Copy(sData, nLen + 1, length(sData) - nLen);
DecodeBuffer(sUserEntryMsg, @UserEntry, SizeOf(TUserEntry));
DecodeBuffer(sUserAddEntryMsg, @UserAddEntry, SizeOf(TUserEntryAdd));
nCode := -1;
if (UserInfo.sAccount = UserEntry.sAccount) and
CheckAccountName(UserEntry.sAccount) then
begin
try
begin
if (n10 >= 0) then
begin
if DataModule_ID.Get (UserInfo.sAccount, DBRecord) then
begin
DBRecord.UserEntry := UserEntry;
DBRecord.UserEntryAdd := UserAddEntry;
DataModule_ID.Update(DBRecord);
nCode := 1;
end;
end
else
nCode := 0;
end;
finally
end;
end; //0046C74B
if nCode = 1 then
begin
WriteLogMsg(Config, 'upg', UserEntry, UserAddEntry);
DefMsg := MakeDefaultMsg(SM_UPDATEID_SUCCESS, 0, 0, 0, 0);
end
else
begin
DefMsg := MakeDefaultMsg(SM_UPDATEID_FAIL, nCode, 0, 0, 0);
end;
SendGateMsg(UserInfo.Socket, UserInfo.sSockIndex, EncodeMessage(DefMsg));
except
MainOutMessage('TFrmMain.UpdateUserInfo');
end;
end;
procedure AccountGetBackPassword(UserInfo: pTUserInfo;
sData: string);
var
sMsg : string;
sAccount : string;
sQuest1 : string;
sAnswer1 : string;
sQuest2 : string;
sAnswer2 : string;
sPassword : string;
sBirthDay : string;
nCode : Integer;
nIndex : Integer;
DefMsg : TDefaultMessage;
DBRecord : TAccountDBRecord;
begin
{
sMsg := DecodeString(sData);
sMsg := GetValidStr3(sMsg, sAccount, [#9]);
sMsg := GetValidStr3(sMsg, sQuest1, [#9]);
sMsg := GetValidStr3(sMsg, sAnswer1, [#9]);
sMsg := GetValidStr3(sMsg, sQuest2, [#9]);
sMsg := GetValidStr3(sMsg, sAnswer2, [#9]);
sMsg := GetValidStr3(sMsg, sBirthDay, [#9]);
nCode := 0;
try
if (sAccount <> '') then
begin
nIndex := AccountDB.Index(sAccount);
if (nIndex >= 0) and (AccountDB.Get(nIndex, DBRecord) >= 0) then
begin
if (DBRecord.nErrorCount < 5) or ((GetTickCount - DBRecord.dwActionTick)
> 180000) then
begin
nCode := -1;
if (DBRecord.UserEntry.sQuiz = sQuest1) then
begin
nCode := -3;
if DBRecord.UserEntry.sAnswer = sAnswer1 then
begin
if DBRecord.UserEntryAdd.sBirthDay = sBirthDay then
begin
nCode := 1;
end;
end;
end;
if nCode <> 1 then
begin
if (DBRecord.UserEntryAdd.sQuiz2 = sQuest2) then
begin
nCode := -3;
if DBRecord.UserEntryAdd.sAnswer2 = sAnswer2 then
begin
if DBRecord.UserEntryAdd.sBirthDay = sBirthDay then
begin
nCode := 1;
end;
end;
end;
end;
if nCode = 1 then
begin
sPassword := DBRecord.UserEntry.sPassword;
end
else
begin
Inc(DBRecord.nErrorCount);
DBRecord.dwActionTick := GetTickCount();
AccountDB.Update(nIndex, DBRecord);
end;
end
else
begin
nCode := -2;
if GetTickCount < DBRecord.dwActionTick then
begin
DBRecord.dwActionTick := GetTickCount();
AccountDB.Update(nIndex, DBRecord);
end;
end;
end;
end;
finally
AccountDB.Close;
end;
if nCode = 1 then
begin
DefMsg := MakeDefaultMsg(SM_GETBACKPASSWD_SUCCESS, 0, 0, 0, 0);
SendGateMsg(UserInfo.Socket, UserInfo.sSockIndex, EncodeMessage(DefMsg) +
EncodeString(sPassword));
end
else
begin
DefMsg := MakeDefaultMsg(SM_GETBACKPASSWD_FAIL, nCode, 0, 0, 0);
SendGateMsg(UserInfo.Socket, UserInfo.sSockIndex, EncodeMessage(DefMsg));
end;
}
end;
//0046A500
procedure SendGateMsg(Socket: TCustomWinSocket; sSockIndex,
sMsg: string);
var
sSendMsg : string;
begin
sSendMsg := '%' + sSockIndex + '/#' + sMsg + '!$';
Socket.SendText(sSendMsg);
end;
//0046A104
function IsLogin(Config: pTConfig; nSessionID: Integer): Boolean;
var
ConnInfo : pTConnInfo;
I : Integer;
begin
Result := False;
Config.SessionList.Lock;
try
for I := 0 to Config.SessionList.Count - 1 do
begin
ConnInfo := Config.SessionList.Items[I];
if (ConnInfo.nSessionID = nSessionID) then
begin
Result := true;
break;
end;
end;
finally
Config.SessionList.UnLock;
end;
end;
//00469B54
function IsLogin(Config: pTConfig; sLoginID,sGateIp: string): Boolean;
var
ConnInfo : pTConnInfo;
I : Integer;
begin
Result := False;
Config.SessionList.Lock;
try
for I := 0 to Config.SessionList.Count - 1 do
begin
ConnInfo := Config.SessionList.Items[I];
if (ConnInfo.sAccount = sLoginID) then
begin
Result := true;
break;
end;
end;
finally
Config.SessionList.UnLock;
end;
end;
//00469BE8
procedure SessionKick(Config: pTConfig; sLoginID: string);
var
ConnInfo : pTConnInfo;
I : Integer;
begin
Config.SessionList.Lock;
try
for I := 0 to Config.SessionList.Count - 1 do
begin
ConnInfo := Config.SessionList.Items[I];
if (ConnInfo.sAccount = sLoginID) and not ConnInfo.boKicked then
begin
FrmMasSoc.SendServerMsg(SS_CLOSESESSION, ConnInfo.sServerName,
ConnInfo.sAccount + '/' + IntToStr(ConnInfo.nSessionID));
ConnInfo.dwKickTick := GetTickCount();
ConnInfo.boKicked := true;
end;
end;
finally
Config.SessionList.UnLock;
end;
end;
//00469F00
procedure SessionAdd(Config: pTConfig; sAccount, sIPaddr,sGateIp: string;
nSessionID: Integer; boPayCost, bo11: Boolean);
var
ConnInfo : pTConnInfo;
begin
New(ConnInfo);
ConnInfo.sAccount := sAccount;
ConnInfo.sIPaddr := sIPaddr;
ConnInfo.sGateIp := sGateIp;
ConnInfo.nSessionID := nSessionID;
ConnInfo.boPayCost := boPayCost;
ConnInfo.bo11 := bo11;
ConnInfo.dwKickTick := GetTickCount();
ConnInfo.dwStartTick := GetTickCount();
ConnInfo.boKicked := False;
Config.SessionList.Lock;
try
Config.SessionList.Add(ConnInfo);
finally
Config.SessionList.UnLock;
end;
end;
//0046A5AC
procedure SendGateKickMsg(Socket: TCustomWinSocket;
sSockIndex: string);
var
sSendMsg : string;
begin
sSendMsg := '%+-' + sSockIndex + '$';
Socket.SendText(sSendMsg);
end;
procedure SessionUpdate(Config: pTConfig; nSessionID: Integer; sServerName:
string; boPayCost: Boolean);
var
ConnInfo : pTConnInfo;
I : Integer;
begin
Config.SessionList.Lock;
try
for I := 0 to Config.SessionList.Count - 1 do
begin
ConnInfo := Config.SessionList.Items[I];
if (ConnInfo.nSessionID = nSessionID) then
begin
ConnInfo.sServerName := sServerName;
ConnInfo.bo11 := boPayCost;
break;
end;
end;
finally
Config.SessionList.UnLock;
end;
end;
//00469694
procedure GenServerNameList(Config: pTConfig);
var
I, II : Integer;
boD : Boolean;
begin
try
Config.ServerNameList.Clear;
for I := 0 to Config.nRouteCount - 1 do
begin
boD := true;
for II := 0 to Config.ServerNameList.Count - 1 do
begin
if Config.ServerNameList.Strings[II] = Config.GateRoute[I].sServerName
then
boD := False;
end;
if boD then
Config.ServerNameList.Add(Config.GateRoute[I].sServerName);
end;
except
MainOutMessage('TFrmMain.GenServerNameList');
end;
end;
//00469DB4
procedure SessionClearNoPayMent(Config: pTConfig);
var
I : Integer;
ConnInfo : pTConnInfo;
begin
Config.SessionList.Lock;
try
for I := Config.SessionList.Count - 1 downto 0 do
begin
ConnInfo := Config.SessionList.Items[I];
if not ConnInfo.boKicked and not Config.boTestServer and not ConnInfo.bo11
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -