Skip to content

Commit

Permalink
Merge branch 'minetest:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeno333 committed May 21, 2024
2 parents 5032c11 + bd4572c commit 349291f
Show file tree
Hide file tree
Showing 29 changed files with 305 additions and 228 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ "*.*.*" ]
tags: [ "*" ]
pull_request:
# Build docker image on pull requests. (but do not publish)
paths:
Expand All @@ -25,6 +25,12 @@ on:
- '.dockerignore'
- '.github/workflows/docker_image.yml'
workflow_dispatch:
inputs:
use_cache:
description: "Use build cache"
required: true
type: boolean
default: true

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -82,6 +88,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
no-cache: ${{ (github.event_name == 'workflow_dispatch' && !inputs.use_cache) || startsWith(github.ref, 'refs/tags/') }}

- name: Test Docker Image
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- name: CPack
run: |
cd build
cmake .. -DINSTALL_DEVTEST=FALSE
cpack -G ZIP -B macos
- uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions builtin/game/features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ core.features = {
item_meta_range = true,
node_interaction_actor = true,
moveresult_new_pos = true,
override_item_remove_fields = true,
}

function core.has_feature(arg)
Expand Down
2 changes: 1 addition & 1 deletion builtin/game/misc_s.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if core.set_push_moveresult1 then
standing_on_object = b2,
collisions = {{
type = "node",
axis = AXES[axis],
axis = AXES[axis + 1],
node_pos = vector.new(npx, npy, npz),
new_pos = vector.new(v0x, v0y, v0z),
old_velocity = vector.new(v1x, v1y, v1z),
Expand Down
5 changes: 4 additions & 1 deletion builtin/game/register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ core.register_item(":", {
})


function core.override_item(name, redefinition)
function core.override_item(name, redefinition, del_fields)
if redefinition.name ~= nil then
error("Attempt to redefine name of "..name.." to "..dump(redefinition.name), 2)
end
Expand All @@ -418,6 +418,9 @@ function core.override_item(name, redefinition)
for k, v in pairs(redefinition) do
rawset(item, k, v)
end
for _, field in ipairs(del_fields or {}) do
rawset(item, field, nil)
end
register_item_raw(item)
end

Expand Down
12 changes: 10 additions & 2 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5444,6 +5444,8 @@ Utilities
node_interaction_actor = true,
-- "new_pos" field in entity moveresult (5.9.0)
moveresult_new_pos = true,
-- Allow removing definition fields in `minetest.override_item`
override_item_remove_fields = true,
}
```

Expand Down Expand Up @@ -5613,11 +5615,17 @@ Call these functions only at load time!
* `minetest.register_node(name, node definition)`
* `minetest.register_craftitem(name, item definition)`
* `minetest.register_tool(name, item definition)`
* `minetest.override_item(name, redefinition)`
* `minetest.override_item(name, redefinition, del_fields)`
* `redefinition` is a table of fields `[name] = new_value`,
overwriting fields of or adding fields to the existing definition.
* `del_fields` is a list of field names to be set
to `nil` ("deleted from") the original definition.
* Overrides fields of an item registered with register_node/tool/craftitem.
* Note: Item must already be defined, (opt)depend on the mod defining it.
* Example: `minetest.override_item("default:mese",
{light_source=minetest.LIGHT_MAX})`
{light_source=minetest.LIGHT_MAX}, {"sounds"})`:
Overwrites the `light_source` field,
removes the sounds from the definition of the mese block.
* `minetest.unregister_item(name)`
* Unregisters the item from the engine, and deletes the entry with key
`name` from `minetest.registered_items` and from the associated item table
Expand Down
32 changes: 28 additions & 4 deletions games/devtest/mods/unittests/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function unittests.run_all()
-- Print stats
assert(#unittests.list == counters.total)
print(string.rep("+", 80))
print(string.format("Unit Test Results: %s",
print(string.format("Devtest Unit Test Results: %s",
counters.total == counters.passed and "PASSED" or "FAILED"))
print(string.format(" %d / %d failed tests.",
counters.total - counters.passed, counters.total))
Expand All @@ -185,22 +185,46 @@ dofile(modpath .. "/content_ids.lua")
dofile(modpath .. "/metadata.lua")
dofile(modpath .. "/raycast.lua")
dofile(modpath .. "/inventory.lua")
dofile(modpath .. "/load_time.lua")

--------------

local function send_results(name, ok)
core.chat_send_player(name,
minetest.colorize(ok and "green" or "red",
(ok and "All devtest unit tests passed." or
"There were devtest unit test failures.") ..
" Check the console for detailed output."))
end

if core.settings:get_bool("devtest_unittests_autostart", false) then
local test_results = nil
core.after(0, function()
-- CI adds a mod which sets `unittests.on_finished`
-- to write status information to the filesystem
local old_on_finished = unittests.on_finished
unittests.on_finished = function(ok)
for _, player in ipairs(minetest.get_connected_players()) do
send_results(player:get_player_name(), ok)
end
test_results = ok
old_on_finished(ok)
end
coroutine.wrap(unittests.run_all)()
end)
minetest.register_on_joinplayer(function(player)
if test_results == nil then
return -- tests haven't completed yet
end
send_results(player:get_player_name(), test_results)
end)
else
core.register_chatcommand("unittests", {
privs = {basic_privs=true},
description = "Runs devtest unittests (may modify player or map state)",
func = function(name, param)
unittests.on_finished = function(ok)
core.chat_send_player(name,
(ok and "All tests passed." or "There were test failures.") ..
" Check the console for detailed output.")
send_results(name, ok)
end
coroutine.wrap(unittests.run_all)()
return true, ""
Expand Down
13 changes: 13 additions & 0 deletions games/devtest/mods/unittests/load_time.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Test item (un)registration and overriding
do
local itemname = "unittests:test_override_item"
minetest.register_craftitem(":" .. itemname, {description = "foo"})
assert(assert(minetest.registered_items[itemname]).description == "foo")
minetest.override_item(itemname, {description = "bar"})
assert(assert(minetest.registered_items[itemname]).description == "bar")
minetest.override_item(itemname, {}, {"description"})
-- description has the empty string as a default
assert(assert(minetest.registered_items[itemname]).description == "")
minetest.unregister_item("unittests:test_override_item")
assert(minetest.registered_items["unittests:test_override_item"] == nil)
end
2 changes: 1 addition & 1 deletion irr/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
elseif(MSVC)
string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " msvcrt.lib") # ???? fuck off

add_compile_options(/GR- /Zl)
add_compile_options(/Zl)

# Enable SSE for floating point math on 32-bit x86 by default
# reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
Expand Down
23 changes: 4 additions & 19 deletions irr/src/COSOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@

#include "fast_atof.h"

#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
static const bool sdl_supports_primary_selection = [] {
#if SDL_VERSION_ATLEAST(2, 25, 0)
SDL_version linked_version;
SDL_GetVersion(&linked_version);
return (linked_version.major == 2 && linked_version.minor >= 25) || linked_version.major > 2;
#else
return false;
#endif
}();
#endif

namespace irr
{

Expand Down Expand Up @@ -131,8 +119,7 @@ void COSOperator::copyToPrimarySelection(const c8 *text) const

#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#if SDL_VERSION_ATLEAST(2, 25, 0)
if (sdl_supports_primary_selection)
SDL_SetPrimarySelectionText(text);
SDL_SetPrimarySelectionText(text);
#endif

#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
Expand Down Expand Up @@ -195,11 +182,9 @@ const c8 *COSOperator::getTextFromPrimarySelection() const
{
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#if SDL_VERSION_ATLEAST(2, 25, 0)
if (sdl_supports_primary_selection) {
SDL_free(PrimarySelectionText);
PrimarySelectionText = SDL_GetPrimarySelectionText();
return PrimarySelectionText;
}
SDL_free(PrimarySelectionText);
PrimarySelectionText = SDL_GetPrimarySelectionText();
return PrimarySelectionText;
#endif
return 0;

Expand Down
6 changes: 0 additions & 6 deletions irr/src/OpenGL/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,6 @@ IRenderTarget *COpenGL3DriverBase::addRenderTarget()
return renderTarget;
}

// small helper function to create vertex buffer object adress offsets
static inline u8 *buffer_offset(const long offset)
{
return ((u8 *)0 + offset);
}

//! draws a vertex primitive list
void COpenGL3DriverBase::drawVertexPrimitiveList(const void *vertices, u32 vertexCount,
const void *indexList, u32 primitiveCount,
Expand Down
2 changes: 2 additions & 0 deletions irr/src/OpenGL/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class COpenGL3DriverBase : public CNullDriver, public IMaterialRendererServices,
// internally used
virtual void draw2DImage(const video::ITexture *texture, u32 layer, bool flip);

using CNullDriver::draw2DImage;

void draw2DImageBatch(const video::ITexture *texture,
const core::array<core::position2d<s32>> &positions,
const core::array<core::rect<s32>> &sourceRects,
Expand Down
10 changes: 5 additions & 5 deletions irr/src/OpenGL/MaterialRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class COpenGL3MaterialRenderer : public IMaterialRenderer, public IMaterialRende
GLuint getProgram() const;

virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices *services);
bool resetAllRenderstates, IMaterialRendererServices *services) override;

virtual bool OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype);
virtual bool OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype) override;

virtual void OnUnsetMaterial();
virtual void OnUnsetMaterial() override;

virtual bool isTransparent() const;
virtual bool isTransparent() const override;

virtual s32 getRenderCapability() const;
virtual s32 getRenderCapability() const override;

void setBasicRenderStates(const SMaterial &material, const SMaterial &lastMaterial, bool resetAllRenderstates) override;

Expand Down
16 changes: 10 additions & 6 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ class Game {

// Misc
void showOverlayMessage(const char *msg, float dtime, int percent,
bool draw_clouds = true);
float *indef_pos = nullptr);

inline bool fogEnabled()
{
Expand Down Expand Up @@ -966,6 +966,8 @@ class Game {
#ifdef __ANDROID__
bool m_android_chat_open;
#endif

float m_shutdown_progress = 0.0f;
};

Game::Game() :
Expand Down Expand Up @@ -1245,7 +1247,9 @@ void Game::shutdown()
if (g_touchscreengui)
g_touchscreengui->hide();

showOverlayMessage(N_("Shutting down..."), 0, 0, false);
// only if the shutdown progress bar isn't shown yet
if (m_shutdown_progress == 0.0f)
showOverlayMessage(N_("Shutting down..."), 0, 0);

if (clouds)
clouds->drop();
Expand Down Expand Up @@ -1297,7 +1301,7 @@ void Game::shutdown()
m_rendering_engine->run();
f32 dtime;
fps_control.limit(device, &dtime);
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
showOverlayMessage(N_("Shutting down..."), dtime, 0, &m_shutdown_progress);
}

stop_thread->rethrow();
Expand Down Expand Up @@ -1429,7 +1433,7 @@ bool Game::createSingleplayerServer(const std::string &map_dir,
if (success)
showOverlayMessage(N_("Creating server..."), dtime, 5);
else
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
showOverlayMessage(N_("Shutting down..."), dtime, 0, &m_shutdown_progress);
}

start_thread->rethrow();
Expand Down Expand Up @@ -4366,10 +4370,10 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
Misc
****************************************************************************/

void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool draw_sky)
void Game::showOverlayMessage(const char *msg, float dtime, int percent, float *indef_pos)
{
m_rendering_engine->draw_load_screen(wstrgettext(msg), guienv, texture_src,
dtime, percent, draw_sky);
dtime, percent, indef_pos);
}

void Game::settingChangedCallback(const std::string &setting_name, void *data)
Expand Down
15 changes: 9 additions & 6 deletions src/client/localplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,18 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
m_speed.Z = 0.0f;
}

if (y_diff > 0 && m_speed.Y <= 0.0f &&
(physics_override.sneak_glitch || y_diff < BS * 0.6f)) {
if (y_diff > 0 && m_speed.Y <= 0.0f) {
// Move player to the maximal height when falling or when
// the ledge is climbed on the next step.

// Smoothen the movement (based on 'position.Y = bmax.Y')
position.Y += y_diff * dtime * 22.0f + BS * 0.01f;
position.Y = std::min(position.Y, bmax.Y);
m_speed.Y = 0.0f;
v3f check_pos = position;
check_pos.Y += y_diff * dtime * 22.0f + BS * 0.01f;
if (y_diff < BS * 0.6f || (physics_override.sneak_glitch
&& !collision_check_intersection(env, m_client, m_collisionbox, check_pos))) {
// Smoothen the movement (based on 'position.Y = bmax.Y')
position.Y = std::min(check_pos.Y, bmax.Y);
m_speed.Y = 0.0f;
}
}

// Allow jumping on node edges while sneaking
Expand Down
27 changes: 0 additions & 27 deletions src/client/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,32 +329,6 @@ void final_color_blend(video::SColor *result,
Mesh generation helpers
*/

// This table is moved outside getNodeVertexDirs to avoid the compiler using
// a mutex to initialize this table at runtime right in the hot path.
// For details search the internet for "cxa_guard_acquire".
static const v3s16 vertex_dirs_table[] = {
// ( 1, 0, 0)
v3s16( 1,-1, 1), v3s16( 1,-1,-1),
v3s16( 1, 1,-1), v3s16( 1, 1, 1),
// ( 0, 1, 0)
v3s16( 1, 1,-1), v3s16(-1, 1,-1),
v3s16(-1, 1, 1), v3s16( 1, 1, 1),
// ( 0, 0, 1)
v3s16(-1,-1, 1), v3s16( 1,-1, 1),
v3s16( 1, 1, 1), v3s16(-1, 1, 1),
// invalid
v3s16(), v3s16(), v3s16(), v3s16(),
// ( 0, 0,-1)
v3s16( 1,-1,-1), v3s16(-1,-1,-1),
v3s16(-1, 1,-1), v3s16( 1, 1,-1),
// ( 0,-1, 0)
v3s16( 1,-1, 1), v3s16(-1,-1, 1),
v3s16(-1,-1,-1), v3s16( 1,-1,-1),
// (-1, 0, 0)
v3s16(-1,-1,-1), v3s16(-1,-1, 1),
v3s16(-1, 1, 1), v3s16(-1, 1,-1)
};

/*
Gets nth node tile (0 <= n <= 5).
*/
Expand Down Expand Up @@ -1006,7 +980,6 @@ video::SColor encode_light(u16 light, u8 emissive_light)
u8 get_solid_sides(MeshMakeData *data)
{
std::unordered_map<v3s16, u8> results;
v3s16 ofs;
v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
const NodeDefManager *ndef = data->nodedef;

Expand Down
Loading

0 comments on commit 349291f

Please sign in to comment.