summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-14 13:03:13 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-14 13:03:13 +0200
commit77468f87b75204ed55147761290bb3450ddb1436 (patch)
treee1ca5f65763b7835d682246a613419277e8f22d1 /source
parentAlpha sorted PistonBreakable list (diff)
parentPartially fixed tonibm19's mess. (diff)
downloadcuberite-77468f87b75204ed55147761290bb3450ddb1436.tar
cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.gz
cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.bz2
cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.lz
cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.xz
cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.zst
cuberite-77468f87b75204ed55147761290bb3450ddb1436.zip
Diffstat (limited to '')
-rw-r--r--source/Piston.cpp15
-rw-r--r--source/Player.cpp51
2 files changed, 49 insertions, 17 deletions
diff --git a/source/Piston.cpp b/source/Piston.cpp
index d75cd4989..8729287de 100644
--- a/source/Piston.cpp
+++ b/source/Piston.cpp
@@ -21,11 +21,14 @@
*/
-//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) \
{ \
@@ -132,6 +135,9 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz )
/*
#ifdef _WIN32
+ // 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
Sleep(100);
#else
usleep(static_cast<useconds_t>(100)*1000);
@@ -184,6 +190,10 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
}
/*
#ifdef _WIN32
+ // 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
Sleep(100);
#else
usleep(static_cast<useconds_t>(100)*1000);
@@ -197,6 +207,9 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
{
/*
#ifdef _WIN32
+ // 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
Sleep(100);
#else
usleep(static_cast<useconds_t>(100)*1000);
diff --git a/source/Player.cpp b/source/Player.cpp
index d9dbf8406..18c4744bb 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -1322,7 +1322,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
-void cPlayer::UseEquippedItem()
+void cPlayer::UseEquippedItem(void)
{
if (GetGameMode() == gmCreative) // No damage in creative
{
@@ -1332,29 +1332,39 @@ void cPlayer::UseEquippedItem()
GetInventory().DamageEquippedItem();
}
+
+
+
+
void cPlayer::SetSwimState(cChunk & a_Chunk)
{
-
+ int RelY = (int)floor(m_LastPosY + 0.1);
+ if ((RelY < 0) || (RelY >= cChunkDef::Height))
+ {
+ m_IsSwimming = false;
+ m_IsSubmerged = false;
+ return;
+ }
+
BLOCKTYPE BlockIn;
int RelX = (int)floor(m_LastPosX) - a_Chunk.GetPosX() * cChunkDef::Width;
- int RelY = (int)floor(m_LastPosY + 0.1);
int RelZ = (int)floor(m_LastPosZ) - a_Chunk.GetPosZ() * cChunkDef::Width;
- // first we check if the player is swimming
-
+ // Check if the player is swimming:
// Use Unbounded, because we're being called *after* processing super::Tick(), which could have changed our chunk
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockIn));
-
m_IsSwimming = IsBlockWater(BlockIn);
- // now we check if the player is submerged
-
- VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY+1, RelZ, BlockIn));
-
+ // Check if the player is submerged:
+ VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY + 1, RelZ, BlockIn));
m_IsSubmerged = IsBlockWater(BlockIn);
}
-void cPlayer::HandleAir()
+
+
+
+
+void cPlayer::HandleAir(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
// see if the player is /submerged/ water (block above is water)
@@ -1363,22 +1373,28 @@ void cPlayer::HandleAir()
if (IsSubmerged())
{
// either reduce air level or damage player
- if(m_AirLevel < 1)
+ if (m_AirLevel < 1)
{
- if(m_AirTickTimer < 1)
+ if (m_AirTickTimer < 1)
{
// damage player
TakeDamage(dtDrowning, NULL, 1, 1, 0);
// reset timer
m_AirTickTimer = DROWNING_TICKS;
- }else{
+ }
+ else
+ {
m_AirTickTimer -= 1;
}
- }else{
+ }
+ else
+ {
// reduce air supply
m_AirLevel -= 1;
}
- }else{
+ }
+ else
+ {
// set the air back to maximum
m_AirLevel = MAX_AIR_LEVEL;
m_AirTickTimer = DROWNING_TICKS;
@@ -1386,6 +1402,9 @@ void cPlayer::HandleAir()
}
+
+
+
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger