📄 lmain.~pas
字号:
//00469F00
procedure SessionAdd(Config:pTConfig;sAccount, sIPaddr: String;
nSessionID: Integer; boPayCost, bo11: Boolean);
var
ConnInfo:pTConnInfo;
begin
New(ConnInfo);
ConnInfo.sAccount := sAccount;
ConnInfo.sIPaddr := sIPaddr;
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 then begin
if (GetTickCount - ConnInfo.dwStartTick) > 60 * 60 * 1000 then begin
ConnInfo.dwStartTick:=GetTickCount();
if not IsPayMent(Config,ConnInfo.sIPaddr,ConnInfo.sAccount) then begin
FrmMasSoc.SendServerMsg(SS_KICKUSER,ConnInfo.sServerName,ConnInfo.sAccount + '/' + IntToStr(ConnInfo.nSessionID));
Dispose(ConnInfo);
Config.SessionList.Delete(I);
end;
end;
end;
end;
finally
Config.SessionList.UnLock;
end;
end;
//0046DD38
procedure LoadIPaddrCostList(Config:pTConfig;QuickList:TQuickList);
begin
try
CS_DB.Enter;
Config.IPaddrCostList.Clear;
Config.IPaddrCostList.AddStrings(QuickList);
finally
CS_DB.Leave;
end;
end;
//0046DCD0
procedure LoadAccountCostList(Config:pTConfig;QuickList: TQuickList);
begin
try
CS_DB.Enter;
Config.AccountCostList.Clear;
Config.AccountCostList.AddStrings(QuickList);
finally
CS_DB.Leave;
end;
end;
procedure TFrmMain.Panel2DblClick(Sender: TObject);
begin
MainOutMessage(GetServerListInfo)
end;
procedure TFrmMain.MyMessage(var MsgData: TWmCopyData);
var
sData :String;
wIdent :Word;
Config :pTConfig;
begin
Config:=@g_Config;
wIdent:=HiWord(MsgData.From);
// ProgramType:=TProgamType(LoWord(MsgData.From));
sData:=StrPas(MsgData.CopyDataStruct^.lpData);
case wIdent of //
GS_QUIT: begin
Config.boRemoteClose:=True;
Close();
end;
GS_USERACCOUNT: begin
GameCenterGetUserAccount(sData);
end;
GS_CHANGEACCOUNTINFO: GameCenterChangeAccountInfo(sData);
3: ;
end; // case
end;
procedure TFrmMain.GameCenterGetUserAccount(sData: String);
var
DBRecord:TAccountDBRecord;
nIndex:Integer;
nCode:Integer;
DefMsg:TDefaultMessage;
begin
try
nCode:=-1;
if AccountDB.Open then begin
nIndex:=AccountDB.Index(sData);
if (nIndex >= 0) and (AccountDB.Get(nIndex,DBRecord) >= 0) then begin
nCode:=1;
end;
end;
finally
AccountDB.Close;
end;
if nCode > 0 then begin
DefMsg:=MakeDefaultMsg(0,nCode,0,0,0);
SendGameCenterMsg(SG_USERACCOUNT,EncodeMessage(DefMsg) + EncodeBuffer(@DBRecord,SizeOf(DBRecord)));
end else begin
DefMsg:=MakeDefaultMsg(SG_USERACCOUNTNOTFOUND,nCode,0,0,0);
SendGameCenterMsg(SG_USERACCOUNT,EncodeMessage(DefMsg));
end;
end;
procedure TFrmMain.GameCenterChangeAccountInfo(sData: String);
var
NewRecord,DBRecord:TAccountDBRecord;
DefMsg:TDefaultMessage;
sDefMsg:String;
nCode,nIndex:integer;
begin
if Length(sData) < DEFBLOCKSIZE then exit;
sDefMsg:=Copy(sData,1,DEFBLOCKSIZE);
sData:=Copy(sData,DEFBLOCKSIZE+1,Length(sData)-DEFBLOCKSIZE);
DefMsg:=DecodeMessage(sDefMsg);
DecodeBuffer(sData,@NewRecord,SizeOf(NewRecord));
nCode:=-1;
try
if AccountDB.Open then begin
nIndex:=AccountDB.Index(NewRecord.UserEntry.sAccount);
if (nIndex >= 0) and (AccountDB.Get(nIndex,DBRecord) >= 0) then begin
if DBRecord.UserEntry.sAccount = NewRecord.UserEntry.sAccount then begin
DBRecord.nErrorCount := 0;
DBRecord.dwActionTick := 0;
DBRecord.UserEntry := NewRecord.UserEntry;
DBRecord.UserEntryAdd := NewRecord.UserEntryAdd;
AccountDB.Update(nIndex,DBRecord);
nCode:=1;
end else begin
nCode:=2;
end;
end;
end;
finally
AccountDB.Close;
end;
DefMsg:=MakeDefaultMsg(0,nCode,0,0,0);
SendGameCenterMsg(SG_USERACCOUNTCHANGESTATUS,EncodeMessage(DefMsg));
end;
procedure SaveContLogMsg(Config:pTConfig;sLogMsg: String);
var
Year, Month, Day, Hour, Min, Sec, MSec: Word;
sLogDir,sLogFileName:String;
LogFile:TextFile;
begin
if sLogMsg = '' then exit;
DecodeDate(Date, Year, Month, Day);
DecodeTime(Time, Hour, Min, Sec, MSec);
if not DirectoryExists(Config.sCountLogDir) then begin
CreateDir(Config.sCountLogDir);
end;
sLogDir:=Config.sCountLogDir + IntToStr(Year) + '-' + IntToStr2(Month);
if not DirectoryExists(sLogDir) then begin
CreateDirectory(PChar(sLogDir),nil);
end;
sLogFileName:=sLogDir + '\' + IntToStr(Year) + '-' + IntToStr2(Month) + '-' + IntToStr2(Day) + '.txt';
AssignFile(LogFile,sLogFileName);
if not FileExists(sLogFileName) then begin
Rewrite(LogFile);
end else begin
Append(LogFile);
end;
sLogMsg:=sLogMsg + #9 + TimeToStr(Time);
WriteLn(LogFile,sLogMsg);
CloseFile(LogFile);
end;
procedure WriteLogMsg(Config:pTConfig;sType: String; var UserEntry: TUserEntry;
var UserAddEntry: TUserEntryAdd);
var
Year, Month, Day: Word;
sLogDir,sLogFileName:String;
LogFile:TextFile;
sLogFormat,sLogMsg:String;
begin
DecodeDate(Date, Year, Month, Day);
if not DirectoryExists(Config.sChrLogDir) then begin
CreateDir(Config.sChrLogDir);
end;
sLogDir:=Config.sChrLogDir + IntToStr(Year) + '-' + IntToStr2(Month);
if not DirectoryExists(sLogDir) then begin
CreateDirectory(PChar(sLogDir),nil);
end;
sLogFileName:=sLogDir + '\Id_' + IntToStr2(Day) + '.log';
AssignFile(LogFile,sLogFileName);
if not FileExists(sLogFileName) then begin
Rewrite(LogFile);
end else begin
Append(LogFile);
end;
sLogFormat:= '*%s*'#9'%s'#9'"%s"'#9'%s'#9'%s'#9'%s'#9'%s'#9'%s'#9'%s'#9'%s'#9'%s'#9'%s'#9'[%s]';
sLogMsg:=format(sLogFormat,[sType,
UserEntry.sAccount,
UserEntry.sPassword,
UserEntry.sUserName,
UserEntry.sSSNo,
UserEntry.sQuiz,
UserEntry.sAnswer,
UserEntry.sEMail,
UserAddEntry.sQuiz2,
UserAddEntry.sAnswer2,
UserAddEntry.sBirthDay,
UserAddEntry.sMobilePhone,
TimeToStr(Now)]);
//sLogMsg:= UserAddEntry.sQuiz2 + UserAddEntry.sAnswer2 + UserAddEntry.sBirthDay + UserAddEntry.sMobilePhone + '[' + TimeToStr(Now) + ']';
WriteLn(LogFile,sLogMsg);
CloseFile(LogFile);
end;
procedure StartService(Config:pTConfig);
begin
InitializeConfig(Config);
LoadConfig(Config);
end;
procedure StopService(Config:pTConfig);
begin
UnInitializeConfig(Config);
end;
procedure InitializeConfig(Config:pTConfig);
ResourceString
sConfigFile = '.\Logsrv.ini';
begin
Config.IniConf:=TIniFile.Create(sConfigFile);
InitializeCriticalSection(Config.GateCriticalSection);
end;
procedure UnInitializeConfig(Config:pTConfig);
begin
Config.IniConf.Free;
DeleteCriticalSection(Config.GateCriticalSection);
end;
procedure LoadConfig(Config:pTConfig);
function LoadConfigString(sSection,sIdent,sDefault: String):String;
var
sString:String;
begin
sString:=Config.IniConf.ReadString(sSection,sIdent,'');
if sString = '' then begin
Config.IniConf.WriteString(sSection,sIdent,sDefault);
Result:=sDefault;
end else begin
Result:=sString;
end;
end;
function LoadConfigInteger(sSection,sIdent:String;nDefault:Integer):Integer;
var
nLoadInteger:Integer;
begin
nLoadInteger:=Config.IniConf.ReadInteger(sSection,sIdent,-1);
if nLoadInteger < 0 then begin
Config.IniConf.WriteInteger(sSection,sIdent,nDefault);
Result:=nDefault;
end else begin
Result:=nLoadInteger;
end;
end;
function LoadConfigBoolean(sSection,sIdent:String;boDefault:Boolean):Boolean;
var
nLoadInteger:Integer;
begin
nLoadInteger:=Config.IniConf.ReadInteger(sSection,sIdent,-1);
if nLoadInteger < 0 then begin
Config.IniConf.WriteBool(sSection,sIdent,boDefault);
Result:=boDefault;
end else begin
Result:=nLoadInteger = 1;
end;
end;
ResourceString
sSectionServer = 'Server';
sSectionDB = 'DB';
sIdentDBServer = 'DBServer';
sIdentFeeServer = 'FeeServer';
sIdentLogServer = 'LogServer';
sIdentGateAddr = 'GateAddr';
sIdentGatePort = 'GatePort';
sIdentServerAddr = 'ServerAddr';
sIdentServerPort = 'ServerPort';
sIdentMonAddr = 'MonAddr';
sIdentMonPort = 'MonPort';
sIdentDBSPort = 'DBSPort';
sIdentFeePort = 'FeePort';
sIdentLogPort = 'LogPort';
sIdentReadyServers = 'ReadyServers';
sIdentTestServer = 'TestServer';
sIdentDynamicIPMode = 'DynamicIPMode';
sIdentIdDir = 'IdDir';
sIdentWebLogDir = 'WebLogDir';
sIdentCountLogDir = 'CountLogDir';
sIdentFeedIDList = 'FeedIDList';
sIdentFeedIPList = 'FeedIPList';
var
ini: TMemIniFile;
begin
Config.sDBServer := LoadConfigString(sSectionServer,sIdentDBServer,Config.sDBServer);
Config.sFeeServer := LoadConfigString(sSectionServer,sIdentFeeServer,Config.sFeeServer);
Config.sLogServer := LoadConfigString(sSectionServer,sIdentLogServer,Config.sLogServer);
Config.sGateAddr := LoadConfigString(sSectionServer,sIdentGateAddr,Config.sGateAddr);
Config.nGatePort := LoadConfigInteger(sSectionServer,sIdentGatePort,Config.nGatePort);
Config.sServerAddr := LoadConfigString(sSectionServer,sIdentServerAddr,Config.sServerAddr);
Config.nServerPort := LoadConfigInteger(sSectionServer,sIdentServerPort,Config.nServerPort);
Config.sMonAddr := LoadConfigString(sSectionServer,sIdentMonAddr,Config.sMonAddr);
Config.nMonPort := LoadConfigInteger(sSectionServer,sIdentMonPort,Config.nMonPort);
Config.nDBSPort := LoadConfigInteger(sSectionServer,sIdentDBSPort,Config.nDBSPort);
Config.nFeePort := LoadConfigInteger(sSectionServer,sIdentFeePort,Config.nFeePort);
Config.nLogPort := LoadConfigInteger(sSectionServer,sIdentLogPort,Config.nLogPort);
Config.nReadyServers := LoadConfigInteger(sSectionServer,sIdentReadyServers,Config.nReadyServers);
Config.boEnableMakingID := LoadConfigBoolean(sSectionServer,sIdentTestServer,Config.boEnableMakingID);
Config.boDynamicIPMode := LoadConfigBoolean(sSectionServer,sIdentDynamicIPMode,Config.boDynamicIPMode);
Config.sIdDir := LoadConfigString(sSectionDB,sIdentIdDir,Config.sIdDir);
Config.sWebLogDir := LoadConfigString(sSectionDB,sIdentWebLogDir,Config.sWebLogDir);
Config.sCountLogDir := LoadConfigString(sSectionDB,sIdentCountLogDir,Config.sCountLogDir);
Config.sFeedIDList := LoadConfigString(sSectionDB,sIdentFeedIDList,Config.sFeedIDList);
Co
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -