diff --git a/Changelog.txt b/Changelog.txt index be97d52..988db2a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,3 +12,7 @@ - Allow players always to detach from bed (by donat-b) - If more than 50% of players want sleep they can skip the night - Don't show sleep dialog in singleplayer + +1.1.1 +----- +- Prevent possbile crash by trying to reposition leaving players diff --git a/README.txt b/README.txt index eac46f0..20893b8 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ Minetest mod "Beds" =================== -by BlockMen (c) 2014 +by BlockMen (c) 2014-2015 -Version: 1.1 +Version: 1.1.1 About ~~~~~ @@ -34,7 +34,7 @@ Notice: You can use any color of wood or wool, mixing different is also possible License of source code, textures: WTFPL --------------------------------------- -(c) Copyright BlockMen (2014) +(c) Copyright BlockMen (2014-2015) diff --git a/init.lua b/init.lua index ef3f765..64ab3c7 100644 --- a/init.lua +++ b/init.lua @@ -42,7 +42,7 @@ local function check_in_beds(players) return true end -local function lay_down(player, pos, bed_pos, state) +local function lay_down(player, pos, bed_pos, state, skip) local name = player:get_player_name() local hud_flags = player:hud_get_flags() @@ -57,6 +57,10 @@ local function lay_down(player, pos, bed_pos, state) beds.player[name] = nil player_in_bed = player_in_bed - 1 end + -- skip here to prevent sending player specific changes (used for leaving players) + if skip then + return + end if p then player:setpos(p) end @@ -182,7 +186,7 @@ end) minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() - lay_down(player, nil, nil, false) + lay_down(player, nil, nil, false, true) beds.player[name] = nil if check_in_beds() then minetest.after(2, function() diff --git a/spawns.lua b/spawns.lua index 63f55fa..a54b544 100644 --- a/spawns.lua +++ b/spawns.lua @@ -63,4 +63,4 @@ function beds.set_spawns() beds.spawn[name] = p end beds.save_spawns() -end \ No newline at end of file +end