diff options
Diffstat (limited to '')
-rw-r--r-- | source/Piston.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/source/Piston.cpp b/source/Piston.cpp index d179d70b6..310fcdfd4 100644 --- a/source/Piston.cpp +++ b/source/Piston.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Piston.h" @@ -18,6 +17,10 @@ extern bool g_BlockPistonBreakable[]; + + + + #define AddDir( x, y, z, dir, amount ) \ switch (dir) \ { \ @@ -122,6 +125,12 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) AddDir(extx, exty, extz, pistonMeta & 7, 1) + // 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); } @@ -142,7 +151,7 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz ) m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), E_BLOCK_PISTON); m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); m_World->FastSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8)); - + AddDir(pistx, pisty, pistz, pistonMeta & 7, 1) if (m_World->GetBlock(pistx, pisty, pistz) != E_BLOCK_PISTON_EXTENSION) { @@ -166,11 +175,24 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz ) // These cannot be moved by the sticky piston, bail out return; } + + // 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 { + // 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); } } |