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

Function handlePlayerUpdate

src/clientbase/playing.cpp:1729–1770  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1727
1728
1729void handlePlayerUpdate(uint16_t code, void* msg) {
1730 double timestamp;
1731 PlayerId id;
1732 int32_t order;
1733 void* buf = msg;
1734
1735 buf = nboUnpackUInt8(buf, id); // peek! don't update the msg pointer
1736 buf = nboUnpackDouble(buf, timestamp); // peek
1737
1738 Player* tank = lookupPlayer(id);
1739 if (!tank || tank == myTank) {
1740 return;
1741 }
1742
1743 nboUnpackInt32(buf, order); // peek
1744 if (order <= tank->getOrder()) {
1745 return;
1746 }
1747 const short oldStatus = tank->getStatus();
1748 const float oldJumpJets = tank->getState().jumpJetsScale;
1749
1750 tank->unpack(msg, code); // now read
1751 const short newStatus = tank->getStatus();
1752 const float newJumpJets = tank->getState().jumpJetsScale;
1753
1754 if ((oldStatus & short(PlayerState::Exploding)) == 0 &&
1755 (newStatus & short(PlayerState::Exploding)) != 0) {
1756 // player has started exploding and we haven't gotten killed
1757 // message yet -- set explosion now, play sound later (when we
1758 // get killed message). status is already !Alive so make player
1759 // alive again, then call setExplode to kill him.
1760 tank->setStatus(newStatus | short(PlayerState::Alive));
1761 tank->setExplode(BzTime::getTick());
1762 // ROBOT -- play explosion now
1763 }
1764
1765 const bool oldJump = (oldStatus & short(PlayerState::JumpJets)) != 0;
1766 const bool newJump = (newStatus & short(PlayerState::JumpJets)) != 0;
1767 if (newJump && (!oldJump || (oldJumpJets < newJumpJets))) {
1768 eventHandler.PlayerJumped(*tank);
1769 }
1770}
1771
1772
1773void handleTangUpdate(uint16_t len, void* msg) {

Callers 1

handleServerMessageFunction · 0.85

Calls 11

nboUnpackUInt8Function · 0.85
nboUnpackDoubleFunction · 0.85
nboUnpackInt32Function · 0.85
setExplodeMethod · 0.80
lookupPlayerFunction · 0.70
getOrderMethod · 0.45
getStatusMethod · 0.45
getStateMethod · 0.45
unpackMethod · 0.45
setStatusMethod · 0.45
PlayerJumpedMethod · 0.45

Tested by

no test coverage detected