From 6507e43dc57be3d30aac6f897533629b6ddb34f0 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Mon, 15 Aug 2022 15:46:47 +0200 Subject: [PATCH] Do not ignore the portal code if damage is enabled and the "nether_players" file does not exist I have accidentally introduced the bug in commit 4a7dd247e7f5b9f40cb24e802479a045bed2cf98. It was discovered thanks to the people who reported it on the Minetest forum. --- nether/portal.lua | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/nether/portal.lua b/nether/portal.lua index a2be614..c9c08bc 100644 --- a/nether/portal.lua +++ b/nether/portal.lua @@ -13,20 +13,20 @@ end) local save_path = minetest.get_worldpath() .. "/nether_players" local players_in_nether = {} --- only get info from file if nether prisons -if nether_prisons then + +-- Load the list of players which are trapped in the nether +-- (or would be trapped if nether_prisons was true) +do local file = io.open(save_path, "r") - if not file then - return - end - local contents = file:read"*all" - io.close(file) - if not contents then - return - end - local playernames = string.split(contents, " ") - for i = 1,#playernames do - players_in_nether[playernames[i]] = true + if file then + local contents = file:read"*all" + io.close(file) + if contents then + local playernames = string.split(contents, " ") + for i = 1,#playernames do + players_in_nether[playernames[i]] = true + end + end end end @@ -179,6 +179,7 @@ minetest.register_chatcommand("from_hell", { }) +-- Disallow teleportation and change spawn positions if the nether traps players if nether_prisons then -- randomly set player position when he/she dies in nether minetest.register_on_respawnplayer(function(player) @@ -266,12 +267,6 @@ if nether_prisons then end end end) -else - -- test if player is in nether when he/she joins - minetest.register_on_joinplayer(function(player) - players_in_nether[player:get_player_name()] = - player:get_pos().y < nether.start or nil - end) end -- removes the violet stuff from the obsidian portal