summaryrefslogtreecommitdiffstats
path: root/src/Generating/PrefabPiecePool.cpp
diff options
context:
space:
mode:
authorNiels Breuker <niels.breuker@hotmail.nl>2023-03-30 17:18:18 +0200
committerNiels Breuker <niels.breuker@hotmail.nl>2023-03-30 17:18:18 +0200
commit4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d (patch)
tree7bd7ef103724e6bed9c2cb79dadb50e88c901a89 /src/Generating/PrefabPiecePool.cpp
parentAdded small embedded devices to README (diff)
downloadcuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.tar
cuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.tar.gz
cuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.tar.bz2
cuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.tar.lz
cuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.tar.xz
cuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.tar.zst
cuberite-4af1f3ac35f6a7fe7ac2bfe625bad9abaf2e868d.zip
Diffstat (limited to 'src/Generating/PrefabPiecePool.cpp')
-rw-r--r--src/Generating/PrefabPiecePool.cpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp
index 4deee38ef..b78251d78 100644
--- a/src/Generating/PrefabPiecePool.cpp
+++ b/src/Generating/PrefabPiecePool.cpp
@@ -84,6 +84,11 @@ void cPrefabPiecePool::Clear(void)
delete *itr;
}
m_StartingPieces.clear();
+ for (cPieces::iterator itr = m_ClosurePieces.begin(), end = m_ClosurePieces.end(); itr != end; ++itr)
+ {
+ delete* itr;
+ }
+ m_ClosurePieces.clear();
}
@@ -345,8 +350,18 @@ bool cPrefabPiecePool::LoadCubesetPieceVer1(const AString & a_FileName, cLuaStat
else
{
auto p = prefab.release();
- m_AllPieces.push_back(p);
- AddToPerConnectorMap(p);
+
+ int IsClosurePiece = 0;
+ a_LuaState.GetNamedValue("Metadata.IsClosurePiece", IsClosurePiece);
+ if (IsClosurePiece != 0)
+ {
+ m_ClosurePieces.push_back(p);
+ }
+ else
+ {
+ m_AllPieces.push_back(p);
+ AddToPerConnectorMap(p);
+ }
}
return true;
@@ -758,6 +773,28 @@ cPieces cPrefabPiecePool::GetPiecesWithConnector(int a_ConnectorType)
+cPieces cPrefabPiecePool::GetClosurePiecesWithConnector(int a_ConnectorType)
+{
+ cPieces pieces;
+ for (auto& piece : m_ClosurePieces)
+ {
+ auto connectors = piece->GetConnectors();
+ for (auto& connector : connectors)
+ {
+ if (connector.m_Type == a_ConnectorType)
+ {
+ pieces.push_back(piece);
+ break;
+ }
+ }
+ }
+ return pieces;
+}
+
+
+
+
+
cPieces cPrefabPiecePool::GetStartingPieces(void)
{
if (m_StartingPieces.empty())