summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt34
-rw-r--r--CONTRIBUTORS1
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua10
-rw-r--r--MCServer/Plugins/APIDump/main.css2
-rw-r--r--MCServer/Plugins/APIDump/main_APIDump.lua32
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua111
-rw-r--r--MCServer/Plugins/Debuggers/Info.lua6
-rw-r--r--src/Bindings/ManualBindings.cpp58
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp42
-rw-r--r--src/BlockEntities/FurnaceEntity.h8
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/LineBlockTracer.cpp19
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp5
13 files changed, 290 insertions, 39 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3af054ed..d03690865 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ if(DEFINED ENV{TRAVIS_BUILD_WITH_COVERAGE})
endif()
if(DEFINED ENV{MCSERVER_BUILD_ID})
+ # The build info is defined by the build system (Travis / Jenkins)
set(BUILD_ID $ENV{MCSERVER_BUILD_ID})
set(BUILD_SERIES_NAME $ENV{MCSERVER_BUILD_SERIES_NAME})
set(BUILD_DATETIME $ENV{MCSERVER_BUILD_DATETIME})
@@ -34,12 +35,41 @@ if(DEFINED ENV{MCSERVER_BUILD_ID})
execute_process(
COMMAND git rev-parse HEAD
RESULT_VARIABLE GIT_EXECUTED
- OUTPUT_VARIABLE BUILD_COMMIT_ID)
- string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID)
+ OUTPUT_VARIABLE BUILD_COMMIT_ID
+ )
+ string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID)
if (NOT (GIT_EXECUTED EQUAL 0))
message(FATAL_ERROR "Could not identifiy git commit id")
endif()
endif()
+else()
+ # This is a local build, stuff in some basic info:
+ set(BUILD_ID "Unknown")
+ set(BUILD_SERIES_NAME "local build")
+ execute_process(
+ COMMAND git rev-parse HEAD
+ RESULT_VARIABLE GIT_EXECUTED
+ OUTPUT_VARIABLE BUILD_COMMIT_ID
+ )
+ if (NOT(GIT_EXECUTED EQUAL 0))
+ set(BUILD_COMMIT_ID "Unknown")
+ endif()
+ string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID)
+ execute_process(
+ COMMAND git log -1 --date=iso --pretty=format:%ai
+ RESULT_VARIABLE GIT_EXECUTED
+ OUTPUT_VARIABLE BUILD_DATETIME
+ )
+ if (NOT(GIT_EXECUTED EQUAL 0))
+ set(BUILD_DATETIME "Unknown")
+ endif()
+ string(STRIP ${BUILD_DATETIME} BUILD_DATETIME)
+
+ # The BUILD_COMMIT_ID and BUILD_DATETIME aren't updated on each repo pull
+ # They are only updated when cmake re-configures the project
+ # Therefore mark them as "approx: "
+ set(BUILD_COMMIT_ID "approx: ${BUILD_COMMIT_ID}")
+ set(BUILD_DATETIME "approx: ${BUILD_DATETIME}")
endif()
# We need C++11 features, Visual Studio has those from VS2012, but it needs a new platform toolset for those; VS2013 supports them natively:
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index b7ecd45a3..82ae6a7a8 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -8,6 +8,7 @@ derouinw
Diusrex
Duralex
FakeTruth (founder)
+HaoTNN
Howaner
jan64
jasperarmstrong
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 161fe59d1..ba3c8b332 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2038,7 +2038,7 @@ a_Player:OpenWindow(Window);
BroadcastChat =
{
{ Params = "MessageText, MessageType", Return = "", Notes = "Broadcasts a message to all players, with its message type set to MessageType (default: mtCustom)." },
- { Params = "{{cCompositeChat|CompositeChat}}", Return = "", Notes = "Broadcasts a {{cCompositeChat|composite chat message} to all players." },
+ { Params = "{{cCompositeChat|CompositeChat}}", Return = "", Notes = "Broadcasts a {{cCompositeChat|composite chat message}} to all players." },
},
BroadcastChatDeath = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtDeath. Use for when a player has died." },
BroadcastChatFailure = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtFailure. Use for a command that failed to run because of insufficient permissions, etc." },
@@ -2048,12 +2048,16 @@ a_Player:OpenWindow(Window);
BroadcastChatLeave = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtLeave. Use for players leaving the server." },
BroadcastChatSuccess = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtSuccess. Use for success messages." },
BroadcastChatWarning = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtWarning. Use for concerning events, such as plugin reload etc." },
- CreateAndInitializeWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Creates a new world and initializes it. If there is a world whith the same name it returns nil.<br><br><b>NOTE</b>This function is currently unsafe, do not use!" },
+ CreateAndInitializeWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Creates a new world and initializes it. If there is a world whith the same name it returns nil.<br><br><b>NOTE:</b> This function is currently unsafe, do not use!" },
FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "bool", Notes = "Calls the given callback function for the player with the name best matching the name string provided.<br>This function is case-insensitive and will match partial names.<br>Returns false if player not found or there is ambiguity, true otherwise. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}})</pre>" },
DoWithPlayerByUUID = { Params = "PlayerUUID, CallbackFunction", Return = "bool", Notes = "If there is the player with the uuid, calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}})</pre> The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." },
ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|cPlayer}})</pre>" },
ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cWorld|cWorld}})</pre>" },
- Get = { Params = "", Return = "Root object", Notes = "(STATIC)This function returns the cRoot object." },
+ Get = { Params = "", Return = "Root object", Notes = "(STATIC) This function returns the cRoot object." },
+ GetBuildCommitID = { Params = "", Return = "string", Notes = "(STATIC) For official builds (Travis CI / Jenkins) it returns the exact commit hash used for the build. For unofficial local builds, returns the approximate commit hash (since the true one cannot be determined), formatted as \"approx: &lt;CommitHash&gt;\"." },
+ GetBuildDateTime = { Params = "", Return = "string", Notes = "(STATIC) For official builds (Travic CI / Jenkins) it returns the date and time of the build. For unofficial local builds, returns the approximate datetime of the commit (since the true one cannot be determined), formatted as \"approx: &lt;DateTime-iso8601&gt;\"." },
+ GetBuildID = { Params = "", Return = "string", Notes = "(STATIC) For official builds (Travis CI / Jenkins) it returns the unique ID of the build, as recognized by the build system. For unofficial local builds, returns the string \"Unknown\"." },
+ GetBuildSeriesName = { Params = "", Return = "string", Notes = "(STATIC) For official builds (Travis CI / Jenkins) it returns the series name of the build (for example \"MCServer Windows x64 Master\"). For unofficial local builds, returns the string \"local build\"." },
GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" },
GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." },
GetFurnaceFuelBurnTime = { Params = "{{cItem|Fuel}}", Return = "number", Notes = "(STATIC) Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel." },
diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css
index 8041e0d01..e5685caab 100644
--- a/MCServer/Plugins/APIDump/main.css
+++ b/MCServer/Plugins/APIDump/main.css
@@ -61,7 +61,7 @@ footer
font-family: Segoe UI Light, Helvetica;
}
-#content
+#content, #timestamp
{
padding: 0px 25px 25px 25px;
}
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua
index e841922b6..543a299af 100644
--- a/MCServer/Plugins/APIDump/main_APIDump.lua
+++ b/MCServer/Plugins/APIDump/main_APIDump.lua
@@ -153,6 +153,19 @@ end
+--- Returns the timestamp in HTML format
+-- The timestamp will be inserted to all generated HTML files
+local function GetHtmlTimestamp()
+ return string.format("<div id='timestamp'>Generated on %s, Build ID %s, Commit %s</div>",
+ os.date("%Y-%m-%d %H:%M:%S"),
+ cRoot:GetBuildID(), cRoot:GetBuildCommitID()
+ )
+end
+
+
+
+
+
local function WriteArticles(f)
f:write([[
<a name="articles"><h2>Articles</h2></a>
@@ -296,7 +309,9 @@ local function WriteHtmlHook(a_Hook, a_HookNav)
f:write("<p>", (example.Desc or "<i>missing Desc</i>"), "</p>\n");
f:write("<pre class=\"prettyprint lang-lua\">", (example.Code or "<i>missing Code</i>"), "\n</pre>\n\n");
end
- f:write([[</td></tr></table></div><script>prettyPrint();</script></body></html>]]);
+ f:write([[</td></tr></table></div><script>prettyPrint();</script>]])
+ f:write(GetHtmlTimestamp())
+ f:write([[</body></html>]])
f:close();
end
@@ -941,8 +956,10 @@ local function WriteHtmlClass(a_ClassAPI, a_ClassMenu)
end
end
- cf:write([[</td></tr></table></div><script>prettyPrint();</script></body></html>]]);
- cf:close();
+ cf:write([[</td></tr></table></div><script>prettyPrint();</script>]])
+ cf:write(GetHtmlTimestamp())
+ cf:write([[</body></html>]])
+ cf:close()
end
@@ -1320,11 +1337,10 @@ local function DumpAPIHtml(a_API)
WriteStats(f);
- f:write([[ </ul>
- </div>
- </body>
-</html>]]);
- f:close();
+ f:write([[</ul></div>]])
+ f:write(GetHtmlTimestamp())
+ f:write([[</body></html>]])
+ f:close()
LOG("API subfolder written");
end
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index a49f8b5a6..bd0b94a06 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -1880,6 +1880,117 @@ end
+--- Returns the square of the distance from the specified point to the specified line
+local function SqDistPtFromLine(x, y, x1, y1, x2, y2)
+ local dx = x - x1
+ local dy = y - y1
+ local px = x2 - x1
+ local py = y2 - y1
+ local ss = px * dx + py * dy
+ local ds = px * px + py * py
+
+ if (ss < 0) then
+ -- Return sqdistance from point 1
+ return dx * dx + dy * dy
+ end
+ if (ss > ds) then
+ -- Return sqdistance from point 2
+ return ((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y))
+ end
+
+ -- Return sqdistance from the line
+ if ((px * px + py * py) == 0) then
+ return dx * dx + dy * dy
+ else
+ return (py * dx - px * dy) * (py * dx - px * dy) / (px * px + py * py)
+ end
+end
+
+
+
+
+
+function HandleConsoleTestTracer(a_Split, a_EntireCmd)
+ -- Check required params:
+ if not(a_Split[7]) then
+ return true, "Usage: " .. a_Split[1] .. " <x1> <y1> <z1> <x2> <y2> <z2> [<WorldName>]"
+ end
+ local Coords = {}
+ for i = 1, 6 do
+ local v = tonumber(a_Split[i + 1])
+ if not(v) then
+ return true, "Parameter " .. (i + 1) .. " (" .. tostring(a_Split[i + 1]) .. ") not a number "
+ end
+ Coords[i] = v
+ end
+
+ -- Get the world in which to test:
+ local World
+ if (a_Split[8]) then
+ World = cRoot:GetWorld(a_Split[2])
+ else
+ World = cRoot:Get():GetDefaultWorld()
+ end
+ if not(World) then
+ return true, "No such world"
+ end
+
+ -- Define the callbacks to use for tracing:
+ local Callbacks =
+ {
+ OnNextBlock = function(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_EntryFace)
+ LOG(string.format("{%d, %d, %d}: %s", a_BlockX, a_BlockY, a_BlockZ, ItemToString(cItem(a_BlockType, 1, a_BlockMeta))))
+ end,
+ OnNextBlockNoData = function(a_BlockX, a_BlockY, a_BlockZ, a_EntryFace)
+ LOG(string.format("{%d, %d, %d} (no data)", a_BlockX, a_BlockY, a_BlockZ))
+ end,
+ OnNoChunk = function()
+ LOG("Chunk not loaded")
+ end,
+ OnNoMoreHits = function()
+ LOG("Trace finished")
+ end,
+ OnOutOfWorld = function()
+ LOG("Out of world")
+ end,
+ OnIntoWorld = function()
+ LOG("Into world")
+ end,
+ }
+
+ -- Approximate the chunks needed for the trace by iterating over all chunks and measuring their center's distance from the traced line
+ local Chunks = {}
+ local sx = math.floor(Coords[1] / 16)
+ local sz = math.floor(Coords[3] / 16)
+ local ex = math.floor(Coords[4] / 16)
+ local ez = math.floor(Coords[6] / 16)
+ local sgnx = (sx < ex) and 1 or -1
+ local sgnz = (sz < ez) and 1 or -1
+ for z = sz, ez, sgnz do
+ local ChunkCenterZ = z * 16 + 8
+ for x = sx, ex, sgnx do
+ local ChunkCenterX = x * 16 + 8
+ local sqdist = SqDistPtFromLine(ChunkCenterX, ChunkCenterZ, Coords[1], Coords[3], Coords[4], Coords[6])
+ if (sqdist <= 128) then
+ table.insert(Chunks, {x, z})
+ end
+ end
+ end
+
+ -- Load the chunks and do the trace once loaded:
+ World:ChunkStay(Chunks,
+ nil,
+ function()
+ cLineBlockTracer:Trace(World, Callbacks, Coords[1], Coords[2], Coords[3], Coords[4], Coords[5], Coords[6])
+ end
+ )
+ return true
+end
+
+
+
+
+
function HandleConsoleBBox(a_Split)
local bbox = cBoundingBox(0, 10, 0, 10, 0, 10)
local v1 = Vector3d(1, 1, 1)
diff --git a/MCServer/Plugins/Debuggers/Info.lua b/MCServer/Plugins/Debuggers/Info.lua
index 2e170487b..a76690ea1 100644
--- a/MCServer/Plugins/Debuggers/Info.lua
+++ b/MCServer/Plugins/Debuggers/Info.lua
@@ -235,6 +235,12 @@ g_PluginInfo =
Handler = HandleConsoleSchedule,
HelpString = "Tests the world scheduling",
},
+
+ ["testtracer"] =
+ {
+ Handler = HandleConsoleTestTracer,
+ HelpString = "Tests the cLineBlockTracer",
+ }
}, -- ConsoleCommands
} -- g_PluginInfo
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index bce1891e2..7655d8c83 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -34,6 +34,7 @@
#include "../CompositeChat.h"
#include "../StringCompression.h"
#include "../CommandOutput.h"
+#include "../BuildInfo.h"
@@ -2079,6 +2080,50 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
+static int tolua_cRoot_GetBuildCommitID(lua_State * tolua_S)
+{
+ cLuaState L(tolua_S);
+ L.Push(BUILD_COMMIT_ID);
+ return 1;
+}
+
+
+
+
+
+static int tolua_cRoot_GetBuildDateTime(lua_State * tolua_S)
+{
+ cLuaState L(tolua_S);
+ L.Push(BUILD_DATETIME);
+ return 1;
+}
+
+
+
+
+
+static int tolua_cRoot_GetBuildID(lua_State * tolua_S)
+{
+ cLuaState L(tolua_S);
+ L.Push(BUILD_ID);
+ return 1;
+}
+
+
+
+
+
+static int tolua_cRoot_GetBuildSeriesName(lua_State * tolua_S)
+{
+ cLuaState L(tolua_S);
+ L.Push(BUILD_SERIES_NAME);
+ return 1;
+}
+
+
+
+
+
static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
{
cLuaState L(tolua_S);
@@ -2092,7 +2137,8 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
}
// Check the input param:
- cItem * Input = (cItem *)tolua_tousertype(L, 2, nullptr);
+ cItem * Input = nullptr;
+ L.GetStackValue(2, Input);
if (Input == nullptr)
{
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
@@ -2109,9 +2155,9 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
}
// Push the output, number of ticks and input as the three return values:
- tolua_pushusertype(L, Recipe->Out, "const cItem");
- tolua_pushnumber (L, (lua_Number)(Recipe->CookTime));
- tolua_pushusertype(L, Recipe->In, "const cItem");
+ L.Push(Recipe->Out);
+ L.Push(Recipe->CookTime);
+ L.Push(Recipe->In);
return 3;
}
@@ -2868,6 +2914,10 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "DoWithPlayerByUUID", DoWith <cRoot, cPlayer, &cRoot::DoWithPlayerByUUID>);
tolua_function(tolua_S, "ForEachPlayer", ForEach<cRoot, cPlayer, &cRoot::ForEachPlayer>);
tolua_function(tolua_S, "ForEachWorld", ForEach<cRoot, cWorld, &cRoot::ForEachWorld>);
+ tolua_function(tolua_S, "GetBuildCommitID", tolua_cRoot_GetBuildCommitID);
+ tolua_function(tolua_S, "GetBuildDateTime", tolua_cRoot_GetBuildDateTime);
+ tolua_function(tolua_S, "GetBuildID", tolua_cRoot_GetBuildID);
+ tolua_function(tolua_S, "GetBuildSeriesName", tolua_cRoot_GetBuildSeriesName);
tolua_function(tolua_S, "GetFurnaceRecipe", tolua_cRoot_GetFurnaceRecipe);
tolua_endmodule(tolua_S);
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index 2621b560b..d1588160d 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -32,7 +32,8 @@ cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTY
m_NeedCookTime(0),
m_TimeCooked(0),
m_FuelBurnTime(0),
- m_TimeBurned(0)
+ m_TimeBurned(0),
+ m_IsLoading(false)
{
m_Contents.AddListener(*this);
}
@@ -178,20 +179,15 @@ void cFurnaceEntity::BurnNewFuel(void)
{
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel));
- if (NewTime == 0)
+ if ((NewTime == 0) || !CanCookInputToOutput())
{
// The item in the fuel slot is not suitable
+ // or the input and output isn't available for cooking
SetBurnTimes(0, 0);
SetIsCooking(false);
return;
}
- // Is the input and output ready for cooking?
- if (!CanCookInputToOutput())
- {
- return;
- }
-
// Burn one new fuel:
SetBurnTimes(NewTime, 0);
SetIsCooking(true);
@@ -218,6 +214,11 @@ void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
return;
}
+ if (m_IsLoading)
+ {
+ return;
+ }
+
ASSERT(a_ItemGrid == &m_Contents);
switch (a_SlotNum)
{
@@ -238,7 +239,10 @@ void cFurnaceEntity::UpdateInput(void)
if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput))
{
// The input is different from what we had before, reset the cooking time
- m_TimeCooked = 0;
+ if (!m_IsLoading)
+ {
+ m_TimeCooked = 0;
+ }
}
m_LastInput = m_Contents.GetSlot(fsInput);
@@ -253,13 +257,17 @@ void cFurnaceEntity::UpdateInput(void)
else
{
m_NeedCookTime = m_CurrentRecipe->CookTime;
- SetIsCooking(true);
// Start burning new fuel if there's no flame now:
if (GetFuelBurnTimeLeft() <= 0)
{
BurnNewFuel();
}
+ // Already burning, set cooking to ensure that cooking is occuring
+ else
+ {
+ SetIsCooking(true);
+ }
}
}
@@ -293,11 +301,19 @@ void cFurnaceEntity::UpdateOutput(void)
return;
}
- // No need to burn new fuel, the Tick() function will take care of that
-
// Can cook, start cooking if not already underway:
m_NeedCookTime = m_CurrentRecipe->CookTime;
- SetIsCooking(m_FuelBurnTime > 0);
+
+ // Check if fuel needs to start a burn
+ if (GetFuelBurnTimeLeft() <= 0)
+ {
+ BurnNewFuel();
+ }
+ // Already burning, set cooking to ensure that cooking is occuring
+ else
+ {
+ SetIsCooking(true);
+ }
}
diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h
index 8b3ba3e36..8734d763c 100644
--- a/src/BlockEntities/FurnaceEntity.h
+++ b/src/BlockEntities/FurnaceEntity.h
@@ -101,6 +101,11 @@ public:
m_TimeCooked = a_TimeCooked;
}
+ void SetLoading(bool a_IsLoading)
+ {
+ m_IsLoading = a_IsLoading;
+ }
+
protected:
/** Block meta of the block currently represented by this entity */
@@ -129,6 +134,9 @@ protected:
/** Amount of ticks that the current fuel has been burning */
int m_TimeBurned;
+
+ /** Is the block currently being loaded into the world? */
+ bool m_IsLoading;
/** Sends the specified progressbar value to all clients of the window */
void BroadcastProgress(short a_ProgressbarID, short a_Value);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5556ddc4d..c68795bb3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -83,6 +83,7 @@ SET (HDRS
BlockTracer.h
Broadcaster.h
BoundingBox.h
+ BuildInfo.h
BuildInfo.h.cmake
ByteBuffer.h
ChatColor.h
diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp
index 315e8d082..587fa0e7c 100644
--- a/src/LineBlockTracer.cpp
+++ b/src/LineBlockTracer.cpp
@@ -154,38 +154,45 @@ bool cLineBlockTracer::MoveToNextBlock(void)
{
// Find out which of the current block's walls gets hit by the path:
static const double EPS = 0.00001;
- double Coeff = 1;
- enum eDirection
+ enum
{
dirNONE,
dirX,
dirY,
dirZ,
} Direction = dirNONE;
+
+ // Calculate the next YZ wall hit:
+ double Coeff = 1;
if (std::abs(m_DiffX) > EPS)
{
double DestX = (m_DirX > 0) ? (m_CurrentX + 1) : m_CurrentX;
- Coeff = (DestX - m_StartX) / m_DiffX;
- if (Coeff <= 1)
+ double CoeffX = (DestX - m_StartX) / m_DiffX;
+ if (CoeffX <= 1) // We need to include equality for the last block in the trace
{
+ Coeff = CoeffX;
Direction = dirX;
}
}
+
+ // If the next XZ wall hit is closer, use it instead:
if (std::abs(m_DiffY) > EPS)
{
double DestY = (m_DirY > 0) ? (m_CurrentY + 1) : m_CurrentY;
double CoeffY = (DestY - m_StartY) / m_DiffY;
- if (CoeffY < Coeff)
+ if (CoeffY <= Coeff) // We need to include equality for the last block in the trace
{
Coeff = CoeffY;
Direction = dirY;
}
}
+
+ // If the next XY wall hit is closer, use it instead:
if (std::abs(m_DiffZ) > EPS)
{
double DestZ = (m_DirZ > 0) ? (m_CurrentZ + 1) : m_CurrentZ;
double CoeffZ = (DestZ - m_StartZ) / m_DiffZ;
- if (CoeffZ < Coeff)
+ if (CoeffZ <= Coeff) // We need to include equality for the last block in the trace
{
Direction = dirZ;
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 392b9bf83..8ca49c2c0 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1052,7 +1052,8 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag
}
std::unique_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, m_World));
-
+ Furnace->SetLoading(true);
+
// Load slots:
for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child))
{
@@ -1085,9 +1086,9 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag
// Anvil doesn't store the time that an item takes to cook. We simply use the default - 10 seconds (200 ticks)
Furnace->SetCookTimes(200, ct);
}
-
// Restart cooking:
Furnace->ContinueCooking();
+ Furnace->SetLoading(false);
return Furnace.release();
}