Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/api/v2/patched/inventory.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local inventories_manager = start_require("server:lib/private/sandbox/inventories_manager")

local global_inventory = _G["inventory"]

PACK_ENV["inventory"] = table.deep_copy(global_inventory)
Expand Down
1 change: 1 addition & 0 deletions modules/globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RESERVED_USERNAMES = {
IS_RUNNING = false
IS_FIRST_RUN = false
IS_RELEASE = false
IS_HEADLESS = true
PROTOCOL_VERSION = "3.2"
API_VERSION = "2"
PROTOCOL_STATES = {
Expand Down
44 changes: 23 additions & 21 deletions modules/init/engine_patcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@ entities["despawn"] = function(eid)
entities_manager.despawn(eid)
end

-- Патчим skeleton, ибо кому-то пришла ахуительная идея снести нахуй скелеты в хеадлессе ПОЛНОСТЬЮ НАХУЙ
local skeletons_info = {
textures = {},
models = {}
}

__skeleton.set_texture = function(id, key, texture)
table.set_default(skeletons_info.textures, id, {})[key] = texture
end
if IS_HEADLESS then
-- Патчим skeleton, ибо кому-то пришла ахуительная идея снести нахуй скелеты в хеадлессе ПОЛНОСТЬЮ НАХУЙ
local skeletons_info = {
textures = {},
models = {}
}

__skeleton.set_texture = function(id, key, texture)
table.set_default(skeletons_info.textures, id, {})[key] = texture
end

__skeleton.set_model = function(id, key, model)
table.set_default(skeletons_info.models, id, {})[key] = model
end
__skeleton.set_model = function(id, key, model)
table.set_default(skeletons_info.models, id, {})[key] = model
end

__skeleton.get_texture = function(id, key)
local skeleton = skeletons_info.textures[id]
if skeleton then
return skeleton[key]
__skeleton.get_texture = function(id, key)
local skeleton = skeletons_info.textures[id]
if skeleton then
return skeleton[key]
end
end
end

__skeleton.get_model = function(id, key)
local skeleton = skeletons_info.models[id]
if skeleton then
return skeleton[key]
__skeleton.get_model = function(id, key)
local skeleton = skeletons_info.models[id]
if skeleton then
return skeleton[key]
end
end
end

Expand Down
33 changes: 17 additions & 16 deletions modules/init/server.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
local lib = require "lib/private/min"
local protect = require "lib/private/protect"

if protect.protect_require() then return end

local world = lib.world

Expand All @@ -11,7 +8,7 @@ logger.log("std initialized")
do
if not file.exists(CONFIG_PATH) then
file.write(CONFIG_PATH, file.read(PACK_ID .. ":resources/server_config.json"))
IS_FIRST_RUN = true
if IS_HEADLESS then IS_FIRST_RUN = true end
end
end

Expand All @@ -23,7 +20,9 @@ do

if CONFIG.server.chunks_loading_distance > 255 then
CONFIG.server.chunks_loading_distance = 255
logger.log("Chunks distance is too high. Please select a value in the range of 0-255. The current chunks distance is set to 255", 'W')
logger.log(
"Chunks distance is too high. Please select a value in the range of 0-255. The current chunks distance is set to 255",
'W')
end

CONFIG = table.freeze(CONFIG)
Expand All @@ -46,18 +45,20 @@ end

logger.log("sandbox const initialized")

--Загружаем настройки
do
local settings = {
["chunks_loading_distance"] = "chunks.load-distance",
["chunks_loading_speed"] = "chunks.load-speed"
}
if IS_HEADLESS then
--Загружаем настройки
do
local settings = {
["chunks_loading_distance"] = "chunks.load-distance",
["chunks_loading_speed"] = "chunks.load-speed"
}

for cname, sname in pairs(settings) do
app.set_setting(sname, CONFIG.server[cname])
end
for cname, sname in pairs(settings) do
app.set_setting(sname, CONFIG.server[cname])
end

app.set_setting("debug.do-write-lights", false)
app.set_setting("debug.do-write-lights", false)
end
end

--Другое
Expand All @@ -68,4 +69,4 @@ end
logger.log("settings initialized")

world.preparation_main()
logger.log("world initialized")
logger.log("world initialized")
3 changes: 0 additions & 3 deletions modules/lib/private/accounts/account.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local protect = require "lib/private/protect"
if protect.protect_require() then return end

local metadata = start_require "lib/private/files/metadata"
local lib = require "lib/private/min"
local account = {}
Expand Down
3 changes: 0 additions & 3 deletions modules/lib/private/accounts/account_manager.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local protect = require "lib/private/protect"
if protect.protect_require() then return end

local Account = require "lib/private/accounts/account"
local sandbox = require "lib/private/sandbox/sandbox"
local container = require "lib/private/common/container"
Expand Down
5 changes: 1 addition & 4 deletions modules/lib/private/common/container.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local protect = require "lib/private/protect"
if protect.protect_require() then return end

local module = {
player_online = {},
clients_all = {},
Expand Down Expand Up @@ -44,4 +41,4 @@ function module.clients_all.get()
return DATA.clients_all
end

return module
return module
5 changes: 2 additions & 3 deletions modules/lib/private/common/culling.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
local protect = require "lib/private/protect"
local sandbox = require "lib/private/sandbox/sandbox"

local module = {}

function module.in_radius(center, radius, dot)
return ((center.x - dot.x)^2 + (center.y - dot.y)^2)^0.5 <= radius
return ((center.x - dot.x) ^ 2 + (center.y - dot.y) ^ 2) ^ 0.5 <= radius
end

return protect.protect_return(module)
return module
8 changes: 3 additions & 5 deletions modules/lib/private/common/timeout_executor.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local protect = require "lib/private/protect"

local module = {}
local delayed_responses = {}

Expand All @@ -11,11 +9,11 @@ function module.push(func, args, time_out, step)
time_out = time_out,
step = step or 0
}
)
)
end

function module.process()
for i=#delayed_responses, 1, -1 do
for i = #delayed_responses, 1, -1 do
local responce = delayed_responses[i]
local cur_time = time.uptime()
if cur_time - responce.time_create > responce.time_out then
Expand All @@ -31,4 +29,4 @@ function module.process()
end
end

return protect.protect_return(module)
return module
3 changes: 0 additions & 3 deletions modules/lib/private/entities/entities_manager.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local protect = require "lib/private/protect"
if protect.protect_require() then return end

local protocol = require "multiplayer/protocol-kernel/protocol"
local server_echo = require "multiplayer/server/server_echo"

Expand Down
3 changes: 0 additions & 3 deletions modules/lib/private/files/metadata.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local protect = require "lib/private/protect"
if protect.protect_require() then return end

local bson = require "lib/private/files/bson"

local module = {
Expand Down
24 changes: 12 additions & 12 deletions modules/lib/private/gfx/audio_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
Work In Progress
]]

local protect = require "lib/private/protect"
local module = {}

if protect.protect_require() then return end

local module = { }

local SPEAKERS = { }
local SPEAKERS = {}
local SOUNDS_DURATIONS = {}

local aliveSpeakersCount = 0
Expand All @@ -18,7 +14,7 @@ local NEXT_ID = 1

local function ensureSpeaker(id)
if not SPEAKERS[id] then
error("undefined speaker with id '"..id.."'")
error("undefined speaker with id '" .. id .. "'")
end
end

Expand All @@ -39,14 +35,14 @@ end
local function ensureArgs(args, names)
for i = 1, #args do
if not args[i] then
error("'"..names[i].."' argument is undefined")
error("'" .. names[i] .. "' argument is undefined")
end
end
end

local function checkVolPitch(num, name)
if num < 0 or num > 1 then
error("invalid "..name)
error("invalid " .. name)
end
end

Expand Down Expand Up @@ -79,7 +75,9 @@ local function basePlay(name, x, y, z, volume, pitch, channel, loop)

local sound = {
path = name,
x = x, y = y, z = z,
x = x,
y = y,
z = z,
volume = volume,
pitch = pitch,
channel = channel,
Expand Down Expand Up @@ -281,7 +279,9 @@ function module.get_time_left(speaker)
local sound = SPEAKERS[speaker]

if not SOUNDS_DURATIONS[sound.path] then
logger.log('The "audio.get_duration" function in the API returns 0 for technical reasons, please use "audio.register_duration" to fix it', 'W')
logger.log(
'The "audio.get_duration" function in the API returns 0 for technical reasons, please use "audio.register_duration" to fix it',
'W')
return 0
else
local playback = sound.offsetTime + SOUNDS_DURATIONS[sound.path] - module.get_time(speaker)
Expand Down Expand Up @@ -324,4 +324,4 @@ function module.get_in_radius(x, y, z, radius)
return speakers
end

return module
return module
6 changes: 1 addition & 5 deletions modules/lib/private/gfx/blockwraps_manager.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
local protect = require "lib/private/protect"

if protect.protect_require() then return end

local module = {}
local WRAPS = {}

Expand Down Expand Up @@ -90,4 +86,4 @@ function module.get_in_radius(x, z, radius)
return wraps
end

return module
return module
8 changes: 2 additions & 6 deletions modules/lib/private/gfx/particles_manager.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
local protect = require "lib/private/protect"

if protect.protect_require() then return end

local module = {}

local PARTICLES = {}
Expand All @@ -10,7 +6,7 @@ local MAX_PID = 0
function module.emit(origin, count, preset, extension)
local pid = MAX_PID

functions.args_check("emit", {origin = origin or false, count = count or false, preset = preset or false})
functions.args_check("emit", { origin = origin or false, count = count or false, preset = preset or false })

PARTICLES[tohex(pid)] = {
origin = origin,
Expand Down Expand Up @@ -68,4 +64,4 @@ function module.get_in_radius(x, z, radius)
return particles
end

return module
return module
14 changes: 5 additions & 9 deletions modules/lib/private/gfx/text3d_manager.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
local protect = require "lib/private/protect"
local module = {}

if protect.protect_require() then return end

local module = { }

local TEXTS = { }
local TEXTS = {}

local NEXT_ID = 1

Expand Down Expand Up @@ -72,7 +68,7 @@ end

function module.get_axis_x(id)
ensureText(id)
return TEXTS[id].axisX or {1, 0, 0}
return TEXTS[id].axisX or { 1, 0, 0 }
end

function module.set_axis_x(id, axis)
Expand All @@ -83,7 +79,7 @@ end

function module.get_axis_y(id)
ensureText(id)
return TEXTS[id].axisY or {0, 1, 0}
return TEXTS[id].axisY or { 0, 1, 0 }
end

function module.set_axis_y(id, axis)
Expand Down Expand Up @@ -123,4 +119,4 @@ function module.get_in_radius(x, z, radius)
return texts
end

return module
return module
Loading