summaryrefslogtreecommitdiffstats
path: root/src/Generating/PrefabPiecePool.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-11-26 11:19:25 +0100
committerGitHub <noreply@github.com>2016-11-26 11:19:25 +0100
commit4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc (patch)
treeab87c4a6c9f58fdfe2495c4fef939f4940df7d96 /src/Generating/PrefabPiecePool.cpp
parentMerge pull request #3442 from Seadragon91/luacheck_config (diff)
parentPrefabs: Implemented support for ExpandFloorStrategy. (diff)
downloadcuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.tar
cuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.tar.gz
cuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.tar.bz2
cuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.tar.lz
cuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.tar.xz
cuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.tar.zst
cuberite-4e9da46a853f4c8b97cacafdde8e5f95a5c5b1cc.zip
Diffstat (limited to 'src/Generating/PrefabPiecePool.cpp')
-rw-r--r--src/Generating/PrefabPiecePool.cpp54
1 files changed, 44 insertions, 10 deletions
diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp
index 417f8ce7e..d6c2c8819 100644
--- a/src/Generating/PrefabPiecePool.cpp
+++ b/src/Generating/PrefabPiecePool.cpp
@@ -526,16 +526,15 @@ bool cPrefabPiecePool::ReadPieceMetadataCubesetVer1(
}
// Get the values:
- int AddWeightIfSame = 0, DefaultWeight = 100, MoveToGround = 0, ShouldExpandFloor = 0;
+ int AddWeightIfSame = 0, DefaultWeight = 100, MoveToGround = 0;
AString DepthWeight, MergeStrategy, VerticalLimit, VerticalStrategy;
- a_LuaState.GetNamedValue("AddWeightIfSame", AddWeightIfSame);
- a_LuaState.GetNamedValue("DefaultWeight", DefaultWeight);
- a_LuaState.GetNamedValue("DepthWeight", DepthWeight);
- a_LuaState.GetNamedValue("MergeStrategy", MergeStrategy);
- a_LuaState.GetNamedValue("MoveToGround", MoveToGround);
- a_LuaState.GetNamedValue("ShouldExpandFloor", ShouldExpandFloor);
- a_LuaState.GetNamedValue("VerticalLimit", VerticalLimit);
- a_LuaState.GetNamedValue("VerticalStrategy", VerticalStrategy);
+ a_LuaState.GetNamedValue("AddWeightIfSame", AddWeightIfSame);
+ a_LuaState.GetNamedValue("DefaultWeight", DefaultWeight);
+ a_LuaState.GetNamedValue("DepthWeight", DepthWeight);
+ a_LuaState.GetNamedValue("MergeStrategy", MergeStrategy);
+ a_LuaState.GetNamedValue("MoveToGround", MoveToGround);
+ a_LuaState.GetNamedValue("VerticalLimit", VerticalLimit);
+ a_LuaState.GetNamedValue("VerticalStrategy", VerticalStrategy);
// Apply the values:
a_Prefab->SetAddWeightIfSame(AddWeightIfSame);
@@ -555,7 +554,42 @@ bool cPrefabPiecePool::ReadPieceMetadataCubesetVer1(
a_Prefab->SetMergeStrategy(strategy->second);
}
a_Prefab->SetMoveToGround(MoveToGround != 0);
- a_Prefab->SetExtendFloor(ShouldExpandFloor != 0);
+
+ AString ExpandFloorStrategyStr;
+ if (!a_LuaState.GetNamedValue("ExpandFloorStrategy", ExpandFloorStrategyStr))
+ {
+ // Check the older variant for ExpandFloorStrategy, ShouldExpandFloor:
+ int ShouldExpandFloor;
+ if (a_LuaState.GetNamedValue("ShouldExpandFloor", ShouldExpandFloor))
+ {
+ LOG("Piece \"%s\" in file \"%s\" is using the old \"ShouldExpandFloor\" attribute. Use the new \"ExpandFloorStrategy\" attribute instead for more options.",
+ a_PieceName.c_str(), a_FileName.c_str()
+ );
+ a_Prefab->SetExtendFloorStrategy((ShouldExpandFloor != 0) ? cPrefab::efsRepeatBottomTillNonAir : cPrefab::efsNone);
+ }
+ }
+ else
+ {
+ auto lcExpandFloorStrategyStr = StrToLower(ExpandFloorStrategyStr);
+ if (lcExpandFloorStrategyStr == "repeatbottomtillnonair")
+ {
+ a_Prefab->SetExtendFloorStrategy(cPrefab::efsRepeatBottomTillNonAir);
+ }
+ else if (lcExpandFloorStrategyStr == "repeatbottomtillsolid")
+ {
+ a_Prefab->SetExtendFloorStrategy(cPrefab::efsRepeatBottomTillSolid);
+ }
+ else
+ {
+ if (lcExpandFloorStrategyStr != "none")
+ {
+ LOGWARNING("Piece \"%s\" in file \"%s\" is using an unknown \"ExpandFloorStrategy\" attribute value: \"%s\"",
+ a_PieceName.c_str(), a_FileName.c_str(), ExpandFloorStrategyStr.c_str()
+ );
+ }
+ a_Prefab->SetExtendFloorStrategy(cPrefab::efsNone);
+ }
+ }
if (!VerticalLimit.empty())
{
if (!a_Prefab->SetVerticalLimitFromString(VerticalLimit, a_LogWarnings))