+/*
+Minetest-c55
+Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
/*
(c) 2010 Perttu Ahola <celeron55@gmail.com>
*/
Player::Player():
touching_ground(false),
+ in_water(false),
inventory(PLAYER_INVENTORY_SIZE),
peer_id(PEER_ID_NEW),
m_speed(0,0,0),
v3s16 pos_i = floatToInt(position);
+ /*
+ Check if player is in water
+ */
+ try{
+ if(in_water)
+ {
+ v3s16 pp = floatToInt(position + v3f(0,0,0));
+ in_water = content_liquid(map.getNode(pp).d);
+ }
+ else
+ {
+ v3s16 pp = floatToInt(position + v3f(0,BS/2,0));
+ in_water = content_liquid(map.getNode(pp).d);
+ }
+ }
+ catch(InvalidPositionException &e)
+ {
+ in_water = false;
+ }
+
// The frame length is limited to the player going 0.1*BS per call
f32 d = (float)BS * 0.15;
for(s16 y = oldpos_i.Y - 1; y <= oldpos_i.Y + 2; y++){
for(s16 z = oldpos_i.Z - 1; z <= oldpos_i.Z + 1; z++){
for(s16 x = oldpos_i.X - 1; x <= oldpos_i.X + 1; x++){
- //std::cout<<"with ("<<x<<","<<y<<","<<z<<"): ";
try{
- if(map.getNode(v3s16(x,y,z)).d == MATERIAL_AIR){
- //std::cout<<"air."<<std::endl;
+ if(content_walkable(map.getNode(v3s16(x,y,z)).d) == false){
continue;
}
}
RemotePlayer
*/
+#ifndef SERVER
+
RemotePlayer::RemotePlayer(
scene::ISceneNode* parent,
IrrlichtDevice *device,
m_text(NULL)
{
m_box = core::aabbox3d<f32>(-BS/2,0,-BS/2,BS/2,BS*2,BS/2);
-
+
if(parent != NULL && device != NULL)
{
// ISceneNode stores a member called SceneManager
}
}
+#endif
+
+#ifndef SERVER
/*
LocalPlayer
*/
}
if(control.jump)
{
- if(touching_ground){
+ if(touching_ground)
+ {
v3f speed = getSpeed();
speed.Y = 6.5*BS;
setSpeed(speed);
}
+ else if(in_water)
+ {
+ v3f speed = getSpeed();
+ speed.Y = 2.0*BS;
+ setSpeed(speed);
+ }
}
// The speed of the player (Y is ignored)
// Accelerate to target speed with maximum increment
accelerate(speed, inc);
}
-
+#endif