Commit Graph

302 Commits

Author SHA1 Message Date
SmallJoker f2628f1eb4
core.rotate_node: Do not trigger after_place_node (#6900) 2022-05-21 16:15:54 +02:00
stujones11 a85399a9d6
Optional alpha channel support for entities 2022-05-21 16:15:53 +02:00
rubenwardy 96afee3a52
Add reasons to on_dieplayer and on_hpchange 2022-05-21 16:15:53 +02:00
SmallJoker 878458be68
is_area_protected: Rename from intersects_protection (#7073)
* is_area_protected: Rename from intersects_protection
Return first protected position
Clarify docs: Mods may overwrite the function
2022-05-21 16:15:51 +02:00
dopik 26f80d981c
/shutdown can't do countdown when using reconnect and/or shutdown message (#7055)
Delay was converted from the param string and not the delay value, thus never using the actual given delay value when used in combination with other string values in the param, in this case reconnect and the shutdown messsage.
2022-05-21 16:15:49 +02:00
HybridDog c23bdb0be1
Fix "Ignoring CONTENT_IGNORE redefinition" warning (#4393)
minetest.override_item still passes to core
2022-05-21 16:15:48 +02:00
red-001 2240df7c25
Add `on_auth_fail` callback (#7039)
Called when a client fails to supply the correct password for the account it's attempting to login as.
2022-05-21 16:15:48 +02:00
paramat a81c66d0e5
Item entity: Delete in 'ignore' nodes 2022-05-21 16:15:48 +02:00
paramat 068f060a45
Falling.lua: Delete falling node entities on contact with 'ignore'
Prevents falling node entities entering the ignore at a world edge and
resting on unloaded nodes 16 nodes below, unreachable, undiggable and
still being processed by 'on step' because they don't revert to nodes.
2022-05-21 16:15:47 +02:00
HybridDog f28fb6ff6b
Add minetest.is_player (#7013)
* Add minetest.is_player

* First use for is_player
2022-05-21 16:15:45 +02:00
paramat 21112d78d9
Item entity: Prevent motion in ignore nodes 2022-05-21 16:15:45 +02:00
Wuzzy dc9f1819f8
Add kill chat command (#6992)
Replace minetest.* with core.* in 1 file
2022-05-21 16:15:45 +02:00
Wuzzy 4211230bb6
Make chat command + privilege help slightly more accurate (#6964)
* Make chat command help slightly more accurate

* Slightly more accurate privilege help

* Simplify command/priv help

* More command/priv help tweaks
2022-05-21 16:15:44 +02:00
paramat 318484fcaf
Intersects_protection(): Move from Minetest Game to builtin (#6952)
A useful function that applies 'core.is_protected()' to a 3D lattice of
points evenly spaced throughout a defined volume, with a parameter for
the maximum spacing of points.
2022-05-21 16:15:42 +02:00
ashtrayoz 24263ccbb0
Add callback to preserve node metadata as item metadata 2022-05-21 16:15:37 +02:00
SmallJoker 5cf31fb839
Builtin: Fix handle_node_drops crash with nil digger 2022-05-21 16:15:37 +02:00
sfan5 3a6c1d63d7
Auth handler: Player deletion & Iterator (#6741)
* Add player deletion method to auth handler (fixes #6653)
* Support iterating over the auth database

There was no way to do this previously and a recent commit
broke doing this the "hacky" way by accessing `core.auth_table`.
2022-05-21 16:15:35 +02:00
sfan5 552e74b183
Make core.auth_table private and structure builtin/auth.lua
If you give modders the ability to do something, they will...
2022-05-21 16:15:34 +02:00
paramat 2fac86cbd8
Clearobjects: Send progress messages to terminal using actionstream
Change default mode to 'quick' as 'full' can lock up a server for a
long time.
2022-05-21 16:15:33 +02:00
Auke Kok e5db1211dd
Sounds: Add falling node sounds
Falling nodes should make a sound. This can only be done here,
so for simplicity we just call the sound_play() here with the node
place sound. We ignore any gain value in the sound spec since a
falling node should be loud, so the 1.0 default gain makes sense
here.
2022-05-21 16:15:31 +02:00
sfan5 aabd29474f
Make use of safe file writing in auth handler (fixes #6576) 2022-05-21 16:15:30 +02:00
DTA7 13aa347bef
Item entities: Enable item collision detection for sudden movement 2022-05-21 16:15:30 +02:00
raymoo 7e3d9c2108
Fix default item callbacks to work with nil users (#5819)
* Fix default item callbacks to work with nil users

* item.lua: Handle node drops for invalid players

The if-condition for the dropping loop is the same as `inv`, which means that the 2nd possible definition of `give_item` is never used.
Remove redundant `local _, dropped_item`
2022-05-21 16:15:28 +02:00
lhofhansl a42d4efd0d
Do not grant all privs to the admin - changes game behavior (#6460)
* Do not grant all privs to admins.

* Default give_to_admin to give_to_singleplayer
2022-05-21 16:15:25 +02:00
Loïc Blot 0882448ea8
Implement mod communication channels (#6351)
Implement network communication for channels

* Implement ModChannel manager server side to route incoming messages from clients to other clients
* Add signal handler switch on client & ModChannelMgr on client to handle channels
* Add Lua API bindings + client packet sending + unittests
* Implement server message sending
* Add callback from received message handler to Lua API using registration method
2022-05-21 16:15:23 +02:00
SmallJoker 7a8dbc67aa
Customizeable max breath for players (#6411)
* Customizeable maximal breath for players
2022-05-21 16:15:20 +02:00
paramat 2d4280ec1c
Item drop: Tune to land exactly 2 nodes away with level view (#6410) 2022-05-21 16:15:20 +02:00
red-001 5f8c3768b3
Allow the join/leave message to be overridden by mods. 2022-05-21 16:15:19 +02:00
HybridDog 538b6b1416
Fix dropped item look (#6370)
* Abort set_item when it does nothing

* Do not adjust dropped item size linearly

Instead use cube root because the item count is proportional to the volume, not to the length.

* Make the item rotate slower when it's bigger

Bigger items chafe more on the ground, so they can't rotate as fast as small ones

* Fix items flying in air
2022-05-21 16:15:18 +02:00
rubenwardy 4036abc048
Fix crash on revocation of removed privilege 2022-05-21 16:15:18 +02:00
Wuzzy adaf32a416
Prevent /spawnentity from spawning unknown entity (#6388) 2022-05-21 16:15:17 +02:00
Loïc Blot 766de75bda
Implement minetest.register_can_bypass_userlimit (#6369)
* Implement minetest.register_on_userlimit_check

This new callback permits to bypass the max_users parameter with new mods condition, based on player name or IP
Only one mod needs to permit it.

Move core part for builtin privileges checks to builtin
2022-05-21 16:15:16 +02:00
Rui 39b6fb48a6
Remove nodeupdate and nodeupdate_single 2022-05-21 16:15:15 +02:00
paramat 63a338876a
Zoom: Move enabling zoom to a new player object property
Default enabled for no change in default behaviour.
Remove 'zoom' privilege.
2022-05-21 16:15:14 +02:00
rubenwardy 8e1bbe4ef0
Fix mistake when calling on_priv_grant/revoke, and document them (#6341) 2022-05-21 16:15:14 +02:00
zeuner 4ab3f7829d
Lua API: Add function to deregister single biomes (#5445) 2022-05-21 16:15:13 +02:00
rubenwardy 5f04e6a431
Add on_grant and on_revoke callbacks (#4713)
* Add register_on_priv_grant/revoke, and on_grant/revoke to privs. Call from /grant and /revoke

* Call on_grant and on_revoke callbacks from set_privs
2022-05-21 16:15:12 +02:00
rubenwardy 9e23ddc248
Check item_drop amount clientside (#6242) 2022-05-21 16:15:12 +02:00
SmallJoker 692dc11e2b
Builtin item: Tidy up (#4370)
New code structure
Use setting movement_gravity
Reset age on merge
Set merge radius to 1.0m
2022-05-21 16:15:11 +02:00
SmallJoker 30f3f4c248
Respect object property hp_max field for players (#6287)
* Respect object property hp_max field for players
This allows modders to configure the maximal HP per player

* Statbars: Downscale bar to full 20 HP when exceeding this value
Add default max HP for players and breath constants to builtin
Document the constants

* Rename PLAYER_MAX_HP -> PLAYER_MAX_HP_DEFAULT
2022-05-21 16:15:10 +02:00
Dániel Juhász 53fdd2335b
Make dropped items colorable 2022-05-21 16:15:08 +02:00
Wuzzy 1b44ce995b
Add slippery group for nodes (players/items slide) 2022-05-21 16:15:07 +02:00
HybridDog 7f6c6055f1
Abort if static_spawnpoint is an invalid setting instead of just giving an error log 2022-05-21 16:15:06 +02:00
red-001 2dcce68936
Create a filesystem abstraction layer for CSM and only allow accessing files that are scanned into it. (#5965)
* Load client-side mods into memory before executing them.

This removes the remaining filesystem access that client-sided mods had and it will hopefully make then more secure.

* Lua Virtual filesystem: don't load the files into memory just scan the filenames into memory.

* Fix the issues with backtrace

* fix most of the issues

* fix code style.

* add a comment
2022-05-21 16:14:59 +02:00
Dániel Juhász 5f6d3bba2a
Helper methods for hardware colorization (#5870) 2022-05-21 16:14:58 +02:00
Dániel Juhász e4a6867f2c
Automatic item and node colorization (#5640)
* Automatic item and node colorization

Now nodes with a palette yield colored item stacks, and colored items
place colored nodes by default. The client predicts the colorization.

* Backwards compatibility

* Use nil

* Style fixes

* Fix code style

* Document changes
2022-05-21 16:14:56 +02:00
Ezhh 4bd4d2b3b7
Improve chatcommand params consistency (#5985)
* Fix and improve params consistency

* Move parenthesis requirement to descriptions
2022-05-21 16:14:56 +02:00
red-001 2f8ebed7cc
Add function to get player privileges (#5933)
* [CSM] Add function to get player privileges + move related help functions to common

* Added @Zeno- const
2022-05-21 16:14:52 +02:00
Wuzzy e4a9d9276d
Remove “inf” argument from shutdown command help (#5880) 2022-05-21 16:14:51 +02:00
Elijah Duffy 6ec27e1cbf
Add /clearinv chat command (#4994)
Allow players to clear their own inventory or that of another player with /clearinv command. server privilege is required to clear another player's inventory, no privileges are required to clear your own inventory.'
2022-05-21 16:14:48 +02:00
ShadowNinja 5030ce5f4b
Use a settings object for the main settings
This unifies the settings APIs.

This also unifies the sync and async registration APIs, since the async
registration API did not support adding non-functions to the API table.
2022-05-21 16:14:45 +02:00
Loïc Blot 8ed0c6ebfa
Player data to Database (#5475)
* Player data to Database

Add player data into databases (SQLite3 & PG only)

PostgreSQL & SQLite: better POO Design for databases

Add --migrate-players argument to server + deprecation warning

* Remove players directory if empty
2022-05-21 16:14:42 +02:00
Dániel Juhász 26833c3659
Add /fixlight chat command 2022-05-21 16:14:42 +02:00
Loïc Blot bed4f29a19
Implement delayed server shutdown with cancelation (#4664) 2022-05-21 16:14:40 +02:00
Dániel Juhász b97e06de4b
Hardware coloring for itemstacks
Adds the possibility to colorize item stacks based on their metadata.

In the item/node definition you can specify palette (an image file)
and color (fallback color if the item has no palette or metadata).
Then you can add palette_index to the metadata.

Dropped itemstacks with different colors do not merge.
2022-05-21 16:14:38 +02:00
red-001 f12f99333b
Move chat command handling code from C++ to Lua (#5528) 2022-05-21 16:14:37 +02:00
paramat da687589b3
Map generation limit: Make per-world
The setting limits map generation but affects nothing else.
Add 'mapgen_limit' to global mapgen parameters.
Move 'blockpos_over_mapgen_limit()' to the only place it is called
from: map.cpp.
Allow teleportation to any part of the world even if over the set
mapgen limit.
Simplify the reading of this limit in mgvalleys.
Remove the 'map_generation_limit' setting.
2022-05-21 16:14:33 +02:00
red-001 5943ad8975
Change command prefix to "." and add "help" command. 2022-05-21 16:14:32 +02:00
red-001 d210b6d2cf
Give CSM access to use `core.colorize()` (#5113) 2022-05-21 16:14:30 +02:00
Auke Kok 0d606691dd
Fix two nul deref if digging unknown nodes. (#5398)
Introduced by d785456b3fa35faf47cb972fde9e8668382c5e22 (#5162)
2022-05-21 16:14:30 +02:00
Loïc Blot b38c00d90f
sound_play & sound_stop support + client_lua_api doc (#5096)
* squashed: CSM: Implement register_globalstep
  * Re-use fatal error mechanism from server to disconnect client on CSM error
  * Little client functions cleanups

* squashed: CSM: add core.after function
  * core.after is shared code between client & server
  * ModApiUtil get_us_time feature enabled for client
2022-05-21 16:14:27 +02:00
red-001 33b76809dd
Add client-sided chat commands (#5092) 2022-05-21 16:14:27 +02:00
Vladislav Tsendrovskii 49602a4a4f
Save metainfo for falling nodes 2022-05-21 16:14:25 +02:00
tenplus1 22ca380b87
Optimize item.lua Replace slow ItemStack get_definitions with registered_nodes one's and cached playername as it's used multiple times. Also removed local item = itemstack:peek_item() as it is never used. 2022-05-21 16:14:24 +02:00
zaoqi ebe297520a
Add minetest.spawn_falling_node(pos) (#5339)
* Add minetest.spawn_falling_node(pos)

* lua_api.txt: Add minetest.spawn_falling_node(pos)

* Update minetest.spawn_falling_node(pos)
2022-05-21 16:14:23 +02:00
red-001 ccce7bbd6d
Fix crash that can be caused by the shutdown command. (#5292) 2022-05-21 16:14:23 +02:00
Dániel Juhász 3a111fa7d6
Fixes for colorwallmounted and colorfacedir nodes
Correct node placement prediction for attached colorwallmounted nodes.
Correct placement direction for colorfacedir and colorwallmounted nodes.
Correct detatch mechanism for attached colorwallmounted nodes.
2022-05-21 16:14:22 +02:00
tenplus1 560f339872
Statbars.lua: Cache enable_damage setting 2022-05-21 16:14:21 +02:00
red-001 152924b6f2
Add support for the new arguments of `request_shutdown` to the `/shutdown` chatcommand. (#5252) 2022-05-21 16:14:21 +02:00
Wuzzy 3c57053538
Add textures for air and ignore items (#5196) 2022-05-21 16:14:20 +02:00
Nathanaël Courant bfd687d6bf
Make facedir_to_dir and wallmounted_to_dir work with coloured nodes as well. (#5153) 2022-05-21 16:14:18 +02:00
Auke Kok a648fbc2e7
core: Add dir_to_yaw and yaw_to_dir helpers
These are needed to go from things like entity yaw to a vector
and vice versa.
2022-05-21 16:14:17 +02:00
Elijah Duffy d22ecfcbb3
Add chatcommand unregister and override API (#5076)
Introduces two functions to unregister and override chatcommands.
minetest.unregister_chatcommand("<name>") and
minetest.override_chatcommand("<name>", {<redifinition>})
2022-05-21 16:14:16 +02:00
rubenwardy 14a4e9994c
Add minetest.player_exists() (#5064) 2022-05-21 16:14:16 +02:00
Ezhh 3f0a7c339b
Improve priv descriptions (#5047) 2022-05-21 16:14:15 +02:00
red-001 3861ac47bb
Remove client-side chat prediction. (#5055)
Network lag isn't really a big issue with chat and chat prediction makes writing mods harder.
2022-05-21 16:14:14 +02:00
Rui 1d5a04c315
Add staticdata parameter to add_entity (#5009)
* Add staticdata parameter to add_entity
* Add add_entity_with_staticdata to core.features
2022-05-21 16:14:12 +02:00
sfan5 6ecb28d409
builtin/.../falling.lua: Avoid crash when hitting unknown nodes 2022-05-21 16:14:11 +02:00
rubenwardy ec70ea807a
Expose and document chatcommands as minetest.registered_chatcommands 2022-05-21 16:14:10 +02:00
Dorian Wouters 269e50a879
Fix /grant & /revoke not working with custom auth handler (#4974)
core.auth_table is not supposed to be accessed directly.
2022-05-21 16:14:10 +02:00
paramat e7f217fb2e
Builtin/../falling.lua: Avoid crash when object pos over limit
If the object pos is over limit, 'add entity' will not add an entity,
causing 'obj' to be nil.
2022-05-21 16:14:08 +02:00
red-001 0299519ca9
Don't send a join message in singleplayer mode. 2022-05-21 16:14:04 +02:00
sfan5 6e3c875f51
Allow restricting detached inventories to one player
This combats the problem of sending the hundreds of
"creative" / "armor" or whatever detached invs that
exist on popular servers to each and every player
on join or on change of said invs.
2022-05-21 16:14:04 +02:00
orwell96 9c764263a7
Make supplying empty formspec strings close the formspec (#4737)
This will only happen if the formname matches or if formname is "".
2022-05-21 16:14:03 +02:00
paramat b420bbd126
Tool break: Reduce gain of break sounds 2022-05-21 16:14:03 +02:00
Auke Kok 1c75bc27e4
Builtin/../item: Enable tool breaking sounds
If a tool wears out and is destroyed, it's itemstack count
goes to 0, and we can optionally play a breaking sound.

This patch implements playing a breaking sound when this
occurs. Sounds need to be added to the tool itemdef
registration as the sound name string in the .sound.breaks
member.
2022-05-21 16:14:02 +02:00
est31 8fd57dc4bb
Introduce builtin_shared and use it to fix #4778
Fixes #4778 which was about the error:

ServerError: Lua: Runtime error from mod '' in callback item_OnPlace():
/usr/local/share/minetest/builtin/game/item.lua:278: attempt to call global 'check_attached_node' (a nil value)

The issue was a regression of commit 649448a2a91fbf3e944b2f2e739f4e2292af1df0

"Rename nodeupdate and nodeupdate_single and make them part of the official API"
2022-05-21 16:14:02 +02:00
est31 b47663d742
Rename nodeupdate and nodeupdate_single and make them part of the official API
Now, the renamed forms of nodeupdate and nodeupdate_single are part of the official API.

As nodeupdate has been used by Minetest Game and in mods despite of not
being part of the official API, we ease the transition by still supporting
it for the 0.4.15 release. After the release, the two functions can be removed.

The removal will not violate the stability promise, as that promise only
includes the official and documented API.

Also, make some formerly global functions local. They most likely haven't
been used by mods, therefore they won't get stubs with deprecation warnings,
hard erroring directly.
2022-05-21 16:14:00 +02:00
paramat f3720d5ee4
Builtin/../falling: Fix bugs caused by 'ignore' nodes
Original commit by t4im, rebased and developed by paramat.
Fix CONTENT_IGNORE being replaced by falling nodes or causing large
areas of sand to collapse into itself.
Format some conditional code for clarity.
Add and clarify some comments.
2022-05-21 16:14:00 +02:00
Wuzzy 8de2093059
Privileges: Only give singleplayer 4 basic privs
- interact
- shout
- privs
- basic_privs
2022-05-21 16:14:00 +02:00
lhofhansl 912d6b1059
Add debug priv, and allow player to display the scene as wire-frame. (#4709) 2022-05-21 16:13:59 +02:00
red-001 8b8f204d6d
Chat commands: Trim whitespaces from input of `/privs` command 2022-05-21 16:13:57 +02:00
red-001 8ba872f6e4
Builtin/../chatcommands: Add /grantme command 2022-05-21 16:13:55 +02:00
tenplus1 6dae557ad8
Builtin/../falling.lua: Code optimisation 2022-05-21 16:13:55 +02:00
HybridDog 8210849b50
VoxelArea: faster iter function (#4490) 2022-05-21 16:13:54 +02:00
paramat cadfd09355
Builtin/falling: Add fallback vector in case of nil 'wallmounted to dir'
The fallback vector is in case 'wallmounted to dir' is nil due
to voxelmanip placing a wallmounted node without resetting a
pre-existing param2 value that is out-of-range for wallmounted.
The fallback vector corresponds to param2 = 0.
2022-05-21 16:13:53 +02:00
raymoo 222e8090c1
Forceloading: Transient forceloads
Adds a flag to forceload_block which lets you turn off persistence for
that forceload.
2022-05-21 16:13:52 +02:00
Rui 1344513303
Fix typo in core.after (#4560) 2022-05-21 16:13:52 +02:00
paramat 2e54664273
Builtin: Change error to warning for light_source > 14 2022-05-21 16:13:51 +02:00
paramat a114f7297e
Register.lua: Throw error if node 'light_source' > core.LIGHT_MAX
Add 'core.LIGHT_MAX = 14' to builtin/game/constants.lua with the intention
to replace misplaced 'default.LIGHT_MAX = 14' in Minetest Game.
Add comment in light.h requiring the constant be changed in both places.
Add lighting bug warning to note in lua_api.txt.
There are hundreds of mod uses of 15 which causes a lighting bug.
2022-05-21 16:13:50 +02:00
paly2 716d19077f
Add minetest.unregister_item and minetest.register_alias_force 2022-05-21 16:13:49 +02:00
SmallJoker 3102f9f030
Builtin: Disallow registering users with the same name
Prevents duplicate names: 'NickName', 'nickname', 'NICKNAME'.
Skips already registered users, so they can connect as usual.
2022-05-21 16:13:48 +02:00
Xunto bf33a189da
Move on join and on leave messages to lua (#4460) 2022-05-21 16:13:47 +02:00
Ben Deutsch 6d21a3b8fe
Zooming the camera requires the 'zoom' privilege 2022-05-21 16:13:46 +02:00
Tim 552e304da9
Builtin: Add core.MAP_BLOCKSIZE constant 2022-05-21 16:13:45 +02:00
Tim d03f226194
Builtin: Fix check for a player object in core.check_player_privs
core.check_player_privs accepts as first argument a name or player object, but just tested for a string.
This caused crashes inside builtin, when being passed any unexpected types.

This provides a better (duck-typing like) test, better error reporting.
2022-05-21 16:13:44 +02:00
Tim a1fcfc28ec
Builtin/profiler: Replace game profiler (#4245)
Use the setting "profiler.load" to enable profiling.
Other settings can be found in settingtypes.txt.

* /profiler print [filter] - report statistics to in-game console
* /profiler dump [filter] - report statistics to STDOUT and debug.txt
* /profiler save [format [filter]] - saves statistics to a file in your worldpath
	* txt (default) - same treetable format as used by the dump and print commands
	* csv - ready for spreadsheet import
	* json - useful for adhoc D3 visualizations
	* json_pretty - line wrapped and intended json for humans
	* lua - serialized lua table of the profile-data, for adhoc scripts
* /profiler reset - reset all gathered profile data.
	This can be helpful to discard of any startup measurements that often spike during loading or to get more useful min-values.

[filter] allows limiting the output of the data via substring/pattern matching against the modname.

Note: Serialized data structures might be subject to change with changed or added measurements.
	csv might be the most stable, due to flat structure.

Changes to the previous version include:

* Updated and extended API monitoring
* Correct calculation of average (mean) values (undistorted by idleness)
* Reduce instrumentation overhead.
* Fix crashes related to missing parameters for the future and occasional DIV/0's.
* Prevent issues caused by timetravel (overflow, timejump, NTP corrections)
* Prevent modname clashes with internal names.
* Measure each instrumentation individually and label based on registration order.
* Labeling of ABM's and LBM's for easier classification.
  Giving several ABM's or LBM's the same label will treat them as one.
  Missing labels will be autogenerated based on name or registration order.
* Configurable instrumentation and reporting. Skip e.g. builtin if you don't need it.
* Profile the profiler to measure instrumentation overhead.
2022-05-21 16:13:44 +02:00
Auke Kok db3e245ff0
Builtin/game/item: Add `place_param2` nodedef field
This allows a nodedef to specify a fixed value for param2 to be
used for all normal placements.

There are several uses for this:

- nodes that require param2 to be set to a non-zero value for
  internal mod use. E.g. leafdecay could use this to detect that
  leaves are played by players.
- force wallmounted or facedir value at placement at placement

This overrides any player look direction or other on-the-fly
param2 setting during placement.
2022-05-21 16:13:42 +02:00
Nathanaël Courant 4c2af14cef
Add colored text (not only colored chat).
Add documentation, move files to a proper place and avoid memory leaks.
Make it work with most kind of texts, and allow backgrounds too.
2022-05-21 16:13:41 +02:00
TriBlade9 4108d1bd6b
Colored chat working as expected for both freetype and non-freetype builds. @nerzhul improvements * Add unit tests * Fix coding style * move guiChatConsole.hpp to client/ 2022-05-21 16:13:41 +02:00
Sokomine 71b4fd31ac
protection_bypass priv can now be revoked in singleplayer (#4169) 2022-05-21 16:13:40 +02:00
paramat dea9b57e4b
Item entities: Don't show description as infotext
Partially reverts #3547
Infotext remains optional for objects, empty by default
2022-05-21 16:13:40 +02:00
Wayward One 306a8d1311
Add on_punchnode callback 2022-05-21 16:13:39 +02:00
tenplus1 78874e8216
Avoid teleporting player if /teleport coords are out-of-range 2022-05-21 16:13:36 +02:00
rubenwardy 50d7bee97d
Builtin: Add basic_privs setting 2022-05-21 16:13:35 +02:00
Auke Kok 807cec58aa
Fix timer initialization.
This fixes the problem that the first timer tick is an
overrun and causes all timers to expire immediately.

replaces #4003
2022-05-21 16:13:33 +02:00
Auke Kok ea243adba1
falling: walk 4 additional diagonally down directions.
This seems very little cost and matches the old behavior more
closely. This will cause some more falling nodes to get added
to falling clusters. With the efficiency of the algorithm, this
really doesn't do much damage.
2022-05-21 16:13:32 +02:00
Auke Kok a3d0df7466
Convert nodeupdate to non-recursive
This took me a while to figure out. We no longer visit all 9 block
around and with the touched node, but instead visit adjacent plus
self. We then walk -non- recursively through all neigbors and if
they cause a nodeupdate, we just keep walking until it ends. On
the way back we prune the tail.

I've tested this with 8000+ sand nodes. Video result is here:

  https://youtu.be/liKKgLefhFQ

Took ~ 10 seconds to process and return to normal.
2022-05-21 16:13:31 +02:00
tenplus1 b6b49f9cc9
stop falling.lua error
2016-03-27 15:47:01: ERROR[Main]: ServerError: Lua: Runtime error from mod '*builtin*' in callback luaentity_Step(): Node name is not set or is not a string!
2016-03-27 15:47:01: ERROR[Main]: stack traceback:
2016-03-27 15:47:01: ERROR[Main]: 	[C]: in function 'add_node'
2016-03-27 15:47:01: ERROR[Main]: 	/usr/share/minetest/builtin/game/falling.lua:96: in function </usr/share/minetest/builtin/game/falling.lua:43>
2022-05-21 16:13:29 +02:00
Rui 215e71efad
Falling: Set acceleration on step again
Commit

65c09a96f41705bb8e75fc5ff4276342be91ed11 "Set acceleration only once in falling node"

has made the acceleration being set only once.
But this has introduced a regression.

Fix #3884.
2022-05-21 16:13:28 +02:00
Auke Kok 400c4dda7a
Make `options` local here.
Undoubtably this may cause problems later if unchecked.

```
2016-03-22 21:57:52: WARNING[Server]: Assignment to undeclared global "options" inside a function at .../sofar/git/minetest/bin/../builtin/game/chatcommands.lua:862.
```
2022-05-21 16:13:28 +02:00
paramat b12c539595
Builtin/game/falling: Re-add comma removed by recent commit 2022-05-21 16:13:27 +02:00
Rui914 8760d15445
Set acceleration only once in falling node 2022-05-21 16:13:27 +02:00
Auke Kok 9e994e0e39
Introduce "protection_bypass" privilege.
This privilege allows map protection bypassing for server operators
and world moderators.

Initially I had thought that bypassing protection mods would have been
something that could entirely be done inside mods and minetest_game,
but the concept of protection is defined in core, in the code of
core.is_protected().

I don't feel that it would be logical to introduce a protection
concept in core, but not some way around that for server operators
to maintain map parts that need fixing, de-griefing or cleanup.

Others had noticed the same problems, and proposed a patch to
minetest_game. That patch is fine by itself, but it fails to add
protection bypass functionality for digging normal nodes and placing
nodes.

So, instead, we indroduce the new priv "protection_bypass" in core,
and modify 'on_place_node' and 'node_dig' to allow bypassing node
protections if the player holds this priv.

This priv was tested with protector redo by tenplus1.

A followup patch to Minetest Game will include allowing special checks
for doors, trapdoors, chests in Minetest Game.

Protection mods will likely want to mimic the changes in their relevant
code sections.
2022-05-21 16:13:25 +02:00
Auke Kok da5a169a45
Add consistent monotonic day counter - get_day_count()
I've written several experimental bits of code that revolve around the
need for a consistent calendar, but implementing one is extremely hard
in mods due to time changes and mods overriding core.get_timeofday(),
which will conflict.

The second part of the problem is that doing this from a mod requires
constant maintenance of a settings file.

An implementation in core is trivial, however, and solves all of
these problems at virtually no cost: No extra branches in server
steps, and a single branch when minetest.set_time_of_day(), which is
entirely reasonable.

We store the day_count value in env_meta.txt.

The use case is obvious: This change allows mods to create an actual
virtual calendar, or properly account for seasonal changes, etc..

We add a "/days" chatcommand that displays the current day count. No
permissions are needed. It can only retrieve the day count, not
modify it.
2022-05-21 16:13:24 +02:00
ShadowNinja 96b86f8440
Add AreaStore custom ID API 2022-05-21 16:13:24 +02:00
est31 d1e698f4fb
Add minetest.register_lbm() to run code on block load only 2022-05-21 16:13:23 +02:00
Rui914 32752d2bc5
Faster insertion into table 2022-05-21 16:13:23 +02:00
Jeija d0a7fe455e
Add Lua interface to HTTPFetchRequest
This allows mods to perform both asynchronous and synchronous HTTP
requests. Mods are only granted access to HTTP APIs if either mod
security is disabled or if they are whitelisted in any of the
the secure.http_mods and secure.trusted_mods settings.

Adds httpfetch_caller_alloc_secure to generate random, non-predictable
caller IDs so that lua mods cannot spy on each others HTTP queries.
2022-05-21 16:13:20 +02:00
Diego Martínez 60a5b2ac4d
Initialize facedir and wallmounted tables only once.
This makes the functions a bit faster since they don't
have to recreate the tables every invocation, and makes
the code more readable.

Also, document `wallmounted_to_dir`.

The function was implemented but not documented in `lua_api.txt`.
2022-05-21 16:13:18 +02:00
Kahrl c4db9d23ff
Log /clearobjects mode 2022-05-21 16:13:17 +02:00
Kahrl ed493305e4
Add '/clearobjects quick' 2022-05-21 16:13:17 +02:00
Splizard 35bae38ca3
Add admin command which says who the administator is for the server. 2022-05-21 16:13:15 +02:00
Auke Kok 3cef28e731
New timer design.
I could honestly not make much sense of the timer implementation
that was here. Instead I've implemented the type of timer algorithm
that I've used before, and tested it instead.

The concept is extremely simple: all timers are put in an ordered
list. We check every server tick if any of the timers have
elapsed, and execute the function associated with this timer.

We know that many timers by themselves cause new timers to be
added to this list, so we iterate *backwards* over the timer
list. This means that new timers being added while timers are
being executed, can never be executed in the same function pass,
as they are always appended to the table *after* the end of
the table, which we will never reach in the current pass over
all the table elements.

We switch time keeping to minetest.get_us_time(). dtime is
likely unreliable and we have our own high-res timer that we
can fix if it is indeed broken. This removes the need to do
any sort of time keeping.
2022-05-21 16:13:14 +02:00
RealBadAngel 580ea1201e
Show infotext with description for item entities 2022-05-21 16:13:13 +02:00
paramat b36217f608
Liquids: Flow into and destroy 'floodable' nodes
Add new node property 'floodable', default false
Define "air" as floodable = true in C++ and lua
2022-05-21 16:13:10 +02:00
HybridDog 93de351e5f
Fix missing localization for obj 2022-05-21 16:13:09 +02:00
Alex Ford 8341ca836e
Add on_secondary_use when right clicking an item in the air 2022-05-21 16:13:07 +02:00
Robert Zenz e7bc7c6857
Simplify regex used in check_modname_prefix and other improvements.
Simplified the regex used, added comments and changed the error message
to contain the correct mod name.
2022-05-21 16:13:07 +02:00
Rui aedf15826c
Log static_spawn error only once 2022-05-21 16:13:05 +02:00
Robert Zenz 4662b21222
Add the player name to dropped items
The player name is now added in the field "dropped_by" on the created
entity.
2022-05-21 16:13:04 +02:00
kwolekr f9e25279e1
Improve LuaVoxelManip documentation 2022-05-21 16:13:02 +02:00
kwolekr 0b80c8c114
Add callback parameter for core.emerge_area() 2022-05-21 16:13:00 +02:00
Rui914 9bca5b37c4
minetest. to core. 2022-05-21 16:13:00 +02:00
BlockMen 1f21ad4da2
Check if hitter has inventory when punching item
Fixes #3280
2022-05-21 16:12:58 +02:00
Robert Zenz 9ad5562efb
Add more ways to pass data to check_player_privs
The callback can now be invoked with either the player object or name as
the first parameter, and with either a table or a list of strings, like
this:

    minetest.check_player_privs(player_name, { shout = true, fly = true })
    minetest.check_player_privs(player_name, "shout", "fly")
    minetest.check_player_privs(player, { shout = true, fly = true })
    minetest.check_player_privs(player, "shout", "fly")
2022-05-21 16:12:55 +02:00
ShadowNinja 8fc9b3b9cb
Refactor logging
- Add warning log level
- Change debug_log_level setting to enumeration string
- Map Irrlicht log events to MT log events
- Encapsulate log_* functions and global variables into a class, Logger
- Unify dstream with standard logging mechanism
- Unify core.debug() with standard core.log() script API
2022-05-21 16:12:54 +02:00
Rui f3c5e76d9a
Localize digprop_err function 2022-05-21 16:12:54 +02:00
Fernando Carmona Varo 095cfc2c70
Added minetest.wallmounted_to_dir 2022-05-21 16:12:53 +02:00
est31 e1b5a8789e
Some map border related fixes
1. Check for entity addition success in spawn_item implementation
2. Check for success in item_drop callback, so that the player
doesn't lose the item if they are outside bounds and try to drop it.
3. When existing player joins game, check that their position is inside
map bounds. If not, set their position to the return value of findSpawnPos().
4. Make findSpawnPos() respect the border

2 fixes a lua crash if a player drops an item outside map bounds.
3 fixes an assertion crash if a player leaves when being outside map bounds,
and then rejoins.
2022-05-21 16:12:52 +02:00