1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

added PlayerSAO and RemotePlayer, removed ServerRemotePlayer

This commit is contained in:
Kahrl 2012-03-19 03:04:16 +01:00 committed by Perttu Ahola
parent 072c265c30
commit f8c3743991
20 changed files with 833 additions and 810 deletions

View file

@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h"
#include "gamedef.h"
#include "event.h"
#include "content_sao.h"
Player::Player(IGameDef *gamedef):
touching_ground(false),
@ -40,8 +41,7 @@ Player::Player(IGameDef *gamedef):
is_climbing(false),
swimming_up(false),
inventory(gamedef->idef()),
inventory_backup(NULL),
hp(20),
hp(PLAYER_MAX_HP),
peer_id(PEER_ID_INEXISTENT),
// protected
m_gamedef(gamedef),
@ -51,16 +51,6 @@ Player::Player(IGameDef *gamedef):
m_position(0,0,0)
{
updateName("<not set>");
resetInventory();
}
Player::~Player()
{
delete inventory_backup;
}
void Player::resetInventory()
{
inventory.clear();
inventory.addList("main", PLAYER_INVENTORY_SIZE);
inventory.addList("craft", 9);
@ -68,6 +58,10 @@ void Player::resetInventory()
inventory.addList("craftresult", 1);
}
Player::~Player()
{
}
// Y direction is ignored
void Player::accelerate(v3f target_speed, f32 max_increase)
{
@ -126,12 +120,7 @@ void Player::serialize(std::ostream &os)
os<<"PlayerArgsEnd\n";
// If actual inventory is backed up due to creative mode, save it
// instead of the dummy creative mode inventory
if(inventory_backup)
inventory_backup->serialize(os);
else
inventory.serialize(os);
inventory.serialize(os);
}
void Player::deSerialize(std::istream &is)
@ -779,3 +768,13 @@ v3s16 LocalPlayer::getStandingNodePos()
#endif
/*
RemotePlayer
*/
void RemotePlayer::setPosition(const v3f &position)
{
Player::setPosition(position);
if(m_sao)
m_sao->setBasePosition(position);
}