forked from Mirrorlandia_minetest/minetest
ServerRemotePlayer implements ServerActiveObject
This commit is contained in:
parent
ddaff2d653
commit
0b97ad8384
@ -29,5 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#define ACTIVEOBJECT_TYPE_LUAENTITY 7
|
#define ACTIVEOBJECT_TYPE_LUAENTITY 7
|
||||||
|
|
||||||
|
// Special type, not stored in active object lists
|
||||||
|
#define ACTIVEOBJECT_TYPE_PLAYER 100
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -144,16 +144,12 @@ void Player::deSerialize(std::istream &is)
|
|||||||
args.parseConfigLine(line);
|
args.parseConfigLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
//args.getS32("version");
|
//args.getS32("version"); // Version field value not used
|
||||||
std::string name = args.get("name");
|
std::string name = args.get("name");
|
||||||
updateName(name.c_str());
|
updateName(name.c_str());
|
||||||
/*std::string password = "";
|
setPitch(args.getFloat("pitch"));
|
||||||
if(args.exists("password"))
|
setYaw(args.getFloat("yaw"));
|
||||||
password = args.get("password");
|
setPosition(args.getV3F("position"));
|
||||||
updatePassword(password.c_str());*/
|
|
||||||
m_pitch = args.getFloat("pitch");
|
|
||||||
m_yaw = args.getFloat("yaw");
|
|
||||||
m_position = args.getV3F("position");
|
|
||||||
try{
|
try{
|
||||||
craftresult_is_preview = args.getBool("craftresult_is_preview");
|
craftresult_is_preview = args.getBool("craftresult_is_preview");
|
||||||
}catch(SettingNotFoundException &e){
|
}catch(SettingNotFoundException &e){
|
||||||
@ -164,20 +160,6 @@ void Player::deSerialize(std::istream &is)
|
|||||||
}catch(SettingNotFoundException &e){
|
}catch(SettingNotFoundException &e){
|
||||||
hp = 20;
|
hp = 20;
|
||||||
}
|
}
|
||||||
/*try{
|
|
||||||
std::string sprivs = args.get("privs");
|
|
||||||
if(sprivs == "all")
|
|
||||||
{
|
|
||||||
privs = PRIV_ALL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::istringstream ss(sprivs);
|
|
||||||
ss>>privs;
|
|
||||||
}
|
|
||||||
}catch(SettingNotFoundException &e){
|
|
||||||
privs = PRIV_DEFAULT;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
inventory.deSerialize(is);
|
inventory.deSerialize(is);
|
||||||
}
|
}
|
||||||
|
27
src/player.h
27
src/player.h
@ -179,12 +179,24 @@ public:
|
|||||||
Player on the server
|
Player on the server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ServerRemotePlayer : public Player
|
#include "serverobject.h"
|
||||||
|
#include "content_object.h" // Object type IDs
|
||||||
|
|
||||||
|
class ServerRemotePlayer : public Player, public ServerActiveObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerRemotePlayer()
|
ServerRemotePlayer():
|
||||||
|
ServerActiveObject(NULL, v3f(0,0,0))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
ServerRemotePlayer(ServerEnvironment *env, v3f pos_, u16 peer_id_,
|
||||||
|
const char *name_):
|
||||||
|
ServerActiveObject(env, pos_)
|
||||||
|
{
|
||||||
|
setPosition(pos_);
|
||||||
|
peer_id = peer_id_;
|
||||||
|
updateName(name_);
|
||||||
|
}
|
||||||
virtual ~ServerRemotePlayer()
|
virtual ~ServerRemotePlayer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -198,6 +210,17 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void setPosition(const v3f &position)
|
||||||
|
{
|
||||||
|
Player::setPosition(position);
|
||||||
|
ServerActiveObject::setBasePosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
ServerActiveObject interface
|
||||||
|
*/
|
||||||
|
u8 getType() const
|
||||||
|
{return ACTIVEOBJECT_TYPE_PLAYER;}
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4279,11 +4279,7 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id
|
|||||||
Create a new player
|
Create a new player
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
player = new ServerRemotePlayer();
|
// Add authentication stuff
|
||||||
//player->peer_id = c.peer_id;
|
|
||||||
//player->peer_id = PEER_ID_INEXISTENT;
|
|
||||||
player->peer_id = peer_id;
|
|
||||||
player->updateName(name);
|
|
||||||
m_authmanager.add(name);
|
m_authmanager.add(name);
|
||||||
m_authmanager.setPassword(name, password);
|
m_authmanager.setPassword(name, password);
|
||||||
m_authmanager.setPrivs(name,
|
m_authmanager.setPrivs(name,
|
||||||
@ -4294,11 +4290,11 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
infostream<<"Server: Finding spawn place for player \""
|
infostream<<"Server: Finding spawn place for player \""
|
||||||
<<player->getName()<<"\""<<std::endl;
|
<<name<<"\""<<std::endl;
|
||||||
|
|
||||||
v3f pos = findSpawnPos(m_env->getServerMap());
|
v3f pos = findSpawnPos(m_env->getServerMap());
|
||||||
|
|
||||||
player->setPosition(pos);
|
player = new ServerRemotePlayer(m_env, pos, peer_id, name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Add player to environment
|
Add player to environment
|
||||||
|
@ -72,13 +72,14 @@ public:
|
|||||||
Some more dynamic interface
|
Some more dynamic interface
|
||||||
*/
|
*/
|
||||||
virtual void setPos(v3f pos)
|
virtual void setPos(v3f pos)
|
||||||
{ setBasePosition(pos); }
|
{ setBasePosition(pos); }
|
||||||
// continuous: if true, object does not stop immediately at pos
|
// continuous: if true, object does not stop immediately at pos
|
||||||
virtual void moveTo(v3f pos, bool continuous)
|
virtual void moveTo(v3f pos, bool continuous)
|
||||||
{ setBasePosition(pos); }
|
{ setBasePosition(pos); }
|
||||||
// If object has moved less than this and data has not changed,
|
// If object has moved less than this and data has not changed,
|
||||||
// saving to disk may be omitted
|
// saving to disk may be omitted
|
||||||
virtual float getMinimumSavedMovement(){ return 2.0*BS; }
|
virtual float getMinimumSavedMovement()
|
||||||
|
{ return 2.0*BS; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Step object in time.
|
Step object in time.
|
||||||
|
Loading…
Reference in New Issue
Block a user