Commit Graph

203 Commits

Author SHA1 Message Date
sfan5 1b89d4d541 Simplify getBlockNodeIdMapping
since commit 0f9c78c3eb nodedef->get()
will never return an entry with empty name, so we can drop the related parts.
2024-04-20 13:03:42 +02:00
sfan5 2386bfda7e Fix static_save=false not working & related cleanups 2024-03-17 15:55:24 +01:00
lhofhansl 0d4b489545
Detect air-only blocks instead of day/night differences (#14264)
* Detect air-only blocks instead day/night differences

* Write !is_air into the former day-night-diff bit on disk, so that old server can still read maps written by new servers

* Only set is_air bit when reading from disk
2024-02-22 21:47:42 -08:00
sfan5 6ca214fefc
Introduce `std::string_view` into wider use (#14368) 2024-02-17 15:35:33 +01:00
sfan5 6aa4f14a28 Drop some unneeded MOD_REASONs 2024-01-23 22:34:36 +01:00
sfan5 f5b35a074f Get rid of parent pointer in MapBlock 2023-12-16 12:51:42 +01:00
sfan5 cb6e3ac6e1 Allocate data seperately from MapBlock class again
This effectively reverts commit b3503e7853.
2023-12-16 12:51:42 +01:00
sfan5 c3114132d3
Improve readability and infos in verbose log (#13828) 2023-09-22 18:41:10 +02:00
numzero 3b74cc4a41 Replace PP with direct printing 2023-06-26 22:51:32 +02:00
Abdou-31 d1b80b462e
Fix typos and en_US/en_GB inconsistency in various files (#12902) 2022-11-09 11:57:19 -05:00
Loïc Blot 322c8cf270
Reduce exposure of various internals (#12885)
* refactoring(StaticObjectList): don't expose m_active and m_stored anymore

This prevents our old crap code where anyone can access to StaticObjectList. use proper modifiers. It also permits to do a short cleanup on MapBlock using a helper

* refactoring(MapBlock): reduce a bit exposed m_active_blocks variable

* refactoring: MapBlock::m_node_timers is now private

We already had various helpers to perform this privatization, just use it. Also factorize the MapBlock stepping code for timers using already existing code and importing them from ServerEnvironment to MapBlock.

It's currently done pretty straight forward without any inheritance as MapBlock is just used everywhere, maybe in a future we'll have ServerMapBlock over MapBlock. Currently for a simple function let's just use proper objects and add a comment warning

* refactoring(Server): fix duplicated function for add/remove node

* refactoring(guiFormSpecMenu): add removeAll function to prevent duplicated code

* refactoring(ShadowRenderer) + perf: code quality  + increase performance

* All callers are already using the point and we should never test a function with nullptr node, it's a bug. Removed workaround which was hacky and fix the bug
* Drop clientmap lookup from shadowrendered, just use directly its
  pointer and forbid to push it in the generic list
* Reduce memory pressure on the renderShadowObject by preventing
  deallocating and reallocating multiple vectors on each node

* refactoring(MapBlock): reduce exposure of MapBlock::m_static_objects

It's not complete as some parts of the code are pretty nested, but it's better than before :)

* fix: better working on new functions & drop unwanted 2 lines

Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>

Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
2022-11-03 17:35:31 +01:00
Jude Melton-Houghton b3503e7853 Embed data directly in mapblocks 2022-10-09 13:43:48 -04:00
Jude Melton-Houghton 8f996e4a7c Remove unused MapBlock functionality 2022-10-09 13:43:48 -04:00
Jude Melton-Houghton 9676364c1f
Optimize lighting calculation (#12797) 2022-10-09 10:50:26 -04:00
sfan5 9a01581cdd Get rid of global buffer that would ruin concurrent MapBlock serialization 2022-05-26 15:49:12 +02:00
SmallJoker ecc6f4ba25
Remove a few unused functions reported by callcatcher (#11658) 2021-10-12 20:12:20 +02:00
lhofhansl d1624a5521
Switch MapBlock compression to zstd (#10788)
* Add zstd support.
* Rearrange serialization order
* Compress entire mapblock

Co-authored-by: sfan5 <sfan5@live.de>
2021-08-31 17:32:31 -07:00
Lars e638056523 Allow configuring block disk and net compression. Change default disk level. 2020-12-15 10:15:25 -08:00
Lars f1349be542 Avoid marking map blocks dirty upon deserialization. 2020-11-26 11:41:55 -08:00
SmallJoker 947466ab28 (se)SerializeString: Include max length in the name
This commit clarifies the maximal length of the serialized strings.
It will avoid accidental use of serializeString() when a larger string can be expected.

Removes unused Wide String serialization functions
2020-10-01 09:52:59 +02:00
Jozef Behran 86d7f84b89 Merge pull request #8776 from osjc/FixGetNode
Finish getNode cleanup
2019-08-10 19:45:44 +02:00
Paramat bc1e54764b Fix warnings about dungeongen.cpp memcpy() and unused variable in MapBlock::deSerializeNetworkSpecific() (#8122)
* Fix warning about dungeongen.cpp memcpy()

* Fix unused variable in MapBlock::deSerializeNetworkSpecific()

* Fix unused variable a simpler way
2019-01-22 22:13:06 +01:00
SmallJoker bba4563d89 Proselytize the network. Use IEEE F32 (#8030)
* Proselytize the network. Use IEEE F32
* Remove unused V2F1000 functions
2019-01-03 17:04:26 +01:00
Quentin Bazin 5f1cd555cd Move client-specific files to 'src/client' (#7902)
Update Android.mk
Remove 'src/client' from include_directories
2018-11-28 20:01:49 +01:00
nOOb3167 9537cfd3f8 Add a MSVC / Windows compatible snprintf function (#7353)
Use sizeof where applicable for mt_snprintf
2018-07-22 21:56:06 +02: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
Dániel Juhász 735fc2a1f2 Remove unused light updating code
Also remove the unit test that tests the removed algorithms.
2018-02-04 03:16:45 +00: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 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 2015aaba96 Fix a warning introduced by 4eb59aeeb2 2017-07-27 16:55:32 +02:00
Loic Blot ba959ce27f Rename previous_was_found to previous_exists 2017-07-27 07:56:48 +02:00
Loic Blot 4eb59aeeb2 MapBlock::actuallyUpdateDayNightDiff(): little performance optimization
don't check isLightDayNightEq if checked on previous node
2017-07-27 07:56:48 +02:00
Loic Blot 61e4877190 Massive performance improvement on correctBlockNodeIds
correctBlockNodeIds does 2 lookups for each loaded node, one to translate DB ID to name and a second to translate name to real ID. Name to real ID is very consumming if done on every node. As mapblocks are in most cases composed of many identical adjacent nodes, cache previous source and destination id and use them on the next node to prevent any lookup on those maps.

This reduce the function load from 15% of my CPU usage to ~0.7%, on the test, calls was reduced from 2.5M lookups to 42k lookups, it's a huge performance gain
2017-07-27 07:56:48 +02:00
Loic Blot 9d412dd075
Remove unused Map::getDayNightDiff + fix one undefined variable in mapblock.cpp 2017-07-26 23:11:46 +02:00
Loic Blot 14a1a712de
Very little performance fix on correctBlockNodeIds
+ C++11 codestyle
2017-07-18 08:18:13 +02:00
Loic Blot b2977e7691
Fix 1 more warning reported by GCC
We don't write in correct buffer size in analyze_block
2017-06-20 00:19:29 +02:00
Loïc Blot 8f7785771b Cpp11 initializers 2 (#5999)
* C++11 patchset 10: continue cleanup on constructors

* Drop obsolete bool MainMenuData::enable_public (setting is called with cURL in server loop)

* More classes cleanup

* More classes cleanup + change NULL tests to boolean tests
2017-06-17 19:11:28 +02:00
QrchackOfficial 5cc8ad946e Remove superfluous pointer null checks 2017-06-10 21:04:47 -04:00
Loïc Blot 8bdde45895 Revert "Remove deprecated code segments (#5891)"
This reverts commit 599e13e95e.
2017-06-06 16:19:04 +02:00
Thomas--S 599e13e95e Remove deprecated code segments (#5891) 2017-06-04 21:42:32 +02:00
sfan5 071e114ffa Private nodemeta (#5702)
* Private node metadata that isn't sent to the client
2017-05-10 15:29:21 +02:00
Loïc Blot f8ad01ab7c Update server min protocol version to v24 (#5411)
* Update server min protocol version to v24

It's based on @sfan5 stats. See https://kitsunemimi.pw/tmp/serverlist_stats_2017-03-17.txt

v24 was bumped 25/08/14 and 0.4.11 was released 25/12/14

* Drop protocol v23 and lesser code
2017-03-19 08:44:29 +01:00
Dániel Juhász f17c9c45dc Lighting: Update lighting at block loading
This commit updates mapblocks' light if necessary when they are loaded.
This removes ghost lighting.
2017-02-13 00:05:49 +00:00
Rogier 4d4b8bb8a4 Move PP() and PP2() macros to basic_macros.h
Instead of redefining them everywhere.
2016-12-24 00:32:50 +00:00
ShadowNinja 6f2d785d0f Rename macros with two leading underscores
These names are reserved for the compiler/library implementations.
2015-10-14 02:39:37 -04:00
ShadowNinja 96cc5b34fe Use warningstream for log messages with WARNING
Remove DTIME macro and its uses, too
2015-10-14 01:36:48 -04:00
est31 452df1c723 Various style cleanups + unused code removal
-> Don't pass pointer to whole IGameDef to NodeMetadata constructors
	and deserializers, but only to IItemDefManager, which is needed
-> Remove the unused content_mapnode_get_new_name() method
-> Fix style for MapBlock::deSerialize and MapBlock::deSerialize_pre22,
	improving accuracy of error messages a bit
-> Fix style at other serialisation methods too
-> Improve accuracy of some comments
2015-09-19 20:57:29 +02:00
est31 283bf97a1c Serialisation: documentation fixes, clarifying renames and whitespace fixes
1. Do two renames:
	* SER_FMT_CLIENT_VER_LOWEST -> SER_FMT_VER_LOWEST_WRITE
	* SER_FMT_VER_LOWEST -> SER_FMT_VER_LOWEST_READ
Now the two define values are consistently named with the _WRITE defines
SER_FMT_VER_{HIGHEST,LOWEST}_WRITE, and to better point out what the two
serialisation versions actually are for.

2. wrap some lines in doc/worldformat.txt, and point out that the node
timers are serialized at a later point, as this can cause confusion about
what now happens (if one doesn't strictly read the if block's conditions).

3. some whitespace fixes in NodeTimerList::serialize, and one new comment.
2015-09-14 07:02:15 +02:00
David Jones 34b7a147dc Change i++ to ++i 2015-08-25 18:33:52 -04:00
ShadowNinja e4bff8be94 Clean up threading
* Rename everything.
    * Strip J prefix.
    * Change UpperCamelCase functions to lowerCamelCase.
  * Remove global (!) semaphore count mutex on OSX.
  * Remove semaphore count getter (unused, unsafe, depended on internal
    API functions on Windows, and used a hack on OSX).
  * Add `Atomic<type>`.
  * Make `Thread` handle thread names.
  * Add support for C++11 multi-threading.
  * Combine pthread and win32 sources.
  * Remove `ThreadStarted` (unused, unneeded).
  * Move some includes from the headers to the sources.
  * Move all of `Event` into its header (allows inlining with no new includes).
  * Make `Event` use `Semaphore` (except on Windows).
  * Move some porting functions into `Thread`.
  * Integrate logging with `Thread`.
  * Add threading test.
2015-08-23 22:04:06 -04:00