Skip to content

Commit

Permalink
Merge branch 'master' into minetestrl
Browse files Browse the repository at this point in the history
  • Loading branch information
AI-WAIFU committed Oct 29, 2022
2 parents e35a0c5 + b829231 commit 28e6e13
Show file tree
Hide file tree
Showing 369 changed files with 7,772 additions and 4,267 deletions.
30 changes: 13 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(GCC_MINIMUM_VERSION "5.1")
set(CLANG_MINIMUM_VERSION "3.5")

# Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
# You should not need to edit these manually, use util/bump_version.sh
set(VERSION_MAJOR 5)
set(VERSION_MINOR 7)
set(VERSION_PATCH 0)
Expand Down Expand Up @@ -127,7 +127,7 @@ if(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt)
endif()
message(STATUS "Found IrrlichtMt ${IrrlichtMt_VERSION}")

set(TARGET_VER_S 1.9.0mt7)
set(TARGET_VER_S 1.9.0mt8)
string(REPLACE "mt" "." TARGET_VER ${TARGET_VER_S})
if(IrrlichtMt_VERSION VERSION_LESS ${TARGET_VER})
message(FATAL_ERROR "At least IrrlichtMt ${TARGET_VER_S} is required to build")
Expand All @@ -136,6 +136,17 @@ if(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt)
endif()
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
"Version ${GCC_MINIMUM_VERSION} or higher is required.")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
"Version ${CLANG_MINIMUM_VERSION} or higher is required.")
endif()
endif()

# Installation

Expand Down Expand Up @@ -280,23 +291,9 @@ find_package(Lua REQUIRED)
find_package(Zmq REQUIRED)
find_package(Zmqpp REQUIRED)
if(NOT USE_LUAJIT)
set(LUA_BIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/bitop)
set(LUA_BIT_LIBRARY bitop)
add_subdirectory(lib/bitop)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
"Version ${GCC_MINIMUM_VERSION} or higher is required.")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
"Version ${CLANG_MINIMUM_VERSION} or higher is required.")
endif()
endif()

if(BUILD_BENCHMARKS)
add_subdirectory(lib/catch2)
endif()
Expand All @@ -305,7 +302,6 @@ endif()
# Be sure to add all relevant definitions above this
add_subdirectory(src)


# CPack

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A free open-source voxel game engine with easy modding and game creation.")
Expand Down
9 changes: 6 additions & 3 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ https://www.apache.org/licenses/LICENSE-2.0.html
Textures by Zughy are under CC BY-SA 4.0
https://creativecommons.org/licenses/by-sa/4.0/

Media files by DS are under CC BY-SA 4.0
https://creativecommons.org/licenses/by-sa/4.0/

textures/base/pack/server_public.png is under CC-BY 4.0, taken from Twitter's Twemoji set
https://creativecommons.org/licenses/by/4.0/

Expand Down Expand Up @@ -55,22 +58,22 @@ srifqi:

Zughy:
textures/base/pack/cdb_add.png
textures/base/pack/cdb_clear.png
textures/base/pack/cdb_downloading.png
textures/base/pack/cdb_queued.png
textures/base/pack/cdb_update.png
textures/base/pack/cdb_viewonline.png

appgurueu:
textures/base/pack/server_incompatible.png

erlehmann, Warr1024, rollerozxa:
textures/base/pack/no_screenshot.png

kilbith:
textures/base/pack/server_favorite.png

SmallJoker
SmallJoker:
textures/base/pack/cdb_clear.png
textures/base/pack/server_favorite_delete.png (based on server_favorite.png)

License of Minetest source code
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ Where each location is on each platform:
* Windows installed:
* `bin` = `C:\Program Files\Minetest\bin (Depends on the install location)`
* `share` = `C:\Program Files\Minetest (Depends on the install location)`
* `user` = `%APPDATA%\Minetest`
* `user` = `%APPDATA%\Minetest` or `%MINETEST_USER_PATH%`
* Linux installed:
* `bin` = `/usr/bin`
* `share` = `/usr/share/minetest`
* `user` = `~/.minetest`
* `user` = `~/.minetest` or `$MINETEST_USER_PATH`
* macOS:
* `bin` = `Contents/MacOS`
* `share` = `Contents/Resources`
* `user` = `Contents/User OR ~/Library/Application Support/minetest`
* `user` = `Contents/User` or `~/Library/Application Support/minetest` or `$MINETEST_USER_PATH`

Worlds can be found as separate folders in: `user/worlds/`

Expand Down Expand Up @@ -293,9 +293,10 @@ Library specific options:
FREETYPE_LIBRARY - Path to libfreetype.a/libfreetype.so/freetype.lib
FREETYPE_DLL - Only on Windows; path to libfreetype-6.dll
GETTEXT_DLL - Only when building with gettext on Windows; paths to libintl + libiconv DLLs
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains libintl.h
GETTEXT_LIBRARY - Optional/platform-dependent with gettext; path to libintl.so/libintl.dll.a
GETTEXT_MSGFMT - Only when building with gettext; path to msgfmt/msgfmt.exe
ICONV_LIBRARY - Optional/platform-dependent; path to libiconv.so/libiconv.dylib
IRRLICHT_DLL - Only on Windows; path to IrrlichtMt.dll
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h (usable for server build only)
LEVELDB_INCLUDE_DIR - Only when building with LevelDB; directory that contains db.h
Expand Down
7 changes: 6 additions & 1 deletion builtin/async/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ end

-- Import a bunch of individual files from builtin/game/
local gamepath = core.get_builtin_path() .. "game" .. DIR_DELIM
local commonpath = core.get_builtin_path() .. "common" .. DIR_DELIM

local builtin_shared = {}

dofile(gamepath .. "constants.lua")
dofile(gamepath .. "item_s.lua")
assert(loadfile(commonpath .. "item_s.lua"))(builtin_shared)
dofile(gamepath .. "misc_s.lua")
dofile(gamepath .. "features.lua")
dofile(gamepath .. "voxelarea.lua")
Expand Down Expand Up @@ -57,3 +60,5 @@ setmetatable(core.registered_items, alias_metatable)
setmetatable(core.registered_nodes, alias_metatable)
setmetatable(core.registered_craftitems, alias_metatable)
setmetatable(core.registered_tools, alias_metatable)

builtin_shared.cache_content_ids()
1 change: 1 addition & 0 deletions builtin/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dofile(commonpath .. "chatcommands.lua")
dofile(clientpath .. "chatcommands.lua")
dofile(clientpath .. "death_formspec.lua")
dofile(clientpath .. "misc.lua")
assert(loadfile(commonpath .. "item_s.lua"))({}) -- Just for push/read node functions
85 changes: 84 additions & 1 deletion builtin/game/item_s.lua → builtin/common/item_s.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
-- Server or writable access to IGameDef on the engine side.
-- (The '_s' stands for standalone.)

local builtin_shared = ...

--
-- Item definition helpers
--
Expand Down Expand Up @@ -92,6 +94,26 @@ function core.facedir_to_dir(facedir)
return facedir_to_dir[facedir_to_dir_map[facedir % 32]]
end

function core.dir_to_fourdir(dir)
if math.abs(dir.x) > math.abs(dir.z) then
if dir.x < 0 then
return 3
else
return 1
end
else
if dir.z < 0 then
return 2
else
return 0
end
end
end

function core.fourdir_to_dir(fourdir)
return facedir_to_dir[facedir_to_dir_map[fourdir % 4]]
end

function core.dir_to_wallmounted(dir)
if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then
if dir.y < 0 then
Expand Down Expand Up @@ -137,7 +159,8 @@ end

function core.is_colored_paramtype(ptype)
return (ptype == "color") or (ptype == "colorfacedir") or
(ptype == "colorwallmounted") or (ptype == "colordegrotate")
(ptype == "color4dir") or (ptype == "colorwallmounted") or
(ptype == "colordegrotate")
end

function core.strip_param2_color(param2, paramtype2)
Expand All @@ -146,6 +169,8 @@ function core.strip_param2_color(param2, paramtype2)
end
if paramtype2 == "colorfacedir" then
param2 = math.floor(param2 / 32) * 32
elseif paramtype2 == "color4dir" then
param2 = math.floor(param2 / 4) * 4
elseif paramtype2 == "colorwallmounted" then
param2 = math.floor(param2 / 8) * 8
elseif paramtype2 == "colordegrotate" then
Expand All @@ -154,3 +179,61 @@ function core.strip_param2_color(param2, paramtype2)
-- paramtype2 == "color" requires no modification.
return param2
end

-- Content ID caching

local old_get_content_id = core.get_content_id
local old_get_name_from_content_id = core.get_name_from_content_id

local name2content = setmetatable({}, {
__index = function(self, name)
return old_get_content_id(name)
end,
})

local content2name = setmetatable({}, {
__index = function(self, id)
return old_get_name_from_content_id(id)
end,
})

function core.get_content_id(name)
return name2content[name]
end

function core.get_name_from_content_id(id)
return content2name[id]
end

-- Cache content IDs after they have stopped changing.
function builtin_shared.cache_content_ids()
for name in pairs(core.registered_nodes) do
local id = old_get_content_id(name)
name2content[name] = id
content2name[id] = name
end
-- unknown is not in the registered node list.
local unknown_name = old_get_name_from_content_id(core.CONTENT_UNKNOWN)
name2content[unknown_name] = core.CONTENT_UNKNOWN
content2name[core.CONTENT_UNKNOWN] = unknown_name

for name in pairs(core.registered_aliases) do
if core.registered_nodes[name] then
name2content[name] = old_get_content_id(name)
end
end
end

if core.set_read_node and core.set_push_node then
local function read_node(node)
return name2content[node.name], node.param1, node.param2
end
core.set_read_node(read_node)
core.set_read_node = nil

local function push_node(content, param1, param2)
return {name = content2name[content], param1 = param1, param2 = param2}
end
core.set_push_node(push_node)
core.set_push_node = nil
end
12 changes: 0 additions & 12 deletions builtin/common/misc_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -519,18 +519,6 @@ end
--------------------------------------------------------------------------------
-- mainmenu only functions
--------------------------------------------------------------------------------
if INIT == "mainmenu" then
function core.get_game(index)
local games = core.get_games()

if index > 0 and index <= #games then
return games[index]
end

return nil
end
end

if core.gettext then -- for client and mainmenu
function fgettext_ne(text, ...)
text = core.gettext(text)
Expand Down
36 changes: 25 additions & 11 deletions builtin/common/serialize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,21 @@ end
-- Serializes Lua nil, booleans, numbers, strings, tables and even functions
-- Tables are referenced by reference, strings are referenced by value. Supports circular tables.
local function serialize(value, write)
local reference, refnum = "r1", 1
-- [object] = reference string
local reference, refnum = "1", 1
-- [object] = reference
local references = {}
-- Circular tables that must be filled using `table[key] = value` statements
local to_fill = {}
for object, count in pairs(count_objects(value)) do
local type_ = type(object)
-- Object must appear more than once. If it is a string, the reference has to be shorter than the string.
if count >= 2 and (type_ ~= "string" or #reference + 2 < #object) then
if count >= 2 and (type_ ~= "string" or #reference + 5 < #object) then
if refnum == 1 then
write"local _={};" -- initialize reference table
end
write"_["
write(reference)
write("=")
write("]=")
if type_ == "table" then
write("{}")
elseif type_ == "function" then
Expand All @@ -85,7 +89,7 @@ local function serialize(value, write)
to_fill[object] = reference
end
refnum = refnum + 1
reference = ("r%X"):format(refnum)
reference = ("%d"):format(refnum)
end
end
-- Used to decide whether we should do "key=..."
Expand All @@ -105,12 +109,22 @@ local function serialize(value, write)
end
local type_ = type(value)
if type_ == "number" then
return write(string_format("%.17g", value))
if value ~= value then -- nan
return write"0/0"
elseif value == math_huge then
return write"1/0"
elseif value == -math_huge then
return write"-1/0"
else
return write(string_format("%.17g", value))
end
end
-- Reference types: table, function and string
local ref = references[value]
if ref then
return write(ref)
write"_["
write(ref)
return write"]"
end
if type_ == "string" then
return write(quote(value))
Expand Down Expand Up @@ -156,7 +170,9 @@ local function serialize(value, write)
-- Write the statements to fill circular tables
for table, ref in pairs(to_fill) do
for k, v in pairs(table) do
write("_[")
write(ref)
write("]")
if use_short_key(k) then
write(".")
write(k)
Expand Down Expand Up @@ -185,8 +201,6 @@ end

local function dummy_func() end

local nan = (0/0)^1 -- +nan

function core.deserialize(str, safe)
-- Backwards compatibility
if str == nil then
Expand All @@ -201,8 +215,8 @@ function core.deserialize(str, safe)
local func, err = loadstring(str)
if not func then return nil, err end

-- math.huge is serialized to inf, NaNs are serialized to nan by Lua
local env = {inf = math_huge, nan = nan}
-- math.huge was serialized to inf and NaNs to nan by Lua in Minetest 5.6, so we have to support this here
local env = {inf = math_huge, nan = 0/0}
if safe then
env.loadstring = dummy_func
else
Expand Down
1 change: 0 additions & 1 deletion builtin/common/tests/misc_helpers_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_G.core = {}
_G.vector = {metatable = {}}
dofile("builtin/common/vector.lua")
dofile("builtin/common/misc_helpers.lua")

Expand Down
1 change: 0 additions & 1 deletion builtin/common/tests/serialize_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_G.core = {}
_G.vector = {metatable = {}}

_G.setfenv = require 'busted.compatibility'.setfenv

Expand Down
Loading

0 comments on commit 28e6e13

Please sign in to comment.