- else
- {
- lpath = current->x - old->x;
- if(lpath < 0)
- lpath = -lpath;
- if(current->y - old->y > lpath || old->y - current->y > lpath)
- lpath = current->y - old->y;
- if(lpath < 0)
- lpath = -lpath;
- h = 3;
- xd = (current->x - old->x) / lpath;
- yd = (current->y - old->y) / lpath;
- }
-
- steps = (int)(lpath / (float)16);
-
- float orig_x = old->x;
- float orig_y = old->y;
- old->x += xd;
- old->y += yd;
-
- for(float i = 0; i <= lpath; old->x += xd, old->y += yd, ++i)
- {
- if(steps > 0)
- {
- old->y += yd*16.;
- old->x += xd*16.;
- steps--;
- }
-
- if(collision_object_map(*old))
- {
- if(tileinfo.tile->slope_angle != 0)
- { // in case this is a slope, set the right Y position
- // left-right slope:
- if(tileinfo.tile->slope_angle > 0 && tileinfo.tile->slope_angle < M_PI/2)
- current->y = tileinfo.y - current->height +
- (tileinfo.x - current->x)*tan(M_PI/2 - tileinfo.tile->slope_angle)
- - 1;
- // right-left slope:
- if(tileinfo.tile->slope_angle > M_PI/2 && tileinfo.tile->slope_angle < M_PI)
- current->y = tileinfo.y - current->height +
- (current->x - tileinfo.x)*tan(M_PI - tileinfo.tile->slope_angle)
- - 1;
- }
- else
- {
- switch(h)
- {
- case 1:
- current->y = old->y - yd;
- while(collision_object_map(*current))
- current->y -= yd;
- break;
- case 2:
- current->x = old->x - xd;
- while(collision_object_map(*current))
- current->x -= xd;
- break;
- case 3:
- xt = current->x;
- yt = current->y;
- current->x = old->x - xd;
- current->y = old->y - yd;
- while(collision_object_map(*current))
- {
- current->x -= xd;
- current->y -= yd;
- }
-
- temp = current->x;
- current->x = xt;
- if(!collision_object_map(*current))
- break;
- current->x = temp;
- temp = current->y;
- current->y = yt;
-
- if(!collision_object_map(*current))
- {
- break;
- }
- else
- {
- current->y = temp;
- while(!collision_object_map(*current))
- current->y += yd;
- current->y -= yd;
- break;
- }
-
- break;
- default:
- break;
- }
- break;
- }
- }
- }
-
- if((xd > 0 && current->x < orig_x) || (xd < 0 && current->x > orig_x))
- current->x = orig_x;
- if((yd > 0 && current->y < orig_y) || (yd < 0 && current->y > orig_y))
- current->y = orig_y;
-
- *old = *current;
-}
-
-Tile* gettile(float x, float y)
-{
- const TileMap& tilemap = *Sector::current()->solids;
- return tilemap.get_tile_at(Vector(x, y));
-}
-
-bool issolid(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && (tile->attributes & Tile::SOLID);
-}
-
-bool isbrick(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && (tile->attributes & Tile::BRICK);
-}
-
-bool isice(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && (tile->attributes & Tile::ICE);
-}