summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
m---------MCServer/Plugins/MagicCarpet0
-rw-r--r--MCServer/crafting.txt2
-rw-r--r--SetFlags.cmake10
-rw-r--r--src/Bindings/ManualBindings.h10
-rw-r--r--src/ClientHandle.cpp3
-rw-r--r--src/CraftingRecipes.cpp3
-rw-r--r--src/Generating/FinishGen.cpp6
-rw-r--r--src/Mobs/Creeper.cpp2
-rw-r--r--src/Mobs/Guardian.cpp3
-rw-r--r--src/Mobs/Path.cpp25
-rw-r--r--src/Mobs/Squid.cpp3
-rw-r--r--src/OSSupport/StackTrace.cpp9
-rw-r--r--src/StringUtils.h6
14 files changed, 58 insertions, 25 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 4a6850a2f..3505d7155 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -12,6 +12,7 @@ jasperarmstrong
keyboard
Lapayo
Luksor
+linnemannr (Reid Linnemann)
M10360
marmot21
Masy98
diff --git a/MCServer/Plugins/MagicCarpet b/MCServer/Plugins/MagicCarpet
-Subproject 493f2dfa6d39f134e37c4c614cf8d6ffd10c825
+Subproject 94da343b62f0498a5843247f36d6ee00cbeb8f2
diff --git a/MCServer/crafting.txt b/MCServer/crafting.txt
index daac9e098..050186f66 100644
--- a/MCServer/crafting.txt
+++ b/MCServer/crafting.txt
@@ -303,7 +303,7 @@ Dispenser = Cobblestone, 1:1, 1:2, 1:3, 2:1, 3:1, 3:2, 3:3 | Redston
Dropper = Cobblestone, 1:1, 2:1, 3:1, 1:2, 1:3, 3:2, 3:3 | Hopper, 2:2 | RedstoneDust, 2:3
Repeater = Stone, 1:2, 2:2, 3:2 | RedstoneTorchOn, 1:1, 3:1 | RedstoneDust, 2:1
Comparator = RedstoneTorchOn, 2:1, 1:2, 3:2 | NetherQuartz, 2:2 | Stone, 1:3, 2:3, 3:3
-DaylightSensor = Glass, 1:1, 2:1, 3:1 | NetherQuartz, 1:2, 2:2, 3:2 | Woodslab, 1:3, 2:3, 3:3
+DaylightSensor = Glass, 1:1, 2:1, 3:1 | NetherQuartz, 1:2, 2:2, 3:2 | WoodenSlab^-1, 1:3, 2:3, 3:3
Hopper = IronIngot, 1:1, 3:1, 1:2, 3:2, 2:3 | Chest, 2:2
Piston = Planks^-1, 1:1, 2:1, 3:1 | RedstoneDust, 2:3 | Cobblestone, 1:2, 3:2, 1:3, 3:3 | IronIngot, 2:2
StickyPiston = Piston, * | SlimeBall, *
diff --git a/SetFlags.cmake b/SetFlags.cmake
index e336bd6c8..b79551eef 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -16,14 +16,8 @@ macro (add_flags_lnk FLAGS)
endmacro()
macro(add_flags_cxx FLAGS)
- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
- #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAGS}")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAGS}")
- set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} ${FLAGS}")
- set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} ${FLAGS}")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${FLAGS}")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
endmacro()
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index 83b960058..f8c9b96de 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -253,8 +253,9 @@ public:
// Check params:
cLuaState L(tolua_S);
if (
- !L.CheckParamNumber(2, 5) ||
- !L.CheckParamFunction(6)
+ !L.CheckParamNumber(2, 4) ||
+ !L.CheckParamFunction(5) ||
+ !L.CheckParamEnd(6)
)
{
return 0;
@@ -316,8 +317,9 @@ public:
// Check params:
cLuaState L(tolua_S);
if (
- !L.CheckParamNumber(2, 4) ||
- !L.CheckParamFunction(5)
+ !L.CheckParamNumber(2, 3) ||
+ !L.CheckParamFunction(4) ||
+ !L.CheckParamEnd(5)
)
{
return 0;
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 9cba5619d..e3f63b091 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2181,11 +2181,12 @@ void cClientHandle::SendDestroyEntity(const cEntity & a_Entity)
void cClientHandle::SendDisconnect(const AString & a_Reason)
{
+ // Destruction (Destroy()) is called when the client disconnects, not when a disconnect packet (or anything else) is sent
+ // Otherwise, the cClientHandle instance is can be unexpectedly removed from the associated player - Core/#142
if (!m_HasSentDC)
{
LOGD("Sending a DC: \"%s\"", StripColorCodes(a_Reason).c_str());
m_Protocol->SendDisconnect(a_Reason);
- Destroy();
m_HasSentDC = true;
}
}
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index 755b152b0..a95ac5f84 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -771,9 +771,12 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
continue;
}
Recipe->m_Ingredients.push_back(*itrS);
+ Recipe->m_Ingredients.back().x += a_OffsetX;
+ Recipe->m_Ingredients.back().y += a_OffsetY;
}
Recipe->m_Ingredients.insert(Recipe->m_Ingredients.end(), MatchedSlots.begin(), MatchedSlots.end());
+ // Handle the fireworks-related effects:
// We use Recipe instead of a_Recipe because we want the wildcard ingredients' slot numbers as well, which was just added previously
HandleFireworks(a_CraftingGrid, Recipe.get(), a_GridStride, a_OffsetX, a_OffsetY);
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 5540f80d4..59af0fd63 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -1375,8 +1375,12 @@ eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
return mtInvalidType;
}
- size_t RandMob = static_cast<size_t>((m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)) % ListOfSpawnables.size();
auto MobIter = ListOfSpawnables.begin();
+ using diff_type =
+ std::iterator_traits<decltype(MobIter)>::difference_type;
+ diff_type RandMob = static_cast<diff_type>
+ (static_cast<size_t>(m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)
+ % ListOfSpawnables.size());
std::advance(MobIter, RandMob);
return *MobIter;
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index ef3245894..30bd41f13 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -27,7 +27,7 @@ void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (!ReachedFinalDestination() && !m_BurnedWithFlintAndSteel)
+ if (!TargetIsInRange() && !m_BurnedWithFlintAndSteel)
{
m_ExplodingTimer = 0;
m_bIsBlowing = false;
diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp
index cfe7861a6..1429e2b13 100644
--- a/src/Mobs/Guardian.cpp
+++ b/src/Mobs/Guardian.cpp
@@ -37,9 +37,10 @@ void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ m_IsFollowingPath = false; // Disable Pathfinding until it's fixed. TODO
+
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)
-
Vector3d Pos = GetPosition();
// TODO: Not a real behavior, but cool :D
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index 1848e144e..e987381f7 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -157,8 +157,14 @@ bool cPath::IsSolid(const Vector3i & a_Location)
int RelZ = a_Location.z - m_Chunk->GetPosZ() * cChunkDef::Width;
m_Chunk->GetBlockTypeMeta(RelX, a_Location.y, RelZ, BlockType, BlockMeta);
- if ((BlockType == E_BLOCK_FENCE) || (BlockType == E_BLOCK_FENCE_GATE))
+ if (
+ (BlockType == E_BLOCK_FENCE) ||
+ (BlockType == E_BLOCK_FENCE_GATE) ||
+ (BlockType == E_BLOCK_NETHER_BRICK_FENCE) ||
+ ((BlockType >= E_BLOCK_SPRUCE_FENCE_GATE) && (BlockType <= E_BLOCK_ACACIA_FENCE))
+ )
{
+ // TODO move this out of IsSolid to a proper place.
GetCell(a_Location + Vector3i(0, 1, 0))->m_IsSolid = true; // Mobs will always think that the fence is 2 blocks high and therefore won't jump over.
}
if (BlockType == E_BLOCK_STATIONARY_WATER)
@@ -216,28 +222,35 @@ bool cPath::Step_Internal()
ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, 0, -1), CurrentCell, 10);
// Check diagonals on XY plane.
+ // x = -1: west, x = 1: east.
for (int x = -1; x <= 1; x += 2)
{
if (GetCell(CurrentCell->m_Location + Vector3i(x, 0, 0))->m_IsSolid) // If there's a solid our east / west.
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, 1, 0), CurrentCell, JUMP_G_COST); // Check east / west-up.
+ if (!GetCell(CurrentCell->m_Location + Vector3i(0, 1, 0))->m_IsSolid) // If there isn't a solid above.
+ {
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, 1, 0), CurrentCell, JUMP_G_COST); // Check east-up / west-up.
+ }
}
else
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, -1, 0), CurrentCell, 14); // Else check east / west-down.
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, -1, 0), CurrentCell, 14); // Else check east-down / west-down.
}
}
// Check diagonals on the YZ plane.
for (int z = -1; z <= 1; z += 2)
{
- if (GetCell(CurrentCell->m_Location + Vector3i(0, 0, z))->m_IsSolid) // If there's a solid our east / west.
+ if (GetCell(CurrentCell->m_Location + Vector3i(0, 0, z))->m_IsSolid) // If there's a solid our north / south.
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, 1, z), CurrentCell, JUMP_G_COST); // Check east / west-up.
+ if (!GetCell(CurrentCell->m_Location + Vector3i(0, 1, 0))->m_IsSolid) // If there isn't a solid above.
+ {
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, 1, z), CurrentCell, JUMP_G_COST); // Check north-up / south-up.
+ }
}
else
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, -1, z), CurrentCell, 14); // Else check east / west-down.
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, -1, z), CurrentCell, 14); // Else check north-down / south-down.
}
}
diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp
index d148d65f3..30fbfa1ff 100644
--- a/src/Mobs/Squid.cpp
+++ b/src/Mobs/Squid.cpp
@@ -35,9 +35,10 @@ void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ m_IsFollowingPath = false; // Disable Pathfinding until it's fixed. TODO
+
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)
-
Vector3d Pos = GetPosition();
// TODO: Not a real behavior, but cool :D
diff --git a/src/OSSupport/StackTrace.cpp b/src/OSSupport/StackTrace.cpp
index 015a53ba0..1ec10f20e 100644
--- a/src/OSSupport/StackTrace.cpp
+++ b/src/OSSupport/StackTrace.cpp
@@ -12,6 +12,13 @@
#include <unistd.h>
#endif
+// FreeBSD uses size_t for the return type of backtrace()
+#if defined(__FreeBSD__) && (__FreeBSD__ >= 10)
+ #define btsize size_t
+#else
+ #define btsize int
+#endif
+
@@ -34,7 +41,7 @@ void PrintStackTrace(void)
// Use the backtrace() function to get and output the stackTrace:
// Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes
void * stackTrace[30];
- int numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace));
+ btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace));
backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO);
#endif
}
diff --git a/src/StringUtils.h b/src/StringUtils.h
index 8f67d8031..62767d007 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -168,6 +168,12 @@ bool StringToInteger(const AString & a_str, T & a_Num)
}
else
{
+ // Unsigned result cannot be signed!
+ if (!std::numeric_limits<T>::is_signed)
+ {
+ return false;
+ }
+
for (size_t size = a_str.size(); i < size; i++)
{
if ((a_str[i] < '0') || (a_str[i] > '9'))