summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-14 12:45:39 +0200
committermadmaxoft <github@xoft.cz>2013-08-14 12:45:39 +0200
commitb1a892bd9a5e9c2807580b55cb322aa026f80149 (patch)
tree26f8462a6f29e9d12d4baaae9facdc3020b0f7a3
parentMerge pull request #85 from tigerw/master (diff)
downloadcuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.tar
cuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.tar.gz
cuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.tar.bz2
cuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.tar.lz
cuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.tar.xz
cuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.tar.zst
cuberite-b1a892bd9a5e9c2807580b55cb322aa026f80149.zip
-rw-r--r--source/Piston.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/source/Piston.cpp b/source/Piston.cpp
index 161f2b38c..91b1aaa93 100644
--- a/source/Piston.cpp
+++ b/source/Piston.cpp
@@ -12,18 +12,16 @@
#include "Server.h"
#include "Blocks/BlockHandler.h"
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <unistd.h>
-#endif
-//Athar from http://www.cplusplus.com/forum/unices/60161/ helped with the sleep code.
extern bool g_BlockPistonBreakable[];
+
+
+
+
#define AddDir( x, y, z, dir, amount ) \
switch (dir) \
{ \
@@ -128,11 +126,11 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz )
AddDir(extx, exty, extz, pistonMeta & 7, 1)
- #ifdef _WIN32
- Sleep(100);
- #else
- usleep(static_cast<useconds_t>(100)*1000);
- #endif
+ // TODO: This code needs replacing
+ // Sleeping here will play the piston animation on the client; however, it will block the entire server
+ // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad
+ // This needs to be handled using delayed scheduled tasks instead
+ cSleep::MilliSleep(100);
m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta & 7);
}
@@ -178,22 +176,23 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
// These cannot be moved by the sticky piston, bail out
return;
}
- #ifdef _WIN32
- Sleep(100);
- #else
- usleep(static_cast<useconds_t>(100)*1000);
- #endif
+
+ // TODO: This code needs replacing
+ // Sleeping here will play the piston animation on the client; however, it will block the entire server
+ // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad
+ // This needs to be handled using delayed scheduled tasks instead
+ cSleep::MilliSleep(100);
m_World->SetBlock(pistx, pisty, pistz, tempblock, tempmeta);
m_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0);
}
else
{
- #ifdef _WIN32
- Sleep(100);
- #else
- usleep(static_cast<useconds_t>(100)*1000);
- #endif
+ // TODO: This code needs replacing
+ // Sleeping here will play the piston animation on the client; however, it will block the entire server
+ // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad
+ // This needs to be handled using delayed scheduled tasks instead
+ cSleep::MilliSleep(100);
m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0);
}