Commit Graph

5932 Commits

Author SHA1 Message Date
Nils Dagsson Moskopp 9541e401de
Fix handheld maps not displaying in Minetest 5.5.0
The function dynamic_add_media() was changed in incompatible ways in
several minor versions of Minetest, breaking the display of handheld
maps in Minetest 5.5.0. This patch makes handheld maps display there.

The function was blocking with one argument in Minetest 5.3. It was also
blocking in Minetest 5.4, but took an additional argument for a function
to execute once the media had been received. Calling dynamic_add_media()
with a single argument had been deprecated; a function that did nothing
was provided in mcl_maps to satisfy the changed argument requirements.

In Minetest 5.5, dynamic_add_media() was changed to non-blocking. This
introduced a race condition in mcl_maps, where a client often tried to
display a map before it had received the map texture from the server.

Opening an issue on the Minetest issue tracker led to it being closed in
about 20 minutes: <https://github.com/minetest/minetest/issues/11997>
2022-02-25 23:11:34 +01:00
Nils Dagsson Moskopp 19831bbe0d
Use raw packets in RLE compression in tga_encoder 2022-02-20 10:15:06 +01:00
Nils Dagsson Moskopp f2e6e61c47
Darken handheld map in low light conditions 2022-02-20 10:12:47 +01:00
Nils Dagsson Moskopp b10214e1e0
Change map ids to timestamp with random suffix
Before this patch, mcl_maps used mod storage to store a map id counter.
This made it possible to set map ids sequentially. However, mod storage
is not included in world downloads – which means that a world based on a
world download would start counting at zero and overwrite existing maps.

This patch changes map ids to be a combination of the Unix timestamp and
a random value. This makes it possible to have almost sequential map ids
without the need to store a map id counter.
2022-02-20 10:12:46 +01:00
Nils Dagsson Moskopp 738cbf4861
Add setting for update frequency of handheld maps 2022-02-20 10:12:46 +01:00
Nils Dagsson Moskopp e91f29ac24
Show a message on how to add markers to maps 2022-02-20 10:12:45 +01:00
Nils Dagsson Moskopp 6ff0303802
Add markers to maps (using banners) 2022-02-20 10:12:45 +01:00
Nils Dagsson Moskopp f0a925aa20
Display location of item frame in item frame map 2022-02-20 10:12:45 +01:00
Nils Dagsson Moskopp 16a68af119
Store mcl_maps textures in map item meta
Map textures are stored as files in a world directory and in item meta.
For a typical forest landscape, this adds up to 10kb to map item meta.

The main purpose of this is to allow maps to work in world downloads:
Maps are automatically restored when no textures are found on disk.

As a side effect, players will probably lag a bit if they fill their
inventory with many (shulkers full of) maps, but enchanted items or
books can be used for the same purpose already, so this is not new.

Saving PNGs can lead to a few kb of savings here, but would hinder
enhancements to mcl_maps that are based on updating the stored map,
as reading and writing TGA images is stupidly easy compared to PNG.
(Really, any bitmap format is about the same size zlib compressed.)

Note that any hypothetical future version of mcl_maps that changes the
storage format (e.g. to compressed PNM) or sends PNG maps to clients has
to include a TGA parser, to avoid breaking existing maps in user worlds.
2022-02-20 10:12:44 +01:00
Nils Dagsson Moskopp 82a5708144
Display large player dot on maps for nearby player 2022-02-20 10:12:43 +01:00
Nils Dagsson Moskopp e24a38d864
Increase contrast of player marker on maps 2022-02-20 10:12:43 +01:00
Nils Dagsson Moskopp 62ee1267de
Add diagonal player marker to maps 2022-02-20 10:12:43 +01:00
Nils Dagsson Moskopp 9566ea58e3
Fix TGA file writing on Windows
Before this patch, the tga_encoder mod would write corrupted TGA files
on Windows: Bytes that looked like newlines were replaced by a carriage
return and a newline.
2022-02-20 10:12:42 +01:00
Nils Dagsson Moskopp c6436d7176
Reduce TGA filesize by 25% by using 16-bit colors 2022-02-20 10:12:41 +01:00
Nils Dagsson Moskopp ff249500a6
Speed up TGA encoding by creating fewer strings 2022-02-20 10:12:41 +01:00
Nils Dagsson Moskopp e20e264d8c
Use RLE compression in tga_encoder 2022-02-20 10:12:40 +01:00
Elias Fleckenstein 2110fccd9d
Add updated tga_encoder 2022-02-20 10:12:40 +01:00
AFCMS c5a5eaa96e
Update French translation of mcl_maps 2022-02-20 10:12:39 +01:00
Marcin Serwin ad2ce5c719
Update polish translation of mcl_maps 2022-02-20 10:12:39 +01:00
Marcin Serwin 5ef4a81683
Add polish translation of mcl_maps 2022-02-20 10:12:38 +01:00
AFCMS 8015cbc10c
Localize functions in mcl_maps 2022-02-20 10:12:38 +01:00
Elias Fleckenstein b6540c0d80
Add moving marker for the player 2022-02-20 10:12:37 +01:00
Elias Fleckenstein ea272c40a0
Add craft predict for map copying 2022-02-20 10:12:37 +01:00
Elias Fleckenstein ec23f89033
Fix tt snippet to update wield filled maps as well 2022-02-20 10:12:36 +01:00
Elias Fleckenstein 9e4d630987
Prevent placing of wielded maps 2022-02-20 10:12:35 +01:00
Elias Fleckenstein 8f077ff55b
Copy stack before accessing it in add_item 2022-02-20 10:12:35 +01:00
Elias Fleckenstein 697a37c266
Make it look like the player is holding the map in their hand 2022-02-20 10:12:34 +01:00
Elias Fleckenstein f3f2560b32
Make maps show their image when in itemframes 2022-02-20 10:12:34 +01:00
Elias Fleckenstein ad6ebad06f
Show empty map in creative inv, but don't show filled map there 2022-02-20 10:12:33 +01:00
Elias Fleckenstein d0b78d38f5
Implement copying maps 2022-02-20 10:12:33 +01:00
Elias Fleckenstein 8bee9270ef
Stack filled maps that have the same metadata 2022-02-20 10:12:33 +01:00
Elias Fleckenstein 7914ce72e4
Add API to create filled map 2022-02-20 10:12:32 +01:00
Elias Fleckenstein 1478b7ebea
Add Real Maps 2022-02-20 10:12:27 +01:00
erlehmann 18e299d923 Merge pull request 'ITEMS/mcl_fire: Fix fire spread to not freeze the game' (#234) from fix-fire into master
Reviewed-on: https://git.minetest.land/Mineclonia/Mineclonia/pulls/234
Reviewed-by: erlehmann <nils+git.minetest.land@dieweltistgarnichtso.net>
2022-02-12 03:39:40 +00:00
cora f5ba6f5649
Fix memory leak & C stack overflow
Before this patch, when placing a fire above a node that would turn it
into eternal fire (e.g. Netherrack or Magma) the spawn_fire() function
would call itself infinitely via the on_construct() handler of eternal
fire – because the latter called spawn_fire() itself.

On an x86 machine, this caused a memory leak, hanging Minetest. On an
x86_64 machine though, Minetest crashed immediately, showing an error
message about a stack overflow.
2022-02-11 17:44:11 +01:00
cora 4647710945
Extinguish fire without nearby “fuel” faster
This patch adjusts how often the ABM runs that removes fire nodes with
no adjacent nodes that can burn up. This makes fire linger less in air.
2022-02-11 17:44:10 +01:00
cora 5d09ec311c
Extinguish fire using an ABM instead of timers
Even the mitigated timers seem to have lead to slow
memory leaks. Once Minetest has used up all the RAM,
it will free some, then quickly use memory up again,
then repeat it ad nauseum, requiring 100% CPU. On a
PC with 2GB of RAM this could be reliably triggered
by having a fire burn a forest for 20 to 30 minutes.

This patch removes fire node timers completely and
instead extinguishes fire using an ABM.
2022-02-11 17:44:09 +01:00
cora ef7370550f
Make fire spread direction truly random
This patch initializes the random number generator used in mcl_fire with
the current Unix timestamp. It also corrects two biases in fire spread
that were caused by nodes being iterated over in a predictable way.
2022-02-11 17:41:42 +01:00
cora 6c2fb98160
Fix nodes with “flammable = -1” not catching fire 2022-02-07 04:51:27 +01:00
cora 052c9fcbcf
Fix diagonal fire-spread
In Minecraft fire spread logic, “adjacent” does not mean “diagonal”.
2022-02-07 04:51:06 +01:00
cora db8fbdc5dd
Fix beds burning away and dropping 2022-02-07 03:39:52 +01:00
cora 1b89c15193
Fix double nodes not being properly removed 2022-02-07 03:39:51 +01:00
cora 02fa2c9e07
Fix nodes that should not burn up burning up
Nodes with the group “flammable = -1” (e.g. crafting tables) must be
able to catch fire, but must not burn up. This patch adds checks for
this group.
2022-02-07 03:39:51 +01:00
cora c12076e74d
Reimplement basic Minecraft-like fire spread 2022-02-07 03:39:45 +01:00
cora 4deca628dc
Make fire actually remove nodes 2022-02-07 03:22:15 +01:00
cora df4ea94dbc
Add node timer back in so fires burn out 2022-02-07 03:22:02 +01:00
cora 8e8ccddb68
Replace MineClone2 fire with Minetest Game ABMs
ABMs have better performance than the laggy timer-based implementation.
2022-02-07 03:18:54 +01:00
erlehmann 11469886e0 Merge pull request 'MAPGEN/mcl_structures: Add (theoretically) fireproof test structure' (#258) from add-fireproof-structure into master
Reviewed-on: https://git.minetest.land/Mineclonia/Mineclonia/pulls/258
Reviewed-by: Li0n_2 <li0n_2@noreply.git.minetest.land>
2022-02-07 01:24:58 +00:00
Nils Dagsson Moskopp 96822be63d
Add (theoretically) fireproof test structure
This patch adds a new test structure to the “/spawnstruct” command which
can be spawned with this command: /spawnstruct test_structure_fireproof

The structure can be used to verify that eternal fire can be spawned by
the structure placement code. It can also be used to debug fire spread,
as according to Minecraft fire spread rules, it should be fireproof.

See <https://minecraft.fandom.com/wiki/Fire#Spread> for those rules.
2022-02-06 01:19:23 +01:00
cora 6abdbbbd13 Merge pull request 'ENTITIES/mcl_boats: Fix mob-in-boat crash in Minetest 5.5-dev' (#249) from fix-boat-crash-in-minetest-5.5-dev into master
Reviewed-on: https://git.minetest.land/Mineclonia/Mineclonia/pulls/249
Reviewed-by: cora <cora@noreply.git.minetest.land>
2022-01-27 00:50:08 +00:00