Does player firing
| 3358 | |
| 3359 | // Does player firing |
| 3360 | void MultiDoFirePlayerWB(uint8_t *data) { |
| 3361 | int count = 0, ok_to_fire = 1; |
| 3362 | |
| 3363 | // Skip header stuff |
| 3364 | SKIP_HEADER(data, &count); |
| 3365 | |
| 3366 | int pnum = MultiGetByte(data, &count); |
| 3367 | Player_fire_packet[pnum].wb_index = MultiGetByte(data, &count); |
| 3368 | Player_fire_packet[pnum].fire_mask = MultiGetByte(data, &count); |
| 3369 | Player_fire_packet[pnum].damage_scalar = MultiGetByte(data, &count); |
| 3370 | Player_fire_packet[pnum].reliable = MultiGetByte(data, &count); |
| 3371 | |
| 3372 | // Strip out quad data |
| 3373 | int wb_index = Player_fire_packet[pnum].wb_index; |
| 3374 | int quaded = wb_index & MPFF_QUADED; |
| 3375 | wb_index &= ~MPFF_QUADED; |
| 3376 | |
| 3377 | // Fire! |
| 3378 | float scalar = (float)Player_fire_packet[pnum].damage_scalar / 64.0; |
| 3379 | int ship_index = Players[pnum].ship_index; |
| 3380 | Objects[Players[pnum].objnum].dynamic_wb[wb_index].cur_firing_mask = Player_fire_packet[pnum].fire_mask; |
| 3381 | |
| 3382 | if (quaded) |
| 3383 | Objects[Players[pnum].objnum].dynamic_wb[wb_index].flags |= DWBF_QUAD; |
| 3384 | else |
| 3385 | Objects[Players[pnum].objnum].dynamic_wb[wb_index].flags &= ~DWBF_QUAD; |
| 3386 | |
| 3387 | if (Netgame.local_role == LR_SERVER) { |
| 3388 | // Check to see if this player is firing a weapon he doesn't have |
| 3389 | player *playp = &Players[pnum]; |
| 3390 | if (!(playp->weapon_flags & (1 << wb_index))) { |
| 3391 | mprintf(0, "Can't fire client weapon...flags=%d wb_index=%d\n", playp->weapon_flags, wb_index); |
| 3392 | ok_to_fire = 0; |
| 3393 | } |
| 3394 | |
| 3395 | if (!MultiEnoughAmmoToFire(pnum, wb_index)) |
| 3396 | ok_to_fire = 0; |
| 3397 | } |
| 3398 | |
| 3399 | if (ok_to_fire) { |
| 3400 | WBFireBattery(&Objects[Players[pnum].objnum], &Ships[ship_index].static_wb[wb_index], 0, wb_index, scalar); |
| 3401 | // Take off ammo |
| 3402 | MultiSubtractAmmoToFire(pnum, wb_index); |
| 3403 | } |
| 3404 | |
| 3405 | // Play cutoff sound if there is one |
| 3406 | int cutoff_sound = Ships[ship_index].firing_release_sound[wb_index]; |
| 3407 | if (cutoff_sound != -1) |
| 3408 | Sound_system.Play3dSound(cutoff_sound, &Objects[Players[pnum].objnum]); |
| 3409 | |
| 3410 | if ((Netgame.local_role == LR_SERVER && ok_to_fire) && |
| 3411 | ((!(Netgame.flags & NF_PEER_PEER)) || ((Netgame.flags & NF_PEER_PEER) && Player_fire_packet[pnum].reliable))) { |
| 3412 | #ifdef RELIABLE_SECONDARIES |
| 3413 | // How should we send this information? |
| 3414 | // secondary fire in a non-peer to peer game should get sent reliably |
| 3415 | if ((!(Netgame.flags & NF_PEER_PEER)) && (wb_index >= SECONDARY_INDEX) && (wb_index != FLARE_INDEX)) { |
| 3416 | Player_fire_packet[pnum].fired_on_this_frame = PFP_FIRED_RELIABLE; |
| 3417 | } else |
no test coverage detected