Fix bug when event listener handling "Crash" & "PLAYER_LEAVE_UNIT" event cannot call function unit:getPlayerName()
This commit is contained in:
@@ -173,7 +173,7 @@ do
|
|||||||
-- playerNum -1
|
-- playerNum -1
|
||||||
if event.id == world.event.S_EVENT_CRASH or event.id == world.event.S_EVENT_PLAYER_LEAVE_UNIT then
|
if event.id == world.event.S_EVENT_CRASH or event.id == world.event.S_EVENT_PLAYER_LEAVE_UNIT then
|
||||||
local unit = event.initiator
|
local unit = event.initiator
|
||||||
if not unit then return end
|
if not unit or not unit.getPlayerName then return end
|
||||||
|
|
||||||
local playerName = unit:getPlayerName()
|
local playerName = unit:getPlayerName()
|
||||||
if playerName then
|
if playerName then
|
||||||
@@ -232,7 +232,7 @@ do
|
|||||||
--设定下次刷新时间
|
--设定下次刷新时间
|
||||||
local Ratio = 0.05
|
local Ratio = 0.05
|
||||||
for maxPlayer,ratio in pairs(self.player_ratio_table) do
|
for maxPlayer,ratio in pairs(self.player_ratio_table) do
|
||||||
if #self.playerList <= maxPlayer then
|
if self.tableCount(self.playerList) <= maxPlayer then
|
||||||
Ratio = ratio
|
Ratio = ratio
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -243,7 +243,7 @@ do
|
|||||||
local maxTime = nextSpawnTime * (1 + self.RANDOM_DEVIATION)
|
local maxTime = nextSpawnTime * (1 + self.RANDOM_DEVIATION)
|
||||||
nextSpawnTime = math.random(minTime, maxTime)
|
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
|
return time + nextSpawnTime * Ratio
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user