Player collisionbox: Make settable

Breaks compatibility with old clients.
This commit is contained in:
TeTpaAka 2015-05-29 20:30:55 +02:00 committed by paramat
parent 5045bdc6d8
commit 49920cfe8d
4 changed files with 13 additions and 8 deletions

@ -972,7 +972,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
if (m_is_visible) {
int old_anim = player->last_animation;
float old_anim_speed = player->last_animation_speed;
m_position = player->getPosition() + v3f(0,BS,0);
m_position = player->getPosition();
m_velocity = v3f(0,0,0);
m_acceleration = v3f(0,0,0);
pos_translator.vect_show = m_position;
@ -1512,6 +1512,7 @@ void GenericCAO::processMessage(const std::string &data)
if (m_is_local_player) {
LocalPlayer *player = m_env->getLocalPlayer();
player->makes_footstep_sound = m_prop.makes_footstep_sound;
player->setCollisionbox(m_selection_box);
}
if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")

@ -784,7 +784,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
m_prop.hp_max = PLAYER_MAX_HP;
m_prop.physical = false;
m_prop.weight = 75;
m_prop.collisionbox = aabb3f(-0.3f, -1.0f, -0.3f, 0.3f, 0.75f, 0.3f);
m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);
// start of default appearance, this should be overwritten by LUA
m_prop.visual = "upright_sprite";
m_prop.visual_size = v2f(1, 2);
@ -856,7 +856,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
os << serializeString(m_player->getName()); // name
writeU8(os, 1); // is_player
writeS16(os, getId()); //id
writeV3F1000(os, m_base_position + v3f(0,BS*1,0));
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeS16(os, getHP());
@ -1009,7 +1009,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
if(isAttached()) // Just in case we ever do send attachment position too
pos = m_env->getActiveObject(m_attachment_parent_id)->getBasePosition();
else
pos = m_base_position + v3f(0,BS*1,0);
pos = m_base_position;
std::string str = gob_cmd_update_position(
pos,
v3f(0,0,0),
@ -1414,7 +1414,9 @@ bool PlayerSAO::checkMovementCheat()
bool PlayerSAO::getCollisionBox(aabb3f *toset) const
{
*toset = aabb3f(-0.3f * BS, 0.0f, -0.3f * BS, 0.3f * BS, 1.75f * BS, 0.3f * BS);
//update collision box
toset->MinEdge = m_prop.collisionbox.MinEdge * BS;
toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS;
toset->MinEdge += m_base_position;
toset->MaxEdge += m_base_position;

@ -611,8 +611,8 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
// Drop the item
ItemStack item1 = list_from->getItem(from_i);
item1.count = take_count;
if (PLAYER_TO_SA(player)->item_OnDrop(item1, player,
player->getBasePosition() + v3f(0,1,0))) {
if(PLAYER_TO_SA(player)->item_OnDrop(item1, player,
player->getBasePosition())) {
actually_dropped_count = take_count - item1.count;
if (actually_dropped_count == 0) {
@ -815,7 +815,7 @@ void ICraftAction::apply(InventoryManager *mgr,
u16 count = it->count;
do {
PLAYER_TO_SA(player)->item_OnDrop(*it, player,
player->getBasePosition() + v3f(0,1,0));
player->getBasePosition());
if (count >= it->count) {
errorstream << "Couldn't drop replacement stack " <<
it->getItemString() << " because drop loop didn't "

@ -140,6 +140,8 @@ public:
v3f getEyePosition() const { return m_position + getEyeOffset(); }
v3f getEyeOffset() const;
void setCollisionbox(const aabb3f &box) { m_collisionbox = box; }
private:
void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
void accelerateVertical(const v3f &target_speed, const f32 max_increase);