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

Function handleAutoPilot

src/bzflag/guiplaying.cpp:1618–1663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1616
1617
1618void handleAutoPilot(void* msg) {
1619 PlayerId id;
1620 msg = nboUnpackUInt8(msg, id);
1621
1622 uint8_t autopilot;
1623 nboUnpackUInt8(msg, autopilot);
1624
1625 Player* tank = lookupPlayer(id);
1626 if (!tank) {
1627 return;
1628 }
1629
1630 tank->setAutoPilot(autopilot != 0);
1631
1632 if (tank != myTank) {
1633 addMessage(tank, autopilot ? "Roger taking controls" : "Roger releasing controls");
1634 }
1635 else {
1636 if (autopilot == 0) {
1637 if (myTank->requestedAutopilot) {
1638 hud->setAlert(0, "autopilot disabled", 1.0f, true);
1639 }
1640 else {
1641 hud->setAlert(0, "manual drive enabled", 1.0f, true);
1642 }
1643
1644 // grab mouse
1645 if (shouldGrabMouse()) {
1646 mainWindow->grabMouse();
1647 }
1648
1649 myTank->requestedAutopilot = false;
1650 }
1651 else {
1652 if (myTank->requestedAutopilot) {
1653 hud->setAlert(0, "autopilot enabled", 1.0f, true);
1654 }
1655 else {
1656 hud->setAlert(0, "manual drive disabled", 1.0f, true);
1657 }
1658
1659 // ungrab mouse
1660 mainWindow->ungrabMouse();
1661 }
1662 }
1663}
1664
1665
1666

Callers 1

handleServerMessageFunction · 0.50

Calls 8

nboUnpackUInt8Function · 0.85
addMessageFunction · 0.85
setAlertMethod · 0.80
shouldGrabMouseFunction · 0.70
lookupPlayerFunction · 0.50
setAutoPilotMethod · 0.45
grabMouseMethod · 0.45
ungrabMouseMethod · 0.45

Tested by

no test coverage detected