Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
a2738dec
Commit
a2738dec
authored
12 years ago
by
Matthew I
Committed by
Perttu Ahola
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix hovering after mining a block underneath you while sneaking
parent
1788709e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/localplayer.cpp
+32
-13
32 additions, 13 deletions
src/localplayer.cpp
src/localplayer.h
+6
-0
6 additions, 0 deletions
src/localplayer.h
with
38 additions
and
13 deletions
src/localplayer.cpp
+
32
−
13
View file @
a2738dec
...
...
@@ -35,7 +35,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LocalPlayer
::
LocalPlayer
(
IGameDef
*
gamedef
)
:
Player
(
gamedef
),
m_sneak_node
(
32767
,
32767
,
32767
),
m_sneak_node_exists
(
false
)
m_sneak_node_exists
(
false
),
m_old_node_below
(
32767
,
32767
,
32767
),
m_old_node_below_type
(
"air"
),
m_need_to_get_new_sneak_node
(
true
)
{
// Initialize hp to 0, so that no hearts will be shown if server
// doesn't support health points
...
...
@@ -189,8 +192,26 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
/*
Check the nodes under the player to see from which node the
player is sneaking from, if any.
player is sneaking from, if any. If the node from under
the player has been removed, the player falls.
*/
v3s16
current_node
=
floatToInt
(
position
-
v3f
(
0
,
BS
/
2
,
0
),
BS
);
if
(
m_sneak_node_exists
&&
nodemgr
->
get
(
map
.
getNodeNoEx
(
m_old_node_below
)).
name
==
"air"
&&
m_old_node_below_type
!=
"air"
)
{
// Old node appears to have been removed; that is,
// it wasn't air before but now it is
m_need_to_get_new_sneak_node
=
false
;
m_sneak_node_exists
=
false
;
}
else
if
(
nodemgr
->
get
(
map
.
getNodeNoEx
(
current_node
)).
name
!=
"air"
)
{
// We are on something, so make sure to recalculate the sneak
// node.
m_need_to_get_new_sneak_node
=
true
;
}
if
(
m_need_to_get_new_sneak_node
)
{
v3s16
pos_i_bottom
=
floatToInt
(
position
-
v3f
(
0
,
BS
/
2
,
0
),
BS
);
v2f
player_p2df
(
position
.
X
,
position
.
Z
);
...
...
@@ -240,17 +261,9 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
}
bool
sneak_node_found
=
(
min_distance_f
<
100000.0
*
BS
*
0.9
);
if
(
control
.
sneak
&&
m_sneak_node_exists
)
{
if
(
sneak_node_found
)
m_sneak_node
=
new_sneak_node
;
}
else
{
m_sneak_node
=
new_sneak_node
;
m_sneak_node_exists
=
sneak_node_found
;
}
m_sneak_node
=
new_sneak_node
;
m_sneak_node_exists
=
sneak_node_found
;
/*
If sneaking, the player's collision box can be in air, so
...
...
@@ -295,6 +308,12 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
}
}
}
/*
Update the node last under the player
*/
m_old_node_below
=
floatToInt
(
position
-
v3f
(
0
,
BS
/
2
,
0
),
BS
);
m_old_node_below_type
=
nodemgr
->
get
(
map
.
getNodeNoEx
(
m_old_node_below
)).
name
;
}
void
LocalPlayer
::
move
(
f32
dtime
,
Map
&
map
,
f32
pos_max_d
)
...
...
This diff is collapsed.
Click to expand it.
src/localplayer.h
+
6
−
0
View file @
a2738dec
...
...
@@ -95,6 +95,12 @@ class LocalPlayer : public Player
v3s16
m_sneak_node
;
// Whether the player is allowed to sneak
bool
m_sneak_node_exists
;
// Node below player, used to determine whether it has been removed,
// and its old type
v3s16
m_old_node_below
;
std
::
string
m_old_node_below_type
;
// Whether recalculation of the sneak node is needed
bool
m_need_to_get_new_sneak_node
;
};
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment