1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-06 18:25:21 +01:00

Merge branch 'master' into doc-refactor-2

This commit is contained in:
Bradley Pierce
2024-01-20 08:38:10 -05:00
26 changed files with 68 additions and 71 deletions

View File

@@ -74,7 +74,7 @@ jobs:
env:
VCPKG_VERSION: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50
# 2023.10.19
vcpkg_packages: zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp opengl-registry
vcpkg_packages: zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp opengl-registry sdl2
strategy:
fail-fast: false
matrix:

View File

@@ -140,7 +140,7 @@ elseif(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt)
endif()
message(STATUS "Found IrrlichtMt ${IrrlichtMt_VERSION}")
set(TARGET_VER_S 1.9.0mt13)
set(TARGET_VER_S 1.9.0mt14)
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")

View File

@@ -1826,11 +1826,6 @@ mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50
# Value of 0 (default) will let Minetest autodetect the number of available threads.
mesh_generation_threads (Mapblock mesh generation threads) int 0 0 8
# Size of the MapBlock cache of the mesh generator. Increasing this will
# increase the cache hit %, reducing the data being copied from the main
# thread, thus reducing jitter.
meshgen_block_cache_size (Mapblock mesh generator's MapBlock cache size in MB) int 20 0 1000
# True = 256
# False = 128
# Usable to make minimap smoother on slower machines.

View File

@@ -7,8 +7,12 @@
| GCC | 7.5+ | or Clang 7.0.1+ |
| CMake | 3.5+ | |
| IrrlichtMt | - | Custom version of Irrlicht, see https://github.com/minetest/irrlicht |
| libjpeg | - | (via IrrlichtMt) |
| libpng | - | (via IrrlichtMt) |
| SDL | 2.x | (via IrrlichtMt) |
| Freetype | 2.0+ | |
| SQLite3 | 3+ | |
| Zlib | - | |
| Zstd | 1.0+ | |
| LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present |
| GMP | 5.0.0+ | Bundled mini-GMP is used if not present |
@@ -18,27 +22,27 @@
For Debian/Ubuntu users:
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxi-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev gettext
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxi-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev gettext libsdl2-dev
For Fedora users:
sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libpng-devel libjpeg-devel libvorbis-devel libXi-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel libzstd-devel gettext
sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libpng-devel libjpeg-devel libvorbis-devel libXi-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel libzstd-devel gettext SDL2-devel
For openSUSE users:
sudo zypper install gcc cmake libjpeg8-devel libpng16-devel openal-soft-devel libcurl-devel sqlite3-devel luajit-devel libzstd-devel Mesa-libGL-devel libXi-devel libvorbis-devel freetype2-devel
sudo zypper install gcc cmake libjpeg8-devel libpng16-devel openal-soft-devel libcurl-devel sqlite3-devel luajit-devel libzstd-devel Mesa-libGL-devel libXi-devel libvorbis-devel freetype2-devel SDL2-devel
For Arch users:
sudo pacman -S --needed base-devel libcurl-gnutls cmake libxi libpng sqlite libogg libvorbis openal freetype2 jsoncpp gmp luajit leveldb ncurses zstd gettext
sudo pacman -S --needed base-devel libcurl-gnutls cmake libxi libpng sqlite libogg libvorbis openal freetype2 jsoncpp gmp luajit leveldb ncurses zstd gettext sdl2
For Alpine users:
sudo apk add build-base cmake libpng-dev jpeg-dev libxi-dev mesa-dev sqlite-dev libogg-dev libvorbis-dev openal-soft-dev curl-dev freetype-dev zlib-dev gmp-dev jsoncpp-dev luajit-dev zstd-dev gettext
sudo apk add build-base cmake libpng-dev jpeg-dev libxi-dev mesa-dev sqlite-dev libogg-dev libvorbis-dev openal-soft-dev curl-dev freetype-dev zlib-dev gmp-dev jsoncpp-dev luajit-dev zstd-dev gettext sdl2-dev
For Void users:
sudo xbps-install cmake libpng-devel jpeg-devel libXi-devel mesa sqlite-devel libogg-devel libvorbis-devel libopenal-devel libcurl-devel freetype-devel zlib-devel gmp-devel jsoncpp-devel LuaJIT-devel libzstd-devel gettext
sudo xbps-install cmake libpng-devel jpeg-devel libXi-devel mesa sqlite-devel libogg-devel libvorbis-devel libopenal-devel libcurl-devel freetype-devel zlib-devel gmp-devel jsoncpp-devel LuaJIT-devel libzstd-devel gettext SDL2-devel
## Download

View File

@@ -14,7 +14,7 @@ It is highly recommended to use vcpkg as package manager.
After you successfully built vcpkg you can easily install the required libraries:
```powershell
vcpkg install zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp opengl-registry gettext --triplet x64-windows
vcpkg install zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp opengl-registry gettext sdl2 --triplet x64-windows
```
* **Don't forget about IrrlichtMt.** The easiest way is to clone it to `lib/irrlichtmt`:

View File

@@ -1 +1 @@
1.9.0mt13
1.9.0mt14

View File

@@ -326,6 +326,9 @@ if(HAVE_LINK_ATOMIC)
set(PLATFORM_LIBS ${PLATFORM_LIBS} "-latomic")
endif()
include(CheckSymbolExists)
check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)
check_include_files(endian.h HAVE_ENDIAN_H)
configure_file(
@@ -693,7 +696,6 @@ endif()
# Set some optimizations and tweaks
include(CheckCSourceCompiles)
include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${LUA_INCLUDE_DIR})
if(USE_LUAJIT)

View File

@@ -278,6 +278,10 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
error_message = gettext("Connection error (timed out?)");
errorstream << error_message << std::endl;
}
catch (ShaderException &e) {
error_message = e.what();
errorstream << error_message << std::endl;
}
#ifdef NDEBUG
catch (std::exception &e) {

View File

@@ -54,7 +54,6 @@ MeshUpdateQueue::MeshUpdateQueue(Client *client):
{
m_cache_enable_shaders = g_settings->getBool("enable_shaders");
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
m_meshgen_block_cache_size = g_settings->getS32("meshgen_block_cache_size");
}
MeshUpdateQueue::~MeshUpdateQueue()

View File

@@ -87,7 +87,6 @@ private:
// TODO: Add callback to update these when g_settings changes
bool m_cache_enable_shaders;
bool m_cache_smooth_lighting;
int m_meshgen_block_cache_size;
void fillDataFromMapBlocks(QueuedMeshUpdate *q);
void cleanupCache();

View File

@@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IShaderConstantSetCallBack.h>
#include "client/renderingengine.h"
#include "EShaderTypes.h"
#include "gettext.h"
#include "log.h"
#include "gamedef.h"
#include "client/tile.h"
@@ -588,8 +589,8 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
if (!driver->queryFeature(video::EVDF_ARB_GLSL)) {
errorstream << "Shaders are enabled but GLSL is not supported by the driver\n";
return shaderinfo;
throw ShaderException(gettext("Shaders are enabled but GLSL is not "
"supported by the driver."));
}
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
@@ -792,7 +793,9 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
dumpShaderProgram(warningstream, "Vertex", vertex_shader);
dumpShaderProgram(warningstream, "Fragment", fragment_shader);
dumpShaderProgram(warningstream, "Geometry", geometry_shader);
return shaderinfo;
throw ShaderException(
fmtgettext("Failed to compile the \"%s\" shader.", name.c_str()) +
strgettext("\nCheck debug.txt for details."));
}
// Apply the newly created material type

View File

@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sstream>
#include "clientiface.h"
#include "debug.h"
#include "network/connection.h"
#include "network/serveropcodes.h"
#include "remoteplayer.h"
@@ -31,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "server/player_sao.h"
#include "log.h"
#include "util/srp.h"
#include "util/string.h"
#include "face_position_cache.h"
static std::string string_sanitize_ascii(const std::string &s, u32 max_length)
@@ -649,6 +651,14 @@ void RemoteClient::resetChosenMech()
chosen_mech = AUTH_MECHANISM_NONE;
}
void RemoteClient::setEncryptedPassword(const std::string& pwd)
{
FATAL_ERROR_IF(!str_starts_with(pwd, "#1#"), "must be srp");
enc_pwd = pwd;
// We just set SRP encrypted password, we accept only it now
allowed_auth_mechs = AUTH_MECHANISM_SRP;
}
void RemoteClient::setVersionInfo(u8 major, u8 minor, u8 patch, const std::string &full)
{
m_version_major = major;

View File

@@ -243,15 +243,14 @@ public:
AuthMechanism chosen_mech = AUTH_MECHANISM_NONE;
void *auth_data = nullptr;
u32 allowed_auth_mechs = 0;
u32 allowed_sudo_mechs = 0;
void resetChosenMech();
bool isSudoMechAllowed(AuthMechanism mech)
{ return allowed_sudo_mechs & mech; }
bool isMechAllowed(AuthMechanism mech)
{ return allowed_auth_mechs & mech; }
void setEncryptedPassword(const std::string& pwd);
RemoteClient();
~RemoteClient() = default;

View File

@@ -30,6 +30,7 @@
#cmakedefine01 USE_SYSTEM_JSONCPP
#cmakedefine01 USE_REDIS
#cmakedefine01 HAVE_ENDIAN_H
#cmakedefine01 HAVE_STRLCPY
#cmakedefine01 CURSES_HAVE_CURSES_H
#cmakedefine01 CURSES_HAVE_NCURSES_H
#cmakedefine01 CURSES_HAVE_NCURSES_NCURSES_H

View File

@@ -46,7 +46,6 @@ void set_default_settings()
settings->setDefault("enable_mesh_cache", "false");
settings->setDefault("mesh_generation_interval", "0");
settings->setDefault("mesh_generation_threads", "0");
settings->setDefault("meshgen_block_cache_size", "20");
settings->setDefault("enable_vbo", "true");
settings->setDefault("free_move", "false");
settings->setDefault("pitch_move", "false");

View File

@@ -92,6 +92,11 @@ public:
PrngException(const std::string &s): BaseException(s) {}
};
class ShaderException : public BaseException {
public:
ShaderException(const std::string &s): BaseException(s) {}
};
class ModError : public BaseException {
public:
ModError(const std::string &s): BaseException(s) {}

View File

@@ -678,12 +678,8 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
if (!was_url_pressed
&& event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN) {
// Paste primary selection at cursor pos
#if IRRLICHT_VERSION_MT_REVISION >= 11
const c8 *text = Environment->getOSOperator()
->getTextFromPrimarySelection();
#else
const c8 *text = nullptr;
#endif
if (text)
prompt.input(utf8_to_wide(text));
}
@@ -774,9 +770,7 @@ bool GUIChatConsole::weblinkClick(s32 col, s32 row)
void GUIChatConsole::updatePrimarySelection()
{
#if IRRLICHT_VERSION_MT_REVISION >= 11
std::wstring wselected = m_chat_backend->getPrompt().getSelection();
std::string selected = wide_to_utf8(wselected);
Environment->getOSOperator()->copyToPrimarySelection(selected.c_str());
#endif
}

View File

@@ -178,7 +178,6 @@ void GUIEditBox::setTextMarkers(s32 begin, s32 end)
m_mark_begin = begin;
m_mark_end = end;
#if IRRLICHT_VERSION_MT_REVISION >= 11
if (!m_passwordbox && m_operator && m_mark_begin != m_mark_end) {
// copy to primary selection
const s32 realmbgn = m_mark_begin < m_mark_end ? m_mark_begin : m_mark_end;
@@ -187,7 +186,6 @@ void GUIEditBox::setTextMarkers(s32 begin, s32 end)
std::string s = stringw_to_utf8(Text.subString(realmbgn, realmend - realmbgn));
m_operator->copyToPrimarySelection(s.c_str());
}
#endif
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
}
@@ -796,7 +794,6 @@ bool GUIEditBox::processMouse(const SEvent &event)
m_mouse_marking = false;
setTextMarkers(m_cursor_pos, m_cursor_pos);
#if IRRLICHT_VERSION_MT_REVISION >= 11
// paste from the primary selection
inputString([&] {
if (!m_operator)
@@ -806,7 +803,6 @@ bool GUIEditBox::processMouse(const SEvent &event)
return core::stringw();
return utf8_to_stringw(inserted_text_utf8);
}());
#endif
return true;
}

View File

@@ -1515,8 +1515,7 @@ void Server::handleCommand_FirstSrp(NetworkPacket* pkt)
return;
}
std::string initial_ver_key;
initial_ver_key = encode_srp_verifier(verification_key, salt);
std::string encpwd = encode_srp_verifier(verification_key, salt);
// It is possible for multiple connections to get this far with the same
// player name. In the end only one player with a given name will be emerged
@@ -1529,9 +1528,11 @@ void Server::handleCommand_FirstSrp(NetworkPacket* pkt)
DenyAccess(peer_id, SERVER_ACCESSDENIED_ALREADY_CONNECTED);
return;
}
m_script->createAuth(playername, initial_ver_key);
m_script->on_authplayer(playername, addr_s, true);
m_script->createAuth(playername, encpwd);
client->setEncryptedPassword(encpwd);
m_script->on_authplayer(playername, addr_s, true);
acceptAuth(peer_id, false);
} else {
if (cstate < CS_SudoMode) {
@@ -1550,12 +1551,13 @@ void Server::handleCommand_FirstSrp(NetworkPacket* pkt)
return;
}
std::string pw_db_field = encode_srp_verifier(verification_key, salt);
bool success = m_script->setPassword(playername, pw_db_field);
std::string encpwd = encode_srp_verifier(verification_key, salt);
bool success = m_script->setPassword(playername, encpwd);
if (success) {
actionstream << playername << " changes password" << std::endl;
SendChatMessage(peer_id, ChatMessage(CHATMESSAGE_TYPE_SYSTEM,
L"Password change successful."));
client->setEncryptedPassword(encpwd);
} else {
actionstream << playername <<
" tries to change password but it fails" << std::endl;
@@ -1606,7 +1608,8 @@ void Server::handleCommand_SrpBytesA(NetworkPacket* pkt)
AUTH_MECHANISM_LEGACY_PASSWORD : AUTH_MECHANISM_SRP;
if (wantSudo) {
if (!client->isSudoMechAllowed(chosen)) {
// Right now, the auth mechs don't change between login and sudo mode.
if (!client->isMechAllowed(chosen)) {
actionstream << "Server: Player \"" << client->getName() <<
"\" at " << getPeerAddress(peer_id).serializeString() <<
" tried to change password using unallowed mech " << chosen <<

View File

@@ -56,8 +56,9 @@ public:
inline u32 next()
{
m_next = m_next * 1103515245 + 12345;
return (u32)(m_next / 65536) % (RANDOM_RANGE + 1);
m_next = static_cast<u32>(m_next) * 1103515245U + 12345U;
// Signed division is required due to backwards compatibility
return static_cast<u32>(m_next / 65536) % (RANDOM_RANGE + 1U);
}
inline s32 range(s32 min, s32 max)
@@ -70,7 +71,7 @@ public:
PcgRandom, we cannot modify this RNG's range as it would change the
output of this RNG for reverse compatibility.
*/
if ((u32)(max - min) > (RANDOM_RANGE + 1) / 5)
if (static_cast<u32>(max - min) > (RANDOM_RANGE + 1) / 5)
throw PrngException("Range too large");
return (next() % (max - min + 1)) + min;

View File

@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Be mindful of what you include here!
#include <string>
#include "config.h"
#include "irrlichttypes.h" // u64
#include "debug.h"
#include "constants.h"
@@ -70,21 +71,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define strtok_r(x, y, z) mystrtok_r(x, y, z)
#endif
// strlcpy is missing from glibc. thanks a lot, drepper.
// strlcpy is also missing from AIX and HP-UX because they aim to be weird.
// We can't simply alias strlcpy to MSVC's strcpy_s, since strcpy_s by
// default raises an assertion error and aborts the program if the buffer is
// too small.
#if defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__) || defined(__DragonFly__) || \
defined(__APPLE__) || \
defined(__sun) || defined(sun) || \
defined(__QNX__) || defined(__QNXNTO__)
#define HAVE_STRLCPY
#endif
// So we need to define our own.
#ifndef HAVE_STRLCPY
#if !HAVE_STRLCPY
#define strlcpy(d, s, n) mystrlcpy(d, s, n)
#endif

View File

@@ -2902,13 +2902,9 @@ void Server::acceptAuth(session_t peer_id, bool forSudoMode)
NetworkPacket resp_pkt(TOCLIENT_AUTH_ACCEPT, 1 + 6 + 8 + 4, peer_id);
// Right now, the auth mechs don't change between login and sudo mode.
u32 sudo_auth_mechs = client->allowed_auth_mechs;
client->allowed_sudo_mechs = sudo_auth_mechs;
resp_pkt << v3f(0,0,0) << (u64) m_env->getServerMap().getSeed()
<< g_settings->getFloat("dedicated_server_step")
<< sudo_auth_mechs;
<< client->allowed_auth_mechs;
Send(&resp_pkt);
m_clients.event(peer_id, CSE_AuthAccept);

View File

@@ -37,7 +37,7 @@ mkdir -p $libdir
cd $libdir
libhost="http://minetest.kitsunemimi.pw"
download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win32-ucrt.zip" irrlicht-$irrlicht_version-win32.zip
download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win32.zip" irrlicht-$irrlicht_version-win32.zip
download "$libhost/zlib-$zlib_version-win32.zip"
download "$libhost/ucrt/zstd-$zstd_version-win32.zip"
download "$libhost/ucrt/libogg-$ogg_version-win32.zip"

View File

@@ -37,7 +37,7 @@ mkdir -p $libdir
cd $libdir
libhost="http://minetest.kitsunemimi.pw"
download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win64-ucrt.zip" irrlicht-$irrlicht_version-win64.zip
download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win64.zip" irrlicht-$irrlicht_version-win64.zip
download "$libhost/zlib-$zlib_version-win64.zip"
download "$libhost/ucrt/zstd-$zstd_version-win64.zip"
download "$libhost/ucrt/libogg-$ogg_version-win64.zip"

View File

@@ -4,8 +4,8 @@ d70c9886526513a2c8a7962815fb425f296ab934239470a03ea350944169a7ac freetype-2.13.
06aa20c71724e832874baa296d047aa866db2c336e26aa49e4faa72e559414a6 freetype-2.13.2-win64.zip
41b10766de2773f0f0851fde16b363024685e0397f4bb2e5cd2a7be196960a01 gettext-0.20.2-win32.zip
1ceed167ff16fea944f76ab6ea2969160c71a67419259b17c9c523e7a01eb883 gettext-0.20.2-win64.zip
15d09d259b62ce0b5d7582a26360f60bb99784c5b223364b6f21dc9d99844d15 irrlicht-1.9.0mt13-win32.zip
ddfa8d61ac5404202588c0793842f49b0198d8e87b963fe196cca0781a3099ca irrlicht-1.9.0mt13-win64.zip
faa09cd5c3790fdad3fcb43ba1d5c5102492a7b88b9301de59cecb92af37c162 irrlicht-1.9.0mt14-win32.zip
a5724e994f417b04e43bc9dd54adf6f32050e39b2cc1a79acdf361a9d3972ece irrlicht-1.9.0mt14-win64.zip
6d49348215916ff355187fec808d0847450f70e45fe2719f45af9eb61c047358 leveldb-1.23-win32.zip
30c680277320bdda130b238d0adc30c3c59e7522dc008d677893ebfaea22f28b leveldb-1.23-win64.zip
d58b67954f3f552fba5e315ed476c38b230d0cf53445fe07dc733e72f8ba7dc2 libogg-1.3.5-win32.zip

View File

@@ -13,8 +13,8 @@ install_linux_deps() {
shift
else
local ver=$(cat misc/irrlichtmt_tag.txt)
wget "https://github.com/minetest/irrlicht/releases/download/$ver/ubuntu-bionic.tar.gz"
sudo tar -xaf ubuntu-bionic.tar.gz -C /usr/local
wget "https://github.com/minetest/irrlicht/releases/download/$ver/ubuntu-focal.tar.gz"
sudo tar -xaf ubuntu-focal.tar.gz -C /usr/local
fi
sudo apt-get update