mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-01 07:13:45 +01:00
Merge pull request 'small performance fixes' (#1146) from AFCMS/MineClone2:master into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1146
This commit is contained in:
commit
793b5f616e
@ -36,7 +36,7 @@ mcl_weather.rain.set_sky_box = function()
|
|||||||
{r=85, g=86, b=98},
|
{r=85, g=86, b=98},
|
||||||
{r=0, g=0, b=0}})
|
{r=0, g=0, b=0}})
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
player:set_clouds({color="#5D5D5FE8"})
|
player:set_clouds({color="#5D5D5FE8"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -37,7 +37,7 @@ mcl_weather.snow.set_sky_box = function()
|
|||||||
{r=85, g=86, b=86},
|
{r=85, g=86, b=86},
|
||||||
{r=0, g=0, b=0}})
|
{r=0, g=0, b=0}})
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
player:set_clouds({color="#ADADADE8"})
|
player:set_clouds({color="#ADADADE8"})
|
||||||
end
|
end
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
|
@ -25,7 +25,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
{r=40, g=40, b=40},
|
{r=40, g=40, b=40},
|
||||||
{r=0, g=0, b=0}})
|
{r=0, g=0, b=0}})
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
player:set_clouds({color="#3D3D3FE8"})
|
player:set_clouds({color="#3D3D3FE8"})
|
||||||
end
|
end
|
||||||
mcl_weather.thunder.init_done = true
|
mcl_weather.thunder.init_done = true
|
||||||
|
@ -341,7 +341,7 @@ controls.register_on_hold(function(player, key, time)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local wielditem = player:get_wielded_item()
|
local wielditem = player:get_wielded_item()
|
||||||
local wieldindex = player:get_wield_index()
|
local wieldindex = player:get_wield_index()
|
||||||
|
@ -137,7 +137,7 @@ local player_attached = mcl_player.player_attached
|
|||||||
|
|
||||||
-- Check each player and apply animations
|
-- Check each player and apply animations
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local model_name = player_model[name]
|
local model_name = player_model[name]
|
||||||
local model = model_name and models[model_name]
|
local model = model_name and models[model_name]
|
||||||
|
@ -1,91 +1,91 @@
|
|||||||
-- Player state for public API
|
-- Player state for public API
|
||||||
mcl_playerinfo = {}
|
mcl_playerinfo = {}
|
||||||
|
|
||||||
-- Get node but use fallback for nil or unknown
|
-- Get node but use fallback for nil or unknown
|
||||||
local function node_ok(pos, fallback)
|
local function node_ok(pos, fallback)
|
||||||
|
|
||||||
fallback = fallback or "air"
|
fallback = fallback or "air"
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
|
||||||
if not node then
|
if not node then
|
||||||
return fallback
|
return fallback
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.registered_nodes[node.name] then
|
if minetest.registered_nodes[node.name] then
|
||||||
return node.name
|
return node.name
|
||||||
end
|
end
|
||||||
|
|
||||||
return fallback
|
return fallback
|
||||||
end
|
end
|
||||||
|
|
||||||
local time = 0
|
local time = 0
|
||||||
|
|
||||||
local get_player_nodes = function(player_pos)
|
local get_player_nodes = function(player_pos)
|
||||||
local work_pos = table.copy(player_pos)
|
local work_pos = table.copy(player_pos)
|
||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
work_pos.y = work_pos.y - 0.1 -- standing on
|
work_pos.y = work_pos.y - 0.1 -- standing on
|
||||||
local node_stand = node_ok(work_pos)
|
local node_stand = node_ok(work_pos)
|
||||||
local node_stand_below = node_ok({x=work_pos.x, y=work_pos.y-1, z=work_pos.z})
|
local node_stand_below = node_ok({x=work_pos.x, y=work_pos.y-1, z=work_pos.z})
|
||||||
|
|
||||||
work_pos.y = work_pos.y + 1.5 -- head level
|
work_pos.y = work_pos.y + 1.5 -- head level
|
||||||
local node_head = node_ok(work_pos)
|
local node_head = node_ok(work_pos)
|
||||||
|
|
||||||
work_pos.y = work_pos.y - 1.2 -- feet level
|
work_pos.y = work_pos.y - 1.2 -- feet level
|
||||||
local node_feet = node_ok(work_pos)
|
local node_feet = node_ok(work_pos)
|
||||||
|
|
||||||
return node_stand, node_stand_below, node_head, node_feet
|
return node_stand, node_stand_below, node_head, node_feet
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
time = time + dtime
|
time = time + dtime
|
||||||
|
|
||||||
-- Run the rest of the code every 0.5 seconds
|
-- Run the rest of the code every 0.5 seconds
|
||||||
if time < 0.5 then
|
if time < 0.5 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- reset time for next check
|
-- reset time for next check
|
||||||
-- FIXME: Make sure a regular check interval applies
|
-- FIXME: Make sure a regular check interval applies
|
||||||
time = 0
|
time = 0
|
||||||
|
|
||||||
-- check players
|
-- check players
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
-- who am I?
|
-- who am I?
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
-- where am I?
|
-- where am I?
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
||||||
mcl_playerinfo[name].node_stand = node_stand
|
mcl_playerinfo[name].node_stand = node_stand
|
||||||
mcl_playerinfo[name].node_stand_below = node_stand_below
|
mcl_playerinfo[name].node_stand_below = node_stand_below
|
||||||
mcl_playerinfo[name].node_head = node_head
|
mcl_playerinfo[name].node_head = node_head
|
||||||
mcl_playerinfo[name].node_feet = node_feet
|
mcl_playerinfo[name].node_feet = node_feet
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- set to blank on join (for 3rd party mods)
|
-- set to blank on join (for 3rd party mods)
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
mcl_playerinfo[name] = {
|
mcl_playerinfo[name] = {
|
||||||
node_head = "",
|
node_head = "",
|
||||||
node_feet = "",
|
node_feet = "",
|
||||||
node_stand = "",
|
node_stand = "",
|
||||||
node_stand_below = "",
|
node_stand_below = "",
|
||||||
}
|
}
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- clear when player leaves
|
-- clear when player leaves
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
mcl_playerinfo[name] = nil
|
mcl_playerinfo[name] = nil
|
||||||
end)
|
end)
|
||||||
|
@ -19,7 +19,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
|
|
||||||
-- Update jump status immediately since we need this info in real time.
|
-- Update jump status immediately since we need this info in real time.
|
||||||
-- WARNING: This section is HACKY as hell since it is all just based on heuristics.
|
-- WARNING: This section is HACKY as hell since it is all just based on heuristics.
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
local controls = player:get_player_control()
|
local controls = player:get_player_control()
|
||||||
name = player:get_player_name()
|
name = player:get_player_name()
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
time = 0
|
time = 0
|
||||||
|
|
||||||
-- check players
|
-- check players
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
-- who am I?
|
-- who am I?
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ mcl_skins = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local S = minetest.get_translator("mcl_skins")
|
local S = minetest.get_translator("mcl_skins")
|
||||||
|
local has_mcl_armor = minetest.get_modpath("mcl_armor")
|
||||||
|
local has_mcl_inventory = minetest.get_modpath("mcl_inventory")
|
||||||
|
|
||||||
-- load skin list and metadata
|
-- load skin list and metadata
|
||||||
local id, f, data, skin = 0
|
local id, f, data, skin = 0
|
||||||
@ -105,11 +107,11 @@ mcl_skins.set_player_skin = function(player, skin_id)
|
|||||||
mcl_skins.previews[playername] = preview
|
mcl_skins.previews[playername] = preview
|
||||||
player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id))
|
player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id))
|
||||||
mcl_skins.update_player_skin(player)
|
mcl_skins.update_player_skin(player)
|
||||||
if minetest.get_modpath("mcl_armor") then
|
if has_mcl_armor then
|
||||||
armor.textures[playername].skin = skin_file
|
armor.textures[playername].skin = skin_file
|
||||||
armor:update_player_visuals(player)
|
armor:update_player_visuals(player)
|
||||||
end
|
end
|
||||||
if minetest.get_modpath("mcl_inventory") then
|
if has_mcl_inventory then
|
||||||
mcl_inventory.update_inventory_formspec(player)
|
mcl_inventory.update_inventory_formspec(player)
|
||||||
end
|
end
|
||||||
for i=1, #mcl_skins.registered_on_set_skins do
|
for i=1, #mcl_skins.registered_on_set_skins do
|
||||||
|
Loading…
Reference in New Issue
Block a user