summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CONTRIBUTING.md29
-rw-r--r--CONTRIBUTORS4
-rw-r--r--source/BlockID.cpp9
-rw-r--r--source/Blocks/BlockFluid.h6
-rw-r--r--source/Blocks/BlockIce.h2
-rw-r--r--source/Blocks/BlockTorch.h1
-rw-r--r--source/Generating/ComposableGenerator.cpp6
-rw-r--r--source/Piston.cpp26
-rw-r--r--source/Player.cpp51
-rw-r--r--source/World.cpp2
10 files changed, 108 insertions, 28 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..d359f9004
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,29 @@
+Code Stuff
+----------
+
+ * No magic numbers, use named constants:
+ - E_ITEM_XXX, E_BLOCK_XXX and E_META_XXX for items and blocks
+ - E_ENTITY_TYPE_XXX for mob types
+ - dimNether, dimOverworld and dimEnd for world dimension
+ - gmSurvival, gmCreative, gmAdventure for game modes
+ - wSunny, wRain, wThunderstorm for weather
+ - cChunkDef::Width, cChunkDef::Height for chunk dimensions (C++)
+ - etc.
+ * Instead of checking for specific value, use Is functions, if available:
+ - cPlayer:IsGameModeCreative() instead of (cPlayer:GetGameMode() == gmCreative)
+ * Please use tabs for indentation and spaces for alignment. This means that if it's at line start, it's a tab; if it's in the middle of a line, it's a space
+ * Alpha-sort stuff that makes sense alpha-sorting - long lists of similar items etc.
+ * Keep individual functions spaced out by 5 empty lines, this enhances readability and makes navigation in the source file easier.
+ * Add those extra parentheses to conditions, especially in C++
+ - "if ((a == 1) && ((b == 2) || (c == 3)))" instead of ambiguous "if (a == 1 && b == 2 || c == 3)"
+ - This helps prevent mistakes such as "if (a & 1 == 0)"
+ * White space is free, so use it freely
+ - "freely" as in "plentifully", not "arbitrarily"
+
+
+Copyright
+---------
+
+Your work should be licensed under the Apache license, and you should add yourself to the CONTRIBUTORS file.
+
+If your work is not licensed under the Apache license, then it must be compatible and marked as such. Note that only plugins may choose a different license; MC-server's internals need to be single-license.
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index ebb5f37ed..8ac48e880 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -7,5 +7,9 @@ STR_Warrior
mgueydan
tigerw
bearbin
+Lapayo
+rs2k
+Duralex
+mtilden
If you feel you have contributed enough to be included in this list, just put in a PR including yourself.
diff --git a/source/BlockID.cpp b/source/BlockID.cpp
index ad96cfa72..05506777c 100644
--- a/source/BlockID.cpp
+++ b/source/BlockID.cpp
@@ -655,7 +655,7 @@ public:
g_BlockPistonBreakable[E_BLOCK_IRON_DOOR] = true;
g_BlockPistonBreakable[E_BLOCK_JACK_O_LANTERN] = true;
g_BlockPistonBreakable[E_BLOCK_LADDER] = true;
- g_BlockPistonBreakable[E_BLOCK_LAVA] = false;
+ g_BlockPistonBreakable[E_BLOCK_LAVA] = true;
g_BlockPistonBreakable[E_BLOCK_LEVER] = true;
g_BlockPistonBreakable[E_BLOCK_MELON] = true;
g_BlockPistonBreakable[E_BLOCK_MELON_STEM] = true;
@@ -668,18 +668,19 @@ public:
g_BlockPistonBreakable[E_BLOCK_RED_ROSE] = true;
g_BlockPistonBreakable[E_BLOCK_REEDS] = true;
g_BlockPistonBreakable[E_BLOCK_SNOW] = true;
- g_BlockPistonBreakable[E_BLOCK_STATIONARY_LAVA] = false;
- g_BlockPistonBreakable[E_BLOCK_STATIONARY_WATER] = false; //This gave pistons the ability to drop water :D
+ g_BlockPistonBreakable[E_BLOCK_STATIONARY_LAVA] = true;
+ g_BlockPistonBreakable[E_BLOCK_STATIONARY_WATER] = true;
g_BlockPistonBreakable[E_BLOCK_STONE_BUTTON] = true;
g_BlockPistonBreakable[E_BLOCK_STONE_PRESSURE_PLATE] = true;
g_BlockPistonBreakable[E_BLOCK_TALL_GRASS] = true;
g_BlockPistonBreakable[E_BLOCK_TORCH] = true;
g_BlockPistonBreakable[E_BLOCK_VINES] = true;
- g_BlockPistonBreakable[E_BLOCK_WATER] = false;
+ g_BlockPistonBreakable[E_BLOCK_WATER] = true;
g_BlockPistonBreakable[E_BLOCK_WOODEN_DOOR] = true;
g_BlockPistonBreakable[E_BLOCK_WOODEN_PRESSURE_PLATE] = true;
g_BlockPistonBreakable[E_BLOCK_YELLOW_FLOWER] = true;
+
// Blocks that can be snowed over:
g_BlockIsSnowable[E_BLOCK_AIR] = false;
g_BlockIsSnowable[E_BLOCK_BROWN_MUSHROOM] = false;
diff --git a/source/Blocks/BlockFluid.h b/source/Blocks/BlockFluid.h
index 696bfb3ce..0db2f60c4 100644
--- a/source/Blocks/BlockFluid.h
+++ b/source/Blocks/BlockFluid.h
@@ -17,6 +17,12 @@ public:
: cBlockHandler(a_BlockType)
{
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // No pickups
}
diff --git a/source/Blocks/BlockIce.h b/source/Blocks/BlockIce.h
index 11fe425f3..af4961114 100644
--- a/source/Blocks/BlockIce.h
+++ b/source/Blocks/BlockIce.h
@@ -27,7 +27,7 @@ public:
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
// TODO: Ice destroyed with air below it should turn into air instead of water
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STATIONARY_WATER, 8);
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0);
// This is called later than the real destroying of this ice block
}
} ;
diff --git a/source/Blocks/BlockTorch.h b/source/Blocks/BlockTorch.h
index 99c1a7b75..3a50cab77 100644
--- a/source/Blocks/BlockTorch.h
+++ b/source/Blocks/BlockTorch.h
@@ -103,7 +103,6 @@ public:
virtual bool DoesAllowBlockOnTop(void) override
{
return true;
- //was false
}
diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp
index 8763e2809..0852f559e 100644
--- a/source/Generating/ComposableGenerator.cpp
+++ b/source/Generating/ComposableGenerator.cpp
@@ -150,7 +150,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
AString BiomeGenName = a_IniFile.GetValueSet("Generator", "BiomeGen", "");
if (BiomeGenName.empty())
{
- LOGWARN("[Generator]::BiomeGen value not found in world.ini, using \"MultiStepMap\".");
+ LOGWARN("[Generator] BiomeGen value not set in world.ini, using \"MultiStepMap\".");
BiomeGenName = "MultiStepMap";
}
@@ -223,7 +223,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
if (HeightGenName.empty())
{
- LOGWARN("[Generator]::HeightGen value not found in world.ini, using \"Biomal\".");
+ LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\".");
HeightGenName = "Biomal";
}
@@ -309,7 +309,7 @@ void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
if (CompoGenName.empty())
{
- LOGWARN("[Generator]::CompositionGen value not found in world.ini, using \"Biomal\".");
+ LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\".");
CompoGenName = "Biomal";
}
if (NoCaseCompare(CompoGenName, "sameblock") == 0)
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);
}
}
diff --git a/source/Player.cpp b/source/Player.cpp
index a1ea631aa..5a789e285 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -1336,7 +1336,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
-void cPlayer::UseEquippedItem()
+void cPlayer::UseEquippedItem(void)
{
if (GetGameMode() == gmCreative) // No damage in creative
{
@@ -1346,29 +1346,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)
@@ -1377,22 +1387,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;
@@ -1400,6 +1416,9 @@ void cPlayer::HandleAir()
}
+
+
+
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
diff --git a/source/World.cpp b/source/World.cpp
index 4cc130811..0b74adec1 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -2639,7 +2639,7 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c
AString SimulatorName = a_IniFile.GetValueSet("Physics", SimulatorNameKey, "");
if (SimulatorName.empty())
{
- LOGWARNING("%s [Physics]:%s not present or empty, using the default of \"Floody\".", GetIniFileName().c_str(), SimulatorNameKey.c_str());
+ LOGWARNING("[Physics] %s not present or empty in %s, using the default of \"Floody\".", SimulatorNameKey.c_str(), GetIniFileName().c_str());
SimulatorName = "Floody";
}