Skip to content

Commit

Permalink
Code style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfence committed Sep 4, 2024
1 parent 40df961 commit dabe621
Show file tree
Hide file tree
Showing 30 changed files with 311 additions and 310 deletions.
2 changes: 1 addition & 1 deletion builtin/fstk/buttonbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local function buttonbar_formspec(self)
-- `BASE_SPACING` is used as the minimum spacing, like `gap` in CSS Flexbox.

-- The number of buttons per page is always calculated as if the scroll
-- buttons were visible.
-- buttons were visible.
local avail_space = self.size.x - 2*BASE_SPACING - 2*get_scroll_btn_width()
local btns_per_page = math.floor((avail_space - BASE_SPACING) / (btn_size + BASE_SPACING))

Expand Down
2 changes: 1 addition & 1 deletion builtin/game/falling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ core.register_entity(":__builtin:falling_node", {
self.floats = core.get_item_group(node.name, "float") ~= 0

-- Save liquidtype for falling water
self.liquidtype = def.liquidtype
self.liquidtype = def.liquidtype

-- Set entity visuals
if def.drawtype == "torchlike" or def.drawtype == "signlike" then
Expand Down
16 changes: 8 additions & 8 deletions games/devtest/mods/soundstuff/racecar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ local drive_distance = 30

minetest.register_entity("soundstuff:racecar", {
initial_properties = {
physical = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "upright_sprite",
visual_size = {x = 1, y = 1, z = 1},
textures = {"soundstuff_racecar.png", "soundstuff_racecar.png^[transformFX"},
static_save = false,
},
physical = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "upright_sprite",
visual_size = {x = 1, y = 1, z = 1},
textures = {"soundstuff_racecar.png", "soundstuff_racecar.png^[transformFX"},
static_save = false,
},

on_activate = function(self, _staticdata, _dtime_s)
self.min_x = self.object:get_pos().x - drive_distance * 0.5
Expand Down
2 changes: 1 addition & 1 deletion games/devtest/mods/testentities/selectionbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ minetest.register_globalstep(function()
hud_ids[pname] = hud_id or player:hud_add({
type = "text", -- See HUD element types
position = {x=0.5, y=0.5},
text = "X",
text = "X",
number = 0xFF0000,
alignment = {x=0, y=0},
})
Expand Down
51 changes: 26 additions & 25 deletions games/devtest/mods/tiled/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@ local align_help = "Texture spans over a space of 8×8 nodes"
local align_help_n = "Tiles looks the same for every node"

minetest.register_node("tiled:tiled", {
description = "Tiled Node (world-aligned)".."\n"..align_help,
tiles = {{
name = "tiled_tiled.png",
align_style = "world",
scale = 8,
}},
groups = {cracky=3},
description = "Tiled Node (world-aligned)".."\n"..align_help,
tiles = {{
name = "tiled_tiled.png",
align_style = "world",
scale = 8,
}},
groups = {cracky=3},
})

minetest.register_node("tiled:tiled_rooted", {
description = "Tiled 'plantlike_rooted' Node (world-aligned)".."\n"..
"Base node texture spans over a space of 8×8 nodes".."\n"..
"A plantlike thing grows on top",
paramtype = "light",
drawtype = "plantlike_rooted",
tiles = {{
name = "tiled_tiled.png",
align_style = "world",
scale = 8,
}},
special_tiles = {"tiled_tiled_node.png"},
groups = {cracky=3},
description =
"Tiled 'plantlike_rooted' Node (world-aligned)".."\n"..
"Base node texture spans over a space of 8×8 nodes".."\n"..
"A plantlike thing grows on top",
paramtype = "light",
drawtype = "plantlike_rooted",
tiles = {{
name = "tiled_tiled.png",
align_style = "world",
scale = 8,
}},
special_tiles = {"tiled_tiled_node.png"},
groups = {cracky=3},
})

minetest.register_node("tiled:tiled_n", {
description = "Tiled Node (node-aligned)".."\n"..align_help_n,
tiles = {{
name = "tiled_tiled_node.png",
align_style = "node",
}},
groups = {cracky=3},
description = "Tiled Node (node-aligned)".."\n"..align_help_n,
tiles = {{
name = "tiled_tiled_node.png",
align_style = "node",
}},
groups = {cracky=3},
})

stairs.register_stair_and_slab("tiled_n", "tiled:tiled_n",
Expand Down
26 changes: 13 additions & 13 deletions games/devtest/mods/unittests/get_version.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

unittests.register("test_get_version", function()
local version = core.get_version()
assert(type(version) == "table")
assert(type(version.project) == "string")
assert(type(version.string) == "string")
assert(type(version.proto_min) == "number")
assert(type(version.proto_max) == "number")
assert(version.proto_max >= version.proto_min)
assert(type(version.is_dev) == "boolean")
if version.is_dev then
assert(type(version.hash) == "string")
else
assert(version.hash == nil)
end
local version = core.get_version()
assert(type(version) == "table")
assert(type(version.project) == "string")
assert(type(version.string) == "string")
assert(type(version.proto_min) == "number")
assert(type(version.proto_max) == "number")
assert(version.proto_max >= version.proto_min)
assert(type(version.is_dev) == "boolean")
if version.is_dev then
assert(type(version.hash) == "string")
else
assert(version.hash == nil)
end
end)
42 changes: 21 additions & 21 deletions games/devtest/mods/unittests/raycast.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
local function raycast_with_pointabilities(start_pos, end_pos, pointabilities)
local ray = core.raycast(start_pos, end_pos, nil, nil, pointabilities)
for hit in ray do
if hit.type == "node" then
return hit.under
end
if hit.type == "node" then
return hit.under
end
end
return nil
return nil
end

local function test_raycast_pointabilities(player, pos1)
local pos2 = pos1:offset(0, 0, 1)
local pos3 = pos1:offset(0, 0, 2)
local pos2 = pos1:offset(0, 0, 1)
local pos3 = pos1:offset(0, 0, 2)

local oldnode1 = core.get_node(pos1)
local oldnode2 = core.get_node(pos2)
local oldnode3 = core.get_node(pos3)
core.swap_node(pos1, {name = "air"})
core.swap_node(pos2, {name = "testnodes:not_pointable"})
core.swap_node(pos3, {name = "testnodes:pointable"})
local oldnode1 = core.get_node(pos1)
local oldnode2 = core.get_node(pos2)
local oldnode3 = core.get_node(pos3)
core.swap_node(pos1, {name = "air"})
core.swap_node(pos2, {name = "testnodes:not_pointable"})
core.swap_node(pos3, {name = "testnodes:pointable"})

local p = nil
assert(raycast_with_pointabilities(pos1, pos3, p) == pos3)
local p = nil
assert(raycast_with_pointabilities(pos1, pos3, p) == pos3)

p = core.registered_items["testtools:blocked_pointing_staff"].pointabilities
assert(raycast_with_pointabilities(pos1, pos3, p) == nil)
p = core.registered_items["testtools:blocked_pointing_staff"].pointabilities
assert(raycast_with_pointabilities(pos1, pos3, p) == nil)

p = core.registered_items["testtools:ultimate_pointing_staff"].pointabilities
assert(raycast_with_pointabilities(pos1, pos3, p) == pos2)
p = core.registered_items["testtools:ultimate_pointing_staff"].pointabilities
assert(raycast_with_pointabilities(pos1, pos3, p) == pos2)

core.swap_node(pos1, oldnode1)
core.swap_node(pos2, oldnode2)
core.swap_node(pos3, oldnode3)
core.swap_node(pos1, oldnode1)
core.swap_node(pos2, oldnode2)
core.swap_node(pos3, oldnode3)
end

unittests.register("test_raycast_pointabilities", test_raycast_pointabilities, {map=true})
12 changes: 6 additions & 6 deletions games/devtest/mods/util_commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ minetest.register_chatcommand("dump_wear_bar", {
})

core.register_chatcommand("set_saturation", {
params = "<saturation>",
description = "Set the saturation for current player.",
func = function(player_name, param)
local saturation = tonumber(param)
minetest.get_player_by_name(player_name):set_lighting({saturation = saturation })
end
params = "<saturation>",
description = "Set the saturation for current player.",
func = function(player_name, param)
local saturation = tonumber(param)
minetest.get_player_by_name(player_name):set_lighting({saturation = saturation })
end
})
2 changes: 1 addition & 1 deletion src/client/content_cso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SmokePuffCSO: public ClientSimpleObject
MapNode n = env->getMap().getNode(floatToInt(pos, BS), &pos_ok);
light = pos_ok ? decode_light(n.getLightBlend(env->getDayNightRatio(),
env->getGameDef()->ndef()->getLightingFlags(n)))
: 64;
: 64;
video::SColor color(255,light,light,light);
m_spritenode->setColor(color);
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4091,8 +4091,8 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
float old_brightness = sky->getBrightness();
direct_brightness = client->getEnv().getClientMap()
.getBackgroundBrightness(MYMIN(runData.fog_range * 1.2, 60 * BS),
daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen)
/ 255.0;
daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen)
/ 255.0;
}

float time_of_day_smooth = runData.time_of_day_smooth;
Expand Down
38 changes: 19 additions & 19 deletions src/clientdynamicinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ with this program; if not, write to the Free Software Foundation, Inc.,

ClientDynamicInfo ClientDynamicInfo::getCurrent()
{
v2u32 screen_size = RenderingEngine::getWindowSize();
f32 density = RenderingEngine::getDisplayDensity();
f32 gui_scaling = g_settings->getFloat("gui_scaling", 0.5f, 20.0f);
f32 hud_scaling = g_settings->getFloat("hud_scaling", 0.5f, 20.0f);
f32 real_gui_scaling = gui_scaling * density;
f32 real_hud_scaling = hud_scaling * density;
bool touch_controls = g_touchcontrols;

return {
screen_size, real_gui_scaling, real_hud_scaling,
ClientDynamicInfo::calculateMaxFSSize(screen_size, gui_scaling),
touch_controls
};
v2u32 screen_size = RenderingEngine::getWindowSize();
f32 density = RenderingEngine::getDisplayDensity();
f32 gui_scaling = g_settings->getFloat("gui_scaling", 0.5f, 20.0f);
f32 hud_scaling = g_settings->getFloat("hud_scaling", 0.5f, 20.0f);
f32 real_gui_scaling = gui_scaling * density;
f32 real_hud_scaling = hud_scaling * density;
bool touch_controls = g_touchcontrols;

return {
screen_size, real_gui_scaling, real_hud_scaling,
ClientDynamicInfo::calculateMaxFSSize(screen_size, gui_scaling),
touch_controls
};
}

v2f32 ClientDynamicInfo::calculateMaxFSSize(v2u32 render_target_size, f32 gui_scaling)
{
f32 factor = (g_settings->getBool("touch_gui") ? 10 : 15) / gui_scaling;
f32 ratio = (f32)render_target_size.X / (f32)render_target_size.Y;
if (ratio < 1)
return { factor, factor / ratio };
else
return { factor * ratio, factor };
f32 factor = (g_settings->getBool("touch_gui") ? 10 : 15) / gui_scaling;
f32 ratio = (f32)render_target_size.X / (f32)render_target_size.Y;
if (ratio < 1)
return { factor, factor / ratio };
else
return { factor * ratio, factor };
}

#endif
4 changes: 2 additions & 2 deletions src/filesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ std::vector<DirListNode> GetDirListing(const std::string &pathstring)
<< " Error is " << dwError << std::endl;
listing.clear();
return listing;
}
}
}
return listing;
}
Expand Down Expand Up @@ -726,7 +726,7 @@ bool PathStartsWith(const std::string &path, const std::string &prefix)
if(prefixpos == prefixsize)
return true;
// Return false if path has ended (at delimiter/EOS)
// while prefix did not.
// while prefix did not.
if(pathpos == pathsize)
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/guiFormSpecMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3936,7 +3936,7 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode)
fields[name] = "CHG:" + itos(e->getPos());
else
fields[name] = "VAL:" + itos(e->getPos());
}
}
} else if (s.ftype == f_AnimatedImage) {
// No dynamic cast possible due to some distributions shipped
// without rtti support in Irrlicht
Expand Down
2 changes: 1 addition & 1 deletion src/gui/guiHyperText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ void TextDrawer::place(const core::rect<s32> &dest_rect)
std::max(f.margin, p.margin);

} else if (f.rect.UpperLeftCorner.X - f.margin <= left &&
f.rect.LowerRightCorner.X + f.margin >= right) {
f.rect.LowerRightCorner.X + f.margin >= right) {
// float taking all space
left = right;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/touchcontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void TouchControls::translateEvent(const SEvent &event)

toggleOverflowMenu();
// refresh since visibility of buttons has changed
element = m_guienv->getRootGUIElement()->getElementFromPoint(touch_pos);
element = m_guienv->getRootGUIElement()->getElementFromPoint(touch_pos);
// restore after releaseAll in toggleOverflowMenu
m_pointer_downpos[pointer_id] = touch_pos;
m_pointer_pos[pointer_id] = touch_pos;
Expand Down
2 changes: 1 addition & 1 deletion src/mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void MapBlock::serialize(std::ostream &os_compressed, u8 version, bool disk, int
Buffer<u8> buf;
const u8 content_width = 2;
const u8 params_width = 2;
if(disk)
if(disk)
{
MapNode *tmp_nodes = new MapNode[nodecount];
memcpy(tmp_nodes, data, nodecount * sizeof(MapNode));
Expand Down
2 changes: 1 addition & 1 deletion src/mapgen/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ void MapgenBasic::generateBiomes()
// If no stone surface detected in mapchunk column and a water surface
// biome fallback exists, add it to the biomemap. This avoids water
// surface decorations failing in deep water.
if (biomemap[index] == BIOME_NONE && water_biome_index != 0)
if (biomemap[index] == BIOME_NONE && water_biome_index != 0)
biomemap[index] = water_biome_index;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mapgen/mapgen_flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int MapgenFlat::getSpawnLevelAtPoint(v2s16 p)
stone_level = ground_level - depress;
} else if ((spflags & MGFLAT_HILLS) && n_terrain > hill_threshold) {
s16 rise = (n_terrain - hill_threshold) * hill_steepness;
stone_level = ground_level + rise;
stone_level = ground_level + rise;
}

if (ground_level < water_level)
Expand Down Expand Up @@ -311,7 +311,7 @@ s16 MapgenFlat::generateTerrain()
stone_level = ground_level - depress;
} else if ((spflags & MGFLAT_HILLS) && n_terrain > hill_threshold) {
s16 rise = (n_terrain - hill_threshold) * hill_steepness;
stone_level = ground_level + rise;
stone_level = ground_level + rise;
}

u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
Expand Down
Loading

0 comments on commit dabe621

Please sign in to comment.