Compare commits

...

794 Commits

Author SHA1 Message Date
Cora de la Mouche 6df1590803
Add list setting -> chatcmd def for external access (#62)
* Add list setting -> chatcmd def for external access

* Document the _list_setting field

... in both the chatcmd def and minetest.register_list_command

* doc: add missing 'by'

* remove underscore (_list_setting -> list_setting)

---------

Co-authored-by: Lizzy Fleckenstein <eliasfleckenstein@web.de>
2023-06-23 18:26:33 +02:00
Cora de la Mouche 2c050a42d7
Merge pull request #61 from dragonfireclient/serverinfo_seed
Add mapseed to get_server_info table
2023-06-20 02:43:39 +02:00
cora 64e7dda46e Add server info seed field to documentation 2023-06-15 20:15:17 +02:00
cora 7a59bcda75 Add mapseed to get_server_info table 2023-06-15 19:40:02 +02:00
Cora de la Mouche f8fd5c11b6
Merge pull request #59 from PrairieAstronomer/readme_irrlicht_change
Add exact irrlichtmt version to the clone command
2023-04-11 00:34:58 +02:00
PrairieWind c66ae6717a Add exact irrlichtmt version to the clone command 2023-03-11 13:20:00 -07:00
Elias Fleckenstein 296cce39d3
Fix upstream merge issues 2022-06-07 03:31:06 +02:00
Elias Fleckenstein b11c0a6721
Merge branch 'master' of https://github.com/minetest/minetest 2022-06-07 03:19:05 +02:00
Lars Müller edc7df5480
core.formspec_escape: Restore backwards compat
Support numbers as arguments by using `string.gsub(text, ...)` instead of `text:gsub(...)` which will coerce `text` to a string
2022-06-06 18:32:28 +02:00
paradust7 951604e29f Remove invalid fps_max on Mac 2022-06-06 12:03:28 +02:00
Zughy 381f84ee27
Bug report template: ask contributors to provide a code snippet (#12405) 2022-06-05 16:12:39 -04:00
sfan5 14c283a623 Fix crash in commit a69b7abe00 2022-06-05 19:00:14 +02:00
rubenwardy 4baf56520d
Android: Add support for sharing debug.txt (#12370) 2022-06-05 17:42:09 +01:00
sfan5 a69b7abe00 Improve LBMManager::applyLBMs() code
Fixes a possible bug for lbms on content ID zero and removes unsafe casts.
2022-06-05 17:48:51 +02:00
rubenwardy 03d86ea0b4
Add register dialog to separate login/register (#12185)
New users find Minetest's account system confusing.
This change moves username/password to a new dialog,
with login and register buttons added to the Join Game tab.

The old registration confirmation dialog is removed in
favour of the new dialog.

Fixes #8138
2022-06-05 17:47:38 +02:00
ROllerozxa 21323ef1ff
Hide "Autosave Screen Size" on Android 2022-06-05 15:20:39 +02:00
savilli 1f39948bc3
Fix BSD iconv declaration 2022-06-05 15:20:29 +02:00
Lars Mueller e82985c0a1 Document itemstrings with metadata 2022-06-05 15:20:13 +02:00
JosiahWI 8e5bd82c4d
fix integer overflow in mapgen (#11641)
* fix integer overflow in mapgen

Some calculations involving the magic seed had overflow because the result of an intermediate arithmetic step could not fit in an s32. By making the magic seed unsigned, the other operand in the equation will be cast to unsigned, and possibly other operands or intermediate operands. This will result in unexpected behavior if an operand is negative, which is technically possible, but logically should not happen.

* comment noise2d bitshift

While working through the code I was momentarily concerned that the right bitshift in noise2d could fill ones in some cases. It turns out that with signed integers, this is indeed true, but this one is shifting an unsigned integer, so the behavior is as expected. I put a comment here to clarify this, in case someone else wonders the same thing down the line.

* noise2d and noise3d unittests

I have added 3 tests each for noise2d and noise3d, testing all zero inputs, a very large seed (case which caused UB in the old implementation) and some fun primes I picked for no particular reason. This should be sufficient to demonstrate that the behavior of the new implementation has not changed. I used uniform initialization because it is a good feature of C++11. Please do not explode.

* uncomment the noise2d bitshift

This reverts commit 583b77ee9f1ad6bb77340ebb5ba51eb9a88ff51c. It's a
well-defined language semantic; it doesn't need to be commented.

* code cleanliness
2022-06-03 20:51:58 -04:00
sfan5 575caa8015 Properly keep noclip state in Game and ClientMap 2022-06-03 21:48:52 +02:00
sfan5 5f3af7d18b Remove obsolete eye_height related workaround
This was added a long time ago in 42bbd5c9ae
and meant to fix prevent the view becoming black when jumping into a
ceiling, this no longer happens today.
2022-06-03 21:48:52 +02:00
Wuzzy 6a6b579c54
Add helper functions to make tool usable n times (#12047) 2022-06-03 21:47:04 +02:00
ROllerozxa 6d163b72dc
Rework main menu confirmation dialogs (#12356) 2022-06-03 21:46:37 +02:00
Zughy b72932b445 Docs: remove unimplemented `preserve` field in crafting recipes 2022-06-03 21:46:26 +02:00
Elias Fleckenstein 827b9f8d70
Merge branch 'master' of https://github.com/minetest/minetest 2022-06-02 20:54:02 +02:00
sfan5 9fc018ded1 Fix use-after-free in node meta cleanup
bug introduced in 8908a91016
2022-05-29 16:30:13 +02:00
sfan5 a9a207685a Reject registering node with empty name
fixes #10769
2022-05-29 14:00:19 +02:00
sfan5 c1d03695d4 Minor code improvements around active block keeping 2022-05-29 14:00:19 +02:00
sfan5 ea74680df4 Immediately activate blocks when a player joins
issue: #10884
This makes it possible for objects to immediately be activated,
but doesn't guarantee it since blocks may still need be emerged.
2022-05-29 14:00:19 +02:00
stefan bb671c3089 Remove debug.get/setmetatable from security whitelist
fixes #12216
2022-05-29 14:00:19 +02:00
sfan5 1b68fb7683 Don't allow banning in singleplayer
fixes #11819
2022-05-29 14:00:19 +02:00
sfan5 303329f2d6 Handle lua entity HP changes correctly (like punches)
fixes #11975
2022-05-29 14:00:19 +02:00
sfan5 85c824ed13 Make sure real disconnect reason isn't overwritten
bug introduced in 2f32044273
2022-05-29 14:00:19 +02:00
sfan5 998e4820c9 Fix linking with Postgres libs on older cmake versions
closes #12149
2022-05-29 14:00:19 +02:00
sfan5 5cd7b0c6e4 Remove remains of video mode querying 2022-05-29 14:00:19 +02:00
sfan5 8908a91016 Get rid of node metadata when it becomes empty
fixes #8943
2022-05-29 14:00:19 +02:00
sfan5 261a8db9dd Optimize Server::sendMetadataChanged a bit
The distance check also never worked as intended, now fixed.
2022-05-29 14:00:19 +02:00
sfan5 f195db2d14 Add API function to invoke player respawn
closes #12272
2022-05-29 14:00:19 +02:00
sfan5 da71e86633 Protect a few more settings from being set from mods
Of those settings main_menu_script has concrete security impact, the rest are added out of abundance of caution.
2022-05-29 14:00:19 +02:00
sfan5 bccaf5fc2d Map opaque waving leaves to allfaces drawtype
fixes #9842
2022-05-29 14:00:19 +02:00
sfan5 0c6a029413 Improve a translation string
fixes #11442
2022-05-29 14:00:19 +02:00
x2048 25ba9d848d
Default settings, presets and configuration for dynamic shadows (#12359) 2022-05-29 13:58:57 +02:00
Lars Müller 76000e676b
Lua workflow: Use Leafo's Luarocks action
instead of installing outdated packages which lead to failing workflows
2022-05-28 11:31:56 +02:00
Lars Müller e8b2954586
Builtin: Optimize misc helpers (#12377)
Also add formspec_escape unit test
2022-05-27 21:40:38 +02:00
Wuzzy fe299e24d6
DevTest: Add nodes and items for testing overlays (#12304) 2022-05-27 21:39:36 +02:00
x2048 ef22c0206f
Force-update shadows when the world is changed (#12364) 2022-05-26 22:28:34 +02:00
sfan5 8b74257bf3 Reduce size of ContentFeatures structure
On my system this is a reduction from 4664 to 3704 bytes.
This is not for the sake of saving RAM but ensuring
commonly used structures fit into caches better.
2022-05-26 15:49:12 +02:00
sfan5 9a01581cdd Get rid of global buffer that would ruin concurrent MapBlock serialization 2022-05-26 15:49:12 +02:00
sfan5 5d26ac0088 Improve code in mapblock_mesh.cpp a bit 2022-05-26 15:49:12 +02:00
x2048 ed26ed5a1f
Quantize light frustum calculations (#12357)
* Quantize light frustum calculations

Reduces shadow flicker

* Fix function name to match conventions
2022-05-23 23:45:18 +02:00
sfan5 16a30556df Formally drop support for building with upstream Irrlicht
It stopped working with (at least) the last commit.
2022-05-23 22:50:58 +02:00
sfan5 5daafc9d33 Fix hash implementation for SerializedBlockCache 2022-05-23 22:50:58 +02:00
Richard Try e16a470d59
Use unordered_map instead of map for MapSectors 2022-05-23 22:50:49 +02:00
paradust7 367a2d4b29
Add missing concurrency protection in logger (#12325) 2022-05-23 22:50:25 +02:00
Wuzzy 0f9c78c3eb
Fix no_texture.png for unknown nodes with ID < 125 (#12329) 2022-05-23 22:50:10 +02:00
Zughy c660218e43
Docs: clarify spawn_by for decorations 2022-05-23 22:49:48 +02:00
Wuzzy fa682270a9
Add missing comma in example in lua_api.txt (#12339) 2022-05-22 15:23:04 -04:00
Wuzzy ac5e8176b9
Add relative numbers for commands by prepending ~ (#9588)
* Add relative numbers for commands by prepending ~

* Some builtin code cleanup

* Disallow nan and inf in minetest.string_to_area

* Remove unused local variable teleportee (makes Luacheck happy)

* Clean up core.string_to_pos

* Make area parsing less permissive

* Rewrite tests as busted tests

* /time: Fix negative minutes not working

Co-authored-by: Lars Mueller <appgurulars@gmx.de>
2022-05-22 10:28:24 -04:00
Elias Fleckenstein 3ff3103e98
Merge branch 'master' of https://github.com/minetest/minetest 2022-05-22 12:05:27 +02:00
paradust7 9f338f5a56
Replace all uses of core::list with std::list (#12313) 2022-05-22 00:11:59 +02:00
paradust7 2742fef458
Fixes needed to use irrArray backed by std::vector (#12263) 2022-05-22 00:11:49 +02:00
sfan5 bc59fcf5c5 Bump IrrlichtMt version in CI 2022-05-22 00:11:22 +02:00
sfan5 2f32044273 Don't ignore server disconnects in client code
If the server stops talking to us without saying bye we
should actually end the in-game session with an error message.
2022-05-21 17:49:55 +02:00
paradust7 371f21fb35 Fixes to Android build + option to turn LuaJIT on/off for testing purposes (#12334) 2022-05-21 17:49:41 +02:00
Zughy 8edc0fae5f
Make no_screenshot image more clear (#12346) 2022-05-21 17:48:28 +02:00
paradust7 e1f707d7e1
Patch built-in Lua to fix miscompile on Android (#12347) 2022-05-21 17:46:50 +02:00
sfan5 9ee3dc71f1 Optimize JSON string (de)serialization routines
stringstreams were shown to be slow when reading/writing single characters
and there is lots of potential by having functions perform on existing
buffers whenever possible.
2022-05-21 17:46:10 +02:00
sfan5 70dc23f996 Improve testSerializeJsonString unit tests
this also removes the requirement that / is escaped, there is
no reason for doing so.
2022-05-21 17:46:10 +02:00
rubenwardy 4e9e230e34
Deprecate game.conf name, use title instead (#12030) 2022-05-21 16:23:30 +01:00
x2048 dc45b85a54
Improve shadow filters (#12195)
* Rewrite shadow filtering for the new distortion
* Calculate penumbra radius using a single sample
* Avoid peter-panning effect due to filtering of short shadows
* Add adaptive filter quality for soft shadows
* Avoid sharp shadows on surfaces without normals (e.g. plants)
* Increase default and maximum soft shadow radius
* Make line numbers in shader errors match the code
2022-05-21 16:49:30 +02:00
x2048 a4ef62f5b2
Fix lighting of upright_sprite entities (#12336)
Use MeshNode materials to set the light since ReadOnlyMaterials is now false
2022-05-20 22:35:03 +02:00
x2048 604fb2b738
Fix lighting of the wield mesh (#12341)
* Assign node light to player before final color blend.
  Fixes day/night lightbank ratio for wield meshes
* Update wield mesh light when changing mesh
2022-05-20 22:33:52 +02:00
Elias Fleckenstein 350b6d175c
Install lua_async dependency 2022-05-18 17:44:02 +02:00
Elias Fleckenstein 393c839282
Don't include client/game.h on server build 2022-05-18 16:57:14 +02:00
Elias Fleckenstein 8d19b99c5b
Merge branch 'master' of https://github.com/minetest/minetest 2022-05-18 16:00:53 +02:00
Elias Fleckenstein ccd4c504d5
Ship dragonfireclient with selected high-quality mods 2022-05-18 15:57:17 +02:00
paradust7 273bfee9a1
Use std::map instead of core::map (#12301) 2022-05-18 12:31:49 +02:00
Elias Fleckenstein 147aaf326f
Fix build instructions 2022-05-17 22:13:17 +02:00
Elias Fleckenstein 21df26984d
Merge branch 'master' of https://github.com/minetest/minetest 2022-05-17 22:12:00 +02:00
savilli af37f9dc54
Remove confusing message in keybindings menu 2022-05-17 20:11:08 +02:00
JakobDev db9b3aff75
Add vcs-browser and contribute URLs to Appdata 2022-05-17 20:08:32 +02:00
Wuzzy eabf05758e
DevTest: Fix broken PNG textures 2022-05-17 20:06:15 +02:00
Elias Fleckenstein b09fc5de5c
Add spider 2022-05-17 20:05:52 +02:00
Dmitry Kostenko 8756b7a735 Initialize wield mesh color when wield_image is set
#12245
2022-05-15 21:44:55 +02:00
sfan5 ec9f157512 Use native packer to transfer globals into async env(s) 2022-05-10 22:37:42 +02:00
Jude Melton-Houghton 7f58887ae3
Support packing arbitrary graphs (#12289) 2022-05-10 22:37:33 +02:00
Jude Melton-Houghton d17d7eba14 Fix cooking and fuel crafts with aliases 2022-05-10 22:37:05 +02:00
Zughy 4fb4991f5e
Add doc to list breaking changes for the next major release 2022-05-10 22:36:50 +02:00
Octavian 0f8c46771e Fix possible unreliable behavior due to uninitialized variables 2022-05-10 22:36:25 +02:00
sfan5 f5a8593b11
Add more Prometheus metrics (#12274) 2022-05-09 21:20:58 +02:00
Lars Müller c2898f53bc
HUD: Update selection mesh every frame (#12270)
Fixes outdated selection boxes after entity property changes.
2022-05-09 20:43:47 +02:00
Lars Müller 089797dbe6
Fix Minetest blaming the wrong mod for errors (#12241)
Covers the case where mods insert their callbacks manually into "minetest.registered_<callbacks>" (often to achieve a particular order of execution).
2022-05-09 20:42:43 +02:00
Lars Müller 53c70b5f27
Docs: Recommend `self.name` (#12239) 2022-05-09 20:41:47 +02:00
sfan5 a66e6d4dff Consolidate some data structures in MapBlockMesh 2022-05-08 19:12:10 +02:00
sfan5 1fa4f58080 Cache serialized mapblocks during sending
This reduces the
(absolute) time spent in Server::SendBlocks() from 700ms to 300ms
(relative) share of MapBlock::serialize() from 80% to 60%
in a test setup with 10 players and many block changes
2022-05-08 19:12:10 +02:00
sfan5 7fff9da71d item_entity: Cache collisionbox for use in on_step
I don't have absolute numbers but if calls to get_properties() take up
30%+ of on_step() execution time that's bound to matter.
2022-05-08 19:12:10 +02:00
ROllerozxa f128f4cba1 Fix mapblock geometry optimisation not working
Caused by the depth sorting PR marking not only transparent nodes to be ignored but also opaque ones with the TILE_MATERIAL_BASIC material type
2022-05-08 19:11:44 +02:00
Zughy 6f0c966877
Remove unused variable WARN_INIT 2022-05-08 19:11:15 +02:00
Jude Melton-Houghton f10a260301
Enable dependencies when enabling modpacks (#12202) 2022-05-08 16:21:59 +01:00
Jude Melton-Houghton 54bc8a7627
Fix enabling of dependencies with identical names (#12253) 2022-05-08 14:14:14 +01:00
rubenwardy 9824a451bb Fix mods not being recursively enabled
Fixes #12290
2022-05-08 14:01:32 +01:00
rubenwardy e0e897832c Fix texture packs showing as "Nil (enabled)" in Content tab
Fixes #12285
2022-05-07 23:05:39 +01:00
paradust7 87472150bc
Add benchmarks for json string serialize/deserialize (#12258)
Co-authored-by: sfan5 <sfan5@live.de>
2022-05-06 21:17:16 +01:00
Froggo 45d318a773
Enable chat clickable weblinks by default (#12115)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2022-05-06 21:15:16 +01:00
sfan5 4e1de06782 Bump IrrlichtMt to 1.9.0mt5 in CI 2022-05-06 15:16:04 +02:00
sfan5 8735a85a30 Declare all bundled libs as static
Otherwise it can happen that these are built as shared depending on the
options passed to CMake, which obviously isn't intended.
2022-05-06 15:16:04 +02:00
sfan5 e108954633 Sort out some issues with our CI setup
* add missing apt-get update where needed
* move some jobs to run on ubuntu-20.04
* update actions plugins to latest
* speed up the job that runs multiplayer tests
2022-05-06 15:15:53 +02:00
LoneWolfHT 47cf257c40
Fix Windows Visual Studio actions (#11176)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2022-05-04 22:55:02 +01:00
x2048 cc56ebd90d
Avoid rendering invisible faces of simple nodeboxes (#12262)
* Skip rendering faces adjacent to opaque nodes
* Cancel out opposite faces of adjacent nodebox nodes of the same type

Fixes #6409
2022-05-04 23:44:55 +02:00
Lars Müller 89c82035d8
hud_get: Return precision field for waypoints (#12215) 2022-05-04 20:55:20 +02:00
SmallJoker 3ce5a68cd1
guiScalingFilter: Fix most memory leaks (#12256)
Calls to the cache function ended up creating a new texture regardless whether
the texture is already cached.
2022-05-04 20:55:13 +02:00
paradust7 0704ca0550
Make logging cost free when there is no output target (#12247)
The logging streams now do almost no work when there is no output target for them.

For example, if LL_VERBOSE has no output targets, then `verbosestream << x` will return a StreamProxy with a null target. Any further `<<` operations applied to it will do nothing.
2022-05-04 20:55:01 +02:00
Lars Müller ae7664597e
Add vector.combine (#11920) 2022-05-04 07:44:14 -04:00
rubenwardy e9e671078c ContentDB: Fix ungraceful crash on aliases when list download fails
Fixes #12267 and fixes #12154
2022-05-03 20:00:29 +01:00
sfan5 71a56c3552 Fix broken FPS/dtime counters in debug info
was broken by a89afe1229
2022-05-03 20:17:43 +02:00
sfan5 e7659883cc Async environment for mods to do concurrent tasks (#11131) 2022-05-02 20:56:06 +02:00
sfan5 663c936428 Fix synchronization issue at thread start
If a newly started thread immediately exits then m_running would
immediately be set to false again and the caller would be stuck
waiting for m_running to become true forever.
Since a mutex for synchronizing startup already exists we can
simply move the while loop into it.

see also: #5134 which introduced m_start_finished_mutex
2022-05-02 20:54:55 +02:00
sfan5 56a558baf8 Refactor some Lua API functions in preparation for async env 2022-05-02 20:54:55 +02:00
sfan5 e6385e2ab7 Reorganize some builtin functions in preparation for async env 2022-05-02 20:54:55 +02:00
sfan5 5362f472ff Remove some unused variable from Lua class wrappers 2022-05-02 20:54:55 +02:00
JakobDev 41e79d902d
Add German translation to AppData file (#12161) 2022-05-02 18:22:23 +02:00
x2048 c7bcebb628
Initialize wield mesh colors when changing item. (#12254)
Fixes #12245
2022-05-01 17:21:00 +02:00
sfan5 a89afe1229 Deal with compiler warnings 2022-04-30 16:49:41 +02:00
sfan5 faecff570c Enable additional warning flags
also make them work with the RelWithDebInfo build type
2022-04-30 16:49:41 +02:00
x2048 828461c193
Run automated tests when lua files change (#12184)
* Run automated tests when lua files change

* skip busted on devtest

* use newer build env

* Add .luacheckrc for games/devetest

Co-authored-by: sfan5 <sfan5@live.de>
2022-04-30 15:54:07 +02:00
qwerty123a2 ec4a789b4f
Update mods_here.txt to mention installing mods via CDB (#11876)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2022-04-29 17:15:19 +01:00
sfan5 a65f6f07f3 Clean up some auth packet handling related code 2022-04-28 20:05:26 +02:00
sfan5 00f71c3b9d Fix password changing getting stuck if wrong password is entered once 2022-04-28 19:55:36 +02:00
sfan5 3d2bf8fb02 Apply disallow_empty_password to password changes too 2022-04-28 19:55:36 +02:00
sfan5 391eec9ee7 Fix race condition in registration leading to duplicate create_auth calls 2022-04-28 19:55:36 +02:00
Oblomov 0d91ef78dd
Refactor local time getter functions (#12221)
This commit introduces mt_localtime() in src/gettime.h, a wrapper
around the OS-specific thread-safe versions of localtime()
(resp. localtime_s on Windows and localtime_r in other systems).

Per the Open Group recommendation,
«portable applications should call tzset() explicitly before using
ctime_r() or localtime_r() because setting timezone information is
optional for those functions», so we also do a one-shot
call of tzset() (_tzset() on Windows to avoid warning C4996).

The function is used to replace the localtime() calls in
getTimestamp() and makeScreenshot().

(The only reminaing call to localtime() in the tree now is the one in
the local copy of the Lua source code.)
2022-04-28 18:53:33 +02:00
paradust7 7e18a1f1be
Remove HW_buffer_counter after IrrlichtMt fix to remove HWBufferMap (#12232)
Keep code and use version check instead, for backwards compatibility
2022-04-28 18:52:19 +02:00
Wuzzy 7f4fc6f8a7
Show unknown node in debug screen (#12230) 2022-04-28 18:51:46 +02:00
Wuzzy a2f13e479b
DevTest: Fix armorball sprite (#12228) 2022-04-28 18:51:16 +02:00
Lars Müller fccf1e2eac
Support CSS Color Module Level 4 (#12204) 2022-04-27 17:00:02 -04:00
rubenwardy 480d5f2d51 Fix texture packs not showing as enabled in mainmenu
Fixes #12219
2022-04-24 23:09:23 +01:00
Alex a6170963b8
Fix invalid queued package element and path (#12218) 2022-04-24 22:49:07 +01:00
Wuzzy 77325b92fb
DevTest: Add more test weapons and armorball modes (#11870)
Co-authored-by: sfan5 <sfan5@live.de>
2022-04-24 22:48:50 +01:00
Giuseppe Bilotta b55d7cd45a Fix worldaligned textures
As reported in #12197, b0b9732359
introduces a regression in worldalign textures.

The specific change that seems to be responsible for this issue is the
change in order between the computation of the cuboid texture
coordinates and the box edge correction.

Fix #12197 by moving the box edge correction back to before the cuboid
texture coordinates, as it used to be.
2022-04-24 21:11:24 +02:00
Giuseppe Bilotta 23f981c458 Fix some textures not being sent correctly to older clients
Since b2eb44afc5, a texture defined as
`[combine:16x512:0,0=some_file.png;etc`
will not be sent correctly from a 5.5 server to a 5.4 client due to the
overeager detection of unsupported base modifier `[` introducing a
spurious `blank.png^` before the modifier.

Fix this by whitelisting which base modifiers can be passed through
unchanged to the client, and prefix `blank.png` for the others
(which at the moment is just [png:, but the list may grow larger
as new base modifiers are added.)
2022-04-24 21:10:23 +02:00
Lars Müller 48d1bca9b8
Fix typo: vector.check() ought to be vector.check(v) 2022-04-24 21:10:03 +02:00
olive a13cf0e3ce
Use mod names/titles instead of technical names (#12192) 2022-04-24 21:09:11 +02:00
SmallJoker 1c8614ac9a
Builtin: Allow to revoke unknown privileges 2022-04-24 21:08:33 +02:00
Lars Müller 4558793caf
Fix some debug info showing despite being disabled in the UI (#12205) 2022-04-21 21:45:47 +02:00
Lars Müller 583257f093 Update docs to reference CSS Color Module Level 3
as the named color "rebeccapurple" is unavailable, Level 4 clearly isn't supported; the link should not point to a dev version of the spec either
2022-04-21 21:45:20 +02:00
paradust7 7cea688a1c
Fix '[combine' when EVDF_TEXTURE_NPOT is disabled. (#12187)
Stop scaling images to POT immediately when loaded. The 'combine'
modifier hardcodes X and Y coordinates, and so behaves incorrectly
if applied to a scaled image. Images emitted by generateImage()
are already scaled to POT before being used as a texture, so
nothing should break.
2022-04-16 18:50:59 +02:00
olive 062dd8dabc
Send chat error when attemping to /set a secure setting (#12193)
Attempting to /set a secure setting will now say that is disallowed.
Previously this would shut down the server.
Reading secure settings via /set is still allowed.
2022-04-16 18:50:36 +02:00
SmallJoker 1d07a36552
upright_sprite: Fix walk animation in first person (#12194) 2022-04-15 18:55:08 +02:00
x2048 a5d29fa1d4
Implement shadow offsets for the new SM distortion function (#12191)
* Move shadow position calculation to vertex shaders
* Animate entire scene before rendering shadows to prevent lagging of shadows
* Remove unnecessary use of PolygonOffsetFactor
* Apply normal offset to both nodes and objects
* Rename getPerspectiveFactor -> applyPerspectiveDistortion
* Remove perspective distortion from fragment shaders
2022-04-14 22:49:30 +02:00
Lars Mueller 9aabd911eb Fix item entity Z-fighting 2022-04-10 23:25:00 +02:00
Lars Müller 1f27bf6380
Remove unneeded ObjectRef setter return values (#12179) 2022-04-10 23:20:51 +02:00
ShadowNinja 2d8eac4e0a Don't test overflow behavior for VoxelArea extents 2022-04-08 14:55:21 +01:00
ShadowNinja 833538cc90 Remove generate-texture-normals.sh
Minetest does not use normal maps any more.
2022-04-08 14:55:21 +01:00
ShadowNinja 80db8804c7 Fix typo and update settings files 2022-04-08 14:55:21 +01:00
ShadowNinja d9effbb179 Fix spaces generated by settings file generator 2022-04-08 14:55:21 +01:00
ShadowNinja 24a0f55c9c Use CMake's -B, --build, and --install options 2022-04-08 14:55:21 +01:00
ShadowNinja f5e54cd398 Fix OOB read in trim("") 2022-04-08 14:55:21 +01:00
ShadowNinja c9317a16c5 Remove duplicate test for trim 2022-04-08 14:55:21 +01:00
ShadowNinja dae6fe91a1 Update directory name sanitization
Only ASCII spaces have to be handles specially, and leading spaces are
also disallowed.
2022-04-08 14:55:21 +01:00
ShadowNinja 65fdc7ae50 Add tests for sanitizeDirName 2022-04-08 14:55:21 +01:00
ShadowNinja 00ebedad93 Add additional reserved directory names 2022-04-08 14:55:21 +01:00
ShadowNinja 35bfffb556 Auto-detect level of parallelism 2022-04-08 14:55:21 +01:00
ShadowNinja 8af332c9a7 Remove duplication in config.h 2022-04-08 14:55:21 +01:00
ShadowNinja 7993909fab Spacing fixes 2022-04-08 14:55:21 +01:00
ShadowNinja 88b21a72f1 Treat empty XDG_CACHE_HOME same as unset
This matches the XDG base directory spec.
2022-04-08 14:55:21 +01:00
ShadowNinja ea2fba877a Use build directory for builds 2022-04-08 14:55:21 +01:00
ShadowNinja 5683bb76cc Fix compiler warnings 2022-04-08 14:55:21 +01:00
Dmitry Kostenko 3a87fab6c8 Remove reference to a removed file in devtest (followup to #12157) 2022-04-07 23:13:09 +02:00
Dmitry Kostenko 23516acd0b Remove obsolete commented code (follow up to #12166) 2022-04-07 22:38:01 +02:00
x2048 48f7c5603e
Adjust shadowmap distortion to use entire SM texture (#12166) 2022-04-07 22:13:50 +02:00
Jude Melton-Houghton 0b5b2b2633
Disentangle map implementations (#12148)
Fixes violation of Liskov substitution principle
Fixes #12144
2022-04-07 21:58:04 +02:00
x2048 1348d9aaf8
Enable shadows by default in devtest (#12157)
* Move all shadow control to util_commands
* Shadows are now controlled with /set_shadow

Co-authored-by: sfan5 <sfan5@live.de>
2022-04-07 21:55:19 +02:00
Jude Melton-Houghton 21f17e871e
Compile Lua as C++ (#11683)
Co-authored-by: sfan5 <sfan5@live.de>
2022-04-07 15:54:17 +01:00
sfan5 837cea6b4a Fix -mwindows flag not being applied anymore
closes #12165
2022-04-03 21:44:22 +02:00
x2048 b0b9732359
Add depth sorting for node faces (#11696)
Use BSP tree to order transparent triangles
https://en.wikipedia.org/wiki/Binary_space_partitioning
2022-04-02 10:42:27 +02:00
Dmitry Kostenko 26c046a563 Increase the ratio between shadow range and viewing range 2022-04-02 10:39:43 +02:00
Dmitry Kostenko cf650fcaac Avoid negation of comparison operator (luacheck warning) 2022-04-01 09:00:39 +02:00
x2048 3dd7d7867b
Limit shadow map to the viewing range (#12158) 2022-03-31 22:40:59 +02:00
x2048 31578303a4
Tune shadow perspective distortion (#12146)
* Pass perspective distortion parameters as uniforms
* Set all perspective bias parameters via ShadowRenderer
* Recalibrate perspective distortion and shadow range to render less shadow geometry with the same quality and observed shadow distance
2022-03-31 22:40:06 +02:00
Jude Melton-Houghton 06d197cdd0
Store vector metatable in registry 2022-03-29 18:07:00 +02:00
Jude Melton-Houghton 11aab4198b
Optimize swapping nodes with equivalent lighting 2022-03-29 18:06:44 +02:00
DS 8d387433b1
Fix the documentation of InvRef:get_lists() and clean up code (#12150) 2022-03-29 18:06:16 +02:00
x2048 0f25fa7af6
Add API to control shadow intensity from the game/mod (#11944)
* Also Disable shadows when sun/moon is hidden. Fixes #11972.
2022-03-26 16:58:26 +01:00
DS 8d55702d13
Improve lua vector helper class doumentation (#12090) 2022-03-19 12:06:55 +01:00
Daroc Alden e54f5e544f
Fix memory leak in EmergeManager
EmergeManager keeps a copy of the BiomeGen that it creates, but
never deletes it.
2022-03-14 21:01:36 +01:00
Gregor Parzefall 289c3ff377
Fix footsteps for players whose collision box min y != 0 (#12110) 2022-03-14 21:01:18 +01:00
Daroc Alden 11f3f72f1c
Fix undefined behavior in TileLayer (#12125)
Initialize the values properly
2022-03-11 21:22:49 +01:00
sfan5 ad7c72c164 Remove direct OpenGL(ES) dependency
IrrlichtMt now provides this for us (see last commit)
fixes #12041
2022-03-09 22:37:34 +01:00
sfan5 51294163bb Use Irrlicht bindings for GL call 2022-03-09 22:37:34 +01:00
Daroc Alden 598efbf7f9
Fix memory leak from SpatialAreaStore (#12120) 2022-03-09 19:28:12 +01:00
Dmitry Kostenko b651bbf446 Reuse normal offset calculation for nodes 2022-03-07 23:45:26 +01:00
Dmitry Kostenko 4801bdf45a Correct normal bias for entities
Remove use of magic constants.
Apply cameraOffset
Calculate distance projected on SM plane
2022-03-07 23:45:26 +01:00
Dmitry Kostenko 25c1974e0d Change normal bias for entities to avoid shadow acne 2022-03-07 23:45:26 +01:00
Dmitry Kostenko 12896b22d8 Remove debugging code 2022-03-07 23:45:26 +01:00
Dmitry Kostenko e531c59606 Ensure nightRatio is greater than zero in object shader 2022-03-07 23:45:26 +01:00
Dmitry Kostenko 8f652f4e31 Fix shadows for upright sprite nodes
Avoid using read only materials in mesh scene node, as
it confuses shadow renderer.
2022-03-07 23:45:26 +01:00
Dmitry Kostenko 97cb404822 Apply texture matrix when rendering shadowmap
Fixes shadows of animated sprite entities
2022-03-07 23:45:26 +01:00
Dmitry Kostenko d2a3bed240 Avoid possible buffer overflow when checking face normals 2022-03-07 23:45:26 +01:00
Dmitry Kostenko e4583cb9b7 Use correct indexes when checking mesh normals 2022-03-07 23:45:26 +01:00
Dmitry Kostenko a684a91bf5 Fix shadow rendering with filtering disabled 2022-03-07 23:45:26 +01:00
Dmitry Kostenko 1175f48d05 Detect 'insane' normals in checkMeshNormals.
Detect non-zero normals which point in the opposite direction from the
face plane normal.
2022-03-07 23:45:26 +01:00
Dmitry Kostenko 54dccc480e Improve lighting of entities.
Pass correct natural & artificial light to the shaders
Use natural/artificial light ratio for correct rendering of shadows
2022-03-07 23:45:26 +01:00
Dmitry Kostenko f2cccf8da7 Improve self-shadowing based on light/normal angle
Add compatibility with colored shadows.
2022-03-07 23:45:26 +01:00
Dmitry Kostenko 10be033791 Copy shadow mapping shader from nodes to objects 2022-03-07 23:45:26 +01:00
Dmitry Kostenko 4e39cdef94 Apply shadow texture to wield-based entities
For example, dropped nodes and items.
2022-03-07 23:45:26 +01:00
Dmitry Kostenko 2bba53b2c3 Render shadows on entities.
Fixes problem with mod 'drawers'.
2022-03-07 23:45:26 +01:00
Lars Müller b9e886726c
Readd basic_debug as a HUD flag (#12020) 2022-03-05 22:16:17 +01:00
Zughy 44fc888bd6
Allow get_sky to return a table (#11963) 2022-03-05 22:15:41 +01:00
sfan5 f2d1295fe6 Fix segfault with autoscale_mode (again)
closes #12100
This time add some asserts so there is no misunderstanding about the NULL-ness of layer->texture.
2022-03-02 17:49:45 +01:00
sfan5 04bd253390 Move the codebase to C++14 2022-02-26 14:39:41 +01:00
rubenwardy 7db751df3b
Fix broken dependency enabling due to missing `enabled` field (#12093) 2022-02-24 16:01:22 +00:00
SmallJoker f7311e0d97
Lua API documentation: Various fixes (#12059)
Change 1: Clarify when on_step collision information is provided
Change 2: Document PostgreSQL and Redis settings
Change 3: Overall AreaStore documentation improvements including consistent parameter naming based on community suggestions
2022-02-23 21:21:37 +01:00
DS 633e23bd65
FormspecMenu: make drawing of backgrounds less hacky (#9517) 2022-02-22 19:17:53 +01:00
Nils Dagsson Moskopp 7c227d2a00
Add TGA test nodes to devtest (#11978) 2022-02-22 19:17:40 +01:00
Lars Müller 0a0fb11c21
Lua API: Consistently use double vs. single quotes (#12075) 2022-02-22 19:17:08 +01:00
sfan5 c31b301722 Clean up ClientReady packet handling
fixes #12073
2022-02-17 23:20:33 +01:00
pecksin 5d0b18a0d0
Use absolute value for bouncy in collision (#11969)
* use abs(bouncy) in collision
* test case for negative bouncy
* send abs(bouncy) to old clients
2022-02-16 17:06:00 -05:00
ROllerozxa 258ae99491
Apply texture pack main menu textures immediately (#12018) 2022-02-12 20:24:20 +01:00
Wuzzy 10cf2f3edd
Add support for 'seed' in disallow_mapgen_settings (#12023) 2022-02-12 20:23:58 +01:00
Dennis Jenkins 0cd9c5b5be
Correct world_format.txt specification (#12061)
The node timers appear at the end of a mapblock for map format version >= 25, not just map format version 25.
2022-02-12 20:23:46 +01:00
DS a8707158a5
Allow to set the displayed item count and its alignment via meta (#8448)
* Allow to set the displayed item count and its offset via meta

* fix rect constr call

* devtest: add dump_item chatcommand

* fix rect2 constr call (sdim is a position (typedef for v2s32), not a dimension) and remove background because it would work now

* add missing utf8 to wide conversion

* rename to count_meta
2022-02-10 06:17:52 -05:00
Lars Müller ad1da994b2
Increase max objects per block defaults (#12055) 2022-02-08 19:33:10 +01:00
sfan5 ba6fbc417e Remove awful Mingw32 workarounds
Instead a warning is triggered if an affected compiler is detected.
closes #12022
2022-02-08 19:31:24 +01:00
sfan5 ce199d6f9e Update MinGW used by CI
This made a rebuild of 32-bit deps necessary.
They were updated in the process and this was done for 64-bit too for consistency.
2022-02-08 19:31:24 +01:00
Gaël C 0dd8e8c242
Noise params serialization fixup 2022-02-08 19:30:49 +01:00
Lars Müller b9ee29a945
Send HUD flags only if changed 2022-02-08 19:28:32 +01:00
Zughy be05c9022d
Update copyright year in README (#12029) 2022-02-04 20:29:39 +01:00
sfan5 afb061c374
Fix broken server startup if curl is disabled (#12046) 2022-02-04 20:29:28 +01:00
Lars Müller 1ee37148a8
Fix types of get_mapgen_setting_noiseparams (#12025) 2022-02-04 20:28:43 +01:00
Jude Melton-Houghton 1c73902005 Clean up ClientInterface locking 2022-02-03 11:43:51 +01:00
DS d387e9b6d3
Add more documentation for the list[] fs element (#11979) 2022-02-03 11:43:28 +01:00
sfan5 163d3547e6 Fix macOS compile instructions 2022-01-31 22:48:29 +01:00
rubenwardy c61998bd20
Revert "Disable dynamic shadows for the 5.5.0 release" (#12032) 2022-01-31 21:48:14 +00:00
Lars Mueller 1e4d6672be Fix builtin statbar backgrounds
see #12000
2022-01-31 16:35:30 -05:00
Lars Mueller 80812b86d6 Document moon orientation relative to sun 2022-01-31 07:36:39 -05:00
rubenwardy 128f6359e9
Use virtual paths to specify exact mod to enable (#11784) 2022-01-30 22:40:53 +00:00
sfan5 8c0331d244 Continue with 5.6.0-dev 2022-01-30 22:58:19 +01:00
sfan5 54b805ffd0 Bump version to 5.5.0 2022-01-30 22:58:18 +01:00
sfan5 484a4b518f Add another very awful workaround to prevent a crash on Mingw32
This appears to be the same issue as 70df3d54f3.
Hopefully the next MinGW update will remove the need for this.
2022-01-30 22:57:44 +01:00
sfan5 5e4a01f2de
Update credits for 5.5.0 release (#12001) 2022-01-30 21:33:08 +01:00
sfan5 5da204f5bc
Get rid of `basic_debug` last minute
This isn't a revert but rather just disables the codepaths. also see #12011
2022-01-30 21:32:49 +01:00
sfan5 b66477c29f
Abort raycasts that go out-of-bounds (#12006) 2022-01-30 21:31:18 +01:00
poi a0e4b2bf54 Translated using Weblate (Chinese (Simplified))
Currently translated at 93.4% (1323 of 1416 strings)
2022-01-30 19:53:29 +01:00
Nikita Epifanov 98982065ed Translated using Weblate (Russian)
Currently translated at 97.8% (1386 of 1416 strings)
2022-01-30 19:53:29 +01:00
Wuzzy 49adce1a63 Translated using Weblate (German)
Currently translated at 100.0% (1416 of 1416 strings)
2022-01-30 19:53:29 +01:00
Andrij Mizyk 7c393f8658 Translated using Weblate (Ukrainian)
Currently translated at 48.7% (691 of 1416 strings)
2022-01-30 19:53:29 +01:00
waxtatect fcd06d99c6 Translated using Weblate (French)
Currently translated at 100.0% (1416 of 1416 strings)
2022-01-30 19:53:29 +01:00
BreadW f3e23ae972 Translated using Weblate (Japanese)
Currently translated at 100.0% (1416 of 1416 strings)
2022-01-30 19:53:29 +01:00
Marian 39f5b05ae9 Translated using Weblate (Slovak)
Currently translated at 100.0% (1416 of 1416 strings)
2022-01-30 19:53:29 +01:00
Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi 9205f10208 Translated using Weblate (Malay)
Currently translated at 100.0% (1416 of 1416 strings)
2022-01-30 19:53:29 +01:00
Balázs Kovács 8b9e5b47df Translated using Weblate (Hungarian)
Currently translated at 86.0% (1219 of 1416 strings)
2022-01-30 19:53:29 +01:00
Thomas Wagner Nielsen 17bb2712cb
Translated using Weblate (Danish)
Currently translated at 39.9% (566 of 1416 strings)
2022-01-30 19:51:22 +01:00
Wuzzy 9d3135a21b Update German builtin translation 2022-01-30 13:50:07 +01:00
Wuzzy 777fb616b6 Update builtin translation templates 2022-01-30 13:50:07 +01:00
ROllerozxa 172acce352
Fix Minetest logo when installed system-wide 2022-01-30 13:49:52 +01:00
sfan5 f69eead62e Get rid of empty test file 2022-01-30 13:49:26 +01:00
sfan5 a9bccb964f Raise max mapgen limit constant to align with mapblock size 2022-01-30 13:49:26 +01:00
SmallJoker 74a384de0a Auto-update minetest.conf.example 2022-01-29 18:42:55 -05:00
SmallJoker a27362de6a Disable dynamic shadows for the 5.5.0 release
The dynamic shadows are yet not in the desired state to justify the
inclusion into version 5.5.0. A stable release is long overdue, hence
this allows fixes to continue in 5.6.0-dev to finally release an
acceptable version of the dynamic shadows feature.

Reverting this commit is highly recommended to proceed in development.
2022-01-29 18:42:55 -05:00
sfan5 66e8aae9f2 Get rid of legacy workaround in SQLite backend
tested on Android 11, fixes #11937
2022-01-28 17:16:02 +01:00
sfan5 91c6728eb8 Add game name to server status string 2022-01-28 17:15:10 +01:00
sfan5 22f0c66abb Request execution on dedicated GPU on Windows 2022-01-27 22:30:02 +01:00
sfan5 7aea5cb88f Enable high-res timers on Windows
This should fix issues like #11891, caused by the fps limiting
code being unable to operate correctly.
2022-01-27 22:30:02 +01:00
sfan5 058846d687 Rework drawtime and related timekeeping code to use microseconds 2022-01-27 22:30:02 +01:00
Jude Melton-Houghton fc161e757c
Automatically migrate client mod storage (#11960) 2022-01-27 22:24:30 +01:00
SmallJoker 47735c273c
Builtin: Sanity-check /time inputs (#11993)
This enforces the documented bounds for the /time command.
2022-01-27 22:23:14 +01:00
Lars Müller fe0b2d02bf
Define control(bits) as "unset" for entities (#11995) 2022-01-27 22:22:58 +01:00
updatepo.sh 48e508052a Update translations 2022-01-25 23:19:13 +01:00
updatepo.sh 0d0786e414 Update example config and translation .cpp 2022-01-25 23:18:50 +01:00
poi 4f0d7738b3 Translated using Weblate (Chinese (Simplified))
Currently translated at 93.8% (1328 of 1415 strings)
2022-01-25 23:05:57 +01:00
Balázs Kovács 76d7816749 Translated using Weblate (Hungarian)
Currently translated at 85.5% (1210 of 1415 strings)
2022-01-25 23:05:57 +01:00
rubenwardy 8c486aaeae Translated using Weblate (Spanish)
Currently translated at 79.5% (1125 of 1415 strings)
2022-01-25 23:05:57 +01:00
Gao Tiesuan 2c338032ed Translated using Weblate (Chinese (Literary))
Currently translated at 0.6% (9 of 1415 strings)
2022-01-25 23:05:57 +01:00
Gao Tiesuan 94128924b2 Translated using Weblate (Chinese (Simplified))
Currently translated at 92.4% (1308 of 1415 strings)
2022-01-25 23:05:57 +01:00
Gao Tiesuan 319c4d1274 Added translation using Weblate (Chinese (Literary)) 2022-01-25 23:05:57 +01:00
Wuzzy 7a8efa7f4f Translated using Weblate (German)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:57 +01:00
Mehmet Ali 6c3c2b3f92 Translated using Weblate (Turkish)
Currently translated at 98.6% (1396 of 1415 strings)
2022-01-25 23:05:57 +01:00
Yiu Man Ho f1ac573e9a Translated using Weblate (Chinese (Traditional))
Currently translated at 79.9% (1131 of 1415 strings)
2022-01-25 23:05:57 +01:00
Kisbenedek Márton 0be76c0bf5 Translated using Weblate (Hungarian)
Currently translated at 79.9% (1131 of 1415 strings)
2022-01-25 23:05:57 +01:00
pampogo kiraly c07aeb0075 Translated using Weblate (Hungarian)
Currently translated at 79.7% (1129 of 1415 strings)
2022-01-25 23:05:57 +01:00
Sebastian Jasiński 4e5de9607b Translated using Weblate (Polish)
Currently translated at 69.8% (988 of 1415 strings)
2022-01-25 23:05:57 +01:00
Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi c6f3dcc009 Translated using Weblate (Malay (Jawi))
Currently translated at 65.3% (925 of 1415 strings)
2022-01-25 23:05:57 +01:00
Mikita Wiśniewski 620ba51375 Translated using Weblate (Russian)
Currently translated at 98.5% (1394 of 1415 strings)
2022-01-25 23:05:57 +01:00
Imre Kristoffer Eilertsen 1a98351212 Translated using Weblate (Norwegian Bokmål)
Currently translated at 56.5% (800 of 1415 strings)
2022-01-25 23:05:57 +01:00
Muhammad Rifqi Priyo Susanto d4746b349d Translated using Weblate (Indonesian)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:57 +01:00
AFCMS d9caa1bd48 Translated using Weblate (French)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
Joaquín Villalba c3a82b9a49 Translated using Weblate (Spanish)
Currently translated at 79.6% (1127 of 1415 strings)
2022-01-25 23:05:56 +01:00
debiankaios c4b47269a4 Translated using Weblate (German)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
109247019824 b4cc25f25b Translated using Weblate (Bulgarian)
Currently translated at 30.6% (434 of 1415 strings)
2022-01-25 23:05:56 +01:00
Allan Nordhøy 7645c95110 Translated using Weblate (Norwegian Bokmål)
Currently translated at 54.7% (775 of 1415 strings)
2022-01-25 23:05:56 +01:00
Minetest-j45 4decded6ab Translated using Weblate (Spanish)
Currently translated at 79.6% (1127 of 1415 strings)
2022-01-25 23:05:56 +01:00
waxtatect 471031e516 Translated using Weblate (French)
Currently translated at 99.9% (1414 of 1415 strings)
2022-01-25 23:05:56 +01:00
AFCMS c8d621e0b4 Translated using Weblate (French)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
ssantos b1ea3a6199 Translated using Weblate (Portuguese)
Currently translated at 98.9% (1400 of 1415 strings)
2022-01-25 23:05:56 +01:00
Mateusz Mendel bb2d79f930 Translated using Weblate (Polish)
Currently translated at 69.6% (985 of 1415 strings)
2022-01-25 23:05:56 +01:00
Gert-dev c416394ab2 Translated using Weblate (Dutch)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
pesder 02478d2db6 Translated using Weblate (Chinese (Traditional))
Currently translated at 70.3% (996 of 1415 strings)
2022-01-25 23:05:56 +01:00
Stas Kies 9740a35685 Translated using Weblate (Russian)
Currently translated at 98.5% (1394 of 1415 strings)
2022-01-25 23:05:56 +01:00
xerxstirb 7f1db70919 Translated using Weblate (Swedish)
Currently translated at 58.5% (828 of 1415 strings)
2022-01-25 23:05:56 +01:00
ROllerozxa 02c288fa13 Translated using Weblate (Swedish)
Currently translated at 58.5% (828 of 1415 strings)
2022-01-25 23:05:56 +01:00
Nikita Epifanov f6ae8b6350 Translated using Weblate (Russian)
Currently translated at 97.6% (1382 of 1415 strings)
2022-01-25 23:05:56 +01:00
Linerly e59e16161f Translated using Weblate (Indonesian)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
IAmOlive 7b46bcbbb8 Translated using Weblate (Vietnamese)
Currently translated at 20.3% (288 of 1415 strings)
2022-01-25 23:05:56 +01:00
Gabriel Cardoso 9b2dd0c7b3 Translated using Weblate (Portuguese (Brazil))
Currently translated at 99.2% (1404 of 1415 strings)
2022-01-25 23:05:56 +01:00
BreadW 8eeab37473 Translated using Weblate (Japanese)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
Marian c745e711ec Translated using Weblate (Slovak)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
abidin toumi f022f030d0 Translated using Weblate (Arabic)
Currently translated at 37.8% (535 of 1415 strings)
2022-01-25 23:05:56 +01:00
Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi 8ab369475f Translated using Weblate (Malay)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
Oğuz Ersen 9d1aed01fc Translated using Weblate (Turkish)
Currently translated at 98.6% (1396 of 1415 strings)
2022-01-25 23:05:56 +01:00
Andrei Stepanov a2cdc6de33 Translated using Weblate (Russian)
Currently translated at 96.5% (1366 of 1415 strings)
2022-01-25 23:05:56 +01:00
Simone Starace 828ecac826 Translated using Weblate (Italian)
Currently translated at 97.9% (1386 of 1415 strings)
2022-01-25 23:05:56 +01:00
Muhammad Rifqi Priyo Susanto a0edf2849a Translated using Weblate (Indonesian)
Currently translated at 99.9% (1414 of 1415 strings)
2022-01-25 23:05:56 +01:00
Wuzzy e7fe20ada6 Translated using Weblate (German)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
waxtatect 37aa8468a0 Translated using Weblate (French)
Currently translated at 100.0% (1415 of 1415 strings)
2022-01-25 23:05:56 +01:00
Jude Melton-Houghton 1b2176a426
Cancel emerge callbacks on shutdown 2022-01-23 00:56:17 +01:00
Vincent Robinson 95a775cd3a
Bump formspec version (#11980) 2022-01-23 00:55:43 +01:00
Dmitry Kostenko 71317b8579 Make sure nightRatio is always greater than zero.
To avoid underfined behavior of GLSL pow()
2022-01-22 18:52:12 +01:00
sfan5 f8cef52ea0 Fix consistency of sky sun/moon texture behaviour
Also cleans up related code somewhat.
2022-01-22 11:18:34 -05:00
Zughy 37d80784dd
Allow resetting celestial vault elements by leaving its arguments empty (#11922) 2022-01-22 12:42:49 +01:00
sfan5 f66ed2c27f Fix local animation not instantly updating after being set 2022-01-19 23:30:18 +01:00
sfan5 4f6f09590c Free arguments of cancelled minetest.after() jobs 2022-01-19 23:30:18 +01:00
SmallJoker 7c321ad7f5 Main menu: Fix automatic dependency enables on doubleclick
When mods were toggled by double-click, the hard dependencies were no longer enabled automatically.
However, the 'Enabled' checkbox did still work. This commit restores the behaviour as seen before commit c401a06
2022-01-19 18:52:27 +01:00
sfan5 42839fa1db Optimize folder handling in 'files' mod storage backend
This regressed in bf22569019.
2022-01-17 21:49:18 +01:00
sfan5 b02b381af2 Bump IrrlichtMt to 1.9.0mt4 in CI 2022-01-16 15:54:08 +01:00
Dmitry Kostenko b6555ee6af Reset override material in anaglyph
Reset override material properties before applying the color filter.
2022-01-16 13:10:33 +01:00
Alex 7c93b2d7a3
Give the ASCII console splash a facelift 2022-01-15 17:45:33 +01:00
sfan5 9a12e4499e Minor improvements to Lua sandbox 2022-01-15 17:45:08 +01:00
sfan5 379473b670 Improve situation around race condition with dynamic_add_media during client join 2022-01-15 17:45:08 +01:00
savilli 72b14bd994
Don't call on_dieplayer callback two times (#11874) 2022-01-15 17:44:55 +01:00
sfan5 76e97e85a0 Update compiler versions in CI
downgrade gcc 6 -> 5 to better match our minimum
upgrade gcc and clang by moving two images to ubuntu 20.04
2022-01-15 17:44:22 +01:00
sfan5 a90b2a4d4f Raise minimum compiler versions
Supporting these is not reasonable anymore and effectively we didn't
do that anyway, brokenness was only noticed by chance and a PR to restore
support for gcc 5.x is ready now.
2022-01-15 17:44:22 +01:00
Dmitry Kostenko 97248c6957 Add client/mod_storage.sqlite to .gitignore 2022-01-13 20:43:02 +01:00
SmallJoker b2eb44afc5
Fix NodeDef backwards compatibility to 5.3.0 (#11942)
1. Fixes crashes on older clients when [png is used as base image
2. Fixes liquid type assertion fails on debug builds
2022-01-12 18:49:14 +01:00
sfan5 4c8c649779
Mainmenu game-related changes (#11887)
fixes:
* Switching between games does not immediately hide creative mode / damage buttons if so specified
* World creation menu has a game selection list even though the menu already provides a gamebar
* Showing gameid in world list is unnecessary
* Choice of mapgen parameters in menu persists between games (and was half-broken)
2022-01-09 21:15:35 +01:00
Lars Mueller b164e16d1b Copy smoothing note to gui_scaling_filter description 2022-01-09 21:13:54 +01:00
SmallJoker 8fab406c28 Formspec: Fix bgcolor and set_focus checks 2022-01-09 18:47:12 +01:00
sfan5 5eb45e1ea0
Restore pass-through of direction keys (#11924)
This moves relevant code into the PlayerControl class and gets rid of separate keyPressed variable.
2022-01-09 18:46:36 +01:00
sfan5 76dbd0d2d0
Fully remove bitmap font support (#11863)
Freetype is now a build requirement.
2022-01-08 14:53:25 +01:00
Jude Melton-Houghton bf22569019
Use a database for mod storage (#11763) 2022-01-07 20:28:49 +02:00
Wuzzy b81948a14c
Fix damage wraparound if very high damage (#11872) 2022-01-06 21:16:35 +01:00
Aritz Erkiaga 85da2e284b Fix incorrect bit positions in paramtype documentation 2022-01-06 21:16:23 +01:00
Vincent Robinson e39b159845 Base formspec coordinate size on padded screensize 2022-01-04 17:47:32 -08:00
SmallJoker d33ab97434 Inventory: Add ServerEnv checks for calls during script init
This fixes 'minetest.get_inventory' calls to players or nodes during the load phase.
2022-01-04 18:39:27 +01:00
Desour 1965628705 Fix vector.from_string returning a table without vector metatable 2022-01-02 22:15:41 -05:00
Wuzzy 84fdd369d4
Cap damage overlay duration to 1 second (#11871) 2022-01-02 22:14:02 -05:00
x2048 835524654e
Fix shadow mapping when PCF is disabled (#11888) 2022-01-02 13:45:55 -08:00
x2048 e030d9cff0
Recalculate normals before adding mesh to the scene 2022-01-02 14:32:13 +01:00
Zughy 8910c7f8ae
Better document sky_color scope (#11892) 2022-01-01 22:46:00 +01:00
ShadowNinja 29d2b2ccd0
Print announce error response (#11878)
Fix HTTPFetch caller and request ID to 64 bits
Check that allocated caller ID is not DISCARD
Print body if serverlist request returns error
Don't print control characters from HTTP responses
Document special HTTPFetch caller IDs
Allow unicode to be printed
2022-01-01 22:44:56 +01:00
Vincent Robinson 544b9d5c72
Add padding[] element to formspecs (#11821) 2021-12-30 12:54:47 -08:00
Vincent Robinson 4a16ab3585
Improve TTF support for pixel-style fonts (#11848) 2021-12-30 12:54:21 -08:00
SmallJoker 14c7fae378
Formspec: Unify argument checks (#11851) 2021-12-29 23:58:26 +01:00
sfan5 0ea8df4d64
Socket-related cleanups
Improve error handling on Windows and reduce the size of the `Address` class
2021-12-29 23:01:26 +01:00
ROllerozxa 05573d6d8d
Remove unused (de)serializeAttributes() methods 2021-12-29 23:00:16 +01:00
Vitaliy 9b650b9efb
Add more neighbors on mesh update (#6765) 2021-12-29 22:59:53 +01:00
SmallJoker 481bb90eac Fix segfault in drawItems() due to missing inventory list
This fixes a nullptr dereference when the specified inventory list is not known.
Happens when HUD elements are sent before the required inventory list is created.
2021-12-29 19:20:49 +01:00
savilli 0fa54531d4
Fix check that denies new clients from a singleplayer session 2021-12-28 14:08:21 +01:00
William L. DeRieux IV cc64a0405a
Automatically use SSE registers for FP operations on i386 (#11853)
use SSE for floating-point operations to avoid issues with improper fp-rounding and
loss of precision when moving fp-data to incompatible or less-precise
registers/storage locations

https://gcc.gnu.org/wiki/FloatingPointMath
https://gcc.gnu.org/wiki/x87note
2021-12-28 14:06:24 +01:00
JosiahWI 7f6306ca96
Restore GCC 5 compatibility (#11778) 2021-12-28 14:05:49 +01:00
sfan5 0c4929f025 Remove wrong function from lua_api.txt 2021-12-19 17:03:16 +01:00
Jude Melton-Houghton 1b664dd870 Use defined evaluation order in profiler
See https://github.com/LuaJIT/LuaJIT/issues/238
2021-12-19 17:03:07 +01:00
sfan5 49f7d2494c Protect font initialization with mutex
fixes #4532
2021-12-18 20:38:33 +01:00
sfan5 b2409b14d0 Refactor trusted mod checking code 2021-12-18 20:37:13 +01:00
sfan5 f405459548 Remove setlocal and setupvalue from `debug` table whitelist
It's likely that these could be used trick mods into revealing the insecure
environment even if they do everything right (which is already hard enough).
2021-12-18 20:37:13 +01:00
sfan5 8c99f2232b Don't let HTTP API pass through untrusted function
This has been a problem since the first day, oops.
2021-12-18 20:37:13 +01:00
sfan5 8472141b79
Restructure devtest's unittests and run them in CI (#11859) 2021-12-18 20:36:43 +01:00
sfan5 1c5ece8334 Fix eat sound not playing if eating last of stack 2021-12-15 15:36:19 +01:00
sfan5 378175497a
Fix some issues with buildbot scripts (#11860) 2021-12-15 14:36:27 +01:00
ROllerozxa fcf86ded8f
Disable inventory if player's inventory formspec is blank (#11827) 2021-12-13 17:43:29 +01:00
sfan5 84efe279bb Fix URL escaping in content store 2021-12-13 17:33:35 +01:00
Wuzzy f71091bf52 Remove creative/damage info in Esc/Pause menu 2021-12-13 17:33:21 +01:00
Wuzzy 76aa6103e3 Update German locale translation 2021-12-10 12:24:53 +01:00
Wuzzy 1ab3eadd87 Update builtin locale 2021-12-10 12:24:53 +01:00
Francisco a8c58d5cbb
Add pauloue's ItemStack example to docs (#9853) 2021-12-10 12:24:42 +01:00
sfan5 d9d219356a Fix get_bone_position() on unset bones modifying their position
closes #11840
2021-12-06 00:06:49 +01:00
sfan5 ff934d538c
Fix various code & correctness issues (#11815) 2021-12-05 14:40:30 +01:00
Richard Liu 7a043b3ebb
Fix wireshark packet dissector wrong coordinates (#11826) 2021-12-05 14:34:40 +01:00
Wuzzy 80c3c7e642
Improve error message if using "/help --" (#11796) 2021-12-01 20:22:46 +01:00
SmallJoker 57a59ae92d
Network: Delete copy constructor and use std::move instead (#11642)
This is a follow-up change which disables class copies where possible to avoid unnecessary memory movements.
2021-12-01 20:22:33 +01:00
Elias Fleckenstein d404517d2b
Make LuaVoxelManipulator available to CSM API 2021-11-29 11:34:12 +01:00
updatepo.sh 1dc1305ada Update translation files 2021-11-27 19:42:26 +01:00
updatepo.sh a157256706 Update minetest.conf.example and dummy cpp file 2021-11-27 19:41:45 +01:00
ROllerozxa 3ac102c93b Translated using Weblate (Swedish)
Currently translated at 46.0% (643 of 1396 strings)
2021-11-27 19:33:53 +01:00
Ondřej Pfrogner 3332592905 Translated using Weblate (Czech)
Currently translated at 62.9% (879 of 1396 strings)
2021-11-27 19:33:53 +01:00
Johann Lau 42b8167f3d Added translation using Weblate (Yue) 2021-11-27 19:33:53 +01:00
Molly fc0897682d Translated using Weblate (Dutch)
Currently translated at 97.0% (1355 of 1396 strings)
2021-11-27 19:33:53 +01:00
Vancha March 8d99cddecc Translated using Weblate (Dutch)
Currently translated at 95.3% (1331 of 1396 strings)
2021-11-27 19:33:53 +01:00
Joaquín Villalba 6f9d803d67 Translated using Weblate (Spanish)
Currently translated at 81.8% (1142 of 1396 strings)
2021-11-27 19:33:53 +01:00
Manuel González c24b02852b Translated using Weblate (Spanish)
Currently translated at 81.8% (1142 of 1396 strings)
2021-11-27 19:33:53 +01:00
109247019824 88731631ab Translated using Weblate (Bulgarian)
Currently translated at 12.6% (177 of 1396 strings)
2021-11-27 19:33:53 +01:00
phlostically 714d4e4a81 Translated using Weblate (Esperanto)
Currently translated at 97.2% (1357 of 1396 strings)
2021-11-27 19:33:53 +01:00
Markus Mikkonen 1935783cc6 Translated using Weblate (Finnish)
Currently translated at 20.9% (292 of 1396 strings)
2021-11-27 19:33:53 +01:00
Ronoaldo Pereira 9f5d35e2aa Translated using Weblate (Portuguese (Brazil))
Currently translated at 99.7% (1392 of 1396 strings)
2021-11-27 19:33:53 +01:00
Jiri Grönroos 6569056bfc Translated using Weblate (Finnish)
Currently translated at 20.9% (292 of 1396 strings)
2021-11-27 19:33:53 +01:00
Heitor 62c3c90120 Translated using Weblate (Portuguese (Brazil))
Currently translated at 97.0% (1355 of 1396 strings)
2021-11-27 19:33:53 +01:00
Tirifto 7d2c99e2c2 Translated using Weblate (Esperanto)
Currently translated at 95.9% (1340 of 1396 strings)
2021-11-27 19:33:53 +01:00
A M dc73d441b5 Translated using Weblate (Polish)
Currently translated at 71.4% (998 of 1396 strings)
2021-11-27 19:33:53 +01:00
GunChleoc 4866e06e62 Translated using Weblate (Gaelic)
Currently translated at 17.0% (238 of 1396 strings)
2021-11-27 19:33:53 +01:00
Zhaolin Lau cd3a8f96c6 Translated using Weblate (Chinese (Simplified))
Currently translated at 95.3% (1331 of 1396 strings)
2021-11-27 19:33:53 +01:00
Thiago Carmona Monteiro 0eb829f5de Translated using Weblate (Portuguese (Brazil))
Currently translated at 94.4% (1319 of 1396 strings)
2021-11-27 19:33:53 +01:00
Marian c062daccc9 Translated using Weblate (Slovak)
Currently translated at 95.2% (1329 of 1396 strings)
2021-11-27 19:33:53 +01:00
phlostically f57b8f3e8a Translated using Weblate (Esperanto)
Currently translated at 95.2% (1329 of 1396 strings)
2021-11-27 19:33:53 +01:00
Allan Nordhøy efc99a8d42 Translated using Weblate (Norwegian Bokmål)
Currently translated at 56.0% (783 of 1396 strings)
2021-11-27 19:33:53 +01:00
abidin toumi ecd4fbc0de Translated using Weblate (Arabic)
Currently translated at 27.1% (379 of 1396 strings)
2021-11-27 19:33:53 +01:00
Oğuz Ersen 3590261c78 Translated using Weblate (Turkish)
Currently translated at 100.0% (1396 of 1396 strings)
2021-11-27 19:33:53 +01:00
Emily Ellis f8dba7e5cf Translated using Weblate (Chinese (Simplified))
Currently translated at 94.4% (1319 of 1396 strings)
2021-11-27 19:33:53 +01:00
David Leal dd23991a19 Translated using Weblate (Spanish)
Currently translated at 81.2% (1134 of 1396 strings)
2021-11-27 19:33:53 +01:00
Riceball LEE 6328b2274a Translated using Weblate (Chinese (Simplified))
Currently translated at 92.5% (1292 of 1396 strings)
2021-11-27 19:33:53 +01:00
Yangjun Wang 2e0780b437 Translated using Weblate (Chinese (Simplified))
Currently translated at 92.5% (1292 of 1396 strings)
2021-11-27 19:33:53 +01:00
Чтабс dfb1e62bc3 Translated using Weblate (Russian)
Currently translated at 100.0% (1396 of 1396 strings)
2021-11-27 19:33:53 +01:00
Stefan Vukanovic c264e47ee7 Translated using Weblate (Serbian (cyrillic))
Currently translated at 30.4% (425 of 1396 strings)
2021-11-27 19:33:53 +01:00
BreadW 19d5a5066c Translated using Weblate (Japanese)
Currently translated at 99.4% (1389 of 1396 strings)
2021-11-27 19:33:53 +01:00
Lin Happy 666 82f8e24d83 Translated using Weblate (Chinese (Simplified))
Currently translated at 92.3% (1289 of 1396 strings)
2021-11-27 19:33:53 +01:00
Liet Kynes 756261bafe Translated using Weblate (Norwegian Bokmål)
Currently translated at 56.0% (783 of 1396 strings)
2021-11-27 19:33:53 +01:00
Petter Reinholdtsen a8745948c4 Translated using Weblate (Norwegian Bokmål)
Currently translated at 55.4% (774 of 1396 strings)
2021-11-27 19:33:53 +01:00
Liet Kynes 0ce549f49e Translated using Weblate (Norwegian Bokmål)
Currently translated at 55.4% (774 of 1396 strings)
2021-11-27 19:33:52 +01:00
Er2 7445a72f76 Translated using Weblate (Russian)
Currently translated at 100.0% (1396 of 1396 strings)
2021-11-27 19:33:52 +01:00
Ács Zoltán 5cb9a36916 Translated using Weblate (Hungarian)
Currently translated at 81.9% (1144 of 1396 strings)
2021-11-27 19:33:52 +01:00
Mateusz Mendel 3dbf52a871 Translated using Weblate (Polish)
Currently translated at 70.3% (982 of 1396 strings)
2021-11-27 19:33:52 +01:00
ResuUman 9ca08800e1 Translated using Weblate (Polish)
Currently translated at 70.3% (982 of 1396 strings)
2021-11-27 19:33:52 +01:00
Mateusz Mendel 1556e7eb09 Translated using Weblate (Polish)
Currently translated at 70.3% (982 of 1396 strings)
2021-11-27 19:33:52 +01:00
ResuUman f5ab059c0f Translated using Weblate (Polish)
Currently translated at 70.3% (982 of 1396 strings)
2021-11-27 19:33:52 +01:00
Mateusz Mendel 8ac17b877a Translated using Weblate (Polish)
Currently translated at 68.7% (960 of 1396 strings)
2021-11-27 19:33:52 +01:00
ResuUman 9da60be08e Translated using Weblate (Polish)
Currently translated at 68.7% (960 of 1396 strings)
2021-11-27 19:33:52 +01:00
Mateusz Mendel 0fc3684613 Translated using Weblate (Polish)
Currently translated at 68.7% (960 of 1396 strings)
2021-11-27 19:33:52 +01:00
ResuUman c0b977bf32 Translated using Weblate (Polish)
Currently translated at 68.7% (960 of 1396 strings)
2021-11-27 19:33:52 +01:00
Mateusz Mendel d3fab295ad Translated using Weblate (Polish)
Currently translated at 68.7% (960 of 1396 strings)
2021-11-27 19:33:52 +01:00
ResuUman 58170e36ef Translated using Weblate (Polish)
Currently translated at 68.7% (960 of 1396 strings)
2021-11-27 19:33:52 +01:00
Чтабс 60d6be1329 Translated using Weblate (Russian)
Currently translated at 95.4% (1333 of 1396 strings)
2021-11-27 19:33:52 +01:00
Janar Leas 5929c8f5ca Translated using Weblate (Estonian)
Currently translated at 44.1% (616 of 1396 strings)
2021-11-27 19:33:52 +01:00
Wuzzy 28851ca9b2 Translated using Weblate (German)
Currently translated at 100.0% (1396 of 1396 strings)
2021-11-27 19:33:52 +01:00
Nicolae Crefelean 5f79e9552d Translated using Weblate (Romanian)
Currently translated at 47.6% (665 of 1396 strings)
2021-11-27 19:33:52 +01:00
Jordan Irwin 891290a79f Translated using Weblate (Spanish)
Currently translated at 80.6% (1126 of 1396 strings)
2021-11-27 19:33:52 +01:00
Riceball LEE e1fbf4795b Translated using Weblate (Chinese (Simplified))
Currently translated at 91.2% (1274 of 1396 strings)
2021-11-27 19:33:52 +01:00
Yangjun Wang 48bb0bb5bb Translated using Weblate (Chinese (Simplified))
Currently translated at 91.2% (1274 of 1396 strings)
2021-11-27 19:33:52 +01:00
waxtatect b9c1a999ff Translated using Weblate (French)
Currently translated at 94.9% (1325 of 1396 strings)
2021-11-27 19:33:52 +01:00
Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi 70ece73da9
Translated using Weblate (Malay)
Currently translated at 100.0% (1396 of 1396 strings)
2021-11-27 19:31:02 +01:00
rubenwardy 51cfb57b4d
Update to Android target SDK 30 (#11746) 2021-11-27 00:10:13 +00:00
Corey Powell 413be76c63
Implemented disconnect_player (#10492)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2021-11-26 19:19:40 +00:00
ROllerozxa c85aa0030f
Remove unused Direct3D shader error/warning (#11793) 2021-11-26 19:33:24 +01:00
sfan5 87ab97da2a
Fix find_nodes_in_area misbehaving with out-of-map coordinates (#11770)
This ensures that no overflows (side-effects) happen within the find_nodes_in_area function by limiting coordinates like done in the map generation code.
2021-11-26 19:32:41 +01:00
Lejo b9051386ae
Add Lua bitop library (#9847) 2021-11-26 19:31:05 +01:00
HybridDog 7a1464d783
Minimap: gamma-correct average texture colour calculation (#9249)
This calculates the average texture colour while heeding the sRGB colourspace.
2021-11-26 19:30:49 +01:00
Elias Fleckenstein 1ccf88e80a
minetest.dig_node: Remove node 2021-11-24 16:01:04 +01:00
sfan5 206e131854
Add backwards-compatible behaviour if too few CAO textures specified
(#11766)
2021-11-22 17:27:49 +00:00
ExeVirus 52bfbf6ed0
Allow for Game-Specific Menu Music (#11241) 2021-11-22 17:26:46 +00:00
Andrew Kerr e35cfa589a
Add macOS build docs (#11757) 2021-11-19 22:31:15 +00:00
savilli c9070e54bc
Fix local digging animation (#11772) 2021-11-19 22:31:04 +00:00
sfan5 c510037e9a Fix compiler detection in buildbot
it was just half-broken before...
2021-11-10 19:10:32 +01:00
Elijah Duffy cbf658f83d
Lua API: Add `rmdir`, `cpdir` and `mvdir` (#9638)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2021-11-10 19:10:20 +01:00
sfan5 6db914780e Fix typo in buildbot scripts 2021-11-05 11:12:56 +01:00
Riceball LEE 693f98373b
Localize error messages in mainmenu (#11495)
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2021-11-01 12:27:46 +00:00
Wuzzy 6910c8d920
Fix number of tool uses being off by 1..32767 (#11110) 2021-10-31 22:33:33 +00:00
JosiahWI 38ba813c55
Add variable to use existing IrrlichtMt build (#11656)
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
2021-10-31 22:33:11 +00:00
sfan5 0b95da7ad3 Automatically package MinGW runtime in buildbot 2021-10-31 22:32:48 +00:00
sfan5 ea1396f856 Replace uses of which(1) with command -v 2021-10-31 22:32:48 +00:00
sfan5 4114e3047b
Update Android to new dependency repo (#11690) 2021-10-31 22:32:25 +00:00
x2048 cef016d393
Apply shadow only to the naturally lit part of the fragment color (#11722)
Fragment color for nodes is now calculated from:

 * Texture color, highlighted by artificial light if present (light color conveyed via vertex color).
 * Texture color highlighted by natural light (conveyed via vertex color) filtered by shadow.
 * Reflected day/moonlight filtered by shadow (color and intensity), assuming some portion of the light is directly reflected from the materials.
2021-10-31 19:18:30 +01:00
Isabelle COWAN-BERGMAN 532d5b21fd
Add joystick layout for DragonRise GameCube controller (#11467) 2021-10-31 19:17:47 +01:00
rubenwardy 8dfeba02b9 Fix crash on hypertext[] with not enough parts
The length check used < rather than <=, disabling the check when the formspec version
matches the client's FORMSPEC_API_VERSION.

Additionally, it was possible to have fewer parts than required if the formspec version
was greater than the client's FORMSPEC_API_VERSION.
2021-10-25 21:39:40 +01:00
sfan5 4ee643f472 Fixes around emerge handling 2021-10-25 20:31:52 +02:00
Jude Melton-Houghton 1e26e45530
Limit stepheight smoothing to the stepheight and stop smoothing during jumps (#11705) 2021-10-25 20:31:14 +02:00
sfan5 660e63dbae
Fix item duplication if player dies during interact callback (alternative) (#11662) 2021-10-25 20:30:27 +02:00
Wuzzy d4b89eb106 Fix no_texture.png activation w/ simple leaves 2021-10-22 11:01:42 +02:00
sfan5 a78124831f Fix incorrect error message in core.encode_png 2021-10-22 10:55:18 +02:00
Lars Müller 0d345dc1bd
Fix view bobbing not resetting when resting
partially fixes #11694, also fixes #11692
2021-10-20 21:51:21 +02:00
Wuzzy 86b44ecd82
Add no_texture.png as fallback for unspecified textures 2021-10-20 21:50:16 +02:00
LoneWolfHT c82ec8b210
Fix compiling on Windows with Visual Studio 2021-10-15 18:16:09 +02:00
rubenwardy 6901c5fae5
Use scoped app storage on Android (#11466)
From November 2021, the Play Store will no longer be accepting
apps which use the deprecated getExternalStorageDirectory() API.

Therefore, this commit replaces uses of deprecated API with the new
scoped API (`getExternalFilesDir()` and `getExternalCacheDir()`).
It also provides a temporary migration to move user data from the
shared external directory to new storage.

Fixes #2097,  #11417 and #11118
2021-10-15 18:14:48 +02:00
Wuzzy fe7195badb Make /status message easier to read 2021-10-15 18:13:57 +02:00
hecks 02292e03e4
Add embedded PNG texture modifier (#11498) 2021-10-13 17:51:37 +02:00
sfan5 fe5cb2cdfb Remove broken timeout behaviour
Code that relies on `resend_count` was added in 7ea4a03 and 247a1eb, but never worked.
This was fixed in #11607 which caused the problem to surface.
Hence undo the first commit entirely and change the logic of the second.
2021-10-12 20:13:09 +02:00
savilli 6ea558f8ac
Fix player HP desync between client and server 2021-10-12 20:12:49 +02:00
SmallJoker ecc6f4ba25
Remove a few unused functions reported by callcatcher (#11658) 2021-10-12 20:12:20 +02:00
sfan5 6de8d77e17 Move instead of copy during content install if possible 2021-10-07 00:20:01 +02:00
sfan5 2b5075f0e2 Move archive extraction in content store to async job 2021-10-07 00:20:01 +02:00
sfan5 2d5b7b5fb4 Make fs::extractZipFile thread-safe 2021-10-07 00:20:01 +02:00
emixa-d 9fab5d594c
Add "MINETEST_MOD_PATH" environment variable (#11515)
This adds an environment variable MINETEST_MOD_PATH.
When it exists, Minetest will look there for mods in addition to ~/.minetest/mods/.
2021-10-07 00:19:41 +02:00
HybridDog 53e126ac49
List only jpg and png as screenshot format options (#11675)
The other formats are no longer supported in Minetest Irrlicht.
2021-10-05 21:54:13 +02:00
lhofhansl b4b9bee5f2
Reduce shadow jitter (#11668) 2021-10-05 21:54:01 +02:00
Wuzzy bc71622d21
Fix crash when calling remove/kick/ban_player on start (#11672) 2021-10-05 21:53:47 +02:00
Jude Melton-Houghton 5aa95fef10
Make MetaDataRef:get return nil instead of nothing (#11666) 2021-10-05 15:38:33 +03:00
Wuzzy 4fca601e0c
Add get_server_max_lag() (#11671) 2021-10-05 15:35:55 +03:00
Pedro Gimeno d7e7ade0f6 Add an option `-t` to force text output in /help
This also improves detection of whether formspecs are available.
2021-10-01 16:22:05 +02:00
x2048 982e03f60d
Improvements to colored shadows (#11516) 2021-10-01 16:21:53 +02:00
Wuzzy 21113ad410
Split liquid_viscosity to liquid_viscosity and move_resistance (#10810) 2021-10-01 16:21:24 +02:00
x2048 f5040707fe
Order drawlist by distance to the camera when rendering (#11651) 2021-09-27 17:46:08 +02:00
SmallJoker d51d0f3a5a
Various code improvements
* Camera: Fix division by 0 after view bobbing
* Remove ignored constness
* Connection: Improve window size range limits
2021-09-27 17:45:44 +02:00
Wuzzy 918fbe3ec1
Update builtin locale files (#11650) 2021-09-26 18:04:39 +02:00
nia 2dc73d239a
Use CMake's GNUInstallDirs for install directories on Unix (#11636)
This makes the installation process honor system-specific
directories (e.g. ${PREFIX}/man instead of ${PREFIX}/share/man on
BSD).
2021-09-26 18:04:30 +02:00
Wuzzy bc7d05581b
Fix several typos in settingtypes.txt (#11623) 2021-09-26 18:04:19 +02:00
TheBrokenRail 3dcf9e963e
Touch UI support for desktop builds (#10729) 2021-09-26 18:04:09 +02:00
sfan5 9f85862b7c Fix "Could not create ITexture, texture needs to have a non-empty name" warning 2021-09-22 18:43:40 +02:00
Elias Fleckenstein c8900e169a Merge branch 'master' of https://github.com/minetest/minetest 2021-09-19 20:56:13 +02:00
nia 2628316842
Fix src/util/string.cpp on NetBSD
- iconv() prototype changed from traditional Unix defintion
  to POSIX definition in 9.99.x.
- wchar_t is not a valid character set for iconv. Share code
  with Android for using UTF-32.
2021-09-19 20:23:52 +02:00
DS e79d6154fc
Fix client-side performance of chat UI (#11612) 2021-09-19 20:23:35 +02:00
Lars Müller 40ea4ddef1
Fix HUD multiline text alignment (#10795) 2021-09-19 20:23:22 +02:00
Elias Fleckenstein 950d2c9b3e Add ClientObjectRef:remove and return true in on_object_add callback to remove newly added object 2021-09-19 18:55:25 +02:00
sfan5 e0529da5c8 Fix trivial typos 2021-09-19 13:54:20 +02:00
sfan5 16a62426d6 Add feature table entry for new dynamic media API 2021-09-19 13:54:06 +02:00
sfan5 ad076ede85 Add preprocessor check for weird (incorrect) build configurations 2021-09-19 13:53:44 +02:00
sfan5 fd8a8501bc
Shave off buffer copies in networking code (#11607) 2021-09-17 18:14:25 +02:00
sfan5 ea250ff5c5 Fix GLES2 discard behaviour (texture transparency) 2021-09-17 18:13:50 +02:00
HybridDog d1e0f73b77 Hide Wself-assign-overloaded and Wself-move unittest compilation warnings
The warnings occured with the clang compiler
2021-09-17 18:13:04 +02:00
ROllerozxa 6fedee16f0
Readd TGA to the list of valid texture formats. (#11598) 2021-09-15 11:12:24 +01:00
Lars Müller 719a12ecac
Chop game background in mainmenu (#10796) 2021-09-14 20:46:02 +02:00
sfan5 4feb799b7e Add Windows-specific CreateTempFile() implementation
Once again MSVC is the only compiler not supporting basic POSIX functionality.
2021-09-14 20:45:41 +02:00
sfan5 b480a3e9fd Fix broken handling of NodemetaChanged packets
fixes #11610
2021-09-12 14:42:01 +02:00
sfan5 75bf9b75ca
Make sure relevant std::stringstreams are set to binary 2021-09-11 21:06:57 +02:00
sfan5 766e885a1b
Clean up/improve some scriptapi error handling code 2021-09-10 23:16:46 +02:00
Jude Melton-Houghton 7423c4c11e
Send to clients node metadata that changed to become empty (#11597) 2021-09-10 23:16:34 +02:00
DS 2cefe51d3b
Split vector.new into 3 constructors 2021-09-10 23:16:16 +02:00
sfan5 bbfae0cc67
Dynamic_Add_Media v2 (#11550) 2021-09-09 16:51:35 +02:00
Buckaroo Banzai bcb6565483
Add missing zstd-libs to final Docker image
Also add `minetestserver --version` command to verify docker build in CI
2021-09-07 15:29:57 +02:00
NeroBurner 7f3401412e
Fix movement in random_input mode (#11592) 2021-09-05 19:58:50 +02:00
20kdc a3e32d81c5
Add hint to error message on how to build with in-tree Irrlicht 2021-09-05 19:57:40 +02:00
Wuzzy ff9945dc6e
Fix falling mesh nodes being half size (#11389) 2021-09-01 22:20:57 +02:00
sfan5 e912008cb3 Update README for zstd changes 2021-09-01 22:20:38 +02:00
sfan5 31d2b9edcd Don't look for zlib and zstd manually on Windows 2021-09-01 22:20:38 +02:00
sfan5 e5edda28ce Drop Ubuntu 16.04 from gitlab-ci, add 20.04 instead 2021-09-01 22:20:38 +02:00
sfan5 70dafcf5da Check for required libzstd APIs in cmake
It's very unlikely that anyone uses a zstd version this old, but if they do fail early.
2021-09-01 22:20:38 +02:00
lhofhansl d1624a5521
Switch MapBlock compression to zstd (#10788)
* Add zstd support.
* Rearrange serialization order
* Compress entire mapblock

Co-authored-by: sfan5 <sfan5@live.de>
2021-08-31 17:32:31 -07:00
sfan5 beac4a2c98 CI: Bump IrrlichtMt to 1.9.0mt3 2021-08-31 23:57:39 +02:00
Elias Fleckenstein fb4815c660
Merge pull request #35 from arydevy/patch-1
Changed README.md to fit the dragonfire client
2021-08-30 17:59:59 +02:00
Elias Fleckenstein f122888148
Merge pull request #42 from Minetest-j45/master
Add AirJump
2021-08-30 17:58:18 +02:00
Minetest-j45 f3082146c3 remove irrlicht from lid dir (accident) 2021-08-30 16:46:48 +01:00
Minetest-j45 a3925db226 add airjump and remove unused headers 2021-08-30 16:45:27 +01:00
Minetest-j45 7824a4956b
Merge pull request #1 from EliasFleckenstein03/master
update
2021-08-30 15:22:40 +01:00
pecksin 040aed37ab Remove closing paren as weblink delimiter 2021-08-29 19:30:33 +02:00
sfan5 6a1424f2b1
Async-related script cleanups 2021-08-28 12:15:12 +02:00
fn ⌃ ⌥ 0f8a6d78a7
CI: Add macOS workflow (#11454) 2021-08-28 12:14:55 +02:00
savilli 3f1adb49ae
Remove redundant on_dieplayer calls 2021-08-28 12:14:16 +02:00
NeroBurner 1d69a23ba4
Joystick sensitivity for player movement (#11262)
This commit deprecates the forward, backward, left, and right binary
inputs currently used for player movement in the PlayerControl struct.
In their place, it adds the movement_speed and movement_direction
values, which represents the player movement is a polar coordinate
system.

movement_speed is a scalar from 0.0 to 1.0. movement_direction is
an angle from 0 to +-Pi:

	       FWD
	        0
	        _
	 LFT   / \   RGT
	-Pi/2 |   | +Pi/2
	       \_/
	       +-Pi
	       BCK

Boolean movement bits will still be set for server telegrams and
Lua script invocations to provide full backward compatibility.
When generating these values from an analog input, a direction is
considered active when it is 22.5 degrees away from either
orthogonal axis.

Co-authored-by: Markus Koch <markus@notsyncing.net>
Co-authored-by: sfan5 <sfan5@live.de>
2021-08-27 20:24:24 +02:00
Treer 149d8fc8d6
Add group-based tool filtering for node drops (#10141)
Supports both AND and OR requirements, e.g.

 * "a tool that's in any of these groups"
 * "a tool that's in all of these groups"
2021-08-27 20:23:20 +02:00
Lean Rada d36dca3aba
Optimize vector length calculations (#11549) 2021-08-27 20:22:35 +02:00
Loïc Blot a7188bd6f5
Add debian 11 to Gitlab-CI (#11571)
* feat(gitlab-ci): add debian 11 support
2021-08-27 11:19:15 +02:00
Loïc Blot ff3aa18436
fix: update to alpine 3.14 (#11570) 2021-08-24 14:52:05 +02:00
JosiahWI ef84c3b8b9
Set policies through CMake 3.9 to allow enabling IPO (#11560) 2021-08-23 22:13:47 +02:00
Wuzzy 63e8224636
Fix 6th line of infotext being cut off in half (#11456) 2021-08-23 22:13:17 +02:00
SmallJoker eea488ed75
Inventory: Fix rare out-of-bounds access
Co-authored-by: Thomas--S <info@thomas-stangl.de>
2021-08-23 14:10:17 +02:00
DS dad87a360b
Use utf-8 for the Irrlicht clipboard (#11538) 2021-08-23 14:09:50 +02:00
sfan5 fad835cf64
Fix server-only builds on older CMake versions (#11566)
closes #11564
2021-08-23 13:33:25 +02:00
SmallJoker 0c1e9603db
HUD: Reject and warn on invalid stat types (#11548)
This comes into play on older servers which do not know the "stat" type.
Warnings are only logged once to avoid spam within globalstep callbacks
2021-08-21 20:04:04 +02:00
sfan5 a72d13064f Allow lib/irrlichtmt to work for server builds (headers-only) 2021-08-21 13:53:59 +02:00
Wuzzy 6fd8aede48
Show status message when changing block bounds (#11556) 2021-08-21 13:53:49 +02:00
sfan5 e7b05beb7d
Validate staticdata and object property length limits (#11511)
Some games provide users with enough freedom to create items
with metadata longer than 64KB, preventing this from causing
issues is on them but we'll still do the minimum not to abort
the server if this happens.
2021-08-19 20:14:22 +02:00
Wuzzy 1320c51d8e
Fix scaled world-aligned textures being aligned inconsistently for non-normal drawtypes 2021-08-19 20:14:04 +02:00
rubenwardy 24b66dede0
Add fwgettext util function 2021-08-19 20:13:25 +02:00
SmallJoker 3b842a7e02 Fix inconsistent integer comparison warnings 2021-08-17 20:00:47 +02:00
Wuzzy 2eec997e97
Clarify the meaning of "rightclick"/"use" in documentation (#11471) 2021-08-16 17:57:07 +02:00
Lean Rada 328d949225
Start sprite animation at the beginning (#11509)
When setting a sprite animation, do not keep the last animation's frame number. Setting a new animation should start the animation at the start of the new animation.
2021-08-16 17:56:38 +02:00
sfan5 4419e311a9 Cap iterations of imageCleanTransparent sanely
fixes #11513 performance regression with 256x textures
2021-08-16 17:56:11 +02:00
Treer 963fbd1572
Fix access violation in create_schematic() (#11534)
fixes #11533

Schematics saved from y locations greater than 0 would cause an access violation if layer probabilities were specified
2021-08-16 17:55:35 +02:00
SmallJoker b3b075ea02 Fix segfault caused by shadow map on exit 2021-08-12 20:08:39 +02:00
Hugues Ross 47c146120a
Add disable_settings to game.conf to get rid of "Enable Damage"/"Creative Mode"/"Host Server" checkboxes (#11524)
This adds support for disable_settings to game.conf. In this you can specify a list of settings that should not be visible in the "local game" (or however it is called nowadays) tab. Enable Damage, Creative Mode and Host Server are supported.

Co-authored-by: Wuzzy <Wuzzy2@mail.ru>
Co-authored-by: Aaron Suen <warr1024@gmail.com>
Co-authored-by: rubenwardy <rw@rubenwardy.com>
2021-08-12 20:08:12 +02:00
x2048 442e48b84f
Move updating shadows outside of RenderingCore::drawAll. (#11491)
Fixes indirect rendering modes such as some 3D modes mentioned in #11437 and undersampled rendering.
Does not fully fix anaglyph 3d mode.
2021-08-12 20:07:09 +02:00
DS 0709946c75
Fix a segfault caused by wrong textdomain lines in translation files (#11530)
* The problem were lines like these:
  "# textdomain:"
* str_split does not add an empty last part if there is a delimiter
  at the end, but this was probably assumed here.
2021-08-12 20:06:18 +02:00
hecks eefa39e47b
Remove statement semicolons from a lua script 2021-08-09 21:03:18 +02:00
DS 1ab29f1716
Fix GUIEditBoxWithScrollBar using a smaller steps than intlGUIEditBox (#11519) 2021-08-08 18:59:45 +02:00
Pevernow c6eddb0bae
Gettext support on Android (#11435)
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: =?UTF-8?q?Olivier=20Samyn=20=F0=9F=8E=BB?= <code@oleastre.be>
2021-08-08 18:59:07 +02:00
SmallJoker 4a3728d828 OpenAL: Free buffers on quit 2021-08-03 20:29:55 +02:00
rubenwardy bee50ca7fa
ContentDB: Add support for package aliases / renaming (#11484) 2021-08-02 20:05:10 +01:00
SmallJoker 32cb9d0828
Mods: Combine mod loading checks and deprection logging (#11503)
This limits the logged deprecation messages to the mods that are loaded
Unifies the mod naming convention check for CSM & SSM
2021-07-31 19:54:52 +02:00
Wuzzy e7cd4cfa25
Fix /emergeblocks crashing in debug builds (#11461)
The reason for the bug was an u16 overflow, thus failing the assert. This only happened in Debug build but not in Release builds.
2021-07-31 19:54:40 +02:00
sfan5 0257e7150f Update IrrlichtMt-related stuff in README 2021-07-31 13:26:17 +02:00
hecks 1e2b638881 Remove unsupported formats from the media enumerator 2021-07-29 22:42:47 +02:00
hecktest 28c98f9fa5 Remove unsupported extensions from list in tile.cpp 2021-07-29 21:47:08 +02:00
hecks 80d12dbedb
Add a simple PNG image encoder with Lua API (#11485)
* Add a simple PNG image encoder with Lua API
Add ColorSpec to RGBA converter
Make a safety wrapper for the encoder
Create devtest examples

Co-authored-by: hecktest <>
Co-authored-by: sfan5 <sfan5@live.de>
2021-07-29 05:10:10 +02:00
sfan5 2866918f32 buildbot: Readd missing IrrlichtMt DLLs 2021-07-27 20:37:51 +02:00
sfan5 6e8aebf432
Add bold, italic and monospace font styling for HUD text elements (#11478)
Co-authored-by: Elias Fleckenstein <eliasfleckenstein@web.de>
2021-07-27 19:11:46 +02:00
JosiahWI cf136914cf
Take advantage of IrrlichtMt CMake target (#11287)
With the CMake changes to IrrlichtMt, it's now possible to use a target for IrrlichtMt.
Besides greatly improving the ease of setting up IrrlichtMt for users building the client, it removes the need for Minetest's CMake to include transitive dependencies such as image libraries, cleaning it up a tiny bit. The PR works by finding the IrrlichtMt package and linking to the target it provides. If the package isn't found and it isn't building the client, it will still fall back to using just the headers of old Irrlicht or IrrlichtMt.
2021-07-27 19:11:27 +02:00
Wuzzy 216728cc5e
Improve documentation of tools (#11128) 2021-07-27 19:09:14 +02:00
rubenwardy 9c145ba0d8
ContentDB: Add reason to downloads (#10876) 2021-07-27 19:08:49 +02:00
x2048 bf3acbf388
Distribute shadow map update over multiple frames to reduce stutter (#11422)
Reduces stutter and freezes when playing.

 * Maintains double SM and SM Color textures
 * Light frustum update triggers incremental generation of shadow map into secondary 'future' textures.
 * Every incremental update renders a portion of the shadow draw list (split equally).
 * After defined number of frames (currently, 4), 'future' and 'current' textures are swapped, and DirectionalLight 'commits' the new frustum to use when rendering shadows on screen.

Co-authored-by: sfan5 <sfan5@live.de>
2021-07-25 12:36:23 +02:00
x2048 ff2d2a6e93
Add smooth light-shadow transition at noon (#11430)
Node faces with normals pointing East/West (+X/-X) will transition between light
and shadow at noon. This code makes the transition smooth.
2021-07-25 12:35:12 +02:00
random-geek 5d27cc5096
Document glasslikeliquidlevel merge bits (#11479) 2021-07-25 12:34:53 +02:00
hecks a049e8267f
Remove unused ITextSceneNode header (#11476)
Co-authored-by: hecktest <>
2021-07-22 00:55:20 +02:00
hecks 850293bae6
Remove unused header includes 2021-07-21 22:07:13 +02:00
sfan5 6caed7073c Fix no locales being generated when APPLY_LOCALE_BLACKLIST=0
Also enable `ky` which appears to work fine.
2021-07-20 17:58:47 +02:00
SmallJoker 40bee27e56 CSM: Do not index files within hidden directories
CSM would previously scan for files within .git or .svn directories, and also special files such as .gitignore
2021-07-17 16:44:06 +02:00
Wuzzy f4d8cc0f0b
Add wallmounted support for plantlike and plantlike_rooted nodes (#11379) 2021-07-15 21:19:59 +02:00
Hugues Ross 68143ed8ec
Fix documented default colors for set_sky 2021-07-14 17:14:45 +02:00
Wuzzy 6cdb150c8b
Remove hardcoded "You died." message in chat (#11443) 2021-07-12 20:32:27 +02:00
Wuzzy b7b5aad027
Fix revoke debug privs not reliably turn off stuff (#11409) 2021-07-12 20:32:18 +02:00
sfan5 5c89a0e12a Fix build on Ubuntu 16.04 and macOS
Apparently the C++ standard library is supposed to provide
specializations of std::hash for enums (even in C++11)
but those don't always work for whatever reason.
2021-07-12 12:03:39 +02:00
x2048 effb5356ca
Avoid draw list and shadow map update in the same frame to reduce dtime jitter (#11393)
* Separate draw list and shadows update to reduce jitter

* Avoid draw list update and shadow update in the same frame

* Force-update shadows when camera offset changes
2021-07-11 10:57:29 -07:00
x2048 f5706d444b
Improve shadow rendering with non-default camera FOV (#11385)
* Adjust minimum filter radius for perspective

* Expand shadow frustum when camera FOV changes, reuse FOV distance adjustment from numeric.cpp

* Read shadow_soft_radius setting as float

* Use adaptive filter radius to accomodate for PSM distortion

* Adjust filter radius for texture resolution
2021-07-11 08:15:19 -07:00
hecks 1d25d1f7ad
Refactor video driver name retrieval (#11413)
Co-authored-by: hecktest <>
2021-07-11 09:50:34 +02:00
hecktest 29522017a3 Fix typo in lua_api.txt 2021-07-10 16:37:18 -07:00
SmallJoker b93bbfde2c Script API: Fix segfault in remove_detached_inventory
when minetest.remove_detached_inventory is called on script init, the environment is yet not set up,
hence m_env is still nullptr until all scripts are loaded
2021-07-10 14:34:36 +02:00
Lean Rada 42fbc757b1
Use `persistence` instead of `persist` in NoiseParams examples 2021-07-10 14:19:33 +02:00
Warr1024 52128ae11e
Add API for mods to hook liquid transformation events (#11405)
Add API for mods to hook liquid transformation events

Without this API, there is no reliable way for mods to be
notified when liquid transform modifies nodes and mods are
forced to poll for changes.  This allows mods to detect
changes to flowing liquid nodes and liquid renewal using
event-driven logic.
2021-07-09 09:08:40 -04:00
hecks e9bc59e376
Add .editorconfig (#11412)
* Add an .editorconfig to the repo root folder, providing code style hints for some text editors and making the code render properly in github.

Co-authored-by: hecktest <>
2021-07-03 23:05:15 +02:00
SmallJoker 062fd2190e
Auth API: Error when accessed prior to ServerEnv init (#11398) 2021-06-30 20:42:26 +02:00
hecks 827a7852e2
Remove unsupported video drivers (#11395)
This completely removes any mention of the software and D3D drivers from MT, preventing the user from accidentally attempting to use them. Users who need a software renderer should be asked to install Mesa drivers which offer superior fidelity and performance over the 'burningsvideo' driver.
2021-06-30 20:42:15 +02:00
AFCMS 8cc04e0cb4
Run on_grant and on_revoke callbacks after privs change (#11387)
Callbacks were run too early. This changes the order to call after the privs are updated.
2021-06-30 20:40:45 +02:00
SmallJoker f2fd443262
Inventory: Make addList() consistent (#11382)
Fixes list clearing for inv:set_list() using same size, since 2db6b07.
addList() now clears the list in all cases. Use setSize() to resize without clearing.
2021-06-30 20:39:38 +02:00
sfan5 72927b73ca Fix spurious shadow enablement in mainmenu
fixes #11394
2021-06-30 17:10:28 +02:00
NeroBurner fa4dee0e62
Use user provided lib/irrlichtmt if available (#11276)
Use user provided lib/irrlichtmt if available

Make it possible for a user to provide the IrrlichtMt dependency as
subdirectory at `lib/irrlichtmt`.
The subdirectory is added with the `EXCLUDE_FROM_ALL` flag to prevent
`libirrlichtmt.a` or other header files to be installed.

This enables the user to do the following to satisfy the IrrlichtMt
dependency:

git clone --depth 1 https://github.com/minetest/irrlicht.git lib/irrlichtmt
cmake . -DRUN_IN_PLACE=TRUE
2021-06-29 10:57:19 +03:00
Wuzzy 63fc728a84
Require 'basic_debug' priv to view gameplay-relevant debug info, require 'debug' priv to view wireframe (#9315)
Fixes #7245.
2021-06-24 21:21:19 +03:00
Wuzzy 51bf4a6e26
Perform some quality assurance for translation strings (#11375) 2021-06-23 17:35:50 +01:00
sfan5 c60a146e22
Rework Settings to support arbitrary hierarchies (#11352) 2021-06-23 15:22:31 +02:00
Juozas cec0dfcbbd
Buildbot: Use posix on Win64 builds if available (#11355)
Use posix mingw-w64 toolchain on Win64 builds where applicable, avoids
many build errors when using buildwin64.sh to build 64 bit builds on
Ubuntu based Linux distributions
2021-06-22 19:59:09 +02:00
SmallJoker a8b7c8ff38 Server: Ignore whitespace-only chat messages 2021-06-22 19:47:18 +02:00
Wuzzy b5c09ada79
Document hypertext escaping (#11374) 2021-06-22 13:42:40 +01:00
NeroBurner a7143c2a8c
Move build/android directory to root of project (#11283) 2021-06-21 20:51:42 +01:00
Wuzzy 7fdbf3f231
Update builtin locale (#11371) 2021-06-21 18:55:55 +01:00
William L. DeRieux IV 9d2e7fc983
Strip carriage returns from lines in settingtypes.txt (#11338)
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
2021-06-21 18:55:48 +01:00
Bensuperpc 4b9a51ff0d
Update Dockerfile and improve build speed (#11313)
Use ninja to build image, rename docker build steps: builder and runtime, add argument for docker image version

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-06-21 18:55:38 +01:00
Wuzzy b28523bf38
Fix some typos in builtin (#11370) 2021-06-21 17:30:29 +01:00
SmallJoker 2db6b07de1
Inventory: show error on invalid list names (#11368) 2021-06-20 17:21:50 +02:00
sfence b10091be9b
Add min_y and max_y checks for Active Block Modifiers (ABM) (#11333)
This check can be used by ABM to reduce CPU usage.
2021-06-20 17:21:35 +02:00
pecksin 1805775f3d
Make chat web links clickable (#11092)
If enabled in minetest.conf, provides colored, clickable (middle-mouse or ctrl-left-mouse) weblinks in chat output, to open the OS' default web browser.
2021-06-20 17:20:24 +02:00
rubenwardy e1b297a14b
Add roadmap (#10536) 2021-06-17 04:15:30 +01:00
updatepo.sh 88bda3d914 Update translation files 2021-06-16 18:28:05 +02:00
updatepo.sh cb5dd0dae4 Update minetest.conf.example and dummy translation file 2021-06-16 18:27:45 +02:00
Riceball LEE ce0541fc0e Translated using Weblate (Chinese (Simplified))
Currently translated at 95.1% (1290 of 1356 strings)
2021-06-16 18:23:10 +02:00
David Leal 165986beb0 Translated using Weblate (Spanish)
Currently translated at 81.5% (1106 of 1356 strings)
2021-06-16 18:23:10 +02:00
Tirifto 3474b97921 Translated using Weblate (Esperanto)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Yiu Man Ho 5915941eba Translated using Weblate (Chinese (Traditional))
Currently translated at 75.6% (1026 of 1356 strings)
2021-06-16 18:23:10 +02:00
Allan Nordhøy 8575d68d49 Translated using Weblate (Norwegian Bokmål)
Currently translated at 58.1% (789 of 1356 strings)
2021-06-16 18:23:10 +02:00
telmo bruno silva seabra 42aa81befd Translated using Weblate (Esperanto)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Avyukt More 392408401c Translated using Weblate (Marathi)
Currently translated at 8.6% (117 of 1356 strings)
2021-06-16 18:23:10 +02:00
Avyukt More dd3409c961 Added translation using Weblate (Marathi) 2021-06-16 18:23:10 +02:00
Andrei Stepanov 1a5279e911 Translated using Weblate (Russian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Andrij Mizyk a3b480e300 Translated using Weblate (Ukrainian)
Currently translated at 44.6% (606 of 1356 strings)
2021-06-16 18:23:10 +02:00
Nicolae Crefelean 79a2c6f49d Translated using Weblate (Romanian)
Currently translated at 48.7% (661 of 1356 strings)
2021-06-16 18:23:10 +02:00
THANOS SIOURDAKIS 07e7d71bac Translated using Weblate (Greek)
Currently translated at 12.0% (164 of 1356 strings)
2021-06-16 18:23:10 +02:00
Gian M 873feb2619 Added translation using Weblate (Filipino) 2021-06-16 18:23:10 +02:00
Omer I.S a189ce20b1 Translated using Weblate (Hebrew)
Currently translated at 44.3% (601 of 1356 strings)
2021-06-16 18:23:10 +02:00
phlostically 53e82d0b25 Translated using Weblate (Esperanto)
Currently translated at 98.7% (1339 of 1356 strings)
2021-06-16 18:23:10 +02:00
ferrumcccp dfe9f2c925 Translated using Weblate (Chinese (Simplified))
Currently translated at 94.8% (1286 of 1356 strings)
2021-06-16 18:23:10 +02:00
ludemys fd63faa3f3 Translated using Weblate (Spanish)
Currently translated at 81.4% (1104 of 1356 strings)
2021-06-16 18:23:10 +02:00
David Leal 72ae97d8ef Translated using Weblate (Spanish)
Currently translated at 81.4% (1104 of 1356 strings)
2021-06-16 18:23:10 +02:00
ludemys 3c761f86c2 Translated using Weblate (Spanish)
Currently translated at 81.0% (1099 of 1356 strings)
2021-06-16 18:23:10 +02:00
Kornelijus Tvarijanavičius a09db258ee Translated using Weblate (Lithuanian)
Currently translated at 16.5% (224 of 1356 strings)
2021-06-16 18:23:10 +02:00
waxtatect 875e9d4c6f Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Brian Gaucher d3fb83db6b Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Markus Mikkonen 3cc14d58d4 Translated using Weblate (Finnish)
Currently translated at 3.2% (44 of 1356 strings)
2021-06-16 18:23:10 +02:00
Tviljan 33509b13b7 Translated using Weblate (Finnish)
Currently translated at 3.2% (44 of 1356 strings)
2021-06-16 18:23:10 +02:00
Edward 686dcc7c59 Translated using Weblate (Russian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
ssantos 3a2f9859fe Translated using Weblate (Portuguese)
Currently translated at 93.2% (1264 of 1356 strings)
2021-06-16 18:23:10 +02:00
waxtatect ca254e4e4c Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
David Leal a66b4f69e9 Translated using Weblate (Spanish)
Currently translated at 79.7% (1081 of 1356 strings)
2021-06-16 18:23:10 +02:00
Timur Seber 398815c0c5 Translated using Weblate (Tatar)
Currently translated at 0.4% (6 of 1356 strings)
2021-06-16 18:23:10 +02:00
François Delpierre bc49e3a8d1 Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
waxtatect 45ee5c9f03 Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Timur Seber 36af92443c Added translation using Weblate (Tatar) 2021-06-16 18:23:10 +02:00
BreadW 20dd05b343 Translated using Weblate (Japanese)
Currently translated at 99.8% (1354 of 1356 strings)
2021-06-16 18:23:10 +02:00
GnuPGを使うべきだ 34da979ef6 Translated using Weblate (Japanese)
Currently translated at 99.7% (1353 of 1356 strings)
2021-06-16 18:23:10 +02:00
ItsWidee 5b11a6a800 Translated using Weblate (French)
Currently translated at 98.0% (1330 of 1356 strings)
2021-06-16 18:23:10 +02:00
François Delpierre f8e9ea38da Translated using Weblate (French)
Currently translated at 96.6% (1311 of 1356 strings)
2021-06-16 18:23:10 +02:00
Dainis 6405188f68 Translated using Weblate (Latvian)
Currently translated at 28.6% (388 of 1356 strings)
2021-06-16 18:23:10 +02:00
Konstantin Yeliseyev 4b6402a005 Translated using Weblate (Russian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
ResuUman f922a78d13 Translated using Weblate (Polish)
Currently translated at 72.4% (982 of 1356 strings)
2021-06-16 18:23:10 +02:00
Mateusz Mendel ac46a4e7b3 Translated using Weblate (Polish)
Currently translated at 72.4% (982 of 1356 strings)
2021-06-16 18:23:10 +02:00
gnu-ewm 6393d32332 Translated using Weblate (Polish)
Currently translated at 71.6% (972 of 1356 strings)
2021-06-16 18:23:10 +02:00
Alessandro Mandelli aac0d36a1d Translated using Weblate (Italian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:10 +02:00
Hatlábú Farkas 9c8c7cfa13 Translated using Weblate (Hungarian)
Currently translated at 75.8% (1028 of 1356 strings)
2021-06-16 18:23:10 +02:00
ItsWidee a016189bb0 Translated using Weblate (French)
Currently translated at 96.5% (1309 of 1356 strings)
2021-06-16 18:23:10 +02:00
matiasC 116957e131 Translated using Weblate (Spanish)
Currently translated at 79.5% (1079 of 1356 strings)
2021-06-16 18:23:10 +02:00
Joaquín Villalba e64c299983 Translated using Weblate (Spanish)
Currently translated at 79.5% (1079 of 1356 strings)
2021-06-16 18:23:10 +02:00
AnthonyDe dc6c43db7d Translated using Weblate (Spanish)
Currently translated at 79.5% (1079 of 1356 strings)
2021-06-16 18:23:10 +02:00
Michalis 900996c9f1 Translated using Weblate (Greek)
Currently translated at 8.8% (120 of 1356 strings)
2021-06-16 18:23:10 +02:00
Yangjun Wang 2e21b4a1b4 Translated using Weblate (Chinese (Simplified))
Currently translated at 94.7% (1285 of 1356 strings)
2021-06-16 18:23:10 +02:00
Liu Tao 9352c26404 Translated using Weblate (Chinese (Simplified))
Currently translated at 94.7% (1285 of 1356 strings)
2021-06-16 18:23:10 +02:00
Yangjun Wang 5b2b3464c0 Translated using Weblate (Chinese (Simplified))
Currently translated at 92.5% (1255 of 1356 strings)
2021-06-16 18:23:10 +02:00
David Leal 2bc00862d3 Translated using Weblate (Spanish)
Currently translated at 79.0% (1072 of 1356 strings)
2021-06-16 18:23:10 +02:00
Joaquín Villalba 819fbefc12 Translated using Weblate (Spanish)
Currently translated at 78.0% (1059 of 1356 strings)
2021-06-16 18:23:09 +02:00
David Leal 1784d5f741 Translated using Weblate (Spanish)
Currently translated at 78.0% (1059 of 1356 strings)
2021-06-16 18:23:09 +02:00
Agustin Calderon b9456c1a0c Translated using Weblate (Spanish)
Currently translated at 78.0% (1059 of 1356 strings)
2021-06-16 18:23:09 +02:00
abidin toumi 6e8e0d10c8 Translated using Weblate (Arabic)
Currently translated at 25.7% (349 of 1356 strings)
2021-06-16 18:23:09 +02:00
Tirifto 0403de57ed Translated using Weblate (Esperanto)
Currently translated at 94.6% (1283 of 1356 strings)
2021-06-16 18:23:09 +02:00
Oğuz Ersen a70dfcaed9 Translated using Weblate (Turkish)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:09 +02:00
THANOS SIOURDAKIS 67b6f9771c Translated using Weblate (Greek)
Currently translated at 8.8% (120 of 1356 strings)
2021-06-16 18:23:09 +02:00
Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi afecda0a7d Translated using Weblate (Malay)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:09 +02:00
winniepee fa303ae12e Translated using Weblate (Chinese (Simplified))
Currently translated at 92.4% (1254 of 1356 strings)
2021-06-16 18:23:09 +02:00
Ayes 4bc56034cf Translated using Weblate (Estonian)
Currently translated at 39.5% (536 of 1356 strings)
2021-06-16 18:23:09 +02:00
Wuzzy a065e22f97 Translated using Weblate (German)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:09 +02:00
Marian 8231516bca Translated using Weblate (Slovak)
Currently translated at 100.0% (1356 of 1356 strings)
2021-06-16 18:23:09 +02:00
narrnika af7160b859
Translated using Weblate (Russian)
Currently translated at 99.3% (1347 of 1356 strings)
2021-06-16 18:21:11 +02:00
Mateusz Mendel ec5e149c7a
Translated using Weblate (Polish)
Currently translated at 71.2% (966 of 1356 strings)
2021-06-16 18:21:11 +02:00
Giov4 d6debece16
Translated using Weblate (Italian)
Currently translated at 99.7% (1352 of 1356 strings)
2021-06-16 18:21:11 +02:00
sfan5 edf098db63 Drop --videomodes, fullscreen_bpp and high_precision_fpu settings
These have been pointless for a while.
2021-06-16 17:41:34 +02:00
Wuzzy dc165fe942
Message for empty list output in /haspriv & /mods (#11149) 2021-06-12 18:48:21 +02:00
benrob0329 fbcf0fab8e
falling.lua - Fix Meshnodes Being Too Big (#11307) 2021-06-12 18:48:14 +02:00
Liso c47313db65
Shadow mapping render pass (#11244)
Co-authored-by: x2048 <codeforsmile@gmail.com>
2021-06-06 18:51:21 +02:00
sfan5 46f42e15c4 Fix check that given IRRLICHT_LIBRARY exists 2021-06-05 13:36:52 +02:00
Muhammad Rifqi Priyo Susanto 40acfc938c
Android: Do not submit text after pressing Enter key for multi-line text (#11298)
Regular EditText is used for multi-line text to not close the dialog after pressing back button.
New button is added for submitting multi-line text.
2021-06-04 21:22:53 +02:00
DS 8f085e02a1
Add metatables to lua vectors (#11039)
Add backwards-compatible metatable functions for vectors.
2021-06-04 21:22:33 +02:00
sfan5 e15cae9fa0 fontengine: Fix crash loading PNG/XML fonts from paths without dot
fixes #11096
2021-06-01 19:47:41 +02:00
SmallJoker c9144ae5e2
Add core.compare_block_status function (#11247)
Makes it possible to check the status of the mapblock in a future-extensible way.
2021-05-30 20:24:12 +02:00
Lars Müller 89f3991351
Fix base64 validation and add unittests (#10515)
Implement proper padding character checks
2021-05-30 20:23:12 +02:00
sfan5 1bc753f655 Use safe_file_write to save forceloaded blocks 2021-05-30 11:40:14 +02:00
sfan5 f30dcdb504 Fix procession ordering issue in content_cao 2021-05-30 11:40:14 +02:00
sfan5 2c53f03c18 Remove unused version detection from FindLuaJIT.cmake 2021-05-30 11:40:14 +02:00
sfan5 758e3aa1ca Fix background color of formspec text fields 2021-05-30 11:40:14 +02:00
sfan5 a0047d6edc script: Replace calls to depreated luaL_openlib 2021-05-30 11:40:14 +02:00
sfan5 a12017c564 Provide exact error message if postgres connection string missing 2021-05-30 11:40:14 +02:00
Wuzzy d7a4479eb3 Fix misleading /shutdown command syntax 2021-05-29 11:45:04 +02:00
SmallJoker 5bf72468f3
UnitSAO: Prevent circular attachments 2021-05-29 11:44:48 +02:00
Wuzzy ff48619a85 Fix cloud fog being broken for high clouds 2021-05-29 11:44:31 +02:00
savilli 673c29f7ea
Fix client crash on when con::PeerNotFoundException is thrown (#11286) 2021-05-24 19:40:35 +02:00
SmallJoker 93f43c890b GUIEditBox: Allow selecting and copying read-only texts 2021-05-22 14:39:41 +02:00
sfan5 4152227f17 CI: add workaround to fix clang builds
see https://github.com/actions/virtual-environments/issues/3376
2021-05-17 17:12:37 +02:00
sfan5 b56a028d6b Fix curl_timeout being ignored for Lua HTTP fetches 2021-05-17 17:12:30 +02:00
Lejo d44f1aabbb
Fix list of libraries included in AppImage 2021-05-15 23:56:33 +02:00
Dmitry Marakasov 53dca4f95f
Use --image-base instead of -Ttext-segment for lld linker on FreeBSD (#9367) (#11263) 2021-05-15 10:15:03 +02:00
Elias Fleckenstein 35445d24f4 Make set_pitch and set_yaw more accurate by not rounding it to integers 2021-05-13 19:34:32 +02:00
Elias Fleckenstein 5131675a60 Add guards to stop server build fail 2021-05-13 18:15:45 +02:00
Elias Fleckenstein f3e741dad1 Merge branch 'master' of https://github.com/minetest/minetest 2021-05-13 18:06:47 +02:00
Elias Fleckenstein 96a37aed31 Add minetest.get_send_speed 2021-05-13 17:21:13 +02:00
Elias Fleckenstein d082423166 Fix format 2021-05-13 08:24:07 +02:00
Elias Fleckenstein ce0d81a825 Change default cheat menu entry height 2021-05-13 08:18:32 +02:00
sfan5 69c70dd319 Fix swapped vertex colors on GLES2 2021-05-11 21:15:39 +02:00
Elias Fleckenstein b7abc8df28 Add on_object_add callback 2021-05-11 19:15:23 +02:00
Elias Fleckenstein 4f613bbf51 Include tile definitions in get_node_def; Client-side minetest.object_refs table 2021-05-11 14:07:30 +02:00
Elias Fleckenstein c86dcd0f68 Add on_object_hp_change callback and nametag images 2021-05-10 20:45:05 +02:00
Elias Fleckenstein b84ed7d0be Call on_object_properties_change callback when adding object to scene 2021-05-10 17:26:14 +02:00
Elias Fleckenstein 26cfbda653 Add on_object_properties_change callback 2021-05-10 16:51:54 +02:00
Elias Fleckenstein 6dc7a65d9e Add ClientObjectRef:set_properties 2021-05-10 16:07:31 +02:00
Elias Fleckenstein 7d7d4d675c Add ClientObjectRef.get_properties 2021-05-10 15:41:23 +02:00
sfan5 2443f1e235 Fix overlays for 2D-drawn items
fixes #11248
2021-05-08 19:44:43 +02:00
lhofhansl 7c2826cbc0
Fix build for newer versions of GCC (#11246) 2021-05-06 19:24:30 +02:00
Wuzzy 1bb8449734
Improve liquid documentation (#11158) 2021-05-06 19:24:11 +02:00
Loic Blot 225d4541ff fix: extractZipFile is not part of Client but more generic.
This solve a crash from mainmenu while extracting the zip
2021-05-06 16:01:52 +02:00
sfan5 ba40b39500 Add basic client-server test to CI 2021-05-05 22:49:44 +02:00
sfan5 08f1a7fbed Use Irrlicht functions to query npot texture support 2021-05-05 22:49:44 +02:00
Loic Blot de85bc9227 fix: some code tidy about includes & irr namespaces 2021-05-03 19:49:19 +02:00
Loic Blot 48d5abd5be refacto: remove get_gui_env & draw_load_screen from RenderingEngine singleton 2021-05-03 19:49:19 +02:00
Loic Blot a93712458b fix: don't use RenderingEngine singleton when it's possible 2021-05-03 19:49:19 +02:00
Loic Blot 5a02c376ea refacto: RenderingEngine::get_scene_manager() is now not callable from singleton
This permits to make evidence that we have some bad object passing on various code parts. I fixed majority of them to reduce the scope of passed objects

Unfortunately, for some edge cases i should have to expose ISceneManager from client, this should be fixed in the future when our POO will be cleaner client side (we have a mix of rendering and processing in majority of the client objects, it works but it's not clean)
2021-05-03 19:49:19 +02:00
Loic Blot ccdd886e27 refacto: Hud: make driver, client, player, inventory, tsrc private & drop unused guienv
also fix c_content.h, on client it includes the src/client/hud.h instead of src/hud.h, which leads to wrong file dependency on the lua stack
2021-05-03 19:49:19 +02:00
Loic Blot a47a00228b refacto: drop unused Hud::smgr 2021-05-03 19:49:19 +02:00
Loic Blot 809e68fdc0 refacto: don't use RenderingEngine singleton on CAO
* we don't need on CAO side more than SceneManager, and temporary. Pass only required SceneManager as a parameter to build CAO and add them to the current scene
* Use temporary the RenderingEngine singleton from ClientEnvironment, waitfor for better solution
* Make ClientActiveObject::addToScene virtual function mandatory to be defined by children to ensure we don't forget to properly define it
2021-05-03 19:49:19 +02:00
Loic Blot 1bc855646e refacto: protect some RenderingEngine::get_scene_manager
* protect it from Camera, Sky, ClientMap object calls
* rename Game::sky to Game::m_sky
2021-05-03 19:49:19 +02:00
Loic Blot 258101a910 refacto: RenderingEngine is now better hidden
* No more access to the singleton instance from everywhere (RenderingEngine::get_instance dropped)
* RenderingEngine::get_timer_time is now non static
* RenderingEngine::draw_menu_scene is now non static
* RenderingEngine::draw_scene is now non static
* RenderingEngine::{initialize,finalize} are now non static
* RenderingEngine::run is now non static
* RenderingEngine::getWindowSize now have a static helper. It was mandatory to hide the global get_instance access
2021-05-03 19:49:19 +02:00
Loic Blot 74125a74d3 refacto: hide mesh_cache inside the rendering engine
This permit cleaner access to meshCache and ensure we don't access to it from all the code
2021-05-03 19:49:19 +02:00
Loic Blot e0716384d6 refacto: add RenderingEngine::cleanupMeshCache
This permits to prevent client to own the mesh cache cleanup logic. It's better in RenderingEngine
2021-05-03 19:49:19 +02:00
Loic Blot e34d28af9f refacto: rendering engine singleton removal step 1 (filesystem)
Make the RenderingEngine filesystem member non accessible from everywhere

This permits also to determine that some lua code has directly a logic to extract zip file. Move this logic inside client, it's not the lua stack role to perform a such complex operation

Found also another irrlicht <1.8 compat code to remove
2021-05-03 19:49:19 +02:00
Loic Blot bc1888ff21 fix: drop old irrlicht <1.8 compat on Client::loadMedia 2021-05-03 19:49:19 +02:00
sfan5 83a7b48bb1 Fix Windows pipelines on Gitlab-CI 2021-04-28 09:18:05 +02:00
Wuzzy 228f1c6770
Fix rotation for falling mesh degrotate nodes (#11159) 2021-04-28 08:38:47 +02:00
sfan5 734fb2c811
Add helpful error messages if Irrlicht library / include dir are set incorrectly (#11232) 2021-04-28 08:38:18 +02:00
sfan5 9660ae288a
Update library versions in buildbot (#11229) 2021-04-27 11:50:40 +02:00
Wuzzy 776015c350
Rename “Irrlicht” to “IrrlichtMt” in documentation 2021-04-23 21:37:45 +02:00
Vincent Robinson 074e6a67de
Add `minetest.colorspec_to_colorstring` (#10425) 2021-04-23 21:37:24 +02:00
sfan5 3e2145d662 Fix two CMake build issues
* PostgreSQL fallback code missed the includes (closes #11219)
* build failed when Freetype enabled but not found
2021-04-21 20:26:43 +02:00
sfan5 daf862a38a Fix devtest Lua error
fallback_image() was removed in 3e1904fa8c,
which was written after this PR but merged before it.
2021-04-21 16:42:34 +02:00
sfan5 a24899bf2d
Look for PostgreSQL library properly and fix CI 2021-04-20 19:50:34 +02:00
sfan5 1da73418cd
Enable cleanTransparent filter for mipmapping and improve its' algorithm (#11145) 2021-04-20 19:50:19 +02:00
Wuzzy 90a7bd6a0a
Put torch/signlike node on floor if no paramtype2 (#11074) 2021-04-20 19:50:03 +02:00
Seth Traverse 16e5b39e1d
Add a key to toggle map block bounds (#11172)
It's often useful to know where the map block boundaries are for doing server admin work and the like.
Adds three modes: single mapblock, range of 5, and disabled.
2021-04-20 19:23:31 +02:00
sfan5 0077982fb7
GLES fixes (#11205)
* Consistently set float precision for GLES

* Enable DPI scaling on Windows+GLES
2021-04-18 16:07:13 +02:00
sfan5 623f0a8613 Isolate library tables between sandbox and insecure env 2021-04-18 16:06:42 +02:00
sfan5 52c0384bd1 Fix ignored OpenGLES2 include path and cmake warning 2021-04-16 23:39:16 +02:00
benrob0329 a106bfd456
Also return the ObjectRef from minetest.spawn_falling_node() (#11184) 2021-04-13 20:02:43 +02:00
SmallJoker bbe120308f
Attachments: Avoid data loss caused by set_attach() in callbacks (#11181) 2021-04-13 20:02:18 +02:00
sfan5 4d0fef8ae8
Buildbot changes to allow out-of-tree builds (#11180)
* Do proper out-of-tree builds with buildbot
* Don't write to bin/ for cross builds
     * This allows safely building multiple builds from the same source dir, e.g. with the buildbot.
* Disable Gettext (by default) and Freetype (entirely) for server builds
2021-04-11 17:10:06 +02:00
Wuzzy 4b8209d9a4
Modifying fall damage via armor group (#11080)
Adds a new fall_damage_add_percent armor group which influences the fall damage in addition to the existing node group.
2021-04-11 17:09:37 +02:00
sfan5 0abc1e98ed
Fix server favorites not saving when client/serverlist/ doesn't exist already (#11152) 2021-04-09 22:36:10 +02:00
Wuzzy a0e7a4a0df Update German builtin translation 2021-04-09 22:34:18 +02:00
Wuzzy 8c7e214875 Update builtin locale files 2021-04-09 22:34:18 +02:00
Wuzzy e89e6c8380 Don't reseed stars when changing star count 2021-04-09 22:33:45 +02:00
sfan5 57218aa9d1 Update Android build config 2021-04-09 21:16:45 +02:00
arydev ea8fa30b67
Changed README.md to fit the dragonfire client 2021-04-09 09:12:28 +03:00
yw05 85163b531f
Make edit boxes respond to string input (IME) (#11156)
Make edit boxes respond to string input events (introduced in minetest/irrlicht#23) that are usually triggered by entering text with an IME.
2021-04-05 15:56:29 +02:00
DS 2332527765
Add vector.to_string and vector.from_string (#10323)
Writing vectors as strings is very common and should belong to `vector.*`. `minetest.pos_to_string` is also too long to write, implies that one should only use it for positions and leaves no spaces after the commas.
2021-04-05 15:55:56 +02:00
sfan5 19c283546c Don't apply connection timeout limit to locally hosted servers
fixes #11085
2021-04-05 15:21:43 +02:00
SmallJoker c11208c4b5
Game: Scale damage flash to max HP
The flash intensity is calculated proportionally to the maximal HP.
2021-04-05 13:38:50 +02:00
sfan5 f0bad0e2ba
Reserve vectors before pushing and other code quality changes (#11161) 2021-04-05 13:38:31 +02:00
Wuzzy 3e1904fa8c
Devtest: Remove testnodes_show_fallback_image 2021-04-05 13:37:58 +02:00
Loic Blot 88783679cf fix(ci): ensure we build on docker only modifications 2021-04-02 14:40:22 +02:00
Loic Blot 5de849713e fix(docker): reduce the number of required libraries on build 2021-04-02 14:40:22 +02:00
Loic Blot 78da79b60f fix: use irrlicht fork instead of the standard library 2021-04-02 14:40:22 +02:00
Loic Blot c4b048fbb3 fix: don't send the whole local context to the docker image 2021-04-02 14:40:22 +02:00
sfan5 024d47e0d3
CGUITTFont optimizations (#11136) 2021-04-02 00:20:16 +02:00
sfan5 34888a914e
Sort out cURL timeouts and increase default 2021-04-02 00:19:39 +02:00
Vincent Robinson 3560691c0a
Add `math.round` and fix `vector.round` (#10803) 2021-04-02 00:18:58 +02:00
sfan5 1e4913cd76
Irrlicht support code maintenance 2021-03-31 13:15:47 +02:00
sfan5 0d90ed6d92
Draw items as 2D images (instead of meshes) when possible 2021-03-30 21:50:39 +02:00
Lars Müller 88d1fcfe23
Block & report player self-interaction (#11137) 2021-03-30 21:49:50 +02:00
SmallJoker f4118a4fde
Consistent title bar + render information in mainmenu (#10764) 2021-03-30 21:49:15 +02:00
sfan5 f345d00a43 Add entry in features table for degrotate changes 2021-03-30 14:40:09 +02:00
Wuzzy 6c9be39db0
Fix wield image of plantlike_rooted (#11067) 2021-03-30 00:27:46 +02:00
Vitaliy 3b78a22371
Degrotate support for mesh nodes (#7840) 2021-03-30 00:25:11 +02:00
Emojigit fde2785fe3
Update language choices in settingtypes.txt (#11124) 2021-03-29 19:58:39 +02:00
Wuzzy 7ad8ca62dc
Clean up various misleading and/or confusing messages and texts related to priv changes (#11126) 2021-03-29 19:57:48 +02:00
Wuzzy 7c24a9ebef Update CONTRIBUTING info on translating builtin 2021-03-29 19:56:20 +02:00
sfan5 8d89f5f0cc
Replace fallback font nonsense with automatic per-glyph fallback (#11084) 2021-03-29 19:55:24 +02:00
sfan5 5f4c78a77d Fix broken include check and correct Gitlab-CI script 2021-03-26 23:12:19 +01:00
HybridDog fc1512cca6
Translate chatcommand delay message and replace minetest with core (#11113) 2021-03-26 20:59:05 +01:00
sfan5 6a26d6d15a Adjust build config for Irrlicht changes (again) 2021-03-26 20:58:45 +01:00
Loic Blot 298bb3d8f7 Drop irrUString from MT, it's owned by irrlicht now 2021-03-26 20:58:45 +01:00
724 changed files with 115373 additions and 35815 deletions

View File

@ -1,6 +1,7 @@
BasedOnStyle: LLVM
IndentWidth: 8
IndentWidth: 4
UseTab: Always
TabWidth: 4
BreakBeforeBraces: Custom
Standard: Cpp11
BraceWrapping:
@ -16,7 +17,7 @@ BraceWrapping:
FixNamespaceComments: false
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -8
AccessModifierOffset: -4
ColumnLimit: 90
AllowShortFunctionsOnASingleLine: InlineOnly
SortIncludes: false
@ -26,7 +27,7 @@ IncludeCategories:
- Regex: '^<.*'
Priority: 1
AlignAfterOpenBracket: DontAlign
ContinuationIndentWidth: 16
ConstructorInitializerIndentWidth: 16
ContinuationIndentWidth: 8
ConstructorInitializerIndentWidth: 8
BreakConstructorInitializers: AfterColon
AlwaysBreakTemplateDeclarations: Yes

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
./cmake-build-*
./build/*
./cache/*
Dockerfile

9
.editorconfig Executable file
View File

@ -0,0 +1,9 @@
[*]
end_of_line = lf
[*.{cpp,h,lua,txt,glsl,md,c,cmake,java,gradle}]
charset = utf8
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

View File

@ -10,13 +10,31 @@ Contributions are welcome! Here's how you can help:
## Code
1. [Fork](https://help.github.com/articles/fork-a-repo/) the repository and [clone](https://help.github.com/articles/cloning-a-repository/) your fork.
1. [Fork](https://help.github.com/articles/fork-a-repo/) the repository and
[clone](https://help.github.com/articles/cloning-a-repository/) your fork.
2. Before you start coding, consider opening an [issue at Github](https://github.com/minetest/minetest/issues) to discuss the suitability and implementation of your intended contribution with the core developers. If you are planning to start some very significant coding, you would benefit from first discussing on our IRC development channel [#minetest-dev](http://www.minetest.net/irc/). Note that a proper IRC client is required to speak on this channel.
2. Before you start coding, consider opening an
[issue at Github](https://github.com/minetest/minetest/issues) to discuss the
suitability and implementation of your intended contribution with the core
developers.
Any Pull Request that isn't a bug fix and isn't covered by
[the roadmap](../doc/direction.md) will be closed within a week unless it
receives a concept approval from a Core Developer. For this reason, it is
recommended that you open an issue for any such pull requests before doing
the work, to avoid disappointment.
You may also benefit from discussing on our IRC development channel
[#minetest-dev](http://www.minetest.net/irc/). Note that a proper IRC client
is required to speak on this channel.
3. Start coding!
- Refer to the [Lua API](https://github.com/minetest/minetest/blob/master/doc/lua_api.txt), [Developer Wiki](http://dev.minetest.net/Main_Page) and other [documentation](https://github.com/minetest/minetest/tree/master/doc).
- Follow the [C/C++](http://dev.minetest.net/Code_style_guidelines) and [Lua](http://dev.minetest.net/Lua_code_style_guidelines) code style guidelines.
- Refer to the
[Lua API](https://github.com/minetest/minetest/blob/master/doc/lua_api.txt),
[Developer Wiki](http://dev.minetest.net/Main_Page) and other
[documentation](https://github.com/minetest/minetest/tree/master/doc).
- Follow the [C/C++](http://dev.minetest.net/Code_style_guidelines) and
[Lua](http://dev.minetest.net/Lua_code_style_guidelines) code style guidelines.
- Check your code works as expected and document any changes to the Lua API.
4. Commit & [push](https://help.github.com/articles/pushing-to-a-remote/) your changes to a new branch (not `master`, one change per branch)
@ -33,67 +51,115 @@ Contributions are welcome! Here's how you can help:
5. Once you are happy with your changes, submit a pull request.
- Open the [pull-request form](https://github.com/minetest/minetest/pull/new/master).
- Add a description explaining what you've done (or if it's a work-in-progress - what you need to do).
- Add a description explaining what you've done (or if it's a
work-in-progress - what you need to do).
- Make sure to fill out the pull request template.
### A pull-request is considered merge-able when:
1. It follows the roadmap in some way and fits the whole picture of the project: [roadmap introduction](http://c55.me/blog/?p=1491), [roadmap continued](https://forum.minetest.net/viewtopic.php?t=9177)
1. It follows [the roadmap](../doc/direction.md) in some way and fits the whole
picture of the project.
2. It works.
3. It follows the code style for [C/C++](http://dev.minetest.net/Code_style_guidelines) or [Lua](http://dev.minetest.net/Lua_code_style_guidelines).
4. The code's interfaces are well designed, regardless of other aspects that might need more work in the future.
3. It follows the code style for
[C/C++](http://dev.minetest.net/Code_style_guidelines) or
[Lua](http://dev.minetest.net/Lua_code_style_guidelines).
4. The code's interfaces are well designed, regardless of other aspects that
might need more work in the future.
5. It uses protocols and formats which include the required compatibility.
### Important note about automated GitHub checks
When you submit a pull request, GitHub automatically runs checks on the Minetest Engine combined with your changes. One of these checks is called 'cpp lint / clang format', which checks code formatting. Because formatting for readability requires human judgement this check often fails and often makes unsuitable formatting requests which make code readability worse.
When you submit a pull request, GitHub automatically runs checks on the Minetest
Engine combined with your changes. One of these checks is called 'cpp lint /
clang format', which checks code formatting. Because formatting for readability
requires human judgement this check often fails and often makes unsuitable
formatting requests which make code readability worse.
If this check fails, look at the details to check for any clear mistakes and correct those. However, you should not apply everything ClangFormat requests. Ignore requests that make code readability worse and any other clearly unsuitable requests. Discuss in the pull request with a core developer about how to progress.
If this check fails, look at the details to check for any clear mistakes and
correct those. However, you should not apply everything ClangFormat requests.
Ignore requests that make code readability worse and any other clearly
unsuitable requests. Discuss in the pull request with a core developer about how
to progress.
## Issues
If you experience an issue, we would like to know the details - especially when a stable release is on the way.
If you experience an issue, we would like to know the details - especially when
a stable release is on the way.
1. Do a quick search on GitHub to check if the issue has already been reported.
2. Is it an issue with the Minetest *engine*? If not, report it [elsewhere](http://www.minetest.net/development/#reporting-issues).
3. [Open an issue](https://github.com/minetest/minetest/issues/new) and describe the issue you are having - you could include:
2. Is it an issue with the Minetest *engine*? If not, report it
[elsewhere](http://www.minetest.net/development/#reporting-issues).
3. [Open an issue](https://github.com/minetest/minetest/issues/new) and describe
the issue you are having - you could include:
- Error logs (check the bottom of the `debug.txt` file).
- Screenshots.
- Ways you have tried to solve the issue, and whether they worked or not.
- Your Minetest version and the content (games, mods or texture packs) you have installed.
- Your platform (e.g. Windows 10 or Ubuntu 15.04 x64).
After reporting you should aim to answer questions or clarifications as this helps pinpoint the cause of the issue (if you don't do this your issue may be closed after 1 month).
After reporting you should aim to answer questions or clarifications as this
helps pinpoint the cause of the issue (if you don't do this your issue may be
closed after 1 month).
## Feature requests
Feature requests are welcome but take a moment to see if your idea follows the roadmap in some way and fits the whole picture of the project: [roadmap introduction](http://c55.me/blog/?p=1491), [roadmap continued](https://forum.minetest.net/viewtopic.php?t=9177). You should provide a clear explanation with as much detail as possible.
Feature requests are welcome but take a moment to see if your idea follows
[the roadmap](../doc/direction.md) in some way and fits the whole picture of
the project. You should provide a clear explanation with as much detail as
possible.
## Translations
Translations of Minetest are performed using Weblate. You can access the project page with a list of current languages [here](https://hosted.weblate.org/projects/minetest/minetest/).
The core translations of Minetest are performed using Weblate. You can access
the project page with a list of current languages
[here](https://hosted.weblate.org/projects/minetest/minetest/).
Builtin (the component which contains things like server messages, chat command
descriptions, privilege descriptions) is translated separately; it needs to be
translated by editing a `.tr` text file. See
[Translation](https://dev.minetest.net/Translation) for more information.
## Donations
If you'd like to monetarily support Minetest development, you can find donation methods on [our website](http://www.minetest.net/development/#donate).
If you'd like to monetarily support Minetest development, you can find donation
methods on [our website](http://www.minetest.net/development/#donate).
# Maintaining
*This is a concise version of the [Rules & Guidelines](http://dev.minetest.net/Category:Rules_and_Guidelines) on the developer wiki.*
* This is a concise version of the
[Rules & Guidelines](http://dev.minetest.net/Category:Rules_and_Guidelines) on the developer wiki.*
These notes are for those who have push access Minetest (core developers / maintainers).
- See the [project organisation](http://dev.minetest.net/Organisation) for the people involved.
## Concept approvals and roadmaps
If a Pull Request is not a bug fix:
* If it matches a goal in [the roadmap](../doc/direction.md), then the PR should
be labelled as "Roadmap" and the goal stated by number in the description.
* If it doesn't match a goal, then it needs to receive a concept approval within
a week of being opened to remain open. This 1 week deadline does not apply to
PRs opened before the roadmap was adopted; instead, they may remain open or be
closed as needed. Use the "Concept Approved" label. Issues can be marked as
"Concept Approved" to give preapproval to future PRs.
## Reviewing pull requests
Pull requests should be reviewed and, if appropriate, checked if they achieve their intended purpose. You can show that you are in the process of, or will review the pull request by commenting *"Looks good"* or something similar.
Pull requests should be reviewed and, if appropriate, checked if they achieve
their intended purpose. You can show that you are in the process of, or will
review the pull request by commenting *"Looks good"* or something similar.
**If the pull-request is not [merge-able](#a-pull-request-is-considered-merge-able-when):**
Submit a comment explaining to the author what they need to change to make the pull-request merge-able.
Submit a comment explaining to the author what they need to change to make the
pull-request merge-able.
- If the author comments or makes changes to the pull-request, it can be reviewed again.
- If no response is made from the author within 1 month (when improvements are suggested or a question is asked), it can be closed.
- If the author comments or makes changes to the pull-request, it can be
reviewed again.
- If no response is made from the author within 1 month (when improvements are
suggested or a question is asked), it can be closed.
**If the pull-request is [merge-able](#a-pull-request-is-considered-merge-able-when):**

View File

@ -8,8 +8,8 @@ assignees: ''
##### Minetest version
<!--
Paste Minetest version between quotes below
If you are on a devel version, please add git commit hash
Paste Minetest version between quotes below.
If you are on a devel version, please add git commit hash.
You can use `minetest --version` to find it.
-->
```
@ -29,4 +29,4 @@ OpenGL version:
<!-- Describe your problem here -->
##### Steps to reproduce
<!-- For bug reports or build issues, explain how the problem happened -->
<!-- Explain how the problem has happened, providing a minimal test (i.e. a code snippet reduced to the bone) where possible -->

View File

@ -3,6 +3,7 @@ Add compact, short information about your PR for easier understanding:
- Goal of the PR
- How does the PR work?
- Does it resolve any reported issue?
- Does this relate to a goal in [the roadmap](../doc/direction.md)?
- If not a bug fix, why is this PR needed? What usecases does it solve?
## To do

View File

@ -8,7 +8,7 @@ on:
- 'lib/**.cpp'
- 'src/**.[ch]'
- 'src/**.cpp'
- 'build/android/**'
- 'android/**'
- '.github/workflows/android.yml'
pull_request:
paths:
@ -16,27 +16,27 @@ on:
- 'lib/**.cpp'
- 'src/**.[ch]'
- 'src/**.cpp'
- 'build/android/**'
- 'android/**'
- '.github/workflows/android.yml'
jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: actions/checkout@v3
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gettext openjdk-11-jdk-headless
- name: Build with Gradle
run: cd build/android; ./gradlew assemblerelease
run: cd android; ./gradlew assemblerelease
- name: Save armeabi artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Minetest-armeabi-v7a.apk
path: build/android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned.apk
path: android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned.apk
- name: Save arm64 artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Minetest-arm64-v8a.apk
path: build/android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk
path: android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk

View File

@ -13,6 +13,8 @@ on:
- 'util/buildbot/**'
- 'util/ci/**'
- '.github/workflows/**.yml'
- 'Dockerfile'
- '.dockerignore'
pull_request:
paths:
- 'lib/**.[ch]'
@ -24,59 +26,61 @@ on:
- 'util/buildbot/**'
- 'util/ci/**'
- '.github/workflows/**.yml'
- 'Dockerfile'
- '.dockerignore'
jobs:
# This is our minor gcc compiler
gcc_6:
# Older gcc version (should be close to our minimum supported version)
gcc_5:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps g++-6
install_linux_deps g++-5
- name: Build
run: |
./util/ci/build.sh
env:
CC: gcc-6
CXX: g++-6
CC: gcc-5
CXX: g++-5
- name: Test
run: |
./bin/minetest --run-unittests
# This is the current gcc compiler (available in bionic)
gcc_8:
runs-on: ubuntu-18.04
# Current gcc version
gcc_10:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps g++-8
install_linux_deps g++-10
- name: Build
run: |
./util/ci/build.sh
env:
CC: gcc-8
CXX: g++-8
CC: gcc-10
CXX: g++-10
- name: Test
run: |
./bin/minetest --run-unittests
# This is our minor clang compiler
# Older clang version (should be close to our minimum supported version)
clang_3_9:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-3.9
install_linux_deps clang-3.9 gdb
- name: Build
run: |
@ -85,26 +89,30 @@ jobs:
CC: clang-3.9
CXX: clang++-3.9
- name: Test
- name: Unittest
run: |
./bin/minetest --run-unittests
# This is the current clang version
clang_9:
runs-on: ubuntu-18.04
- name: Integration test + devtest
run: |
./util/test_multiplayer.sh
# Current clang version
clang_10:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-9 valgrind libluajit-5.1-dev
install_linux_deps clang-10 valgrind libluajit-5.1-dev
- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-9
CXX: clang++-9
CC: clang-10
CXX: clang++-10
CMAKE_FLAGS: "-DREQUIRE_LUAJIT=1"
- name: Test
@ -118,13 +126,13 @@ jobs:
# Build with prometheus-cpp (server-only)
clang_9_prometheus:
name: "clang_9 (PROMETHEUS=1)"
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps --old-irr clang-9
install_linux_deps clang-9
- name: Build prometheus-cpp
run: |
@ -142,47 +150,25 @@ jobs:
run: |
./bin/minetestserver --run-unittests
# Build without freetype (client-only)
clang_9_no_freetype:
name: "clang_9 (FREETYPE=0)"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-9
- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-9
CXX: clang++-9
CMAKE_FLAGS: "-DENABLE_FREETYPE=0 -DBUILD_SERVER=0"
- name: Test
run: |
./bin/minetest --run-unittests
docker:
name: "Docker image"
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build docker image
run: |
docker build .
docker build . -t minetest:latest
docker run --rm minetest:latest /usr/local/bin/minetestserver --version
win32:
name: "MinGW cross-compiler (32-bit)"
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install compiler
run: |
sudo apt-get update -q && sudo apt-get install gettext -qyy
wget http://minetest.kitsunemimi.pw/mingw-w64-i686_9.2.0_ubuntu18.04.tar.xz -O mingw.tar.xz
sudo apt-get update && sudo apt-get install -y gettext
wget http://minetest.kitsunemimi.pw/mingw-w64-i686_11.2.0_ubuntu20.04.tar.xz -O mingw.tar.xz
sudo tar -xaf mingw.tar.xz -C /usr
- name: Build
@ -194,13 +180,13 @@ jobs:
win64:
name: "MinGW cross-compiler (64-bit)"
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install compiler
run: |
sudo apt-get update -q && sudo apt-get install gettext -qyy
wget http://minetest.kitsunemimi.pw/mingw-w64-x86_64_9.2.0_ubuntu18.04.tar.xz -O mingw.tar.xz
sudo apt-get update && sudo apt-get install -y gettext
wget http://minetest.kitsunemimi.pw/mingw-w64-x86_64_11.2.0_ubuntu20.04.tar.xz -O mingw.tar.xz
sudo tar -xaf mingw.tar.xz -C /usr
- name: Build
@ -213,13 +199,10 @@ jobs:
msvc:
name: VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }}
runs-on: windows-2019
#### Disabled due to Irrlicht switch
if: false
#### Disabled due to Irrlicht switch
env:
VCPKG_VERSION: 0bf3923f9fab4001c00f0f429682a0853b5749e0
# 2020.11
vcpkg_packages: irrlicht zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit
VCPKG_VERSION: 5cf60186a241e84e8232641ee973395d4fde90e1
# 2022.02
vcpkg_packages: zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp opengl-registry
strategy:
fail-fast: false
matrix:
@ -240,11 +223,17 @@ jobs:
# Enable it, when working on the installer.
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Checkout IrrlichtMt
uses: actions/checkout@v3
with:
repository: minetest/irrlicht
path: lib/irrlichtmt/
ref: "1.9.0mt6"
- name: Restore from cache and run vcpkg
uses: lukka/run-vcpkg@v5
uses: lukka/run-vcpkg@v7
with:
vcpkgArguments: ${{env.vcpkg_packages}}
vcpkgDirectory: '${{ github.workspace }}\vcpkg'
@ -252,7 +241,7 @@ jobs:
vcpkgGitCommitId: ${{ env.VCPKG_VERSION }}
vcpkgTriplet: ${{ matrix.config.vcpkg_triplet }}
- name: CMake
- name: Minetest CMake
run: |
cmake ${{matrix.config.generator}} `
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake" `
@ -260,7 +249,7 @@ jobs:
-DENABLE_POSTGRESQL=OFF `
-DRUN_IN_PLACE=${{ contains(matrix.type, 'portable') }} .
- name: Build
- name: Build Minetest
run: cmake --build . --config Release
- name: CPack
@ -279,7 +268,7 @@ jobs:
- name: Package Clean
run: rm -r $env:GITHUB_WORKSPACE\Package\_CPack_Packages
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
with:
name: msvc-${{ matrix.config.arch }}-${{ matrix.type }}
path: .\Package\

View File

@ -26,12 +26,13 @@ on:
jobs:
# clang_format:
# runs-on: ubuntu-18.04
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v2
# - uses: actions/checkout@v3
# - name: Install clang-format
# run: |
# sudo apt-get install clang-format-9 -qyy
# sudo apt-get update
# sudo apt-get install -y clang-format-9
#
# - name: Run clang-format
# run: |
@ -41,14 +42,13 @@ jobs:
# CLANG_FORMAT: clang-format-9
clang_tidy:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install deps
run: |
sudo apt-get install clang-tidy-9 -qyy
source ./util/ci/common.sh
install_linux_deps
install_linux_deps clang-tidy-9
- name: Run clang-tidy
run: |

62
.github/workflows/lua.yml vendored Normal file
View File

@ -0,0 +1,62 @@
name: lua_lint
# Lint on lua changes on builtin or if workflow changed
on:
push:
paths:
- 'builtin/**.lua'
- 'games/devtest/**.lua'
- '.github/workflows/**.yml'
pull_request:
paths:
- 'builtin/**.lua'
- 'games/devtest/**.lua'
- '.github/workflows/**.yml'
jobs:
# Note that the integration tests are also run build.yml, but only when C++ code is changed.
integration_tests:
name: "Compile and run multiplayer tests"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-10 gdb libluajit-5.1-dev
- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-10
CXX: clang++-10
CMAKE_FLAGS: "-DENABLE_GETTEXT=0 -DBUILD_SERVER=0"
- name: Integration test + devtest
run: |
./util/test_multiplayer.sh
luacheck:
name: "Builtin Luacheck and Unit Tests"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: leafo/gh-actions-lua@v9
with:
luaVersion: "5.1.5"
- uses: leafo/gh-actions-luarocks@v4
- name: Install luarocks tools
run: |
luarocks install --local luacheck
luarocks install --local busted
- name: Run checks (builtin)
run: |
$HOME/.luarocks/bin/luacheck builtin
$HOME/.luarocks/bin/busted builtin
- name: Run checks (devtest)
run: |
$HOME/.luarocks/bin/luacheck --config=games/devtest/.luacheckrc games/devtest

View File

@ -1,32 +0,0 @@
name: lua_lint
# Lint on lua changes on builtin or if workflow changed
on:
push:
paths:
- 'builtin/**.lua'
- '.github/workflows/**.yml'
pull_request:
paths:
- 'builtin/**.lua'
- '.github/workflows/**.yml'
jobs:
luacheck:
name: "Builtin Luacheck and Unit Tests"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install luarocks
run: |
sudo apt-get install luarocks -qyy
- name: Install luarocks tools
run: |
luarocks install --local luacheck
luarocks install --local busted
- name: Run checks
run: |
$HOME/.luarocks/bin/luacheck builtin
$HOME/.luarocks/bin/busted builtin

66
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,66 @@
name: macos
# build on c/cpp changes or workflow changes
on:
push:
paths:
- 'lib/**.[ch]'
- 'lib/**.cpp'
- 'src/**.[ch]'
- 'src/**.cpp'
- '**/CMakeLists.txt'
- 'cmake/Modules/**'
- '.github/workflows/macos.yml'
pull_request:
paths:
- 'lib/**.[ch]'
- 'lib/**.cpp'
- 'src/**.[ch]'
- 'src/**.cpp'
- '**/CMakeLists.txt'
- 'cmake/Modules/**'
- '.github/workflows/macos.yml'
env:
IRRLICHT_TAG: 1.9.0mt6
MINETEST_GAME_REPO: https://github.com/minetest/minetest_game.git
MINETEST_GAME_BRANCH: master
MINETEST_GAME_NAME: minetest_game
jobs:
build:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
pkgs=(cmake freetype gettext gmp hiredis jpeg jsoncpp leveldb libogg libpng libvorbis luajit zstd)
brew update
brew install ${pkgs[@]}
brew unlink $(brew ls --formula)
brew link ${pkgs[@]}
- name: Build
run: |
git clone -b $MINETEST_GAME_BRANCH $MINETEST_GAME_REPO games/$MINETEST_GAME_NAME
rm -rvf games/$MINETEST_GAME_NAME/.git
git clone https://github.com/minetest/irrlicht -b $IRRLICHT_TAG lib/irrlichtmt
mkdir build
cd build
cmake .. \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_INSTALL_PREFIX=../build/macos/ \
-DRUN_IN_PLACE=FALSE \
-DENABLE_FREETYPE=TRUE -DENABLE_GETTEXT=TRUE
make -j2
make install
- name: Test
run: |
./build/macos/minetest.app/Contents/MacOS/minetest --run-unittests
- uses: actions/upload-artifact@v3
with:
name: minetest-macos
path: ./build/macos/

12
.gitignore vendored
View File

@ -76,6 +76,7 @@ doc/mkdocs/docs/*.md
doc/mkdocs/mkdocs.yml
## Build files
build/
CMakeFiles
Makefile
cmake_install.cmake
@ -86,6 +87,7 @@ src/test_config.h
src/cmake_config.h
src/cmake_config_githash.h
src/unittest/test_world/world.mt
games/devtest/mods/testnodes/textures/testnodes_generated_*.png
/locale/
.directory
*.cbp
@ -105,3 +107,13 @@ CMakeDoxy*
compile_commands.json
*.apk
*.zip
# Visual Studio
*.vcxproj*
*.sln
.vs/
# Optional user provided library folder
lib/irrlichtmt
# Generated mod storage database
client/mod_storage.sqlite

View File

@ -9,7 +9,7 @@ stages:
- deploy
variables:
IRRLICHT_TAG: "1.9.0mt0"
IRRLICHT_TAG: "1.9.0mt6"
MINETEST_GAME_REPO: "https://github.com/minetest/minetest_game.git"
CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH
@ -17,18 +17,12 @@ variables:
stage: build
before_script:
- apt-get update
- apt-get -y install build-essential git cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libleveldb-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev
- DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libleveldb-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev
script:
- git clone https://github.com/minetest/irrlicht -b $IRRLICHT_TAG
- cd irrlicht
- cmake . -DBUILD_SHARED_LIBS=OFF
- make -j2
- cd ..
- mkdir cmakebuild
- cd cmakebuild
- cmake -DIRRLICHT_LIBRARY=$PWD/../irrlicht/lib/Linux/libIrrlicht.a -DIRRLICHT_INCLUDE_DIR=$PWD/../irrlicht/include -DCMAKE_INSTALL_PREFIX=../artifact/minetest/usr/ -DCMAKE_BUILD_TYPE=Release -DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE -DBUILD_SERVER=TRUE ..
- make -j2
- make install
- git clone https://github.com/minetest/irrlicht -b $IRRLICHT_TAG lib/irrlichtmt
- cmake -B build -DCMAKE_INSTALL_PREFIX=../artifact/minetest/usr/ -DCMAKE_BUILD_TYPE=Release -DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE -DBUILD_SERVER=TRUE ..
- cmake --build build --parallel $(($(nproc) + 1))
- cmake --install build
artifacts:
when: on_success
expire_in: 1h
@ -49,6 +43,7 @@ variables:
- sed -i 's/DATEPLACEHOLDER/'$(date +%y.%m.%d)'/g' build/deb/minetest/DEBIAN/control
- sed -i 's/JPEG_PLACEHOLDER/'$JPEG_PKG'/g' build/deb/minetest/DEBIAN/control
- sed -i 's/LEVELDB_PLACEHOLDER/'$LEVELDB_PKG'/g' build/deb/minetest/DEBIAN/control
- sed -i 's/JSONCPP_PLACEHOLDER/'$JSONCPP_PKG'/g' build/deb/minetest/DEBIAN/control
- cd build/deb/ && dpkg-deb -b minetest/ && mv minetest.deb ../../
artifacts:
expire_in: 90 day
@ -58,7 +53,7 @@ variables:
.debpkg_install:
stage: deploy
before_script:
- apt-get update
- apt-get update -qy
script:
- apt-get install -y ./*.deb
- minetest --version
@ -79,6 +74,7 @@ package:debian-9:
needs:
- build:debian-9
variables:
JSONCPP_PKG: libjsoncpp1
LEVELDB_PKG: libleveldb1v5
JPEG_PKG: libjpeg62-turbo
@ -100,6 +96,7 @@ package:debian-10:
needs:
- build:debian-10
variables:
JSONCPP_PKG: libjsoncpp1
LEVELDB_PKG: libleveldb1d
JPEG_PKG: libjpeg62-turbo
@ -109,31 +106,32 @@ deploy:debian-10:
needs:
- package:debian-10
# Bullseye
build:debian-11:
extends: .build_template
image: debian:11
package:debian-11:
extends: .debpkg_template
image: debian:11
needs:
- build:debian-11
variables:
JSONCPP_PKG: libjsoncpp24
LEVELDB_PKG: libleveldb1d
JPEG_PKG: libjpeg62-turbo
deploy:debian-11:
extends: .debpkg_install
image: debian:11
needs:
- package:debian-11
##
## Ubuntu
##
# Xenial
build:ubuntu-16.04:
extends: .build_template
image: ubuntu:xenial
package:ubuntu-16.04:
extends: .debpkg_template
image: ubuntu:xenial
needs:
- build:ubuntu-16.04
variables:
LEVELDB_PKG: libleveldb1v5
JPEG_PKG: libjpeg-turbo8
deploy:ubuntu-16.04:
extends: .debpkg_install
image: ubuntu:xenial
needs:
- package:ubuntu-16.04
# Bionic
build:ubuntu-18.04:
@ -146,6 +144,7 @@ package:ubuntu-18.04:
needs:
- build:ubuntu-18.04
variables:
JSONCPP_PKG: libjsoncpp1
LEVELDB_PKG: libleveldb1v5
JPEG_PKG: libjpeg-turbo8
@ -155,6 +154,28 @@ deploy:ubuntu-18.04:
needs:
- package:ubuntu-18.04
# Focal
build:ubuntu-20.04:
extends: .build_template
image: ubuntu:focal
package:ubuntu-20.04:
extends: .debpkg_template
image: ubuntu:focal
needs:
- build:ubuntu-20.04
variables:
JSONCPP_PKG: libjsoncpp1
LEVELDB_PKG: libleveldb1d
JPEG_PKG: libjpeg-turbo8
deploy:ubuntu-20.04:
extends: .debpkg_install
image: ubuntu:focal
needs:
- package:ubuntu-20.04
##
## Fedora
##
@ -164,36 +185,23 @@ build:fedora-28:
extends: .build_template
image: fedora:28
before_script:
- dnf -y install make git gcc gcc-c++ kernel-devel cmake libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel
- dnf -y install make git gcc gcc-c++ kernel-devel cmake libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-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
##
## MinGW for Windows
##
.generic_win_template:
image: ubuntu:bionic
image: ubuntu:focal
before_script:
- apt-get update
- apt-get install -y wget xz-utils unzip git cmake gettext
- wget -nv http://minetest.kitsunemimi.pw/mingw-w64-${WIN_ARCH}_9.2.0_ubuntu18.04.tar.xz -O mingw.tar.xz
- DEBIAN_FRONTEND=noninteractive apt-get install -y wget xz-utils unzip git cmake gettext
- wget -nv http://minetest.kitsunemimi.pw/mingw-w64-${WIN_ARCH}_11.2.0_ubuntu20.04.tar.xz -O mingw.tar.xz
- tar -xaf mingw.tar.xz -C /usr
.build_win_template:
extends: .generic_win_template
stage: build
artifacts:
expire_in: 1h
paths:
- _build/*
.package_win_template:
extends: .generic_win_template
stage: package
script:
- unzip _build/minetest-*.zip
- cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libgcc*.dll minetest-*-win*/bin/
- cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libstdc++*.dll minetest-*-win*/bin/
- cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libwinpthread*.dll minetest-*-win*/bin/
artifacts:
expire_in: 90 day
paths:
@ -203,28 +211,15 @@ build:win32:
extends: .build_win_template
script:
- EXISTING_MINETEST_DIR=$PWD ./util/buildbot/buildwin32.sh build
- unzip -q build/build/*.zip
variables:
WIN_ARCH: "i686"
package:win32:
extends: .package_win_template
needs:
- build:win32
variables:
WIN_ARCH: "i686"
build:win64:
extends: .build_win_template
script:
- EXISTING_MINETEST_DIR=$PWD ./util/buildbot/buildwin64.sh build
variables:
WIN_ARCH: "x86_64"
package:win64:
extends: .package_win_template
needs:
- build:win64
- unzip -q build/build/*.zip
variables:
WIN_ARCH: "x86_64"
@ -275,7 +270,7 @@ package:appimage-client:
- build:ubuntu-18.04
before_script:
- apt-get update -y
- apt-get install -y git wget
- apt-get install -y git
# Collect files
- mkdir AppDir
- cp -a artifact/minetest/usr/ AppDir/usr/

View File

@ -20,7 +20,7 @@ read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn", "indexof", "insert_all", "combine"}},
math = {fields = {"hypot"}},
math = {fields = {"hypot", "round"}},
}
globals = {

View File

@ -24,18 +24,21 @@ AppDir:
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-security main universe
include:
- libirrlicht1.8
- libxxf86vm1
- libgl1-mesa-glx
- libsqlite3-0
- libogg0
- libvorbis0a
- libopenal1
- libc6
- libcurl3-gnutls
- libfreetype6
- zlib1g
- libgmp10
- libgl1
- libjpeg-turbo8
- libjsoncpp1
- libleveldb1v5
- libopenal1
- libpng16-16
- libsqlite3-0
- libstdc++6
- libvorbisfile3
- libx11-6
- libxxf86vm1
- zlib1g
files:
exclude:

View File

@ -1,16 +1,24 @@
cmake_minimum_required(VERSION 3.5)
# Set policies up to 3.9 since we want to enable the IPO option
if(${CMAKE_VERSION} VERSION_LESS 3.9)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.9)
endif()
# This can be read from ${PROJECT_NAME} after project() is called
project(minetest)
set(PROJECT_NAME_CAPITALIZED "Dragonfire")
set(CMAKE_CXX_STANDARD 11)
set(GCC_MINIMUM_VERSION "4.8")
set(CLANG_MINIMUM_VERSION "3.4")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(GCC_MINIMUM_VERSION "5.1")
set(CLANG_MINIMUM_VERSION "3.5")
# Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
set(VERSION_MAJOR 5)
set(VERSION_MINOR 5)
set(VERSION_MINOR 6)
set(VERSION_PATCH 0)
set(VERSION_EXTRA "dragonfire" CACHE STRING "Stuff to append to version string")
@ -19,7 +27,7 @@ set(DEVELOPMENT_BUILD FALSE)
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_EXTRA)
set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
set(VERSION_STRING "${VERSION_STRING}-${VERSION_EXTRA}")
elseif(DEVELOPMENT_BUILD)
set(VERSION_STRING "${VERSION_STRING}-dev")
endif()
@ -44,7 +52,7 @@ set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
set(BUILD_SERVER FALSE CACHE BOOL "Build server")
set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
set(BUILD_BENCHMARKS FALSE CACHE BOOL "Build benchmarks")
set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
@ -57,30 +65,60 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# This is done here so that relative search paths are more reasonable
find_package(Irrlicht)
if(BUILD_CLIENT AND NOT IRRLICHT_FOUND)
message(FATAL_ERROR "Irrlicht is required to build the client, but it was not found.")
elseif(IRRLICHT_INCLUDE_DIR STREQUAL "")
message(FATAL_ERROR "Irrlicht headers are required to build the server, but none found.")
set(IRRLICHTMT_BUILD_DIR "" CACHE PATH "Path to IrrlichtMt build directory.")
if(NOT "${IRRLICHTMT_BUILD_DIR}" STREQUAL "")
find_package(IrrlichtMt QUIET
PATHS "${IRRLICHTMT_BUILD_DIR}"
NO_DEFAULT_PATH
)
if(NOT TARGET IrrlichtMt::IrrlichtMt)
# find_package() searches certain subdirectories. ${PATH}/cmake is not
# the only one, but it is the one where IrrlichtMt is supposed to export
# IrrlichtMtConfig.cmake
message(FATAL_ERROR "Could not find IrrlichtMtConfig.cmake in ${IRRLICHTMT_BUILD_DIR}/cmake.")
endif()
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt")
message(STATUS "Using user-provided IrrlichtMt at subdirectory 'lib/irrlichtmt'")
if(BUILD_CLIENT)
# tell IrrlichtMt to create a static library
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared library" FORCE)
add_subdirectory(lib/irrlichtmt EXCLUDE_FROM_ALL)
unset(BUILD_SHARED_LIBS CACHE)
if(NOT TARGET IrrlichtMt)
message(FATAL_ERROR "IrrlichtMt project is missing a CMake target?!")
endif()
else()
add_library(IrrlichtMt::IrrlichtMt INTERFACE IMPORTED)
set_target_properties(IrrlichtMt::IrrlichtMt PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt/include")
endif()
else()
find_package(IrrlichtMt QUIET)
if(NOT TARGET IrrlichtMt::IrrlichtMt)
string(CONCAT explanation_msg
"The Minetest team has forked Irrlicht to make their own customizations. "
"It can be found here: https://github.com/minetest/irrlicht\n"
"For example use: git clone --depth=1 https://github.com/minetest/irrlicht lib/irrlichtmt\n")
if(BUILD_CLIENT)
message(FATAL_ERROR "IrrlichtMt is required to build the client, but it was not found.\n${explanation_msg}")
endif()
include(MinetestFindIrrlichtHeaders)
if(NOT IRRLICHT_INCLUDE_DIR)
message(FATAL_ERROR "IrrlichtMt headers are required to build the server, but none found.\n${explanation_msg}")
endif()
message(STATUS "Found IrrlichtMt headers: ${IRRLICHT_INCLUDE_DIR}")
add_library(IrrlichtMt::IrrlichtMt INTERFACE IMPORTED)
# Note that we can't use target_include_directories() since that doesn't work for IMPORTED targets before CMake 3.11
set_target_properties(IrrlichtMt::IrrlichtMt PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${IRRLICHT_INCLUDE_DIR}")
endif()
endif()
include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${IRRLICHT_INCLUDE_DIR})
unset(HAS_FORKED_IRRLICHT CACHE)
check_symbol_exists(IRRLICHT_VERSION_MT "IrrCompileConfig.h" HAS_FORKED_IRRLICHT)
if(NOT HAS_FORKED_IRRLICHT)
string(CONCAT EXPLANATION_MSG
"Irrlicht found, but it is not Minetest's Irrlicht fork. "
"The Minetest team has forked Irrlicht to make their own customizations. "
"It can be found here: https://github.com/minetest/irrlicht")
if(BUILD_CLIENT)
message(FATAL_ERROR "${EXPLANATION_MSG}\n"
"Building the client with upstream Irrlicht is no longer possible.")
else()
message(WARNING "${EXPLANATION_MSG}\n"
"The server can still be built with upstream Irrlicht but this is DISCOURAGED.")
endif()
if(TARGET IrrlichtMt::IrrlichtMt)
message(STATUS "Found IrrlichtMt ${IrrlichtMt_VERSION}")
endif()
@ -112,15 +150,16 @@ elseif(UNIX) # Linux, BSD etc
set(ICONDIR "unix/icons")
set(LOCALEDIR "locale")
else()
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
include(GNUInstallDirs)
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")
set(BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(DOCDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}")
set(MANDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_MANDIR}")
set(EXAMPLE_CONF_DIR ${DOCDIR})
set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/metainfo")
set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications")
set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/metainfo")
set(ICONDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/icons")
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}")
endif()
endif()
@ -223,10 +262,10 @@ endif()
find_package(GMP REQUIRED)
find_package(Json REQUIRED)
find_package(Lua REQUIRED)
# JsonCpp doesn't compile well on GCC 4.8
if(NOT USE_SYSTEM_JSONCPP)
set(GCC_MINIMUM_VERSION "4.9")
if(NOT USE_LUAJIT)
set(LUA_BIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/bitop)
set(LUA_BIT_LIBRARY bitop)
add_subdirectory(lib/bitop)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@ -241,9 +280,12 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang")
endif()
endif()
if(BUILD_BENCHMARKS)
add_subdirectory(lib/catch2)
endif()
# Subdirectories
# Be sure to add all relevant definitions above this
add_subdirectory(src)

View File

@ -1,6 +1,8 @@
FROM alpine:3.11
ARG DOCKER_IMAGE=alpine:3.14
FROM $DOCKER_IMAGE AS builder
ENV MINETEST_GAME_VERSION master
ENV IRRLICHT_VERSION master
COPY .git /usr/src/minetest/.git
COPY CMakeLists.txt /usr/src/minetest/CMakeLists.txt
@ -18,48 +20,49 @@ COPY textures /usr/src/minetest/textures
WORKDIR /usr/src/minetest
RUN apk add --no-cache git build-base irrlicht-dev cmake bzip2-dev libpng-dev \
jpeg-dev libxxf86vm-dev mesa-dev sqlite-dev libogg-dev \
libvorbis-dev openal-soft-dev curl-dev freetype-dev zlib-dev \
gmp-dev jsoncpp-dev postgresql-dev luajit-dev ca-certificates && \
RUN apk add --no-cache git build-base cmake sqlite-dev curl-dev zlib-dev zstd-dev \
gmp-dev jsoncpp-dev postgresql-dev ninja luajit-dev ca-certificates && \
git clone --depth=1 -b ${MINETEST_GAME_VERSION} https://github.com/minetest/minetest_game.git ./games/minetest_game && \
rm -fr ./games/minetest_game/.git
WORKDIR /usr/src/
RUN git clone --recursive https://github.com/jupp0r/prometheus-cpp/ && \
mkdir prometheus-cpp/build && \
cd prometheus-cpp/build && \
cmake .. \
cd prometheus-cpp && \
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_TESTING=0 && \
make -j2 && \
make install
-DENABLE_TESTING=0 \
-GNinja && \
cmake --build build && \
cmake --install build
RUN git clone --depth=1 https://github.com/minetest/irrlicht/ -b ${IRRLICHT_VERSION} && \
cp -r irrlicht/include /usr/include/irrlichtmt
WORKDIR /usr/src/minetest
RUN mkdir build && \
cd build && \
cmake .. \
RUN cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SERVER=TRUE \
-DENABLE_PROMETHEUS=TRUE \
-DBUILD_UNITTESTS=FALSE \
-DBUILD_CLIENT=FALSE && \
make -j2 && \
make install
-DBUILD_CLIENT=FALSE \
-GNinja && \
cmake --build build && \
cmake --install build
FROM alpine:3.11
ARG DOCKER_IMAGE=alpine:3.14
FROM $DOCKER_IMAGE AS runtime
RUN apk add --no-cache sqlite-libs curl gmp libstdc++ libgcc libpq luajit jsoncpp && \
RUN apk add --no-cache sqlite-libs curl gmp libstdc++ libgcc libpq luajit jsoncpp zstd-libs && \
adduser -D minetest --uid 30000 -h /var/lib/minetest && \
chown -R minetest:minetest /var/lib/minetest
WORKDIR /var/lib/minetest
COPY --from=0 /usr/local/share/minetest /usr/local/share/minetest
COPY --from=0 /usr/local/bin/minetestserver /usr/local/bin/minetestserver
COPY --from=0 /usr/local/share/doc/minetest/minetest.conf.example /etc/minetest/minetest.conf
COPY --from=builder /usr/local/share/minetest /usr/local/share/minetest
COPY --from=builder /usr/local/bin/minetestserver /usr/local/bin/minetestserver
COPY --from=builder /usr/local/share/doc/minetest/minetest.conf.example /etc/minetest/minetest.conf
USER minetest:minetest

View File

@ -63,6 +63,15 @@ Zughy:
appgurueu:
textures/base/pack/server_incompatible.png
erlehmann, Warr1024, rollerozxa:
textures/base/pack/no_screenshot.png
kilbith:
textures/base/pack/server_favorite.png
SmallJoker
textures/base/pack/server_favorite_delete.png (based on server_favorite.png)
License of Minetest source code
-------------------------------
@ -87,7 +96,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Irrlicht
---------------
This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/
This program uses IrrlichtMt, Minetest's fork of
the Irrlicht Engine. http://irrlicht.sourceforge.net/
The Irrlicht Engine License

150
README.md
View File

@ -7,12 +7,12 @@ Minetest
Minetest is a free open-source voxel game engine with easy modding and game creation.
Copyright (C) 2010-2020 Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2010-2022 Perttu Ahola <celeron55@gmail.com>
and contributors (see source file comments and the version control log)
In case you downloaded the source code
--------------------------------------
If you downloaded the Minetest Engine source code in which this file is
If you downloaded the Dragonfire Client source code in which this file is
contained, you probably want to download the [Minetest Game](https://github.com/minetest/minetest_game/)
project too. See its README.txt for more information.
@ -132,29 +132,31 @@ Compiling
| Dependency | Version | Commentary |
|------------|---------|------------|
| GCC | 4.9+ | Can be replaced with Clang 3.4+ |
| CMake | 2.6+ | |
| Irrlicht | - | Custom version required, see https://github.com/minetest/irrlicht |
| SQLite3 | 3.0+ | |
| GCC | 5.1+ | or Clang 3.5+ |
| CMake | 3.5+ | |
| IrrlichtMt | - | Custom version of Irrlicht, see https://github.com/minetest/irrlicht |
| Freetype | 2.0+ | |
| SQLite3 | 3+ | |
| 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 |
| JsonCPP | 1.0.0+ | Bundled JsonCPP is used if not present |
For Debian/Ubuntu users:
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxxf86vm-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
For Fedora users:
sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel
sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-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
For Arch users:
sudo pacman -S base-devel libcurl-gnutls cmake libxxf86vm libpng sqlite libogg libvorbis openal freetype2 jsoncpp gmp luajit leveldb ncurses
sudo pacman -S base-devel libcurl-gnutls cmake libxxf86vm libpng sqlite libogg libvorbis openal freetype2 jsoncpp gmp luajit leveldb ncurses zstd
For Alpine users:
sudo apk add build-base cmake libpng-dev jpeg-dev libxxf86vm-dev mesa-dev sqlite-dev libogg-dev libvorbis-dev openal-soft-dev curl-dev freetype-dev zlib-dev gmp-dev jsoncpp-dev luajit-dev
sudo apk add build-base cmake libpng-dev jpeg-dev libxxf86vm-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
#### Download
@ -170,13 +172,17 @@ For Fedora users:
Download source (this is the URL to the latest of source repository, which might not work at all times) using Git:
git clone --depth 1 https://github.com/minetest/minetest.git
cd minetest
git clone --depth 1 https://github.com/dragonfireclient/dragonfireclient
cd dragonfireclient
Download minetest_game (otherwise only the "Development Test" game is available) using Git:
git clone --depth 1 https://github.com/minetest/minetest_game.git games/minetest_game
Download IrrlichtMt to `lib/irrlichtmt`, it will be used to satisfy the IrrlichtMt dependency that way:
git clone --branch 1.9.0mt7 --depth 1 https://github.com/minetest/irrlicht.git lib/irrlichtmt
Download source, without using Git:
wget https://github.com/minetest/minetest/archive/master.tar.gz
@ -191,6 +197,14 @@ Download minetest_game, without using Git:
mv minetest_game-master minetest_game
cd ..
Download IrrlichtMt, without using Git:
cd lib/
wget https://github.com/minetest/irrlicht/archive/master.tar.gz
tar xf master.tar.gz
mv irrlicht-master irrlichtmt
cd ..
#### Build
Build a version that runs directly from the source directory:
@ -209,8 +223,15 @@ Run it:
- You can disable the client build by specifying `-DBUILD_CLIENT=FALSE`.
- You can select between Release and Debug build by `-DCMAKE_BUILD_TYPE=<Debug or Release>`.
- Debug build is slower, but gives much more useful output in a debugger.
- If you build a bare server you don't need to have the Irrlicht library installed.
- In that case use `-DIRRLICHT_INCLUDE_DIR=/some/where/irrlicht/include`.
- If you build a bare server you don't need to compile IrrlichtMt, just the headers suffice.
- In that case use `-DIRRLICHT_INCLUDE_DIR=/some/where/irrlichtmt/include`.
- Minetest will use the IrrlichtMt package that is found first, given by the following order:
1. Specified `IRRLICHTMT_BUILD_DIR` CMake variable
2. `${PROJECT_SOURCE_DIR}/lib/irrlichtmt` (if existent)
3. Installation of IrrlichtMt in the system-specific library paths
4. For server builds with disabled `BUILD_CLIENT` variable, the headers from `IRRLICHT_INCLUDE_DIR` will be used.
- NOTE: Changing the IrrlichtMt build directory (includes system installs) requires regenerating the CMake cache (`rm CMakeCache.txt`)
### CMake options
@ -219,6 +240,7 @@ General options and their default values:
BUILD_CLIENT=TRUE - Build Minetest client
BUILD_SERVER=FALSE - Build Minetest server
BUILD_UNITTESTS=TRUE - Build unittest sources
BUILD_BENCHMARKS=FALSE - Build benchmark sources
CMAKE_BUILD_TYPE=Release - Type of build (Release vs. Debug)
Release - Release build
Debug - Debug build
@ -227,9 +249,8 @@ General options and their default values:
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
ENABLE_FREETYPE=ON - Build with FreeType2; Allows using TTF fonts
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations
ENABLE_GLES=OFF - Build for OpenGL ES instead of OpenGL (requires support by Irrlicht)
ENABLE_GLES=OFF - Enable extra support code for OpenGL ES (requires support by IrrlichtMt)
ENABLE_LEVELDB=ON - Build with LevelDB; Enables use of LevelDB map backend
ENABLE_POSTGRESQL=ON - Build with libpq; Enables use of PostgreSQL map backend (PostgreSQL 9.5 or greater recommended)
ENABLE_REDIS=ON - Build with libhiredis; Enables use of Redis map backend
@ -239,10 +260,10 @@ General options and their default values:
ENABLE_PROMETHEUS=OFF - Build with Prometheus metrics exporter (listens on tcp/30000 by default)
ENABLE_SYSTEM_GMP=ON - Use GMP from system (much faster than bundled mini-gmp)
ENABLE_SYSTEM_JSONCPP=ON - Use JsonCPP from system
OPENGL_GL_PREFERENCE=LEGACY - Linux client build only; See CMake Policy CMP0072 for reference
RUN_IN_PLACE=FALSE - Create a portable install (worlds, settings etc. in current directory)
USE_GPROF=FALSE - Enable profiling using GProf
VERSION_EXTRA= - Text to append to version (e.g. VERSION_EXTRA=foobar -> Minetest 0.4.9-foobar)
ENABLE_TOUCH=FALSE - Enable Touchscreen support (requires support by IrrlichtMt)
Library specific options:
@ -251,17 +272,17 @@ Library specific options:
CURL_LIBRARY - Only if building with cURL; path to libcurl.a/libcurl.so/libcurl.lib
EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h
EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so
FREETYPE_INCLUDE_DIR_freetype2 - Only if building with FreeType 2; directory that contains an freetype directory with files such as ftimage.h in it
FREETYPE_INCLUDE_DIR_ft2build - Only if building with FreeType 2; directory that contains ft2build.h
FREETYPE_LIBRARY - Only if building with FreeType 2; path to libfreetype.a/libfreetype.so/freetype.lib
FREETYPE_DLL - Only if building with FreeType 2 on Windows; path to libfreetype.dll
EXTRA_DLL - Only on Windows; optional paths to additional DLLs that should be packaged
FREETYPE_INCLUDE_DIR_freetype2 - Directory that contains files such as ftimage.h
FREETYPE_INCLUDE_DIR_ft2build - Directory that contains ft2build.h
FREETYPE_LIBRARY - Path to libfreetype.a/libfreetype.so/freetype.lib
FREETYPE_DLL - Only on Windows; path to libfreetype-6.dll
GETTEXT_DLL - Only when building with gettext on Windows; paths to libintl + libiconv DLLs
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a
GETTEXT_MSGFMT - Only when building with gettext; path to msgfmt/msgfmt.exe
IRRLICHT_DLL - Only on Windows; path to Irrlicht.dll
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h
IRRLICHT_LIBRARY - Path to libIrrlicht.a/libIrrlicht.so/libIrrlicht.dll.a/Irrlicht.lib
IRRLICHT_DLL - Only on Windows; path to IrrlichtMt.dll
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h (usable for server build only)
LEVELDB_INCLUDE_DIR - Only when building with LevelDB; directory that contains db.h
LEVELDB_LIBRARY - Only when building with LevelDB; path to libleveldb.a/libleveldb.so/libleveldb.dll.a
LEVELDB_DLL - Only when building with LevelDB on Windows; path to libleveldb.dll
@ -279,20 +300,20 @@ Library specific options:
OPENAL_DLL - Only if building with sound on Windows; path to OpenAL32.dll
OPENAL_INCLUDE_DIR - Only if building with sound; directory where al.h is located
OPENAL_LIBRARY - Only if building with sound; path to libopenal.a/libopenal.so/OpenAL32.lib
OPENGLES2_INCLUDE_DIR - Only if building with GLES; directory that contains gl2.h
OPENGLES2_LIBRARY - Only if building with GLES; path to libGLESv2.a/libGLESv2.so
SQLITE3_INCLUDE_DIR - Directory that contains sqlite3.h
SQLITE3_LIBRARY - Path to libsqlite3.a/libsqlite3.so/sqlite3.lib
VORBISFILE_LIBRARY - Only if building with sound; path to libvorbisfile.a/libvorbisfile.so/libvorbisfile.dll.a
VORBIS_DLL - Only if building with sound on Windows; paths to vorbis DLLs
VORBIS_INCLUDE_DIR - Only if building with sound; directory that contains a directory vorbis with vorbisenc.h inside
VORBIS_LIBRARY - Only if building with sound; path to libvorbis.a/libvorbis.so/libvorbis.dll.a
XXF86VM_LIBRARY - Only on Linux; path to libXXf86vm.a/libXXf86vm.so
ZLIB_DLL - Only on Windows; path to zlib1.dll
ZLIB_INCLUDE_DIR - Directory that contains zlib.h
ZLIB_LIBRARY - Path to libz.a/libz.so/zlib.lib
ZSTD_DLL - Only on Windows; path to libzstd.dll
ZSTD_INCLUDE_DIR - Directory that contains zstd.h
ZSTD_LIBRARY - Path to libzstd.a/libzstd.so/ztd.lib
### Compiling on Windows
### Compiling on Windows using MSVC
### Requirements
@ -305,17 +326,14 @@ Library specific options:
It is highly recommended to use vcpkg as package manager.
#### a) Using vcpkg to install dependencies
After you successfully built vcpkg you can easily install the required libraries:
```powershell
vcpkg install zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit gmp jsoncpp --triplet x64-windows
vcpkg install zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp opengl-registry --triplet x64-windows
```
- **Note that you currently need to build irrlicht on your own**
- **Don't forget about IrrlichtMt.** The easiest way is to clone it to `lib/irrlichtmt` as described in the Linux section.
- `curl` is optional, but required to read the serverlist, `curl[winssl]` is required to use the content store.
- `openal-soft`, `libvorbis` and `libogg` are optional, but required to use sound.
- `freetype` is optional, it allows true-type font rendering.
- `luajit` is optional, it replaces the integrated Lua interpreter with a faster just-in-time interpreter.
- `gmp` and `jsoncpp` are optional, otherwise the bundled versions will be compiled
@ -323,10 +341,6 @@ There are other optional libraries, but they are not tested if they can build an
Use `--triplet` to specify the target triplet, e.g. `x64-windows` or `x86-windows`.
#### b) Compile the dependencies on your own
This is outdated and not recommended. Follow the instructions on https://dev.minetest.net/Build_Win32_Minetest_including_all_required_libraries#VS2012_Build
### Compile Minetest
#### a) Using the vcpkg toolchain and CMake GUI
@ -355,12 +369,6 @@ cmake --build . --config Release
```
Make sure that the right compiler is selected and the path to the vcpkg toolchain is correct.
#### c) Using your own compiled libraries
**This is outdated and not recommended**
Follow the instructions on https://dev.minetest.net/Build_Win32_Minetest_including_all_required_libraries#VS2012_Build
### Windows Installer using WiX Toolset
Requirements:
@ -374,6 +382,60 @@ Build the binaries as described above, but make sure you unselect `RUN_IN_PLACE`
Open the generated project file with Visual Studio. Right-click **Package** and choose **Generate**.
It may take some minutes to generate the installer.
### Compiling on MacOS
#### Requirements
- [Homebrew](https://brew.sh/)
- [Git](https://git-scm.com/downloads)
Install dependencies with homebrew:
```
brew install cmake freetype gettext gmp hiredis jpeg jsoncpp leveldb libogg libpng libvorbis luajit zstd
```
#### Download
Download source (this is the URL to the latest of source repository, which might not work at all times) using Git:
```bash
git clone --depth 1 https://github.com/minetest/minetest.git
cd minetest
```
Download minetest_game (otherwise only the "Development Test" game is available) using Git:
```
git clone --depth 1 https://github.com/minetest/minetest_game.git games/minetest_game
```
Download Minetest's fork of Irrlicht:
```
git clone --depth 1 https://github.com/minetest/irrlicht.git lib/irrlichtmt
```
#### Build
```bash
mkdir build
cd build
cmake .. \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_INSTALL_PREFIX=../build/macos/ \
-DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE
make -j$(sysctl -n hw.logicalcpu)
make install
```
#### Run
```
open ./build/macos/minetest.app
```
Docker
------

View File

@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion '30.0.3'
ndkVersion '22.0.7026061'
ndkVersion "$ndk_version"
defaultConfig {
applicationId 'net.minetest.minetest'
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
versionCode project.versionCode
}
@ -52,7 +52,7 @@ android {
task prepareAssets() {
def assetsFolder = "build/assets"
def projRoot = "../../.."
def projRoot = "../.."
def gameToCopy = "minetest_game"
copy {
@ -68,7 +68,7 @@ task prepareAssets() {
from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders"
}
copy {
from "../native/deps/Android/Irrlicht/shaders" into "${assetsFolder}/client/shaders/Irrlicht"
from "../native/deps/armeabi-v7a/Irrlicht/Shaders" into "${assetsFolder}/client/shaders/Irrlicht"
}
copy {
from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts"
@ -76,10 +76,13 @@ task prepareAssets() {
copy {
from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}"
}
/*copy {
// ToDo: fix broken locales
from "${projRoot}/po" into "${assetsFolder}/po"
}*/
fileTree("${projRoot}/po").include("**/*.po").forEach { poFile ->
def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/"
file(moPath).mkdirs()
exec {
commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile
}
}
copy {
from "${projRoot}/textures" into "${assetsFolder}/textures"
}
@ -109,5 +112,5 @@ android.applicationVariants.all { variant ->
dependencies {
implementation project(':native')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
}

View File

@ -30,7 +30,8 @@
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:maxAspectRatio="3.0"
android:screenOrientation="sensorLandscape"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -44,7 +45,8 @@
android:launchMode="singleTask"
android:maxAspectRatio="3.0"
android:screenOrientation="sensorLandscape"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@ -57,6 +59,17 @@
android:name=".UnzipService"
android:enabled="true"
android:exported="false" />
</application>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="net.minetest.minetest.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
</application>
</manifest>

View File

@ -26,16 +26,25 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.Keep;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider;
import java.io.File;
import java.util.Objects;
// Native code finds these methods by name (see porting_android.cpp).
// This annotation prevents the minifier/Proguard from mangling them.
@Keep
public class GameActivity extends NativeActivity {
static {
System.loadLibrary("c++_shared");
@ -85,9 +94,19 @@ public class GameActivity extends NativeActivity {
private void showDialogUI(String hint, String current, int editType) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
EditText editText = new CustomEditText(this);
builder.setView(editText);
LinearLayout container = new LinearLayout(this);
container.setOrientation(LinearLayout.VERTICAL);
builder.setView(container);
AlertDialog alertDialog = builder.create();
EditText editText;
// For multi-line, do not close the dialog after pressing back button
if (editType == 1) {
editText = new EditText(this);
} else {
editText = new CustomEditText(this);
}
container.addView(editText);
editText.setMaxLines(8);
editText.requestFocus();
editText.setHint(hint);
editText.setText(current);
@ -103,8 +122,9 @@ public class GameActivity extends NativeActivity {
else
editText.setInputType(InputType.TYPE_CLASS_TEXT);
editText.setSelection(editText.getText().length());
editText.setOnKeyListener((view, KeyCode, event) -> {
if (KeyCode == KeyEvent.KEYCODE_ENTER) {
editText.setOnKeyListener((view, keyCode, event) -> {
// For multi-line, do not submit the text after pressing Enter key
if (keyCode == KeyEvent.KEYCODE_ENTER && editType != 1) {
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
messageReturnCode = 0;
messageReturnValue = editText.getText().toString();
@ -113,6 +133,18 @@ public class GameActivity extends NativeActivity {
}
return false;
});
// For multi-line, add Done button since Enter key does not submit text
if (editType == 1) {
Button doneButton = new Button(this);
container.addView(doneButton);
doneButton.setText(R.string.ime_dialog_done);
doneButton.setOnClickListener((view -> {
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
messageReturnCode = 0;
messageReturnValue = editText.getText().toString();
alertDialog.dismiss();
}));
}
alertDialog.show();
alertDialog.setOnCancelListener(dialog -> {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
@ -146,4 +178,30 @@ public class GameActivity extends NativeActivity {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(browserIntent);
}
public String getUserDataPath() {
return Utils.getUserDataDirectory(this).getAbsolutePath();
}
public String getCachePath() {
return Utils.getCacheDirectory(this).getAbsolutePath();
}
public void shareFile(String path) {
File file = new File(path);
if (!file.exists()) {
Log.e("GameActivity", "File " + file.getAbsolutePath() + " doesn't exist");
return;
}
Uri fileUri = FileProvider.getUriForFile(this, "net.minetest.minetest.fileprovider", file);
Intent intent = new Intent(Intent.ACTION_SEND, fileUri);
intent.setDataAndType(fileUri, getContentResolver().getType(fileUri));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
Intent shareIntent = Intent.createChooser(intent, null);
startActivity(shareIntent);
}
}

View File

@ -29,12 +29,14 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@ -43,11 +45,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static net.minetest.minetest.UnzipService.ACTION_FAILURE;
import static net.minetest.minetest.UnzipService.ACTION_PROGRESS;
import static net.minetest.minetest.UnzipService.ACTION_UPDATE;
import static net.minetest.minetest.UnzipService.FAILURE;
import static net.minetest.minetest.UnzipService.SUCCESS;
import static net.minetest.minetest.UnzipService.*;
public class MainActivity extends AppCompatActivity {
private final static int versionCode = BuildConfig.VERSION_CODE;
@ -56,26 +54,40 @@ public class MainActivity extends AppCompatActivity {
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
private static final String SETTINGS = "MinetestSettings";
private static final String TAG_VERSION_CODE = "versionCode";
private ProgressBar mProgressBar;
private TextView mTextView;
private SharedPreferences sharedPreferences;
private final BroadcastReceiver myReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int progress = 0;
if (intent != null)
@StringRes int message = 0;
if (intent != null) {
progress = intent.getIntExtra(ACTION_PROGRESS, 0);
if (progress >= 0) {
if (mProgressBar != null) {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(progress);
}
mTextView.setVisibility(View.VISIBLE);
} else if (progress == FAILURE) {
message = intent.getIntExtra(ACTION_PROGRESS_MESSAGE, 0);
}
if (progress == FAILURE) {
Toast.makeText(MainActivity.this, intent.getStringExtra(ACTION_FAILURE), Toast.LENGTH_LONG).show();
finish();
} else if (progress == SUCCESS)
} else if (progress == SUCCESS) {
startNative();
} else {
if (mProgressBar != null) {
mProgressBar.setVisibility(View.VISIBLE);
if (progress == INDETERMINATE) {
mProgressBar.setIndeterminate(true);
} else {
mProgressBar.setIndeterminate(false);
mProgressBar.setProgress(progress);
}
}
mTextView.setVisibility(View.VISIBLE);
if (message != 0)
mTextView.setText(message);
}
}
};
@ -88,7 +100,9 @@ public class MainActivity extends AppCompatActivity {
mProgressBar = findViewById(R.id.progressBar);
mTextView = findViewById(R.id.textView);
sharedPreferences = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
Build.VERSION.SDK_INT < Build.VERSION_CODES.R)
checkPermission();
else
checkAppVersion();
@ -120,6 +134,7 @@ public class MainActivity extends AppCompatActivity {
if (grantResult != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, R.string.not_granted, Toast.LENGTH_LONG).show();
finish();
return;
}
}
checkAppVersion();
@ -127,10 +142,27 @@ public class MainActivity extends AppCompatActivity {
}
private void checkAppVersion() {
if (sharedPreferences.getInt(TAG_VERSION_CODE, 0) == versionCode)
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
Toast.makeText(this, R.string.no_external_storage, Toast.LENGTH_LONG).show();
finish();
return;
}
if (UnzipService.getIsRunning()) {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setIndeterminate(true);
mTextView.setVisibility(View.VISIBLE);
} else if (sharedPreferences.getInt(TAG_VERSION_CODE, 0) == versionCode &&
Utils.isInstallValid(this)) {
startNative();
else
new CopyZipTask(this).execute(getCacheDir() + "/Minetest.zip");
} else {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setIndeterminate(true);
mTextView.setVisibility(View.VISIBLE);
Intent intent = new Intent(this, UnzipService.class);
startService(intent);
}
}
private void startNative() {

View File

@ -0,0 +1,259 @@
/*
Minetest
Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2020 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.minetest.minetest;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Environment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
public class UnzipService extends IntentService {
public static final String ACTION_UPDATE = "net.minetest.minetest.UPDATE";
public static final String ACTION_PROGRESS = "net.minetest.minetest.PROGRESS";
public static final String ACTION_PROGRESS_MESSAGE = "net.minetest.minetest.PROGRESS_MESSAGE";
public static final String ACTION_FAILURE = "net.minetest.minetest.FAILURE";
public static final int SUCCESS = -1;
public static final int FAILURE = -2;
public static final int INDETERMINATE = -3;
private final int id = 1;
private NotificationManager mNotifyManager;
private boolean isSuccess = true;
private String failureMessage;
private static boolean isRunning = false;
public static synchronized boolean getIsRunning() {
return isRunning;
}
private static synchronized void setIsRunning(boolean v) {
isRunning = v;
}
public UnzipService() {
super("net.minetest.minetest.UnzipService");
}
@Override
protected void onHandleIntent(Intent intent) {
Notification.Builder notificationBuilder = createNotification();
final File zipFile = new File(getCacheDir(), "Minetest.zip");
try {
setIsRunning(true);
File userDataDirectory = Utils.getUserDataDirectory(this);
if (userDataDirectory == null) {
throw new IOException("Unable to find user data directory");
}
try (InputStream in = this.getAssets().open(zipFile.getName())) {
try (OutputStream out = new FileOutputStream(zipFile)) {
int readLen;
byte[] readBuffer = new byte[16384];
while ((readLen = in.read(readBuffer)) != -1) {
out.write(readBuffer, 0, readLen);
}
}
}
migrate(notificationBuilder, userDataDirectory);
unzip(notificationBuilder, zipFile, userDataDirectory);
} catch (IOException e) {
isSuccess = false;
failureMessage = e.getLocalizedMessage();
} finally {
setIsRunning(false);
zipFile.delete();
}
}
private Notification.Builder createNotification() {
String name = "net.minetest.minetest";
String channelId = "Minetest channel";
String description = "notifications from Minetest";
Notification.Builder builder;
if (mNotifyManager == null)
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = null;
if (mNotifyManager != null)
mChannel = mNotifyManager.getNotificationChannel(channelId);
if (mChannel == null) {
mChannel = new NotificationChannel(channelId, name, importance);
mChannel.setDescription(description);
// Configure the notification channel, NO SOUND
mChannel.setSound(null, null);
mChannel.enableLights(false);
mChannel.enableVibration(false);
mNotifyManager.createNotificationChannel(mChannel);
}
builder = new Notification.Builder(this, channelId);
} else {
builder = new Notification.Builder(this);
}
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
builder.setContentTitle(getString(R.string.notification_title))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText(getString(R.string.notification_description))
.setContentIntent(intent)
.setOngoing(true)
.setProgress(0, 0, true);
mNotifyManager.notify(id, builder.build());
return builder;
}
private void unzip(Notification.Builder notificationBuilder, File zipFile, File userDataDirectory) throws IOException {
int per = 0;
int size;
try (ZipFile zipSize = new ZipFile(zipFile)) {
size = zipSize.size();
}
int readLen;
byte[] readBuffer = new byte[16384];
try (FileInputStream fileInputStream = new FileInputStream(zipFile);
ZipInputStream zipInputStream = new ZipInputStream(fileInputStream)) {
ZipEntry ze;
while ((ze = zipInputStream.getNextEntry()) != null) {
if (ze.isDirectory()) {
++per;
Utils.createDirs(userDataDirectory, ze.getName());
continue;
}
publishProgress(notificationBuilder, R.string.loading, 100 * ++per / size);
try (OutputStream outputStream = new FileOutputStream(
new File(userDataDirectory, ze.getName()))) {
while ((readLen = zipInputStream.read(readBuffer)) != -1) {
outputStream.write(readBuffer, 0, readLen);
}
}
}
}
}
void moveFileOrDir(@NonNull File src, @NonNull File dst) throws IOException {
try {
Process p = new ProcessBuilder("/system/bin/mv",
src.getAbsolutePath(), dst.getAbsolutePath()).start();
int exitcode = p.waitFor();
if (exitcode != 0)
throw new IOException("Move failed with exit code " + exitcode);
} catch (InterruptedException e) {
throw new IOException("Move operation interrupted");
}
}
boolean recursivelyDeleteDirectory(@NonNull File loc) {
try {
Process p = new ProcessBuilder("/system/bin/rm", "-rf",
loc.getAbsolutePath()).start();
return p.waitFor() == 0;
} catch (IOException | InterruptedException e) {
return false;
}
}
/**
* Migrates user data from deprecated external storage to app scoped storage
*/
private void migrate(Notification.Builder notificationBuilder, File newLocation) throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return;
}
File oldLocation = new File(Environment.getExternalStorageDirectory(), "Minetest");
if (!oldLocation.isDirectory())
return;
publishProgress(notificationBuilder, R.string.migrating, 0);
newLocation.mkdir();
String[] dirs = new String[] { "worlds", "games", "mods", "textures", "client" };
for (int i = 0; i < dirs.length; i++) {
publishProgress(notificationBuilder, R.string.migrating, 100 * i / dirs.length);
File dir = new File(oldLocation, dirs[i]), dir2 = new File(newLocation, dirs[i]);
if (dir.isDirectory() && !dir2.isDirectory()) {
moveFileOrDir(dir, dir2);
}
}
for (String filename : new String[] { "minetest.conf" }) {
File file = new File(oldLocation, filename), file2 = new File(newLocation, filename);
if (file.isFile() && !file2.isFile()) {
moveFileOrDir(file, file2);
}
}
recursivelyDeleteDirectory(oldLocation);
}
private void publishProgress(@Nullable Notification.Builder notificationBuilder, @StringRes int message, int progress) {
Intent intentUpdate = new Intent(ACTION_UPDATE);
intentUpdate.putExtra(ACTION_PROGRESS, progress);
intentUpdate.putExtra(ACTION_PROGRESS_MESSAGE, message);
if (!isSuccess)
intentUpdate.putExtra(ACTION_FAILURE, failureMessage);
sendBroadcast(intentUpdate);
if (notificationBuilder != null) {
notificationBuilder.setContentText(getString(message));
if (progress == INDETERMINATE) {
notificationBuilder.setProgress(100, 50, true);
} else {
notificationBuilder.setProgress(100, progress, false);
}
mNotifyManager.notify(id, notificationBuilder.build());
}
}
@Override
public void onDestroy() {
super.onDestroy();
mNotifyManager.cancel(id);
publishProgress(null, R.string.loading, isSuccess ? SUCCESS : FAILURE);
}
}

View File

@ -0,0 +1,39 @@
package net.minetest.minetest;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.File;
public class Utils {
public static @NonNull File createDirs(File root, String dir) {
File f = new File(root, dir);
if (!f.isDirectory())
f.mkdirs();
return f;
}
public static @Nullable File getUserDataDirectory(Context context) {
File extDir = context.getExternalFilesDir(null);
if (extDir == null) {
return null;
}
return createDirs(extDir, "Minetest");
}
public static @Nullable File getCacheDirectory(Context context) {
return context.getCacheDir();
}
public static boolean isInstallValid(Context context) {
File userDataDirectory = getUserDataDirectory(context);
return userDataDirectory != null && userDataDirectory.isDirectory() &&
new File(userDataDirectory, "games").isDirectory() &&
new File(userDataDirectory, "builtin").isDirectory() &&
new File(userDataDirectory, "client").isDirectory() &&
new File(userDataDirectory, "textures").isDirectory();
}
}

View File

Before

Width:  |  Height:  |  Size: 83 B

After

Width:  |  Height:  |  Size: 83 B

View File

@ -1,4 +1,5 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -14,7 +15,8 @@
android:layout_marginRight="90dp"
android:indeterminate="false"
android:max="100"
android:visibility="gone" />
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/textView"
@ -25,6 +27,7 @@
android:background="@android:color/transparent"
android:text="@string/loading"
android:textColor="#FEFEFE"
android:visibility="gone" />
android:visibility="gone"
tools:visibility="visible" />
</RelativeLayout>

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -3,8 +3,11 @@
<string name="label">Minetest</string>
<string name="loading">Loading&#8230;</string>
<string name="migrating">Migrating save data from old install&#8230; (this may take a while)</string>
<string name="not_granted">Required permission wasn\'t granted, Minetest can\'t run without it</string>
<string name="notification_title">Loading Minetest</string>
<string name="notification_description">Less than 1 minute&#8230;</string>
<string name="ime_dialog_done">Done</string>
<string name="no_external_storage">External storage isn\'t available. If you use an SDCard, please reinsert it. Otherwise, try restarting your phone or contacting the Minetest developers</string>
</resources>

View File

@ -0,0 +1,3 @@
<paths>
<external-files-path path="Minetest/" name="minetest" />
</paths>

View File

@ -1,21 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
project.ext.set("versionMajor", 5) // Version Major
project.ext.set("versionMinor", 5) // Version Minor
project.ext.set("versionMinor", 6) // Version Minor
project.ext.set("versionPatch", 0) // Version Patch
project.ext.set("versionExtra", "-dev") // Version Extra
project.ext.set("versionCode", 32) // Android Version Code
project.ext.set("versionCode", 38) // Android Version Code
// NOTE: +2 after each release!
// +1 for ARM and +1 for ARM64 APK's, because
// each APK must have a larger `versionCode` than the previous
buildscript {
ext.ndk_version = '23.0.7599858'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'de.undercouch:gradle-download-task:4.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -1,6 +1,5 @@
#Fri Jan 08 17:52:00 UTC 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip

View File

@ -98,7 +98,7 @@ location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
command -v java >/dev/null || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,68 @@
apply plugin: 'com.android.library'
apply plugin: 'de.undercouch.download'
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
ndkVersion "$ndk_version"
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
externalNativeBuild {
ndkBuild {
arguments '-j' + Runtime.getRuntime().availableProcessors(),
"versionMajor=${versionMajor}",
"versionMinor=${versionMinor}",
"versionPatch=${versionPatch}",
"versionExtra=${versionExtra}"
}
}
}
externalNativeBuild {
ndkBuild {
path file('jni/Android.mk')
}
}
// supported architectures
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a'//, 'x86'
}
}
buildTypes {
release {
externalNativeBuild {
ndkBuild {
arguments 'NDEBUG=1'
}
}
ndk {
debugSymbolLevel 'SYMBOL_TABLE'
}
}
}
}
// get precompiled deps
task downloadDeps(type: Download) {
src 'https://github.com/minetest/minetest_android_deps/releases/download/latest/deps.zip'
dest new File(buildDir, 'deps.zip')
overwrite false
}
task getDeps(dependsOn: downloadDeps, type: Copy) {
def deps = new File(buildDir.parent, 'deps')
if (!deps.exists()) {
deps.mkdir()
from zipTree(downloadDeps.dest)
into deps
}
}
preBuild.dependsOn getDeps

View File

@ -0,0 +1,290 @@
LOCAL_PATH := $(call my-dir)/..
#LOCAL_ADDRESS_SANITIZER:=true
#USE_BUILTIN_LUA:=true
include $(CLEAR_VARS)
LOCAL_MODULE := Curl
LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libmbedcrypto
LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libmbedcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libmbedtls
LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libmbedtls.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libmbedx509
LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libmbedx509.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Freetype
LOCAL_SRC_FILES := deps/$(APP_ABI)/Freetype/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Iconv
LOCAL_SRC_FILES := deps/$(APP_ABI)/Iconv/libiconv.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcharset
LOCAL_SRC_FILES := deps/$(APP_ABI)/Iconv/libcharset.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Irrlicht
LOCAL_SRC_FILES := deps/$(APP_ABI)/Irrlicht/libIrrlichtMt.a
include $(PREBUILT_STATIC_LIBRARY)
ifndef USE_BUILTIN_LUA
include $(CLEAR_VARS)
LOCAL_MODULE := LuaJIT
LOCAL_SRC_FILES := deps/$(APP_ABI)/LuaJIT/libluajit.a
include $(PREBUILT_STATIC_LIBRARY)
endif
include $(CLEAR_VARS)
LOCAL_MODULE := OpenAL
LOCAL_SRC_FILES := deps/$(APP_ABI)/OpenAL-Soft/libopenal.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Gettext
LOCAL_SRC_FILES := deps/$(APP_ABI)/Gettext/libintl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := SQLite3
LOCAL_SRC_FILES := deps/$(APP_ABI)/SQLite/libsqlite3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Vorbis
LOCAL_SRC_FILES := deps/$(APP_ABI)/Vorbis/libvorbis.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvorbisfile
LOCAL_SRC_FILES := deps/$(APP_ABI)/Vorbis/libvorbisfile.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libogg
LOCAL_SRC_FILES := deps/$(APP_ABI)/Vorbis/libogg.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Zstd
LOCAL_SRC_FILES := deps/$(APP_ABI)/Zstd/libzstd.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Minetest
LOCAL_CFLAGS += \
-DJSONCPP_NO_LOCALE_SUPPORT \
-DHAVE_TOUCHSCREENGUI \
-DENABLE_GLES=1 \
-DUSE_CURL=1 \
-DUSE_SOUND=1 \
-DUSE_LEVELDB=0 \
-DUSE_GETTEXT=1 \
-DVERSION_MAJOR=${versionMajor} \
-DVERSION_MINOR=${versionMinor} \
-DVERSION_PATCH=${versionPatch} \
-DVERSION_EXTRA=${versionExtra} \
$(GPROF_DEF)
ifdef USE_BUILTIN_LUA
LOCAL_CFLAGS += -DUSE_LUAJIT=0
else
LOCAL_CFLAGS += -DUSE_LUAJIT=1
endif
ifdef NDEBUG
LOCAL_CFLAGS += -DNDEBUG=1
endif
ifdef GPROF
GPROF_DEF := -DGPROF
PROFILER_LIBS := android-ndk-profiler
LOCAL_CFLAGS += -pg
endif
LOCAL_C_INCLUDES := \
../../src \
../../src/script \
../../lib/gmp \
../../lib/jsoncpp \
deps/$(APP_ABI)/Curl/include \
deps/$(APP_ABI)/Freetype/include/freetype2 \
deps/$(APP_ABI)/Irrlicht/include \
deps/$(APP_ABI)/Gettext/include \
deps/$(APP_ABI)/Iconv/include \
deps/$(APP_ABI)/OpenAL-Soft/include \
deps/$(APP_ABI)/SQLite/include \
deps/$(APP_ABI)/Vorbis/include \
deps/$(APP_ABI)/Zstd/include
ifdef USE_BUILTIN_LUA
LOCAL_C_INCLUDES += \
../../lib/lua/src \
../../lib/bitop
else
LOCAL_C_INCLUDES += deps/$(APP_ABI)/LuaJIT/include
endif
LOCAL_SRC_FILES := \
$(wildcard ../../src/client/*.cpp) \
$(wildcard ../../src/client/*/*.cpp) \
$(wildcard ../../src/content/*.cpp) \
../../src/database/database.cpp \
../../src/database/database-dummy.cpp \
../../src/database/database-files.cpp \
../../src/database/database-sqlite3.cpp \
$(wildcard ../../src/gui/*.cpp) \
$(wildcard ../../src/irrlicht_changes/*.cpp) \
$(wildcard ../../src/mapgen/*.cpp) \
$(wildcard ../../src/network/*.cpp) \
$(wildcard ../../src/script/*.cpp) \
$(wildcard ../../src/script/*/*.cpp) \
$(wildcard ../../src/server/*.cpp) \
$(wildcard ../../src/threading/*.cpp) \
$(wildcard ../../src/util/*.c) \
$(wildcard ../../src/util/*.cpp) \
../../src/ban.cpp \
../../src/chat.cpp \
../../src/clientiface.cpp \
../../src/collision.cpp \
../../src/content_mapnode.cpp \
../../src/content_nodemeta.cpp \
../../src/convert_json.cpp \
../../src/craftdef.cpp \
../../src/debug.cpp \
../../src/defaultsettings.cpp \
../../src/emerge.cpp \
../../src/environment.cpp \
../../src/face_position_cache.cpp \
../../src/filesys.cpp \
../../src/gettext.cpp \
../../src/httpfetch.cpp \
../../src/hud.cpp \
../../src/inventory.cpp \
../../src/inventorymanager.cpp \
../../src/itemdef.cpp \
../../src/itemstackmetadata.cpp \
../../src/light.cpp \
../../src/log.cpp \
../../src/main.cpp \
../../src/map.cpp \
../../src/map_settings_manager.cpp \
../../src/mapblock.cpp \
../../src/mapnode.cpp \
../../src/mapsector.cpp \
../../src/metadata.cpp \
../../src/modchannels.cpp \
../../src/nameidmapping.cpp \
../../src/nodedef.cpp \
../../src/nodemetadata.cpp \
../../src/nodetimer.cpp \
../../src/noise.cpp \
../../src/objdef.cpp \
../../src/object_properties.cpp \
../../src/particles.cpp \
../../src/pathfinder.cpp \
../../src/player.cpp \
../../src/porting.cpp \
../../src/porting_android.cpp \
../../src/profiler.cpp \
../../src/raycast.cpp \
../../src/reflowscan.cpp \
../../src/remoteplayer.cpp \
../../src/rollback.cpp \
../../src/rollback_interface.cpp \
../../src/serialization.cpp \
../../src/server.cpp \
../../src/serverenvironment.cpp \
../../src/serverlist.cpp \
../../src/settings.cpp \
../../src/staticobject.cpp \
../../src/texture_override.cpp \
../../src/tileanimation.cpp \
../../src/tool.cpp \
../../src/translation.cpp \
../../src/version.cpp \
../../src/voxel.cpp \
../../src/voxelalgorithms.cpp
# Built-in Lua
ifdef USE_BUILTIN_LUA
LOCAL_SRC_FILES += \
../../lib/lua/src/lapi.c \
../../lib/lua/src/lauxlib.c \
../../lib/lua/src/lbaselib.c \
../../lib/lua/src/lcode.c \
../../lib/lua/src/ldblib.c \
../../lib/lua/src/ldebug.c \
../../lib/lua/src/ldo.c \
../../lib/lua/src/ldump.c \
../../lib/lua/src/lfunc.c \
../../lib/lua/src/lgc.c \
../../lib/lua/src/linit.c \
../../lib/lua/src/liolib.c \
../../lib/lua/src/llex.c \
../../lib/lua/src/lmathlib.c \
../../lib/lua/src/lmem.c \
../../lib/lua/src/loadlib.c \
../../lib/lua/src/lobject.c \
../../lib/lua/src/lopcodes.c \
../../lib/lua/src/loslib.c \
../../lib/lua/src/lparser.c \
../../lib/lua/src/lstate.c \
../../lib/lua/src/lstring.c \
../../lib/lua/src/lstrlib.c \
../../lib/lua/src/ltable.c \
../../lib/lua/src/ltablib.c \
../../lib/lua/src/ltm.c \
../../lib/lua/src/lundump.c \
../../lib/lua/src/lvm.c \
../../lib/lua/src/lzio.c \
../../lib/bitop/bit.c
endif
# GMP
LOCAL_SRC_FILES += ../../lib/gmp/mini-gmp.c
# JSONCPP
LOCAL_SRC_FILES += ../../lib/jsoncpp/jsoncpp.cpp
LOCAL_STATIC_LIBRARIES += \
Curl libmbedcrypto libmbedtls libmbedx509 \
Freetype \
Iconv libcharset \
Irrlicht \
OpenAL \
Gettext \
SQLite3 \
Vorbis libvorbisfile libogg \
Zstd
ifndef USE_BUILTIN_LUA
LOCAL_STATIC_LIBRARIES += LuaJIT
endif
LOCAL_STATIC_LIBRARIES += android_native_app_glue $(PROFILER_LIBS)
LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES
include $(BUILD_SHARED_LIBRARY)
ifdef GPROF
$(call import-module,android-ndk-profiler)
endif
$(call import-module,android/native_app_glue)

View File

@ -0,0 +1,32 @@
APP_PLATFORM := ${APP_PLATFORM}
APP_ABI := ${TARGET_ABI}
APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := clang
APP_SHORT_COMMANDS := true
APP_MODULES := Minetest
APP_CPPFLAGS := -O2 -fvisibility=hidden
ifeq ($(APP_ABI),armeabi-v7a)
APP_CPPFLAGS += -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb
endif
ifeq ($(APP_ABI),x86)
APP_CPPFLAGS += -mssse3 -mfpmath=sse -funroll-loops
endif
ifndef NDEBUG
APP_CPPFLAGS := -g -Og -fno-omit-frame-pointer
endif
APP_CFLAGS := $(APP_CPPFLAGS) -Wno-inconsistent-missing-override -Wno-parentheses-equality
APP_CXXFLAGS := $(APP_CPPFLAGS) -fexceptions -frtti -std=gnu++14
APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe
ifeq ($(APP_ABI),arm64-v8a)
APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections
endif
ifndef NDEBUG
APP_LDFLAGS :=
endif

View File

@ -1,82 +0,0 @@
/*
Minetest
Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2020 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.minetest.minetest;
import android.content.Intent;
import android.os.AsyncTask;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
public class CopyZipTask extends AsyncTask<String, Void, String> {
private final WeakReference<AppCompatActivity> activityRef;
CopyZipTask(AppCompatActivity activity) {
activityRef = new WeakReference<>(activity);
}
protected String doInBackground(String... params) {
copyAsset(params[0]);
return params[0];
}
@Override
protected void onPostExecute(String result) {
startUnzipService(result);
}
private void copyAsset(String zipName) {
String filename = zipName.substring(zipName.lastIndexOf("/") + 1);
try (InputStream in = activityRef.get().getAssets().open(filename);
OutputStream out = new FileOutputStream(zipName)) {
copyFile(in, out);
} catch (IOException e) {
AppCompatActivity activity = activityRef.get();
if (activity != null) {
activity.runOnUiThread(() -> Toast.makeText(activityRef.get(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show());
}
cancel(true);
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1)
out.write(buffer, 0, read);
}
private void startUnzipService(String file) {
Intent intent = new Intent(activityRef.get(), UnzipService.class);
intent.putExtra(UnzipService.EXTRA_KEY_IN_FILE, file);
AppCompatActivity activity = activityRef.get();
if (activity != null) {
activity.startService(intent);
}
}
}

View File

@ -1,157 +0,0 @@
/*
Minetest
Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2020 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.minetest.minetest;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Environment;
import android.widget.Toast;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
public class UnzipService extends IntentService {
public static final String ACTION_UPDATE = "net.minetest.minetest.UPDATE";
public static final String ACTION_PROGRESS = "net.minetest.minetest.PROGRESS";
public static final String ACTION_FAILURE = "net.minetest.minetest.FAILURE";
public static final String EXTRA_KEY_IN_FILE = "file";
public static final int SUCCESS = -1;
public static final int FAILURE = -2;
private final int id = 1;
private NotificationManager mNotifyManager;
private boolean isSuccess = true;
private String failureMessage;
public UnzipService() {
super("net.minetest.minetest.UnzipService");
}
private void isDir(String dir, String location) {
File f = new File(location, dir);
if (!f.isDirectory())
f.mkdirs();
}
@Override
protected void onHandleIntent(Intent intent) {
createNotification();
unzip(intent);
}
private void createNotification() {
String name = "net.minetest.minetest";
String channelId = "Minetest channel";
String description = "notifications from Minetest";
Notification.Builder builder;
if (mNotifyManager == null)
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = null;
if (mNotifyManager != null)
mChannel = mNotifyManager.getNotificationChannel(channelId);
if (mChannel == null) {
mChannel = new NotificationChannel(channelId, name, importance);
mChannel.setDescription(description);
// Configure the notification channel, NO SOUND
mChannel.setSound(null, null);
mChannel.enableLights(false);
mChannel.enableVibration(false);
mNotifyManager.createNotificationChannel(mChannel);
}
builder = new Notification.Builder(this, channelId);
} else {
builder = new Notification.Builder(this);
}
builder.setContentTitle(getString(R.string.notification_title))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText(getString(R.string.notification_description));
mNotifyManager.notify(id, builder.build());
}
private void unzip(Intent intent) {
String zip = intent.getStringExtra(EXTRA_KEY_IN_FILE);
isDir("Minetest", Environment.getExternalStorageDirectory().toString());
String location = Environment.getExternalStorageDirectory() + File.separator + "Minetest" + File.separator;
int per = 0;
int size = getSummarySize(zip);
File zipFile = new File(zip);
int readLen;
byte[] readBuffer = new byte[8192];
try (FileInputStream fileInputStream = new FileInputStream(zipFile);
ZipInputStream zipInputStream = new ZipInputStream(fileInputStream)) {
ZipEntry ze;
while ((ze = zipInputStream.getNextEntry()) != null) {
if (ze.isDirectory()) {
++per;
isDir(ze.getName(), location);
} else {
publishProgress(100 * ++per / size);
try (OutputStream outputStream = new FileOutputStream(location + ze.getName())) {
while ((readLen = zipInputStream.read(readBuffer)) != -1) {
outputStream.write(readBuffer, 0, readLen);
}
}
}
zipFile.delete();
}
} catch (IOException e) {
isSuccess = false;
failureMessage = e.getLocalizedMessage();
}
}
private void publishProgress(int progress) {
Intent intentUpdate = new Intent(ACTION_UPDATE);
intentUpdate.putExtra(ACTION_PROGRESS, progress);
if (!isSuccess) intentUpdate.putExtra(ACTION_FAILURE, failureMessage);
sendBroadcast(intentUpdate);
}
private int getSummarySize(String zip) {
int size = 0;
try {
ZipFile zipSize = new ZipFile(zip);
size += zipSize.size();
} catch (IOException e) {
Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
return size;
}
@Override
public void onDestroy() {
super.onDestroy();
mNotifyManager.cancel(id);
publishProgress(isSuccess ? SUCCESS : FAILURE);
}
}

View File

@ -1,98 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'de.undercouch.download'
android {
compileSdkVersion 29
buildToolsVersion '30.0.3'
ndkVersion '22.0.7026061'
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
externalNativeBuild {
ndkBuild {
arguments '-j' + Runtime.getRuntime().availableProcessors(),
"versionMajor=${versionMajor}",
"versionMinor=${versionMinor}",
"versionPatch=${versionPatch}",
"versionExtra=${versionExtra}"
}
}
}
externalNativeBuild {
ndkBuild {
path file('jni/Android.mk')
}
}
// supported architectures
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a'//, 'x86'
}
}
buildTypes {
release {
externalNativeBuild {
ndkBuild {
arguments 'NDEBUG=1'
}
}
}
}
}
// get precompiled deps
def folder = 'minetest_android_deps_binaries'
task downloadDeps(type: Download) {
src 'https://github.com/minetest/' + folder + '/archive/master.zip'
dest new File(buildDir, 'deps.zip')
overwrite false
}
task getDeps(dependsOn: downloadDeps, type: Copy) {
def deps = file('deps')
def f = file("$buildDir/" + folder + "-master")
if (!deps.exists() && !f.exists()) {
from zipTree(downloadDeps.dest)
into buildDir
}
doLast {
if (!deps.exists()) {
file(f).renameTo(file(deps))
}
}
}
// get sqlite
def sqlite_ver = '3340000'
task downloadSqlite(dependsOn: getDeps, type: Download) {
src 'https://www.sqlite.org/2020/sqlite-amalgamation-' + sqlite_ver + '.zip'
dest new File(buildDir, 'sqlite.zip')
overwrite false
}
task getSqlite(dependsOn: downloadSqlite, type: Copy) {
def sqlite = file('deps/Android/sqlite')
def f = file("$buildDir/sqlite-amalgamation-" + sqlite_ver)
if (!sqlite.exists() && !f.exists()) {
from zipTree(downloadSqlite.dest)
into buildDir
}
doLast {
if (!sqlite.exists()) {
file(f).renameTo(file(sqlite))
}
}
}
preBuild.dependsOn getDeps
preBuild.dependsOn getSqlite

View File

@ -1,219 +0,0 @@
LOCAL_PATH := $(call my-dir)/..
#LOCAL_ADDRESS_SANITIZER:=true
include $(CLEAR_VARS)
LOCAL_MODULE := Curl
LOCAL_SRC_FILES := deps/Android/Curl/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Freetype
LOCAL_SRC_FILES := deps/Android/Freetype/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Irrlicht
LOCAL_SRC_FILES := deps/Android/Irrlicht/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libIrrlicht.a
include $(PREBUILT_STATIC_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := LevelDB
#LOCAL_SRC_FILES := deps/Android/LevelDB/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libleveldb.a
#include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := LuaJIT
LOCAL_SRC_FILES := deps/Android/LuaJIT/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libluajit.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mbedTLS
LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedtls.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mbedx509
LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedx509.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mbedcrypto
LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OpenAL
LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libopenal.a
include $(PREBUILT_STATIC_LIBRARY)
# You can use `OpenSSL and Crypto` instead `mbedTLS mbedx509 mbedcrypto`,
#but it increase APK size on ~0.7MB
#include $(CLEAR_VARS)
#LOCAL_MODULE := OpenSSL
#LOCAL_SRC_FILES := deps/Android/OpenSSL/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libssl.a
#include $(PREBUILT_STATIC_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := Crypto
#LOCAL_SRC_FILES := deps/Android/OpenSSL/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcrypto.a
#include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Vorbis
LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Minetest
LOCAL_CFLAGS += \
-DJSONCPP_NO_LOCALE_SUPPORT \
-DHAVE_TOUCHSCREENGUI \
-DENABLE_GLES=1 \
-DUSE_CURL=1 \
-DUSE_SOUND=1 \
-DUSE_FREETYPE=1 \
-DUSE_LEVELDB=0 \
-DUSE_LUAJIT=1 \
-DVERSION_MAJOR=${versionMajor} \
-DVERSION_MINOR=${versionMinor} \
-DVERSION_PATCH=${versionPatch} \
-DVERSION_EXTRA=${versionExtra} \
$(GPROF_DEF)
ifdef NDEBUG
LOCAL_CFLAGS += -DNDEBUG=1
endif
ifdef GPROF
GPROF_DEF := -DGPROF
PROFILER_LIBS := android-ndk-profiler
LOCAL_CFLAGS += -pg
endif
LOCAL_C_INCLUDES := \
../../../src \
../../../src/script \
../../../lib/gmp \
../../../lib/jsoncpp \
deps/Android/Curl/include \
deps/Android/Freetype/include \
deps/Android/Irrlicht/include \
deps/Android/LevelDB/include \
deps/Android/libiconv/include \
deps/Android/libiconv/libcharset/include \
deps/Android/LuaJIT/src \
deps/Android/OpenAL-Soft/include \
deps/Android/sqlite \
deps/Android/Vorbis/include
LOCAL_SRC_FILES := \
$(wildcard ../../../src/client/*.cpp) \
$(wildcard ../../../src/client/*/*.cpp) \
$(wildcard ../../../src/content/*.cpp) \
../../../src/database/database.cpp \
../../../src/database/database-dummy.cpp \
../../../src/database/database-files.cpp \
../../../src/database/database-sqlite3.cpp \
$(wildcard ../../../src/gui/*.cpp) \
$(wildcard ../../../src/irrlicht_changes/*.cpp) \
$(wildcard ../../../src/mapgen/*.cpp) \
$(wildcard ../../../src/network/*.cpp) \
$(wildcard ../../../src/script/*.cpp) \
$(wildcard ../../../src/script/*/*.cpp) \
$(wildcard ../../../src/server/*.cpp) \
$(wildcard ../../../src/threading/*.cpp) \
$(wildcard ../../../src/util/*.c) \
$(wildcard ../../../src/util/*.cpp) \
../../../src/ban.cpp \
../../../src/chat.cpp \
../../../src/clientiface.cpp \
../../../src/collision.cpp \
../../../src/content_mapnode.cpp \
../../../src/content_nodemeta.cpp \
../../../src/convert_json.cpp \
../../../src/craftdef.cpp \
../../../src/debug.cpp \
../../../src/defaultsettings.cpp \
../../../src/emerge.cpp \
../../../src/environment.cpp \
../../../src/face_position_cache.cpp \
../../../src/filesys.cpp \
../../../src/gettext.cpp \
../../../src/httpfetch.cpp \
../../../src/hud.cpp \
../../../src/inventory.cpp \
../../../src/inventorymanager.cpp \
../../../src/itemdef.cpp \
../../../src/itemstackmetadata.cpp \
../../../src/light.cpp \
../../../src/log.cpp \
../../../src/main.cpp \
../../../src/map.cpp \
../../../src/map_settings_manager.cpp \
../../../src/mapblock.cpp \
../../../src/mapnode.cpp \
../../../src/mapsector.cpp \
../../../src/metadata.cpp \
../../../src/modchannels.cpp \
../../../src/nameidmapping.cpp \
../../../src/nodedef.cpp \
../../../src/nodemetadata.cpp \
../../../src/nodetimer.cpp \
../../../src/noise.cpp \
../../../src/objdef.cpp \
../../../src/object_properties.cpp \
../../../src/particles.cpp \
../../../src/pathfinder.cpp \
../../../src/player.cpp \
../../../src/porting.cpp \
../../../src/porting_android.cpp \
../../../src/profiler.cpp \
../../../src/raycast.cpp \
../../../src/reflowscan.cpp \
../../../src/remoteplayer.cpp \
../../../src/rollback.cpp \
../../../src/rollback_interface.cpp \
../../../src/serialization.cpp \
../../../src/server.cpp \
../../../src/serverenvironment.cpp \
../../../src/serverlist.cpp \
../../../src/settings.cpp \
../../../src/staticobject.cpp \
../../../src/texture_override.cpp \
../../../src/tileanimation.cpp \
../../../src/tool.cpp \
../../../src/translation.cpp \
../../../src/version.cpp \
../../../src/voxel.cpp \
../../../src/voxelalgorithms.cpp
# LevelDB backend is disabled
# ../../../src/database/database-leveldb.cpp
# GMP
LOCAL_SRC_FILES += ../../../lib/gmp/mini-gmp.c
# JSONCPP
LOCAL_SRC_FILES += ../../../lib/jsoncpp/jsoncpp.cpp
# iconv
LOCAL_SRC_FILES += \
deps/Android/libiconv/lib/iconv.c \
deps/Android/libiconv/libcharset/lib/localcharset.c
# SQLite3
LOCAL_SRC_FILES += deps/Android/sqlite/sqlite3.c
LOCAL_STATIC_LIBRARIES += Curl Freetype Irrlicht OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT android_native_app_glue $(PROFILER_LIBS) #LevelDB
#OpenSSL Crypto
LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES
include $(BUILD_SHARED_LIBRARY)
ifdef GPROF
$(call import-module,android-ndk-profiler)
endif
$(call import-module,android/native_app_glue)

View File

@ -1,32 +0,0 @@
APP_PLATFORM := ${APP_PLATFORM}
APP_ABI := ${TARGET_ABI}
APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := clang
APP_SHORT_COMMANDS := true
APP_MODULES := Minetest
APP_CPPFLAGS := -Ofast -fvisibility=hidden -fexceptions -Wno-deprecated-declarations -Wno-extra-tokens
ifeq ($(APP_ABI),armeabi-v7a)
APP_CPPFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb
endif
#ifeq ($(APP_ABI),x86)
#APP_CPPFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops
#endif
ifndef NDEBUG
APP_CPPFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer -fexceptions
endif
APP_CFLAGS := $(APP_CPPFLAGS) -Wno-parentheses-equality #-Werror=shorten-64-to-32
APP_CXXFLAGS := $(APP_CPPFLAGS) -frtti -std=gnu++17
APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe
ifeq ($(APP_ABI),arm64-v8a)
APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections
endif
ifndef NDEBUG
APP_LDFLAGS :=
endif

46
builtin/async/game.lua Normal file
View File

@ -0,0 +1,46 @@
core.log("info", "Initializing asynchronous environment (game)")
local function pack2(...)
return {n=select('#', ...), ...}
end
-- Entrypoint to run async jobs, called by C++
function core.job_processor(func, params)
local retval = pack2(func(unpack(params, 1, params.n)))
return retval
end
-- Import a bunch of individual files from builtin/game/
local gamepath = core.get_builtin_path() .. "game" .. DIR_DELIM
local commonpath = core.get_builtin_path() .. "common" .. DIR_DELIM
dofile(gamepath .. "constants.lua")
dofile(gamepath .. "item_s.lua")
dofile(gamepath .. "misc_s.lua")
dofile(gamepath .. "features.lua")
dofile(commonpath .. "voxelarea.lua")
-- Transfer of globals
do
local all = assert(core.transferred_globals)
core.transferred_globals = nil
-- reassemble other tables
all.registered_nodes = {}
all.registered_craftitems = {}
all.registered_tools = {}
for k, v in pairs(all.registered_items) do
if v.type == "node" then
all.registered_nodes[k] = v
elseif v.type == "craftitem" then
all.registered_craftitems[k] = v
elseif v.type == "tool" then
all.registered_tools[k] = v
end
end
for k, v in pairs(all) do
core[k] = v
end
end

View File

@ -1,17 +0,0 @@
core.log("info", "Initializing Asynchronous environment")
function core.job_processor(serialized_func, serialized_param)
local func = loadstring(serialized_func)
local param = core.deserialize(serialized_param)
local retval = nil
if type(func) == "function" then
retval = core.serialize(func(param))
else
core.log("error", "ASYNC WORKER: Unable to deserialize function")
end
return retval or core.serialize(nil)
end

View File

@ -0,0 +1,9 @@
core.log("info", "Initializing asynchronous environment")
function core.job_processor(func, serialized_param)
local param = core.deserialize(serialized_param)
local retval = core.serialize(func(param))
return retval or core.serialize(nil)
end

View File

@ -12,6 +12,8 @@ core.cheats = {
["NoSlow"] = "no_slow",
["JetPack"] = "jetpack",
["AntiSlip"] = "antislip",
["AirJump"] = "airjump",
["Spider"] = "spider",
},
["Render"] = {
["Xray"] = "xray",

View File

@ -1,8 +1,8 @@
local death_formspec = ""
.. "size[11,5.5]"
.. "bgcolor[#320000b4;true]"
.. "label[4.85,1.35;" .. "You died" .. "]"
.. "button_exit[2,3;3,0.5;btn_respawn;" .. "Respawn" .. "]"
.. "label[4.85,1.35;" .. fgettext("You died") .. "]"
.. "button_exit[2,3;3,0.5;btn_respawn;" .. fgettext("Respawn") .. "]"
.. "button_exit[6,3;3,0.5;btn_ghost_mode;" .. "Ghost Mode" .. "]"
.. "set_focus[btn_respawn;true]"

View File

@ -7,6 +7,7 @@ dofile(clientpath .. "register.lua")
dofile(commonpath .. "after.lua")
dofile(commonpath .. "chatcommands.lua")
dofile(commonpath .. "vector.lua")
dofile(commonpath .. "voxelarea.lua")
dofile(clientpath .. "util.lua")
dofile(clientpath .. "chatcommands.lua")
dofile(clientpath .. "death_formspec.lua")

View File

@ -1,4 +1,3 @@
core.callback_origins = {}
local getinfo = debug.getinfo
@ -105,6 +104,10 @@ core.registered_on_inventory_open, core.register_on_inventory_open = make_regist
core.registered_on_recieve_physics_override, core.register_on_recieve_physics_override = make_registration()
core.registered_on_play_sound, core.register_on_play_sound = make_registration()
core.registered_on_spawn_particle, core.register_on_spawn_particle = make_registration()
core.registered_on_object_properties_change, core.register_on_object_properties_change = make_registration()
core.registered_on_object_hp_change, core.register_on_object_hp_change = make_registration()
core.registered_on_object_add, core.register_on_object_add = make_registration()
core.registered_nodes = {}
core.registered_items = {}
core.object_refs = {}

View File

@ -37,7 +37,14 @@ function core.after(after, func, ...)
arg = {...},
mod_origin = core.get_last_run_mod(),
}
jobs[#jobs + 1] = new_job
time_next = math.min(time_next, expire)
return { cancel = function() new_job.func = function() end end }
return {
cancel = function()
new_job.func = function() end
new_job.args = {}
end
}
end

View File

@ -6,6 +6,42 @@ local S = core.get_translator("__builtin")
core.registered_chatcommands = {}
-- Interpret the parameters of a command, separating options and arguments.
-- Input: command, param
-- command: name of command
-- param: parameters of command
-- Returns: opts, args
-- opts is a string of option letters, or false on error
-- args is an array with the non-option arguments in order, or an error message
-- Example: for this command line:
-- /command a b -cd e f -g
-- the function would receive:
-- a b -cd e f -g
-- and it would return:
-- "cdg", {"a", "b", "e", "f"}
-- Negative numbers are taken as arguments. Long options (--option) are
-- currently rejected as reserved.
local function getopts(command, param)
local opts = ""
local args = {}
for match in param:gmatch("%S+") do
if match:byte(1) == 45 then -- 45 = '-'
local second = match:byte(2)
if second == 45 then
return false, S("Invalid parameters (see /help @1).", command)
elseif second and (second < 48 or second > 57) then -- 48 = '0', 57 = '9'
opts = opts .. match:sub(2)
else
-- numeric, add it to args
args[#args + 1] = match
end
else
args[#args + 1] = match
end
end
return opts, args
end
function core.register_chatcommand(cmd, def)
def = def or {}
def.params = def.params or ""
@ -38,6 +74,7 @@ if INIT == "client" then
local def = {}
def.description = desc
def.params = "del <item> | add <item> | list"
def.list_setting = setting
function def.func(param)
local list = (minetest.settings:get(setting) or ""):split(",")
if param == "list" then
@ -78,22 +115,30 @@ if INIT == "client" then
end
end
local function do_help_cmd(name, param)
local function format_help_line(cmd, def)
local cmd_marker = "/"
if INIT == "client" then
cmd_marker = "."
end
local msg = core.colorize("#00ffff", cmd_marker .. cmd)
if def.params and def.params ~= "" then
msg = msg .. " " .. def.params
end
if def.description and def.description ~= "" then
msg = msg .. ": " .. def.description
end
return msg
local function format_help_line(cmd, def)
local cmd_marker = INIT == "client" and "." or "/"
local msg = core.colorize("#00ffff", cmd_marker .. cmd)
if def.params and def.params ~= "" then
msg = msg .. " " .. def.params
end
if param == "" then
if def.description and def.description ~= "" then
msg = msg .. ": " .. def.description
end
return msg
end
local function do_help_cmd(name, param)
local opts, args = getopts("help", param)
if not opts then
return false, args
end
if #args > 1 then
return false, S("Too many arguments, try using just /help <command>")
end
local use_gui = INIT ~= "client" and core.get_player_by_name(name)
use_gui = use_gui and not opts:find("t")
if #args == 0 and not use_gui then
local cmds = {}
for cmd, def in pairs(core.registered_chatcommands) do
if INIT == "client" or core.check_player_privs(name, def.privs) then
@ -116,7 +161,10 @@ local function do_help_cmd(name, param)
.. "everything.")
end
return true, msg
elseif param == "all" then
elseif #args == 0 or (args[1] == "all" and use_gui) then
core.show_general_help_formspec(name)
return true
elseif args[1] == "all" then
local cmds = {}
for cmd, def in pairs(core.registered_chatcommands) do
if INIT == "client" or core.check_player_privs(name, def.privs) then
@ -131,7 +179,11 @@ local function do_help_cmd(name, param)
msg = core.gettext("Available commands:")
end
return true, msg.."\n"..table.concat(cmds, "\n")
elseif INIT == "game" and param == "privs" then
elseif INIT == "game" and args[1] == "privs" then
if use_gui then
core.show_privs_help_formspec(name)
return true
end
local privs = {}
for priv, def in pairs(core.registered_privileges) do
privs[#privs + 1] = priv .. ": " .. def.description
@ -139,7 +191,7 @@ local function do_help_cmd(name, param)
table.sort(privs)
return true, S("Available privileges:").."\n"..table.concat(privs, "\n")
else
local cmd = param
local cmd = args[1]
local def = core.registered_chatcommands[cmd]
if not def then
local msg
@ -165,8 +217,8 @@ if INIT == "client" then
})
else
core.register_chatcommand("help", {
params = S("[all | privs | <cmd>]"),
description = S("Get help for commands or list privileges"),
params = S("[all | privs | <cmd>] [-t]"),
description = S("Get help for commands or list privileges (-t: output in chat)"),
func = do_help_cmd,
})
end

View File

@ -22,7 +22,6 @@ local LIST_FORMSPEC_DESCRIPTION = [[
local F = core.formspec_escape
local S = core.get_translator("__builtin")
local check_player_privs = core.check_player_privs
-- CHAT COMMANDS FORMSPEC
@ -58,10 +57,11 @@ local function build_chatcommands_formspec(name, sel, copy)
.. "any entry in the list.").. "\n" ..
S("Double-click to copy the entry to the chat history.")
local privs = core.get_player_privs(name)
for i, data in ipairs(mod_cmds) do
rows[#rows + 1] = COLOR_BLUE .. ",0," .. F(data[1]) .. ","
for j, cmds in ipairs(data[2]) do
local has_priv = check_player_privs(name, cmds[2].privs)
local has_priv = privs[cmds[2].privs]
rows[#rows + 1] = ("%s,1,%s,%s"):format(
has_priv and COLOR_GREEN or COLOR_GRAY,
cmds[1], F(cmds[2].params))
@ -125,30 +125,12 @@ core.register_on_player_receive_fields(function(player, formname, fields)
end
end)
local help_command = core.registered_chatcommands["help"]
local old_help_func = help_command.func
help_command.func = function(name, param)
local admin = core.settings:get("name")
-- If the admin ran help, put the output in the chat buffer as well to
-- work with the server terminal
if param == "privs" then
core.show_formspec(name, "__builtin:help_privs",
build_privs_formspec(name))
if name ~= admin then
return true
end
end
if param == "" or param == "all" then
core.show_formspec(name, "__builtin:help_cmds",
build_chatcommands_formspec(name))
if name ~= admin then
return true
end
end
return old_help_func(name, param)
function core.show_general_help_formspec(name)
core.show_formspec(name, "__builtin:help_cmds",
build_chatcommands_formspec(name))
end
function core.show_privs_help_formspec(name)
core.show_formspec(name, "__builtin:help_privs",
build_privs_formspec(name))
end

View File

@ -204,19 +204,12 @@ end
--------------------------------------------------------------------------------
function string:trim()
return (self:gsub("^%s*(.-)%s*$", "%1"))
return self:match("^%s*(.-)%s*$")
end
--------------------------------------------------------------------------------
function math.hypot(x, y)
local t
x = math.abs(x)
y = math.abs(y)
t = math.min(x, y)
x = math.max(x, y)
if x == 0 then return 0 end
t = t / x
return x * math.sqrt(1 + t * t)
return math.sqrt(x * x + y * y)
end
--------------------------------------------------------------------------------
@ -244,15 +237,24 @@ function math.factorial(x)
return v
end
function core.formspec_escape(text)
if text ~= nil then
text = string.gsub(text,"\\","\\\\")
text = string.gsub(text,"%]","\\]")
text = string.gsub(text,"%[","\\[")
text = string.gsub(text,";","\\;")
text = string.gsub(text,",","\\,")
function math.round(x)
if x >= 0 then
return math.floor(x + 0.5)
end
return text
return math.ceil(x - 0.5)
end
local formspec_escapes = {
["\\"] = "\\\\",
["["] = "\\[",
["]"] = "\\]",
[";"] = "\\;",
[","] = "\\,"
}
function core.formspec_escape(text)
-- Use explicit character set instead of dot here because it doubles the performance
return text and string.gsub(text, "[\\%[%];,]", formspec_escapes)
end
@ -263,18 +265,21 @@ function core.wrap_text(text, max_length, as_table)
return as_table and {text} or text
end
for word in text:gmatch('%S+') do
local cur_length = #table.concat(line, ' ')
if cur_length > 0 and cur_length + #word + 1 >= max_length then
local line_length = 0
for word in text:gmatch("%S+") do
if line_length > 0 and line_length + #word + 1 >= max_length then
-- word wouldn't fit on current line, move to next line
table.insert(result, table.concat(line, ' '))
line = {}
table.insert(result, table.concat(line, " "))
line = {word}
line_length = #word
else
table.insert(line, word)
line_length = line_length + 1 + #word
end
table.insert(line, word)
end
table.insert(result, table.concat(line, ' '))
return as_table and result or table.concat(result, '\n')
table.insert(result, table.concat(line, " "))
return as_table and result or table.concat(result, "\n")
end
--------------------------------------------------------------------------------
@ -423,56 +428,50 @@ function core.string_to_pos(value)
return nil
end
local p = {}
p.x, p.y, p.z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
p.x = tonumber(p.x)
p.y = tonumber(p.y)
p.z = tonumber(p.z)
return p
end
p = {}
p.x, p.y, p.z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
if p.x and p.y and p.z then
p.x = tonumber(p.x)
p.y = tonumber(p.y)
p.z = tonumber(p.z)
return p
value = value:match("^%((.-)%)$") or value -- strip parentheses
local x, y, z = value:trim():match("^([%d.-]+)[,%s]%s*([%d.-]+)[,%s]%s*([%d.-]+)$")
if x and y and z then
x = tonumber(x)
y = tonumber(y)
z = tonumber(z)
return vector.new(x, y, z)
end
return nil
end
--------------------------------------------------------------------------------
function core.string_to_area(value)
local p1, p2 = unpack(value:split(") ("))
if p1 == nil or p2 == nil then
return nil
do
local rel_num_cap = "(~?-?%d*%.?%d*)" -- may be overly permissive as this will be tonumber'ed anyways
local num_delim = "[,%s]%s*"
local pattern = "^" .. table.concat({rel_num_cap, rel_num_cap, rel_num_cap}, num_delim) .. "$"
local function parse_area_string(pos, relative_to)
local pp = {}
pp.x, pp.y, pp.z = pos:trim():match(pattern)
return core.parse_coordinates(pp.x, pp.y, pp.z, relative_to)
end
p1 = core.string_to_pos(p1 .. ")")
p2 = core.string_to_pos("(" .. p2)
if p1 == nil or p2 == nil then
return nil
function core.string_to_area(value, relative_to)
local p1, p2 = value:match("^%((.-)%)%s*%((.-)%)$")
if not p1 then
return
end
p1 = parse_area_string(p1, relative_to)
p2 = parse_area_string(p2, relative_to)
if p1 == nil or p2 == nil then
return
end
return p1, p2
end
return p1, p2
end
local function test_string_to_area()
local p1, p2 = core.string_to_area("(10.0, 5, -2) ( 30.2, 4, -12.53)")
assert(p1.x == 10.0 and p1.y == 5 and p1.z == -2)
assert(p2.x == 30.2 and p2.y == 4 and p2.z == -12.53)
p1, p2 = core.string_to_area("(10.0, 5, -2 30.2, 4, -12.53")
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(10.0, 5,) -2 fgdf2, 4, -12.53")
assert(p1 == nil and p2 == nil)
end
test_string_to_area()
--------------------------------------------------------------------------------
function table.copy(t, seen)
local n = {}
@ -543,7 +542,7 @@ if INIT == "mainmenu" then
end
end
if INIT == "client" or INIT == "mainmenu" then
if core.gettext then -- for client and mainmenu
function fgettext_ne(text, ...)
text = core.gettext(text)
local arg = {n=select('#', ...), ...}
@ -785,3 +784,80 @@ end
function core.is_nan(number)
return number ~= number
end
--[[ Helper function for parsing an optionally relative number
of a chat command parameter, using the chat command tilde notation.
Parameters:
* arg: String snippet containing the number; possible values:
* "<number>": return as number
* "~<number>": return relative_to + <number>
* "~": return relative_to
* Anything else will return `nil`
* relative_to: Number to which the `arg` number might be relative to
Returns:
A number or `nil`, depending on `arg.
Examples:
* `core.parse_relative_number("5", 10)` returns 5
* `core.parse_relative_number("~5", 10)` returns 15
* `core.parse_relative_number("~", 10)` returns 10
]]
function core.parse_relative_number(arg, relative_to)
if not arg then
return nil
elseif arg == "~" then
return relative_to
elseif string.sub(arg, 1, 1) == "~" then
local number = tonumber(string.sub(arg, 2))
if not number then
return nil
end
if core.is_nan(number) or number == math.huge or number == -math.huge then
return nil
end
return relative_to + number
else
local number = tonumber(arg)
if core.is_nan(number) or number == math.huge or number == -math.huge then
return nil
end
return number
end
end
--[[ Helper function to parse coordinates that might be relative
to another position; supports chat command tilde notation.
Intended to be used in chat command parameter parsing.
Parameters:
* x, y, z: Parsed x, y, and z coordinates as strings
* relative_to: Position to which to compare the position
Syntax of x, y and z:
* "<number>": return as number
* "~<number>": return <number> + player position on this axis
* "~": return player position on this axis
Returns: a vector or nil for invalid input or if player does not exist
]]
function core.parse_coordinates(x, y, z, relative_to)
if not relative_to then
x, y, z = tonumber(x), tonumber(y), tonumber(z)
return x and y and z and { x = x, y = y, z = z }
end
local rx = core.parse_relative_number(x, relative_to.x)
local ry = core.parse_relative_number(y, relative_to.y)
local rz = core.parse_relative_number(z, relative_to.z)
return rx and ry and rz and { x = rx, y = ry, z = rz }
end
function core.inventorycube(img1, img2, img3)
img2 = img2 or img1
img3 = img3 or img1
return "[inventorycube"
.. "{" .. img1:gsub("%^", "&")
.. "{" .. img2:gsub("%^", "&")
.. "{" .. img3:gsub("%^", "&")
end

View File

@ -1,8 +1,3 @@
-- Always warn when creating a global variable, even outside of a function.
-- This ignores mod namespaces (variables with the same name as the current mod).
local WARN_INIT = false
local getinfo = debug.getinfo
function core.global_exists(name)
@ -33,11 +28,6 @@ function meta:__newindex(name, value)
end
declared[name] = true
end
-- Ignore mod namespaces
if WARN_INIT and name ~= core.get_current_modname() then
core.log("warning", ("Global variable %q created at %s.")
:format(name, desc))
end
rawset(self, name, value)
end
@ -54,4 +44,3 @@ function meta:__index(name)
end
setmetatable(_G, meta)

View File

@ -1,4 +1,6 @@
_G.core = {}
_G.vector = {metatable = {}}
dofile("builtin/common/vector.lua")
dofile("builtin/common/misc_helpers.lua")
describe("string", function()
@ -55,8 +57,8 @@ end)
describe("pos", function()
it("from string", function()
assert.same({ x = 10, y = 5.1, z = -2}, core.string_to_pos("10.0, 5.1, -2"))
assert.same({ x = 10, y = 5.1, z = -2}, core.string_to_pos("( 10.0, 5.1, -2)"))
assert.equal(vector.new(10, 5.1, -2), core.string_to_pos("10.0, 5.1, -2"))
assert.equal(vector.new(10, 5.1, -2), core.string_to_pos("( 10.0, 5.1, -2)"))
assert.is_nil(core.string_to_pos("asd, 5, -2)"))
end)
@ -65,9 +67,107 @@ describe("pos", function()
end)
end)
describe("area parsing", function()
describe("valid inputs", function()
it("accepts absolute numbers", function()
local p1, p2 = core.string_to_area("(10.0, 5, -2) ( 30.2 4 -12.53)")
assert(p1.x == 10 and p1.y == 5 and p1.z == -2)
assert(p2.x == 30.2 and p2.y == 4 and p2.z == -12.53)
end)
it("accepts relative numbers", function()
local p1, p2 = core.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})
assert(type(p1) == "table" and type(p2) == "table")
assert(p1.x == 1 and p1.y == 2 and p1.z == 3)
assert(p2.x == 15 and p2.y == 5 and p2.z == 10)
p1, p2 = core.string_to_area("(1 2 3) (~5 ~-5 ~)", {x=10,y=10,z=10})
assert(type(p1) == "table" and type(p2) == "table")
assert(p1.x == 1 and p1.y == 2 and p1.z == 3)
assert(p2.x == 15 and p2.y == 5 and p2.z == 10)
end)
end)
describe("invalid inputs", function()
it("rejects too few numbers", function()
local p1, p2 = core.string_to_area("(1,1) (1,1,1,1)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
end)
it("rejects too many numbers", function()
local p1, p2 = core.string_to_area("(1,1,1,1) (1,1,1,1)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
end)
it("rejects nan & inf", function()
local p1, p2 = core.string_to_area("(1,1,1) (1,1,nan)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(1,1,1) (1,1,~nan)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(1,1,1) (1,~nan,1)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(1,1,1) (1,1,inf)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(1,1,1) (1,1,~inf)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(1,1,1) (1,~inf,1)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(nan,nan,nan) (nan,nan,nan)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(nan,nan,nan) (nan,nan,nan)")
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(inf,inf,inf) (-inf,-inf,-inf)", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(inf,inf,inf) (-inf,-inf,-inf)")
assert(p1 == nil and p2 == nil)
end)
it("rejects words", function()
local p1, p2 = core.string_to_area("bananas", {x=1,y=1,z=1})
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("bananas", "foobar")
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("bananas")
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(bananas,bananas,bananas)")
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(bananas,bananas,bananas) (bananas,bananas,bananas)")
assert(p1 == nil and p2 == nil)
end)
it("requires parenthesis & valid numbers", function()
local p1, p2 = core.string_to_area("(10.0, 5, -2 30.2, 4, -12.53")
assert(p1 == nil and p2 == nil)
p1, p2 = core.string_to_area("(10.0, 5,) -2 fgdf2, 4, -12.53")
assert(p1 == nil and p2 == nil)
end)
end)
end)
describe("table", function()
it("indexof()", function()
assert.equal(1, table.indexof({"foo", "bar"}, "foo"))
assert.equal(-1, table.indexof({"foo", "bar"}, "baz"))
end)
end)
describe("formspec_escape", function()
it("escapes", function()
assert.equal(nil, core.formspec_escape(nil))
assert.equal("", core.formspec_escape(""))
assert.equal("\\[Hello\\\\\\[", core.formspec_escape("[Hello\\["))
end)
end)

View File

@ -1,8 +1,10 @@
_G.core = {}
_G.vector = {metatable = {}}
_G.setfenv = require 'busted.compatibility'.setfenv
dofile("builtin/common/serialize.lua")
dofile("builtin/common/vector.lua")
describe("serialize", function()
it("works", function()
@ -53,4 +55,16 @@ describe("serialize", function()
assert.is_nil(test_out.func)
assert.equals(test_out.foo, "bar")
end)
it("vectors work", function()
local v = vector.new(1, 2, 3)
assert.same({{x = 1, y = 2, z = 3}}, core.deserialize(core.serialize({v})))
assert.same({x = 1, y = 2, z = 3}, core.deserialize(core.serialize(v)))
-- abuse
v = vector.new(1, 2, 3)
v.a = "bla"
assert.same({x = 1, y = 2, z = 3, a = "bla"},
core.deserialize(core.serialize(v)))
end)
end)

View File

@ -1,17 +1,23 @@
_G.vector = {}
_G.vector = {metatable = {}}
dofile("builtin/common/vector.lua")
describe("vector", function()
describe("new()", function()
it("constructs", function()
assert.same({ x = 0, y = 0, z = 0 }, vector.new())
assert.same({ x = 1, y = 2, z = 3 }, vector.new(1, 2, 3))
assert.same({ x = 3, y = 2, z = 1 }, vector.new({ x = 3, y = 2, z = 1 }))
assert.same({x = 0, y = 0, z = 0}, vector.new())
assert.same({x = 1, y = 2, z = 3}, vector.new(1, 2, 3))
assert.same({x = 3, y = 2, z = 1}, vector.new({x = 3, y = 2, z = 1}))
assert.is_true(vector.check(vector.new()))
assert.is_true(vector.check(vector.new(1, 2, 3)))
assert.is_true(vector.check(vector.new({x = 3, y = 2, z = 1})))
local input = vector.new({ x = 3, y = 2, z = 1 })
local output = vector.new(input)
assert.same(input, output)
assert.are_not.equal(input, output)
assert.equal(input, output)
assert.is_false(rawequal(input, output))
assert.equal(input, input:new())
end)
it("throws on invalid input", function()
@ -25,27 +31,294 @@ describe("vector", function()
end)
end)
it("equal()", function()
local function assertE(a, b)
assert.is_true(vector.equals(a, b))
end
local function assertNE(a, b)
assert.is_false(vector.equals(a, b))
end
assertE({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
assertE({x = -1, y = 0, z = 1}, {x = -1, y = 0, z = 1})
local a = { x = 2, y = 4, z = -10 }
assertE(a, a)
assertNE({x = -1, y = 0, z = 1}, a)
it("zero()", function()
assert.same({x = 0, y = 0, z = 0}, vector.zero())
assert.same(vector.new(), vector.zero())
assert.equal(vector.new(), vector.zero())
assert.is_true(vector.check(vector.zero()))
end)
it("add()", function()
assert.same({ x = 2, y = 4, z = 6 }, vector.add(vector.new(1, 2, 3), { x = 1, y = 2, z = 3 }))
it("copy()", function()
local v = vector.new(1, 2, 3)
assert.same(v, vector.copy(v))
assert.same(vector.new(v), vector.copy(v))
assert.equal(vector.new(v), vector.copy(v))
assert.is_true(vector.check(vector.copy(v)))
end)
it("indexes", function()
local some_vector = vector.new(24, 42, 13)
assert.equal(24, some_vector[1])
assert.equal(24, some_vector.x)
assert.equal(42, some_vector[2])
assert.equal(42, some_vector.y)
assert.equal(13, some_vector[3])
assert.equal(13, some_vector.z)
some_vector[1] = 100
assert.equal(100, some_vector.x)
some_vector.x = 101
assert.equal(101, some_vector[1])
some_vector[2] = 100
assert.equal(100, some_vector.y)
some_vector.y = 102
assert.equal(102, some_vector[2])
some_vector[3] = 100
assert.equal(100, some_vector.z)
some_vector.z = 103
assert.equal(103, some_vector[3])
end)
it("direction()", function()
local a = vector.new(1, 0, 0)
local b = vector.new(1, 42, 0)
assert.equal(vector.new(0, 1, 0), vector.direction(a, b))
assert.equal(vector.new(0, 1, 0), a:direction(b))
end)
it("distance()", function()
local a = vector.new(1, 0, 0)
local b = vector.new(3, 42, 9)
assert.is_true(math.abs(43 - vector.distance(a, b)) < 1.0e-12)
assert.is_true(math.abs(43 - a:distance(b)) < 1.0e-12)
assert.equal(0, vector.distance(a, a))
assert.equal(0, b:distance(b))
end)
it("length()", function()
local a = vector.new(0, 0, -23)
assert.equal(0, vector.length(vector.new()))
assert.equal(23, vector.length(a))
assert.equal(23, a:length())
end)
it("normalize()", function()
local a = vector.new(0, 0, -23)
assert.equal(vector.new(0, 0, -1), vector.normalize(a))
assert.equal(vector.new(0, 0, -1), a:normalize())
assert.equal(vector.new(), vector.normalize(vector.new()))
end)
it("floor()", function()
local a = vector.new(0.1, 0.9, -0.5)
assert.equal(vector.new(0, 0, -1), vector.floor(a))
assert.equal(vector.new(0, 0, -1), a:floor())
end)
it("round()", function()
local a = vector.new(0.1, 0.9, -0.5)
assert.equal(vector.new(0, 1, -1), vector.round(a))
assert.equal(vector.new(0, 1, -1), a:round())
end)
it("apply()", function()
local i = 0
local f = function(x)
i = i + 1
return x + i
end
local a = vector.new(0.1, 0.9, -0.5)
assert.equal(vector.new(1, 1, 0), vector.apply(a, math.ceil))
assert.equal(vector.new(1, 1, 0), a:apply(math.ceil))
assert.equal(vector.new(0.1, 0.9, 0.5), vector.apply(a, math.abs))
assert.equal(vector.new(0.1, 0.9, 0.5), a:apply(math.abs))
assert.equal(vector.new(1.1, 2.9, 2.5), vector.apply(a, f))
assert.equal(vector.new(4.1, 5.9, 5.5), a:apply(f))
end)
it("combine()", function()
local a = vector.new(1, 2, 3)
local b = vector.new(3, 2, 1)
assert.equal(vector.add(a, b), vector.combine(a, b, function(x, y) return x + y end))
assert.equal(vector.new(3, 2, 3), vector.combine(a, b, math.max))
assert.equal(vector.new(1, 2, 1), vector.combine(a, b, math.min))
end)
it("equals()", function()
local function assertE(a, b)
assert.is_true(vector.equals(a, b))
end
local function assertNE(a, b)
assert.is_false(vector.equals(a, b))
end
assertE({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
assertE({x = -1, y = 0, z = 1}, {x = -1, y = 0, z = 1})
assertE({x = -1, y = 0, z = 1}, vector.new(-1, 0, 1))
local a = {x = 2, y = 4, z = -10}
assertE(a, a)
assertNE({x = -1, y = 0, z = 1}, a)
assert.equal(vector.new(1, 2, 3), vector.new(1, 2, 3))
assert.is_true(vector.new(1, 2, 3):equals(vector.new(1, 2, 3)))
assert.not_equal(vector.new(1, 2, 3), vector.new(1, 2, 4))
assert.is_true(vector.new(1, 2, 3) == vector.new(1, 2, 3))
assert.is_false(vector.new(1, 2, 3) == vector.new(1, 3, 3))
end)
it("metatable is same", function()
local a = vector.new()
local b = vector.new(1, 2, 3)
assert.equal(true, vector.check(a))
assert.equal(true, vector.check(b))
assert.equal(vector.metatable, getmetatable(a))
assert.equal(vector.metatable, getmetatable(b))
assert.equal(vector.metatable, a.metatable)
end)
it("sort()", function()
local a = vector.new(1, 2, 3)
local b = vector.new(0.5, 232, -2)
local sorted = {vector.new(0.5, 2, -2), vector.new(1, 232, 3)}
assert.same(sorted, {vector.sort(a, b)})
assert.same(sorted, {a:sort(b)})
end)
it("angle()", function()
assert.equal(math.pi, vector.angle(vector.new(-1, -2, -3), vector.new(1, 2, 3)))
assert.equal(math.pi/2, vector.new(0, 1, 0):angle(vector.new(1, 0, 0)))
end)
it("dot()", function()
assert.equal(-14, vector.dot(vector.new(-1, -2, -3), vector.new(1, 2, 3)))
assert.equal(0, vector.new():dot(vector.new(1, 2, 3)))
end)
it("cross()", function()
local a = vector.new(-1, -2, 0)
local b = vector.new(1, 2, 3)
assert.equal(vector.new(-6, 3, 0), vector.cross(a, b))
assert.equal(vector.new(-6, 3, 0), a:cross(b))
end)
it("offset()", function()
assert.same({ x = 41, y = 52, z = 63 }, vector.offset(vector.new(1, 2, 3), 40, 50, 60))
assert.same({x = 41, y = 52, z = 63}, vector.offset(vector.new(1, 2, 3), 40, 50, 60))
assert.equal(vector.new(41, 52, 63), vector.offset(vector.new(1, 2, 3), 40, 50, 60))
assert.equal(vector.new(41, 52, 63), vector.new(1, 2, 3):offset(40, 50, 60))
end)
it("is()", function()
local some_table1 = {foo = 13, [42] = 1, "bar", 2}
local some_table2 = {1, 2, 3}
local some_table3 = {x = 1, 2, 3}
local some_table4 = {1, 2, z = 3}
local old = {x = 1, y = 2, z = 3}
local real = vector.new(1, 2, 3)
assert.is_false(vector.check(nil))
assert.is_false(vector.check(1))
assert.is_false(vector.check(true))
assert.is_false(vector.check("foo"))
assert.is_false(vector.check(some_table1))
assert.is_false(vector.check(some_table2))
assert.is_false(vector.check(some_table3))
assert.is_false(vector.check(some_table4))
assert.is_false(vector.check(old))
assert.is_true(vector.check(real))
assert.is_true(real:check())
end)
it("global pairs", function()
local out = {}
local vec = vector.new(10, 20, 30)
for k, v in pairs(vec) do
out[k] = v
end
assert.same({x = 10, y = 20, z = 30}, out)
end)
it("abusing works", function()
local v = vector.new(1, 2, 3)
v.a = 1
assert.equal(1, v.a)
local a_is_there = false
for key, value in pairs(v) do
if key == "a" then
a_is_there = true
assert.equal(value, 1)
break
end
end
assert.is_true(a_is_there)
end)
it("add()", function()
local a = vector.new(1, 2, 3)
local b = vector.new(1, 4, 3)
local c = vector.new(2, 6, 6)
assert.equal(c, vector.add(a, {x = 1, y = 4, z = 3}))
assert.equal(c, vector.add(a, b))
assert.equal(c, a:add(b))
assert.equal(c, a + b)
assert.equal(c, b + a)
end)
it("subtract()", function()
local a = vector.new(1, 2, 3)
local b = vector.new(2, 4, 3)
local c = vector.new(-1, -2, 0)
assert.equal(c, vector.subtract(a, {x = 2, y = 4, z = 3}))
assert.equal(c, vector.subtract(a, b))
assert.equal(c, a:subtract(b))
assert.equal(c, a - b)
assert.equal(c, -b + a)
end)
it("multiply()", function()
local a = vector.new(1, 2, 3)
local b = vector.new(2, 4, 3)
local c = vector.new(2, 8, 9)
local s = 2
local d = vector.new(2, 4, 6)
assert.equal(c, vector.multiply(a, {x = 2, y = 4, z = 3}))
assert.equal(c, vector.multiply(a, b))
assert.equal(d, vector.multiply(a, s))
assert.equal(d, a:multiply(s))
assert.equal(d, a * s)
assert.equal(d, s * a)
assert.equal(-a, -1 * a)
end)
it("divide()", function()
local a = vector.new(1, 2, 3)
local b = vector.new(2, 4, 3)
local c = vector.new(0.5, 0.5, 1)
local s = 2
local d = vector.new(0.5, 1, 1.5)
assert.equal(c, vector.divide(a, {x = 2, y = 4, z = 3}))
assert.equal(c, vector.divide(a, b))
assert.equal(d, vector.divide(a, s))
assert.equal(d, a:divide(s))
assert.equal(d, a / s)
assert.equal(d, 1/s * a)
assert.equal(-a, a / -1)
end)
it("to_string()", function()
local v = vector.new(1, 2, 3.14)
assert.same("(1, 2, 3.14)", vector.to_string(v))
assert.same("(1, 2, 3.14)", v:to_string())
assert.same("(1, 2, 3.14)", tostring(v))
end)
it("from_string()", function()
local v = vector.new(1, 2, 3.14)
assert.is_true(vector.check(vector.from_string("(1, 2, 3.14)")))
assert.same({v, 13}, {vector.from_string("(1, 2, 3.14)")})
assert.same({v, 12}, {vector.from_string("(1,2 ,3.14)")})
assert.same({v, 12}, {vector.from_string("(1,2,3.14,)")})
assert.same({v, 11}, {vector.from_string("(1 2 3.14)")})
assert.same({v, 15}, {vector.from_string("( 1, 2, 3.14 )")})
assert.same({v, 15}, {vector.from_string(" ( 1, 2, 3.14) ")})
assert.same({vector.new(), 8}, {vector.from_string("(0,0,0) ( 1, 2, 3.14) ")})
assert.same({v, 22}, {vector.from_string("(0,0,0) ( 1, 2, 3.14) ", 8)})
assert.same({v, 22}, {vector.from_string("(0,0,0) ( 1, 2, 3.14) ", 9)})
assert.same(nil, vector.from_string("nothing"))
end)
-- This function is needed because of floating point imprecision.

View File

@ -1,73 +1,132 @@
--[[
Vector helpers
Note: The vector.*-functions must be able to accept old vectors that had no metatables
]]
vector = {}
-- localize functions
local setmetatable = setmetatable
-- vector.metatable is set by C++.
local metatable = vector.metatable
local xyz = {"x", "y", "z"}
-- only called when rawget(v, key) returns nil
function metatable.__index(v, key)
return rawget(v, xyz[key]) or vector[key]
end
-- only called when rawget(v, key) returns nil
function metatable.__newindex(v, key, value)
rawset(v, xyz[key] or key, value)
end
-- constructors
local function fast_new(x, y, z)
return setmetatable({x = x, y = y, z = z}, metatable)
end
function vector.new(a, b, c)
if type(a) == "table" then
assert(a.x and a.y and a.z, "Invalid vector passed to vector.new()")
return {x=a.x, y=a.y, z=a.z}
elseif a then
assert(b and c, "Invalid arguments for vector.new()")
return {x=a, y=b, z=c}
if a and b and c then
return fast_new(a, b, c)
end
-- deprecated, use vector.copy and vector.zero directly
if type(a) == "table" then
return vector.copy(a)
else
assert(not a, "Invalid arguments for vector.new()")
return vector.zero()
end
return {x=0, y=0, z=0}
end
function vector.zero()
return fast_new(0, 0, 0)
end
function vector.copy(v)
assert(v.x and v.y and v.z, "Invalid vector passed to vector.copy()")
return fast_new(v.x, v.y, v.z)
end
function vector.from_string(s, init)
local x, y, z, np = string.match(s, "^%s*%(%s*([^%s,]+)%s*[,%s]%s*([^%s,]+)%s*[,%s]" ..
"%s*([^%s,]+)%s*[,%s]?%s*%)()", init)
x = tonumber(x)
y = tonumber(y)
z = tonumber(z)
if not (x and y and z) then
return nil
end
return fast_new(x, y, z), np
end
function vector.to_string(v)
return string.format("(%g, %g, %g)", v.x, v.y, v.z)
end
metatable.__tostring = vector.to_string
function vector.equals(a, b)
return a.x == b.x and
a.y == b.y and
a.z == b.z
end
metatable.__eq = vector.equals
-- unary operations
function vector.length(v)
return math.hypot(v.x, math.hypot(v.y, v.z))
return math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
end
-- Note: we can not use __len because it is already used for primitive table length
function vector.normalize(v)
local len = vector.length(v)
if len == 0 then
return {x=0, y=0, z=0}
return fast_new(0, 0, 0)
else
return vector.divide(v, len)
end
end
function vector.floor(v)
return {
x = math.floor(v.x),
y = math.floor(v.y),
z = math.floor(v.z)
}
return vector.apply(v, math.floor)
end
function vector.round(v)
return {
x = math.floor(v.x + 0.5),
y = math.floor(v.y + 0.5),
z = math.floor(v.z + 0.5)
}
return fast_new(
math.round(v.x),
math.round(v.y),
math.round(v.z)
)
end
function vector.apply(v, func)
return {
x = func(v.x),
y = func(v.y),
z = func(v.z)
}
return fast_new(
func(v.x),
func(v.y),
func(v.z)
)
end
function vector.combine(a, b, func)
return fast_new(
func(a.x, b.x),
func(a.y, b.y),
func(a.z, b.z)
)
end
function vector.distance(a, b)
local x = a.x - b.x
local y = a.y - b.y
local z = a.z - b.z
return math.hypot(x, math.hypot(y, z))
return math.sqrt(x * x + y * y + z * z)
end
function vector.direction(pos1, pos2)
return vector.normalize({
x = pos2.x - pos1.x,
y = pos2.y - pos1.y,
z = pos2.z - pos1.z
})
return vector.subtract(pos2, pos1):normalize()
end
function vector.angle(a, b)
@ -82,70 +141,137 @@ function vector.dot(a, b)
end
function vector.cross(a, b)
return {
x = a.y * b.z - a.z * b.y,
y = a.z * b.x - a.x * b.z,
z = a.x * b.y - a.y * b.x
}
return fast_new(
a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x
)
end
function metatable.__unm(v)
return fast_new(-v.x, -v.y, -v.z)
end
-- add, sub, mul, div operations
function vector.add(a, b)
if type(b) == "table" then
return {x = a.x + b.x,
y = a.y + b.y,
z = a.z + b.z}
return fast_new(
a.x + b.x,
a.y + b.y,
a.z + b.z
)
else
return {x = a.x + b,
y = a.y + b,
z = a.z + b}
return fast_new(
a.x + b,
a.y + b,
a.z + b
)
end
end
function metatable.__add(a, b)
return fast_new(
a.x + b.x,
a.y + b.y,
a.z + b.z
)
end
function vector.subtract(a, b)
if type(b) == "table" then
return {x = a.x - b.x,
y = a.y - b.y,
z = a.z - b.z}
return fast_new(
a.x - b.x,
a.y - b.y,
a.z - b.z
)
else
return {x = a.x - b,
y = a.y - b,
z = a.z - b}
return fast_new(
a.x - b,
a.y - b,
a.z - b
)
end
end
function metatable.__sub(a, b)
return fast_new(
a.x - b.x,
a.y - b.y,
a.z - b.z
)
end
function vector.multiply(a, b)
if type(b) == "table" then
return {x = a.x * b.x,
y = a.y * b.y,
z = a.z * b.z}
return fast_new(
a.x * b.x,
a.y * b.y,
a.z * b.z
)
else
return {x = a.x * b,
y = a.y * b,
z = a.z * b}
return fast_new(
a.x * b,
a.y * b,
a.z * b
)
end
end
function metatable.__mul(a, b)
if type(a) == "table" then
return fast_new(
a.x * b,
a.y * b,
a.z * b
)
else
return fast_new(
a * b.x,
a * b.y,
a * b.z
)
end
end
function vector.divide(a, b)
if type(b) == "table" then
return {x = a.x / b.x,
y = a.y / b.y,
z = a.z / b.z}
return fast_new(
a.x / b.x,
a.y / b.y,
a.z / b.z
)
else
return {x = a.x / b,
y = a.y / b,
z = a.z / b}
return fast_new(
a.x / b,
a.y / b,
a.z / b
)
end
end
function metatable.__div(a, b)
-- scalar/vector makes no sense
return fast_new(
a.x / b,
a.y / b,
a.z / b
)
end
-- misc stuff
function vector.offset(v, x, y, z)
return {x = v.x + x,
y = v.y + y,
z = v.z + z}
return fast_new(
v.x + x,
v.y + y,
v.z + z
)
end
function vector.sort(a, b)
return {x = math.min(a.x, b.x), y = math.min(a.y, b.y), z = math.min(a.z, b.z)},
{x = math.max(a.x, b.x), y = math.max(a.y, b.y), z = math.max(a.z, b.z)}
return fast_new(math.min(a.x, b.x), math.min(a.y, b.y), math.min(a.z, b.z)),
fast_new(math.max(a.x, b.x), math.max(a.y, b.y), math.max(a.z, b.z))
end
function vector.check(v)
return getmetatable(v) == metatable
end
local function sin(x)
@ -213,7 +339,7 @@ end
function vector.dir_to_rotation(forward, up)
forward = vector.normalize(forward)
local rot = {x = math.asin(forward.y), y = -math.atan2(forward.x, forward.z), z = 0}
local rot = vector.new(math.asin(forward.y), -math.atan2(forward.x, forward.z), 0)
if not up then
return rot
end
@ -221,7 +347,7 @@ function vector.dir_to_rotation(forward, up)
"Invalid vectors passed to vector.dir_to_rotation().")
up = vector.normalize(up)
-- Calculate vector pointing up with roll = 0, just based on forward vector.
local forwup = vector.rotate({x = 0, y = 1, z = 0}, rot)
local forwup = vector.rotate(vector.new(0, 1, 0), rot)
-- 'forwup' and 'up' are now in a plane with 'forward' as normal.
-- The angle between them is the absolute of the roll value we're looking for.
rot.z = vector.angle(forwup, up)

View File

@ -1,6 +1,6 @@
VoxelArea = {
MinEdge = {x=1, y=1, z=1},
MaxEdge = {x=0, y=0, z=0},
MinEdge = vector.new(1, 1, 1),
MaxEdge = vector.new(0, 0, 0),
ystride = 0,
zstride = 0,
}
@ -19,11 +19,11 @@ end
function VoxelArea:getExtent()
local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge
return {
x = MaxEdge.x - MinEdge.x + 1,
y = MaxEdge.y - MinEdge.y + 1,
z = MaxEdge.z - MinEdge.z + 1,
}
return vector.new(
MaxEdge.x - MinEdge.x + 1,
MaxEdge.y - MinEdge.y + 1,
MaxEdge.z - MinEdge.z + 1
)
end
function VoxelArea:getVolume()

View File

@ -63,7 +63,7 @@ function ui.update()
-- handle errors
if gamedata ~= nil and gamedata.reconnect_requested then
local error_message = core.formspec_escape(
gamedata.errormessage or "<none available>")
gamedata.errormessage or fgettext("<none available>"))
formspec = {
"size[14,8]",
"real_coordinates[true]",

22
builtin/game/async.lua Normal file
View File

@ -0,0 +1,22 @@
core.async_jobs = {}
function core.async_event_handler(jobid, retval)
local callback = core.async_jobs[jobid]
assert(type(callback) == "function")
callback(unpack(retval, 1, retval.n))
core.async_jobs[jobid] = nil
end
function core.handle_async(func, callback, ...)
assert(type(func) == "function" and type(callback) == "function",
"Invalid minetest.handle_async invocation")
local args = {n = select("#", ...), ...}
local mod_origin = core.get_last_run_mod()
local jobid = core.do_async_callback(func, args, mod_origin)
core.async_jobs[jobid] = callback
return true
end

View File

@ -87,6 +87,10 @@ core.builtin_auth_handler = {
core.settings:get("default_password")))
end
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
@ -100,9 +104,6 @@ core.builtin_auth_handler = {
core.run_priv_callbacks(name, priv, nil, "revoke")
end
end
auth_entry.privileges = privileges
core_auth.save(auth_entry)
core.notify_authentication_modified(name)
end,
reload = function()

View File

@ -75,9 +75,9 @@ core.register_on_chat_message(function(name, message)
local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs)
if has_privs then
core.set_last_run_mod(cmd_def.mod_origin)
local t_before = minetest.get_us_time()
local t_before = core.get_us_time()
local success, result = cmd_def.func(name, param)
local delay = (minetest.get_us_time() - t_before) / 1000000
local delay = (core.get_us_time() - t_before) / 1000000
if success == false and result == nil then
core.chat_send_player(name, "-!- "..S("Invalid command usage."))
local help_def = core.registered_chatcommands["help"]
@ -91,11 +91,12 @@ core.register_on_chat_message(function(name, message)
if delay > msg_time_threshold then
-- Show how much time it took to execute the command
if result then
result = result ..
minetest.colorize("#f3d2ff", " (%.5g s)"):format(delay)
result = result .. core.colorize("#f3d2ff", S(" (@1 s)",
string.format("%.5f", delay)))
else
result = minetest.colorize("#f3d2ff",
"Command execution took %.5f s"):format(delay)
result = core.colorize("#f3d2ff", S(
"Command execution took @1 s",
string.format("%.5f", delay)))
end
end
if result then
@ -129,8 +130,13 @@ local function parse_range_str(player_name, str)
return false, S("Unable to get position of player @1.", player_name)
end
else
p1, p2 = core.string_to_area(str)
if p1 == nil then
local player = core.get_player_by_name(player_name)
local relpos
if player then
relpos = player:get_pos()
end
p1, p2 = core.string_to_area(str, relpos)
if p1 == nil or p2 == nil then
return false, S("Incorrect area format. "
.. "Expected: (x1,y1,z1) (x2,y2,z2)")
end
@ -166,6 +172,18 @@ core.register_chatcommand("admin", {
end,
})
local function privileges_of(name, privs)
if not privs then
privs = core.get_player_privs(name)
end
local privstr = core.privs_to_string(privs, ", ")
if privstr == "" then
return S("@1 does not have any privileges.", name)
else
return S("Privileges of @1: @2", name, privstr)
end
end
core.register_chatcommand("privs", {
params = S("[<name>]"),
description = S("Show privileges of yourself or another player"),
@ -175,9 +193,7 @@ core.register_chatcommand("privs", {
if not core.player_exists(name) then
return false, S("Player @1 does not exist.", name)
end
return true, S("Privileges of @1: @2", name,
core.privs_to_string(
core.get_player_privs(name), ", "))
return true, privileges_of(name)
end,
})
@ -201,9 +217,14 @@ core.register_chatcommand("haspriv", {
table.insert(players_with_priv, player_name)
end
end
return true, S("Players online with the \"@1\" privilege: @2",
param,
table.concat(players_with_priv, ", "))
if #players_with_priv == 0 then
return true, S("No online player has the \"@1\" privilege.",
param)
else
return true, S("Players online with the \"@1\" privilege: @2",
param,
table.concat(players_with_priv, ", "))
end
end
})
@ -226,7 +247,10 @@ local function handle_grant_command(caller, grantname, grantprivstr)
core.string_to_privs(core.settings:get("basic_privs") or "interact,shout")
for priv, _ in pairs(grantprivs) do
if not basic_privs[priv] and not caller_privs.privs then
return false, S("Your privileges are insufficient.")
return false, S("Your privileges are insufficient. "..
"'@1' only allows you to grant: @2",
"basic_privs",
core.privs_to_string(basic_privs, ', '))
end
if not core.registered_privileges[priv] then
privs_unknown = privs_unknown .. S("Unknown privilege: @1", priv) .. "\n"
@ -236,24 +260,22 @@ local function handle_grant_command(caller, grantname, grantprivstr)
if privs_unknown ~= "" then
return false, privs_unknown
end
core.set_player_privs(grantname, privs)
for priv, _ in pairs(grantprivs) do
-- call the on_grant callbacks
core.run_priv_callbacks(grantname, priv, caller, "grant")
end
core.set_player_privs(grantname, privs)
core.log("action", caller..' granted ('..core.privs_to_string(grantprivs, ', ')..') privileges to '..grantname)
if grantname ~= caller then
core.chat_send_player(grantname,
S("@1 granted you privileges: @2", caller,
core.privs_to_string(grantprivs, ' ')))
core.privs_to_string(grantprivs, ', ')))
end
return true, S("Privileges of @1: @2", grantname,
core.privs_to_string(
core.get_player_privs(grantname), ' '))
return true, privileges_of(grantname)
end
core.register_chatcommand("grant", {
params = S("<name> (<privilege> | all)"),
params = S("<name> (<privilege> [, <privilege2> [<...>]] | all)"),
description = S("Give privileges to player"),
func = function(name, param)
local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)")
@ -265,7 +287,7 @@ core.register_chatcommand("grant", {
})
core.register_chatcommand("grantme", {
params = S("<privilege> | all"),
params = S("<privilege> [, <privilege2> [<...>]] | all"),
description = S("Grant privileges to yourself"),
func = function(name, param)
if param == "" then
@ -285,46 +307,90 @@ local function handle_revoke_command(caller, revokename, revokeprivstr)
return false, S("Player @1 does not exist.", revokename)
end
local revokeprivs = core.string_to_privs(revokeprivstr)
local privs = core.get_player_privs(revokename)
local revokeprivs = core.string_to_privs(revokeprivstr)
local is_singleplayer = core.is_singleplayer()
local is_admin = not is_singleplayer
and revokename == core.settings:get("name")
and revokename ~= ""
if revokeprivstr == "all" then
revokeprivs = table.copy(privs)
end
local privs_unknown = ""
local basic_privs =
core.string_to_privs(core.settings:get("basic_privs") or "interact,shout")
local irrevokable = {}
local has_irrevokable_priv = false
for priv, _ in pairs(revokeprivs) do
if not basic_privs[priv] and not caller_privs.privs then
return false, S("Your privileges are insufficient.")
return false, S("Your privileges are insufficient. "..
"'@1' only allows you to revoke: @2",
"basic_privs",
core.privs_to_string(basic_privs, ', '))
end
local def = core.registered_privileges[priv]
if not def then
-- Old/removed privileges might still be granted to certain players
if not privs[priv] then
privs_unknown = privs_unknown .. S("Unknown privilege: @1", priv) .. "\n"
end
elseif is_singleplayer and def.give_to_singleplayer then
irrevokable[priv] = true
elseif is_admin and def.give_to_admin then
irrevokable[priv] = true
end
end
for priv, _ in pairs(irrevokable) do
revokeprivs[priv] = nil
has_irrevokable_priv = true
end
if privs_unknown ~= "" then
return false, privs_unknown
end
if has_irrevokable_priv then
if is_singleplayer then
core.chat_send_player(caller,
S("Note: Cannot revoke in singleplayer: @1",
core.privs_to_string(irrevokable, ', ')))
elseif is_admin then
core.chat_send_player(caller,
S("Note: Cannot revoke from admin: @1",
core.privs_to_string(irrevokable, ', ')))
end
end
if revokeprivstr == "all" then
revokeprivs = privs
privs = {}
else
for priv, _ in pairs(revokeprivs) do
privs[priv] = nil
end
local revokecount = 0
for priv, _ in pairs(revokeprivs) do
privs[priv] = nil
revokecount = revokecount + 1
end
if revokecount == 0 then
return false, S("No privileges were revoked.")
end
core.set_player_privs(revokename, privs)
for priv, _ in pairs(revokeprivs) do
-- call the on_revoke callbacks
core.run_priv_callbacks(revokename, priv, caller, "revoke")
end
local new_privs = core.get_player_privs(revokename)
core.set_player_privs(revokename, privs)
core.log("action", caller..' revoked ('
..core.privs_to_string(revokeprivs, ', ')
..') privileges from '..revokename)
if revokename ~= caller then
core.chat_send_player(revokename,
S("@1 revoked privileges from you: @2", caller,
core.privs_to_string(revokeprivs, ' ')))
core.privs_to_string(revokeprivs, ', ')))
end
return true, S("Privileges of @1: @2", revokename,
core.privs_to_string(
core.get_player_privs(revokename), ' '))
return true, privileges_of(revokename, new_privs)
end
core.register_chatcommand("revoke", {
params = S("<name> (<privilege> | all)"),
params = S("<name> (<privilege> [, <privilege2> [<...>]] | all)"),
description = S("Remove privileges from player"),
privs = {},
func = function(name, param)
@ -337,7 +403,7 @@ core.register_chatcommand("revoke", {
})
core.register_chatcommand("revokeme", {
params = S("<privilege> | all"),
params = S("<privilege> [, <privilege2> [<...>]] | all"),
description = S("Revoke privileges from yourself"),
privs = {},
func = function(name, param)
@ -444,10 +510,10 @@ core.register_chatcommand("remove_player", {
-- pos may be a non-integer position
local function find_free_position_near(pos)
local tries = {
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
vector.new( 1, 0, 0),
vector.new(-1, 0, 0),
vector.new( 0, 0, 1),
vector.new( 0, 0, -1),
}
for _, d in ipairs(tries) do
local p = vector.add(pos, d)
@ -464,7 +530,7 @@ end
-- Teleports player <name> to <p> if possible
local function teleport_to_pos(name, p)
local lm = 31000
local lm = 31007 -- equals MAX_MAP_GENERATION_LIMIT in C++
if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm
or p.z < -lm or p.z > lm then
return false, S("Cannot teleport out of map bounds!")
@ -509,10 +575,15 @@ core.register_chatcommand("teleport", {
description = S("Teleport to position or player"),
privs = {teleport=true},
func = function(name, param)
local player = core.get_player_by_name(name)
local relpos
if player then
relpos = player:get_pos()
end
local p = {}
p.x, p.y, p.z = param:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
p = vector.apply(p, tonumber)
if p.x and p.y and p.z then
p.x, p.y, p.z = string.match(param, "^([%d.~-]+)[, ] *([%d.~-]+)[, ] *([%d.~-]+)$")
p = core.parse_coordinates(p.x, p.y, p.z, relpos)
if p and p.x and p.y and p.z then
return teleport_to_pos(name, p)
end
@ -526,9 +597,19 @@ core.register_chatcommand("teleport", {
"other players (missing privilege: @1).", "bring")
local teleportee_name
p = {}
teleportee_name, p.x, p.y, p.z = param:match(
"^([^ ]+) +([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
"^([^ ]+) +([%d.~-]+)[, ] *([%d.~-]+)[, ] *([%d.~-]+)$")
if teleportee_name then
local teleportee = core.get_player_by_name(teleportee_name)
if not teleportee then
return
end
relpos = teleportee:get_pos()
p = core.parse_coordinates(p.x, p.y, p.z, relpos)
end
p = vector.apply(p, tonumber)
if teleportee_name and p.x and p.y and p.z then
if not has_bring_priv then
return false, missing_bring_msg
@ -561,6 +642,10 @@ core.register_chatcommand("set", {
setname, setvalue = string.match(param, "([^ ]+) (.+)")
if setname and setvalue then
if setname:sub(1, 7) == "secure." then
return false, S("Failed. Cannot modify secure settings. "
.. "Edit the settings file manually.")
end
if not core.settings:get(setname) then
return false, S("Failed. Use '/set -n <name> <value>' "
.. "to create a new setting.")
@ -682,7 +767,12 @@ core.register_chatcommand("mods", {
description = S("List mods installed on the server"),
privs = {},
func = function(name, param)
return true, table.concat(core.get_modnames(), ", ")
local mods = core.get_modnames()
if #mods == 0 then
return true, S("No mods installed.")
else
return true, table.concat(core.get_modnames(), ", ")
end
end,
})
@ -772,7 +862,7 @@ core.register_chatcommand("spawnentity", {
description = S("Spawn entity at given (or your) position"),
privs = {give=true, interact=true},
func = function(name, param)
local entityname, p = string.match(param, "^([^ ]+) *(.*)$")
local entityname, pstr = string.match(param, "^([^ ]+) *(.*)$")
if not entityname then
return false, S("EntityName required.")
end
@ -786,11 +876,15 @@ core.register_chatcommand("spawnentity", {
if not core.registered_entities[entityname] then
return false, S("Cannot spawn an unknown entity.")
end
if p == "" then
local p
if pstr == "" then
p = player:get_pos()
else
p = core.string_to_pos(p)
if p == nil then
p = {}
p.x, p.y, p.z = string.match(pstr, "^([%d.~-]+)[, ] *([%d.~-]+)[, ] *([%d.~-]+)$")
local relpos = player:get_pos()
p = core.parse_coordinates(p.x, p.y, p.z, relpos)
if not (p and p.x and p.y and p.z) then
return false, S("Invalid parameters (@1).", param)
end
end
@ -949,6 +1043,13 @@ core.register_chatcommand("status", {
end,
})
local function get_time(timeofday)
local time = math.floor(timeofday * 1440)
local minute = time % 60
local hour = (time - minute) / 60
return time, hour, minute
end
core.register_chatcommand("time", {
params = S("[<0..23>:<0..59> | <0..24000>]"),
description = S("Show or set time of day"),
@ -967,25 +1068,44 @@ core.register_chatcommand("time", {
return false, S("You don't have permission to run "
.. "this command (missing privilege: @1).", "settime")
end
local hour, minute = param:match("^(%d+):(%d+)$")
if not hour then
local new_time = tonumber(param)
local relative, negative, hour, minute = param:match("^(~?)(%-?)(%d+):(%d+)$")
if not relative then -- checking the first capture against nil suffices
local new_time = core.parse_relative_number(param, core.get_timeofday() * 24000)
if not new_time then
return false, S("Invalid time.")
new_time = tonumber(param) or -1
else
new_time = new_time % 24000
end
-- Backward compatibility.
core.set_timeofday((new_time % 24000) / 24000)
if new_time ~= new_time or new_time < 0 or new_time > 24000 then
return false, S("Invalid time (must be between 0 and 24000).")
end
core.set_timeofday(new_time / 24000)
core.log("action", name .. " sets time to " .. new_time)
return true, S("Time of day changed.")
end
local new_time
hour = tonumber(hour)
minute = tonumber(minute)
if hour < 0 or hour > 23 then
return false, S("Invalid hour (must be between 0 and 23 inclusive).")
elseif minute < 0 or minute > 59 then
return false, S("Invalid minute (must be between 0 and 59 inclusive).")
if relative == "" then
if hour < 0 or hour > 23 then
return false, S("Invalid hour (must be between 0 and 23 inclusive).")
elseif minute < 0 or minute > 59 then
return false, S("Invalid minute (must be between 0 and 59 inclusive).")
end
new_time = (hour * 60 + minute) / 1440
else
if minute < 0 or minute > 59 then
return false, S("Invalid minute (must be between 0 and 59 inclusive).")
end
local current_time = core.get_timeofday()
if negative == "-" then -- negative time
hour, minute = -hour, -minute
end
new_time = (current_time + (hour * 60 + minute) / 1440) % 1
local _
_, hour, minute = get_time(new_time)
end
core.set_timeofday((hour * 60 + minute) / 1440)
core.set_timeofday(new_time)
core.log("action", ("%s sets time to %d:%02d"):format(name, hour, minute))
return true, S("Time of day changed.")
end,
@ -998,24 +1118,58 @@ core.register_chatcommand("days", {
end
})
local function parse_shutdown_param(param)
local delay, reconnect, message
local one, two, three
one, two, three = param:match("^(%S+) +(%-r) +(.*)")
if one and two and three then
-- 3 arguments: delay, reconnect and message
return one, two, three
end
-- 2 arguments
one, two = param:match("^(%S+) +(.*)")
if one and two then
if tonumber(one) then
delay = one
if two == "-r" then
reconnect = two
else
message = two
end
elseif one == "-r" then
reconnect, message = one, two
end
return delay, reconnect, message
end
-- 1 argument
one = param:match("(.*)")
if tonumber(one) then
delay = one
elseif one == "-r" then
reconnect = one
else
message = one
end
return delay, reconnect, message
end
core.register_chatcommand("shutdown", {
params = S("[<delay_in_seconds> | -1] [reconnect] [<message>]"),
description = S("Shutdown server (-1 cancels a delayed shutdown)"),
params = S("[<delay_in_seconds> | -1] [-r] [<message>]"),
description = S("Shutdown server (-1 cancels a delayed shutdown, -r allows players to reconnect)"),
privs = {server=true},
func = function(name, param)
local delay, reconnect, message
delay, param = param:match("^%s*(%S+)(.*)")
if param then
reconnect, param = param:match("^%s*(%S+)(.*)")
local delay, reconnect, message = parse_shutdown_param(param)
local bool_reconnect = reconnect == "-r"
if not message then
message = ""
end
message = param and param:match("^%s*(.+)") or ""
delay = tonumber(delay) or 0
if delay == 0 then
core.log("action", name .. " shuts down server")
core.chat_send_all("*** "..S("Server shutting down (operator request)."))
end
core.request_shutdown(message:trim(), core.is_yes(reconnect), delay)
core.request_shutdown(message:trim(), bool_reconnect, delay)
return true
end,
})
@ -1033,6 +1187,9 @@ core.register_chatcommand("ban", {
return true, S("Ban list: @1", ban_list)
end
end
if core.is_singleplayer() then
return false, S("You cannot ban players in singleplayer!")
end
if not core.get_player_by_name(param) then
return false, S("Player is not online.")
end
@ -1184,7 +1341,7 @@ local function handle_kill_command(killer, victim)
return false, S("@1 is already dead.", victim)
end
end
if not killer == victim then
if killer ~= victim then
core.log("action", string.format("%s killed %s", killer, victim))
end
-- Kill victim

View File

@ -39,7 +39,7 @@ local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
core.register_entity(":__builtin:falling_node", {
initial_properties = {
visual = "item",
visual_size = {x = SCALE, y = SCALE, z = SCALE},
visual_size = vector.new(SCALE, SCALE, SCALE),
textures = {},
physical = true,
is_visible = false,
@ -84,9 +84,6 @@ core.register_entity(":__builtin:falling_node", {
local textures
if def.tiles and def.tiles[1] then
local tile = def.tiles[1]
if def.drawtype == "torchlike" and def.paramtype2 ~= "wallmounted" then
tile = def.tiles[2] or def.tiles[1]
end
if type(tile) == "table" then
tile = tile.name
end
@ -99,7 +96,7 @@ core.register_entity(":__builtin:falling_node", {
local vsize
if def.visual_scale then
local s = def.visual_scale
vsize = {x = s, y = s, z = s}
vsize = vector.new(s, s, s)
end
self.object:set_properties({
is_visible = true,
@ -114,15 +111,21 @@ core.register_entity(":__builtin:falling_node", {
itemstring = core.itemstring_with_palette(itemstring, node.param2)
end
-- FIXME: solution needed for paramtype2 == "leveled"
local vsize
if def.visual_scale then
local s = def.visual_scale * SCALE
vsize = {x = s, y = s, z = s}
-- Calculate size of falling node
local s = {}
s.x = (def.visual_scale or 1) * SCALE
s.y = s.x
s.z = s.x
-- Compensate for wield_scale
if def.wield_scale then
s.x = s.x / def.wield_scale.x
s.y = s.y / def.wield_scale.y
s.z = s.z / def.wield_scale.z
end
self.object:set_properties({
is_visible = true,
wield_item = itemstring,
visual_size = vsize,
visual_size = s,
glow = def.light_source,
})
end
@ -147,11 +150,7 @@ core.register_entity(":__builtin:falling_node", {
-- Rotate entity
if def.drawtype == "torchlike" then
if def.paramtype2 == "wallmounted" then
self.object:set_yaw(math.pi*0.25)
else
self.object:set_yaw(-math.pi*0.25)
end
self.object:set_yaw(math.pi*0.25)
elseif ((node.param2 ~= 0 or def.drawtype == "nodebox" or def.drawtype == "mesh")
and (def.wield_image == "" or def.wield_image == nil))
or def.drawtype == "signlike"
@ -165,8 +164,13 @@ core.register_entity(":__builtin:falling_node", {
if euler then
self.object:set_rotation(euler)
end
elseif (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted") then
elseif (def.drawtype ~= "plantlike" and def.drawtype ~= "plantlike_rooted" and
(def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike")) then
local rot = node.param2 % 8
if (def.drawtype == "signlike" and def.paramtype2 ~= "wallmounted" and def.paramtype2 ~= "colorwallmounted") then
-- Change rotation to "floor" by default for non-wallmounted paramtype2
rot = 1
end
local pitch, yaw, roll = 0, 0, 0
if def.drawtype == "nodebox" or def.drawtype == "mesh" then
if rot == 0 then
@ -208,6 +212,14 @@ core.register_entity(":__builtin:falling_node", {
end
end
self.object:set_rotation({x=pitch, y=yaw, z=roll})
elseif (def.drawtype == "mesh" and def.paramtype2 == "degrotate") then
local p2 = (node.param2 - (def.place_param2 or 0)) % 240
local yaw = (p2 / 240) * (math.pi * 2)
self.object:set_yaw(yaw)
elseif (def.drawtype == "mesh" and def.paramtype2 == "colordegrotate") then
local p2 = (node.param2 % 32 - (def.place_param2 or 0) % 32) % 24
local yaw = (p2 / 24) * (math.pi * 2)
self.object:set_yaw(yaw)
end
end
end,
@ -222,7 +234,7 @@ core.register_entity(":__builtin:falling_node", {
on_activate = function(self, staticdata)
self.object:set_armor_groups({immortal = 1})
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
self.object:set_acceleration(vector.new(0, -gravity, 0))
local ds = core.deserialize(staticdata)
if ds and ds.node then
@ -298,7 +310,7 @@ core.register_entity(":__builtin:falling_node", {
if self.floats then
local pos = self.object:get_pos()
local bcp = vector.round({x = pos.x, y = pos.y - 0.7, z = pos.z})
local bcp = pos:offset(0, -0.7, 0):round()
local bcn = core.get_node(bcp)
local bcd = core.registered_nodes[bcn.name]
@ -339,13 +351,12 @@ core.register_entity(":__builtin:falling_node", {
-- TODO: this hack could be avoided in the future if objects
-- could choose who to collide with
local vel = self.object:get_velocity()
self.object:set_velocity({
x = vel.x,
y = player_collision.old_velocity.y,
z = vel.z
})
self.object:set_pos(vector.add(self.object:get_pos(),
{x = 0, y = -0.5, z = 0}))
self.object:set_velocity(vector.new(
vel.x,
player_collision.old_velocity.y,
vel.z
))
self.object:set_pos(self.object:get_pos():offset(0, -0.5, 0))
end
return
elseif bcn.name == "ignore" then
@ -407,7 +418,7 @@ local function convert_to_falling_node(pos, node)
obj:get_luaentity():set_node(node, metatable)
core.remove_node(pos)
return true
return true, obj
end
function core.spawn_falling_node(pos)
@ -425,7 +436,7 @@ local function drop_attached_node(p)
if def and def.preserve_metadata then
local oldmeta = core.get_meta(p):to_table().fields
-- Copy pos and node because the callback can modify them.
local pos_copy = {x=p.x, y=p.y, z=p.z}
local pos_copy = vector.new(p)
local node_copy = {name=n.name, param1=n.param1, param2=n.param2}
local drop_stacks = {}
for k, v in pairs(drops) do
@ -450,14 +461,14 @@ end
function builtin_shared.check_attached_node(p, n)
local def = core.registered_nodes[n.name]
local d = {x = 0, y = 0, z = 0}
local d = vector.new()
if def.paramtype2 == "wallmounted" or
def.paramtype2 == "colorwallmounted" then
-- The fallback vector here 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.
d = core.wallmounted_to_dir(n.param2) or {x = 0, y = 1, z = 0}
d = core.wallmounted_to_dir(n.param2) or vector.new(0, 1, 0)
else
d.y = -1
end
@ -477,7 +488,7 @@ end
function core.check_single_for_falling(p)
local n = core.get_node(p)
if core.get_item_group(n.name, "falling_node") ~= 0 then
local p_bottom = {x = p.x, y = p.y - 1, z = p.z}
local p_bottom = vector.offset(p, 0, -1, 0)
-- Only spawn falling node if node below is loaded
local n_bottom = core.get_node_or_nil(p_bottom)
local d_bottom = n_bottom and core.registered_nodes[n_bottom.name]
@ -516,17 +527,17 @@ end
-- Down first as likely case, but always before self. The same with sides.
-- Up must come last, so that things above self will also fall all at once.
local check_for_falling_neighbors = {
{x = -1, y = -1, z = 0},
{x = 1, y = -1, z = 0},
{x = 0, y = -1, z = -1},
{x = 0, y = -1, z = 1},
{x = 0, y = -1, z = 0},
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 0},
{x = 0, y = 1, z = 0},
vector.new(-1, -1, 0),
vector.new( 1, -1, 0),
vector.new( 0, -1, -1),
vector.new( 0, -1, 1),
vector.new( 0, -1, 0),
vector.new(-1, 0, 0),
vector.new( 1, 0, 0),
vector.new( 0, 0, 1),
vector.new( 0, 0, -1),
vector.new( 0, 0, 0),
vector.new( 0, 1, 0),
}
function core.check_for_falling(p)

View File

@ -19,6 +19,10 @@ core.features = {
object_step_has_moveresult = true,
direct_velocity_on_players = true,
use_texture_alpha_string_modes = true,
degrotate_240_steps = true,
abm_min_max_y = true,
dynamic_add_media_table = true,
get_sky_as_table = true,
}
function core.has_feature(arg)

View File

@ -86,12 +86,6 @@ local function read_file(filename)
return core.deserialize(t) or {}
end
local function write_file(filename, table)
local f = io.open(filename, "w")
f:write(core.serialize(table))
f:close()
end
blocks_forceloaded = read_file(wpath.."/force_loaded.txt")
for _, __ in pairs(blocks_forceloaded) do
total_forceloaded = total_forceloaded + 1
@ -106,7 +100,8 @@ end)
-- persists the currently forceloaded blocks to disk
local function persist_forceloaded_blocks()
write_file(wpath.."/force_loaded.txt", blocks_forceloaded)
local data = core.serialize(blocks_forceloaded)
core.safe_file_write(wpath.."/force_loaded.txt", data)
end
-- periodical forceload persistence

View File

@ -7,9 +7,8 @@ local gamepath = scriptpath .. "game".. DIR_DELIM
-- not exposed to outer context
local builtin_shared = {}
dofile(commonpath .. "vector.lua")
dofile(gamepath .. "constants.lua")
dofile(gamepath .. "item_s.lua")
assert(loadfile(gamepath .. "item.lua"))(builtin_shared)
dofile(gamepath .. "register.lua")
@ -18,8 +17,10 @@ if core.settings:get_bool("profiler.load") then
end
dofile(commonpath .. "after.lua")
dofile(commonpath .. "voxelarea.lua")
dofile(gamepath .. "item_entity.lua")
dofile(gamepath .. "deprecated.lua")
dofile(gamepath .. "misc_s.lua")
dofile(gamepath .. "misc.lua")
dofile(gamepath .. "privileges.lua")
dofile(gamepath .. "auth.lua")
@ -30,9 +31,9 @@ dofile(gamepath .. "static_spawn.lua")
dofile(gamepath .. "detached_inventory.lua")
assert(loadfile(gamepath .. "falling.lua"))(builtin_shared)
dofile(gamepath .. "features.lua")
dofile(gamepath .. "voxelarea.lua")
dofile(gamepath .. "forceloading.lua")
dofile(gamepath .. "statbars.lua")
dofile(gamepath .. "knockback.lua")
dofile(gamepath .. "async.lua")
profiler = nil

View File

@ -15,149 +15,29 @@ end
-- Item definition helpers
--
function core.inventorycube(img1, img2, img3)
img2 = img2 or img1
img3 = img3 or img1
return "[inventorycube"
.. "{" .. img1:gsub("%^", "&")
.. "{" .. img2:gsub("%^", "&")
.. "{" .. img3:gsub("%^", "&")
end
function core.dir_to_facedir(dir, is6d)
--account for y if requested
if is6d and math.abs(dir.y) > math.abs(dir.x) and math.abs(dir.y) > math.abs(dir.z) then
--from above
if dir.y < 0 then
if math.abs(dir.x) > math.abs(dir.z) then
if dir.x < 0 then
return 19
else
return 13
end
else
if dir.z < 0 then
return 10
else
return 4
end
end
--from below
else
if math.abs(dir.x) > math.abs(dir.z) then
if dir.x < 0 then
return 15
else
return 17
end
else
if dir.z < 0 then
return 6
else
return 8
end
end
end
--otherwise, place horizontally
elseif math.abs(dir.x) > math.abs(dir.z) then
if dir.x < 0 then
return 3
else
return 1
end
else
if dir.z < 0 then
return 2
else
return 0
function core.get_pointed_thing_position(pointed_thing, above)
if pointed_thing.type == "node" then
if above then
-- The position where a node would be placed
return pointed_thing.above
end
-- The position where a node would be dug
return pointed_thing.under
elseif pointed_thing.type == "object" then
return pointed_thing.ref and pointed_thing.ref:get_pos()
end
end
-- Table of possible dirs
local facedir_to_dir = {
{x= 0, y=0, z= 1},
{x= 1, y=0, z= 0},
{x= 0, y=0, z=-1},
{x=-1, y=0, z= 0},
{x= 0, y=-1, z= 0},
{x= 0, y=1, z= 0},
}
-- Mapping from facedir value to index in facedir_to_dir.
local facedir_to_dir_map = {
[0]=1, 2, 3, 4,
5, 2, 6, 4,
6, 2, 5, 4,
1, 5, 3, 6,
1, 6, 3, 5,
1, 4, 3, 2,
}
function core.facedir_to_dir(facedir)
return facedir_to_dir[facedir_to_dir_map[facedir % 32]]
end
function core.dir_to_wallmounted(dir)
if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then
if dir.y < 0 then
return 1
else
return 0
end
elseif math.abs(dir.x) > math.abs(dir.z) then
if dir.x < 0 then
return 3
else
return 2
end
else
if dir.z < 0 then
return 5
else
return 4
local function has_all_groups(tbl, required_groups)
if type(required_groups) == "string" then
return (tbl[required_groups] or 0) ~= 0
end
for _, group in ipairs(required_groups) do
if (tbl[group] or 0) == 0 then
return false
end
end
end
-- table of dirs in wallmounted order
local wallmounted_to_dir = {
[0] = {x = 0, y = 1, z = 0},
{x = 0, y = -1, z = 0},
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z = -1},
}
function core.wallmounted_to_dir(wallmounted)
return wallmounted_to_dir[wallmounted % 8]
end
function core.dir_to_yaw(dir)
return -math.atan2(dir.x, dir.z)
end
function core.yaw_to_dir(yaw)
return {x = -math.sin(yaw), y = 0, z = math.cos(yaw)}
end
function core.is_colored_paramtype(ptype)
return (ptype == "color") or (ptype == "colorfacedir") or
(ptype == "colorwallmounted")
end
function core.strip_param2_color(param2, paramtype2)
if not core.is_colored_paramtype(paramtype2) then
return nil
end
if paramtype2 == "colorfacedir" then
param2 = math.floor(param2 / 32) * 32
elseif paramtype2 == "colorwallmounted" then
param2 = math.floor(param2 / 8) * 8
end
-- paramtype2 == "color" requires no modification.
return param2
return true
end
function core.get_node_drops(node, toolname)
@ -199,7 +79,7 @@ function core.get_node_drops(node, toolname)
if item.rarity ~= nil then
good_rarity = item.rarity < 1 or math.random(item.rarity) == 1
end
if item.tools ~= nil then
if item.tools ~= nil or item.tool_groups ~= nil then
good_tool = false
end
if item.tools ~= nil and toolname then
@ -214,6 +94,27 @@ function core.get_node_drops(node, toolname)
end
end
end
if item.tool_groups ~= nil and toolname then
local tooldef = core.registered_items[toolname]
if tooldef ~= nil and type(tooldef.groups) == "table" then
if type(item.tool_groups) == "string" then
-- tool_groups can be a string which specifies the required group
good_tool = core.get_item_group(toolname, item.tool_groups) ~= 0
else
-- tool_groups can be a list of sufficient requirements.
-- i.e. if any item in the list can be satisfied then the tool is good
assert(type(item.tool_groups) == "table")
for _, required_groups in ipairs(item.tool_groups) do
-- required_groups can be either a string (a single group),
-- or an array of strings where all must be in tooldef.groups
good_tool = has_all_groups(tooldef.groups, required_groups)
if good_tool then
break
end
end
end
end
end
if good_rarity and good_tool then
got_count = got_count + 1
for _, add_item in ipairs(item.items) do
@ -275,12 +176,12 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
end
-- Place above pointed node
local place_to = {x = above.x, y = above.y, z = above.z}
local place_to = vector.new(above)
-- If node under is buildable_to, place into it instead (eg. snow)
if olddef_under.buildable_to then
log("info", "node under is buildable to")
place_to = {x = under.x, y = under.y, z = under.z}
place_to = vector.new(under)
end
if core.is_protected(place_to, playername) then
@ -300,22 +201,14 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
newnode.param2 = def.place_param2
elseif (def.paramtype2 == "wallmounted" or
def.paramtype2 == "colorwallmounted") and not param2 then
local dir = {
x = under.x - above.x,
y = under.y - above.y,
z = under.z - above.z
}
local dir = vector.subtract(under, above)
newnode.param2 = core.dir_to_wallmounted(dir)
-- Calculate the direction for furnaces and chests and stuff
elseif (def.paramtype2 == "facedir" or
def.paramtype2 == "colorfacedir") and not param2 then
local placer_pos = placer and placer:get_pos()
if placer_pos then
local dir = {
x = above.x - placer_pos.x,
y = above.y - placer_pos.y,
z = above.z - placer_pos.z
}
local dir = vector.subtract(above, placer_pos)
newnode.param2 = core.dir_to_facedir(dir)
log("info", "facedir: " .. newnode.param2)
end
@ -332,6 +225,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
color_divisor = 8
elseif def.paramtype2 == "colorfacedir" then
color_divisor = 32
elseif def.paramtype2 == "colordegrotate" then
color_divisor = 32
end
if color_divisor then
local color = math.floor(metatable.palette_index / color_divisor)
@ -367,7 +262,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
-- Run callback
if def.after_place_node and not prevent_after_place then
-- Deepcopy place_to and pointed_thing because callback can modify it
local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
local place_to_copy = vector.new(place_to)
local pointed_thing_copy = copy_pointed_thing(pointed_thing)
if def.after_place_node(place_to_copy, placer, itemstack,
pointed_thing_copy) then
@ -378,7 +273,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
-- Run script hook
for _, callback in ipairs(core.registered_on_placenodes) do
-- Deepcopy pos, node and pointed_thing because callback can modify them
local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
local place_to_copy = vector.new(place_to)
local newnode_copy = {name=newnode.name, param1=newnode.param1, param2=newnode.param2}
local oldnode_copy = {name=oldnode.name, param1=oldnode.param1, param2=oldnode.param2}
local pointed_thing_copy = copy_pointed_thing(pointed_thing)
@ -457,34 +352,41 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
return result
end
end
-- read definition before potentially emptying the stack
local def = itemstack:get_definition()
if itemstack:take_item() ~= nil then
user:set_hp(user:get_hp() + hp_change)
if itemstack:take_item():is_empty() then
return itemstack
end
if def and def.sound and def.sound.eat then
core.sound_play(def.sound.eat, {
pos = user:get_pos(),
max_hear_distance = 16
}, true)
end
if def and def.sound and def.sound.eat then
core.sound_play(def.sound.eat, {
pos = user:get_pos(),
max_hear_distance = 16
}, true)
end
if replace_with_item then
if itemstack:is_empty() then
itemstack:add_item(replace_with_item)
-- Changing hp might kill the player causing mods to do who-knows-what to the
-- inventory, so do this before set_hp().
if replace_with_item then
if itemstack:is_empty() then
itemstack:add_item(replace_with_item)
else
local inv = user:get_inventory()
-- Check if inv is null, since non-players don't have one
if inv and inv:room_for_item("main", {name=replace_with_item}) then
inv:add_item("main", replace_with_item)
else
local inv = user:get_inventory()
-- Check if inv is null, since non-players don't have one
if inv and inv:room_for_item("main", {name=replace_with_item}) then
inv:add_item("main", replace_with_item)
else
local pos = user:get_pos()
pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, replace_with_item)
end
local pos = user:get_pos()
pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, replace_with_item)
end
end
end
return itemstack
user:set_wielded_item(itemstack)
user:set_hp(user:get_hp() + hp_change)
return nil -- don't overwrite wield item a second time
end
function core.item_eat(hp_change, replace_with_item)
@ -524,11 +426,11 @@ function core.handle_node_drops(pos, drops, digger)
for _, dropped_item in pairs(drops) do
local left = give_item(dropped_item)
if not left:is_empty() then
local p = {
x = pos.x + math.random()/2-0.25,
y = pos.y + math.random()/2-0.25,
z = pos.z + math.random()/2-0.25,
}
local p = vector.offset(pos,
math.random()/2-0.25,
math.random()/2-0.25,
math.random()/2-0.25
)
core.add_item(p, left)
end
end
@ -565,7 +467,7 @@ function core.node_dig(pos, node, digger)
if wielded then
local wdef = wielded:get_definition()
local tp = wielded:get_tool_capabilities()
local dp = core.get_dig_params(def and def.groups, tp)
local dp = core.get_dig_params(def and def.groups, tp, wielded:get_wear())
if wdef and wdef.after_use then
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
else
@ -587,7 +489,7 @@ function core.node_dig(pos, node, digger)
if def and def.preserve_metadata then
local oldmeta = core.get_meta(pos):to_table().fields
-- Copy pos and node because the callback can modify them.
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
local pos_copy = vector.new(pos)
local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
local drop_stacks = {}
for k, v in pairs(drops) do
@ -619,7 +521,7 @@ function core.node_dig(pos, node, digger)
-- Run callback
if def and def.after_dig_node then
-- Copy pos and node because callback can modify them
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
local pos_copy = vector.new(pos)
local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
def.after_dig_node(pos_copy, node_copy, oldmetadata, digger)
end
@ -627,12 +529,10 @@ function core.node_dig(pos, node, digger)
-- Run script hook
for _, callback in ipairs(core.registered_on_dignodes) do
local origin = core.callback_origins[callback]
if origin then
core.set_last_run_mod(origin.mod)
end
core.set_last_run_mod(origin.mod)
-- Copy pos and node because callback can modify them
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
local pos_copy = vector.new(pos)
local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
callback(pos_copy, node_copy, digger)
end
@ -675,7 +575,7 @@ core.nodedef_default = {
groups = {},
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
wield_scale = vector.new(1, 1, 1),
stack_max = default_stack_max,
usable = false,
liquids_pointable = false,
@ -734,7 +634,7 @@ core.craftitemdef_default = {
groups = {},
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
wield_scale = vector.new(1, 1, 1),
stack_max = default_stack_max,
liquids_pointable = false,
tool_capabilities = nil,
@ -753,7 +653,7 @@ core.tooldef_default = {
groups = {},
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
wield_scale = vector.new(1, 1, 1),
stack_max = 1,
liquids_pointable = false,
tool_capabilities = nil,
@ -772,7 +672,7 @@ core.noneitemdef_default = { -- This is used for the hand and unknown items
groups = {},
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
wield_scale = vector.new(1, 1, 1),
stack_max = default_stack_max,
liquids_pointable = false,
tool_capabilities = nil,

Some files were not shown because too many files have changed in this diff Show More