Skip to content

Commit

Permalink
Fixed player death and respawning in zone
Browse files Browse the repository at this point in the history
  • Loading branch information
1ForeverHD committed Apr 15, 2021
1 parent 9d4fcd8 commit d30f043
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [2.1.2] - April 15 2021
### Fixed
- ``playerExiting`` not firing when the player dies and respawns immidately within the zone.
- A rare nil checking bug within ``getTouchingZones`` in ``ZoneController``.



--------

## [2.1.1] - April 7 2021
### Fixed
- nil comparison within ZoneController getTouchingZones line 450
Expand Down
6 changes: 4 additions & 2 deletions src/Zone/ZoneController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ local function fillOccupants(zonesAndOccupantsTable, zone, occupant)
occupantsDict = {}
zonesAndOccupantsTable[zone] = occupantsDict
end
occupantsDict[occupant] = true
occupantsDict[occupant] = (occupant.Character or true)
end

local heartbeatActions = {
Expand Down Expand Up @@ -442,7 +442,9 @@ function ZoneController.getTouchingZones(player, onlyActiveZones, recommendedDet
local zonesDict = {}
for _, part in pairs(parts) do
local correspondingZone = partToZoneDict[part]
zonesDict[correspondingZone] = true
if correspondingZone then
zonesDict[correspondingZone] = true
end
end
local touchingZonesArray = {}
local newExitDetection
Expand Down
7 changes: 4 additions & 3 deletions src/Zone/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,9 @@ function Zone:_updateOccupants(triggerType, newOccupants)
local exitedSignal = self[triggerType.."Exited"]
local enteredSignal = self[triggerType.."Entered"]
if exitedSignal then
for occupant, _ in pairs(previousOccupants) do
if newOccupants[occupant] == nil then
for occupant, prevCharacter in pairs(previousOccupants) do
local newCharacter = newOccupants[occupant]
if newCharacter == nil or newCharacter ~= prevCharacter then
previousOccupants[occupant] = nil
exitedSignal:Fire(occupant)
end
Expand All @@ -555,7 +556,7 @@ function Zone:_updateOccupants(triggerType, newOccupants)
if enteredSignal then
for occupant, _ in pairs(newOccupants) do
if previousOccupants[occupant] == nil then
previousOccupants[occupant] = true
previousOccupants[occupant] = occupant.Character
enteredSignal:Fire(occupant)
end
end
Expand Down

0 comments on commit d30f043

Please sign in to comment.