@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
25
25
#include " gamedef.h"
26
26
#include " nodedef.h"
27
27
#include " settings.h"
28
+ #include " environment.h"
28
29
#include " map.h"
29
30
#include " util/numeric.h"
30
31
@@ -57,9 +58,10 @@ LocalPlayer::~LocalPlayer()
57
58
{
58
59
}
59
60
60
- void LocalPlayer::move (f32 dtime, Map &map , f32 pos_max_d,
61
+ void LocalPlayer::move (f32 dtime, ClientEnvironment *env , f32 pos_max_d,
61
62
std::list<CollisionInfo> *collision_info)
62
63
{
64
+ Map *map = &env->getMap ();
63
65
INodeDefManager *nodemgr = m_gamedef->ndef ();
64
66
65
67
v3f position = getPosition ();
@@ -97,15 +99,15 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
97
99
if (in_liquid)
98
100
{
99
101
v3s16 pp = floatToInt (position + v3f (0 ,BS*0.1 ,0 ), BS);
100
- in_liquid = nodemgr->get (map. getNode (pp).getContent ()).isLiquid ();
101
- liquid_viscosity = nodemgr->get (map. getNode (pp).getContent ()).liquid_viscosity ;
102
+ in_liquid = nodemgr->get (map-> getNode (pp).getContent ()).isLiquid ();
103
+ liquid_viscosity = nodemgr->get (map-> getNode (pp).getContent ()).liquid_viscosity ;
102
104
}
103
105
// If not in liquid, the threshold of going in is at lower y
104
106
else
105
107
{
106
108
v3s16 pp = floatToInt (position + v3f (0 ,BS*0.5 ,0 ), BS);
107
- in_liquid = nodemgr->get (map. getNode (pp).getContent ()).isLiquid ();
108
- liquid_viscosity = nodemgr->get (map. getNode (pp).getContent ()).liquid_viscosity ;
109
+ in_liquid = nodemgr->get (map-> getNode (pp).getContent ()).isLiquid ();
110
+ liquid_viscosity = nodemgr->get (map-> getNode (pp).getContent ()).liquid_viscosity ;
109
111
}
110
112
}
111
113
catch (InvalidPositionException &e)
@@ -118,7 +120,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
118
120
*/
119
121
try {
120
122
v3s16 pp = floatToInt (position + v3f (0 ,0 ,0 ), BS);
121
- in_liquid_stable = nodemgr->get (map. getNode (pp).getContent ()).isLiquid ();
123
+ in_liquid_stable = nodemgr->get (map-> getNode (pp).getContent ()).isLiquid ();
122
124
}
123
125
catch (InvalidPositionException &e)
124
126
{
@@ -132,8 +134,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
132
134
try {
133
135
v3s16 pp = floatToInt (position + v3f (0 ,0.5 *BS,0 ), BS);
134
136
v3s16 pp2 = floatToInt (position + v3f (0 ,-0.2 *BS,0 ), BS);
135
- is_climbing = ((nodemgr->get (map. getNode (pp).getContent ()).climbable ||
136
- nodemgr->get (map. getNode (pp2).getContent ()).climbable ) && !free_move);
137
+ is_climbing = ((nodemgr->get (map-> getNode (pp).getContent ()).climbable ||
138
+ nodemgr->get (map-> getNode (pp2).getContent ()).climbable ) && !free_move);
137
139
}
138
140
catch (InvalidPositionException &e)
139
141
{
@@ -197,7 +199,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
197
199
198
200
v3f accel_f = v3f (0 ,0 ,0 );
199
201
200
- collisionMoveResult result = collisionMoveSimple (&map , m_gamedef,
202
+ collisionMoveResult result = collisionMoveSimple (env , m_gamedef,
201
203
pos_max_d, playerbox, player_stepheight, dtime,
202
204
position, m_speed, accel_f);
203
205
@@ -219,15 +221,15 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
219
221
*/
220
222
v3s16 current_node = floatToInt (position - v3f (0 ,BS/2 ,0 ), BS);
221
223
if (m_sneak_node_exists &&
222
- nodemgr->get (map. getNodeNoEx (m_old_node_below)).name == " air" &&
224
+ nodemgr->get (map-> getNodeNoEx (m_old_node_below)).name == " air" &&
223
225
m_old_node_below_type != " air" )
224
226
{
225
227
// Old node appears to have been removed; that is,
226
228
// it wasn't air before but now it is
227
229
m_need_to_get_new_sneak_node = false ;
228
230
m_sneak_node_exists = false ;
229
231
}
230
- else if (nodemgr->get (map. getNodeNoEx (current_node)).name != " air" )
232
+ else if (nodemgr->get (map-> getNodeNoEx (current_node)).name != " air" )
231
233
{
232
234
// We are on something, so make sure to recalculate the sneak
233
235
// node.
@@ -267,10 +269,10 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
267
269
268
270
try {
269
271
// The node to be sneaked on has to be walkable
270
- if (nodemgr->get (map. getNode (p)).walkable == false )
272
+ if (nodemgr->get (map-> getNode (p)).walkable == false )
271
273
continue ;
272
274
// And the node above it has to be nonwalkable
273
- if (nodemgr->get (map. getNode (p+v3s16 (0 ,1 ,0 ))).walkable == true )
275
+ if (nodemgr->get (map-> getNode (p+v3s16 (0 ,1 ,0 ))).walkable == true )
274
276
continue ;
275
277
}
276
278
catch (InvalidPositionException &e)
@@ -331,7 +333,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
331
333
{
332
334
camera_barely_in_ceiling = false ;
333
335
v3s16 camera_np = floatToInt (getEyePosition (), BS);
334
- MapNode n = map. getNodeNoEx (camera_np);
336
+ MapNode n = map-> getNodeNoEx (camera_np);
335
337
if (n.getContent () != CONTENT_IGNORE){
336
338
if (nodemgr->get (n).walkable && nodemgr->get (n).solidness == 2 ){
337
339
camera_barely_in_ceiling = true ;
@@ -343,21 +345,21 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
343
345
Update the node last under the player
344
346
*/
345
347
m_old_node_below = floatToInt (position - v3f (0 ,BS/2 ,0 ), BS);
346
- m_old_node_below_type = nodemgr->get (map. getNodeNoEx (m_old_node_below)).name ;
348
+ m_old_node_below_type = nodemgr->get (map-> getNodeNoEx (m_old_node_below)).name ;
347
349
348
350
/*
349
351
Check properties of the node on which the player is standing
350
352
*/
351
- const ContentFeatures &f = nodemgr->get (map. getNodeNoEx (getStandingNodePos ()));
353
+ const ContentFeatures &f = nodemgr->get (map-> getNodeNoEx (getStandingNodePos ()));
352
354
// Determine if jumping is possible
353
355
m_can_jump = touching_ground && !in_liquid;
354
356
if (itemgroup_get (f.groups , " disable_jump" ))
355
357
m_can_jump = false ;
356
358
}
357
359
358
- void LocalPlayer::move (f32 dtime, Map &map , f32 pos_max_d)
360
+ void LocalPlayer::move (f32 dtime, ClientEnvironment *env , f32 pos_max_d)
359
361
{
360
- move (dtime, map , pos_max_d, NULL );
362
+ move (dtime, env , pos_max_d, NULL );
361
363
}
362
364
363
365
void LocalPlayer::applyControl (float dtime)
0 commit comments