summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-09-22 21:31:53 +0200
committerMattes D <github@xoft.cz>2013-09-22 21:31:53 +0200
commit63c627f68fbfe7b97fb04f0a40b44423cd12c366 (patch)
tree3f52eb0bc26015e90492d4cabdb3150984fb94b3
parentAdded a simple valgrind script for easier testing. (diff)
parentRemoved some unneeded includes (diff)
downloadcuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.tar
cuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.tar.gz
cuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.tar.bz2
cuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.tar.lz
cuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.tar.xz
cuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.tar.zst
cuberite-63c627f68fbfe7b97fb04f0a40b44423cd12c366.zip
Diffstat (limited to '')
-rw-r--r--VC2008/MCServer.vcproj8
-rw-r--r--source/Blocks/BlockButton.cpp39
-rw-r--r--source/Blocks/BlockButton.h69
-rw-r--r--source/Blocks/BlockComparator.cpp13
-rw-r--r--source/Blocks/BlockComparator.h2
-rw-r--r--source/Blocks/BlockHandler.cpp3
-rw-r--r--source/Blocks/BlockLever.cpp14
-rw-r--r--source/Blocks/BlockLever.h2
-rw-r--r--source/Blocks/BlockRedstoneRepeater.cpp13
-rw-r--r--source/Blocks/BlockRedstoneRepeater.h2
-rw-r--r--source/Blocks/BlockStairs.h1
-rw-r--r--source/ClientHandle.cpp2
-rw-r--r--source/Entities/Boat.h1
-rw-r--r--source/Entities/Minecart.h1
-rw-r--r--source/Piston.cpp2
15 files changed, 125 insertions, 47 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index ace82b010..c1c2593bf 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -2052,6 +2052,14 @@
>
</File>
<File
+ RelativePath="..\source\Blocks\BlockButton.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockButton.h"
+ >
+ </File>
+ <File
RelativePath="..\source\blocks\BlockCactus.h"
>
</File>
diff --git a/source/Blocks/BlockButton.cpp b/source/Blocks/BlockButton.cpp
new file mode 100644
index 000000000..1011f9351
--- /dev/null
+++ b/source/Blocks/BlockButton.cpp
@@ -0,0 +1,39 @@
+
+#include "Globals.h"
+#include "BlockButton.h"
+
+
+
+
+
+cBlockButtonHandler::cBlockButtonHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+{
+}
+
+
+
+
+
+void cBlockButtonHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+{
+ // Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off.
+ NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f);
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+
+ if (Meta & 0x08)
+ {
+ a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
+ }
+ else
+ {
+ a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.5f);
+ }
+
+ // Queue a button reset (unpress), with a GetBlock to prevent duplication of buttons (press, break, wait for reset)
+ a_World->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ), ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 25);
+}
+
+
+
+
diff --git a/source/Blocks/BlockButton.h b/source/Blocks/BlockButton.h
new file mode 100644
index 000000000..e3f655bfa
--- /dev/null
+++ b/source/Blocks/BlockButton.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockButtonHandler :
+ public cBlockHandler
+{
+public:
+ cBlockButtonHandler(BLOCKTYPE a_BlockType);
+
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(m_BlockType == E_BLOCK_WOODEN_BUTTON ? E_BLOCK_WOODEN_BUTTON : E_BLOCK_STONE_BUTTON, 1, 0));
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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;
+ a_BlockMeta = BlockFaceToMetaData(a_BlockFace);
+ return true;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return m_BlockType == E_BLOCK_WOODEN_BUTTON ? "step.wood" : "step.stone";
+ }
+
+
+ inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace)
+ {
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_ZP: { return 0x4; }
+ case BLOCK_FACE_ZM: { return 0x3; }
+ case BLOCK_FACE_XP: { return 0x2; }
+ case BLOCK_FACE_XM: { return 0x1; }
+ default:
+ {
+ ASSERT(!"Unhandled block face!");
+ return 0x0; // No idea, give a special meta (button in centre of block)
+ }
+ }
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockComparator.cpp b/source/Blocks/BlockComparator.cpp
index e6fa64e2c..b4e5a55d0 100644
--- a/source/Blocks/BlockComparator.cpp
+++ b/source/Blocks/BlockComparator.cpp
@@ -1,8 +1,6 @@
#include "Globals.h"
#include "BlockComparator.h"
-#include "../Item.h"
-#include "../World.h"
#include "../Simulator/RedstoneSimulator.h"
#include "../Entities/Player.h"
@@ -32,16 +30,7 @@ void cBlockComparatorHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_Bl
{
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
-}
-
-
-
-
-
-void cBlockComparatorHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}
diff --git a/source/Blocks/BlockComparator.h b/source/Blocks/BlockComparator.h
index 208727107..cb2941d3c 100644
--- a/source/Blocks/BlockComparator.h
+++ b/source/Blocks/BlockComparator.h
@@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
-#include "../World.h"
@@ -15,7 +14,6 @@ public:
cBlockComparatorHandler(BLOCKTYPE a_BlockType);
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp
index b06171119..e59fee8ee 100644
--- a/source/Blocks/BlockHandler.cpp
+++ b/source/Blocks/BlockHandler.cpp
@@ -7,6 +7,7 @@
#include "../PluginManager.h"
#include "BlockBed.h"
#include "BlockBrewingStand.h"
+#include "BlockButton.h"
#include "BlockCactus.h"
#include "BlockCarpet.h"
#include "BlockCauldron.h"
@@ -185,6 +186,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_STICKY_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_STONE: return new cBlockStoneHandler (a_BlockType);
case E_BLOCK_STONE_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_STONE_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_SUGARCANE: return new cBlockSugarcaneHandler (a_BlockType);
case E_BLOCK_TALL_GRASS: return new cBlockTallGrassHandler (a_BlockType);
@@ -192,6 +194,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType);
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
+ case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);
case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_WOODEN_STAIRS: return new cBlockStairsHandler (a_BlockType);
diff --git a/source/Blocks/BlockLever.cpp b/source/Blocks/BlockLever.cpp
index f2ca1805a..a9bd6c990 100644
--- a/source/Blocks/BlockLever.cpp
+++ b/source/Blocks/BlockLever.cpp
@@ -1,8 +1,6 @@
#include "Globals.h"
#include "BlockLever.h"
-#include "../Item.h"
-#include "../World.h"
#include "../Entities/Player.h"
#include "../Simulator/RedstoneSimulator.h"
@@ -23,7 +21,8 @@ void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX,
{
// Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off.
NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
+
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
if (Meta & 0x08)
{
a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
@@ -37,12 +36,3 @@ void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX,
-
-void cBlockLeverHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
-}
-
-
-
-
diff --git a/source/Blocks/BlockLever.h b/source/Blocks/BlockLever.h
index ddf48297c..5553170e2 100644
--- a/source/Blocks/BlockLever.h
+++ b/source/Blocks/BlockLever.h
@@ -1,7 +1,6 @@
#pragma once
#include "BlockHandler.h"
-#include "../World.h"
#include "../Simulator/RedstoneSimulator.h"
@@ -14,7 +13,6 @@ class cBlockLeverHandler :
public:
cBlockLeverHandler(BLOCKTYPE a_BlockType);
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
diff --git a/source/Blocks/BlockRedstoneRepeater.cpp b/source/Blocks/BlockRedstoneRepeater.cpp
index 5e491ee5a..72ea21012 100644
--- a/source/Blocks/BlockRedstoneRepeater.cpp
+++ b/source/Blocks/BlockRedstoneRepeater.cpp
@@ -1,8 +1,6 @@
#include "Globals.h"
#include "BlockRedstoneRepeater.h"
-#include "../Item.h"
-#include "../World.h"
#include "../Simulator/RedstoneSimulator.h"
#include "../Entities/Player.h"
@@ -30,16 +28,7 @@ void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_BlockX, i
void cBlockRedstoneRepeaterHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
-}
-
-
-
-
-
-void cBlockRedstoneRepeaterHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
}
diff --git a/source/Blocks/BlockRedstoneRepeater.h b/source/Blocks/BlockRedstoneRepeater.h
index 21f227332..958841a34 100644
--- a/source/Blocks/BlockRedstoneRepeater.h
+++ b/source/Blocks/BlockRedstoneRepeater.h
@@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
-#include "../World.h"
@@ -15,7 +14,6 @@ public:
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType);
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
diff --git a/source/Blocks/BlockStairs.h b/source/Blocks/BlockStairs.h
index 485ebda1a..8d259eee3 100644
--- a/source/Blocks/BlockStairs.h
+++ b/source/Blocks/BlockStairs.h
@@ -53,7 +53,6 @@ public:
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 90 + 45; // So its not aligned with axis
- NIBBLETYPE result = 0x0;
if (a_Rotation > 360)
{
a_Rotation -= 360;
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 9ae6095b6..f67a546fd 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -1918,7 +1918,7 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
-void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleTypeType is specific to Minecarts
+void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts
{
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType);
}
diff --git a/source/Entities/Boat.h b/source/Entities/Boat.h
index 734ebda83..8c51ab86c 100644
--- a/source/Entities/Boat.h
+++ b/source/Entities/Boat.h
@@ -10,7 +10,6 @@
#pragma once
#include "Entity.h"
-#include "../Item.h"
diff --git a/source/Entities/Minecart.h b/source/Entities/Minecart.h
index 0ca6586db..0152f5dfc 100644
--- a/source/Entities/Minecart.h
+++ b/source/Entities/Minecart.h
@@ -10,7 +10,6 @@
#pragma once
#include "Entity.h"
-#include "../Item.h"
diff --git a/source/Piston.cpp b/source/Piston.cpp
index b5fda1600..136100922 100644
--- a/source/Piston.cpp
+++ b/source/Piston.cpp
@@ -21,7 +21,7 @@ extern bool g_BlockPistonBreakable[];
/// Number of ticks that the piston extending / retracting waits before setting the block
-const int PISTON_TICK_DELAY = 10;
+const int PISTON_TICK_DELAY = 20;