Commit Graph

212 Commits

Author SHA1 Message Date
cosin15 15b569fb71
Remove unnecessary copy of a big data structure 2024-04-23 19:03:50 +02:00
sfan5 bc4ab8b99e General code refactoring/improvements in server, treegen and connection 2024-03-20 16:37:32 +01:00
sfan5 dfba79f8ff Split servermap.cpp/h off from map.cpp/h 2024-03-20 16:37:32 +01:00
lhofhansl 59abf1bb42
Allow active blocks to be generated (#14185) 2024-01-13 10:27:41 -08:00
lhofhansl bd42cc2c77
Ensure deterministic client occlusion culling and minor improvements (#14212)
* Ensure deterministic client occlusion culling
* Increase culling optimize distance slightly
* More accurate culling when sampling
2024-01-06 18:43:46 -08:00
lhofhansl 22a1653702
Perform server occlusion check before a block is loaded or generated (#14148) 2023-12-29 21:53:27 +01:00
lhofhansl ca1a723890
Allow cheaper culling checks at a distance (#14073)
* Allow cheaper culling checks at a distance
* Pick a random ray, so that far missing block will eventually be shown
2023-12-16 15:04:21 -08:00
sfan5 2c987b66c1 Move implementations of some LuaVoxelManip functions to l_mapgen 2023-08-14 18:16:36 +02:00
Desour 1780d1bbde Use unique_ptrs for MapSector::m_blocks 2023-06-05 20:43:33 +02:00
DS ed632f3854
Safely handle block deletion (#13315)
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
2023-03-24 12:34:44 +01:00
Jude Melton-Houghton d13b12b791
Store `MapEditEvent` blocks in a vector (#13071) 2022-12-24 12:21:59 -05:00
Jude Melton-Houghton 7701e70dc9 Make MapEditEvent more complete
SetBlocksNotSent is no longer used.
2022-12-24 08:24:59 -05:00
Jude Melton-Houghton cb725a4555 Speed up find_nodes_in_area (#12845) 2022-10-13 09:35:19 -04:00
Jude Melton-Houghton f916398a54
Add lighting test and benchmark (#12802) 2022-09-26 06:49:08 -04:00
SmallJoker 051181fa6e
Enforce limits of settings that could cause buggy behaviour (#12450)
Enforces the setting value bounds that are currently only limited by the GUI (settingtypes.txt).
2022-07-09 22:32:08 +02:00
Richard Try e16a470d59
Use unordered_map instead of map for MapSectors 2022-05-23 22:50:49 +02:00
sfan5 f5a8593b11
Add more Prometheus metrics (#12274) 2022-05-09 21:20:58 +02:00
sfan5 e7659883cc Async environment for mods to do concurrent tasks (#11131) 2022-05-02 20:56:06 +02:00
sfan5 a89afe1229 Deal with compiler warnings 2022-04-30 16:49:41 +02:00
Jude Melton-Houghton 0b5b2b2633
Disentangle map implementations (#12148)
Fixes violation of Liskov substitution principle
Fixes #12144
2022-04-07 21:58:04 +02:00
SmallJoker ecc6f4ba25
Remove a few unused functions reported by callcatcher (#11658) 2021-10-12 20:12:20 +02:00
SmallJoker c9144ae5e2
Add core.compare_block_status function (#11247)
Makes it possible to check the status of the mapblock in a future-extensible way.
2021-05-30 20:24:12 +02:00
rubenwardy 4c76239818
Remove dead code (#10845) 2021-01-22 15:09:26 +00:00
Lars e638056523 Allow configuring block disk and net compression. Change default disk level. 2020-12-15 10:15:25 -08:00
Lars f1d72d212a Avoid generating the same chunk more than once with multiple emerge threads. 2020-11-26 20:31:20 -08:00
SmallJoker f46509d5e2
Remove unused functions reported by cppcheck (#10463)
Run unused functions reported by cppcheck

This change removes a few (but not all) unused functions.
Some unused helper functions were not removed due to their complexity and potential of future use.
2020-10-05 09:07:33 +02:00
rubenwardy 6e4d8de104 Revert "Verify database connection on interval (#9665)"
Fixes #10113

This reverts commit 5c588f89e7.
2020-07-07 17:50:52 +01:00
Loic Blot 56bababcdf Add MetricsBackend with prometheus counter support 2020-04-29 07:48:08 +02:00
Loïc Blot 5c588f89e7
Verify database connection on interval (#9665) 2020-04-15 08:01:11 +02:00
random-geek 2f3c96b38d Remove legacy flat-file map code 2019-10-23 20:53:24 +02:00
SmallJoker 26b39f1eae
Fix some reference counters (memleak) (#8981)
Fix some reference counters (memleak)
Map::dispatchEvent: Allocation safety using references
2019-09-24 19:05:28 +02:00
sfan5 efbac7e446 Improve occlusion culling in corridors with additional check 2019-08-24 18:37:25 +02:00
sfan5 e8716ffede Restore approximate occlusion check
While less precise, it worked better which is what matters in the end.
2019-08-24 01:41:55 +02:00
SmallJoker 6ada090bb0 Occlusion: Check for light_propagates and do mapblock bounds checks 2019-08-23 19:17:43 +02:00
SmallJoker 7d016b4efd Occlusion: Begin cleanup 2019-08-23 19:17:43 +02:00
Jozef Behran 72b7a957af Fix unnecessary exception use in Map::getSectorXXX (#8792)
The Map::getSectorNoGenerate throws an exception but no other
code is really dependent on that. Fix the odd instance of
misuse in ClientMap::emergeSector and remove the exception
throwing version of the method along with the "NoEx" suffixes
in the names of these methods.
2019-08-13 19:58:27 +02:00
Jozef Behran 86d7f84b89 Merge pull request #8776 from osjc/FixGetNode
Finish getNode cleanup
2019-08-10 19:45:44 +02:00
Jozef Behran eb2bda7d0b Optimize string (mis)handling (#8128)
* Optimize statbar drawing

The texture name of the statbar is a string passed by value.
That slows down the client and creates litter in the heap
as the content of the string is allocated there. Convert the
offending parameter to a const reference to avoid the
performance hit.

* Optimize texture cache

There is an unnecessary temporary created when the texture
path is being generated. This slows down the cache each time
a new texture is encountered and it needs to be loaded into
the cache. Additionally, the heap litter created by this
unnecessary temporary is particularly troublesome here as
the following code then piles another string (the resulting
full path of the texture) on top of it, followed by the
texture itself, which both are quite long term objects as
they are subsequently inserted into the cache where they can
remain for quite a while (especially if the texture turns
out to be a common one like dirt, grass or stone).

Use std::string.append to get rid of the temporary which
solves both issues (speed and heap fragmentation).

* Optimize animations in client

Each time an animated node is updated, an unnecessary copy of
the texture name is created, littering the heap with lots of
fragments. This can be specifically troublesome when looking
at oceans or large lava lakes as both of these nodes are
usually animated (the lava animation is pretty visible).
Convert the parameter of GenericCAO::updateTextures to a
const reference to get rid of the unnecessary copy.

There is a comment stating "std::string copy is mandatory as
mod can be a class member and there is a swap on those class
members ... do NOT pass by reference", reinforcing the
belief that the unnecessary copy is in fact necessary.
However one of the first things the code of the method does
is to assign the parameter to its class member, creating
another copy. By rearranging the code a little bit this
"another copy" can then be used by the subsequent code,
getting rid of the need to pass the parameter by value and
thus saving that copying effort.

* Optimize chat console history handling

The GUIChatConsole::replaceAndAddToHistory was getting the
line to work on by value which turns out to be unnecessary.
Get rid of that unnecessary copy by converting the parameter
to a const reference.

* Optimize gui texture setting

The code used to set the texture for GUI components was
getting the name of the texture by value, creating
unnecessary performance bottleneck for mods/games with
heavily textured GUIs. Get rid of the bottleneck by passing
the texture name as a const reference.

* Optimize sound playing code in GUIEngine

The GUIEngine's code receives the specification of the sound
to be played by value, which turns out to be most likely a
mistake as the underlying sound manager interface receives
the same thing by reference. Convert the offending parameter
to a const reference to get rid of the rather bulky copying
effort and the associated performance hit.

* Silence CLANG TIDY warnings for unit tests

Change "std::string" to "const std::string &" to avoid an
unnecessary local value copy, silencing the CLANG TIDY
process.

* Optimize formspec handling

The "formspec prepend" parameter was passed to the formspec
handling code by value, creating unnecessary copy of
std::string and slowing down the game if mods add things like
textured backgrounds for the player inventory and/or other
forms. Get rid of that performance bottleneck by converting
the parameter to a const reference.

* Optimize hotbar image handling

The code that sets the background images for the hotbar is
getting the name of the image by value, creating an
unnecessary std::string copying effort. Fix that by
converting the relevant parameters to const references.

* Optimize inventory deserialization

The inventory manager deserialization code gets the
serialized version of the inventory by value, slowing the
server and the client down when there are inventory updates.
This can get particularly troublesome with pipeworks which
adds nodes that can mess around with inventories
automatically or with mods that have mobs with inventories
that actively use them.

* Optimize texture scaling cache

There is an io::path parameter passed by value in the
procedure used to add images converted from textures,
leading to slowdown when the image is not yet created and
the conversion is thus needed. The performance hit is
quite significant as io::path is similar to std::string
so convert the parameter to a const reference to get rid of
it.

* Optimize translation file loader

Use "std::string::append" when calculating the final index
for the translation table to avoid unnecessary temporary
strings. This speeds the translation file loader up
significantly as std::string uses heap allocation which
tends to be rather slow. Additionally, the heap is no
longer being littered by these unnecessary string
temporaries, increasing performance of code that gets
executed after the translation file loader finishes.

* Optimize server map saving

When the directory structure for the world data is created
during server map saving, an unnecessary value passing of
the directory name slows things down. Remove that overhead
by converting the offending parameter to a const reference.
2019-05-18 17:19:13 +02:00
SmallJoker 3d66622772
Send only changed node metadata to clients instead of whole mapblock (#5268)
Includes newer style changes and fixes by est31

Improve the block position de-serialization
Add type NodeMetadataMap
2018-12-04 20:37:48 +01:00
SmallJoker 297beea5bf
Check node updates whether the blocks are known (#7568)
* Remove unused ignore_id
2018-08-16 20:10:34 +02:00
lhofhansl 7454deb1bf
Allow an optional readonly base database (#7544)
* Allow an optional readonly base database

* Added basic documentation
2018-07-25 17:54:23 +02:00
paramat 359a940dde SAO limits: Allow SAOs to exist outside the set 'mapgen limit' 2018-02-26 17:21:45 +00:00
Loic Blot 359c8f82ce
map.cpp: Initialize NodeNeighbor, set NeighborType to u8 & cleanup
Cleanup:
* Drop unused Map::transforming_liquid_size()
* NodeNeighbor must use const ref for v3s16
* Add a missing default in a switch case
2018-02-11 09:23:25 +01:00
Dániel Juhász 3face01a20 Node definition manager refactor (#7016)
* Rename IWritableNodeDefManager to NodeDefManager
* Make INodeDefManager functions const
* Use "const *NodeDefManager" instead of "*INodeDefManager"
* Remove unused INodeDefManager class
* Merge NodeDefManager and CNodeDefManager
* Document NodeDefManager
2018-02-10 21:04:16 +01:00
Loïc Blot de4c2e4250 ServerMap saving: cleanups (#6274)
* remove sector meta loading/saving from files which targets dead code (differs_from_disk is always empty)
* this remove empty ServerMapSector and ClientMapSector, remove MapSector childs
2017-08-19 11:29:46 +02:00
Loic Blot b5f7249a7e
Code modernization: src/m* (part 2)
* empty function
* default constructor/destructor
* remove unused Map::emergeSector(a,b)
* for range-based loops
* migrate a dirs[7] table to direction tables
* remove various old unused function
2017-08-19 09:12:54 +02:00
Loïc Blot fd3afbced5 Optimize headers (part 2) (#6272)
* Optimize headers (part 2)

* less debug.h in headers
* less remoteplayer.h for everybody

* Cleanup (part 2)

* camera.h: mesh.h
* mapgen.h: mapnode.h
* serverenvironment.h: mapblock.h
* nodedef.h: shader.h
2017-08-18 19:25:07 +02:00
Loïc Blot c427533389 Modernize various files (src/m*) (#6267)
* Modernize various files (src/m*)

* range-based for loops
* code style
* C++ headers instead of C headers
* Default operators
* empty function

Thanks to clang-tidy
2017-08-18 18:18:25 +02:00
Loïc Blot 921151d97a C++ modernize: Pragma once (#6264)
* Migrate cpp headers to pragma once
2017-08-17 22:19:39 +02:00
Loic Blot 9d412dd075
Remove unused Map::getDayNightDiff + fix one undefined variable in mapblock.cpp 2017-07-26 23:11:46 +02:00