| 30 | |
| 31 | |
| 32 | bool WorldPlayer::doEndShot(int ident, bool isHit, fvec3& pos) { |
| 33 | const int index = ident & 255; |
| 34 | const int salt = (ident >> 8) & 127; |
| 35 | |
| 36 | // special id used in some messages (and really shouldn't be sent here) |
| 37 | if (ident == -1) { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | // ignore bogus shots (those with a bad index or for shots that don't exist) |
| 42 | if (index < 0 || index >= (int)shots.size() || !shots[index]) { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | // ignore shots that already ending |
| 47 | if (shots[index]->isExpired() || shots[index]->isExpiring()) { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | // ignore shots that have the wrong salt. since we reuse shot indices |
| 52 | // it's possible for an old MsgShotEnd to arrive after we've started a |
| 53 | // new shot. that's where the salt comes in. it changes for each shot |
| 54 | // so we can identify an old shot from a new one. |
| 55 | if (salt != ((shots[index]->getShotId() >> 8) & 127)) { |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | // don't stop if it's because were hitting something and we don't stop |
| 60 | // when we hit something. |
| 61 | if (isHit && !shots[index]->isStoppedByHit()) { |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | // end it |
| 66 | pos = shots[index]->getPosition(); |
| 67 | shots[index]->setExpired(); |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | void WorldPlayer::updateShots(float dt) { |
nothing calls this directly
no test coverage detected