📄 usrengn.pas
字号:
try
EnterCriticalSection(m_LoadPlaySection);
try
for i:=0 to m_LoadPlayList.Count -1 do begin
if not FrontEngine.IsFull and not IsLogined(m_LoadPlayList.Strings[i]) then begin
UserOpenInfo:=pTUserOpenInfo(m_LoadPlayList.Objects[i]);
PlayObject:=MakeNewHuman(UserOpenInfo);
if PlayObject <> nil then begin
//PlayObject.m_boClientFlag:=UserOpenInfo.LoadUser.boClinetFlag; //将客户端标志传到人物数据中
m_PlayObjectList.AddObject(m_LoadPlayList.Strings[i],PlayObject);
SendServerGroupMsg(SS_201,nServerIndex,PlayObject.m_sCharName);
m_NewHumanList.Add(PlayObject);
end;
end else begin//004B0BF9
KickOnlineUser(m_LoadPlayList.Strings[i]);
UserOpenInfo:=pTUserOpenInfo(m_LoadPlayList.Objects[i]);
m_ListOfGateIdx.Add(Pointer(UserOpenInfo.LoadUser.nGateIdx)); //004B0C39
m_ListOfSocket.Add(Pointer(UserOpenInfo.LoadUser.nSocket));
end;
Dispose(pTUserOpenInfo(m_LoadPlayList.Objects[I]));
end;//004B0C96
m_LoadPlayList.Clear;
for I:=0 to m_ChangeHumanDBGoldList.Count -1 do begin
GoldChangeInfo:=m_ChangeHumanDBGoldList.Items[I];
PlayObject:=GeTPlayObject(GoldChangeInfo.sGameMasterName);
if PlayObject <> nil then begin
PlayObject.GoldChange(GoldChangeInfo.sGetGoldUser,GoldChangeInfo.nGold);
end;
Dispose(GoldChangeInfo);
end;
m_ChangeHumanDBGoldList.Clear;
finally
LeaveCriticalSection(m_LoadPlaySection);
end;
//004B0D4A
for I:=0 to m_NewHumanList.Count -1 do begin
PlayObject:=TPlayObject(m_NewHumanList.Items[I]);
RunSocket.SetGateUserList(PlayObject.m_nGateIdx,PlayObject.m_nSocket,PlayObject);
end;
m_NewHumanList.Clear;
for i:=0 to m_ListOfGateIdx.Count -1 do begin
RunSocket.CloseUser(Integer(m_ListOfGateIdx.Items[i]),Integer(m_ListOfSocket.Items[i]));//GateIdx,nSocket
end;
m_ListOfGateIdx.Clear;
m_ListOfSocket.Clear;
except
on e: Exception do begin
MainOutMessage(format(sExceptionMsg1,[0]));
MainOutMessage(E.Message);
end;
end;
end;//004B0E1E
try
for I := 0 to m_PlayObjectFreeList.Count - 1 do begin
PlayObject:=TPlayObject(m_PlayObjectFreeList.Items[i]);
if (GetTickCount - PlayObject.m_dwGhostTick) > g_Config.dwHumanFreeDelayTime {5 * 60 * 1000} then begin
try
TPlayObject(m_PlayObjectFreeList.Items[i]).Free;
except
MainOutMessage(sExceptionMsg2);
end;
m_PlayObjectFreeList.Delete(i);
break;
end else begin
if PlayObject.m_boSwitchData and (PlayObject.m_boRcdSaved) then begin
if SendSwitchData(PlayObject,PlayObject.m_nServerIndex) or (PlayObject.m_nWriteChgDataErrCount > 20) then begin
PlayObject.m_boSwitchData:=False;
PlayObject.m_boSwitchDataSended:=True;
PlayObject.m_dwChgDataWritedTick:=GetTickCount();
end else Inc(PlayObject.m_nWriteChgDataErrCount);
end;
if PlayObject.m_boSwitchDataSended and ((GetTickCount - PlayObject.m_dwChgDataWritedTick) > 100) then begin
PlayObject.m_boSwitchDataSended:=False;
SendChangeServer(PlayObject,PlayObject.m_nServerIndex);
end;
end;
end;
except
MainOutMessage(sExceptionMsg3);
end;//004B0F91
boCheckTimeLimit:=False;//004B0F91
try
dwCurTick:=GetTickCount();
nIdx:=m_nProcHumIDx;
while True do begin
if m_PlayObjectList.Count <= nIdx then break;
PlayObject:=TPlayObject(m_PlayObjectList.Objects[nIdx]);
if Integer(dwCurTick - PlayObject.m_dwRunTick) > PlayObject.m_nRunTime then begin
PlayObject.m_dwRunTick:=dwCurTick;
if not PlayObject.m_boGhost then begin
if not PlayObject.m_boLoginNoticeOK then begin
{$IF CATEXCEPTION = TRYEXCEPTION}
try
{$IFEND}
PlayObject.RunNotice();
{$IF CATEXCEPTION = TRYEXCEPTION}
except
MainOutMessage(sExceptionMsg4);
end;
{$IFEND}
end else begin//004B1058
try
if not PlayObject.m_boReadyRun then begin
PlayObject.m_boReadyRun:=True;//004B1075
PlayObject.UserLogon; //BaseObject.0FFFEh;
end else begin
if (GetTickCount() - PlayObject.m_dwSearchTick) > PlayObject.m_dwSearchTime then begin
PlayObject.m_dwSearchTick:=GetTickCount();
PlayObject.SearchViewRange;
PlayObject.GameTimeChanged;
end;//004B10C4
if (GetTickCount() - PlayObject.m_dwShowLineNoticeTick) > g_Config.dwShowLineNoticeTime then begin
PlayObject.m_dwShowLineNoticeTick:=GetTickCount();
if LineNoticeList.Count > PlayObject.m_nShowLineNoticeIdx then begin
LineNoticeMsg:=g_ManageNPC.GetLineVariableText(PlayObject,LineNoticeList.Strings[PlayObject.m_nShowLineNoticeIdx]);
//PlayObject.SysMsg(g_Config.sLineNoticePreFix + ' '+ LineNoticeList.Strings[PlayObject.m_nShowLineNoticeIdx],g_nLineNoticeColor);
case LineNoticeMsg[1] of
'R': PlayObject.SysMsg(Copy(LineNoticeMsg,2,length(LineNoticeMsg) - 1),c_Red,t_Notice);
'G': PlayObject.SysMsg(Copy(LineNoticeMsg,2,length(LineNoticeMsg) - 1),c_Green,t_Notice);
'B': PlayObject.SysMsg(Copy(LineNoticeMsg,2,length(LineNoticeMsg) - 1),c_Blue,t_Notice);
else begin
PlayObject.SysMsg(LineNoticeMsg,TMsgColor(g_Config.nLineNoticeColor){c_Blue},t_Notice);
end;
end;
end;
Inc(PlayObject.m_nShowLineNoticeIdx);
if (LineNoticeList.Count <= PlayObject.m_nShowLineNoticeIdx) then
PlayObject.m_nShowLineNoticeIdx:=0;
end;
PlayObject.Run();
if not FrontEngine.IsFull and((GetTickCount() - PlayObject.m_dwSaveRcdTick) > g_Config.dwSaveHumanRcdTime) then begin
PlayObject.m_dwSaveRcdTick:=GetTickCount();
PlayObject.DealCancelA();
SaveHumanRcd(PlayObject);
end;
end;//004B119F
except
on e: Exception do begin
MainOutMessage(format(sExceptionMsg5,[0]));
MainOutMessage(E.Message);
end;
end;
end;
end else begin//if not PlayObject.boIsGhost then begin //CODE:004B11C5
try
m_PlayObjectList.Delete(nIdx);
nCheck30:=2;
PlayObject.Disappear();
nCheck30:=3;
except
on e: Exception do begin
MainOutMessage(format(sExceptionMsg6,[nCheck30]));
MainOutMessage(E.Message);
end;
end;//004B1232
try
AddToHumanFreeList(PlayObject);
nCheck30:=4;
PlayObject.DealCancelA();
SaveHumanRcd(PlayObject);
RunSocket.CloseUser(PlayObject.m_nGateIdx,PlayObject.m_nSocket);
except
MainOutMessage(format(sExceptionMsg7,[nCheck30]));
end;//004B12BA
SendServerGroupMsg(SS_202,nServerIndex,PlayObject.m_sCharName);
Continue;
end;
end;//if (dwTime14 - PlayObject.dw368) > PlayObject.dw36C then begin
Inc(nIdx);//004B12E6
if (GetTickCount - dwCheckTime) > g_dwHumLimit then begin
boCheckTimeLimit:=True;
m_nProcHumIDx:=nIdx;
break;
end;
end;//while True do begin
if not boCheckTimeLimit then m_nProcHumIDx:=0;
except
MainOutMessage(sExceptionMsg8);
end;
Inc(nProcessHumanLoopTime);
g_nProcessHumanLoopTime:=nProcessHumanLoopTime;
if m_nProcHumIDx = 0 then begin
nProcessHumanLoopTime:=0;
g_nProcessHumanLoopTime:=nProcessHumanLoopTime;
dwUsrRotTime:=GetTickCount - g_dwUsrRotCountTick;
dwUsrRotCountMin:=dwUsrRotTime;
g_dwUsrRotCountTick:=GetTickCount();
if dwUsrRotCountMax < dwUsrRotTime then dwUsrRotCountMax:=dwUsrRotTime;
end;
g_nHumCountMin:=GetTickCount - dwCheckTime;
if g_nHumCountMax < g_nHumCountMin then g_nHumCountMax:=g_nHumCountMin;
end;
procedure TUserEngine.ProcessMerchants;//004B1B8C
var
dwRunTick,dwCurrTick:LongWord;
i:integer;
MerchantNPC:TMerchant;
boProcessLimit:Boolean;
ResourceString
sExceptionMsg = '[Exception] TUserEngine::ProcessMerchants';
begin
dwRunTick:=GetTickCount();
boProcessLimit:=False;
try
dwCurrTick:=GetTickCount();
m_MerchantList.Lock;
try
for i:=nMerchantPosition to m_MerchantList.Count -1 do begin
MerchantNPC:=m_MerchantList.Items[i];
if not MerchantNPC.m_boGhost then begin
if Integer(dwCurrTick - MerchantNPC.m_dwRunTick) > MerchantNPC.m_nRunTime then begin
if (GetTickCount - MerchantNPC.m_dwSearchTick) > MerchantNPC.m_dwSearchTime then begin
MerchantNPC.m_dwSearchTick:=GetTickCount();
MerchantNPC.SearchViewRange();
end;//004B1C3C
if Integer(dwCurrTick - MerchantNPC.m_dwRunTick) > MerchantNPC.m_nRunTime then begin
MerchantNPC.m_dwRunTick:=dwCurrTick;
MerchantNPC.Run; {FFFFB}
end;
end;//004B1C6B
end else begin//004B1C6B
if (GetTickCount - MerchantNPC.m_dwGhostTick) > 60 * 1000 then begin
MerchantNPC.Free;
m_MerchantList.Delete(i);
break;
end;
end;
if (GetTickCount - dwRunTick) > g_dwNpcLimit then begin
nMerchantPosition:=i;
boProcessLimit:=True;
Break;
end;//004B1C8C
end;//004B1C98
finally
m_MerchantList.UnLock;
end;
if not boProcessLimit then begin
nMerchantPosition:=0;
end;//004B1CA6
except
MainOutMessage(sExceptionMsg);
end;
dwProcessMerchantTimeMin:=GetTickCount - dwRunTick;
if dwProcessMerchantTimeMin > dwProcessMerchantTimeMax then dwProcessMerchantTimeMax:=dwProcessMerchantTimeMin;
if dwProcessNpcTimeMin > dwProcessNpcTimeMax then dwProcessNpcTimeMax:=dwProcessNpcTimeMin;
end;
procedure TUserEngine.ProcessMissions;
begin
end;
procedure TUserEngine.ProcessMonsters;
function GetZenTime(dwTime:LongWord):LongWord;
var
r:Real;
begin
if dwTime < 30 * 60 * 1000 then begin
r := (GetUserCount - g_Config.nUserFull) / g_Config.nZenFastStep;
if r > 0 then begin
if r > 6 then r := 6;
Result:= dwTime - Round((dwTime / 10) * r)
end else
Result:=dwTime;
end else
Result:=dwTime;
end;
//004B1638
var
dwCurrentTick :LongWord;
dwRunTick :LongWord;
dwMonProcTick :LongWord;
MonGen :pTMonGenInfo;
nGenCount :Integer;
nGenModCount :Integer;
boProcessLimit :Boolean;
boRegened :Boolean;
I :Integer;
nProcessPosition :Integer;
Monster :TAnimalObject;
tCode :Integer;
ResourceString
sExceptionMsg = '[Exception] TUserEngine::ProcessMonsters %d';
begin
tCode := 0;
dwRunTick := GetTickCount();
try
tCode := 0;
boProcessLimit := False;
dwCurrentTick := GetTickCount();
MonGen := nil;
//刷新怪物开始
if ((GetTickCount - dwRegenMonstersTick) > g_Config.dwRegenMonstersTime) then begin
dwRegenMonstersTick:=GetTickCount();
if m_nCurrMonGen < m_MonGenList.Count then begin
MonGen:=m_MonGenList.Items[m_nCurrMonGen];
end;
if m_nCurrMonGen < m_MonGenList.Count - 1 then begin
Inc(m_nCurrMonGen);
end else begin
m_nCurrMonGen:=0;
end;//004B1718
if (MonGen <> nil) and (MonGen.sMonName <> '') and not g_Config.boVentureServer then begin
if (MonGen.dwStartTick = 0) or ((GetTickCount - MonGen.dwStartTick) > GetZenTime(MonGen.dwZenTime)) then begin
nGenCount:=GetGenMonCount(MonGen);
boRegened:=True;
//if MonGen.nCount > tGenCount then begin
//if (MonGen.nCount <= g_nMonGenRate) or (MonGen.nCount div g_nMonGenRate > tGenCount) then begin //0806 增加 控制刷怪数量比例
nGenModCount:=_MAX(1,ROUND(_MAX(1,MonGen.nCount) / (g_Config.nMonGenRate / 10)));
if nGenModCount > nGenCount then begin //0806 增加 控制刷怪数量比例
boRegened:=RegenMonsters(MonGen,nGenModCount - nGenCount);
end;//004B1798
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -