Compare commits

...

256 Commits

Author SHA1 Message Date
Gregor Parzefall
d445638265 Bump version to 5.8.1 2024-05-06 20:58:14 +02:00
Gregor Parzefall
f61f6626b7 Fix Android build for 5.8.1 2024-05-06 20:58:14 +02:00
Gregor Parzefall
857ba25115 Android CI: Additionally make an AAB for uploading to the Play Store (#14584) 2024-05-06 20:58:14 +02:00
grorp
00774bc28b Fix some Game members not being freed after some startup errors (#14561) 2024-05-06 20:58:14 +02:00
Gregor Parzefall
f572266f19 Fix local server startup and shutdown blocking the main thread
Co-authored-by: sfan5 <sfan5@live.de>
2024-05-06 20:58:14 +02:00
Gregor Parzefall
c3893064a3 Fix all cached media being loaded at once on the main thread 2024-05-06 20:58:14 +02:00
grorp
4183443f02 Allow sync HTTP fetches to be interrupted to fix hanging (#14412)
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
2024-05-06 20:58:14 +02:00
sfan5
5715434d5e Skip Android deps download if they already exist
It's close to impossible to test locally built changes otherwise.
2024-05-06 20:58:14 +02:00
lhofhansl
ab2419db24 Allow shaders with disabled post processing pipeline (#14338)
- Allow disabling of the post processing pipeline while leaving shaders enabled
- Also disable post processing on Android by default
2024-05-06 20:58:14 +02:00
David Heidelberg
35a83c3514 Enable IPO/LTO by default except for debug builds (#14198)
Test case:

```
$ cmake . -DRUN_IN_PLACE=TRUE -DCMAKE_BUILD_TYPE=Release -DBUILD_SERVER=TRUE -DENABLE_TOUCH=FALSE

         minetest minetestserver
W/o LTO:      13M           7.3M
W/  LTO:      11M           5.9M
difference:   15%            19%
```

Also fixes various compiler warnings resulting from compilation using LTO.

---------

Signed-off-by: David Heidelberg <david@ixit.cz>
2024-05-06 20:58:14 +02:00
sfan5
de09cac1e9 Drop valgrind from CI and instead enable ASan
The recently added ioctl use is reported as a false-positive by valgrind.
I tried moving it to different compilers/versions two times and only
hit further issues that were valgrind's fault.

Also includes a tiny fix.
2024-05-06 20:58:14 +02:00
sfan5
b64f4bdb3a Optimize fs::CopyFileContents on Linux and Windows 2024-05-06 20:58:14 +02:00
sfan5
008310aad9 Add unit tests for fs::CopyFileContents 2024-05-06 20:58:14 +02:00
sfan5
4d024d737c Bypass media transfer in single player 2024-05-06 20:58:14 +02:00
grorp
50edb30a18 Save the settings in more cases to avoid losing setting changes (especially on Android) (#14266) 2024-05-06 20:58:14 +02:00
Muhammad Rifqi Priyo Susanto
00f6bd0f08 Android: Use the correct value for notification (#14209)
The notification channel creation is moved into MainActivity.
The notification channel ID string is stored into a static variable.
The name and description of the notification channel are stored into the strings resource file.

Co-authored-by: sfan5 <sfan5@live.de>
2024-05-06 20:58:14 +02:00
Maintainer_
81e40a1172 Fix GameUI text staying visible during shutdown. (#14197) 2024-05-06 20:58:14 +02:00
grorp
fe4f89f3fa Touchscreen: Make server-sent overrides of button textures work (#14145) 2024-05-06 20:58:14 +02:00
Gregor Parzefall
0d372250c1 Fix TouchScreenGUI ignoring server-sent pitch changes 2024-05-06 20:58:14 +02:00
Gregor Parzefall
367720020c Fix touch input on Linux
The code relied on touch IDs being consecutive. This is true on Android, but not on Linux.
Therefore, touch input on Linux was broken since 53886dcdb5.
2024-05-06 20:58:14 +02:00
grorp
0dab82085d Fix unittest failure for release versions (#14067) 2024-05-06 20:58:14 +02:00
SmallJoker
cb211d63cd Merge remote-tracking branch 'upstream/stable-5' into HEAD 2023-12-04 19:04:18 +01:00
sfan5
2e497cc471 Merge remote-tracking branch 'origin/stable-5' into HEAD 2023-04-08 19:32:11 +02:00
sfan5
587f6656a4 Bump version to 5.6.1 2022-09-19 21:05:10 +02:00
sfan5
4377c03168 Bump used IrrlichtMt version 2022-09-16 20:27:29 +02:00
savilli
1e0520074c Fix UAF in craft recipes (#12763)
If you call minetest.clear_craft after minetest.register_alias_force, the craft definition reference may not be removed from m_output_craft_definitions leading to UAF.
2022-09-16 19:18:51 +02:00
DS
b9f6832347 Fix tooltips for dropdown, scrollbar and more (#12747) 2022-09-14 13:48:06 +02:00
Jude Melton-Houghton
f8bb0cd3d1 Fix potential use-after-free with item metadata (#12729)
This fixes a use-after-free bug in the case where itemstack metadata is accessed after the itemstack has been garbage-collected.
2022-09-14 13:48:06 +02:00
Lars Mueller
129aef758e Serialize: Restore forward compatibility 2022-09-14 13:48:06 +02:00
Lars Mueller
94f55cf406 Serialize: Use numbers for refs to work around LuaJIT limits 2022-09-14 13:48:06 +02:00
sfan5
a20b758e19 Allow looped animation to be used safely with old clients
fixes #12657
2022-09-14 13:48:06 +02:00
pecksin
128842becf Chat weblink: remove comma as delimiter (#12730) 2022-09-14 13:48:06 +02:00
x2048
d51331f51f Convert entity glow value to color space before adding to the light 2022-09-14 13:48:06 +02:00
Niklp
4ef221a645 Fix incorrectly placed label in tab_online (#12732) 2022-09-14 13:48:06 +02:00
savilli
79010e972e Fix and enable x86 build for Android (#12700) 2022-09-14 13:48:06 +02:00
fluxionary
0ca530e251 Fix texture_min_size 2022-09-14 13:48:06 +02:00
Elliott Lester
57b4d46dbc Apply DPI Scaling to GUIModalMenu (#12693)
Co-authored-by: sfan5 <sfan5@live.de>
2022-09-14 13:48:06 +02:00
rubenwardy
50df5e2f59 Fix crash when trying to overwrite a package
Before #11646, core.copy_dir would overwrite the target if it exists. Adding core.delete_dir restores the exact same behaviour

Fixes #12303
2022-09-14 13:48:06 +02:00
Fábio Rodrigues Ribeiro
b6db2c7262 Remove resolution of appstream screenshots (#12652)
resolves Appdata not valid #12597
2022-09-14 13:48:06 +02:00
sfan5
9441b69ad2 Move some CI jobs to newer compiler versions 2022-09-14 13:48:06 +02:00
x2048
08e3d16a58 Limit force shadow update to urgent blocks (#12692) 2022-09-14 13:48:06 +02:00
Lars Müller
3f3049fdba Check hp_max > 0 for entities (#12667) 2022-09-14 13:39:30 +02:00
Zughy
41fb7a8a7e Reassure previous nil behaviour for tiles and special_tiles (#12678)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
2022-09-14 13:39:20 +02:00
Zughy
5b9828e094 Fix crash when crafting callbacks return strings (#12685)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
2022-09-14 13:37:54 +02:00
Zughy
96e35585b0 Fix crash when stars are reset 2022-09-14 13:37:44 +02:00
sfan5
f035fe9336 Merge remote-tracking branch 'origin/stable-5' into HEAD 2022-08-04 22:54:13 +02:00
sfan5
44c2e33c78 Bump version to 5.5.1 2022-05-15 21:53:21 +02:00
rubenwardy
2785dcbbbf Fix broken dependency enabling due to missing enabled field 2022-05-14 18:24:46 +01:00
sfan5
9b03bd3243 Fix Docker build
prometheus-cpp switched to C++14 in April (after we did) so this issue only affects older branches.
2022-05-14 18:51:48 +02:00
Jude Melton-Houghton
8f30456ee3 Fix cooking and fuel crafts with aliases 2022-05-14 18:33:42 +02:00
Octavian
38557ff635 Fix possible unreliable behavior due to uninitialized variables 2022-05-14 18:33:42 +02:00
Lars Müller
7bc2cde4dd HUD: Update selection mesh every frame (#12270)
Fixes outdated selection boxes after entity property changes.
2022-05-14 18:33:42 +02:00
Lars Müller
f065d3a06b 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-14 18:33:42 +02:00
Jude Melton-Houghton
21f7e3a987 Enable dependencies when enabling modpacks (#12202) 2022-05-14 18:33:42 +02:00
Jude Melton-Houghton
9f688bc433 Fix enabling of dependencies with identical names (#12253) 2022-05-14 18:33:42 +02:00
rubenwardy
6e9d31d4fb Fix mods not being recursively enabled
Fixes #12290
2022-05-14 18:33:42 +02:00
sfan5
e81c48526b 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-14 18:33:42 +02:00
SmallJoker
b405985b80 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-14 18:33:42 +02:00
rubenwardy
8b010c5a9f ContentDB: Fix ungraceful crash on aliases when list download fails
Fixes #12267 and fixes #12154
2022-05-14 18:33:42 +02:00
sfan5
1e7b5d6fdb 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-14 18:33:42 +02:00
sfan5
a55982e7f0 Fix password changing getting stuck if wrong password is entered once 2022-05-14 18:33:42 +02:00
sfan5
1ac378063e Apply disallow_empty_password to password changes too 2022-05-14 18:33:42 +02:00
sfan5
d497c92684 Fix race condition in registration leading to duplicate create_auth calls 2022-05-14 18:33:42 +02:00
paradust7
677dc2c155 Remove HW_buffer_counter after IrrlichtMt fix to remove HWBufferMap (#12232)
Keep code and use version check instead, for backwards compatibility
2022-05-14 18:33:42 +02:00
Alex
beea8deeb5 Fix invalid queued package element and path (#12218) 2022-05-14 18:33:42 +02:00
Giuseppe Bilotta
0d0f1a2fb2 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-05-14 18:33:42 +02:00
paradust7
439701ed7a 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-05-14 18:33:42 +02:00
ShadowNinja
d945d0129c Fix OOB read in trim("") 2022-05-14 18:33:42 +02:00
Dmitry Kostenko
cc91477308 Avoid negation of comparison operator (luacheck warning) 2022-05-14 18:33:42 +02:00
Daroc Alden
ac139ec03d Fix memory leak in EmergeManager
EmergeManager keeps a copy of the BiomeGen that it creates, but
never deletes it.
2022-05-14 18:33:42 +02:00
Gregor Parzefall
b4f0e834bf Fix footsteps for players whose collision box min y != 0 (#12110) 2022-05-14 18:33:42 +02:00
Daroc Alden
6e6cdc834f Fix undefined behavior in TileLayer (#12125)
Initialize the values properly
2022-05-14 18:33:42 +02:00
Daroc Alden
4b81ae1b35 Fix memory leak from SpatialAreaStore (#12120) 2022-05-14 18:33:42 +02:00
sfan5
d569dc45a8 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-05-14 18:33:42 +02:00
sfan5
23d49fda29 Clean up ClientReady packet handling
fixes #12073
2022-05-14 18:33:42 +02:00
pecksin
62ad2c3bc1 Use absolute value for bouncy in collision (#11969)
[backport: removed devtest change and protocol_version comparison]
2022-05-14 18:33:42 +02:00
sfan5
25373ad294 Remove awful Mingw32 workarounds
Instead a warning is triggered if an affected compiler is detected.
closes #12022
2022-05-12 11:36:50 +02:00
sfan5
26d0c0fd8d Fix broken server startup if curl is disabled (#12046) 2022-05-12 11:36:39 +02:00
Lars Mueller
3afffcd36b Fix builtin statbar backgrounds
see #12000
2022-05-12 11:36:11 +02:00
sfan5
5440de1785 Merge remote-tracking branch 'origin/stable-5' into HEAD 2022-01-30 23:10:56 +01:00
rubenwardy
25a56f11c8 Bump version to 5.4.2 2021-10-22 23:06:51 +01:00
rubenwardy
8271c6481f Fix manifest and various things 2021-10-20 15:27:30 +01:00
sfan5
83e26f839d Reserve vectors before pushing and other code quality changes (#11161) 2021-10-20 14:25:39 +01:00
sfan5
c3f7905d82 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-19 19:23:00 +01:00
sfan5
05b54a8d18 Shave off buffer copies in networking code (#11607) 2021-10-19 19:22:46 +01:00
rubenwardy
e5cfdd369e Update deps ref 2021-10-18 18:33:25 +01:00
rubenwardy
c61d8cfb85 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-18 18:12:03 +01:00
NeroBurner
27f4195471 Move build/android directory to root of project (#11283) 2021-10-18 18:11:33 +01:00
sfan5
b2596eda32 Bump version to 5.4.1 2021-04-10 18:41:12 +02:00
waxtatect
9379440fcb Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
Brian Gaucher
b7c502c8d1 Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
Markus Mikkonen
3c16d2d9b4 Translated using Weblate (Finnish)
Currently translated at 3.2% (44 of 1356 strings)
2021-04-10 17:51:40 +02:00
Tviljan
6cbc03a418 Translated using Weblate (Finnish)
Currently translated at 3.2% (44 of 1356 strings)
2021-04-10 17:51:40 +02:00
Edward
15ecc0fa65 Translated using Weblate (Russian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
ssantos
7f2f8cdad1 Translated using Weblate (Portuguese)
Currently translated at 93.2% (1264 of 1356 strings)
2021-04-10 17:51:40 +02:00
waxtatect
a64646cb7b Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
David Leal
05f531c538 Translated using Weblate (Spanish)
Currently translated at 79.7% (1081 of 1356 strings)
2021-04-10 17:51:40 +02:00
François Delpierre
7ca335446b Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
waxtatect
99e96a6581 Translated using Weblate (French)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
BreadW
7200d8f90e Translated using Weblate (Japanese)
Currently translated at 99.8% (1354 of 1356 strings)
2021-04-10 17:51:40 +02:00
GnuPGを使うべきだ
7038837aca Translated using Weblate (Japanese)
Currently translated at 99.7% (1353 of 1356 strings)
2021-04-10 17:51:40 +02:00
ItsWidee
541dcc0e5a Translated using Weblate (French)
Currently translated at 98.0% (1330 of 1356 strings)
2021-04-10 17:51:40 +02:00
François Delpierre
1060b5aabf Translated using Weblate (French)
Currently translated at 96.6% (1311 of 1356 strings)
2021-04-10 17:51:40 +02:00
Dainis
6ea73c4982 Translated using Weblate (Latvian)
Currently translated at 28.6% (388 of 1356 strings)
2021-04-10 17:51:40 +02:00
Konstantin Yeliseyev
cff847273a Translated using Weblate (Russian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
ResuUman
e669f8db9b Translated using Weblate (Polish)
Currently translated at 72.4% (982 of 1356 strings)
2021-04-10 17:51:40 +02:00
Mateusz Mendel
461cc30842 Translated using Weblate (Polish)
Currently translated at 72.4% (982 of 1356 strings)
2021-04-10 17:51:40 +02:00
gnu-ewm
13d7cb957c Translated using Weblate (Polish)
Currently translated at 71.6% (972 of 1356 strings)
2021-04-10 17:51:40 +02:00
Alessandro Mandelli
47a439a905 Translated using Weblate (Italian)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:40 +02:00
Hatlábú Farkas
053fb96694 Translated using Weblate (Hungarian)
Currently translated at 75.8% (1028 of 1356 strings)
2021-04-10 17:51:39 +02:00
ItsWidee
b72c1f7367 Translated using Weblate (French)
Currently translated at 96.5% (1309 of 1356 strings)
2021-04-10 17:51:39 +02:00
matiasC
e90738575f Translated using Weblate (Spanish)
Currently translated at 79.5% (1079 of 1356 strings)
2021-04-10 17:51:39 +02:00
Joaquín Villalba
35718eec9c Translated using Weblate (Spanish)
Currently translated at 79.5% (1079 of 1356 strings)
2021-04-10 17:51:39 +02:00
AnthonyDe
8285a53152 Translated using Weblate (Spanish)
Currently translated at 79.5% (1079 of 1356 strings)
2021-04-10 17:51:39 +02:00
Michalis
116fe7815b Translated using Weblate (Greek)
Currently translated at 8.8% (120 of 1356 strings)
2021-04-10 17:51:39 +02:00
Yangjun Wang
4c2efd7da3 Translated using Weblate (Chinese (Simplified))
Currently translated at 94.7% (1285 of 1356 strings)
2021-04-10 17:51:39 +02:00
Liu Tao
1a433e3185 Translated using Weblate (Chinese (Simplified))
Currently translated at 94.7% (1285 of 1356 strings)
2021-04-10 17:51:39 +02:00
Yangjun Wang
fa98a00916 Translated using Weblate (Chinese (Simplified))
Currently translated at 92.5% (1255 of 1356 strings)
2021-04-10 17:51:39 +02:00
David Leal
f4dd46ad60 Translated using Weblate (Spanish)
Currently translated at 79.0% (1072 of 1356 strings)
2021-04-10 17:51:39 +02:00
Joaquín Villalba
41825ccfbb Translated using Weblate (Spanish)
Currently translated at 78.0% (1059 of 1356 strings)
2021-04-10 17:51:39 +02:00
David Leal
4d1a5f12c0 Translated using Weblate (Spanish)
Currently translated at 78.0% (1059 of 1356 strings)
2021-04-10 17:51:39 +02:00
Agustin Calderon
cc58d56c6d Translated using Weblate (Spanish)
Currently translated at 78.0% (1059 of 1356 strings)
2021-04-10 17:51:39 +02:00
abidin toumi
683ef07312 Translated using Weblate (Arabic)
Currently translated at 25.7% (349 of 1356 strings)
2021-04-10 17:51:39 +02:00
Tirifto
c77c78cef5 Translated using Weblate (Esperanto)
Currently translated at 94.6% (1283 of 1356 strings)
2021-04-10 17:51:39 +02:00
Oğuz Ersen
88517030a4 Translated using Weblate (Turkish)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:39 +02:00
THANOS SIOURDAKIS
45471e8e63 Translated using Weblate (Greek)
Currently translated at 8.8% (120 of 1356 strings)
2021-04-10 17:51:39 +02:00
Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi
4e620beb75 Translated using Weblate (Malay)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:39 +02:00
winniepee
e7ab875b47 Translated using Weblate (Chinese (Simplified))
Currently translated at 92.4% (1254 of 1356 strings)
2021-04-10 17:51:39 +02:00
Ayes
be74ed9ab6 Translated using Weblate (Estonian)
Currently translated at 39.5% (536 of 1356 strings)
2021-04-10 17:51:39 +02:00
Wuzzy
52b2eacd37 Translated using Weblate (German)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:39 +02:00
Marian
6b4210a2ea Translated using Weblate (Slovak)
Currently translated at 100.0% (1356 of 1356 strings)
2021-04-10 17:51:39 +02:00
narrnika
740d0da5ee Translated using Weblate (Russian)
Currently translated at 99.3% (1347 of 1356 strings)
2021-04-10 17:51:07 +02:00
Mateusz Mendel
34883d356e Translated using Weblate (Polish)
Currently translated at 71.2% (966 of 1356 strings)
2021-04-10 17:51:07 +02:00
Giov4
aeafcce314 Translated using Weblate (Italian)
Currently translated at 99.7% (1352 of 1356 strings)
2021-04-10 17:51:07 +02:00
savilli
ae1d82c325 Fix hud_change and hud_remove after hud_add (#10997) 2021-04-09 22:05:22 +02:00
Vitaliy
1c89a07226 Restore minimal normal texture support (for minimap shading) 2021-04-09 22:04:51 +02:00
sfan5
43e262f13e Don't apply connection timeout limit to locally hosted servers
fixes #11085
2021-04-05 16:02:47 +02:00
sfan5
e5f802ab5c Fix server favorites not saving when client/serverlist/ doesn't exist already (#11152) 2021-04-05 16:02:32 +02:00
Lars Müller
847860fc5c Block & report player self-interaction (#11137) 2021-04-05 16:01:27 +02:00
SmallJoker
77e936445f Protect dropping from far node inventories
Also changes if/if to switch/case
2021-04-05 16:01:21 +02:00
SmallJoker
41beb74ef7 Protect per-player detached inventory actions 2021-04-05 16:01:15 +02:00
Elias Fleckenstein
67be50b706 Make pkgmgr handle modpacks containing modpacks properly
fixes #10550
2021-04-05 16:01:10 +02:00
rubenwardy
cd840b7c9d pkgmgr: Fix crash when .conf release field is invalid
Fixes #10942
2021-04-05 16:01:03 +02:00
sfan5
07903949ec Merge remote-tracking branch 'origin/stable-5' into HEAD 2021-02-23 20:18:23 +01:00
sfan5
d2156ddaad Merge remote-tracking branch 'origin/stable-5' into HEAD 2020-07-09 22:21:48 +02:00
sfan5
a84ff4b3ff Merge remote-tracking branch 'origin/stable-5' into HEAD 2020-04-05 18:44:51 +02:00
rubenwardy
c02f13d33f Release 5.1.1 2020-01-11 18:29:02 +00:00
rubenwardy
f6490859fd Translated using Weblate (Japanese (Kansai))
Currently translated at 0.2% (2 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
4b7816dbf4 Translated using Weblate (Burmese)
Currently translated at 0.2% (2 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
86ffbc3ec5 Translated using Weblate (Kazakh)
Currently translated at 0.2% (2 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
67257f44a5 Translated using Weblate (Arabic)
Currently translated at 6.1% (78 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
3086f5567a Translated using Weblate (Vietnamese)
Currently translated at 2.5% (32 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
bb8acb095d Translated using Weblate (Portuguese)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
24be3cbb5f Translated using Weblate (Basque)
Currently translated at 15.1% (193 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
9773191103 Translated using Weblate (Greek)
Currently translated at 1.4% (18 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
ddc703c3ec Translated using Weblate (Filipino)
Currently translated at 0.2% (2 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
09ec204e4b Translated using Weblate (Thai)
Currently translated at 66.9% (852 of 1274 strings)
2020-01-11 18:29:02 +00:00
rubenwardy
8b6cafa0e0 Translated using Weblate (Lao)
Currently translated at 0.2% (2 of 1274 strings)
2020-01-11 18:29:02 +00:00
Osoitz
1ee8be9d43 Translated using Weblate (Basque)
Currently translated at 15.1% (192 of 1274 strings)
2020-01-10 18:57:47 +00:00
Dhimas Wnz
91bc190d21 Translated using Weblate (Indonesian)
Currently translated at 96.9% (1234 of 1274 strings)
2020-01-10 18:57:47 +00:00
THANOS SIOURDAKIS
4dc833b642 Translated using Weblate (Greek)
Currently translated at 1.3% (17 of 1274 strings)
2020-01-10 18:57:47 +00:00
universales
895e9f8d5c Translated using Weblate (Spanish)
Currently translated at 61.9% (789 of 1274 strings)
2020-01-10 18:57:47 +00:00
Osoitz
12906ff631 Translated using Weblate (Basque)
Currently translated at 9.7% (123 of 1274 strings)
2020-01-10 18:57:47 +00:00
Osoitz
9c9bcff107 Added translation using Weblate (Basque) 2020-01-10 18:57:47 +00:00
Hotower
443ca5c63b Translated using Weblate (Chinese (Simplified))
Currently translated at 65.1% (830 of 1274 strings)
2020-01-10 18:57:47 +00:00
Stas Kies
1102b1fc4c Translated using Weblate (German)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:47 +00:00
abidin toumi
0d089eab21 Translated using Weblate (Arabic)
Currently translated at 6.0% (77 of 1274 strings)
2020-01-10 18:57:47 +00:00
zaoqi
b44fada29e Translated using Weblate (Chinese (Simplified))
Currently translated at 65.1% (830 of 1274 strings)
2020-01-10 18:57:47 +00:00
Yangjun Wang
859ea160e6 Translated using Weblate (Chinese (Simplified))
Currently translated at 63.2% (805 of 1274 strings)
2020-01-10 18:57:47 +00:00
Ács Zoltán
1c49e2ffc0 Translated using Weblate (Hungarian)
Currently translated at 61.9% (789 of 1274 strings)
2020-01-10 18:57:47 +00:00
Tirifto
140245c58d Translated using Weblate (Esperanto)
Currently translated at 97.2% (1238 of 1274 strings)
2020-01-10 18:57:47 +00:00
Petter Reinholdtsen
47adcced60 Translated using Weblate (Norwegian Bokmål)
Currently translated at 43.3% (552 of 1274 strings)
2020-01-10 18:57:47 +00:00
Luboš Nečas
a2054deb12 Translated using Weblate (Czech)
Currently translated at 48.8% (622 of 1274 strings)
2020-01-10 18:57:47 +00:00
Tirifto
30fdfd9ded Translated using Weblate (Esperanto)
Currently translated at 94.9% (1209 of 1274 strings)
2020-01-10 18:57:47 +00:00
ramon.venson
a87a86eb92 Translated using Weblate (Portuguese (Brazil))
Currently translated at 96.9% (1235 of 1274 strings)
2020-01-10 18:57:47 +00:00
Daniel Mancini
49dfbcfbc8 Translated using Weblate (Portuguese (Brazil))
Currently translated at 96.9% (1235 of 1274 strings)
2020-01-10 18:57:47 +00:00
Andrei Stepanov
c558a4f4f6 Translated using Weblate (Russian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Andrei Stepanov
4f49a2248f Translated using Weblate (Russian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Andrei Stepanov
4e57da42c1 Translated using Weblate (Russian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Andrei Stepanov
4f6c9e206c Translated using Weblate (Russian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Andrei Stepanov
699e1d4b77 Translated using Weblate (Russian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Matej Mlinar
fa2978b3b9 Translated using Weblate (Slovenian)
Currently translated at 43.9% (559 of 1274 strings)
2020-01-10 18:57:46 +00:00
abidin toumi
ffcdf741fc Translated using Weblate (Arabic)
Currently translated at 5.7% (73 of 1274 strings)
2020-01-10 18:57:46 +00:00
Fixer
429d7f33d4 Translated using Weblate (Ukrainian)
Currently translated at 42.1% (536 of 1274 strings)
2020-01-10 18:57:46 +00:00
Andrei Stepanov
b6a229775e Translated using Weblate (Russian)
Currently translated at 81.9% (1044 of 1274 strings)
2020-01-10 18:57:46 +00:00
abidin toumi
0a4580368a Translated using Weblate (Arabic)
Currently translated at 5.6% (71 of 1274 strings)
2020-01-10 18:57:46 +00:00
abidin toumi
e5b191e1f1 Translated using Weblate (Arabic)
Currently translated at 4.2% (53 of 1274 strings)
2020-01-10 18:57:46 +00:00
Andrei Stepanov
a07acc067b Translated using Weblate (Russian)
Currently translated at 81.7% (1041 of 1274 strings)
2020-01-10 18:57:46 +00:00
abidin toumi
01e763f879 Added translation using Weblate (Arabic) 2020-01-10 18:57:46 +00:00
Viktar Vauchkevich
a95e75261a Translated using Weblate (Belarusian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Julien Maulny
dcaa7ac609 Translated using Weblate (French)
Currently translated at 97.0% (1236 of 1274 strings)
2020-01-10 18:57:46 +00:00
Jacques Lagrange
7d2ae10849 Translated using Weblate (Italian)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
642cac3759 Translated using Weblate (Japanese (Kansai))
Currently translated at 0.1% (1 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
662af2edba Translated using Weblate (Dhivehi)
Currently translated at 8.2% (105 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
6f97e15a8f Translated using Weblate (Chinese (Simplified))
Currently translated at 63.0% (803 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
ab2fa2ca9d Translated using Weblate (Burmese)
Currently translated at 0.1% (1 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
4666c99b27 Translated using Weblate (Kyrgyz)
Currently translated at 8.6% (110 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
e38415c56d Translated using Weblate (Slovenian)
Currently translated at 42.0% (535 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
3f3fce4664 Translated using Weblate (Kannada)
Currently translated at 3.0% (38 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
1407a7bc8a Translated using Weblate (Kazakh)
Currently translated at 0.1% (1 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
1d268f4b83 Translated using Weblate (Norwegian Nynorsk)
Currently translated at 31.2% (398 of 1274 strings)
2020-01-10 18:57:46 +00:00
Krock
92aab79d27 Translated using Weblate (Italian)
Currently translated at 96.9% (1234 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
0823bb1276 Translated using Weblate (Hebrew)
Currently translated at 4.3% (55 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
18e42efa01 Translated using Weblate (Hungarian)
Currently translated at 61.9% (788 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
0ea16328df Translated using Weblate (Estonian)
Currently translated at 14.4% (183 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
b037efc5c6 Translated using Weblate (Esperanto)
Currently translated at 79.6% (1014 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
839bb71389 Translated using Weblate (Greek)
Currently translated at 1.1% (14 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
2ef7df5cfe Translated using Weblate (Danish)
Currently translated at 49.5% (631 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
f5d2d79f75 Translated using Weblate (Portuguese (Brazil))
Currently translated at 96.4% (1228 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
8e5fa96ffc Translated using Weblate (Filipino)
Currently translated at 0.1% (1 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
6dbbe07d50 Translated using Weblate (Thai)
Currently translated at 66.8% (851 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
3c23410753 Translated using Weblate (Lithuanian)
Currently translated at 15.4% (196 of 1274 strings)
2020-01-10 18:57:45 +00:00
Krock
8e35ab78b4 Translated using Weblate (Lao)
Currently translated at 0.1% (1 of 1274 strings)
2020-01-10 18:57:45 +00:00
Allan Nordhøy
7f2911b7f0 Translated using Weblate (Italian)
Currently translated at 96.9% (1234 of 1274 strings)
2020-01-10 18:57:45 +00:00
Mateusz Mendel
d877e90301 Translated using Weblate (Polish)
Currently translated at 81.1% (1033 of 1274 strings)
2020-01-10 18:57:45 +00:00
Vicente Carrasco Alvarez
93db4be726 Translated using Weblate (Spanish)
Currently translated at 61.5% (783 of 1274 strings)
2020-01-10 18:57:45 +00:00
Mateusz Mendel
1f419ad19f Translated using Weblate (Polish)
Currently translated at 81.1% (1033 of 1274 strings)
2020-01-10 18:57:45 +00:00
Muhammad Nur Hidayat Yasuyoshi
3c7f6508ad Translated using Weblate (Malay)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:45 +00:00
Mattias Münster
39449d4b63 Translated using Weblate (Swedish)
Currently translated at 32.7% (417 of 1274 strings)
2020-01-10 18:57:45 +00:00
Jacques Lagrange
28e05295fa Translated using Weblate (Italian)
Currently translated at 96.9% (1234 of 1274 strings)
2020-01-10 18:57:45 +00:00
Ács Zoltán
60c18d3550 Translated using Weblate (Hungarian)
Currently translated at 61.9% (788 of 1274 strings)
2020-01-10 18:57:45 +00:00
ssantos
482ab186a2 Translated using Weblate (Portuguese)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:45 +00:00
BreadW
4814195dc4 Translated using Weblate (Japanese)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:45 +00:00
Wuzzy
d215b7a10e Translated using Weblate (German)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:45 +00:00
nautilusx
0e52b78590 Translated using Weblate (German)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:45 +00:00
monolifed
b3a9d607c4 Translated using Weblate (Turkish)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:45 +00:00
Oguz Ersen
c00081b62c Translated using Weblate (Turkish)
Currently translated at 100.0% (1274 of 1274 strings)
2020-01-10 18:57:44 +00:00
William Breathitt Gray
5e4739b460 Fix find_path for newer jsoncpp installations
The upstream JsonCpp project has renamed the `json/features.h` file to
`json/json_features.h`. This patch fixes the JsonCpp installation search
by looking for `json/allocator.h` which has not been renamed on newer
versions of JsonCpp.

Fixes: https://github.com/minetest/minetest/issues/9119
2019-12-31 21:39:16 +00:00
SmallJoker
0d8f598df2 Fix LocalPlayer-bound sound playback broken by 81c2370 2019-12-31 21:31:53 +00:00
Wuzzy
2ef04cc308 Fix item eat sound not played if last item (#9239) 2019-12-31 21:31:53 +00:00
rubenwardy
7a0884e2cd Fix spaces breaking formspec_version[] tag 2019-12-31 21:31:53 +00:00
ANAND
fa858530cc Use a safer implementation of gsub in core.chat_format_message (#9133)
This search-and-replace implementation does not use Lua pattern-matching
2019-12-31 21:31:53 +00:00
sfan5
1c61fe5ed9 Rework packet receiving in ServerThread
Notably it tries to receive all queued packets
between server steps, not just one.
2019-12-31 21:31:53 +00:00
Dmitry Marakasov
57409ef382 Fix build issue due to conflicting s64 type definitions (#9064)
See comment in irrlichttypes.h and https://sourceforge.net/p/irrlicht/bugs/433/
2019-12-31 21:31:52 +00:00
SmallJoker
06ba826803 Formspecs: Reset version number on rebuild 2019-12-26 17:24:27 +00:00
rubenwardy
6e6ef9489f Continue with 5.1.1-dev 2019-12-26 17:24:23 +00:00
Loic Blot
45bbe39d1f Add arm64-v8a but it's not sufficient for 64bit build 2019-11-09 12:50:53 +01:00
Loic Blot
6c9fc13083 Bump to version code 25 2019-11-09 11:37:46 +01:00
MoNTE48
4c8a642388 Android: build fixes & compat fixes 2019-11-09 11:23:31 +01:00
sfan5
6208c9d64f Merge remote-tracking branch 'origin/stable-5' into HEAD 2019-10-12 15:59:36 +02:00
sfan5
76325d0ba9 Bump version to 5.0.1 2019-03-31 22:57:45 +02:00
rubenwardy
cf1802a6de Prevent multi-line chat messages server-side (#8420) 2019-03-28 21:49:03 +00:00
sfan5
538a7b12bd Fix texture rotation for wallmounted nodeboxes
fixes #8358
2019-03-19 22:37:11 +01:00
sfan5
57e0f52aaa httpfetch: Disable IPv6 here too if requested by settings (#8399) 2019-03-19 02:18:34 +00:00
Paramat
1ae0335b62 num_emerge_threads: Initialise value to cope with setting syntax error (#8396) 2019-03-19 02:18:26 +00:00
paramat
ca1bff6b66 num_emerge_threads: Fix documentation of automatic selection 2019-03-19 02:18:17 +00:00
Paramat
10cc62d2ca num_emerge_threads: Warn of crashes when > 1 (#8357) 2019-03-14 17:58:19 +00:00
rubenwardy
dd451a8a00 Fix cast from const by accessing string data directly (#8354)
Fixes #8327
2019-03-12 20:25:55 +00:00
rubenwardy
444ec1e412 HPChange Reason: Fix push after free, and type being overwritten (#8359)
* HPChange Reason: Fix push after free, and type being overwritten

Fixes #8227 and #8344
2019-03-12 20:25:48 +00:00
Paramat
82739f4d7d Change 'num_emerge_threads' default to 1 (#8303) 2019-03-11 22:07:19 +00:00
sofar
19825d853e getS16NoEx() returns true unless syntactical error in conf. (#8304)
The getS16NoEx() handler will return true unless there is a
`[num_emerge_threads]` line in the `minetest.conf` at which
point the excption handler part is reached. Due to the fact that
`defaultsettings.cpp` has a default value set for this setting,
that never will happen.

Because of this, the code will never check the number of threads on
the system, and keep `nthreads = 0`. If that happens, the value is
changed to `1` and only 1 emerge thread will be used.

The default should be set to `1` instead, due to the potential unsafe
consequences for the standard sqlite map files, but that should be a
separate commit that also adds documentation for that setting. This
commit focuses on removing this `hiding` bug instead.
2019-03-11 22:07:19 +00:00
rubenwardy
d8ece2e3e9 Fix serialization of std::time_t by casting to u64 first (#8353)
Fixes #8332
2019-03-11 22:07:19 +00:00
Paramat
bf4deb0ce6 Confirm registration GUI: Remove positional strings to fix Windows bug (#8258)
Positional strings don't work on some Windows builds.
Remove server address string, leave player name string present.
2019-03-11 22:07:19 +00:00
rubenwardy
da4739a26c Fix detach inventory serialisation (#8331) 2019-03-11 22:07:19 +00:00
rubenwardy
fc24bf0915 Fix incorrect string length check after cast 2019-03-11 22:07:19 +00:00
rubenwardy
9329b99cba Continue with 5.0.1-dev 2019-03-11 22:07:12 +00:00
49 changed files with 712 additions and 214 deletions

View File

@@ -28,8 +28,17 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gettext openjdk-11-jdk-headless
- name: Build with Gradle
- name: Build AAB with Gradle
# We build an AAB as well for uploading to the the Play Store.
run: cd android; ./gradlew bundlerelease
- name: Build APKs with Gradle
# "assemblerelease" is very fast after "bundlerelease".
run: cd android; ./gradlew assemblerelease
- name: Save AAB artifact
uses: actions/upload-artifact@v4
with:
name: Minetest-release.aab
path: android/app/build/outputs/bundle/release/app-release.aab
- name: Save armeabi artifact
uses: actions/upload-artifact@v3
with:

View File

@@ -83,7 +83,7 @@ jobs:
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-7 valgrind
install_linux_deps clang-7 llvm
- name: Build
run: |
@@ -91,15 +91,12 @@ jobs:
env:
CC: clang-7
CXX: clang++-7
CMAKE_FLAGS: '-DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address"'
- name: Unittest
run: |
./bin/minetest --run-unittests
- name: Valgrind
run: |
valgrind --leak-check=full --leak-check-heuristics=all --undef-value-errors=no --error-exitcode=9 ./bin/minetest --run-unittests
# Current clang version
clang_14:
runs-on: ubuntu-22.04

View File

@@ -1,11 +1,4 @@
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()
cmake_minimum_required(VERSION 3.12)
# This can be read from ${PROJECT_NAME} after project() is called
project(minetest)
@@ -19,7 +12,7 @@ set(CLANG_MINIMUM_VERSION "7.0.1")
# You should not need to edit these manually, use util/bump_version.sh
set(VERSION_MAJOR 5)
set(VERSION_MINOR 8)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
# Change to false for releases
@@ -44,6 +37,13 @@ set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
set(BUILD_BENCHMARKS FALSE CACHE BOOL "Build benchmarks")
set(BUILD_DOCUMENTATION TRUE CACHE BOOL "Build documentation")
set(DEFAULT_ENABLE_LTO TRUE)
# by default don't enable on Debug builds to get faster builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEFAULT_ENABLE_LTO FALSE)
endif()
set(ENABLE_LTO ${DEFAULT_ENABLE_LTO} CACHE BOOL "Use Link Time Optimization")
set(DEFAULT_RUN_IN_PLACE FALSE)
if(WIN32)
set(DEFAULT_RUN_IN_PLACE TRUE)
@@ -66,6 +66,20 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
endif()
# FIXME: Windows build fails in multiple places to link, needs to be investigated.
if (ENABLE_LTO AND NOT WIN32)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT lto_output)
if(lto_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "LTO/IPO is enabled")
else()
message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
endif()
else()
message(STATUS "LTO/IPO is not enabled")
endif()
set(ENABLE_UPDATE_CHECKER (NOT ${DEVELOPMENT_BUILD}) CACHE BOOL
"Whether to enable update checks by default")

View File

@@ -80,6 +80,17 @@ public class GameActivity extends NativeActivity {
makeFullScreen();
}
private native void saveSettings();
@Override
protected void onStop() {
super.onStop();
// Avoid losing setting changes in case the app is onDestroy()ed later.
// Saving stuff in onStop() is recommended in the Android activity
// lifecycle documentation.
saveSettings();
}
@Override
public void onBackPressed() {
// Ignore the back press so Minetest can handle it

View File

@@ -20,23 +20,29 @@ with this program; if not, write to the Free Software Foundation, Inc.,
package net.minetest.minetest;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import static net.minetest.minetest.UnzipService.*;
public class MainActivity extends AppCompatActivity {
public static final String NOTIFICATION_CHANNEL_ID = "Minetest channel";
private final static int versionCode = BuildConfig.VERSION_CODE;
private static final String SETTINGS = "MinetestSettings";
private static final String TAG_VERSION_CODE = "versionCode";
@@ -81,12 +87,18 @@ public class MainActivity extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
IntentFilter filter = new IntentFilter(ACTION_UPDATE);
registerReceiver(myReceiver, filter);
mProgressBar = findViewById(R.id.progressBar);
mTextView = findViewById(R.id.textView);
sharedPreferences = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);
checkAppVersion();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
createNotificationChannel();
}
private void checkAppVersion() {
@@ -114,6 +126,28 @@ public class MainActivity extends AppCompatActivity {
startActivity(intent);
}
@RequiresApi(Build.VERSION_CODES.O)
private void createNotificationChannel() {
NotificationManager notifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notifyManager == null)
return;
NotificationChannel notifyChannel = new NotificationChannel(
NOTIFICATION_CHANNEL_ID,
getString(R.string.notification_channel_name),
NotificationManager.IMPORTANCE_LOW
);
notifyChannel.setDescription(getString(R.string.notification_channel_description));
// Configure the notification channel without sound set
notifyChannel.setSound(null, null);
notifyChannel.enableLights(false);
notifyChannel.enableVibration(false);
// It is fine to always create the notification channel because creating a channel
// with the same ID is the same as overriding it (only its name and description).
notifyManager.createNotificationChannel(notifyChannel);
}
@Override
public void onBackPressed() {
// Prevent abrupt interruption when copy game files from assets

View File

@@ -22,7 +22,6 @@ 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;
@@ -58,9 +57,11 @@ public class UnzipService extends IntentService {
private String failureMessage;
private static boolean isRunning = false;
public static synchronized boolean getIsRunning() {
return isRunning;
}
private static synchronized void setIsRunning(boolean v) {
isRunning = v;
}
@@ -99,28 +100,13 @@ public class UnzipService extends IntentService {
}
}
@NonNull
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);
builder = new Notification.Builder(this, MainActivity.NOTIFICATION_CHANNEL_ID);
} else {
builder = new Notification.Builder(this);
}
@@ -135,9 +121,9 @@ public class UnzipService extends IntentService {
PendingIntent intent = PendingIntent.getActivity(this, 0,
notificationIntent, pendingIntentFlag);
builder.setContentTitle(getString(R.string.notification_title))
builder.setContentTitle(getString(R.string.unzip_notification_title))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText(getString(R.string.notification_description))
.setContentText(getString(R.string.unzip_notification_description))
.setContentIntent(intent)
.setOngoing(true)
.setProgress(0, 0, true);
@@ -198,7 +184,7 @@ public class UnzipService extends IntentService {
}
}
private void publishProgress(@Nullable Notification.Builder notificationBuilder, @StringRes int message, int progress) {
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);

View File

@@ -2,7 +2,9 @@
<resources>
<string name="label">Minetest</string>
<string name="loading">Loading&#8230;</string>
<string name="notification_title">Loading Minetest</string>
<string name="notification_description">Less than 1 minute&#8230;</string>
<string name="notification_channel_name">General notification</string>
<string name="notification_channel_description">Notifications from Minetest</string>
<string name="unzip_notification_title">Loading Minetest</string>
<string name="unzip_notification_description">Less than 1 minute&#8230;</string>
<string name="ime_dialog_done">Done</string>
</resources>

View File

@@ -2,9 +2,9 @@
project.ext.set("versionMajor", 5) // Version Major
project.ext.set("versionMinor", 8) // Version Minor
project.ext.set("versionPatch", 0) // Version Patch
project.ext.set("versionPatch", 1) // Version Patch
// ^ keep in sync with cmake
project.ext.set("versionCode", 46) // Android Version Code
project.ext.set("versionCode", 48) // 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

View File

@@ -43,19 +43,25 @@ android {
}
// get precompiled deps
task downloadDeps(type: Download) {
def depsDir = new File(buildDir.parent, 'deps')
def depsZip = new File(buildDir, 'deps.zip')
def depsDir = new File(buildDir.parent, 'deps')
if (new File(depsDir, 'armeabi-v7a').exists()) {
task getDeps {
doLast { logger.lifecycle('Using existing deps from {}', depsDir) }
}
} else {
task downloadDeps(type: Download) {
def depsZip = new File(buildDir, 'deps.zip')
src 'https://github.com/minetest/minetest_android_deps/releases/download/latest/deps.zip'
dest depsZip
overwrite false
src 'https://github.com/minetest/minetest_android_deps/releases/download/5.8.0/deps.zip'
dest depsZip
overwrite false
task getDeps(dependsOn: downloadDeps, type: Copy) {
depsDir.mkdir()
from zipTree(depsZip)
into depsDir
doFirst { logger.lifecycle('Extracting to {}', depsDir) }
task getDeps(dependsOn: downloadDeps, type: Copy) {
depsDir.mkdir()
from zipTree(depsZip)
into depsDir
doFirst { logger.lifecycle('Extracting to {}', depsDir) }
}
}
}

View File

@@ -608,6 +608,16 @@ local function get_formspec(dialogdata)
end
-- On Android, closing the app via the "Recents screen" won't result in a clean
-- exit, discarding any setting changes made by the user.
-- To avoid that, we write the settings file in more cases on Android.
function write_settings_early()
if PLATFORM == "Android" then
core.settings:write()
end
end
local function buttonhandler(this, fields)
local dialogdata = this.data
dialogdata.leftscroll = core.explode_scrollbar_event(fields.leftscroll).value or dialogdata.leftscroll
@@ -622,12 +632,15 @@ local function buttonhandler(this, fields)
if fields.show_technical_names ~= nil then
local value = core.is_yes(fields.show_technical_names)
core.settings:set_bool("show_technical_names", value)
write_settings_early()
return true
end
if fields.show_advanced ~= nil then
local value = core.is_yes(fields.show_advanced)
core.settings:set_bool("show_advanced", value)
write_settings_early()
local suggested_page_id = update_filtered_pages(dialogdata.query)
@@ -672,12 +685,15 @@ local function buttonhandler(this, fields)
for i, comp in ipairs(dialogdata.components) do
if comp.on_submit and comp:on_submit(fields, this) then
write_settings_early()
-- Clear components so they regenerate
dialogdata.components = nil
return true
end
if comp.setting and fields["reset_" .. i] then
core.settings:remove(comp.setting.name)
write_settings_early()
-- Clear components so they regenerate
dialogdata.components = nil

View File

@@ -401,7 +401,8 @@ anisotropic_filter (Anisotropic filtering) bool false
#
# * None - No antialiasing (default)
#
# * FSAA - Hardware-provided full-screen antialiasing (incompatible with shaders)
# * FSAA - Hardware-provided full-screen antialiasing
# (incompatible with Post Processing and Undersampling)
# A.K.A multi-sample antialiasing (MSAA)
# Smoothens out block edges but does not affect the insides of textures.
# A restart is required to change this option.
@@ -557,12 +558,17 @@ shadow_sky_body_orbit_tilt (Sky Body Orbit Tilt) float 0.0 -60.0 60.0
[**Post Processing]
# Enables the post processing pipeline.
#
# Requires: shaders
enable_post_processing (Enable Post Processing) bool true
# Enables Hable's 'Uncharted 2' filmic tone mapping.
# Simulates the tone curve of photographic film and how this approximates the
# appearance of high dynamic range images. Mid-range contrast is slightly
# enhanced, highlights and shadows are gradually compressed.
#
# Requires: shaders
# Requires: shaders, enable_post_processing
tone_mapping (Filmic tone mapping) bool false
# Enable automatic exposure correction
@@ -570,14 +576,14 @@ tone_mapping (Filmic tone mapping) bool false
# automatically adjust to the brightness of the scene,
# simulating the behavior of human eye.
#
# Requires: shaders
# Requires: shaders, enable_post_processing
enable_auto_exposure (Enable Automatic Exposure) bool false
# Set the exposure compensation in EV units.
# Value of 0.0 (default) means no exposure compensation.
# Range: from -1 to 1.0
#
# Requires: shaders, enable_auto_exposure
# Requires: shaders, enable_post_processing, enable_auto_exposure
exposure_compensation (Exposure compensation) float 0.0 -1.0 1.0
[**Bloom]
@@ -585,7 +591,7 @@ exposure_compensation (Exposure compensation) float 0.0 -1.0 1.0
# Set to true to enable bloom effect.
# Bright colors will bleed over the neighboring objects.
#
# Requires: shaders
# Requires: shaders, enable_post_processing
enable_bloom (Enable Bloom) bool false
# Set to true to render debugging breakdown of the bloom effect.
@@ -593,27 +599,27 @@ enable_bloom (Enable Bloom) bool false
# top-left - processed base image, top-right - final image
# bottom-left - raw base image, bottom-right - bloom texture.
#
# Requires: shaders, enable_bloom
# Requires: shaders, enable_post_processing, enable_bloom
enable_bloom_debug (Enable Bloom Debug) bool false
# Defines how much bloom is applied to the rendered image
# Smaller values make bloom more subtle
# Range: from 0.01 to 1.0, default: 0.05
#
# Requires: shaders, enable_bloom
# Requires: shaders, enable_post_processing, enable_bloom
bloom_intensity (Bloom Intensity) float 0.05 0.01 1.0
# Defines the magnitude of bloom overexposure.
# Range: from 0.1 to 10.0, default: 1.0
#
# Requires: shaders, enable_bloom
# Requires: shaders, enable_post_processing, enable_bloom
bloom_strength_factor (Bloom Strength Factor) float 1.0 0.1 10.0
# Logical value that controls how far the bloom effect spreads
# from the bright objects.
# Range: from 0.1 to 8, default: 1
#
# Requires: shaders, enable_bloom
# Requires: shaders, enable_post_processing, enable_bloom
bloom_radius (Bloom Radius) float 1 0.1 8

View File

@@ -1,4 +1,4 @@
Minetest Lua Client Modding API Reference 5.8.0
Minetest Lua Client Modding API Reference 5.8.1
================================================
* More information at <http://www.minetest.net/>
* Developer Wiki: <http://dev.minetest.net/>

View File

@@ -28,6 +28,7 @@ General options and their default values:
ENABLE_REDIS=ON - Build with libhiredis; Enables use of Redis map backend
ENABLE_SPATIAL=ON - Build with LibSpatial; Speeds up AreaStores
ENABLE_SOUND=ON - Build with OpenAL, libogg & libvorbis; in-game sounds
ENABLE_LTO=ON - Build with IPO/LTO optimizations (smaller and more efficient than regular build)
ENABLE_LUAJIT=ON - Build with LuaJIT (much faster than non-JIT Lua)
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)

View File

@@ -1,4 +1,4 @@
Minetest Lua Mainmenu API Reference 5.8.0
Minetest Lua Mainmenu API Reference 5.8.1
=========================================
Introduction

View File

@@ -7,6 +7,10 @@ unittests.register("test_get_version", function()
assert(type(version.proto_min) == "number")
assert(type(version.proto_max) == "number")
assert(version.proto_max >= version.proto_min)
assert(type(version.hash) == "string")
assert(type(version.is_dev) == "boolean")
if version.is_dev then
assert(type(version.hash) == "string")
else
assert(version.hash == nil)
end
end)

View File

@@ -82,6 +82,6 @@
<translation type="gettext">minetest</translation>
<update_contact>sfan5@live.de</update_contact>
<releases>
<release date="2023-12-04" version="5.8.0"/>
<release date="2024-04-21" version="5.8.1"/>
</releases>
</component>

View File

@@ -1777,6 +1777,11 @@ float Client::mediaReceiveProgress()
return 1.0; // downloader only exists when not yet done
}
void Client::drawLoadScreen(const std::wstring &text, float dtime, int percent) {
m_rendering_engine->run();
m_rendering_engine->draw_load_screen(text, guienv, m_tsrc, dtime, percent);
}
struct TextureUpdateArgs {
gui::IGUIEnvironment *guienv;
u64 last_time_ms;

View File

@@ -357,6 +357,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
float mediaReceiveProgress();
void drawLoadScreen(const std::wstring &text, float dtime, int percent);
void afterContentReceived();
void showUpdateProgressTexture(void *args, u32 progress, u32 max_progress);

View File

@@ -215,8 +215,9 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
L" " + utf8_to_wide(g_version_hash) +
L" [" + wstrgettext("Main Menu") + L"]").c_str());
try { // This is used for catching disconnects
#ifdef NDEBUG
try {
#endif
m_rendering_engine->get_gui_env()->clear();
/*
@@ -247,11 +248,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
}
// Break out of menu-game loop to shut down cleanly
if (!m_rendering_engine->run() || *kill) {
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
if (!m_rendering_engine->run() || *kill)
break;
}
m_rendering_engine->get_video_driver()->setTextureCreationFlag(
video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
@@ -270,14 +268,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
chat_backend,
&reconnect_requested
);
} //try
catch (con::PeerNotFoundException &e) {
error_message = gettext("Connection error (timed out?)");
errorstream << error_message << std::endl;
}
#ifdef NDEBUG
catch (std::exception &e) {
} catch (std::exception &e) {
error_message = "Some exception: ";
error_message.append(debug_describe_exc(e));
errorstream << error_message << std::endl;
@@ -292,6 +284,16 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
receiver->m_touchscreengui = NULL;
#endif
/* Save the settings when leaving the game.
* This makes sure that setting changes made in-game are persisted even
* in case of a later unclean exit from the mainmenu.
* This is especially useful on Android because closing the app from the
* "Recents screen" results in an unclean exit.
* Caveat: This means that the settings are saved twice when exiting Minetest.
*/
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
// If no main menu, show error and exit
if (skip_main_menu) {
if (!error_message.empty()) {
@@ -555,6 +557,16 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
/* leave scene manager in a clean state */
m_rendering_engine->get_scene_manager()->clear();
/* Save the settings when leaving the mainmenu.
* This makes sure that setting changes made in the mainmenu are persisted
* even in case of a later unclean exit from the game.
* This is especially useful on Android because closing the app from the
* "Recents screen" results in an unclean exit.
* Caveat: This means that the settings are saved twice when exiting Minetest.
*/
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
}
void ClientLauncher::speed_tests()

View File

@@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "clientmedia.h"
#include "gettext.h"
#include "httpfetch.h"
#include "client.h"
#include "filecache.h"
@@ -29,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/serialize.h"
#include "util/sha1.h"
#include "util/string.h"
#include <sstream>
static std::string getMediaCacheDir()
{
@@ -41,7 +43,16 @@ bool clientMediaUpdateCache(const std::string &raw_hash, const std::string &file
std::string sha1_hex = hex_encode(raw_hash);
if (!media_cache.exists(sha1_hex))
return media_cache.update(sha1_hex, filedata);
return true;
return false;
}
bool clientMediaUpdateCacheCopy(const std::string &raw_hash, const std::string &path)
{
FileCache media_cache(getMediaCacheDir());
std::string sha1_hex = hex_encode(raw_hash);
if (!media_cache.exists(sha1_hex))
return media_cache.updateCopyFile(sha1_hex, path);
return false;
}
/*
@@ -174,6 +185,11 @@ void ClientMediaDownloader::step(Client *client)
void ClientMediaDownloader::initialStep(Client *client)
{
std::wstring loading_text = wstrgettext("Media...");
// Tradeoff between responsiveness during media loading and media loading speed
const u64 chunk_time_ms = 33;
u64 last_time = porting::getTimeMs();
// Check media cache
m_uncached_count = m_files.size();
for (auto &file_it : m_files) {
@@ -185,14 +201,17 @@ void ClientMediaDownloader::initialStep(Client *client)
filestatus->received = true;
m_uncached_count--;
}
u64 cur_time = porting::getTimeMs();
u64 dtime = porting::getDeltaMs(last_time, cur_time);
if (dtime >= chunk_time_ms) {
client->drawLoadScreen(loading_text, dtime / 1000.0f, 30);
last_time = cur_time;
}
}
assert(m_uncached_received_count == 0);
// Create the media cache dir if we are likely to write to it
if (m_uncached_count != 0)
createCacheDirs();
// If we found all files in the cache, report this fact to the server.
// If the server reported no remote servers, immediately start
// conventional transfers. Note: if cURL support is not compiled in,
@@ -511,18 +530,6 @@ IClientMediaDownloader::IClientMediaDownloader():
{
}
void IClientMediaDownloader::createCacheDirs()
{
if (!m_write_to_cache)
return;
std::string path = getMediaCacheDir();
if (!fs::CreateAllDirs(path)) {
errorstream << "Client: Could not create media cache directory: "
<< path << std::endl;
}
}
bool IClientMediaDownloader::tryLoadFromCache(const std::string &name,
const std::string &sha1, Client *client)
{
@@ -726,8 +733,6 @@ void SingleMediaDownloader::initialStep(Client *client)
if (isDone())
return;
createCacheDirs();
// If the server reported no remote servers, immediately fall back to
// conventional transfer.
if (!USE_CURL || m_remotes.empty()) {

View File

@@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h"
#include "filecache.h"
#include "util/basic_macros.h"
#include <ostream>
#include <map>
#include <set>
#include <vector>
@@ -35,10 +34,15 @@ struct HTTPFetchResult;
#define MTHASHSET_FILE_NAME "index.mth"
// Store file into media cache (unless it exists already)
// Validating the hash is responsibility of the caller
// Caller should check the hash.
// return true if something was updated
bool clientMediaUpdateCache(const std::string &raw_hash,
const std::string &filedata);
// Copy file on disk(!) into media cache (unless it exists already)
bool clientMediaUpdateCacheCopy(const std::string &raw_hash,
const std::string &path);
// more of a base class than an interface but this name was most convenient...
class IClientMediaDownloader
{
@@ -81,8 +85,6 @@ class IClientMediaDownloader
virtual bool loadMedia(Client *client, const std::string &data,
const std::string &name) = 0;
void createCacheDirs();
bool tryLoadFromCache(const std::string &name, const std::string &sha1,
Client *client);

View File

@@ -28,6 +28,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <fstream>
#include <cstdlib>
void FileCache::createDir()
{
if (!fs::CreateAllDirs(m_dir)) {
errorstream << "Could not create cache directory: "
<< m_dir << std::endl;
}
}
bool FileCache::loadByPath(const std::string &path, std::ostream &os)
{
std::ifstream fis(path.c_str(), std::ios_base::binary);
@@ -40,8 +48,8 @@ bool FileCache::loadByPath(const std::string &path, std::ostream &os)
bool bad = false;
for(;;){
char buf[1024];
fis.read(buf, 1024);
char buf[4096];
fis.read(buf, sizeof(buf));
std::streamsize len = fis.gcount();
os.write(buf, len);
if(fis.eof())
@@ -61,6 +69,7 @@ bool FileCache::loadByPath(const std::string &path, std::ostream &os)
bool FileCache::updateByPath(const std::string &path, const std::string &data)
{
createDir();
std::ofstream file(path.c_str(), std::ios_base::binary |
std::ios_base::trunc);
@@ -95,3 +104,11 @@ bool FileCache::exists(const std::string &name)
std::ifstream fis(path.c_str(), std::ios_base::binary);
return fis.good();
}
bool FileCache::updateCopyFile(const std::string &name, const std::string &src_path)
{
std::string path = m_dir + DIR_DELIM + name;
createDir();
return fs::CopyFileContents(src_path, path);
}

View File

@@ -35,9 +35,13 @@ class FileCache
bool load(const std::string &name, std::ostream &os);
bool exists(const std::string &name);
// Copy another file on disk into the cache
bool updateCopyFile(const std::string &name, const std::string &src_path);
private:
std::string m_dir;
void createDir();
bool loadByPath(const std::string &path, std::ostream &os);
bool updateByPath(const std::string &path, const std::string &data);
};

View File

@@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/mapblock_mesh.h"
#include "client/sound.h"
#include "clientmap.h"
#include "clientmedia.h" // For clientMediaUpdateCacheCopy
#include "clouds.h"
#include "config.h"
#include "content_cao.h"
@@ -63,6 +64,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "shader.h"
#include "sky.h"
#include "threading/lambda.h"
#include "translation.h"
#include "util/basic_macros.h"
#include "util/directiontables.h"
@@ -737,6 +739,7 @@ class Game {
bool initSound();
bool createSingleplayerServer(const std::string &map_dir,
const SubgameSpec &gamespec, u16 port);
void copyServerClientCache();
// Client creation
bool createClient(const GameStartData &start_data);
@@ -1058,7 +1061,7 @@ Game::~Game()
delete soundmaker;
sound_manager.reset();
delete server; // deleted first to stop all server threads
delete server;
delete hud;
delete camera;
@@ -1272,6 +1275,9 @@ void Game::shutdown()
if (formspec)
formspec->quitMenu();
// Clear text when exiting.
m_game_ui->clearText();
#ifdef HAVE_TOUCHSCREENGUI
g_touchscreengui->hide();
#endif
@@ -1309,6 +1315,31 @@ void Game::shutdown()
sleep_ms(100);
}
}
delete client;
client = nullptr;
delete soundmaker;
soundmaker = nullptr;
sound_manager.reset();
auto stop_thread = runInThread([=] {
delete server;
server = nullptr;
}, "ServerStop");
FpsControl fps_control;
fps_control.reset();
while (stop_thread->isRunning()) {
m_rendering_engine->run();
f32 dtime;
fps_control.limit(device, &dtime);
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
}
stop_thread->rethrow();
// to be continued in Game::~Game
}
@@ -1414,9 +1445,53 @@ bool Game::createSingleplayerServer(const std::string &map_dir,
server = new Server(map_dir, gamespec, simple_singleplayer_mode, bind_addr,
false, nullptr, error_message);
server->start();
return true;
auto start_thread = runInThread([=] {
server->start();
copyServerClientCache();
}, "ServerStart");
input->clear();
bool success = true;
FpsControl fps_control;
fps_control.reset();
while (start_thread->isRunning()) {
if (!m_rendering_engine->run() || input->cancelPressed())
success = false;
f32 dtime;
fps_control.limit(device, &dtime);
if (success)
showOverlayMessage(N_("Creating server..."), dtime, 5);
else
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
}
start_thread->rethrow();
return success;
}
void Game::copyServerClientCache()
{
// It would be possible to let the client directly read the media files
// from where the server knows they are. But aside from being more complicated
// it would also *not* fill the media cache and cause slower joining of
// remote servers.
// (Imagine that you launch a game once locally and then connect to a server.)
assert(server);
auto map = server->getMediaList();
u32 n = 0;
for (auto &it : map) {
assert(it.first.size() == 20); // SHA1
if (clientMediaUpdateCacheCopy(it.first, it.second))
n++;
}
infostream << "Copied " << n << " files directly from server to client cache"
<< std::endl;
}
bool Game::createClient(const GameStartData &start_data)
@@ -1428,12 +1503,6 @@ bool Game::createClient(const GameStartData &start_data)
return false;
bool could_connect, connect_aborted;
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui) {
g_touchscreengui->init(texture_src);
g_touchscreengui->hide();
}
#endif
if (!connectToServer(start_data, &could_connect, &connect_aborted))
return false;
@@ -1542,10 +1611,8 @@ bool Game::initGui()
-1, chat_backend, client, &g_menumgr);
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui)
g_touchscreengui->show();
g_touchscreengui->init(texture_src);
#endif
return true;
@@ -2616,7 +2683,7 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui) {
cam->camera_yaw += g_touchscreengui->getYawChange();
cam->camera_pitch = g_touchscreengui->getPitch();
cam->camera_pitch += g_touchscreengui->getPitchChange();
} else {
#endif
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
@@ -4553,6 +4620,10 @@ void the_game(bool *kill,
error_message = std::string("ModError: ") + e.what() +
strgettext("\nCheck debug.txt for details.");
errorstream << error_message << std::endl;
} catch (con::PeerNotFoundException &e) {
error_message = gettext("Connection error (timed out?)");
errorstream << error_message << std::endl;
}
game.shutdown();
}

View File

@@ -334,3 +334,36 @@ void GameUI::deleteFormspec()
m_formname.clear();
}
void GameUI::clearText()
{
if (m_guitext_chat) {
m_guitext_chat->remove();
m_guitext_chat = nullptr;
}
if (m_guitext) {
m_guitext->remove();
m_guitext = nullptr;
}
if (m_guitext2) {
m_guitext2->remove();
m_guitext2 = nullptr;
}
if (m_guitext_info) {
m_guitext_info->remove();
m_guitext_info = nullptr;
}
if (m_guitext_status) {
m_guitext_status->remove();
m_guitext_status = nullptr;
}
if (m_guitext_profiler) {
m_guitext_profiler->remove();
m_guitext_profiler = nullptr;
}
}

View File

@@ -106,6 +106,7 @@ class GameUI
const std::string &getFormspecName() { return m_formname; }
GUIFormSpecMenu *&getFormspecGUI() { return m_formspec; }
void deleteFormspec();
void clearText();
private:
Flags m_flags;

View File

@@ -213,10 +213,10 @@ void Particle::step(float dtime)
if (m_p.animation.type != TAT_NONE) {
m_animation_time += dtime;
int frame_length_i, frame_count;
int frame_length_i = 0;
m_p.animation.determineParams(
m_material.getTexture(0)->getSize(),
&frame_count, &frame_length_i, NULL);
NULL, &frame_length_i, NULL);
float frame_length = frame_length_i / 1000.0;
while (m_animation_time > frame_length) {
m_animation_frame++;

View File

@@ -106,7 +106,7 @@ void UpscaleStep::run(PipelineContext &context)
std::unique_ptr<RenderStep> create3DStage(Client *client, v2f scale)
{
RenderStep *step = new Draw3D();
if (g_settings->getBool("enable_shaders")) {
if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing")) {
RenderPipeline *pipeline = new RenderPipeline();
pipeline->addStep(pipeline->own(std::unique_ptr<RenderStep>(step)));
@@ -131,7 +131,7 @@ RenderStep* addUpscaling(RenderPipeline *pipeline, RenderStep *previousStep, v2f
return previousStep;
// When shaders are enabled, post-processing pipeline takes care of rescaling
if (g_settings->getBool("enable_shaders"))
if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing"))
return previousStep;

View File

@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#include <iostream>
#include <exception>
#include <cassert>
#include "gettime.h"

View File

@@ -248,6 +248,7 @@ void set_default_settings()
settings->setDefault("minimap_double_scan_height", "true");
// Effects
settings->setDefault("enable_post_processing", "true");
settings->setDefault("directional_colored_fog", "true");
settings->setDefault("inventory_items_animations", "false");
settings->setDefault("mip_map", "false");
@@ -497,6 +498,7 @@ void set_default_settings()
settings->setDefault("active_block_range", "2");
settings->setDefault("viewing_range", "50");
settings->setDefault("leaves_style", "simple");
settings->setDefault("enable_post_processing", "false");
settings->setDefault("curl_verify_cert", "false");
// Apply settings according to screen size

View File

@@ -31,6 +31,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER
#include "irr_ptr.h"
#endif
#ifdef __linux__
#include <fcntl.h>
#include <sys/ioctl.h>
#ifndef FICLONE
#define FICLONE _IOW(0x94, 9, int)
#endif
#endif
namespace fs
{
@@ -214,6 +221,31 @@ std::string CreateTempFile()
return path;
}
bool CopyFileContents(const std::string &source, const std::string &target)
{
BOOL ok = CopyFileEx(source.c_str(), target.c_str(), nullptr, nullptr,
nullptr, COPY_FILE_ALLOW_DECRYPTED_DESTINATION);
if (!ok) {
errorstream << "copying " << source << " to " << target
<< " failed: " << GetLastError() << std::endl;
return false;
}
// docs: "File attributes for the existing file are copied to the new file."
// This is not our intention so get rid of unwanted attributes:
DWORD attr = GetFileAttributes(target.c_str());
if (attr == INVALID_FILE_ATTRIBUTES) {
errorstream << target << ": file disappeared after copy" << std::endl;
return false;
}
attr &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN);
SetFileAttributes(target.c_str(), attr);
tracestream << "copied " << source << " to " << target
<< " using CopyFileEx" << std::endl;
return true;
}
#else
/*********
@@ -412,6 +444,101 @@ std::string CreateTempFile()
return path;
}
namespace {
struct FileDeleter {
void operator()(FILE *stream) {
fclose(stream);
}
};
typedef std::unique_ptr<FILE, FileDeleter> FileUniquePtr;
}
bool CopyFileContents(const std::string &source, const std::string &target)
{
FileUniquePtr sourcefile, targetfile;
#ifdef __linux__
// Try to clone using Copy-on-Write (CoW). This is instant but supported
// only by some filesystems.
int srcfd, tgtfd;
srcfd = open(source.c_str(), O_RDONLY);
if (srcfd == -1) {
errorstream << source << ": can't open for reading: "
<< strerror(errno) << std::endl;
return false;
}
tgtfd = open(target.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tgtfd == -1) {
errorstream << target << ": can't open for writing: "
<< strerror(errno) << std::endl;
close(srcfd);
return false;
}
if (ioctl(tgtfd, FICLONE, srcfd) == 0) {
tracestream << "copied " << source << " to " << target
<< " using FICLONE" << std::endl;
close(srcfd);
close(tgtfd);
return true;
}
// fallback to normal copy, but no need to reopen the files
sourcefile.reset(fdopen(srcfd, "rb"));
targetfile.reset(fdopen(tgtfd, "wb"));
goto fallback;
#endif
sourcefile.reset(fopen(source.c_str(), "rb"));
targetfile.reset(fopen(target.c_str(), "wb"));
fallback:
if (!sourcefile) {
errorstream << source << ": can't open for reading: "
<< strerror(errno) << std::endl;
return false;
}
if (!targetfile) {
errorstream << target << ": can't open for writing: "
<< strerror(errno) << std::endl;
return false;
}
size_t total = 0;
bool done = false;
char readbuffer[BUFSIZ];
while (!done) {
size_t readbytes = fread(readbuffer, 1,
sizeof(readbuffer), sourcefile.get());
total += readbytes;
if (ferror(sourcefile.get())) {
errorstream << source << ": IO error: "
<< strerror(errno) << std::endl;
return false;
}
if (readbytes > 0)
fwrite(readbuffer, 1, readbytes, targetfile.get());
if (feof(sourcefile.get())) {
// flush destination file to catch write errors (e.g. disk full)
fflush(targetfile.get());
done = true;
}
if (ferror(targetfile.get())) {
errorstream << target << ": IO error: "
<< strerror(errno) << std::endl;
return false;
}
}
tracestream << "copied " << total << " bytes from "
<< source << " to " << target << std::endl;
return true;
}
#endif
/****************************
@@ -486,60 +613,6 @@ bool CreateAllDirs(const std::string &path)
return true;
}
bool CopyFileContents(const std::string &source, const std::string &target)
{
FILE *sourcefile = fopen(source.c_str(), "rb");
if(sourcefile == NULL){
errorstream<<source<<": can't open for reading: "
<<strerror(errno)<<std::endl;
return false;
}
FILE *targetfile = fopen(target.c_str(), "wb");
if(targetfile == NULL){
errorstream<<target<<": can't open for writing: "
<<strerror(errno)<<std::endl;
fclose(sourcefile);
return false;
}
size_t total = 0;
bool retval = true;
bool done = false;
char readbuffer[BUFSIZ];
while(!done){
size_t readbytes = fread(readbuffer, 1,
sizeof(readbuffer), sourcefile);
total += readbytes;
if(ferror(sourcefile)){
errorstream<<source<<": IO error: "
<<strerror(errno)<<std::endl;
retval = false;
done = true;
}
if(readbytes > 0){
fwrite(readbuffer, 1, readbytes, targetfile);
}
if(feof(sourcefile) || ferror(sourcefile)){
// flush destination file to catch write errors
// (e.g. disk full)
fflush(targetfile);
done = true;
}
if(ferror(targetfile)){
errorstream<<target<<": IO error: "
<<strerror(errno)<<std::endl;
retval = false;
done = true;
}
}
infostream<<"copied "<<total<<" bytes from "
<<source<<" to "<<target<<std::endl;
fclose(sourcefile);
fclose(targetfile);
return retval;
}
bool CopyDir(const std::string &source, const std::string &target)
{
if(PathExists(source)){

View File

@@ -608,13 +608,15 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
fetch_request.caller = HTTPFETCH_SYNC;
fetch_request.timeout = std::max(MIN_HTTPFETCH_TIMEOUT,
(long)g_settings->getS32("curl_file_download_timeout"));
httpfetch_sync(fetch_request, fetch_result);
bool completed = httpfetch_sync_interruptible(fetch_request, fetch_result);
if (!fetch_result.succeeded) {
if (!completed || !fetch_result.succeeded) {
target_file.close();
fs::DeleteSingleFileOrEmptyDirectory(target);
return false;
}
// TODO: directly stream the response data into the file instead of first
// storing the complete response in memory
target_file << fetch_result.data;
return true;

View File

@@ -222,7 +222,7 @@ void GUITable::setTable(const TableOptions &options,
s32 colcount = columns.size();
assert(colcount >= 1);
// rowcount = ceil(cellcount / colcount) but use integer arithmetic
s32 rowcount = (content.size() + colcount - 1) / colcount;
s32 rowcount = std::min(((u32)content.size() + colcount - 1) / colcount, (u32)S32_MAX);
assert(rowcount >= 0);
// Append empty strings to content if there is an incomplete row
s32 cellcount = rowcount * colcount;

View File

@@ -278,7 +278,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
irr_ptr<GUIModalMenu> holder;
holder.grab(this); // keep this alive until return (it might be dropped downstream [?])
if (event.TouchInput.ID == 0) {
if (event.TouchInput.touchedCount == 1) {
if (event.TouchInput.Event == ETIE_PRESSED_DOWN || event.TouchInput.Event == ETIE_MOVED)
m_pointer = v2s32(event.TouchInput.X, event.TouchInput.Y);
gui::IGUIElement *hovered = Environment->getRootGUIElement()->getElementFromPoint(core::position2d<s32>(m_pointer));
@@ -295,7 +295,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
if (event.TouchInput.Event == ETIE_LEFT_UP)
leave();
return ret;
} else if (event.TouchInput.ID == 1) {
} else if (event.TouchInput.touchedCount == 2) {
if (event.TouchInput.Event != ETIE_LEFT_UP)
return true; // ignore
auto focused = Environment->getFocus();

View File

@@ -832,7 +832,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
const double d = g_settings->getFloat("touchscreen_sensitivity", 0.001f, 10.0f) * 3.0f;
m_camera_yaw_change -= dir_free.X * d;
m_camera_pitch = MYMIN(MYMAX(m_camera_pitch + (dir_free.Y * d), -180.0f), 180.0f);
m_camera_pitch_change += dir_free.Y * d;
// update shootline
// no need to update (X, Y) when using crosshair since the shootline is not used

View File

@@ -171,7 +171,11 @@ class TouchScreenGUI
return res;
}
double getPitch() { return m_camera_pitch; }
double getPitchChange() {
double res = m_camera_pitch_change;
m_camera_pitch_change = 0;
return res;
}
/**
* Returns a line which describes what the player is pointing at.
@@ -213,7 +217,7 @@ class TouchScreenGUI
// value in degree
double m_camera_yaw_change = 0.0;
double m_camera_pitch = 0.0;
double m_camera_pitch_change = 0.0;
/**
* A line starting at the camera and pointing towards the selected object.

View File

@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "exceptions.h"
#include "debug.h"
#include "log.h"
#include "porting.h"
#include "util/container.h"
#include "util/thread.h"
#include "version.h"
@@ -783,7 +784,7 @@ static void httpfetch_request_clear(u64 caller)
}
}
void httpfetch_sync(const HTTPFetchRequest &fetch_request,
static void httpfetch_sync(const HTTPFetchRequest &fetch_request,
HTTPFetchResult &fetch_result)
{
// Create ongoing fetch data and make a cURL handle
@@ -796,6 +797,28 @@ void httpfetch_sync(const HTTPFetchRequest &fetch_request,
fetch_result = *ongoing.complete(res);
}
bool httpfetch_sync_interruptible(const HTTPFetchRequest &fetch_request,
HTTPFetchResult &fetch_result, long interval)
{
if (Thread *thread = Thread::getCurrentThread()) {
HTTPFetchRequest req = fetch_request;
req.caller = httpfetch_caller_alloc_secure();
httpfetch_async(req);
do {
if (thread->stopRequested()) {
httpfetch_caller_free(req.caller);
fetch_result = HTTPFetchResult(fetch_request);
return false;
}
sleep_ms(interval);
} while (!httpfetch_async_get(req.caller, fetch_result));
httpfetch_caller_free(req.caller);
} else {
httpfetch_sync(fetch_request, fetch_result);
}
return true;
}
#else // USE_CURL
/*
@@ -825,13 +848,14 @@ static void httpfetch_request_clear(u64 caller)
{
}
void httpfetch_sync(const HTTPFetchRequest &fetch_request,
HTTPFetchResult &fetch_result)
bool httpfetch_sync_interruptible(const HTTPFetchRequest &fetch_request,
HTTPFetchResult &fetch_result, long interval)
{
errorstream << "httpfetch_sync: unable to fetch " << fetch_request.url
errorstream << "httpfetch_sync_interruptible: unable to fetch " << fetch_request.url
<< " because USE_CURL=0" << std::endl;
fetch_result = HTTPFetchResult(fetch_request); // sets succeeded = false etc.
return false;
}
#endif // USE_CURL

View File

@@ -135,6 +135,9 @@ u64 httpfetch_caller_alloc_secure();
// to stop any ongoing fetches for the given caller.
void httpfetch_caller_free(u64 caller);
// Performs a synchronous HTTP request. This blocks and therefore should
// only be used from background threads.
void httpfetch_sync(const HTTPFetchRequest &fetch_request, HTTPFetchResult &fetch_result);
// Performs a synchronous HTTP request that is interruptible if the current
// thread is a Thread object. interval is the completion check interval in ms.
// This blocks and therefore should only be used from background threads.
// Returned is whether the request completed without interruption.
bool httpfetch_sync_interruptible(const HTTPFetchRequest &fetch_request,
HTTPFetchResult &fetch_result, long interval = 100);

View File

@@ -716,7 +716,7 @@ static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
int frame_count = 1;
if (layer->material_flags & MATERIAL_FLAG_ANIMATION) {
assert(layer->texture);
int frame_length_ms;
int frame_length_ms = 0;
tiledef.animation.determineParams(layer->texture->getOriginalSize(),
&frame_count, &frame_length_ms, NULL);
layer->animation_frame_count = frame_count;

View File

@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "config.h"
#include "filesys.h"
#include "log.h"
#include "settings.h"
#include <sstream>
#include <exception>
@@ -39,6 +40,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
extern int main(int argc, char *argv[]);
extern "C" JNIEXPORT void JNICALL
Java_net_minetest_minetest_GameActivity_saveSettings(JNIEnv* env, jobject /* this */) {
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
}
void android_main(android_app *app)
{
int retval = 0;

View File

@@ -114,9 +114,9 @@ int ModApiHttp::l_http_fetch_sync(lua_State *L)
infostream << "Mod performs HTTP request with URL " << req.url << std::endl;
HTTPFetchResult res;
httpfetch_sync(req, res);
bool completed = httpfetch_sync_interruptible(req, res);
push_http_fetch_result(L, res, true);
push_http_fetch_result(L, res, completed);
return 1;
}

View File

@@ -167,26 +167,6 @@ int ModApiServer::l_get_player_information(lua_State *L)
return 1;
}
/*
Be careful not to introduce a depdendency on the connection to
the peer here. This function is >>REQUIRED<< to still be able to return
values even when the peer unexpectedly disappears.
Hence all the ConInfo values here are optional.
*/
auto getConInfo = [&] (con::rtt_stat_type type, float *value) -> bool {
return server->getClientConInfo(player->getPeerId(), type, value);
};
float min_rtt, max_rtt, avg_rtt, min_jitter, max_jitter, avg_jitter;
bool have_con_info =
getConInfo(con::MIN_RTT, &min_rtt) &&
getConInfo(con::MAX_RTT, &max_rtt) &&
getConInfo(con::AVG_RTT, &avg_rtt) &&
getConInfo(con::MIN_JITTER, &min_jitter) &&
getConInfo(con::MAX_JITTER, &max_jitter) &&
getConInfo(con::AVG_JITTER, &avg_jitter);
ClientInfo info;
if (!server->getClientInfo(player->getPeerId(), info)) {
warningstream << FUNCTION_NAME << ": no client info?!" << std::endl;
@@ -211,6 +191,26 @@ int ModApiServer::l_get_player_information(lua_State *L)
}
lua_settable(L, table);
/*
Be careful not to introduce a depdendency on the connection to
the peer here. This function is >>REQUIRED<< to still be able to return
values even when the peer unexpectedly disappears.
Hence all the ConInfo values here are optional.
*/
auto getConInfo = [&] (con::rtt_stat_type type, float *value) -> bool {
return server->getClientConInfo(player->getPeerId(), type, value);
};
float min_rtt, max_rtt, avg_rtt, min_jitter, max_jitter, avg_jitter;
bool have_con_info =
getConInfo(con::MIN_RTT, &min_rtt) &&
getConInfo(con::MAX_RTT, &max_rtt) &&
getConInfo(con::AVG_RTT, &avg_rtt) &&
getConInfo(con::MIN_JITTER, &min_jitter) &&
getConInfo(con::MAX_JITTER, &max_jitter) &&
getConInfo(con::AVG_JITTER, &avg_jitter);
if (have_con_info) { // may be missing
lua_pushstring(L, "min_rtt");
lua_pushnumber(L, min_rtt);

View File

@@ -4081,6 +4081,19 @@ Translations *Server::getTranslationLanguage(const std::string &lang_code)
return translations;
}
std::unordered_map<std::string, std::string> Server::getMediaList()
{
MutexAutoLock env_lock(m_env_mutex);
std::unordered_map<std::string, std::string> ret;
for (auto &it : m_media) {
if (it.second.no_announce)
continue;
ret.emplace(base64_decode(it.second.sha1_digest), it.second.path);
}
return ret;
}
ModStorageDatabase *Server::openModStorageDatabase(const std::string &world_path)
{
std::string world_mt_path = world_path + DIR_DELIM + "world.mt";

View File

@@ -375,6 +375,10 @@ class Server : public con::PeerHandler, public MapEventReceiver,
// Get or load translations for a language
Translations *getTranslationLanguage(const std::string &lang_code);
// Returns all media files the server knows about
// map key = binary sha1, map value = file path
std::unordered_map<std::string, std::string> getMediaList();
static ModStorageDatabase *openModStorageDatabase(const std::string &world_path);
static ModStorageDatabase *openModStorageDatabase(const std::string &backend,

64
src/threading/lambda.h Normal file
View File

@@ -0,0 +1,64 @@
// Minetest
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include <exception>
#include <functional>
#include <memory>
#include "debug.h"
#include "threading/thread.h"
/**
* Class returned by `runInThread`.
*
* Provides the usual thread methods along with `rethrow()`.
*/
class LambdaThread : public Thread
{
friend std::unique_ptr<LambdaThread> runInThread(
const std::function<void()> &, const std::string &);
public:
/// Re-throw a caught exception, if any. Can only be called after thread exit.
void rethrow()
{
sanity_check(!isRunning());
if (m_exptr)
std::rethrow_exception(m_exptr);
}
private:
// hide methods
LambdaThread(const std::string &name="") : Thread(name) {}
using Thread::start;
std::function<void()> m_fn;
std::exception_ptr m_exptr;
void *run()
{
try {
m_fn();
} catch(...) {
m_exptr = std::current_exception();
}
return nullptr;
};
};
/**
* Run a lambda in a separate thread.
*
* Exceptions will be caught.
* @param fn function to run
* @param thread_name name for thread
* @return thread object of type `LambdaThread`
*/
std::unique_ptr<LambdaThread> runInThread(const std::function<void()> &fn,
const std::string &thread_name = "")
{
std::unique_ptr<LambdaThread> t(new LambdaThread(thread_name));
t->m_fn = fn;
t->start();
return t;
}

View File

@@ -60,6 +60,9 @@ DEALINGS IN THE SOFTWARE.
#endif
thread_local Thread *current_thread = nullptr;
Thread::Thread(const std::string &name) :
m_name(name),
m_request_stop(false),
@@ -176,6 +179,8 @@ void Thread::threadProc(Thread *thr)
thr->m_kernel_thread_id = thread_self();
#endif
current_thread = thr;
thr->setName(thr->m_name);
g_logger.registerThread(thr->m_name);
@@ -196,6 +201,12 @@ void Thread::threadProc(Thread *thr)
}
Thread *Thread::getCurrentThread()
{
return current_thread;
}
void Thread::setName(const std::string &name)
{
#if defined(__linux__)

View File

@@ -59,6 +59,7 @@ class Thread {
Thread(const std::string &name="");
virtual ~Thread();
DISABLE_CLASS_COPY(Thread)
// Note: class cannot be moved since other references exist
/*
* Begins execution of a new thread at the pure virtual method Thread::run().
@@ -119,6 +120,11 @@ class Thread {
*/
bool setPriority(int prio);
/*
* Returns the thread object of the current thread if it exists.
*/
static Thread *getCurrentThread();
/*
* Sets the currently executing thread's name to where supported; useful
* for debugging.

View File

@@ -38,6 +38,8 @@ class TestFilePath : public TestBase {
void testRemoveLastPathComponent();
void testRemoveLastPathComponentWithTrailingDelimiter();
void testRemoveRelativePathComponent();
void testSafeWriteToFile();
void testCopyFileContents();
};
static TestFilePath g_test_instance;
@@ -49,6 +51,8 @@ void TestFilePath::runTests(IGameDef *gamedef)
TEST(testRemoveLastPathComponent);
TEST(testRemoveLastPathComponentWithTrailingDelimiter);
TEST(testRemoveRelativePathComponent);
TEST(testSafeWriteToFile);
TEST(testCopyFileContents);
}
////////////////////////////////////////////////////////////////////////////////
@@ -56,7 +60,7 @@ void TestFilePath::runTests(IGameDef *gamedef)
// adjusts a POSIX path to system-specific conventions
// -> changes '/' to DIR_DELIM
// -> absolute paths start with "C:\\" on windows
std::string p(std::string path)
static std::string p(std::string path)
{
for (size_t i = 0; i < path.size(); ++i) {
if (path[i] == '/') {
@@ -262,3 +266,47 @@ void TestFilePath::testRemoveRelativePathComponent()
result = fs::RemoveRelativePathComponents(path);
UASSERT(result == p("/a/e"));
}
void TestFilePath::testSafeWriteToFile()
{
const std::string dest_path = getTestTempFile();
const std::string test_data("hello\0world", 11);
fs::safeWriteToFile(dest_path, test_data);
UASSERT(fs::PathExists(dest_path));
std::string contents_actual;
UASSERT(fs::ReadFile(dest_path, contents_actual));
UASSERTEQ(auto, contents_actual, test_data);
}
void TestFilePath::testCopyFileContents()
{
const auto dir_path = getTestTempDirectory();
const auto file1 = dir_path + DIR_DELIM "src", file2 = dir_path + DIR_DELIM "dst";
const std::string test_data("hello\0world", 11);
// error case
UASSERT(!fs::CopyFileContents(file1, "somewhere"));
{
std::ofstream ofs(file1);
ofs << test_data;
}
// normal case
UASSERT(fs::CopyFileContents(file1, file2));
std::string contents_actual;
UASSERT(fs::ReadFile(file2, contents_actual));
UASSERTEQ(auto, contents_actual, test_data);
// should overwrite and truncate
{
std::ofstream ofs(file2);
for (int i = 0; i < 10; i++)
ofs << "OH MY GAH";
}
UASSERT(fs::CopyFileContents(file1, file2));
contents_actual.clear();
UASSERT(fs::ReadFile(file2, contents_actual));
UASSERTEQ(auto, contents_actual, test_data);
}

View File

@@ -1,7 +1,8 @@
#! /bin/bash -e
#!/bin/bash -e
cmake -B build \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
-DENABLE_LTO=FALSE \
-DRUN_IN_PLACE=TRUE \
-DENABLE_GETTEXT=${CMAKE_ENABLE_GETTEXT:-TRUE} \
-DBUILD_SERVER=${CMAKE_BUILD_SERVER:-TRUE} \