components/prboom/p_spec.c
//
// P_CanUnlockGenDoor()
//
// Passed a generalized locked door linedef and a player, returns whether
// the player has the keys necessary to unlock that door.
//
// Note: The linedef passed MUST be a generalized locked door type
//       or results are undefined.
//
// jff 02/05/98 routine added to test for unlockability of
//  generalized locked doors
//
P_CanUnlockGenDoor()
Passed a generalized locked door linedef and a player, returns whether
the player has the keys necessary to unlock that door.

The linedef passed MUST be a generalized locked door type
or results are undefined.

jff 02/05/98 routine added to test for unlockability of
generalized locked doors
P_CanUnlockGenDoor () Passed a generalized locked door linedef and a player returns whether the player has the keys necessary to unlock that door . The linedef passed MUST be a generalized locked door type or results are undefined . jff 02 / 05 / 98 routine added to test for unlockability of generalized locked doors
boolean P_CanUnlockGenDoor
( line_t* line,
  player_t* player)
{
  int skulliscard = (line->special & LockedNKeys)>>LockedNKeysShift;
  switch((line->special & LockedKey)>>LockedKeyShift)
  {
    case AnyKey:
      if
      (
        !player->cards[it_redcard] &&
        !player->cards[it_redskull] &&
        !player->cards[it_bluecard] &&
        !player->cards[it_blueskull] &&
        !player->cards[it_yellowcard] &&
        !player->cards[it_yellowskull]
      )
      {
        player->message = s_PD_ANY; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case RCard:
      if
      (
        !player->cards[it_redcard] &&
        (!skulliscard || !player->cards[it_redskull])
      )
      {
        player->message = skulliscard? s_PD_REDK : s_PD_REDC; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case BCard:
      if
      (
        !player->cards[it_bluecard] &&
        (!skulliscard || !player->cards[it_blueskull])
      )
      {
        player->message = skulliscard? s_PD_BLUEK : s_PD_BLUEC; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case YCard:
      if
      (
        !player->cards[it_yellowcard] &&
        (!skulliscard || !player->cards[it_yellowskull])
      )
      {
        player->message = skulliscard? s_PD_YELLOWK : s_PD_YELLOWC; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case RSkull:
      if
      (
        !player->cards[it_redskull] &&
        (!skulliscard || !player->cards[it_redcard])
      )
      {
        player->message = skulliscard? s_PD_REDK : s_PD_REDS; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case BSkull:
      if
      (
        !player->cards[it_blueskull] &&
        (!skulliscard || !player->cards[it_bluecard])
      )
      {
        player->message = skulliscard? s_PD_BLUEK : s_PD_BLUES; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case YSkull:
      if
      (
        !player->cards[it_yellowskull] &&
        (!skulliscard || !player->cards[it_yellowcard])
      )
      {
        player->message = skulliscard? s_PD_YELLOWK : s_PD_YELLOWS; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
    case AllKeys:
      if
      (
        !skulliscard &&
        (
          !player->cards[it_redcard] ||
          !player->cards[it_redskull] ||
          !player->cards[it_bluecard] ||
          !player->cards[it_blueskull] ||
          !player->cards[it_yellowcard] ||
          !player->cards[it_yellowskull]
        )
      )
      {
        player->message = s_PD_ALL6; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      if
      (
        skulliscard &&
        (
          (!player->cards[it_redcard] &&
            !player->cards[it_redskull]) ||
          (!player->cards[it_bluecard] &&
            !player->cards[it_blueskull]) ||
          (!player->cards[it_yellowcard] &&
            !player->cards[it_yellowskull])
        )
      )
      {
        player->message = s_PD_ALL3; 
        S_StartSound(player->mo,sfx_oof);             
        return false;
      }
      break;
  }
  return true;
}
boolean P_CanUnlockGenDoor ( line_t * line , player_t * player ) { int skulliscard = ( line -> special & LockedNKeys ) >> LockedNKeysShift ; switch ( ( line -> special & LockedKey ) >> LockedKeyShift ) { case AnyKey : if ( ! player -> cards [ it_redcard ] && ! player -> cards [ it_redskull ] && ! player -> cards [ it_bluecard ] && ! player -> cards [ it_blueskull ] && ! player -> cards [ it_yellowcard ] && ! player -> cards [ it_yellowskull ] ) { player -> message = s_PD_ANY ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case RCard : if ( ! player -> cards [ it_redcard ] && ( ! skulliscard || ! player -> cards [ it_redskull ] ) ) { player -> message = skulliscard ? s_PD_REDK : s_PD_REDC ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case BCard : if ( ! player -> cards [ it_bluecard ] && ( ! skulliscard || ! player -> cards [ it_blueskull ] ) ) { player -> message = skulliscard ? s_PD_BLUEK : s_PD_BLUEC ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case YCard : if ( ! player -> cards [ it_yellowcard ] && ( ! skulliscard || ! player -> cards [ it_yellowskull ] ) ) { player -> message = skulliscard ? s_PD_YELLOWK : s_PD_YELLOWC ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case RSkull : if ( ! player -> cards [ it_redskull ] && ( ! skulliscard || ! player -> cards [ it_redcard ] ) ) { player -> message = skulliscard ? s_PD_REDK : s_PD_REDS ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case BSkull : if ( ! player -> cards [ it_blueskull ] && ( ! skulliscard || ! player -> cards [ it_bluecard ] ) ) { player -> message = skulliscard ? s_PD_BLUEK : s_PD_BLUES ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case YSkull : if ( ! player -> cards [ it_yellowskull ] && ( ! skulliscard || ! player -> cards [ it_yellowcard ] ) ) { player -> message = skulliscard ? s_PD_YELLOWK : s_PD_YELLOWS ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; case AllKeys : if ( ! skulliscard && ( ! player -> cards [ it_redcard ] || ! player -> cards [ it_redskull ] || ! player -> cards [ it_bluecard ] || ! player -> cards [ it_blueskull ] || ! player -> cards [ it_yellowcard ] || ! player -> cards [ it_yellowskull ] ) ) { player -> message = s_PD_ALL6 ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } if ( skulliscard && ( ( ! player -> cards [ it_redcard ] && ! player -> cards [ it_redskull ] ) || ( ! player -> cards [ it_bluecard ] && ! player -> cards [ it_blueskull ] ) || ( ! player -> cards [ it_yellowcard ] && ! player -> cards [ it_yellowskull ] ) ) ) { player -> message = s_PD_ALL3 ; S_StartSound ( player -> mo , sfx_oof ) ; return false ; } break ; } return true ; }
P_CanUnlockGenDoor()
Passed a generalized locked door linedef and a player, returns whether
the player has the keys necessary to unlock that door.
P_CanUnlockGenDoor () Passed a generalized locked door linedef and a player returns whether the player has the keys necessary to unlock that door .
// does this line special distinguish between skulls and keys? // determine for each case of lock type if player's keys are adequate // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98 // Ty 03/27/98 - externalized // killough 3/20/98