3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "irrlichttypes.h"
24 #include "inventory.h"
26 #define PLAYERNAME_SIZE 20
28 #define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
39 Player(IGameDef *gamedef);
40 virtual ~Player() = 0;
42 virtual void move(f32 dtime, Map &map, f32 pos_max_d)
50 void setSpeed(v3f speed)
55 // Y direction is ignored
56 void accelerate(v3f target_speed, f32 max_increase);
63 v3s16 getLightPosition() const;
67 // This is at the height of the eyes of the current figure
68 // return v3f(0, BS*1.5, 0);
69 // This is more like in minecraft
70 if(camera_barely_in_ceiling)
71 return v3f(0,BS*1.5,0);
73 return v3f(0,BS*1.625,0);
78 return m_position + getEyeOffset();
81 virtual void setPosition(const v3f &position)
83 m_position = position;
86 void setPitch(f32 pitch)
91 virtual void setYaw(f32 yaw)
108 return -1.0 * m_pitch * core::DEGTORAD;
113 return (m_yaw + 90.) * core::DEGTORAD;
116 void updateName(const char *name)
118 snprintf(m_name, PLAYERNAME_SIZE, "%s", name);
121 const char * getName() const
126 virtual bool isLocal() const
128 virtual PlayerSAO *getPlayerSAO()
130 virtual void setPlayerSAO(PlayerSAO *sao)
134 serialize() writes a bunch of text that can contain
135 any characters except a '\0', and such an ending that
136 deSerialize stops reading exactly at the right point.
138 void serialize(std::ostream &os);
139 void deSerialize(std::istream &is);
141 bool touching_ground;
142 // This oscillates so that the player jumps a bit above the surface
144 // This is more stable and defines the maximum speed of the player
145 bool in_water_stable;
148 bool camera_barely_in_ceiling;
152 // In creative mode, this is the invisible backup inventory
162 char m_name[PLAYERNAME_SIZE];
172 class RemotePlayer : public Player
175 RemotePlayer(IGameDef *gamedef): Player(gamedef), m_sao(0) {}
176 virtual ~RemotePlayer() {}
178 PlayerSAO *getPlayerSAO()
180 void setPlayerSAO(PlayerSAO *sao)
182 void setPosition(const v3f &position);