summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/InfoDump.lua4
-rw-r--r--Tools/BiomeVisualiser/BiomeRenderer.cpp2
-rw-r--r--src/Bindings/LuaState.cpp15
-rw-r--r--src/BiomeDef.cpp14
-rw-r--r--src/BiomeDef.h9
-rw-r--r--src/BlockID.h5
-rw-r--r--src/Blocks/BlockHandler.cpp9
-rw-r--r--src/Blocks/BlockQuartz.h67
-rw-r--r--src/Blocks/BlockSideways.h (renamed from src/Blocks/BlockWood.h)4
-rw-r--r--src/ChunkMap.cpp2
-rw-r--r--src/Generating/BioGen.cpp10
-rw-r--r--src/Generating/ChunkDesc.cpp4
-rw-r--r--src/Generating/ChunkDesc.h2
-rw-r--r--src/Mobs/SnowGolem.cpp2
-rw-r--r--src/Simulator/FluidSimulator.cpp2
-rw-r--r--src/World.cpp4
-rw-r--r--src/World.h2
17 files changed, 128 insertions, 29 deletions
diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua
index 6b1da7a77..28a17c214 100644
--- a/MCServer/Plugins/InfoDump.lua
+++ b/MCServer/Plugins/InfoDump.lua
@@ -149,7 +149,7 @@ local function GetCommandRefForum(a_Command)
if (type(a_Command) == "string") then
return "[color=blue]" .. a_Command .. "[/color]";
end
- return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. a_Command.Params .. "[/color]";
+ return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. (a_Command.Params or "") .. "[/color]";
end
@@ -169,7 +169,7 @@ local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCo
f:write("The following parameter combinations are recognized:\n");
for idx, combination in ipairs(a_ParameterCombinations) do
- f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color]");
+ f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params or "", "[/color]");
if (combination.Help ~= nil) then
f:write(" - ", ForumizeString(combination.Help));
end
diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp
index 569128a12..c0123c08a 100644
--- a/Tools/BiomeVisualiser/BiomeRenderer.cpp
+++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp
@@ -78,7 +78,7 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
{
for (int i = 0; i < ARRAYCOUNT(CurBiomes); i++)
{
- CurBiomes[i] = (EMCSBiome)-1;
+ CurBiomes[i] = biInvalidBiome;
}
break;
}
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index d49cd8ef3..8dd17c448 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -1066,11 +1066,13 @@ int cLuaState::CallFunctionWithForeignParams(
{
// Something went wrong, fix the stack and exit
lua_pop(m_LuaState, 2);
+ m_NumCurrentFunctionArgs = -1;
+ m_CurrentFunctionName.clear();
return -1;
}
// Call the function, with an error handler:
- int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop);
+ int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1);
if (ReportErrors(s))
{
LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str());
@@ -1081,11 +1083,19 @@ int cLuaState::CallFunctionWithForeignParams(
{
lua_pop(m_LuaState, CurTop - OldTop);
}
- return -1;
+
+ // Reset the internal checking mechanisms:
+ m_NumCurrentFunctionArgs = -1;
+ m_CurrentFunctionName.clear();
+
+ // Make Lua think everything is okay and return 0 values, so that plugins continue executing.
+ // The failure is indicated by the zero return values.
+ return 0;
}
// Reset the internal checking mechanisms:
m_NumCurrentFunctionArgs = -1;
+ m_CurrentFunctionName.clear();
// Remove the error handler from the stack:
lua_remove(m_LuaState, OldTop + 1);
@@ -1152,6 +1162,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
// Copy the value:
void * ud = tolua_touserdata(a_SrcLuaState, i, NULL);
tolua_pushusertype(m_LuaState, ud, type);
+ break;
}
default:
{
diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp
index 89a1cdefb..3fba93e8a 100644
--- a/src/BiomeDef.cpp
+++ b/src/BiomeDef.cpp
@@ -13,8 +13,16 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
int res = atoi(a_BiomeString.c_str());
if ((res != 0) || (a_BiomeString.compare("0") == 0))
{
- // It was a valid number
- return (EMCSBiome)res;
+ if ((res >= biFirstBiome) && (res < biNumBiomes))
+ {
+ return (EMCSBiome)res;
+ }
+ else if ((res >= biFirstVariantBiome) && (res < biNumVariantBiomes))
+ {
+ return (EMCSBiome)res;
+ }
+ // It was an invalid number
+ return biInvalidBiome;
}
// Convert using the built-in map:
@@ -100,7 +108,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
return BiomeMap[i].m_Biome;
}
} // for i - BiomeMap[]
- return (EMCSBiome)-1;
+ return biInvalidBiome;
}
diff --git a/src/BiomeDef.h b/src/BiomeDef.h
index df1e387f0..474d4df76 100644
--- a/src/BiomeDef.h
+++ b/src/BiomeDef.h
@@ -20,6 +20,9 @@ BiomeIDs over 255 are used by MCServer internally and are translated to MC biome
*/
enum EMCSBiome
{
+ biInvalidBiome = -1,
+
+ biFirstBiome = 0,
biOcean = 0,
biPlains = 1,
biDesert = 2,
@@ -74,6 +77,7 @@ enum EMCSBiome
biVariant = 128,
// Release 1.7 biome variants:
+ biFirstVariantBiome = 129,
biSunflowerPlains = 129,
biDesertM = 130,
biExtremeHillsM = 131,
@@ -95,9 +99,12 @@ enum EMCSBiome
biMesaBryce = 165,
biMesaPlateauFM = 166,
biMesaPlateauM = 167,
+ // Automatically capture the maximum consecutive biome value into biVarientMaxBiome:
+ biNumVariantBiomes, // True number of biomes, since they are zero-based
+ biMaxVariantBiome = biNumVariantBiomes - 1, // The maximum biome value
} ;
-/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
+/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure.
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
/// Returns true if the biome has no downfall - deserts and savannas
diff --git a/src/BlockID.h b/src/BlockID.h
index f53440ec8..d5b3da672 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -500,6 +500,11 @@ enum
E_META_PLANKS_BIRCH = 2,
E_META_PLANKS_JUNGLE = 3,
+ // E_BLOCK_QUARTZ_BLOCK metas:
+ E_META_QUARTZ_NORMAL = 0,
+ E_META_QUARTZ_CHISELLED = 1,
+ E_META_QUARTZ_PILLAR = 2,
+
// E_BLOCK_RAIL metas
E_META_RAIL_ZM_ZP = 0,
E_META_RAIL_XM_XP = 1,
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index c16f255b8..657058e3e 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -49,6 +49,7 @@
#include "BlockPlanks.h"
#include "BlockPortal.h"
#include "BlockPumpkin.h"
+#include "BlockQuartz.h"
#include "BlockRail.h"
#include "BlockRedstone.h"
#include "BlockRedstoneLamp.h"
@@ -56,6 +57,7 @@
#include "BlockRedstoneTorch.h"
#include "BlockSand.h"
#include "BlockSapling.h"
+#include "BlockSideways.h"
#include "BlockSign.h"
#include "BlockSlab.h"
#include "BlockSnow.h"
@@ -67,7 +69,6 @@
#include "BlockTorch.h"
#include "BlockTrapdoor.h"
#include "BlockVine.h"
-#include "BlockWood.h"
#include "BlockWorkbench.h"
@@ -144,6 +145,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType);
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
+ case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
@@ -158,14 +160,14 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType);
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
- case E_BLOCK_LOG: return new cBlockWoodHandler (a_BlockType);
+ case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType);
case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType);
case E_BLOCK_NETHER_WART: return new cBlockNetherWartHandler (a_BlockType);
- case E_BLOCK_NEW_LOG: return new cBlockWoodHandler (a_BlockType);
+ case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( );
@@ -174,6 +176,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType);
case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
+ case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartzHandler (a_BlockType);
case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); // We need this to change pickups to an off lamp; else 1.7+ clients crash
diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h
new file mode 100644
index 000000000..a9f8f9046
--- /dev/null
+++ b/src/Blocks/BlockQuartz.h
@@ -0,0 +1,67 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockQuartzHandler : public cBlockHandler
+{
+public:
+ cBlockQuartzHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
+ if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
+ {
+ a_BlockMeta = Meta;
+ return true;
+ }
+
+ a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta);
+ return true;
+ }
+
+ inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_QuartzMeta)
+ {
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ {
+ return a_QuartzMeta; // Top or bottom, just return original
+ }
+
+ case BLOCK_FACE_ZP:
+ case BLOCK_FACE_ZM:
+ {
+ return 0x4; // North or south
+ }
+
+ case BLOCK_FACE_XP:
+ case BLOCK_FACE_XM:
+ {
+ return 0x3; // East or west
+ }
+
+ default:
+ {
+ ASSERT(!"Unhandled block face!");
+ return a_QuartzMeta; // No idea, give a special meta (all sides the same)
+ }
+ }
+ }
+} ; \ No newline at end of file
diff --git a/src/Blocks/BlockWood.h b/src/Blocks/BlockSideways.h
index cf49d0745..f11f0bee1 100644
--- a/src/Blocks/BlockWood.h
+++ b/src/Blocks/BlockSideways.h
@@ -7,10 +7,10 @@
-class cBlockWoodHandler : public cBlockHandler
+class cBlockSidewaysHandler : public cBlockHandler
{
public:
- cBlockWoodHandler(BLOCKTYPE a_BlockType)
+ cBlockSidewaysHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
{
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 1e2181f32..757396a20 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1808,7 +1808,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
if (FinalDamage > a_Entity->GetMaxHealth())
FinalDamage = a_Entity->GetMaxHealth();
else if (FinalDamage < 0)
- return false;
+ FinalDamage = 0;
if (!a_Entity->IsTNT()) // Don't apply damage to other TNT entities, they should be invincible
{
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index f89b1800d..967deba6a 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -97,7 +97,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile)
{
AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains");
m_Biome = StringToBiome(Biome);
- if (m_Biome == -1)
+ if (m_Biome == biInvalidBiome)
{
LOGWARN("[Generator]::ConstantBiome value \"%s\" not recognized, using \"Plains\".", Biome.c_str());
m_Biome = biPlains;
@@ -233,7 +233,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes)
}
}
EMCSBiome Biome = StringToBiome(Split2[0]);
- if (Biome != -1)
+ if (Biome != biInvalidBiome)
{
for (int i = 0; i < Count; i++)
{
@@ -500,7 +500,7 @@ void cBioGenMultiStepMap::DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cC
int OffsetZ = (m_Noise4.IntNoise3DInt(RealCellX, 32 * RealCellX - 16 * RealCellZ, RealCellZ) / 8) % m_OceanCellSize;
SeedX[xc][zc] = CellBlockX + OffsetX;
SeedZ[xc][zc] = CellBlockZ + OffsetZ;
- SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : ((EMCSBiome)(-1));
+ SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (biInvalidBiome);
} // for z
} // for x
@@ -573,7 +573,7 @@ void cBioGenMultiStepMap::AddRivers(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome
float NoiseCoordZ = (float)(a_ChunkZ * cChunkDef::Width + z) / m_RiverCellSize;
for (int x = 0; x < cChunkDef::Width; x++)
{
- if (cChunkDef::GetBiome(a_BiomeMap, x, z) != -1)
+ if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biInvalidBiome)
{
// Biome already set, skip this column
continue;
@@ -693,7 +693,7 @@ void cBioGenMultiStepMap::DecideLandBiomes(cChunkDef::BiomeMap & a_BiomeMap, con
int idxZ = 17 * z;
for (int x = 0; x < cChunkDef::Width; x++)
{
- if (cChunkDef::GetBiome(a_BiomeMap, x, z) != -1)
+ if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biInvalidBiome)
{
// Already set before
continue;
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 87566aa78..d9529b4b0 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -118,9 +118,9 @@ void cChunkDesc::SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_B
-void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, int a_BiomeID)
+void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, EMCSBiome a_BiomeID)
{
- cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, (EMCSBiome)a_BiomeID);
+ cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, a_BiomeID);
}
diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h
index e258383d5..8edc2800b 100644
--- a/src/Generating/ChunkDesc.h
+++ b/src/Generating/ChunkDesc.h
@@ -53,7 +53,7 @@ public:
void SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta);
NIBBLETYPE GetBlockMeta(int a_RelX, int a_RelY, int a_RelZ);
- void SetBiome(int a_RelX, int a_RelZ, int a_BiomeID);
+ void SetBiome(int a_RelX, int a_RelZ, EMCSBiome a_BiomeID);
EMCSBiome GetBiome(int a_RelX, int a_RelZ);
// These operate on the heightmap, so they could get out of sync with the data
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index 06021cca5..c60103055 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -29,7 +29,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (IsBiomeNoDownfall((EMCSBiome) m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) ))
+ if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) ))
{
TakeDamage(*this);
}
diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp
index 72b2eb628..61c93ed73 100644
--- a/src/Simulator/FluidSimulator.cpp
+++ b/src/Simulator/FluidSimulator.cpp
@@ -166,14 +166,12 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
{
LowestPoint = Meta;
X = Pos->x;
- Pos->y; //Remove if no side effects
Z = Pos->z;
}
}else if(BlockID == E_BLOCK_AIR)
{
LowestPoint = 9; //This always dominates
X = Pos->x;
- Pos->y; //Remove if no side effects
Z = Pos->z;
}
diff --git a/src/World.cpp b/src/World.cpp
index 410326b2d..d6c9b293d 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1222,7 +1222,7 @@ void cWorld::GrowTreeByBiome(int a_X, int a_Y, int a_Z)
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
- GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), (EMCSBiome)GetBiomeAt(a_X, a_Z), Logs, Other);
+ GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
GrowTreeImage(Other);
@@ -1475,7 +1475,7 @@ void cWorld::GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBl
-int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
+EMCSBiome cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
{
return m_ChunkMap->GetBiomeAt(a_BlockX, a_BlockZ);
}
diff --git a/src/World.h b/src/World.h
index 33db16614..8cf860ff5 100644
--- a/src/World.h
+++ b/src/World.h
@@ -526,7 +526,7 @@ public:
void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
/** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */
- int GetBiomeAt(int a_BlockX, int a_BlockZ);
+ EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ);
/** Returns the name of the world */
const AString & GetName(void) const { return m_WorldName; }