mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 15:00:18 +01:00
Fix crash on exit of bed formspec if not sleeping (#2826)
This commit is contained in:
parent
3d95fceee8
commit
624dafc12b
@ -60,18 +60,19 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||
|
||||
-- stand up
|
||||
if state ~= nil and not state then
|
||||
local p = beds.pos[name] or nil
|
||||
if not beds.player[name] then
|
||||
-- player not in bed, do nothing
|
||||
return false
|
||||
end
|
||||
beds.bed_position[name] = nil
|
||||
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||
if skip then
|
||||
return
|
||||
end
|
||||
if p then
|
||||
player:set_pos(p)
|
||||
end
|
||||
player:set_pos(beds.pos[name])
|
||||
|
||||
-- physics, eye_offset, etc
|
||||
local physics_override = assert(beds.player[name].physics_override)
|
||||
local physics_override = beds.player[name].physics_override
|
||||
beds.player[name] = nil
|
||||
player:set_physics_override({
|
||||
speed = physics_override.speed,
|
||||
@ -101,6 +102,11 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||
return false
|
||||
end
|
||||
|
||||
if beds.player[name] then
|
||||
-- player already in bed, do nothing
|
||||
return false
|
||||
end
|
||||
|
||||
beds.pos[name] = pos
|
||||
beds.bed_position[name] = bed_pos
|
||||
beds.player[name] = {physics_override = player:get_physics_override()}
|
||||
|
Loading…
Reference in New Issue
Block a user