summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-12-09 12:29:04 +0100
committerGitHub <noreply@github.com>2016-12-09 12:29:04 +0100
commite8fb85be885f6c32fdeb861b12fb8402de66ebe5 (patch)
tree2e2ed40816c0b053ace2f01340e2b667e1d1e28f
parentMerge pull request #3471 from marvinkopf/fix-3417 (diff)
downloadcuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.tar
cuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.tar.gz
cuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.tar.bz2
cuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.tar.lz
cuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.tar.xz
cuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.tar.zst
cuberite-e8fb85be885f6c32fdeb861b12fb8402de66ebe5.zip
-rw-r--r--Server/Plugins/Debuggers/Debuggers.lua18
-rw-r--r--Server/Plugins/Debuggers/Info.lua6
-rw-r--r--src/BlockArea.cpp6
-rw-r--r--src/Blocks/BlockRail.h88
4 files changed, 83 insertions, 35 deletions
diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua
index 4dfc55030..8e2bd0156 100644
--- a/Server/Plugins/Debuggers/Debuggers.lua
+++ b/Server/Plugins/Debuggers/Debuggers.lua
@@ -987,6 +987,24 @@ end;
+function HandleGenRailsCmd(a_Split, a_Player)
+ local MAX_RAIL_META = 9
+ local pos = a_Player:GetPosition()
+ local ba = cBlockArea:new()
+ ba:Create(2 * MAX_RAIL_META + 3, 4, 3, cBlockArea.baTypes + cBlockArea.baMetas)
+ ba:FillRelCuboid(0, 2 * MAX_RAIL_META + 2, 0, 0, 0, 2, cBlockArea.baTypes, E_BLOCK_STONE)
+ ba:FillRelCuboid(0, 2 * MAX_RAIL_META + 2, 1, 3, 0, 2, cBlockArea.baTypes, E_BLOCK_AIR)
+ for x = 0, MAX_RAIL_META do
+ ba:SetRelBlockTypeMeta(2 * x + 1, 1, 1, E_BLOCK_RAIL, x)
+ end
+ ba:Write(a_Player:GetWorld(), pos:Floor())
+ return true
+end
+
+
+
+
+
function HandleGetCustomNameCmd(a_Split, a_Player)
local item = a_Player:GetInventory():GetEquippedItem()
if (not(item.m_CustomName) or (item.m_CustomName == "")) then
diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua
index c21865218..ea1a60a56 100644
--- a/Server/Plugins/Debuggers/Info.lua
+++ b/Server/Plugins/Debuggers/Info.lua
@@ -100,6 +100,12 @@ g_PluginInfo =
Handler = HandleGCCmd,
HelpString = "Activates the Lua garbage collector"
},
+ ["/genrails"] =
+ {
+ Permission = "debuggers",
+ Handler = HandleGenRailsCmd,
+ HelpString = "Generates rail blocks with all metas from current block towards X+",
+ },
["/getcustomname"] =
{
Permission = "debuggers",
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index b54f6b2e7..2c3af5fec 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -1126,7 +1126,7 @@ void cBlockArea::MirrorXY(void)
int MaxZ = m_Size.z - 1;
for (int y = 0; y < m_Size.y; y++)
{
- for (int z = 0; z < HalfZ; z++)
+ for (int z = 0; z <= HalfZ; z++)
{
for (int x = 0; x < m_Size.x; x++)
{
@@ -1164,7 +1164,7 @@ void cBlockArea::MirrorXZ(void)
// We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
int HalfY = m_Size.y / 2;
int MaxY = m_Size.y - 1;
- for (int y = 0; y < HalfY; y++)
+ for (int y = 0; y <= HalfY; y++)
{
for (int z = 0; z < m_Size.z; z++)
{
@@ -1208,7 +1208,7 @@ void cBlockArea::MirrorYZ(void)
{
for (int z = 0; z < m_Size.z; z++)
{
- for (int x = 0; x < HalfX; x++)
+ for (int x = 0; x <= HalfX; x++)
{
int Idx1 = MakeIndex(x, y, z);
int Idx2 = MakeIndex(MaxX - x, y, z);
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index dda9af60d..867461554 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -524,6 +524,8 @@ public:
return a_Meta;
}
+
+
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
@@ -559,66 +561,88 @@ public:
return a_Meta;
}
+
+
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
- // Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
- if ((a_Meta < 0x06) || (a_Meta > 0x09))
+ // MirrorXY basically flips the ZP and ZM parts of the meta
+ if (m_BlockType == E_BLOCK_RAIL)
{
- // Save powered rail flag.
- NIBBLETYPE OtherMeta = a_Meta & 0x08;
- // Mirrors according to table; 0x07 == 0111.
- // Rails can either be flat (North / South) or Ascending (Asc. East)
- switch (a_Meta & 0x07)
+ // Basic rails can have curves and thus their meta behaves differently from specialized rails:
+ switch (a_Meta)
{
- case 0x05: return 0x04 + OtherMeta; // Asc. South -> Asc. North
- case 0x04: return 0x05 + OtherMeta; // Asc. North -> Asc. South
+ case E_META_RAIL_ASCEND_XM: return E_META_RAIL_ASCEND_XM;
+ case E_META_RAIL_ASCEND_XP: return E_META_RAIL_ASCEND_XP;
+ case E_META_RAIL_ASCEND_ZM: return E_META_RAIL_ASCEND_ZP;
+ case E_META_RAIL_ASCEND_ZP: return E_META_RAIL_ASCEND_ZM;
+ case E_META_RAIL_CURVED_ZM_XM: return E_META_RAIL_CURVED_ZP_XM;
+ case E_META_RAIL_CURVED_ZM_XP: return E_META_RAIL_CURVED_ZP_XP;
+ case E_META_RAIL_CURVED_ZP_XM: return E_META_RAIL_CURVED_ZM_XM;
+ case E_META_RAIL_CURVED_ZP_XP: return E_META_RAIL_CURVED_ZM_XP;
+ case E_META_RAIL_XM_XP: return E_META_RAIL_XM_XP;
+ case E_META_RAIL_ZM_ZP: return E_META_RAIL_ZM_ZP;
}
}
else
{
- switch (a_Meta)
+ // Specialized rails don't have curves, instead they use bit 0x08 as a flag
+ NIBBLETYPE flag = a_Meta & 0x08;
+ switch (a_Meta & 0x07)
{
- // Corner Directions
- case 0x06: return 0x09; // Northwest Cnr. -> Southwest Cnr.
- case 0x07: return 0x08; // Northeast Cnr. -> Southeast Cnr.
- case 0x08: return 0x07; // Southeast Cnr. -> Northeast Cnr.
- case 0x09: return 0x06; // Southwest Cnr. -> Northwest Cnr.
+ case E_META_RAIL_ASCEND_XM: return flag | E_META_RAIL_ASCEND_XM;
+ case E_META_RAIL_ASCEND_XP: return flag | E_META_RAIL_ASCEND_XP;
+ case E_META_RAIL_ASCEND_ZM: return flag | E_META_RAIL_ASCEND_ZP;
+ case E_META_RAIL_ASCEND_ZP: return flag | E_META_RAIL_ASCEND_ZM;
+ case E_META_RAIL_XM_XP: return flag | E_META_RAIL_XM_XP;
+ case E_META_RAIL_ZM_ZP: return flag | E_META_RAIL_ZM_ZP;
}
}
- // To avoid a compiler warning;
+ ASSERT(!"Unknown rail meta");
return a_Meta;
}
+
+
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
- // Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
- if ((a_Meta < 0x06) || (a_Meta > 0x09))
+ // MirrorYZ basically flips the XP and XM parts of the meta
+ if (m_BlockType == E_BLOCK_RAIL)
{
- // Save powered rail flag.
- NIBBLETYPE OtherMeta = a_Meta & 0x08;
- // Mirrors according to table; 0x07 == 0111.
- // Rails can either be flat (North / South) or Ascending (Asc. East)
- switch (a_Meta & 0x07)
+ // Basic rails can have curves and thus their meta behaves differently from specialized rails:
+ switch (a_Meta)
{
- case 0x02: return 0x03 + OtherMeta; // Asc. East -> Asc. West
- case 0x03: return 0x02 + OtherMeta; // Asc. West -> Asc. East
+ case E_META_RAIL_ASCEND_XM: return E_META_RAIL_ASCEND_XP;
+ case E_META_RAIL_ASCEND_XP: return E_META_RAIL_ASCEND_XM;
+ case E_META_RAIL_ASCEND_ZM: return E_META_RAIL_ASCEND_ZM;
+ case E_META_RAIL_ASCEND_ZP: return E_META_RAIL_ASCEND_ZP;
+ case E_META_RAIL_CURVED_ZM_XM: return E_META_RAIL_CURVED_ZM_XP;
+ case E_META_RAIL_CURVED_ZM_XP: return E_META_RAIL_CURVED_ZM_XM;
+ case E_META_RAIL_CURVED_ZP_XM: return E_META_RAIL_CURVED_ZP_XP;
+ case E_META_RAIL_CURVED_ZP_XP: return E_META_RAIL_CURVED_ZP_XM;
+ case E_META_RAIL_XM_XP: return E_META_RAIL_XM_XP;
+ case E_META_RAIL_ZM_ZP: return E_META_RAIL_ZM_ZP;
}
}
else
{
- switch (a_Meta)
+ // Specialized rails don't have curves, instead they use bit 0x08 as a flag
+ NIBBLETYPE flag = a_Meta & 0x08;
+ switch (a_Meta & 0x07)
{
- // Corner Directions
- case 0x06: return 0x07; // Northwest Cnr. -> Northeast Cnr.
- case 0x07: return 0x06; // Northeast Cnr. -> Northwest Cnr.
- case 0x08: return 0x09; // Southeast Cnr. -> Southwest Cnr.
- case 0x09: return 0x08; // Southwest Cnr. -> Southeast Cnr.
+ case E_META_RAIL_ASCEND_XM: return flag | E_META_RAIL_ASCEND_XP;
+ case E_META_RAIL_ASCEND_XP: return flag | E_META_RAIL_ASCEND_XM;
+ case E_META_RAIL_ASCEND_ZM: return flag | E_META_RAIL_ASCEND_ZM;
+ case E_META_RAIL_ASCEND_ZP: return flag | E_META_RAIL_ASCEND_ZP;
+ case E_META_RAIL_XM_XP: return flag | E_META_RAIL_XM_XP;
+ case E_META_RAIL_ZM_ZP: return flag | E_META_RAIL_ZM_ZP;
}
}
- // To avoid a compiler warning;
+ ASSERT(!"Unknown rail meta");
return a_Meta;
}
+
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);