]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Use absolute value for bouncy in collision (#11969)
authorpecksin <78765996+pecksin@users.noreply.github.com>
Wed, 16 Feb 2022 22:06:00 +0000 (17:06 -0500)
committerGitHub <noreply@github.com>
Wed, 16 Feb 2022 22:06:00 +0000 (17:06 -0500)
* use abs(bouncy) in collision
* test case for negative bouncy
* send abs(bouncy) to old clients

games/devtest/mods/testnodes/properties.lua
src/collision.cpp
src/nodedef.cpp

index 51f703d7c22afe513d3393b9c22abc0198e82497..89facf71c3dd71822919a9f31845e28f8a365a28 100644 (file)
@@ -252,9 +252,9 @@ for i=-100, 100, 25 do
 end
 
 -- Bouncy nodes (various bounce levels)
-for i=20, 180, 20 do
+for i=-140, 180, 20 do
        local val = math.floor(((i-20)/200)*255)
-       minetest.register_node("testnodes:bouncy"..i, {
+       minetest.register_node(("testnodes:bouncy"..i):gsub("-","NEG"), {
                description = S("Bouncy Node (@1%)", i),
                groups = {bouncy=i, dig_immediate=3},
 
index d85a5688435a516b879c35a1b7811f7cdb2ce423..ccc3a058db27b234b273a4dd9d5ace4c4e5826bb 100644 (file)
@@ -303,7 +303,8 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                        if (!f.walkable)
                                continue;
 
-                       int n_bouncy_value = itemgroup_get(f.groups, "bouncy");
+                       // Negative bouncy may have a meaning, but we need +value here.
+                       int n_bouncy_value = abs(itemgroup_get(f.groups, "bouncy"));
 
                        int neighbors = 0;
                        if (f.drawtype == NDT_NODEBOX &&
index 8a55428371236067fa7999875f9f8e106cb65afa..fe0cc4bb0ce072ab7e42ef66b3e85119c996fc0a 100644 (file)
@@ -452,7 +452,12 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
        writeU16(os, groups.size());
        for (const auto &group : groups) {
                os << serializeString16(group.first);
-               writeS16(os, group.second);
+               if (protocol_version < 41 && group.first.compare("bouncy") == 0) {
+                       // Old clients may choke on negative bouncy value
+                       writeS16(os, abs(group.second));
+               } else {
+                       writeS16(os, group.second);
+               }
        }
        writeU8(os, param_type);
        writeU8(os, param_type_2);