| 30 | |
| 31 | |
| 32 | bool ExecuteReq::process(RCRobotPlayer* rrp) { |
| 33 | if (!rrp->isSteadyState()) { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | rrp->lastTickAt = BzTime::getCurrent().getSeconds(); |
| 38 | |
| 39 | if (rrp->pendingUpdates[RCRobotPlayer::speedUpdate]) { |
| 40 | rrp->speed = rrp->nextSpeed; |
| 41 | } |
| 42 | if (rrp->pendingUpdates[RCRobotPlayer::turnRateUpdate]) { |
| 43 | rrp->turnRate = rrp->nextTurnRate; |
| 44 | } |
| 45 | |
| 46 | if (rrp->pendingUpdates[RCRobotPlayer::distanceUpdate]) { |
| 47 | if (rrp->nextDistance < 0.0f) { |
| 48 | rrp->distanceForward = false; |
| 49 | } |
| 50 | else { |
| 51 | rrp->distanceForward = true; |
| 52 | } |
| 53 | rrp->distanceRemaining = (rrp->distanceForward ? 1 : -1) * rrp->nextDistance; |
| 54 | } |
| 55 | if (rrp->pendingUpdates[RCRobotPlayer::turnUpdate]) { |
| 56 | if (rrp->nextTurn < 0.0f) { |
| 57 | rrp->turnLeft = false; |
| 58 | } |
| 59 | else { |
| 60 | rrp->turnLeft = true; |
| 61 | } |
| 62 | rrp->turnRemaining = (rrp->turnLeft ? 1 : -1) * rrp->nextTurn * M_PI / 180.0f; /* We have to convert to radians! */ |
| 63 | } |
| 64 | |
| 65 | for (int i = 0; i < RCRobotPlayer::updateCount; ++i) { |
| 66 | rrp->pendingUpdates[i] = false; |
| 67 | } |
| 68 | |
| 69 | if (rrp->shoot) { |
| 70 | rrp->shoot = false; |
| 71 | rrp->fireShot(); |
| 72 | } |
| 73 | |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | bool SetSpeedReq::process(RCRobotPlayer* rrp) { |
| 78 | rrp->nextSpeed = speed; |
nothing calls this directly
no test coverage detected