diff options
Diffstat (limited to 'server/server.lua')
| -rw-r--r-- | server/server.lua | 28 | 
1 files changed, 5 insertions, 23 deletions
diff --git a/server/server.lua b/server/server.lua index e9eef30..cc9903e 100644 --- a/server/server.lua +++ b/server/server.lua @@ -1,7 +1,6 @@  local enet = require"enet"  local json = require"common.dkjson"  local chunk = require"common.chunk" -local Chunk = require"common.chunk".Chunk  local noise = require"noise"  local coords = require"common.coords"  local worldgen = require"worldgen" @@ -170,30 +169,13 @@ end  while true do  	local now = timenow()  	local dt = now - last_tick_time - -	if dt >= tick_interval then -		dts[ndt] = dt -		ndt = 1+(ndt%ndts) +	local time_till_next_tick = (last_tick_time+tick_interval)-now +	if time_till_next_tick > 0.001 then +		local ev = host:service(time_till_next_tick*1000) +		if ev then handle_ev(ev) end +	else  		last_tick_time = now  		ntick = ntick + 1 -  		tick(ntick) - -		local tps = 0 -		for _,d in ipairs(dts) do tps = tps + 1/d end -		tps = tps/#dts - - -		print(ndt,ndts) -		if 1 == ndt%ndts then -			print("tps",tps) -		end -	end - -	local now2 = timenow() -	local time_till_next_tick = (last_tick_time+tick_interval)-now2 -	if time_till_next_tick > 0 then -		local ev = host:service(time_till_next_tick/1000) -		if ev then handle_ev(ev) end  	end  end  | 
