Fix bug when event listener handling "Crash" & "PLAYER_LEAVE_UNIT" event cannot call function unit:getPlayerName()

This commit is contained in:
2025-03-02 19:25:56 +08:00
parent 786ae01902
commit a2cf76bd5d
+3 -3
View File
@@ -173,7 +173,7 @@ do
-- playerNum -1
if event.id == world.event.S_EVENT_CRASH or event.id == world.event.S_EVENT_PLAYER_LEAVE_UNIT then
local unit = event.initiator
if not unit then return end
if not unit or not unit.getPlayerName then return end
local playerName = unit:getPlayerName()
if playerName then
@@ -232,7 +232,7 @@ do
--设定下次刷新时间
local Ratio = 0.05
for maxPlayer,ratio in pairs(self.player_ratio_table) do
if #self.playerList <= maxPlayer then
if self.tableCount(self.playerList) <= maxPlayer then
Ratio = ratio
break
end
@@ -243,7 +243,7 @@ do
local maxTime = nextSpawnTime * (1 + self.RANDOM_DEVIATION)
nextSpawnTime = math.random(minTime, maxTime)
Debug('playerNumber:' ..#self.playerList..' ratio: '..Ratio..' Preset:'..preset.categoryName..' nextSpawnTime: '..nextSpawnTime * Ratio)
Debug('playerNumber:' ..self.tableCount(self.playerList)..' ratio: '..Ratio..' Preset:'..preset.categoryName..' nextSpawnTime: '..nextSpawnTime * Ratio)
return time + nextSpawnTime * Ratio
end