void P_BringUpWeapon (player_t *player) { FState *newstate; AWeapon *weapon; if (player->PendingWeapon == WP_NOCHANGE) { if (player->ReadyWeapon != NULL) { player->psprites[ps_weapon].sy = WEAPONTOP; P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetReadyState()); } return; } weapon = player->PendingWeapon; // If the player has a tome of power, use this weapon's powered up // version, if one is available. if (weapon != NULL && weapon->SisterWeapon && weapon->SisterWeapon->WeaponFlags & WIF_POWERED_UP && player->mo->FindInventory (RUNTIME_CLASS(APowerWeaponLevel2), true)) { weapon = weapon->SisterWeapon; } if (weapon != NULL) { if (weapon->UpSound) { S_Sound (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM); } newstate = weapon->GetUpState (); player->refire = 0; } else { newstate = NULL; } player->PendingWeapon = WP_NOCHANGE; player->ReadyWeapon = weapon; player->psprites[ps_weapon].sy = player->cheats & CF_INSTANTWEAPSWITCH ? WEAPONTOP : WEAPONBOTTOM; P_SetPsprite (player, ps_weapon, newstate); // make sure that the previous weapon's flash state is terminated. // When coming here from a weapon drop it may still be active. P_SetPsprite(player, ps_flash, NULL); for(unsigned j = ps_user1; j <= NUMUSERPSPRITES; j++) { P_SetPsprite(player, j, NULL); } player->mo->weaponspecial = 0; }
void P_BringUpWeapon (player_t *player) { AWeapon *weapon; if (player->PendingWeapon == WP_NOCHANGE) { if (player->ReadyWeapon != nullptr) { player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP; P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState()); } return; } weapon = player->PendingWeapon; // If the player has a tome of power, use this weapon's powered up // version, if one is available. if (weapon != nullptr && weapon->SisterWeapon && weapon->SisterWeapon->WeaponFlags & WIF_POWERED_UP && player->mo->FindInventory (RUNTIME_CLASS(APowerWeaponLevel2), true)) { weapon = weapon->SisterWeapon; } player->PendingWeapon = WP_NOCHANGE; player->ReadyWeapon = weapon; player->mo->weaponspecial = 0; if (weapon != nullptr) { if (weapon->UpSound) { S_Sound (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM); } player->refire = 0; player->GetPSprite(PSP_WEAPON)->y = player->cheats & CF_INSTANTWEAPSWITCH ? WEAPONTOP : WEAPONBOTTOM; // make sure that the previous weapon's flash state is terminated. // When coming here from a weapon drop it may still be active. P_SetPsprite(player, PSP_FLASH, nullptr); P_SetPsprite(player, PSP_WEAPON, weapon->GetUpState()); } }