summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SetFlags.cmake14
-rw-r--r--Tools/MCADefrag/Globals.h2
-rw-r--r--src/Bindings/Plugin.h4
-rw-r--r--src/BlockEntities/BlockEntity.h4
-rw-r--r--src/BlockEntities/JukeboxEntity.h2
-rw-r--r--src/BlockEntities/NoteEntity.h2
-rw-r--r--src/Blocks/BlockHandler.h8
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Chunk.cpp40
-rw-r--r--src/Chunk.h20
-rw-r--r--src/ChunkDataCallback.h14
-rw-r--r--src/ChunkMap.cpp25
-rw-r--r--src/ChunkMap.h20
-rw-r--r--src/CommandOutput.h6
-rw-r--r--src/Entities/ArrowEntity.h2
-rw-r--r--src/Entities/Boat.h2
-rw-r--r--src/Entities/EnderCrystal.h2
-rw-r--r--src/Entities/Entity.h2
-rw-r--r--src/Entities/EntityEffect.h2
-rw-r--r--src/Entities/ExpBottleEntity.h2
-rw-r--r--src/Entities/ExpOrb.h2
-rw-r--r--src/Entities/FallingBlock.h2
-rw-r--r--src/Entities/FireChargeEntity.h2
-rw-r--r--src/Entities/FireworkEntity.h2
-rw-r--r--src/Entities/Floater.h2
-rw-r--r--src/Entities/GhastFireballEntity.h2
-rw-r--r--src/Entities/HangingEntity.h4
-rw-r--r--src/Entities/ItemFrame.h4
-rw-r--r--src/Entities/Minecart.h12
-rw-r--r--src/Entities/Painting.h2
-rw-r--r--src/Entities/Pawn.h2
-rw-r--r--src/Entities/Pickup.h2
-rw-r--r--src/Entities/Player.h2
-rw-r--r--src/Entities/ProjectileEntity.h2
-rw-r--r--src/Entities/SplashPotionEntity.h2
-rw-r--r--src/Entities/TNTEntity.h2
-rw-r--r--src/Entities/ThrownEggEntity.h2
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h2
-rw-r--r--src/Entities/ThrownSnowballEntity.h2
-rw-r--r--src/Entities/WitherSkullEntity.h2
-rw-r--r--src/Generating/ChunkGenerator.h2
-rw-r--r--src/HTTPServer/HTTPMessage.h2
-rw-r--r--src/Mobs/Bat.h2
-rw-r--r--src/Mobs/Blaze.h2
-rw-r--r--src/Mobs/CaveSpider.h2
-rw-r--r--src/Mobs/Chicken.h2
-rw-r--r--src/Mobs/Cow.h2
-rw-r--r--src/Mobs/Creeper.h2
-rw-r--r--src/Mobs/EnderDragon.h2
-rw-r--r--src/Mobs/Enderman.h2
-rw-r--r--src/Mobs/Ghast.h2
-rw-r--r--src/Mobs/Giant.h2
-rw-r--r--src/Mobs/Horse.h2
-rw-r--r--src/Mobs/IronGolem.h2
-rw-r--r--src/Mobs/MagmaCube.h2
-rw-r--r--src/Mobs/Monster.h2
-rw-r--r--src/Mobs/Mooshroom.h2
-rw-r--r--src/Mobs/Ocelot.h2
-rw-r--r--src/Mobs/Pig.h2
-rw-r--r--src/Mobs/Sheep.h2
-rw-r--r--src/Mobs/Silverfish.h2
-rw-r--r--src/Mobs/Skeleton.h4
-rw-r--r--src/Mobs/Slime.h2
-rw-r--r--src/Mobs/SnowGolem.h2
-rw-r--r--src/Mobs/Spider.h2
-rw-r--r--src/Mobs/Squid.h2
-rw-r--r--src/Mobs/Villager.h2
-rw-r--r--src/Mobs/Witch.h2
-rw-r--r--src/Mobs/Wither.h2
-rw-r--r--src/Mobs/Wolf.h2
-rw-r--r--src/Mobs/Zombie.h2
-rw-r--r--src/Mobs/ZombiePigman.h2
-rw-r--r--src/OSSupport/Queue.h4
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol125.h2
-rw-r--r--src/SetChunkData.cpp115
-rw-r--r--src/SetChunkData.h120
-rw-r--r--src/Simulator/Simulator.h2
-rw-r--r--src/World.cpp95
-rw-r--r--src/World.h48
-rw-r--r--src/WorldStorage/FastNBT.h2
-rw-r--r--src/WorldStorage/WSSAnvil.cpp5
-rw-r--r--src/WorldStorage/WSSCompact.cpp5
-rw-r--r--src/WorldStorage/WorldStorage.h4
84 files changed, 470 insertions, 229 deletions
diff --git a/SetFlags.cmake b/SetFlags.cmake
index bf467ca01..abd7bae2b 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -28,7 +28,7 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
if (NOT MSVC)
-
+
if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE")
message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
@@ -85,7 +85,7 @@ macro(set_flags)
# We use a signed char (fixes #640 on RasPi)
add_flags_cxx("-fsigned-char")
-
+
endif()
@@ -202,7 +202,7 @@ macro(enable_profile)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugProfile;ReleaseProfile;Coverage" CACHE STRING "" FORCE)
endif()
endmacro()
-
+
macro(set_exe_flags)
# Remove disabling the maximum warning level:
# clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings
@@ -216,22 +216,22 @@ macro(set_exe_flags)
string(REPLACE "-w" "" CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE}")
string(REPLACE "-w" "" CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}")
add_flags_cxx("-Wall -Wextra -Wno-unused-parameter -Wno-error=switch")
-
+
# we support non-IEEE 754 fpus so can make no guarentees about error
add_flags_cxx("-ffast-math")
-
+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# clang does not provide the __extern_always_inline macro and a part of libm depends on this when using fast-math
add_flags_cxx("-D__extern_always_inline=inline")
add_flags_cxx("-Werror -Weverything -Wno-c++98-compat-pedantic -Wno-string-conversion")
- add_flags_cxx("-Wno-extra-semi -Wno-error=switch-enum -Wno-documentation")
+ add_flags_cxx("-Wno-error=switch-enum -Wno-documentation -Wno-exit-time-destructors")
add_flags_cxx("-Wno-error=sign-conversion -Wno-error=conversion -Wno-padded")
add_flags_cxx("-Wno-error=deprecated -Wno-error=weak-vtables -Wno-error=float-equal")
add_flags_cxx("-Wno-error=missing-prototypes -Wno-error=non-virtual-dtor")
add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow")
add_flags_cxx("-Wno-error=exit-time-destructors -Wno-error=missing-variable-declarations")
add_flags_cxx("-Wno-error=global-constructors -Wno-implicit-fallthrough")
- add_flags_cxx("-Wno-weak-vtables -Wno-switch-enum -Wno-exit-time-destructors")
+ add_flags_cxx("-Wno-error=extra-semi -Wno-weak-vtables -Wno-switch-enum")
endif()
endif()
diff --git a/Tools/MCADefrag/Globals.h b/Tools/MCADefrag/Globals.h
index 6593187e6..288069599 100644
--- a/Tools/MCADefrag/Globals.h
+++ b/Tools/MCADefrag/Globals.h
@@ -240,7 +240,7 @@ template <typename Type> class cItemCallback
public:
/// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
virtual bool Item(Type * a_Type) = 0;
- virtual ~cItemCallback() {};
+ virtual ~cItemCallback() {}
} ;
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 3882b7474..39d53674b 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -115,10 +115,10 @@ public:
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) = 0;
/// All bound commands are to be removed, do any language-dependent cleanup here
- virtual void ClearCommands(void) {} ;
+ virtual void ClearCommands(void) {}
/// All bound console commands are to be removed, do any language-dependent cleanup here
- virtual void ClearConsoleCommands(void) {} ;
+ virtual void ClearConsoleCommands(void) {}
// tolua_begin
const AString & GetName(void) const { return m_Name; }
diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h
index 24c25e729..5710f8543 100644
--- a/src/BlockEntities/BlockEntity.h
+++ b/src/BlockEntities/BlockEntity.h
@@ -38,9 +38,9 @@ protected:
public:
// tolua_end
- virtual ~cBlockEntity() {}; // force a virtual destructor in all descendants
+ virtual ~cBlockEntity() {} // force a virtual destructor in all descendants
- virtual void Destroy(void) {};
+ virtual void Destroy(void) {}
void SetWorld(cWorld * a_World)
{
diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h
index 8bb3009eb..d677d340f 100644
--- a/src/BlockEntities/JukeboxEntity.h
+++ b/src/BlockEntities/JukeboxEntity.h
@@ -58,7 +58,7 @@ public:
static const char * GetClassStatic(void) { return "cJukeboxEntity"; }
virtual void UsedBy(cPlayer * a_Player) override;
- virtual void SendTo(cClientHandle &) override { };
+ virtual void SendTo(cClientHandle &) override {}
private:
int m_Record;
diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h
index 07b8fd259..e8497da3e 100644
--- a/src/BlockEntities/NoteEntity.h
+++ b/src/BlockEntities/NoteEntity.h
@@ -52,7 +52,7 @@ public:
// tolua_end
virtual void UsedBy(cPlayer * a_Player) override;
- virtual void SendTo(cClientHandle &) override { };
+ virtual void SendTo(cClientHandle &) override {}
static const char * GetClassStatic(void) { return "cNoteEntity"; }
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index a5d15d930..de90ce55b 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -60,19 +60,19 @@ public:
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position)
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {};
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/// Notifies all neighbors of the given block about a change
static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called while the player diggs the block.
- virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {};
+ virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/// Called if the user right clicks the block and the block is useable
- virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {};
+ virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}
/** Called when a right click to this block is cancelled */
- virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {};
+ virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}
/// <summary>Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents</summary>
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b8780e8a6..29337cb2e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,6 +56,7 @@ SET (SRCS
Root.cpp
Scoreboard.cpp
Server.cpp
+ SetChunkData.cpp
Statistics.cpp
StringCompression.cpp
StringUtils.cpp
@@ -124,6 +125,7 @@ SET (HDRS
Root.h
Scoreboard.h
Server.h
+ SetChunkData.h
StackWalker.h
Statistics.h
StringCompression.h
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 60987b070..10bc2ff23 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -34,6 +34,7 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BlockInServerPluginInterface.h"
+#include "SetChunkData.h"
#include "json/json.h"
@@ -265,41 +266,34 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback)
-void cChunk::SetAllData(
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const HeightMap * a_HeightMap,
- const BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities
-)
+void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
{
- memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap));
+ ASSERT(a_SetChunkData.IsHeightMapValid());
+ ASSERT(a_SetChunkData.AreBiomesValid());
+
+ memcpy(m_BiomeMap, a_SetChunkData.GetBiomes(), sizeof(m_BiomeMap));
+ memcpy(m_HeightMap, a_SetChunkData.GetHeightMap(), sizeof(m_HeightMap));
- if (a_HeightMap != NULL)
+ m_ChunkData.SetBlockTypes(a_SetChunkData.GetBlockTypes());
+ m_ChunkData.SetMetas(a_SetChunkData.GetBlockMetas());
+ if (a_SetChunkData.IsLightValid())
{
- memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
+ m_ChunkData.SetBlockLight(a_SetChunkData.GetBlockLight());
+ m_ChunkData.SetSkyLight(a_SetChunkData.GetSkyLight());
+ m_IsLightValid = true;
}
-
- if (a_HeightMap == NULL)
+ else
{
- CalculateHeightmap(a_BlockTypes);
+ m_IsLightValid = false;
}
- m_ChunkData.SetBlockTypes(a_BlockTypes);
- m_ChunkData.SetMetas(a_BlockMeta);
- m_ChunkData.SetBlockLight(a_BlockLight);
- m_ChunkData.SetSkyLight(a_BlockSkyLight);
-
- m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL);
-
// Clear the block entities present - either the loader / saver has better, or we'll create empty ones:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
delete *itr;
}
- std::swap(a_BlockEntities, m_BlockEntities);
+ m_BlockEntities.clear();
+ std::swap(a_SetChunkData.GetBlockEntities(), m_BlockEntities);
// Set all block entities' World variable:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
diff --git a/src/Chunk.h b/src/Chunk.h
index 9ab39a0a2..7eee3999c 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -95,16 +95,10 @@ public:
/** Gets all chunk data, calls the a_Callback's methods for each data type */
void GetAllData(cChunkDataCallback & a_Callback);
- /** Sets all chunk data */
- void SetAllData(
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities
- );
+ /** Sets all chunk data as either loaded from the storage or generated.
+ BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
+ Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */
+ void SetAllData(cSetChunkData & a_SetChunkData);
void SetLight(
const cChunkDef::BlockNibbles & a_BlockLight,
@@ -386,9 +380,9 @@ public:
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; }
cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; }
cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; }
- cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; };
- cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; };
- cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; };
+ cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }
+ cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }
+ cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }
bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; }
void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; }
diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h
index 53d44d038..804299816 100644
--- a/src/ChunkDataCallback.h
+++ b/src/ChunkDataCallback.h
@@ -29,25 +29,25 @@ public:
(only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
If false is returned, the chunk is skipped.
*/
- virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; };
+ virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }
/// Called once to provide heightmap data
- virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); };
+ virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) { UNUSED(a_HeightMap); }
/// Called once to provide biome data
- virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); };
+ virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { UNUSED(a_BiomeMap); }
/// Called once to let know if the chunk lighting is valid. Return value is ignored
- virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); };
+ virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); }
/// Called once to export block info
- virtual void ChunkData(const cChunkData & a_Buffer) {UNUSED(a_Buffer); };
+ virtual void ChunkData(const cChunkData & a_Buffer) { UNUSED(a_Buffer); }
/// Called for each entity in the chunk
- virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); };
+ virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); }
/// Called for each blockentity in the chunk
- virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); };
+ virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); }
} ;
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 3ef981e94..05d219918 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -16,6 +16,7 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BoundingBox.h"
+#include "SetChunkData.h"
#include "Entities/Pickup.h"
@@ -912,28 +913,20 @@ void cChunkMap::MarkChunkSaved (int a_ChunkX, int a_ChunkZ)
-void cChunkMap::SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
-)
+void cChunkMap::SetChunkData(cSetChunkData & a_SetChunkData)
{
+ int ChunkX = a_SetChunkData.GetChunkX();
+ int ChunkZ = a_SetChunkData.GetChunkZ();
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+ cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
if (Chunk == NULL)
{
return;
}
- Chunk->SetAllData(a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, a_HeightMap, a_BiomeMap, a_BlockEntities);
+ Chunk->SetAllData(a_SetChunkData);
- if (a_MarkDirty)
+ if (a_SetChunkData.ShouldMarkDirty())
{
Chunk->MarkDirty();
}
@@ -942,7 +935,7 @@ void cChunkMap::SetChunkData(
cChunkStays ToBeDisabled;
for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr)
{
- if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ))
+ if ((*itr)->ChunkAvailable(ChunkX, ChunkZ))
{
// The chunkstay wants to be disabled, add it to a list of to-be-disabled chunkstays for later processing:
ToBeDisabled.push_back(*itr);
@@ -957,7 +950,7 @@ void cChunkMap::SetChunkData(
}
// Notify plugins of the chunk becoming available
- cPluginManager::Get()->CallHookChunkAvailable(m_World, a_ChunkX, a_ChunkZ);
+ cPluginManager::Get()->CallHookChunkAvailable(m_World, ChunkX, ChunkZ);
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 4be1a4752..e33d9f894 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -34,6 +34,7 @@ class cChunkDataSerializer;
class cBlockArea;
class cMobCensus;
class cMobSpawner;
+class cSetChunkData;
typedef std::list<cClientHandle *> cClientHandleList;
typedef cChunk * cChunkPtr;
@@ -112,22 +113,11 @@ public:
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
/** Sets the chunk data as either loaded from the storage or generated.
- a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
- a_BiomeMap is optional, if not present, biomes will be calculated by the generator
- a_HeightMap is optional, if not present, will be calculated.
- If a_MarkDirty is set, the chunk is set as dirty (used after generating)
+ BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
+ If MarkDirty is set, the chunk is set as dirty (used after generating)
+ Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk.
*/
- void SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
- );
+ void SetChunkData(cSetChunkData & a_SetChunkData);
void ChunkLighted(
int a_ChunkX, int a_ChunkZ,
diff --git a/src/CommandOutput.h b/src/CommandOutput.h
index 5682b4fd8..daa9430c0 100644
--- a/src/CommandOutput.h
+++ b/src/CommandOutput.h
@@ -14,16 +14,16 @@ Descendants override that function to provide specific processing of the output.
class cCommandOutputCallback
{
public:
- virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses
+ virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses
- /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n"
+ /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline"
void Out(const char * a_Fmt, ...) FORMATSTRING(2, 3);
/// Called when the command wants to output anything; may be called multiple times
virtual void Out(const AString & a_Text) = 0;
/// Called when the command processing has been finished
- virtual void Finished(void) {};
+ virtual void Finished(void) {}
} ;
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index ad93dba6c..4bfcb1f6d 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -28,7 +28,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cArrowEntity);
+ CLASS_PROTODEF(cArrowEntity)
/// Creates a new arrow with psNoPickup state and default damage modifier coeff
cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index 0fcfbd602..8de88d165 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -21,7 +21,7 @@ class cBoat :
typedef cEntity super;
public:
- CLASS_PROTODEF(cBoat);
+ CLASS_PROTODEF(cBoat)
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index 30211de13..c98c3b681 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -15,7 +15,7 @@ class cEnderCrystal :
typedef cEntity super;
public:
- CLASS_PROTODEF(cEnderCrystal);
+ CLASS_PROTODEF(cEnderCrystal)
cEnderCrystal(double a_X, double a_Y, double a_Z);
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 83fe76e7e..efca60a6c 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -428,7 +428,7 @@ public:
// tolua_end
/// Called when the specified player right-clicks this entity
- virtual void OnRightClicked(cPlayer &) {};
+ virtual void OnRightClicked(cPlayer &) {}
/// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL)
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index ebd611ff0..396a9bbe0 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -55,7 +55,7 @@ public:
@param a_OtherEffect The other effect to copy */
cEntityEffect & operator=(cEntityEffect a_OtherEffect);
- virtual ~cEntityEffect(void) {};
+ virtual ~cEntityEffect(void) {}
/** Creates a pointer to the proper entity effect from the effect type
@warning This function creates raw pointers that must be manually managed.
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index e9536452c..d62a84469 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cExpBottleEntity);
+ CLASS_PROTODEF(cExpBottleEntity)
cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index 2cd4ef31f..bdb9a5b19 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -16,7 +16,7 @@ class cExpOrb :
public:
// tolua_end
- CLASS_PROTODEF(cExpOrb);
+ CLASS_PROTODEF(cExpOrb)
cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward);
cExpOrb(const Vector3d & a_Pos, int a_Reward);
diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h
index 5ba9909bb..c20fe8eb9 100644
--- a/src/Entities/FallingBlock.h
+++ b/src/Entities/FallingBlock.h
@@ -20,7 +20,7 @@ class cFallingBlock :
typedef cEntity super;
public:
- CLASS_PROTODEF(cFallingBlock);
+ CLASS_PROTODEF(cFallingBlock)
/// Creates a new falling block. a_BlockPosition is expected in world coords
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index 42ecc7d74..5df55bec4 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cFireChargeEntity);
+ CLASS_PROTODEF(cFireChargeEntity)
cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h
index 7dbdc49e1..20f18b6dc 100644
--- a/src/Entities/FireworkEntity.h
+++ b/src/Entities/FireworkEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cFireworkEntity);
+ CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
const cItem & GetItem(void) const { return m_FireworkItem; }
diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h
index 5d2720b6a..96d77ac82 100644
--- a/src/Entities/Floater.h
+++ b/src/Entities/Floater.h
@@ -16,7 +16,7 @@ class cFloater :
public:
// tolua_end
- CLASS_PROTODEF(cFloater);
+ CLASS_PROTODEF(cFloater)
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index fa59fa642..3ed72d9ef 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cGhastFireballEntity);
+ CLASS_PROTODEF(cGhastFireballEntity)
cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 6498e4b5b..3593f9ede 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -16,7 +16,7 @@ class cHangingEntity :
public:
- CLASS_PROTODEF(cHangingEntity);
+ CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@@ -38,7 +38,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
eBlockFace m_BlockFace;
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index 9261e52cc..a63b78b70 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -16,7 +16,7 @@ class cItemFrame :
public:
- CLASS_PROTODEF(cItemFrame);
+ CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@@ -24,7 +24,7 @@ public:
const cItem & GetItem(void) { return m_Item; } // tolua_export
/** Set the item in the frame */
- void SetItem(cItem & a_Item) { m_Item = a_Item; }; // tolua_export
+ void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export
/** Returns the rotation from the item in the frame */
Byte GetRotation(void) const { return m_Rotation; } // tolua_export
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index c585cfab0..410d3c77d 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -21,7 +21,7 @@ class cMinecart :
typedef cEntity super;
public:
- CLASS_PROTODEF(cMinecart);
+ CLASS_PROTODEF(cMinecart)
/** Minecart payload, values correspond to packet subtype */
enum ePayload
@@ -89,7 +89,7 @@ class cRideableMinecart :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cRideableMinecart);
+ CLASS_PROTODEF(cRideableMinecart)
cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height);
@@ -113,7 +113,7 @@ class cMinecartWithChest :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithChest);
+ CLASS_PROTODEF(cMinecartWithChest)
/// Number of item slots in the chest
static const int NumSlots = 9 * 3;
@@ -144,7 +144,7 @@ class cMinecartWithFurnace :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithFurnace);
+ CLASS_PROTODEF(cMinecartWithFurnace)
cMinecartWithFurnace(double a_X, double a_Y, double a_Z);
@@ -176,7 +176,7 @@ class cMinecartWithTNT :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithTNT);
+ CLASS_PROTODEF(cMinecartWithTNT)
cMinecartWithTNT(double a_X, double a_Y, double a_Z);
} ;
@@ -191,7 +191,7 @@ class cMinecartWithHopper :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithHopper);
+ CLASS_PROTODEF(cMinecartWithHopper)
cMinecartWithHopper(double a_X, double a_Y, double a_Z);
} ;
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index ce7c6f3de..9877c95c5 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -15,7 +15,7 @@ class cPainting :
typedef cEntity super;
public:
- CLASS_PROTODEF(cPainting);
+ CLASS_PROTODEF(cPainting)
cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
const AString & GetName(void) const { return m_Name; } // tolua_export
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 63c7cfbb6..d50bcd8af 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -16,7 +16,7 @@ class cPawn :
typedef cEntity super;
public:
- CLASS_PROTODEF(cPawn);
+ CLASS_PROTODEF(cPawn)
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index d7c5d2b26..4d5250819 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -23,7 +23,7 @@ class cPickup :
public:
// tolua_end
- CLASS_PROTODEF(cPickup);
+ CLASS_PROTODEF(cPickup)
cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f);
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 26db2050b..488884602 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -48,7 +48,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); };
+ virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }
/** Returns the curently equipped weapon; empty item if none */
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index e6b05714e..0ebc32f36 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -41,7 +41,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cProjectileEntity);
+ CLASS_PROTODEF(cProjectileEntity)
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 290dd81d4..dd14ea82f 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -23,7 +23,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cSplashPotionEntity);
+ CLASS_PROTODEF(cSplashPotionEntity)
cSplashPotionEntity(
cEntity * a_Creator,
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index df61b14f5..48503cf76 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -14,7 +14,7 @@ class cTNTEntity :
public:
// tolua_end
- CLASS_PROTODEF(cTNTEntity);
+ CLASS_PROTODEF(cTNTEntity)
cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80);
cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80);
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index f93731256..a0b7d5340 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownEggEntity);
+ CLASS_PROTODEF(cThrownEggEntity)
cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 549d8a3eb..436450013 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownEnderPearlEntity);
+ CLASS_PROTODEF(cThrownEnderPearlEntity)
cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index 6f3efdd7e..8d195ced1 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownSnowballEntity);
+ CLASS_PROTODEF(cThrownSnowballEntity)
cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index ebc1550e3..c59acd807 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -22,7 +22,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cWitherSkullEntity);
+ CLASS_PROTODEF(cWitherSkullEntity)
cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h
index 9b2d9eb3c..88d71f3f9 100644
--- a/src/Generating/ChunkGenerator.h
+++ b/src/Generating/ChunkGenerator.h
@@ -44,7 +44,7 @@ public:
{
public:
cGenerator(cChunkGenerator & a_ChunkGenerator);
- virtual ~cGenerator() {} ; // Force a virtual destructor
+ virtual ~cGenerator() {} // Force a virtual destructor
/// Called to initialize the generator on server startup.
virtual void Initialize(cIniFile & a_IniFile);
diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h
index dab942136..e402c8ad6 100644
--- a/src/HTTPServer/HTTPMessage.h
+++ b/src/HTTPServer/HTTPMessage.h
@@ -33,7 +33,7 @@ public:
cHTTPMessage(eKind a_Kind);
// Force a virtual destructor in all descendants
- virtual ~cHTTPMessage() {};
+ virtual ~cHTTPMessage() {}
/** Adds a header into the internal map of headers. Recognizes special headers: Content-Type and Content-Length */
void AddHeader(const AString & a_Key, const AString & a_Value);
diff --git a/src/Mobs/Bat.h b/src/Mobs/Bat.h
index e878d0ee8..6b06aeb4f 100644
--- a/src/Mobs/Bat.h
+++ b/src/Mobs/Bat.h
@@ -15,7 +15,7 @@ class cBat :
public:
cBat(void);
- CLASS_PROTODEF(cBat);
+ CLASS_PROTODEF(cBat)
bool IsHanging(void) const {return false; }
} ;
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index 5970451c7..f283b1070 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -15,7 +15,7 @@ class cBlaze :
public:
cBlaze(void);
- CLASS_PROTODEF(cBlaze);
+ CLASS_PROTODEF(cBlaze)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Attack(float a_Dt) override;
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index 3f8b2cece..f9ed10e1b 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -14,7 +14,7 @@ class cCaveSpider :
public:
cCaveSpider(void);
- CLASS_PROTODEF(cCaveSpider);
+ CLASS_PROTODEF(cCaveSpider)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Attack(float a_Dt) override;
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h
index a4c1d6b9e..b1a50b61c 100644
--- a/src/Mobs/Chicken.h
+++ b/src/Mobs/Chicken.h
@@ -14,7 +14,7 @@ class cChicken :
public:
cChicken(void);
- CLASS_PROTODEF(cChicken);
+ CLASS_PROTODEF(cChicken)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h
index 973171ab5..8814b7e09 100644
--- a/src/Mobs/Cow.h
+++ b/src/Mobs/Cow.h
@@ -15,7 +15,7 @@ class cCow :
public:
cCow();
- CLASS_PROTODEF(cCow);
+ CLASS_PROTODEF(cCow)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index fc7db6716..747daca09 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -15,7 +15,7 @@ class cCreeper :
public:
cCreeper(void);
- CLASS_PROTODEF(cCreeper);
+ CLASS_PROTODEF(cCreeper)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h
index 77177edfe..1d4cd657c 100644
--- a/src/Mobs/EnderDragon.h
+++ b/src/Mobs/EnderDragon.h
@@ -15,7 +15,7 @@ class cEnderDragon :
public:
cEnderDragon(void);
- CLASS_PROTODEF(cEnderDragon);
+ CLASS_PROTODEF(cEnderDragon)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h
index 32e40e70b..aa2eff682 100644
--- a/src/Mobs/Enderman.h
+++ b/src/Mobs/Enderman.h
@@ -15,7 +15,7 @@ class cEnderman :
public:
cEnderman(void);
- CLASS_PROTODEF(cEnderman);
+ CLASS_PROTODEF(cEnderman)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index 43e8bedb6..1d4e6b94a 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -15,7 +15,7 @@ class cGhast :
public:
cGhast(void);
- CLASS_PROTODEF(cGhast);
+ CLASS_PROTODEF(cGhast)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Attack(float a_Dt) override;
diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h
index 356dd4352..7c04c9b4f 100644
--- a/src/Mobs/Giant.h
+++ b/src/Mobs/Giant.h
@@ -15,7 +15,7 @@ class cGiant :
public:
cGiant(void);
- CLASS_PROTODEF(cGiant);
+ CLASS_PROTODEF(cGiant)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h
index be0c23f9b..47189b3b0 100644
--- a/src/Mobs/Horse.h
+++ b/src/Mobs/Horse.h
@@ -15,7 +15,7 @@ class cHorse :
public:
cHorse(int Type, int Color, int Style, int TameTimes);
- CLASS_PROTODEF(cHorse);
+ CLASS_PROTODEF(cHorse)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h
index 30f9bedff..c5341ed76 100644
--- a/src/Mobs/IronGolem.h
+++ b/src/Mobs/IronGolem.h
@@ -15,7 +15,7 @@ class cIronGolem :
public:
cIronGolem(void);
- CLASS_PROTODEF(cIronGolem);
+ CLASS_PROTODEF(cIronGolem)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h
index 43065cae5..bfe63fa2e 100644
--- a/src/Mobs/MagmaCube.h
+++ b/src/Mobs/MagmaCube.h
@@ -15,7 +15,7 @@ public:
/// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest
cMagmaCube(int a_Size);
- CLASS_PROTODEF(cMagmaCube);
+ CLASS_PROTODEF(cMagmaCube)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
int GetSize(void) const { return m_Size; }
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index ffd078505..cdbd26c09 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -82,7 +82,7 @@ public:
*/
cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
- CLASS_PROTODEF(cMonster);
+ CLASS_PROTODEF(cMonster)
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h
index 16f6c8248..fb002c2bf 100644
--- a/src/Mobs/Mooshroom.h
+++ b/src/Mobs/Mooshroom.h
@@ -15,7 +15,7 @@ class cMooshroom :
public:
cMooshroom(void);
- CLASS_PROTODEF(cMooshroom);
+ CLASS_PROTODEF(cMooshroom)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Ocelot.h b/src/Mobs/Ocelot.h
index adb7a1f75..f2727d354 100644
--- a/src/Mobs/Ocelot.h
+++ b/src/Mobs/Ocelot.h
@@ -18,7 +18,7 @@ public:
{
}
- CLASS_PROTODEF(cOcelot);
+ CLASS_PROTODEF(cOcelot)
} ;
diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h
index 313af2f44..534a0ca6f 100644
--- a/src/Mobs/Pig.h
+++ b/src/Mobs/Pig.h
@@ -15,7 +15,7 @@ class cPig :
public:
cPig(void);
- CLASS_PROTODEF(cPig);
+ CLASS_PROTODEF(cPig)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 5ffd3e4fe..28e1c7254 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -20,7 +20,7 @@ public:
with the GenerateNaturalRandomColor() function. */
cSheep(int a_Color = -1);
- CLASS_PROTODEF(cSheep);
+ CLASS_PROTODEF(cSheep)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h
index a6e11c49d..2df333dbc 100644
--- a/src/Mobs/Silverfish.h
+++ b/src/Mobs/Silverfish.h
@@ -18,7 +18,7 @@ public:
{
}
- CLASS_PROTODEF(cSilverfish);
+ CLASS_PROTODEF(cSilverfish)
} ;
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 9a121ef48..577588b32 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -15,7 +15,7 @@ class cSkeleton :
public:
cSkeleton(bool IsWither);
- CLASS_PROTODEF(cSkeleton);
+ CLASS_PROTODEF(cSkeleton)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
@@ -24,7 +24,7 @@ public:
virtual bool IsUndead(void) override { return true; }
- bool IsWither(void) const { return m_bIsWither; };
+ bool IsWither(void) const { return m_bIsWither; }
private:
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index 15ae113dc..f0b800f94 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -16,7 +16,7 @@ public:
/** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */
cSlime(int a_Size);
- CLASS_PROTODEF(cSlime);
+ CLASS_PROTODEF(cSlime)
// cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h
index ff5e90da8..aba89e52d 100644
--- a/src/Mobs/SnowGolem.h
+++ b/src/Mobs/SnowGolem.h
@@ -15,7 +15,7 @@ class cSnowGolem :
public:
cSnowGolem(void);
- CLASS_PROTODEF(cSnowGolem);
+ CLASS_PROTODEF(cSnowGolem)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h
index 51e65d028..813d2e266 100644
--- a/src/Mobs/Spider.h
+++ b/src/Mobs/Spider.h
@@ -15,7 +15,7 @@ class cSpider :
public:
cSpider(void);
- CLASS_PROTODEF(cSpider);
+ CLASS_PROTODEF(cSpider)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h
index a9dba8b70..b57340427 100644
--- a/src/Mobs/Squid.h
+++ b/src/Mobs/Squid.h
@@ -17,7 +17,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- CLASS_PROTODEF(cSquid);
+ CLASS_PROTODEF(cSquid)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index 068dfd835..aa81f0790 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -27,7 +27,7 @@ public:
cVillager(eVillagerType VillagerType);
- CLASS_PROTODEF(cVillager);
+ CLASS_PROTODEF(cVillager)
// cEntity overrides
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h
index 51c63322a..bd059f61d 100644
--- a/src/Mobs/Witch.h
+++ b/src/Mobs/Witch.h
@@ -16,7 +16,7 @@ class cWitch :
public:
cWitch();
- CLASS_PROTODEF(cWitch);
+ CLASS_PROTODEF(cWitch)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index cc8d1459b..2403823ed 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -15,7 +15,7 @@ class cWither :
public:
cWither(void);
- CLASS_PROTODEF(cWither);
+ CLASS_PROTODEF(cWither)
unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; }
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index fb8a7c995..2e83db701 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -16,7 +16,7 @@ class cWolf :
public:
cWolf(void);
- CLASS_PROTODEF(cWolf);
+ CLASS_PROTODEF(cWolf)
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h
index 082573d8b..118b6e6e7 100644
--- a/src/Mobs/Zombie.h
+++ b/src/Mobs/Zombie.h
@@ -14,7 +14,7 @@ class cZombie :
public:
cZombie(bool a_IsVillagerZombie);
- CLASS_PROTODEF(cZombie);
+ CLASS_PROTODEF(cZombie)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index a4bad7efb..bae0115eb 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -14,7 +14,7 @@ class cZombiePigman :
public:
cZombiePigman(void);
- CLASS_PROTODEF(cZombiePigman);
+ CLASS_PROTODEF(cZombiePigman)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h
index 269f9db41..bf4d7f004 100644
--- a/src/OSSupport/Queue.h
+++ b/src/OSSupport/Queue.h
@@ -26,14 +26,14 @@ struct cQueueFuncs
public:
/// Called when an Item is deleted from the queue without being returned
- static void Delete(T) {};
+ static void Delete(T) {}
/// Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already inserted
static void Combine(T & a_existing, const T & a_new)
{
UNUSED(a_existing);
UNUSED(a_new);
- };
+ }
};
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index c5ba7a679..166e9ab1b 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -138,7 +138,7 @@ protected:
virtual void SendData(const char * a_Data, size_t a_Size) = 0;
/// Called after writing each packet, enables descendants to flush their buffers
- virtual void Flush(void) {};
+ virtual void Flush(void) {}
// Helpers for writing partial packet data, write using SendData()
void WriteByte(Byte a_Value)
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index d7ebf535b..bf08b6c50 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -90,7 +90,7 @@ public:
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) override;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
- virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {};
+ virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {}
virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendWeather (eWeather a_Weather) override;
diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp
new file mode 100644
index 000000000..6e0c2733e
--- /dev/null
+++ b/src/SetChunkData.cpp
@@ -0,0 +1,115 @@
+
+// SetChunkData.cpp
+
+// Implements the cSetChunkData class used for sending loaded / generated chunk
+
+#include "Globals.h"
+#include "SetChunkData.h"
+
+
+
+
+
+cSetChunkData::cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty) :
+ m_ChunkX(a_ChunkX),
+ m_ChunkZ(a_ChunkZ),
+ m_ShouldMarkDirty(a_ShouldMarkDirty)
+{
+}
+
+
+
+
+
+cSetChunkData::cSetChunkData(
+ int a_ChunkX, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockMetas,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_SkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ const cChunkDef::BiomeMap * a_Biomes,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities,
+ bool a_ShouldMarkDirty
+) :
+ m_ChunkX(a_ChunkX),
+ m_ChunkZ(a_ChunkZ),
+ m_ShouldMarkDirty(a_ShouldMarkDirty)
+{
+ // Check the params' validity:
+ ASSERT(a_BlockTypes != NULL);
+ ASSERT(a_BlockMetas != NULL);
+ ASSERT(a_Biomes != NULL);
+
+ // Copy block types and metas:
+ memcpy(m_BlockTypes, a_BlockTypes, sizeof(cChunkDef::BlockTypes));
+ memcpy(m_BlockMetas, a_BlockMetas, sizeof(cChunkDef::BlockNibbles));
+
+ // Copy lights, if both given:
+ if ((a_BlockLight != NULL) && (a_SkyLight != NULL))
+ {
+ memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight));
+ memcpy(m_SkyLight, a_SkyLight, sizeof(m_SkyLight));
+ m_IsLightValid = true;
+ }
+ else
+ {
+ m_IsLightValid = false;
+ }
+
+ // Copy the heightmap, if available:
+ if (a_HeightMap != NULL)
+ {
+ memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
+ m_IsHeightMapValid = true;
+ }
+ else
+ {
+ m_IsHeightMapValid = false;
+ }
+
+ // Copy biomes, if available:
+ if (a_Biomes != NULL)
+ {
+ memcpy(m_Biomes, a_Biomes, sizeof(m_Biomes));
+ m_AreBiomesValid = true;
+ }
+ else
+ {
+ m_AreBiomesValid = false;
+ }
+
+ // Move entities and blockentities:
+ std::swap(m_Entities, a_Entities);
+ std::swap(m_BlockEntities, a_BlockEntities);
+}
+
+
+
+
+
+void cSetChunkData::CalculateHeightMap(void)
+{
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int y = cChunkDef::Height - 1; y > -1; y--)
+ {
+ int index = cChunkDef::MakeIndexNoCheck(x, y, z);
+ if (m_BlockTypes[index] != E_BLOCK_AIR)
+ {
+ m_HeightMap[x + z * cChunkDef::Width] = (HEIGHTTYPE)y;
+ break;
+ }
+ } // for y
+ } // for z
+ } // for x
+ m_IsHeightMapValid = true;
+}
+
+
+
+
+
diff --git a/src/SetChunkData.h b/src/SetChunkData.h
new file mode 100644
index 000000000..a2f776f6b
--- /dev/null
+++ b/src/SetChunkData.h
@@ -0,0 +1,120 @@
+
+// SetChunkData.h
+
+// Declares the cSetChunkData class used for sending loaded / generated chunk data into cWorld
+
+
+
+
+
+#pragma once
+
+
+
+
+
+class cSetChunkData
+{
+public:
+ /** Constructs a new instance with empty data.
+ Allocates new buffers for the block data.
+ Prefer to use this constructor, then fill the object with data and then send it to cWorld, as this will
+ reduce the copying required to queue the set operation. */
+ cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty);
+
+ /** Constructs a new instance based on data existing elsewhere, will copy all the memory. Prefer to use the
+ other constructor as much as possible.
+ Will move the entity and blockentity lists into the internal storage, and empty the a_Entities and
+ a_BlockEntities lists.
+ a_BlockTypes and a_BlockMetas must always be valid.
+ If either of the light arrays are NULL, the chunk data will be marked as not having any light at all and
+ will be scheduled for re-lighting once it is set into the chunkmap.
+ If a_Biomes is not valid, the internal flag is set and the world will calculate the biomes using the chunk
+ generator when setting the chunk data.
+ If a_HeightMap is not assigned, the world will calculate the heightmap based on the blocktypes when setting
+ the chunk data. */
+ cSetChunkData(
+ int a_ChunkX, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockMetas,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_SkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ const cChunkDef::BiomeMap * a_Biomes,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities,
+ bool a_ShouldMarkDirty
+ );
+
+ int GetChunkX(void) const { return m_ChunkX; }
+ int GetChunkZ(void) const { return m_ChunkZ; }
+
+ /** Returns the internal storage of the block types, read-only. */
+ const cChunkDef::BlockTypes & GetBlockTypes(void) const { return m_BlockTypes; }
+
+ /** Returns the internal storage of the block types, read-only. */
+ const cChunkDef::BlockNibbles & GetBlockMetas(void) const { return m_BlockMetas; }
+
+ /** Returns the internal storage of the block light, read-only. */
+ const cChunkDef::BlockNibbles & GetBlockLight(void) const { return m_BlockLight; }
+
+ /** Returns the internal storage of the block types, read-only. */
+ const cChunkDef::BlockNibbles & GetSkyLight(void) const { return m_SkyLight; }
+
+ /** Returns the internal storage for heightmap, read-only. */
+ const cChunkDef::HeightMap & GetHeightMap(void) const { return m_HeightMap; }
+
+ /** Returns the internal storage for biomes, read-write. */
+ cChunkDef::BiomeMap & GetBiomes(void) { return m_Biomes; }
+
+ /** Returns the internal storage for entities, read-write. */
+ cEntityList & GetEntities(void) { return m_Entities; }
+
+ /** Returns the internal storage for block entities, read-write. */
+ cBlockEntityList & GetBlockEntities(void) { return m_BlockEntities; }
+
+ /** Returns whether both light arrays stored in this object are valid. */
+ bool IsLightValid(void) const { return m_IsLightValid; }
+
+ /** Returns whether the heightmap stored in this object is valid. */
+ bool IsHeightMapValid(void) const { return m_IsHeightMapValid; }
+
+ /** Returns whether the biomes stored in this object are valid. */
+ bool AreBiomesValid(void) const { return m_AreBiomesValid; }
+
+ /** Returns whether the chunk should be marked as dirty after its data is set.
+ Used by the generator to save chunks after generating. */
+ bool ShouldMarkDirty(void) const { return m_ShouldMarkDirty; }
+
+ /** Marks the biomes stored in this object as valid. */
+ void MarkBiomesValid(void) { m_AreBiomesValid = true; }
+
+ /** Calculates the heightmap based on the contained blocktypes and marks it valid. */
+ void CalculateHeightMap(void);
+
+protected:
+ int m_ChunkX;
+ int m_ChunkZ;
+
+ cChunkDef::BlockTypes m_BlockTypes;
+ cChunkDef::BlockNibbles m_BlockMetas;
+ cChunkDef::BlockNibbles m_BlockLight;
+ cChunkDef::BlockNibbles m_SkyLight;
+ cChunkDef::HeightMap m_HeightMap;
+ cChunkDef::BiomeMap m_Biomes;
+ cEntityList m_Entities;
+ cBlockEntityList m_BlockEntities;
+
+ bool m_IsLightValid;
+ bool m_IsHeightMapValid;
+ bool m_AreBiomesValid;
+ bool m_ShouldMarkDirty;
+};
+
+typedef SharedPtr<cSetChunkData> cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11
+typedef std::vector<cSetChunkDataPtr> cSetChunkDataPtrs;
+
+
+
+
+
diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h
index 171eba91c..4d9a18867 100644
--- a/src/Simulator/Simulator.h
+++ b/src/Simulator/Simulator.h
@@ -32,7 +32,7 @@ public:
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
UNUSED(a_Chunk);
- };
+ }
/// Called when a block changes
virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk);
diff --git a/src/World.cpp b/src/World.cpp
index 4ddd11f59..7ad350e24 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -11,6 +11,7 @@
#include "ChunkMap.h"
#include "Generating/ChunkDesc.h"
#include "OSSupport/Timer.h"
+#include "SetChunkData.h"
// Serializers
#include "WorldStorage/ScoreboardSerializer.h"
@@ -719,6 +720,17 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
// Call the plugins
cPluginManager::Get()->CallHookWorldTick(*this, a_Dt, a_LastTickDurationMSec);
+ // Set any chunk data that has been queued for setting:
+ cSetChunkDataPtrs SetChunkDataQueue;
+ {
+ cCSLock Lock(m_CSSetChunkDataQueue);
+ std::swap(SetChunkDataQueue, m_SetChunkDataQueue);
+ }
+ for (cSetChunkDataPtrs::iterator itr = SetChunkDataQueue.begin(), end = SetChunkDataQueue.end(); itr != end; ++itr)
+ {
+ SetChunkData(**itr);
+ } // for itr - SetChunkDataQueue[]
+
// We need sub-tick precision here, that's why we store the time in seconds and calculate ticks off of it
m_WorldAgeSecs += (double)a_Dt / 1000.0;
m_TimeOfDaySecs += (double)a_Dt / 1000.0;
@@ -2217,47 +2229,59 @@ void cWorld::MarkChunkSaved (int a_ChunkX, int a_ChunkZ)
-void cWorld::SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap * a_BiomeMap,
- cEntityList & a_Entities,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
-)
+void cWorld::QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData)
{
// Validate biomes, if needed:
- cChunkDef::BiomeMap BiomeMap;
- const cChunkDef::BiomeMap * Biomes = a_BiomeMap;
- if (a_BiomeMap == NULL)
+ if (!a_SetChunkData->AreBiomesValid())
{
// The biomes are not assigned, get them from the generator:
- Biomes = &BiomeMap;
- m_Generator.GenerateBiomes(a_ChunkX, a_ChunkZ, BiomeMap);
+ m_Generator.GenerateBiomes(a_SetChunkData->GetChunkX(), a_SetChunkData->GetChunkZ(), a_SetChunkData->GetBiomes());
+ a_SetChunkData->MarkBiomesValid();
}
- m_ChunkMap->SetChunkData(
- a_ChunkX, a_ChunkZ,
- a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight,
- a_HeightMap, *Biomes,
- a_BlockEntities,
- a_MarkDirty
- );
+ // Validate heightmap, if needed:
+ if (!a_SetChunkData->IsHeightMapValid())
+ {
+ a_SetChunkData->CalculateHeightMap();
+ }
+
+ // Store a copy of the data in the queue:
+ // TODO: If the queue is too large, wait for it to get processed. Not likely, though.
+ cCSLock Lock(m_CSSetChunkDataQueue);
+ m_SetChunkDataQueue.push_back(a_SetChunkData);
+}
+
+
+
+
+
+void cWorld::SetChunkData(cSetChunkData & a_SetChunkData)
+{
+ ASSERT(a_SetChunkData.AreBiomesValid());
+ ASSERT(a_SetChunkData.IsHeightMapValid());
+
+ m_ChunkMap->SetChunkData(a_SetChunkData);
// Initialize the entities (outside the m_ChunkMap's CS, to fix FS #347):
- for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr)
+ cEntityList Entities;
+ std::swap(a_SetChunkData.GetEntities(), Entities);
+ for (cEntityList::iterator itr = Entities.begin(), end = Entities.end(); itr != end; ++itr)
{
(*itr)->Initialize(*this);
}
// If a client is requesting this chunk, send it to them:
- if (m_ChunkMap->HasChunkAnyClients(a_ChunkX, a_ChunkZ))
+ int ChunkX = a_SetChunkData.GetChunkX();
+ int ChunkZ = a_SetChunkData.GetChunkZ();
+ if (m_ChunkMap->HasChunkAnyClients(ChunkX, ChunkZ))
+ {
+ m_ChunkSender.ChunkReady(ChunkX, ChunkZ);
+ }
+
+ // Save the chunk right after generating, so that we don't have to generate it again on next run
+ if (a_SetChunkData.ShouldMarkDirty())
{
- m_ChunkSender.ChunkReady(a_ChunkX, a_ChunkZ);
+ m_Storage.QueueSaveChunk(ChunkX, 0, ChunkZ);
}
}
@@ -2975,21 +2999,31 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp
int cWorld::SpawnMobFinalize(cMonster * a_Monster)
{
+ // Invalid cMonster object. Bail out.
if (!a_Monster)
+ {
return -1;
+ }
+
+ // Give the mob full health.
a_Monster->SetHealth(a_Monster->GetMaxHealth());
+
+ // A plugin doesn't agree with the spawn. bail out.
if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster))
{
delete a_Monster;
a_Monster = NULL;
return -1;
}
+
+ // Initialize the monster into the current world.
if (!a_Monster->Initialize(*this))
{
delete a_Monster;
a_Monster = NULL;
return -1;
}
+
BroadcastSpawnEntity(*a_Monster);
cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster);
@@ -3285,17 +3319,14 @@ void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc
cChunkDef::BlockNibbles BlockMetas;
a_ChunkDesc.CompressBlockMetas(BlockMetas);
- m_World->SetChunkData(
+ m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData(
a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(),
a_ChunkDesc.GetBlockTypes(), BlockMetas,
NULL, NULL, // We don't have lighting, chunk will be lighted when needed
&a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(),
a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(),
true
- );
-
- // Save the chunk right after generating, so that we don't have to generate it again on next run
- m_World->GetStorage().QueueSaveChunk(a_ChunkDesc.GetChunkX(), 0, a_ChunkDesc.GetChunkZ());
+ )));
}
diff --git a/src/World.h b/src/World.h
index 2346ac523..9658178ae 100644
--- a/src/World.h
+++ b/src/World.h
@@ -49,9 +49,14 @@ class cNoteEntity;
class cMobHeadEntity;
class cCompositeChat;
class cCuboid;
+class cSetChunkData;
+
typedef std::list< cPlayer * > cPlayerList;
+typedef SharedPtr<cSetChunkData> cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11
+typedef std::vector<cSetChunkDataPtr> cSetChunkDataPtrs;
+
typedef cItemCallback<cPlayer> cPlayerListCallback;
typedef cItemCallback<cEntity> cEntityCallback;
typedef cItemCallback<cChestEntity> cChestCallback;
@@ -91,7 +96,7 @@ public:
class cTask
{
public:
- virtual ~cTask(){};
+ virtual ~cTask() {}
virtual void Run(cWorld & a_World) = 0;
} ;
@@ -246,24 +251,9 @@ public:
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ);
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
- /** Sets the chunk data as either loaded from the storage or generated.
- a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
- a_BiomeMap is optional, if not present, biomes will be calculated by the generator
- a_HeightMap is optional, if not present, will be calculated.
- If a_MarkDirty is set, the chunk is set as dirty (used after generating)
- */
- void SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap * a_BiomeMap,
- cEntityList & a_Entities,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
- );
+ /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
+ If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */
+ void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData);
void ChunkLighted(
int a_ChunkX, int a_ChunkZ,
@@ -655,7 +645,7 @@ public:
void GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLightingQueue);
// Various queues length queries (cannot be const, they lock their CS):
- inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export
+ inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export
inline size_t GetLightingQueueLength (void) { return m_Lighting.GetQueueLength(); } // tolua_export
inline size_t GetStorageLoadQueueLength(void) { return m_Storage.GetLoadQueueLength(); } // tolua_export
inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export
@@ -687,13 +677,13 @@ public:
void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ);
/** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */
- void SetWeather (eWeather a_NewWeather);
+ void SetWeather(eWeather a_NewWeather);
/** Forces a weather change in the next game tick */
- void ChangeWeather (void);
+ void ChangeWeather(void);
/** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */
- eWeather GetWeather (void) const { return m_Weather; };
+ eWeather GetWeather(void) const { return m_Weather; }
/** Returns true if the current weather is sun */
bool IsWeatherSunny(void) const { return (m_Weather == wSunny); }
@@ -708,7 +698,7 @@ public:
bool IsWeatherRain(void) const { return (m_Weather == wRain); }
/** Returns true if it is raining at the specified location. This takes into account biomes. */
- bool IsWeatherRainAt (int a_BlockX, int a_BlockZ)
+ bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
{
return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
}
@@ -969,6 +959,12 @@ private:
/** List of players that are scheduled for adding, waiting for the Tick thread to add them. */
cPlayerList m_PlayersToAdd;
+
+ /** CS protecting m_SetChunkDataQueue. */
+ cCriticalSection m_CSSetChunkDataQueue;
+
+ /** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */
+ cSetChunkDataPtrs m_SetChunkDataQueue;
cWorld(const AString & a_WorldName);
@@ -1011,6 +1007,10 @@ private:
/** Adds the players queued in the m_PlayersToAdd queue into the m_Players list.
Assumes it is called from the Tick thread. */
void AddQueuedPlayers(void);
+
+ /** Sets the specified chunk data into the chunkmap. Called in the tick thread.
+ Modifies the a_SetChunkData - moves the entities contained in it into the chunk. */
+ void SetChunkData(cSetChunkData & a_SetChunkData);
}; // tolua_export
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index 7aa83fc24..4ef72e379 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -160,7 +160,7 @@ public:
/** Returns the direct child tag of the specified name, or -1 if no such tag. */
int FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLength = 0) const;
- /** Returns the child tag of the specified path (Name1\Name2\Name3...), or -1 if no such tag. */
+ /** Returns the child tag of the specified path (Name1/Name2/Name3...), or -1 if no such tag. */
int FindTagByPath(int a_Tag, const AString & a_Path) const;
eTagType GetType(int a_Tag) const { return m_Tags[(size_t)a_Tag].m_Type; }
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 663d489bc..2851647fe 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -14,6 +14,7 @@
#include "../Item.h"
#include "../ItemGrid.h"
#include "../StringCompression.h"
+#include "../SetChunkData.h"
#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
@@ -391,7 +392,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
} // for y
//*/
- m_World->SetChunkData(
+ m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ,
BlockTypes, MetaData,
IsLightValid ? BlockLight : NULL,
@@ -399,7 +400,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
NULL, Biomes,
Entities, BlockEntities,
false
- );
+ )));
return true;
}
diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp
index 5382a3e01..ee47047a0 100644
--- a/src/WorldStorage/WSSCompact.cpp
+++ b/src/WorldStorage/WSSCompact.cpp
@@ -18,6 +18,7 @@
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/SignEntity.h"
+#include "../SetChunkData.h"
@@ -911,7 +912,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + LightOffset);
NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + SkyLightOffset);
- a_World->SetChunkData(
+ a_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ,
BlockData, MetaData,
IsLightValid ? BlockLight : NULL,
@@ -919,7 +920,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
NULL, NULL,
Entities, BlockEntities,
false
- );
+ )));
return true;
}
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index 2d5d9c830..978a5b5d1 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -103,11 +103,11 @@ protected:
struct FuncTable
{
- static void Delete(sChunkLoad) {};
+ static void Delete(sChunkLoad) {}
static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new)
{
a_orig.m_Generate |= a_new.m_Generate;
- };
+ }
};
typedef cQueue<sChunkLoad, FuncTable> sChunkLoadQueue;