Compare commits

..

5 Commits

Author SHA1 Message Date
Bas 35d088497c Added hanging explanation to lua doc 2013-04-11 02:51:32 +03:00
Bas 2dc5f134b3 Add special group hanging_node
- hanging_node: drops node(s) beneath it if they contain hanging_node group. Can only place node when top node is haning_node or walkable true
2013-04-11 02:48:46 +03:00
sapier dda2071cc0 fix bug in scriptapi line_of_sight
fix warnings for pathfinder debug traces
2013-04-10 16:50:24 -04:00
sapier 6e4fdf37ba fix objects colliding with its own collision boxes 2013-04-09 23:16:13 +02:00
sapier 7d002b60ff fix emergemanager memory leaks 2013-04-09 02:34:11 -04:00
10 changed files with 49 additions and 15 deletions

View File

@ -161,6 +161,17 @@ function nodeupdate_single(p, delay)
end end
end end
if minetest.get_node_group(n.name, "hanging_node") ~= 0 then
p_top = {x=p.x, y=p.y+1, z=p.z}
n_top = minetest.env:get_node(p_top)
if minetest.registered_nodes[n_top.name].walkable == true then return end
if minetest.get_node_group(n_top.name, "hanging_node") ~= 0 == false then
drop_attached_node(p)
nodeupdate(p)
end
return
end
if minetest.get_node_group(n.name, "attached_node") ~= 0 then if minetest.get_node_group(n.name, "attached_node") ~= 0 then
if not check_attached_node(p, n) then if not check_attached_node(p, n) then
drop_attached_node(p) drop_attached_node(p)

View File

@ -528,7 +528,8 @@ Special groups
- attached_node: if the node under it is not a walkable block the node will be - attached_node: if the node under it is not a walkable block the node will be
dropped as an item. If the node is wallmounted the dropped as an item. If the node is wallmounted the
wallmounted direction is checked. wallmounted direction is checked.
- hanging_node: drops node(s) beneath it if they contain hanging_node group.
Can only place node when top node is haning_node or walkable true
Known damage and digging time defining groups Known damage and digging time defining groups
---------------------------------------------- ----------------------------------------------
- crumbly: dirt, sand - crumbly: dirt, sand

View File

@ -192,7 +192,7 @@ bool wouldCollideWithCeiling(
collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
f32 pos_max_d, const aabb3f &box_0, f32 pos_max_d, const aabb3f &box_0,
f32 stepheight, f32 dtime, f32 stepheight, f32 dtime,
v3f &pos_f, v3f &speed_f, v3f &accel_f) v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self)
{ {
Map *map = &env->getMap(); Map *map = &env->getMap();
//TimeTaker tt("collisionMoveSimple"); //TimeTaker tt("collisionMoveSimple");
@ -300,9 +300,11 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
c_env->getActiveObjects(pos_f,distance * 1.5,clientobjects); c_env->getActiveObjects(pos_f,distance * 1.5,clientobjects);
for (int i=0; i < clientobjects.size(); i++) for (int i=0; i < clientobjects.size(); i++)
{ {
if ((self == 0) || (self != clientobjects[i].obj)) {
objects.push_back((ActiveObject*)clientobjects[i].obj); objects.push_back((ActiveObject*)clientobjects[i].obj);
} }
} }
}
else else
#endif #endif
{ {
@ -314,10 +316,12 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
for (std::set<u16>::iterator iter = s_objects.begin(); iter != s_objects.end(); iter++) for (std::set<u16>::iterator iter = s_objects.begin(); iter != s_objects.end(); iter++)
{ {
ServerActiveObject *current = s_env->getActiveObject(*iter); ServerActiveObject *current = s_env->getActiveObject(*iter);
if ((self == 0) || (self != current)) {
objects.push_back((ActiveObject*)current); objects.push_back((ActiveObject*)current);
} }
} }
} }
}
for (std::list<ActiveObject*>::const_iterator iter = objects.begin();iter != objects.end(); ++iter) for (std::list<ActiveObject*>::const_iterator iter = objects.begin();iter != objects.end(); ++iter)
{ {
@ -458,8 +462,9 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
if (is_object[nearest_boxindex]) { if (is_object[nearest_boxindex]) {
info.type = COLLISION_OBJECT; info.type = COLLISION_OBJECT;
} }
else else {
info.type = COLLISION_NODE; info.type = COLLISION_NODE;
}
info.node_p = node_positions[nearest_boxindex]; info.node_p = node_positions[nearest_boxindex];
info.bouncy = bouncy; info.bouncy = bouncy;
info.old_speed = speed_f; info.old_speed = speed_f;

View File

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class Map; class Map;
class IGameDef; class IGameDef;
class Environment; class Environment;
class ActiveObject;
enum CollisionType enum CollisionType
{ {
@ -70,7 +71,7 @@ struct collisionMoveResult
collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef, collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
f32 pos_max_d, const aabb3f &box_0, f32 pos_max_d, const aabb3f &box_0,
f32 stepheight, f32 dtime, f32 stepheight, f32 dtime,
v3f &pos_f, v3f &speed_f, v3f &accel_f); v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self=0);
#if 0 #if 0
// This doesn't seem to work and isn't used // This doesn't seem to work and isn't used

View File

@ -1152,7 +1152,7 @@ public:
v3f p_acceleration = m_acceleration; v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(env,env->getGameDef(), moveresult = collisionMoveSimple(env,env->getGameDef(),
pos_max_d, box, stepheight, dtime, pos_max_d, box, stepheight, dtime,
p_pos, p_velocity, p_acceleration); p_pos, p_velocity, p_acceleration,this);
// Apply results // Apply results
m_position = p_pos; m_position = p_pos;
m_velocity = p_velocity; m_velocity = p_velocity;

View File

@ -502,7 +502,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
v3f p_acceleration = m_acceleration; v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(), moveresult = collisionMoveSimple(m_env,m_env->getGameDef(),
pos_max_d, box, stepheight, dtime, pos_max_d, box, stepheight, dtime,
p_pos, p_velocity, p_acceleration); p_pos, p_velocity, p_acceleration,this);
// Apply results // Apply results
m_base_position = p_pos; m_base_position = p_pos;
m_velocity = p_velocity; m_velocity = p_velocity;

View File

@ -96,9 +96,23 @@ EmergeManager::~EmergeManager() {
delete emergethread[i]; delete emergethread[i];
delete mapgen[i]; delete mapgen[i];
} }
emergethread.clear();
for (unsigned int i = 0; i < mapgen.size(); i++)
delete mapgen[i];
mapgen.clear();
for (unsigned int i = 0; i < ores.size(); i++)
delete ores[i];
ores.clear();
for (std::map<std::string, MapgenFactory *>::iterator iter = mglist.begin();
iter != mglist.end(); iter ++) {
delete iter->second;
}
mglist.clear();
delete biomedef; delete biomedef;
delete params;
} }

View File

@ -2494,6 +2494,8 @@ ServerMap::~ServerMap()
delete chunk; delete chunk;
} }
#endif #endif
delete m_mgparams;
} }
bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos) bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)

View File

@ -687,9 +687,8 @@ bool pathfinder::update_all_costs( v3s16 ipos,
if ((g_pos2.totalcost < 0) || if ((g_pos2.totalcost < 0) ||
(g_pos2.totalcost > new_cost)) { (g_pos2.totalcost > new_cost)) {
int old_cost = g_pos2.totalcost;
DEBUG_OUT(LVL "Pathfinder: updating path at: "<< DEBUG_OUT(LVL "Pathfinder: updating path at: "<<
PPOS(ipos2) << " from: " << old_cost << " to "<< PPOS(ipos2) << " from: " << g_pos2.totalcost << " to "<<
new_cost << std::endl); new_cost << std::endl);
if (update_all_costs(ipos2,invert(directions[i]), if (update_all_costs(ipos2,invert(directions[i]),
new_cost,level)) { new_cost,level)) {
@ -847,9 +846,8 @@ bool pathfinder::update_cost_heuristic( v3s16 ipos,
if ((g_pos2.totalcost < 0) || if ((g_pos2.totalcost < 0) ||
(g_pos2.totalcost > new_cost)) { (g_pos2.totalcost > new_cost)) {
int old_cost = g_pos2.totalcost;
DEBUG_OUT(LVL "Pathfinder: updating path at: "<< DEBUG_OUT(LVL "Pathfinder: updating path at: "<<
PPOS(ipos2) << " from: " << old_cost << " to "<< PPOS(ipos2) << " from: " << g_pos2.totalcost << " to "<<
new_cost << " srcdir=" << new_cost << " srcdir=" <<
PPOS(invert(direction))<< std::endl); PPOS(invert(direction))<< std::endl);
if (update_cost_heuristic(ipos2,invert(direction), if (update_cost_heuristic(ipos2,invert(direction),

View File

@ -664,7 +664,9 @@ int EnvRef::l_line_of_sight(lua_State *L) {
if(lua_isnumber(L, 3)) if(lua_isnumber(L, 3))
stepsize = lua_tonumber(L, 3); stepsize = lua_tonumber(L, 3);
return (env->line_of_sight(pos1,pos2,stepsize)); lua_pushboolean(L, env->line_of_sight(pos1,pos2,stepsize));
return 1;
} }
int EnvRef::l_find_path(lua_State *L) int EnvRef::l_find_path(lua_State *L)