summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2013-07-22 18:54:30 +0200
committerPilzAdam <pilzadam@minetest.net>2013-07-30 19:48:02 +0200
commit251e3e01c7350d94ea8dec0857e834d1ed84ac3f (patch)
tree4278247af930c66a1012e71d2ed5d65fea137347
parentff7c380d0eabf96a8677dfa3a94f0d18191572cf (diff)
downloadminetest-251e3e01c7350d94ea8dec0857e834d1ed84ac3f.tar.gz
minetest-251e3e01c7350d94ea8dec0857e834d1ed84ac3f.tar.bz2
minetest-251e3e01c7350d94ea8dec0857e834d1ed84ac3f.zip
Add support for setting stepheight for entities
-rw-r--r--doc/lua_api.txt1
-rw-r--r--src/clientserver.h1
-rw-r--r--src/content_cao.cpp3
-rw-r--r--src/content_sao.cpp4
-rw-r--r--src/object_properties.cpp5
-rw-r--r--src/object_properties.h1
-rw-r--r--src/script/common/c_content.cpp2
7 files changed, 12 insertions, 5 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index e5fbd7a3a..b5a9762b4 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1860,6 +1860,7 @@ Object Properties
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = false,
+ stepheight = 0,
}
Entity definition (register_entity)
diff --git a/src/clientserver.h b/src/clientserver.h
index 0d07d64ff..f490508c2 100644
--- a/src/clientserver.h
+++ b/src/clientserver.h
@@ -100,6 +100,7 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
TOSERVER_BREATH
range added to ItemDefinition
drowning, leveled and liquid_range added to ContentFeatures
+ stepheight and collideWithObjects added to object properties
*/
#define LATEST_PROTOCOL_VERSION 21
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 925855288..bbee0bc83 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1150,12 +1150,11 @@ public:
box.MaxEdge *= BS;
collisionMoveResult moveresult;
f32 pos_max_d = BS*0.125; // Distance per iteration
- f32 stepheight = 0;
v3f p_pos = m_position;
v3f p_velocity = m_velocity;
v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(env,env->getGameDef(),
- pos_max_d, box, stepheight, dtime,
+ pos_max_d, box, m_prop.stepheight, dtime,
p_pos, p_velocity, p_acceleration,
this, m_prop.collideWithObjects);
// Apply results
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 6b3593ec7..90c4fa69c 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -505,14 +505,14 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
box.MaxEdge *= BS;
collisionMoveResult moveresult;
f32 pos_max_d = BS*0.25; // Distance per iteration
- f32 stepheight = 0; // Maximum climbable step height
v3f p_pos = m_base_position;
v3f p_velocity = m_velocity;
v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(),
- pos_max_d, box, stepheight, dtime,
+ pos_max_d, box, m_prop.stepheight, dtime,
p_pos, p_velocity, p_acceleration,
this, m_prop.collideWithObjects);
+
// Apply results
m_base_position = p_pos;
m_velocity = p_velocity;
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index c2debf328..1602f03f2 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -39,7 +39,8 @@ ObjectProperties::ObjectProperties():
initial_sprite_basepos(0,0),
is_visible(true),
makes_footstep_sound(false),
- automatic_rotate(0)
+ automatic_rotate(0),
+ stepheight(0)
{
textures.push_back("unknown_object.png");
colors.push_back(video::SColor(255,255,255,255));
@@ -100,6 +101,7 @@ void ObjectProperties::serialize(std::ostream &os) const
writeARGB8(os, colors[i]);
}
writeU8(os, collideWithObjects);
+ writeF1000(os,stepheight);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
}
@@ -133,6 +135,7 @@ void ObjectProperties::deSerialize(std::istream &is)
colors.push_back(readARGB8(is));
}
collideWithObjects = readU8(is);
+ stepheight = readF1000(is);
}catch(SerializationError &e){}
}
else
diff --git a/src/object_properties.h b/src/object_properties.h
index a0f5618d6..e8188cb60 100644
--- a/src/object_properties.h
+++ b/src/object_properties.h
@@ -44,6 +44,7 @@ struct ObjectProperties
bool is_visible;
bool makes_footstep_sound;
float automatic_rotate;
+ f32 stepheight;
ObjectProperties();
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index d97264009..ef0544400 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -188,6 +188,8 @@ void read_object_properties(lua_State *L, int index,
getboolfield(L, -1, "is_visible", prop->is_visible);
getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound);
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
+ getfloatfield(L, -1, "stepheight", prop->stepheight);
+ prop->stepheight*=BS;
}
/******************************************************************************/