コード例 #1
0
WayPoint ResetCurrentWP (TaskForce tf)
{
    WayPoint	w;
    GridIndex	x,y,ux,uy;

    w = tf->GetCurrentUnitWP();
    while (w && w->GetWPDepartureTime() < Camp_GetCurrentTime())
    {
        if (w->GetWPFlags())				// Make sure we actually get here, it's important
        {
            w->GetWPLocation(&x,&y);
            tf->GetLocation(&ux,&uy);
            if (DistSqu(x,y,ux,uy) > 2.0F)
                return w;
            if (DoWPAction(tf,w))
                return tf->GetCurrentUnitWP();
        }
        w = w->GetNextWP();
        tf->SetCurrentUnitWP(w);
    }
    return w;
}
コード例 #2
0
// Unit within operation area, needs to take it's Waypoint's action
// This currently is only called if this waypoint has a flag set
WayPoint DoWPAction (TaskForce tf, WayPoint w)
{
    WayPoint	cw;

    if (!w || !tf)
        return NULL;

    // Check Actions
    /*	int action = w->GetWPAction();
    	switch (action)
    	{
    	case WP_NOTHING:
    	default:
    	break;
    	}
     */

    // Check Flags
    if (w->GetWPFlags() & WPF_REPEAT)
    {
        // Check if we've been here long enough
        if (Camp_GetCurrentTime() > w->GetWPDepartureTime())
        {
            // If so, go on to the next wp (adjust their times from now)
            tf->AdjustWayPoints();
        }
        else
        {
            // If not, restore previous WP and readjust times
            cw = w->GetPrevWP();
            tf->SetCurrentUnitWP(cw);
            tf->AdjustWayPoints();
            return cw;
        }
    }

    return NULL;
}