#endif
#include "main.h" // For g_settings
#include "settings.h"
-#include "mapnode_contentfeatures.h"
+#include "nodedef.h"
+#include "environment.h"
+#include "gamedef.h"
-Player::Player():
+Player::Player(IGameDef *gamedef):
touching_ground(false),
in_water(false),
in_water_stable(false),
craftresult_is_preview(true),
hp(20),
peer_id(PEER_ID_INEXISTENT),
+// protected
+ m_gamedef(gamedef),
m_selected_item(0),
m_pitch(0),
m_yaw(0),
inventory.serialize(os);
}
-void Player::deSerialize(std::istream &is, IGameDef *gamedef)
+void Player::deSerialize(std::istream &is)
{
Settings args;
hp = 20;
}
- inventory.deSerialize(is, gamedef);
+ inventory.deSerialize(is, m_gamedef);
}
/*
ServerRemotePlayer
*/
+ServerRemotePlayer::ServerRemotePlayer(ServerEnvironment *env):
+ Player(env->getGameDef()),
+ ServerActiveObject(env, v3f(0,0,0))
+{
+}
+ServerRemotePlayer::ServerRemotePlayer(ServerEnvironment *env, v3f pos_, u16 peer_id_,
+ const char *name_):
+ Player(env->getGameDef()),
+ ServerActiveObject(env, pos_)
+{
+ setPosition(pos_);
+ peer_id = peer_id_;
+ updateName(name_);
+}
+
/* ServerActiveObject interface */
InventoryItem* ServerRemotePlayer::getWieldedItem()
#ifndef SERVER
RemotePlayer::RemotePlayer(
+ IGameDef *gamedef,
scene::ISceneNode* parent,
IrrlichtDevice *device,
s32 id):
+ Player(gamedef),
scene::ISceneNode(parent, (device==NULL)?NULL:device->getSceneManager(), id),
m_text(NULL)
{
LocalPlayer
*/
-LocalPlayer::LocalPlayer():
+LocalPlayer::LocalPlayer(IGameDef *gamedef):
+ Player(gamedef),
m_sneak_node(32767,32767,32767),
m_sneak_node_exists(false)
{
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
core::list<CollisionInfo> *collision_info)
{
+ INodeDefManager *nodemgr = m_gamedef->ndef();
+
v3f position = getPosition();
v3f oldpos = position;
v3s16 oldpos_i = floatToInt(oldpos, BS);
if(in_water)
{
v3s16 pp = floatToInt(position + v3f(0,BS*0.1,0), BS);
- in_water = content_liquid(map.getNode(pp).getContent());
+ in_water = nodemgr->get(map.getNode(pp).getContent()).isLiquid();
}
// If not in water, the threshold of going in is at lower y
else
{
v3s16 pp = floatToInt(position + v3f(0,BS*0.5,0), BS);
- in_water = content_liquid(map.getNode(pp).getContent());
+ in_water = nodemgr->get(map.getNode(pp).getContent()).isLiquid();
}
}
catch(InvalidPositionException &e)
*/
try{
v3s16 pp = floatToInt(position + v3f(0,0,0), BS);
- in_water_stable = content_liquid(map.getNode(pp).getContent());
+ in_water_stable = nodemgr->get(map.getNode(pp).getContent()).isLiquid();
}
catch(InvalidPositionException &e)
{
*/
try {
- v3s16 pp = floatToInt(position + v3f(0,0.5*BS,0), BS);
+ v3s16 pp = floatToInt(position + v3f(0,0.5*BS,0), BS);
v3s16 pp2 = floatToInt(position + v3f(0,-0.2*BS,0), BS);
- is_climbing = ((content_features(map.getNode(pp).getContent()).climbable ||
- content_features(map.getNode(pp2).getContent()).climbable) && !free_move);
+ is_climbing = ((nodemgr->get(map.getNode(pp).getContent()).climbable ||
+ nodemgr->get(map.getNode(pp2).getContent()).climbable) && !free_move);
}
catch(InvalidPositionException &e)
{
- is_climbing = false;
+ is_climbing = false;
}
/*
bool is_unloaded = false;
try{
// Player collides into walkable nodes
- if(content_walkable(map.getNode(v3s16(x,y,z)).getContent()) == false)
+ if(nodemgr->get(map.getNode(v3s16(x,y,z))).walkable == false)
continue;
}
catch(InvalidPositionException &e)
try{
// The node to be sneaked on has to be walkable
- if(content_walkable(map.getNode(p).getContent()) == false)
+ if(nodemgr->get(map.getNode(p)).walkable == false)
continue;
// And the node above it has to be nonwalkable
- if(content_walkable(map.getNode(p+v3s16(0,1,0)).getContent()) == true)
+ if(nodemgr->get(map.getNode(p+v3s16(0,1,0))).walkable == true)
continue;
}
catch(InvalidPositionException &e)