5 changes: 3 additions & 2 deletions builtin/game/auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,20 @@ core.builtin_auth_handler = {
core.settings:get("default_password")))
end

local prev_privs = auth_entry.privileges
auth_entry.privileges = privileges

core_auth.save(auth_entry)

-- Run grant callbacks
for priv, _ in pairs(privileges) do
if not auth_entry.privileges[priv] then
if not prev_privs[priv] then
core.run_priv_callbacks(name, priv, nil, "grant")
end
end

-- Run revoke callbacks
for priv, _ in pairs(auth_entry.privileges) do
for priv, _ in pairs(prev_privs) do
if not privileges[priv] then
core.run_priv_callbacks(name, priv, nil, "revoke")
end
Expand Down
10 changes: 9 additions & 1 deletion builtin/mainmenu/content/update_detector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ end

local has_fetched = false
local latest_releases
do
local tmp = core.get_once("cdb_latest_releases")
if tmp then
latest_releases = core.deserialize(tmp, true)
has_fetched = latest_releases ~= nil
end
end


local function fetch_latest_releases()
Expand Down Expand Up @@ -89,8 +96,9 @@ local function fetch()
has_fetched = false
return
end

latest_releases = lowercase_keys(releases)
core.set_once("cdb_latest_releases", core.serialize(latest_releases))

if update_detector.get_count() > 0 then
local maintab = ui.find_by_name("maintab")
if not maintab.hidden then
Expand Down
6 changes: 6 additions & 0 deletions doc/menu_lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Functions
---------

* `core.start()`
* start game session
* `core.close()`
* exit engine
* `core.get_min_supp_proto()`
* returns the minimum supported network protocol version
* `core.get_max_supp_proto()`
Expand All @@ -53,6 +55,10 @@ Functions
* Android only. Shares file using the share popup
* `core.get_version()` (possible in async calls)
* returns current core version
* `core.set_once(key, value)`:
* save a string value that persists even if menu is closed
* `core.get_once(key)`:
* get a string value saved by above function, or `nil`



Expand Down
6 changes: 5 additions & 1 deletion games/devtest/mods/unittests/get_version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ unittests.register("test_get_version", function()
assert(type(version.proto_min) == "number")
assert(type(version.proto_max) == "number")
assert(version.proto_max >= version.proto_min)
assert(type(version.hash) == "string")
assert(type(version.is_dev) == "boolean")
if version.is_dev then
assert(type(version.hash) == "string")
else
assert(version.hash == nil)
end
end)
11 changes: 7 additions & 4 deletions games/devtest/mods/unittests/misc.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
local function test_random()
-- Try out PseudoRandom
local pseudo = PseudoRandom(13)
assert(pseudo:next() == 22290)
assert(pseudo:next() == 13854)
-- We have comprehensive unit tests in C++, this is just to make sure the API code isn't messing up
local pr = PseudoRandom(13)
assert(pr:next() == 22290)
assert(pr:next() == 13854)

local pr2 = PseudoRandom(-101)
assert(pr2:next(0, 100) == 35)
end
unittests.register("test_random", test_random)

Expand Down
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,9 @@ else()
endif()

if(MINGW)
set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601 -DWIN32_LEAN_AND_MEAN")
endif()

Expand Down Expand Up @@ -801,7 +803,7 @@ else()
endif()

if(MINGW)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mwindows")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-mwindows")
endif()
endif()

Expand Down
16 changes: 11 additions & 5 deletions src/client/content_cao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)

infostream << "GenericCAO::addToScene(): " << m_prop.visual << std::endl;

m_material_type_param = 0.5f; // May cut off alpha < 128 depending on m_material_type

if (m_enable_shaders) {
IShaderSource *shader_source = m_client->getShaderSource();
MaterialType material_type;
Expand All @@ -633,8 +635,12 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL);
m_material_type = shader_source->getShaderInfo(shader_id).material;
} else {
m_material_type = (m_prop.use_texture_alpha) ?
video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
if (m_prop.use_texture_alpha) {
m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_material_type_param = 1.0f / 256.f; // minimal alpha for texture rendering
} else {
m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
}
}

auto grabMatrixNode = [this] {
Expand Down Expand Up @@ -1340,7 +1346,7 @@ void GenericCAO::updateTextures(std::string mod)

video::SMaterial &material = m_spritenode->getMaterial(0);
material.MaterialType = m_material_type;
material.MaterialTypeParam = 0.5f;
material.MaterialTypeParam = m_material_type_param;
material.setTexture(0, tsrc->getTextureForMesh(texturestring));

// This allows setting per-material colors. However, until a real lighting
Expand Down Expand Up @@ -1376,7 +1382,7 @@ void GenericCAO::updateTextures(std::string mod)
// Set material flags and texture
video::SMaterial &material = m_animated_meshnode->getMaterial(i);
material.MaterialType = m_material_type;
material.MaterialTypeParam = 0.5f;
material.MaterialTypeParam = m_material_type_param;
material.TextureLayers[0].Texture = texture;
material.Lighting = true;
material.BackfaceCulling = m_prop.backface_culling;
Expand Down Expand Up @@ -1420,7 +1426,7 @@ void GenericCAO::updateTextures(std::string mod)
// Set material flags and texture
video::SMaterial &material = m_meshnode->getMaterial(i);
material.MaterialType = m_material_type;
material.MaterialTypeParam = 0.5f;
material.MaterialTypeParam = m_material_type_param;
material.Lighting = false;
material.setTexture(0, tsrc->getTextureForMesh(texturestring));
material.getTextureMatrix(0).makeIdentity();
Expand Down
1 change: 1 addition & 0 deletions src/client/content_cao.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class GenericCAO : public ClientActiveObject
bool m_is_visible = false;
// Material
video::E_MATERIAL_TYPE m_material_type;
f32 m_material_type_param;
// Settings
bool m_enable_shaders = false;

Expand Down
16 changes: 6 additions & 10 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,9 @@ void Game::shutdown()
if (formspec)
formspec->quitMenu();

// Clear text when exiting.
m_game_ui->clearText();

#ifdef HAVE_TOUCHSCREENGUI
g_touchscreengui->hide();
#endif
Expand Down Expand Up @@ -1428,12 +1431,6 @@ bool Game::createClient(const GameStartData &start_data)
return false;

bool could_connect, connect_aborted;
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui) {
g_touchscreengui->init(texture_src);
g_touchscreengui->hide();
}
#endif
if (!connectToServer(start_data, &could_connect, &connect_aborted))
return false;

Expand Down Expand Up @@ -1542,10 +1539,8 @@ bool Game::initGui()
-1, chat_backend, client, &g_menumgr);

#ifdef HAVE_TOUCHSCREENGUI

if (g_touchscreengui)
g_touchscreengui->show();

g_touchscreengui->init(texture_src);
#endif

return true;
Expand Down Expand Up @@ -2616,7 +2611,7 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui) {
cam->camera_yaw += g_touchscreengui->getYawChange();
cam->camera_pitch = g_touchscreengui->getPitch();
cam->camera_pitch += g_touchscreengui->getPitchChange();
} else {
#endif
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
Expand Down Expand Up @@ -4124,6 +4119,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
break;

if (formspec->getReferenceCount() == 1) {
// See GUIFormSpecMenu::create what refcnt = 1 means
m_game_ui->deleteFormspec();
break;
}
Expand Down
33 changes: 33 additions & 0 deletions src/client/gameui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,36 @@ void GameUI::deleteFormspec()

m_formname.clear();
}

void GameUI::clearText()
{
if (m_guitext_chat) {
m_guitext_chat->remove();
m_guitext_chat = nullptr;
}

if (m_guitext) {
m_guitext->remove();
m_guitext = nullptr;
}

if (m_guitext2) {
m_guitext2->remove();
m_guitext2 = nullptr;
}

if (m_guitext_info) {
m_guitext_info->remove();
m_guitext_info = nullptr;
}

if (m_guitext_status) {
m_guitext_status->remove();
m_guitext_status = nullptr;
}

if (m_guitext_profiler) {
m_guitext_profiler->remove();
m_guitext_profiler = nullptr;
}
}
1 change: 1 addition & 0 deletions src/client/gameui.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class GameUI
const std::string &getFormspecName() { return m_formname; }
GUIFormSpecMenu *&getFormspecGUI() { return m_formspec; }
void deleteFormspec();
void clearText();

private:
Flags m_flags;
Expand Down
6 changes: 4 additions & 2 deletions src/client/renderingengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,10 @@ void RenderingEngine::draw_load_screen(const std::wstring &text,
#ifndef __ANDROID__
const core::dimension2d<u32> &img_size =
progress_img_bg->getSize();
u32 imgW = rangelim(img_size.Width, 200, 600) * getDisplayDensity();
u32 imgH = rangelim(img_size.Height, 24, 72) * getDisplayDensity();
float density = g_settings->getFloat("gui_scaling", 0.5f, 20.0f) *
getDisplayDensity();
u32 imgW = rangelim(img_size.Width, 200, 600) * density;
u32 imgH = rangelim(img_size.Height, 24, 72) * density;
#else
const core::dimension2d<u32> img_size(256, 48);
float imgRatio = (float)img_size.Height / img_size.Width;
Expand Down
Loading