📄 svmain.~pas
字号:
end;
{$IFEND}
end;
end;
function LoadAbuseInformation(FileName:String):Boolean;
var
i:integer;
sText:String;
begin
Result:=False;
if FileExists(FileName) then begin
AbuseTextList.Clear;
AbuseTextList.LoadFromFile(FileName);
i:=0;
while (True) do begin
if AbuseTextList.Count <= i then break;
sText:=Trim(AbuseTextList.Strings[i]);
if sText = '' then begin
AbuseTextList.Delete(i);
Continue;
end;
Inc(i);
end;
Result:=True;
end;
end;
procedure LoadServerTable();//004E3E64
var
i,ii:Integer;
LoadList:TStringList;
GateList:TStringList;
SrvNetInfo:pTSrvNetInfo;
sLineText,sGateMsg:String;
sServerIdx,sIPaddr,sPort:String;
begin
for I:=0 to ServerTableList.Count -1 do begin
TList(ServerTableList.Items[I]).Free;
end;
ServerTableList.Clear;
if FileExists('.\!servertable.txt') then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile('.\!servertable.txt');
for I:=0 to LoadList.Count - 1 do begin
sLineText:=Trim(LoadList.Strings[i]);
if (sLineText <> '') and (sLineText[1] <> ';') then begin
sGateMsg:=Trim(GetValidStr3(sLineText, sGateMsg, [' ', #9]));
if sGateMsg <> '' then begin
GateList:=TStringList.Create;
for II:=0 to 30 do begin
if sGateMsg = '' then break;
sGateMsg:=Trim(GetValidStr3(sGateMsg, sIPaddr, [' ', #9]));
sGateMsg:=Trim(GetValidStr3(sGateMsg, sPort, [' ', #9]));
if (sIPaddr <> '') and (sPort <> '') then begin
GateList.AddObject(sIPaddr,TObject(Str_ToInt(sPort,0)));
end;
end;
ServerTableList.Add(GateList);
end;
end;
end;
LoadList.Free;
end else begin
ShowMessage('文件!servertable.txt未找到!!!');
end;
end;
procedure WriteConLog(MsgList:TStringList);
var
I: Integer;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
sLogDir,sLogFileName:String;
LogFile:TextFile;
begin
if MsgList.Count <= 0 then exit;
DecodeDate(Date, Year, Month, Day);
DecodeTime(Time, Hour, Min, Sec, MSec);
if not DirectoryExists(g_Config.sConLogDir) then begin
//CreateDirectory(PChar(g_Config.sConLogDir),nil);
CreateDir(g_Config.sConLogDir);
end;
sLogDir:=g_Config.sConLogDir + IntToStr(Year) + '-' + IntToStr2(Month) + '-' + IntToStr2(Day);
if not DirectoryExists(sLogDir) then begin
CreateDirectory(PChar(sLogDir),nil);
end;
sLogFileName:=sLogDir + '\C-' + IntToStr(nServerIndex) + '-' + IntToStr2(Hour) + 'H' + IntToStr2((Min div 10 * 2) * 5) + 'M.txt';
AssignFile(LogFile,sLogFileName);
if not FileExists(sLogFileName) then begin
Rewrite(LogFile);
end else begin
Append(LogFile);
end;
for I := 0 to MsgList.Count - 1 do begin
WriteLn(LogFile,'1' + #9 + MsgList.Strings[I]);
end; // for
CloseFile(LogFile);
end;
Procedure calcVarmsgcode;
begin
end;
procedure TFrmMain.SaveItemNumber();
var
I:Integer;
begin
try
Config.WriteInteger('Setup','ItemNumber',g_Config.nItemNumber);
Config.WriteInteger('Setup','ItemNumberEx',g_Config.nItemNumberEx);
for I := Low(g_Config.GlobalVal) to High(g_Config.GlobalVal) do begin
Config.WriteInteger('Setup','GlobalVal' + IntToStr(I),g_Config.GlobalVal[I])
end;
for I := Low(g_Config.Globalstr) to High(g_Config.Globalstr) do begin
Config.Writestring('Setup','Globalstr' + IntToStr(I),g_Config.Globalstr[I])
end;
Config.WriteInteger('Setup','WinLotteryCount',g_Config.nWinLotteryCount);
Config.WriteInteger('Setup','NoWinLotteryCount',g_Config.nNoWinLotteryCount);
Config.WriteInteger('Setup','WinLotteryLevel1',g_Config.nWinLotteryLevel1);
Config.WriteInteger('Setup','WinLotteryLevel2',g_Config.nWinLotteryLevel2);
Config.WriteInteger('Setup','WinLotteryLevel3',g_Config.nWinLotteryLevel3);
Config.WriteInteger('Setup','WinLotteryLevel4',g_Config.nWinLotteryLevel4);
Config.WriteInteger('Setup','WinLotteryLevel5',g_Config.nWinLotteryLevel5);
Config.WriteInteger('Setup','WinLotteryLevel6',g_Config.nWinLotteryLevel6);
except
end;
end;
procedure TFrmMain.AppOnIdle (Sender: TObject; var Done: Boolean);
begin
// MainOutMessage ('空闲');
// QMemDecommitOverstock ;
end;
procedure TFrmMain.OnProgramException (Sender: TObject; E: Exception);
begin
MainOutMessage(E.Message);
// raise;
end;
procedure TFrmMain.DBSocketError(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
begin
ErrorCode:=0;
Socket.Close;
end;
procedure TFrmMain.DBSocketRead(Sender: TObject; Socket: TCustomWinSocket);
var
tStr:String;
begin
EnterCriticalSection(UserDBSection);
try
tStr:=Socket.ReceiveText;
g_Config.sDBSocketRecvText:=g_Config.sDBSocketRecvText + tStr;
// MainOutMessage(sDBSocStr[1]);
if not g_Config.boDBSocketWorking then begin
g_Config.sDBSocketRecvText:='';
end;
finally
LeaveCriticalSection(UserDBSection);
end;
end;
procedure TFrmMain.Timer1Timer(Sender: TObject); //004E5418
var
boWriteLog :Boolean;
i :Integer;
nRow :Integer;
wHour :Word;
wMinute :Word;
wSecond :Word;
tSecond :Integer;
sSrvType :String;
sVerType :String;
tTimeCount :Currency;
GateInfo :pTGateInfo;
// sGate,tGate :String;
LogFile :TextFile;
MemoryStream:TMemoryStream;
s28:String;
begin
// Caption:=sCaption + ' [' + sCaptionExtText + ']';
Caption:= format('%s - %s',[mydecodestring(g_sTitleName),sCaption+mydecodestring(USERREGOFF)]);//M2标题显示已注册
EnterCriticalSection(LogMsgCriticalSection);
try
if MemoLog.Lines.Count > 500 then MemoLog.Clear;
boWriteLog:=True;
if MainLogMsgList.Count > 0 then begin
try
if not FileExists(sLogFileName) then begin
AssignFile(LogFile,sLogFileName);
Rewrite(LogFile);
end else begin
AssignFile(LogFile,sLogFileName);
Append(LogFile);
end;
boWriteLog:=False;
except
MemoLog.Lines.Add('保存日志信息出错!!!');
end;
end;
for i:=0 to MainLogMsgList.Count - 1 do begin
MemoLog.Lines.Add(MainLogMsgList.Strings[i]);
if not boWriteLog then begin
Writeln(LogFile,MainLogMsgList.Strings[i]);
end;
end;
MainLogMsgList.Clear;
if not boWriteLog then CloseFile(LogFile);
for I := 0 to LogStringList.Count - 1 do begin
MemoryStream:=TMemoryStream.Create;
try
s28:='1' + #9 + IntToStr(g_Config.nServerNumber) + #9 + IntToStr(nServerIndex) + #9 + LogStringList.Strings[I];
MemoryStream.Write(s28[1],length(s28));
LogUDP.SendStream(MemoryStream);
finally
MemoryStream.Free;
end;
end;
LogStringList.Clear;
if LogonCostLogList.Count > 0 then begin
WriteConLog(LogonCostLogList);
end;
LogonCostLogList.Clear;
finally
LeaveCriticalSection(LogMsgCriticalSection);
end;
(*{$IF SoftVersion = VERDEMO}
sVerType:='[D]';
{$ELSEIF SoftVersion = VERFREE}
sVerType:='[F]';
{$ELSEIF SoftVersion = VERSTD}
sVerType:='[S]';
{$ELSEIF SoftVersion = VEROEM}
sVerType:='[O]';
{$ELSEIF SoftVersion = VERPRO}
sVerType:='[P]';
{$ELSEIF SoftVersion = VERENT}
sVerType:='[E]';
{$IFEND} *)
if nServerIndex = 0 then begin
sSrvType:='[M]';
end else begin
if FrmMsgClient.MsgClient.Socket.Connected then begin
sSrvType:='[S]';
end else begin
sSrvType:='[ ]';
end;
end;
//检查线程 运行时间
//g_dwEngineRunTime:=GetTickCount - g_dwEngineTick;
tSecond:=(GetTickCount() - g_dwStartTick) div 1000;
wHour:=tSecond div 3600;
wMinute:=(tSecond div 60) mod 60;
wSecond:=tSecond mod 60;
LbRunTime.Caption:= IntToStr(wHour) + ':' +
IntToStr(wMinute) + ':' +
IntToStr(wSecond) + ' ' + sSrvType + sVerType;{ +
IntToStr(g_dwEngineRunTime) + g_sProcessName + '-' + g_sOldProcessName;}
LbUserCount.Caption:= '(' + IntToStr(UserEngine.MonsterCount) + ')' +
IntToStr(UserEngine.OnlinePlayObject) + '/' +
IntToStr(UserEngine.PlayObjectCount) + '[' +
IntToStr(UserEngine.LoadPlayCount) + '/' +
IntToStr(UserEngine.m_PlayObjectFreeList.Count) + ']';
{
Label1.Caption:= 'Run' + IntToStr(nRunTimeMin) + '/' + IntToStr(nRunTimeMax) + ' ' +
'Soc' + IntToStr(g_nSockCountMin) + '/' + IntToStr(g_nSockCountMax) + ' ' +
'Usr' + IntToStr(g_nUsrTimeMin) + '/' + IntToStr(g_nUsrTimeMax);
}
Label1.Caption:= format('处理(%d/%d) 传输(%d/%d) 角色(%d/%d)',[nRunTimeMin,nRunTimeMax,g_nSockCountMin,g_nSockCountMax,g_nUsrTimeMin,g_nUsrTimeMax]);
{
Label2.Caption:= 'Hum' + IntToStr(g_nHumCountMin) + '/' + IntToStr(g_nHumCountMax) + ' ' +
'Mon' + IntToStr(g_nMonTimeMin) + '/' + IntToStr(g_nMonTimeMax) + ' ' +
'UsrRot' + IntToStr(dwUsrRotCountMin) + '/' + IntToStr(dwUsrRotCountMax) + ' ' +
'Merch' + IntToStr(UserEngine.dwProcessMerchantTimeMin) + '/' + IntToStr(UserEngine.dwProcessMerchantTimeMax) + ' ' +
'Npc' + IntToStr(UserEngine.dwProcessNpcTimeMin) + '/' + IntToStr(UserEngine.dwProcessNpcTimeMax) + ' ' +
'(' + IntToStr(g_nProcessHumanLoopTime) + ')';
}
Label2.Caption:= format('人物(%d/%d) 循环(%d/%d) 交易(%d/%d) 管理(%d/%d) (%d)',[g_nHumCountMin,
g_nHumCountMax,
dwUsrRotCountMin,
dwUsrRotCountMax,
UserEngine.dwProcessMerchantTimeMin,
UserEngine.dwProcessMerchantTimeMax,
UserEngine.dwProcessNpcTimeMin,
UserEngine.dwProcessNpcTimeMax,
g_nProcessHumanLoopTime]);
Label5.Caption:= g_sMonGenInfo1 + ' - ' + g_sMonGenInfo2 + ' ';
{
Label20.Caption:='MonG' + IntToStr(g_nMonGenTime) + '/' + IntToStr(g_nMonGenTimeMin) + '/' + IntToStr(g_nMonGenTimeMax) + ' ' +
'MonP' + IntToStr(g_nMonProcTime) + '/' + IntToStr(g_nMonProcTimeMin) + '/' + IntToStr(g_nMonProcTimeMax) + ' ' +
'ObjRun' + IntToStr(g_nBaseObjTimeMin) + '/' + IntToStr(g_nBaseObjTimeMax);
}
Label20.Caption:=format('刷新怪物(%d/%d/%d) 处理怪物(%d/%d/%d) 角色处理(%d/%d)',[g_nMonGenTime,g_nMonGenTimeMin,g_nMonGenTimeMax,g_nMonProcTime,g_nMonProcTimeMin,g_nMonProcTimeMax,g_nBaseObjTimeMin,g_nBaseObjTimeMax]);
MemStatus.Caption:='内存: ' + FormatFloat('0.##', GetAddressSpaceUsed / 1464) + 'MB';// + ' 内存块数: ' + IntToStr(AllocMemCount);
// IntToStr(ROUND(AllocMemSize / 1024)) // QMemTotalAllocated // AllocMemSize
// Lbcheck.Caption:='check' + IntToStr(g_CheckCode.dwThread0) + '/w' + IntToStr(g_ProcessMsg.wIdent) + '/' + IntToStr(g_ProcessMsg.nParam1) + '/' + IntToStr(g_ProcessMsg.nParam2) + '/' + IntToStr(g_ProcessMsg.nParam3) + '/' + g_ProcessMsg.sMsg;
tTimeCount:=GetTickCount() / (24 * 60 * 60 * 1000);
if tTimeCount >= 36 then LbTimeCount.Font.Color:=clRed
else LbTimeCount.Font.Color:=clBlack;
LbTimeCount.Caption:=CurrToStr(tTimeCount) + '天';
{
//004E5B78
for i:= Low(RunSocket.GateList) to High(RunSocket.GateList) do begin
GateInfo:=@RunSocket.GateList[i];
if GateInfo.boUsed and (GateInfo.Socket <> nil) then begin
if GateInfo.nSendMsgBytes < 1024 then begin
tGate:=IntToStr(GateInfo.nSendMsgBytes) + 'b ';
end else begin//004E5BDA
tGate:=IntToStr(GateInfo.nSendMsgBytes div 1024) + 'kb ';
end;//004E5C0A
sGate:='[G' + IntToStr(i) + ': ' +
IntToStr(GateInfo.nSendMsgCount) + '/' +
IntToStr(GateInfo.nSendRemainCount) + ' ' +
tGate + IntToStr(GateInfo.nSendedMsgCount) + ']' + sGate;
end;//004E5C90
end;
Label3.Caption:=sGate;
}
// GridGate
nRow:=1;
//for i:= Low(RunSocket.GateList) to High(RunSocket.GateList) do begin
for i:= Low(g_GateArr) to High(g_GateArr) do begin
GridGate.Cells[0,I + 1]:='';
GridGate.Cells[1,I + 1]:='';
GridGate.Cells[2,I + 1]:='';
GridGate.Cells[3,I + 1]:='';
GridGate.Cells[4,I + 1]:='';
GridGate.Cells[5,I + 1]:='';
GridGate.Cells[6,I + 1]:='';
GateInfo:=@g_GateArr[i];
//GateInfo:=@RunSocket.GateList[i];
if GateInfo.boUsed and (GateInfo.Socket <> nil) then begin
GridGate.Cells[0,nRow]:=IntToStr(I);
GridGate.Cells[1,nRow]:=GateInfo.sAddr + ':' + IntToStr(GateInfo.nPort);
GridGate.Cells[2,nRow]:=IntToStr(GateInfo.nSendMsgCount);
GridGate.Cells[3,nRow]:=IntToStr(GateInfo.nSendedMsgCount);
GridGate.Cells[4,nRow]:=IntToStr(GateInfo.nSendRemainCount);
if GateInfo.nSendMsgBytes < 1024 then begin
GridGate.Cells[5,nRow]:=IntToStr(GateInfo.nSendMsgBytes) + 'b';
end else begin
GridGate.Cells[5,nRow]:=IntToStr(GateInfo.nSendMsgBytes div 1024) + 'kb';
end;
GridGate.Cells[6,nRow]:=IntToStr(GateInfo.nUserCount) + '/' + IntToStr(GateInfo.UserList.Count);
Inc(nRow);
end;
end;
//LbRunSocketTime.Caption:='Soc' + IntToStr(g_nGateRecvMsgLenMin) + '/' + IntToStr(g_nGateRecvMsgLenMax) + ' Ct' + IntToStr(CertCheck.Count) + '/' + IntToStr(EventCheck.Count);
//LbRunSocketTime.Caption:='Sess' + IntToStr(FrmIDSoc.GetSessionCount());
Inc(nRunTimeMax);
if g_nSockCountMax > 0 then Dec(g_nSockCountMax);
if g_nUsrTimeMax > 0 then Dec(g_nUsrTimeMax);
if g_nHumCountMax > 0 then Dec(g_nHumCountMax);
if g_nMonTimeMax > 0 then Dec(g_nMonTimeMax);
if dwUsrRotCountMax > 0 then Dec(dwUsrRotCountMax);
if g_nMonGenTimeMin > 1 then Dec(g_nMonGenTimeMin,2);
if g_nMonProcTimeMin > 1 then Dec(g_nMonProcTimeMin,2);
if g_nBaseObjTimeMax > 0 then Dec(g_nBaseObjTimeMax);
asm
NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP;
end;
if gettickcount - dwCheckMachIdCount >dwCheckMachIdTime then begin
//do something about check
dwCheckMachIdCount:=gettickcount;
end;
end;
procedure TFrmMain.StartTimerTimer(Sender: TObject);//004E4848
var
nCode:Integer;
begin
SendGameCenterMsg(SG_STARTNOW,'正在启动游戏主程序...');
StartTimer.Enabled:=False;
// {$IFDEF Test}
// InIVar ;
// RunFunction($A32E3F07 XOR 389696 XOR $53CEFC);
// {$ELSE}
// runfunction(222);
//{$ENDIF}
FrmDB:=TFrmDB.Create();
// {$IFDEF Test}
StartService();
// RunFunction($A32E3F07 XOR 389696 XOR $53C7D0);
// {$ELSE}
// runfunction(333);
// {$ENDIF}
try
// if SizeOf(THumDataInfo)<> SIZEOFTHUMAN then begin
// ShowMessage('sizeof(THuman) ' + IntToStr(sizeof(THumDataInfo)) + ' <> SIZEOFTHUMAN ' + IntToStr(SIZEOFTHUMAN));
// Close;
// exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -