Skip to content

Commit

Permalink
FIXED calculate_ground_pos for cases where top-most object is not
Browse files Browse the repository at this point in the history
below center of character.

This also fixes render_zone issues with the recent wastesedge data,
as groundpos is also used to set Z position of mapview.
  • Loading branch information
ksterker committed Sep 12, 2012
1 parent ba8aa4c commit fb79c4e
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/world/moving.cc
Expand Up @@ -358,25 +358,33 @@ void moving::calculate_ground_pos ()
// sort according to their z-Order
ground_tiles.sort (z_order());

// the highest object will be our ground pos
ci = ground_tiles.begin ();
// find tile beneath character
for (ci = ground_tiles.begin (); ci != ground_tiles.end(); ci++)
{
MyShadow->cast_on (*ci);

MyShadow->cast_on (*ci);
// position of character's center relative to tile
s_int32 px = x() + placeable::length()/2 - (*ci)->center_min().x();
s_int32 py = y() + placeable::width()/2 - (*ci)->center_min().y();

// position of character's center relative to tile
s_int32 px = x() + placeable::length()/2 - (*ci)->center_min().x();
s_int32 py = y() + placeable::width()/2 - (*ci)->center_min().y();
if (px >= 0 && py >= 0 && px <= (*ci)->get_object()->solid_max_length() && py <= (*ci)->get_object()->solid_max_width())
{
// the highest object will be our new ground pos
GroundPos = (*ci)->center_min().z() + (*ci)->get_object()->get_surface_pos (px, py);

// get ground pos
GroundPos = (*ci)->center_min().z() + (*ci)->get_object()->get_surface_pos (px, py);
// get the terrain, if any
Terrain = (*ci)->get_object()->get_terrain();

// get the terrain, if any
Terrain = (*ci)->get_object()->get_terrain();
ci++;
break;
}
}

// apply remainder of shadow
for (ci++; ci != ground_tiles.end(); ci++)
while (ci != ground_tiles.end())
{
MyShadow->cast_on (*ci);
ci++;
}
}
else
Expand Down

0 comments on commit fb79c4e

Please sign in to comment.