aboutsummaryrefslogtreecommitdiff
path: root/src/mapnode.cpp
diff options
context:
space:
mode:
authorWuzzy <Wuzzy@disroot.org>2022-09-16 13:18:55 +0200
committerGitHub <noreply@github.com>2022-09-16 13:18:55 +0200
commit1d04903c1973591e795d3275b900d76d7cb7877a (patch)
tree06891c6fe3075c1868832bc0007308e525cef70f /src/mapnode.cpp
parentb5e7280708221cdcca89df7d16f2aea19e4b3c4c (diff)
downloadminetest-1d04903c1973591e795d3275b900d76d7cb7877a.tar.xz
Add paramtype2s for 4 horizontal rotations and 64 colors (#11431)
4dir is like facedir, but only for 4 horizontal directions: NESW. It is identical in behavior to facedir otherwise. The reason why game makers would want to use this over facedir is 1) simplicity and 2) you get 6 free bits. It can be used for things like chests and furnaces and you don't need or want them to "flip them on the side" (like you could with facedir). color4dir is like colorfacedir, but you get 64 colors instead of only 8.
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r--src/mapnode.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp
index 42f020e71..1685dc11c 100644
--- a/src/mapnode.cpp
+++ b/src/mapnode.cpp
@@ -149,6 +149,9 @@ u8 MapNode::getFaceDir(const NodeDefManager *nodemgr,
if (f.param_type_2 == CPT2_FACEDIR ||
f.param_type_2 == CPT2_COLORED_FACEDIR)
return (getParam2() & 0x1F) % 24;
+ if (f.param_type_2 == CPT2_4DIR ||
+ f.param_type_2 == CPT2_COLORED_4DIR)
+ return getParam2() & 0x03;
if (allow_wallmounted && (f.param_type_2 == CPT2_WALLMOUNTED ||
f.param_type_2 == CPT2_COLORED_WALLMOUNTED))
return wallmounted_to_facedir[getParam2() & 0x07];
@@ -196,7 +199,8 @@ void MapNode::rotateAlongYAxis(const NodeDefManager *nodemgr, Rotation rot)
{
ContentParamType2 cpt2 = nodemgr->get(*this).param_type_2;
- if (cpt2 == CPT2_FACEDIR || cpt2 == CPT2_COLORED_FACEDIR) {
+ if (cpt2 == CPT2_FACEDIR || cpt2 == CPT2_COLORED_FACEDIR ||
+ cpt2 == CPT2_4DIR || cpt2 == CPT2_COLORED_4DIR) {
static const u8 rotate_facedir[24 * 4] = {
// Table value = rotated facedir
// Columns: 0, 90, 180, 270 degrees rotation around vertical axis
@@ -232,10 +236,17 @@ void MapNode::rotateAlongYAxis(const NodeDefManager *nodemgr, Rotation rot)
22, 21, 20, 23,
23, 22, 21, 20
};
- u8 facedir = (param2 & 31) % 24;
- u8 index = facedir * 4 + rot;
- param2 &= ~31;
- param2 |= rotate_facedir[index];
+ if (cpt2 == CPT2_FACEDIR || cpt2 == CPT2_COLORED_FACEDIR) {
+ u8 facedir = (param2 & 31) % 24;
+ u8 index = facedir * 4 + rot;
+ param2 &= ~31;
+ param2 |= rotate_facedir[index];
+ } else if (cpt2 == CPT2_4DIR || cpt2 == CPT2_COLORED_4DIR) {
+ u8 fourdir = param2 & 3;
+ u8 index = fourdir + rot;
+ param2 &= ~3;
+ param2 |= rotate_facedir[index];
+ }
} else if (cpt2 == CPT2_WALLMOUNTED ||
cpt2 == CPT2_COLORED_WALLMOUNTED) {
u8 wmountface = (param2 & 7);