summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua3
-rw-r--r--MCServer/Plugins/APIDump/Hooks/OnServerPing.lua50
-rw-r--r--Tools/QtBiomeVisualiser/Globals.h11
-rw-r--r--src/BlockInfo.cpp2
-rw-r--r--src/Blocks/ChunkInterface.cpp2
-rw-r--r--src/ChunkMap.cpp1
-rw-r--r--src/ClientHandle.cpp14
-rw-r--r--src/Generating/BioGen.cpp60
-rw-r--r--src/Generating/BioGen.h15
-rw-r--r--src/Mobs/Monster.h2
-rw-r--r--src/Protocol/Protocol18x.cpp7
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.inc7
-rw-r--r--src/Simulator/Simulator.cpp7
13 files changed, 124 insertions, 57 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index e6ee4ca10..f903308d1 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1984,6 +1984,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
HOOK_PLAYER_USING_ITEM = { Notes = "Called when the player is about to right-click with a usable item in their hand." },
HOOK_POST_CRAFTING = { Notes = "Called after a valid recipe has been chosen for the current contents of the crafting grid. Plugins may modify the recipe." },
HOOK_PRE_CRAFTING = { Notes = "Called before a recipe is searched for the current contents of the crafting grid. Plugins may provide a recipe and cancel the built-in search." },
+ HOOK_SERVER_PING = { Notes = "Called when a client pings the server from the server list. Plugins may change the favicon, server description, players online and maximum players values." },
HOOK_SPAWNED_ENTITY = { Notes = "Called after an entity is spawned in a {{cWorld|world}}. The entity is already part of the world." },
HOOK_SPAWNED_MONSTER = { Notes = "Called after a mob is spawned in a {{cWorld|world}}. The mob is already part of the world." },
HOOK_SPAWNING_ENTITY = { Notes = "Called just before an entity is spawned in a {{cWorld|world}}." },
@@ -2814,7 +2815,7 @@ end
Globals =
{
Desc = [[
- These functions are available directly, without a class instance. Any plugin cal call them at any
+ These functions are available directly, without a class instance. Any plugin can call them at any
time.
]],
Functions =
diff --git a/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua b/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
new file mode 100644
index 000000000..6d2325fe6
--- /dev/null
+++ b/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
@@ -0,0 +1,50 @@
+return
+{
+ HOOK_SERVER_PING =
+ {
+ CalledWhen = "Client pings the server from the server list.",
+ DefaultFnName = "OnServerPing", -- also used as pagename
+ Desc = [[
+ A plugin may implement an OnServerPing() function and register it as a Hook to process pings from
+ clients in the server server list. It can change the logged in players and player capacity, as well
+ as the server description and the favicon, that are displayed to the client in the server list.
+ ]],
+ Params = {
+ { Name = "ClientHandle", Type = "{{cClientHandle}}", Notes = "The client handle that pinged the server" },
+ { Name = "ServerDescription", Type = "string", Notes = "The server description" },
+ { Name = "OnlinePlayersCount", Type = "number", Notes = "The number of players currently on the server" },
+ { Name = "MaxPlayersCount", Type = "number", Notes = "The current player cap for the server" },
+ { Name = "Favicon", Type = "string", Notes = "The base64 encoded favicon to be displayed in the server list for compatible clients" },
+ },
+ Returns = [[
+ The plugin can return whether to continue processing of the hook with other plugins, the server description to
+ be displayed to the client, the currently online players, the player cap and the base64/png favicon data, in that order.
+ ]],
+ CodeExamples = {
+ {
+ Title = "Change information returned to the player",
+ Desc = "Tells the client that the server description is 'test', there are one more players online than there actually are, and that the player cap is zero. It also changes the favicon data.",
+ Code = [[
+function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
+ -- Change Server Description
+ ServerDescription = "Test"
+
+ -- Change online / max players
+ OnlinePlayers = OnlinePlayers + 1
+ MaxPlayers = 0
+
+ -- Change favicon
+ if (cFile:IsFile("my-favicon.png")) then
+ local FaviconData = cFile:ReadWholeFile("my-favicon.png")
+ if (FaviconData != "") then
+ Favicon = Base64Encode(FaviconData)
+ end
+ end
+
+ return false, ServerDescription, OnlinePlayers, MaxPlayers, Favicon
+end
+ ]],
+ },
+ },
+ }, -- HOOK_SERVER_PING
+}
diff --git a/Tools/QtBiomeVisualiser/Globals.h b/Tools/QtBiomeVisualiser/Globals.h
index 8d2e913b7..e2e9a9970 100644
--- a/Tools/QtBiomeVisualiser/Globals.h
+++ b/Tools/QtBiomeVisualiser/Globals.h
@@ -158,8 +158,17 @@ template class SizeChecker<UInt16, 2>;
TypeName(const TypeName &); \
void operator =(const TypeName &)
+// A macro that is used to mark unused local variables, to avoid pedantic warnings in gcc / clang / MSVC
+// Note that in MSVC it requires the full type of X to be known
+#define UNUSED_VAR(X) (void)(X)
+
// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
-#define UNUSED(X) (void)(X)
+// Written so that the full type of param needn't be known
+#ifdef _MSC_VER
+ #define UNUSED(X)
+#else
+ #define UNUSED UNUSED_VAR
+#endif
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index fb9b746b3..14e814084 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -734,7 +734,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_NEW_LOG ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_DARK_OAK_WOOD_STAIRS ].m_PlaceSound = "dig.wood";
- a_Info[E_BLOCK_SLIME_BLOCK ].m_PlaceSound = "dig.slime"; // I hope it is named slime, it's definetly a new sound type though...
+ a_Info[E_BLOCK_SLIME_BLOCK ].m_PlaceSound = "dig.slime"; // TODO: Check that this is the correct name
a_Info[E_BLOCK_BARRIER ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_IRON_TRAPDOOR ].m_PlaceSound = "dig.metal";
a_Info[E_BLOCK_PRISMARINE_BLOCK ].m_PlaceSound = "dig.stone";
diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp
index e22a1410e..817640e98 100644
--- a/src/Blocks/ChunkInterface.cpp
+++ b/src/Blocks/ChunkInterface.cpp
@@ -4,7 +4,7 @@
#include "ChunkInterface.h"
#include "ChunkMap.h"
#include "BlockHandler.h"
-#include "WorldInterface.h"
+#include "WorldInterface.h"
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 38a7d9bd4..299fe0eca 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1888,6 +1888,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
case E_BLOCK_OBSIDIAN:
case E_BLOCK_BEACON:
case E_BLOCK_BEDROCK:
+ case E_BLOCK_BARRIER:
case E_BLOCK_WATER:
case E_BLOCK_LAVA:
{
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 9858aa991..bd00c0b9e 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1148,10 +1148,18 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
FinishDigAnimation();
- if (!m_Player->IsGameModeCreative() && (a_OldBlock == E_BLOCK_BEDROCK))
+ if (!m_Player->IsGameModeCreative())
{
- Kick("You can't break a bedrock!");
- return;
+ if (a_OldBlock == E_BLOCK_BEDROCK)
+ {
+ Kick("You can't break a bedrock!");
+ return;
+ }
+ if (a_OldBlock == E_BLOCK_BARRIER)
+ {
+ Kick("You can't break a barrier!");
+ return;
+ }
}
cWorld * World = m_Player->GetWorld();
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 3ee0bd4c5..8924a7999 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -737,8 +737,6 @@ void cBioGenMultiStepMap::FreezeWaterBiomes(cChunkDef::BiomeMap & a_BiomeMap, co
cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) :
m_VoronoiLarge(a_Seed + 1000),
m_VoronoiSmall(a_Seed + 2000),
- m_DistortX(a_Seed + 3000),
- m_DistortZ(a_Seed + 4000),
m_Noise1(a_Seed + 5001),
m_Noise2(a_Seed + 5002),
m_Noise3(a_Seed + 5003),
@@ -762,19 +760,17 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
int DistortZ[cChunkDef::Width + 1][cChunkDef::Width + 1];
for (int x = 0; x <= 4; x++) for (int z = 0; z <= 4; z++)
{
- int BlockX = BaseX + x * 4;
- int BlockZ = BaseZ + z * 4;
- float BlockXF = (float)(16 * BlockX) / 128;
- float BlockZF = (float)(16 * BlockZ) / 128;
- double NoiseX = m_Noise1.CubicNoise2D(BlockXF / 16, BlockZF / 16);
- NoiseX += 0.5 * m_Noise2.CubicNoise2D(BlockXF / 8, BlockZF / 8);
- NoiseX += 0.08 * m_Noise3.CubicNoise2D(BlockXF, BlockZF);
- double NoiseZ = m_Noise4.CubicNoise2D(BlockXF / 16, BlockZF / 16);
- NoiseZ += 0.5 * m_Noise5.CubicNoise2D(BlockXF / 8, BlockZF / 8);
- NoiseZ += 0.08 * m_Noise6.CubicNoise2D(BlockXF, BlockZF);
+ float BlockX = BaseX + x * 4;
+ float BlockZ = BaseZ + z * 4;
+ double NoiseX = m_AmpX1 * m_Noise1.CubicNoise2D(BlockX * m_FreqX1, BlockZ * m_FreqX1);
+ NoiseX += m_AmpX2 * m_Noise2.CubicNoise2D(BlockX * m_FreqX2, BlockZ * m_FreqX2);
+ NoiseX += m_AmpX3 * m_Noise3.CubicNoise2D(BlockX * m_FreqX3, BlockZ * m_FreqX3);
+ double NoiseZ = m_AmpZ1 * m_Noise4.CubicNoise2D(BlockX * m_FreqZ1, BlockZ * m_FreqZ1);
+ NoiseZ += m_AmpZ2 * m_Noise5.CubicNoise2D(BlockX * m_FreqZ2, BlockZ * m_FreqZ2);
+ NoiseZ += m_AmpZ3 * m_Noise6.CubicNoise2D(BlockX * m_FreqZ3, BlockZ * m_FreqZ3);
- DistortX[4 * x][4 * z] = BlockX + (int)(64 * NoiseX);
- DistortZ[4 * x][4 * z] = BlockZ + (int)(64 * NoiseZ);
+ DistortX[4 * x][4 * z] = (int)(BlockX + NoiseX);
+ DistortZ[4 * x][4 * z] = (int)(BlockZ + NoiseZ);
}
LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortX[0][0]);
@@ -915,30 +911,18 @@ void cBioGenTwoLevel::InitializeBiomeGen(cIniFile & a_IniFile)
{
m_VoronoiLarge.SetCellSize(a_IniFile.GetValueSetI("Generator", "TwoLevelLargeCellSize", 1024));
m_VoronoiSmall.SetCellSize(a_IniFile.GetValueSetI("Generator", "TwoLevelSmallCellSize", 128));
- m_DistortX.AddOctave(
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave1Freq", 0.01),
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave1Amp", 16)
- );
- m_DistortX.AddOctave(
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave2Freq", 0.005),
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave2Amp", 8)
- );
- m_DistortX.AddOctave(
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave3Freq", 0.0025),
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave3Amp", 4)
- );
- m_DistortZ.AddOctave(
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave1Freq", 0.01),
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave1Amp", 16)
- );
- m_DistortZ.AddOctave(
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave2Freq", 0.005),
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave2Amp", 8)
- );
- m_DistortZ.AddOctave(
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave3Freq", 0.0025),
- (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave3Amp", 4)
- );
+ m_FreqX1 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave1Freq", 0.01);
+ m_AmpX1 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave1Amp", 80);
+ m_FreqX2 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave2Freq", 0.05);
+ m_AmpX2 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave2Amp", 20);
+ m_FreqX3 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave3Freq", 0.1),
+ m_AmpX3 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortXOctave3Amp", 8);
+ m_FreqZ1 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave1Freq", 0.01);
+ m_AmpZ1 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave1Amp", 80);
+ m_FreqZ2 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave2Freq", 0.05);
+ m_AmpZ2 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave2Amp", 20);
+ m_FreqZ3 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave3Freq", 0.1);
+ m_AmpZ3 = (float)a_IniFile.GetValueSetF("Generator", "TwoLevelDistortZOctave3Amp", 8);
}
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h
index 20d199611..22ddfae5c 100644
--- a/src/Generating/BioGen.h
+++ b/src/Generating/BioGen.h
@@ -285,12 +285,7 @@ protected:
/// The Voronoi map that decides biomes inside individual biome groups
cVoronoiMap m_VoronoiSmall;
- /// The noise used to distort the input X coord
- cPerlinNoise m_DistortX;
-
- /// The noise used to distort the inupt Z coord
- cPerlinNoise m_DistortZ;
-
+ // The noises used for the distortion:
cNoise m_Noise1;
cNoise m_Noise2;
cNoise m_Noise3;
@@ -298,6 +293,14 @@ protected:
cNoise m_Noise5;
cNoise m_Noise6;
+ // Frequencies and amplitudes for the distortion noises:
+ float m_FreqX1, m_AmpX1;
+ float m_FreqX2, m_AmpX2;
+ float m_FreqX3, m_AmpX3;
+ float m_FreqZ1, m_AmpZ1;
+ float m_FreqZ2, m_AmpZ2;
+ float m_FreqZ3, m_AmpZ3;
+
// cBiomeGen overrides:
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index ba746ebc8..a1f9c4a5b 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -25,7 +25,7 @@ class cMonster :
typedef cPawn super;
public:
- //Depreciated
+ // Deprecated
typedef eMonsterType eType;
enum eFamily
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index c983f6671..7a6eb5f28 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -989,7 +989,6 @@ void cProtocol180::SendPluginMessage(const AString & a_Channel, const AString &
cPacketizer Pkt(*this, 0x3f);
Pkt.WriteString(a_Channel);
- Pkt.WriteVarInt((UInt32)a_Message.size());
Pkt.WriteBuf(a_Message.data(), a_Message.size());
}
@@ -2316,9 +2315,11 @@ void cProtocol180::HandlePacketPlayerPosLook(cByteBuffer & a_ByteBuffer)
void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel);
- HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, DataLen);
AString Data;
- a_ByteBuffer.ReadString(Data, DataLen);
+ if (!a_ByteBuffer.ReadString(Data, a_ByteBuffer.GetReadableSpace() - 1))
+ {
+ return;
+ }
m_Client->HandlePluginMessage(Channel, Data);
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.inc b/src/Simulator/IncrementalRedstoneSimulator.inc
index adaa47967..937e6b790 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.inc
+++ b/src/Simulator/IncrementalRedstoneSimulator.inc
@@ -408,7 +408,12 @@ void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime,
// Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid
// Checking only when a block is changed, as opposed to every tick, also improves performance
- PoweredBlocksList & PoweredBlocks = ((cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData())->m_PoweredBlocks;
+ cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::cIncrementalRedstoneSimulatorChunkData * SimulatorChunkData = ((cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData());
+ if (SimulatorChunkData == NULL)
+ {
+ return;
+ }
+ PoweredBlocksList & PoweredBlocks = SimulatorChunkData->m_PoweredBlocks;
for (typename PoweredBlocksList::iterator itr = PoweredBlocks.begin(); itr != PoweredBlocks.end();)
{
if (!itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
diff --git a/src/Simulator/Simulator.cpp b/src/Simulator/Simulator.cpp
index d26702166..29a1132ad 100644
--- a/src/Simulator/Simulator.cpp
+++ b/src/Simulator/Simulator.cpp
@@ -8,6 +8,11 @@
#include "Simulator.inc"
-#pragma clang diagnostic ignored "-Wweak-template-vtables"
+#ifdef __clang__
+ #pragma clang diagnostic ignored "-Wweak-template-vtables"
+#endif // __clang__
+
template class cSimulator<cChunk, cWorld>;
+
+