summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-13 18:41:50 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-13 18:41:50 +0200
commitdd6450c2a9a521a30873a933f847f93a0704ac3d (patch)
tree8f16fe851cc72afab33ea7c3ded1296b9bb2b966 /source
parentAttempt two (diff)
downloadcuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.tar
cuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.tar.gz
cuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.tar.bz2
cuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.tar.lz
cuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.tar.xz
cuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.tar.zst
cuberite-dd6450c2a9a521a30873a933f847f93a0704ac3d.zip
Diffstat (limited to 'source')
-rw-r--r--source/Piston.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/source/Piston.cpp b/source/Piston.cpp
index 569ef02e3..0d436924c 100644
--- a/source/Piston.cpp
+++ b/source/Piston.cpp
@@ -12,7 +12,11 @@
#include "Server.h"
#include "Blocks/BlockHandler.h"
-
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
@@ -122,12 +126,10 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz )
AddDir(extx, exty, extz, pistonMeta & 7, 1)
- #ifdef _WIN32 // Pause for 0.1 seconds to allow client animation to run
- #include <windows.h>
- Sleep(100);
+ #ifdef __WIN32__
+ Sleep(100);
#else
- #include <unistd.h>
- sleep(0.1);
+ usleep(static_cast<useconds_t>(100)*1000); //or use nanosleep on platforms where it's needed
#endif
m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta & 7);
@@ -174,12 +176,10 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
// These cannot be moved by the sticky piston, bail out
return;
}
- #ifdef _WIN32
- #include <windows.h>
- Sleep(100);
+ #ifdef __WIN32__
+ Sleep(100);
#else
- #include <unistd.h>
- sleep(0.1);
+ usleep(static_cast<useconds_t>(100)*1000); //or use nanosleep on platforms where it's needed
#endif
m_World->SetBlock(pistx, pisty, pistz, tempblock, tempmeta);
@@ -187,12 +187,10 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
}
else
{
- #ifdef _WIN32
- #include <windows.h>
- Sleep(100);
+ #ifdef __WIN32__
+ Sleep(100);
#else
- #include <unistd.h>
- sleep(0.1);
+ usleep(static_cast<useconds_t>(100)*1000); //or use nanosleep on platforms where it's needed
#endif
m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0);