Skip to content

Commit 8787d2e

Browse files
JohnWayne1986est31
authored andcommittedSep 26, 2015
Fix falling through nodes on world load (fixes #2784)
On world load the collision code can not see node boxes, since the nodes have not been loaded. Thus it collided only at the next full node. However, standing on a slab on world load leaded to sinking into it until the world finished loading. Then one maybe fell further, if the node below was not walkable. Now, with this commit, when no node around the player has been loaded it simply does not move the player.
1 parent 776760a commit 8787d2e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎src/collision.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
245245
s16 max_y = MYMAX(oldpos_i.Y, newpos_i.Y) + (box_0.MaxEdge.Y / BS) + 1;
246246
s16 max_z = MYMAX(oldpos_i.Z, newpos_i.Z) + (box_0.MaxEdge.Z / BS) + 1;
247247

248+
bool any_position_valid = false;
249+
248250
for(s16 x = min_x; x <= max_x; x++)
249251
for(s16 y = min_y; y <= max_y; y++)
250252
for(s16 z = min_z; z <= max_z; z++)
@@ -257,6 +259,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
257259
if (is_position_valid) {
258260
// Object collides into walkable nodes
259261

262+
any_position_valid = true;
260263
const ContentFeatures &f = gamedef->getNodeDefManager()->get(n);
261264
if(f.walkable == false)
262265
continue;
@@ -289,6 +292,12 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
289292
is_object.push_back(false);
290293
}
291294
}
295+
296+
// Do not move if world has not loaded yet, since custom node boxes
297+
// are not available for collision detection.
298+
if (!any_position_valid)
299+
return result;
300+
292301
} // tt2
293302

294303
if(collideWithObjects)
@@ -298,7 +307,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
298307

299308
/* add object boxes to cboxes */
300309

301-
302310
std::vector<ActiveObject*> objects;
303311
#ifndef SERVER
304312
ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);

0 commit comments

Comments
 (0)
Please sign in to comment.