1
0
Fork 0
Commit Graph

84 Commits

Author SHA1 Message Date
Tiger Wang 9b97d63f8f
Chest, weather, crash, and miscellaneous fixes (#5215)
* Alpha-sort cChestEntity

* Chests: use SendUpdateBlockEntity

* Pathfinder: fix out of range Y

* 1.13: correct weather packet ID

* Chests: fix neighbour scanner

+ Add OnAddToWorld and overload to scan neighbours there, instead of in the constructor/OnUse. This fixes hoppers accessing newly loaded double chests and seeing a null m_Neighbour, thus thinking its a single chest.
* Fix typo in cross coords computation.
* Simplify hopper logic.

* Block entities: ASSERT that type is correct

If you match the block type first before calling DoWithBlockEntity, the corresponding block entity must either be empty or correspond to the block type.

* Chunk: fix some forgotten PendingSendBE cleanup

+ Add cleanup in SetAllData, WriteBlockArea
- Remove RemoveBlockEntity (used once), HasBlockEntity (not used)

* Replace MakeIndex with MakeIndexNoCheck

* Remove extraneous MarkDirty in hopper & chests
2021-04-30 13:23:46 +00:00
Tiger Wang 748b121703
Unify DoWithBlockEntity (#5168)
+ DoWith calls now broadcast the block entity and mark the chunk dirty
+ Add block entity change queue to synchronise BE updates with block updates
* Fixed a few incorrect assertions about BE type
- Remove manual overloads
2021-03-28 14:40:57 +01:00
Tiger Wang 868cd94ee9
Prepare ChunkData for BlockState storage (#5105)
* Rename ChunkData Creatable test

* Add missing Y-check in RedstoneWireHandler

* Remove ChunkDef.h dependency in Scoreboard

* Prepare ChunkData for BlockState storage

+ Split chunk block, meta, block & sky light storage
+ Load the height map from disk
- Reduce duplicated code in ChunkData
- Remove saving MCSBiomes, there aren't any
- Remove the allocation pool, ref #4315, #3864

* fixed build

* fixed test

* fixed the debug compile

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
2021-03-05 14:03:55 +01:00
Tiger Wang 491238f799 Chunk: use FAST_FLOOR_DIV 2020-12-21 13:52:15 +00:00
KingCol13 a78fd671b2
Deleted BiomeDef.h and ChunkDef.h from Globals.h (#4885)
* Removed BiomeDef.h

* Removed ChunkDef.h from Globals.h

* Added to CONTRIBUTORS.

* Re-added empty last line to Globals.h

* Included stddef and StringUtils in BiomeDef.h

* Fixed build tools compiling. It compiles, but at what cost?

* Added include to src/Generating/Trees.h

* Include added in ChunkGeneratorThread.h

* Moved rearranged includes in LineBlockTracer.cpp

* Re-arrange headers in ChunkInterface.cpp

* Included ChunkDef.h in Path.h

* Included ChunkDef.h in NBTChunkSerializer.h

* Rearranged included and added required includes to headers.

* Removed unnecessary included in StringUtils.h.
2020-09-25 09:13:59 +00:00
Tiger Wang da9158937d WorldStorage: Removed unused callback parameters 2020-08-28 21:36:46 +01:00
Mattes D 487f9a2aa9
Vector3 in Handlers (#4680)
Refactored all cBlockHandler and cItemHandler descendants to use Vector3.
2020-04-21 22:19:22 +02:00
peterbell10 aac592f985
Manage block entity lifetime with unique_ptr (#4080) 2020-04-03 23:23:38 +02:00
NiLSPACE dc787e1d96 Improved large jungle and acacia tree generation (#4413) 2019-12-22 23:38:11 +01:00
Mattes D 61904af626 Moved growing from cWorld / cChunk to cBlockHandler descendants. 2019-10-28 10:45:43 +01:00
Mattes D 365cbc6e1c
Refactored more of Entities and BlockEntities to use Vector3. (#4403) 2019-09-29 14:59:24 +02:00
Mattes D 180a43d097 Fixed MSVC warnings (#4400) 2019-09-27 16:51:44 +01:00
Mattes D e4ac84a6ab BiomeGen: Changed to use cChunkCoords params. 2019-09-08 20:21:49 +02:00
Mattes D a2ffa432b3 Separated chunk generator from world / plugin interfaces.
The generator now only takes care of servicing synchronous "GetChunk(X, Y)" and "GetBiomes(X, Y)" requests.
2019-09-06 16:12:33 +02:00
peterbell10 4727ed2084 Add a formatting function for Vector3 (#4282)
* Vector3: Add custom fmt compatible formatter.

* cLuaState: Add fmt version of ApiParamError

* Use vector formatting in manual bindings

* Always log vectors with FLOG
2018-09-24 21:33:39 +01:00
peterbell10 c94d7184eb Broadcast refactor (#4264)
* Move Broadcast functions from cChunkMap to cBroadcaster

- Remove cBroadcastInterface in favour of cBroadcaster.

- cChunk: Remove broadcast functions.

* resurect broadcast interface

* Absorb cBroadcaster into cWorld.
Removes the need for forwarding the function calls.

* Improve const-correctness

* Use Int8 instead of char

+ Comment `ForClients` functions

* Improve comments

* Broadcaster: Rename ForClients functions
2018-07-24 22:30:49 +01:00
peterbell10 31a11a6df4
Optimise chunk set (#4260)
Closes #1244

Initially I was just going to add the cChunkData to cSetChunkData but profiling revealed 
that the copying wasn't even the biggest slowdown. Much more time was being spent in 
cChunk::CreateBlockEntities and cChunk::WakeUpSimulators than was in memcpy so I've made 
those significantly faster as well.

Optimisations performed:
 * cSetChunkData now stores blocks in a cChunkData object
 * cChunkData objects can now perform moves even if they are using different pools
 * cChunk::CreateBlockEntities now iterates in the correct order and only over present chunk sections
 * Similarly for cChunk::WakeUpSimulators
 * cSetChunkData::CalculateHeightMap now shortcuts to the highest present chunk section before checking blocks directly
2018-07-23 19:12:51 +01:00
peterbell10 2df14a0496
cChunk and cChunkData: Use vectors for block get and set functions (#4172)
* cChunkData: Change interface to use Vector3i
* cChunk: Add Vector3i overloads for bounded block get and set functions.
2018-02-04 22:15:31 +00:00
Bond-009 5badb9bcca cChunkInterface GetBlock, GetBlockMeta, GetBlockTypeMeta use vectors (#4050) 2017-11-20 11:13:11 +00:00
Tiger Wang 72d7027861 Merge pull request #3489 from cuberite/EntityOwnership
* Changed entity ownership model to use smart pointers
2017-08-18 11:17:56 +01:00
Lane Kolbly 7bdbfad1bb Changed int parameters to vector parameters in cCuboid and simulators (#3874) 2017-08-17 15:48:38 +02:00
Tiger Wang 4ef47aed62 Changed entity ownership model to use smart pointers 2017-08-07 19:24:16 +01:00
peterbell10 759618b035 Remove double includes part 2 (#3890) 2017-08-03 15:34:19 +02:00
Lane Kolbly 5402b214b3 Check for intersection between placed blocks and entities. (#3850)
* Check for intersection between placed blocks and entities.

+ Implemented GetPlacementCollisionBox, to permit custom placement collision boxes for blocks.

* Factored block-entity placement checking into another function in cPlayer.

- Removed vector min/max functions

* Use GetWorld to get the world in DoesPlacingBlocksIntersectEntity.

+ Added block height checks, allow different cEntity subclasses to decide whether they will prevent block placement.
2017-07-28 17:59:21 +01:00
peterbell10 8a890cf945 Store cChunk::m_BlockEntities in a map (#3717)
* Store block entities in a map from block index
* Cleanup ForEachBlockEntity
* Cleanup DoWithBlockEntityAt
2017-05-22 22:27:55 +02:00
LogicParrot ca6ef58b1e Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
Julian Laubstein 62b41c351c Added cChunkDef::IsValidWidth() 2015-11-23 01:30:48 +01:00
Julian Laubstein 98bac62c07 Added cChunkDef::IsValidHeight() 2015-11-10 19:44:30 +01:00
Mattes D 9da404ea2d Fixed a race condition between chunk loader and generator.
When using ChunkWorx to generate multiple chunks, the server would sometimes fail an assert because it would generate a chunk even when it was successfully loaded. This was caused by chunks queued in cWorld's m_SetChunkDataQueue and thus being marked as "InQueue" although they were already loaded.

Solved by adding a new parameter to chunk coord callbacks specifying whether the operation succeeded or failed, and using that instead of the chunk presence flag to decide whether to generate or not.
2015-10-04 14:06:37 +02:00
Mattes D 82d9ac1e1c Namechange to Cuberite 2015-09-25 10:14:17 +02:00
Mattes D 6e4122e551 Unified the doxy-comment format. 2015-07-31 16:49:10 +02:00
Tiger Wang 171c59a01b Changed appropriate containers to unordered_map
Thanks to @worktycho for guidance!

* Potential speed improvements
2015-06-06 12:21:21 +01:00
Tiger Wang 84534dfeb2 Redstone wire and trapdoor fixes
* Fixes #1887
* Fixes #1763
* Fixes #1083
2015-06-06 12:21:19 +01:00
Tiger Wang de5b1401f8 Comparators 2015-06-06 12:21:09 +01:00
tycho f2689c4887 Fixed a lot of warnings 2015-05-19 11:50:59 +01:00
Mattes D 63de5f8a55 Replaced a std::hash specialization with explicit type.
std::hash is problematic in gcc / clang, one has a class, the other a struct.
2014-12-24 08:38:37 +01:00
Mattes D 9c5463be1e gcc compilation fix. 2014-12-24 07:32:31 +01:00
Mattes D ccdf03daaf Refactored all player block placing to go through hooks.
Fixes #1618.
2014-12-24 07:20:17 +01:00
Mattes D fcd3d1bfed Added a cWorld:PrepareChunk function.
It prepares the chunk - loads or generates it and lights it.
The spawn prepare process uses this function.
2014-12-10 22:35:16 +01:00
Mattes D bcb839d07b Merged branch 'master' of git://github.com/sriehl/MCServer 2014-10-21 18:12:40 +02:00
Steven Riehl 856764dee8 convert old style casts to fix warnings 2014-10-11 20:39:55 -06:00
Mattes D c140ba2367 Merge pull request #1351 from LO1ZB/remove-a_RelY
remove y-coord from chunks
2014-09-03 21:47:00 +02:00
LO1ZB 554f585017 re-add the missing "s" too cChunkCoordsWithBoolList 2014-09-03 00:28:08 +02:00
LO1ZB a600e3bdfe hopefully the last commit for removing y-coord from chunks. :) 2014-09-03 00:14:51 +02:00
madmaxoft 6f18d01b51 Fixed off-by-one errors in cChunkDef asserts. 2014-09-01 21:17:22 +02:00
LO1ZB ac95173e81 remove orphaned comment. 2014-08-30 00:45:05 +02:00
LO1ZB 3c1c073714 remove y-coord from chunks 2014-08-28 11:36:35 +02:00
Mattes D 64fec204c4 Added initializers for class members.
As reported by Coverity, these weren't initialized.
2014-08-21 22:39:53 +02:00
madmaxoft 93d29555e5 Style: Normalized to no spaces before closing parenthesis. 2014-07-21 17:40:43 +02:00
madmaxoft 7fff12bfac Fixed spaces around single-line comments.
There should be at least two spaces in front and one space after //-style comments.
2014-07-17 19:13:23 +02:00