Merge pull request 'Mob spawner crash teleport bug logging' (#3534) from over_mapgen_limit into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3534respiration
commit
9f182dc63a
|
@ -5,25 +5,18 @@ local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
|
||||||
|
|
||||||
local PATHFINDING = "gowp"
|
local PATHFINDING = "gowp"
|
||||||
local CRASH_WARN_FREQUENCY = 60
|
local CRASH_WARN_FREQUENCY = 60
|
||||||
|
local LIFETIMER_DISTANCE = 47
|
||||||
|
|
||||||
-- Localize
|
-- Localize
|
||||||
local S = minetest.get_translator("mcl_mobs")
|
local S = minetest.get_translator("mcl_mobs")
|
||||||
|
|
||||||
local DEVELOPMENT = minetest.settings:get_bool("mcl_development",false)
|
local DEVELOPMENT = minetest.settings:get_bool("mcl_development",false)
|
||||||
|
|
||||||
local LOGGING_ON = minetest.settings:get_bool("mcl_logging_mobs_villager",false)
|
|
||||||
local function mcl_log (message)
|
|
||||||
if LOGGING_ON then
|
|
||||||
mcl_util.mcl_log (message, "[Mobs]", true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Invisibility mod check
|
-- Invisibility mod check
|
||||||
mcl_mobs.invis = {}
|
mcl_mobs.invis = {}
|
||||||
|
|
||||||
local remove_far = true
|
local remove_far = true
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
|
||||||
local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false
|
|
||||||
local mobs_debug = minetest.settings:get_bool("mobs_debug", false) -- Shows helpful debug info above each mob
|
local mobs_debug = minetest.settings:get_bool("mobs_debug", false) -- Shows helpful debug info above each mob
|
||||||
local spawn_logging = minetest.settings:get_bool("mcl_logging_mobs_spawn",true)
|
local spawn_logging = minetest.settings:get_bool("mcl_logging_mobs_spawn",true)
|
||||||
|
|
||||||
|
@ -503,6 +496,7 @@ end
|
||||||
-- main mob function
|
-- main mob function
|
||||||
function mob_class:on_step(dtime)
|
function mob_class:on_step(dtime)
|
||||||
if not DEVELOPMENT then
|
if not DEVELOPMENT then
|
||||||
|
-- Removed as bundled Lua (5.1 doesn't support xpcall)
|
||||||
--local status, retVal = xpcall(on_step_work, on_step_error_handler, self, dtime)
|
--local status, retVal = xpcall(on_step_work, on_step_error_handler, self, dtime)
|
||||||
local status, retVal = pcall(on_step_work, self, dtime)
|
local status, retVal = pcall(on_step_work, self, dtime)
|
||||||
if status then
|
if status then
|
||||||
|
@ -510,6 +504,12 @@ function mob_class:on_step(dtime)
|
||||||
else
|
else
|
||||||
warn_user_error ()
|
warn_user_error ()
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
if pos then
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node and node.name == "ignore" then
|
||||||
|
minetest.log("warning", "Pos is ignored: " .. dump(pos))
|
||||||
|
end
|
||||||
|
end
|
||||||
log_error (dump(retVal), dump(pos), dump(self))
|
log_error (dump(retVal), dump(pos), dump(self))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -518,12 +518,13 @@ function mob_class:on_step(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
|
local function update_lifetimer(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if timer < 1 then return end
|
if timer < 1 then return end
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 47)) do
|
for _, obj in pairs(minetest.get_objects_inside_radius(pos, LIFETIMER_DISTANCE)) do
|
||||||
local lua = obj:get_luaentity()
|
local lua = obj:get_luaentity()
|
||||||
if lua and lua.is_mob then
|
if lua and lua.is_mob then
|
||||||
lua.lifetimer = math.max(20, lua.lifetimer)
|
lua.lifetimer = math.max(20, lua.lifetimer)
|
||||||
|
@ -532,6 +533,10 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
update_lifetimer(dtime)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -622,24 +622,34 @@ function mob_class:do_env_damage()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local sunlight = minetest.get_natural_light(pos, self.time_of_day)
|
local node = minetest.get_node(pos)
|
||||||
|
if node then
|
||||||
-- bright light harms mob
|
if node.name ~= "ignore" then
|
||||||
if self.light_damage ~= 0 and (sunlight or 0) > 12 then
|
-- put below code in this block if we can prove that unloaded maps are causing crash.
|
||||||
if self:deal_light_damage(pos, self.light_damage) then
|
-- it should warn then error
|
||||||
return true
|
else
|
||||||
|
--minetest.log("warning", "Pos is ignored: " .. dump(pos))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
local _, dim = mcl_worlds.y_to_layer(pos.y)
|
local sunlight = minetest.get_natural_light(pos, self.time_of_day)
|
||||||
if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then
|
|
||||||
if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then
|
if self.light_damage ~= 0 and (sunlight or 0) > 12 then
|
||||||
if self.ignited_by_sunlight then
|
if self:deal_light_damage(pos, self.light_damage) then
|
||||||
mcl_burning.set_on_fire(self.object, 10)
|
|
||||||
else
|
|
||||||
self:deal_light_damage(pos, self.sunlight_damage)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local _, dim = mcl_worlds.y_to_layer(pos.y)
|
||||||
|
if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then
|
||||||
|
if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then
|
||||||
|
if self.ignited_by_sunlight then
|
||||||
|
mcl_burning.set_on_fire(self.object, 10)
|
||||||
|
else
|
||||||
|
self:deal_light_damage(pos, self.sunlight_damage)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local y_level = self.collisionbox[2]
|
local y_level = self.collisionbox[2]
|
||||||
|
|
Loading…
Reference in New Issue