MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / process

Method process

bots/cplusplus/rcbot/RCRequests_Process.cpp:32–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32bool 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
77bool SetSpeedReq::process(RCRobotPlayer* rrp) {
78 rrp->nextSpeed = speed;

Callers

nothing calls this directly

Calls 15

GunHeatReplyClass · 0.85
TurnRemainingReplyClass · 0.85
ShotsBeginReplyClass · 0.85
ShotReplyClass · 0.85
ShotClass · 0.85
XReplyClass · 0.85
YReplyClass · 0.85
ZReplyClass · 0.85
WidthReplyClass · 0.85
LengthReplyClass · 0.85

Tested by

no test coverage detected