double path_get_direction(unsigned pathid, double t) //this is clearly via ass kind of thing, but something like this is needed at the end anyway
{
    double x1,y1,x2,y2;
    path_getXY(enigma::pathstructarray[pathid], x1, y1, t);
    path_getXY(enigma::pathstructarray[pathid], x2, y2, fmin(1,fmax(0,t+0.005f)));
    if (t<1)
        return fmod((atan2(y1-y2,x2-x1)*(180/M_PI))+360,360);
    else
        return fmod((atan2(y2-y1,x1-x2)*(180/M_PI))+360,360);
}
double path_get_direction(unsigned pathid, double t)
{
    cs_scalar x1,y1,x2,y2,p1,p2,precision;
    precision = 0.0005;

    p1 = t - precision;
    if (p1 < 0)
        p1 = 1 - fmod(-p1, 1);
    else
        p1 = fmod(p1, 1);

    p2 = t + precision;
    if (p2 < 0)
        p2 = 1 - fmod(-p2, 1);
    else
        p2 = fmod(p2, 1);

    path_getXY(enigma::pathstructarray[pathid], x1, y1, p1);
    path_getXY(enigma::pathstructarray[pathid], x2, y2, p2);
    return fmod((atan2(y1-y2,x2-x1)*(180/M_PI))+360,360);
}
double path_get_y(unsigned pathid, double t)
{
    double x,y;
    path_getXY(enigma::pathstructarray[pathid], x, y, t);
    return y;
}
cs_scalar path_get_x(unsigned pathid, double t)
{
    cs_scalar x,y;
    path_getXY(enigma::pathstructarray[pathid], x, y, t);
    return x;
}