components/prboom/p_switch.c
//
// P_InitSwitchList()
//
// Only called at game initialization in order to list the set of switches
// and buttons known to the engine. This enables their texture to change
// when activated, and in the case of buttons, change back after a timeout.
//
// This routine modified to read its data from a predefined lump or
// PWAD lump called SWITCHES rather than a static table in this module to
// allow wad designers to insert or modify switches.
//
// Lump format is an array of byte packed switchlist_t structures, terminated
// by a structure with episode == -0. The lump can be generated from a
// text source file using SWANTBLS.EXE, distributed with the BOOM utils.
// The standard list of switches and animations is contained in the example
// source text file DEFSWANI.DAT also in the BOOM util distribution.
//
// Rewritten by Lee Killough to remove limit 2/8/98
//
P_InitSwitchList()
Only called at game initialization in order to list the set of switches
and buttons known to the engine. This enables their texture to change
when activated, and in the case of buttons, change back after a timeout.

This routine modified to read its data from a predefined lump or
PWAD lump called SWITCHES rather than a static table in this module to
allow wad designers to insert or modify switches.

Lump format is an array of byte packed switchlist_t structures, terminated
by a structure with episode == -0. The lump can be generated from a
text source file using SWANTBLS.EXE, distributed with the BOOM utils.
The standard list of switches and animations is contained in the example
source text file DEFSWANI.DAT also in the BOOM util distribution.

Rewritten by Lee Killough to remove limit 2/8/98
P_InitSwitchList () Only called at game initialization in order to list the set of switches and buttons known to the engine . This enables their texture to change when activated and in the case of buttons change back after a timeout . This routine modified to read its data from a predefined lump or PWAD lump called SWITCHES rather than a static table in this module to allow wad designers to insert or modify switches . Lump format is an array of byte packed switchlist_t structures terminated by a structure with episode == - 0 . The lump can be generated from a text source file using SWANTBLS . EXE distributed with the BOOM utils . The standard list of switches and animations is contained in the example source text file DEFSWANI . DAT also in the BOOM util distribution . Rewritten by Lee Killough to remove limit 2 / 8 / 98
void P_InitSwitchList(void)
{
  int i, index = 0;
  int episode = (gamemode == registered || gamemode==retail) ?
                 2 : gamemode == commercial ? 3 : 1;
  const switchlist_t *alphSwitchList;         
  int lump = W_GetNumForName("SWITCHES"); 
  alphSwitchList = (const switchlist_t *)W_CacheLumpNum(lump);
  for (i=0;;i++)
  {
    if (index+1 >= max_numswitches)
      switchlist = realloc(switchlist, sizeof *switchlist *
          (max_numswitches = max_numswitches ? max_numswitches*2 : 8));
    if (SHORT(alphSwitchList[i].episode) <= episode) 
    {
      int texture1, texture2;
      if (!SHORT(alphSwitchList[i].episode))
        break;
      texture1 = R_CheckTextureNumForName(alphSwitchList[i].name1);
      if (texture1 == -1)
        lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
            alphSwitchList[i].name1);
      texture2 = R_CheckTextureNumForName(alphSwitchList[i].name2);
      if (texture2 == -1)
        lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
            alphSwitchList[i].name2);
      if (texture1 != -1 && texture2 != -1) {
        switchlist[index++] = texture1;
        switchlist[index++] = texture2;
      }
    }
  }
  numswitches = index/2;
  switchlist[index] = -1;
  W_UnlockLumpNum(lump);
}
void P_InitSwitchList ( void ) { int i , index = 0 ; int episode = ( gamemode == registered || gamemode == retail ) ? 2 : gamemode == commercial ? 3 : 1 ; const switchlist_t * alphSwitchList ; int lump = W_GetNumForName ( " " ) ; alphSwitchList = ( const switchlist_t * ) W_CacheLumpNum ( lump ) ; for ( i = 0 ; ; i ++ ) { if ( index + 1 >= max_numswitches ) switchlist = realloc ( switchlist , sizeof * switchlist * ( max_numswitches = max_numswitches ? max_numswitches * 2 : 8 ) ) ; if ( SHORT ( alphSwitchList [ i ] . episode ) <= episode ) { int texture1 , texture2 ; if ( ! SHORT ( alphSwitchList [ i ] . episode ) ) break ; texture1 = R_CheckTextureNumForName ( alphSwitchList [ i ] . name1 ) ; if ( texture1 == -1 ) lprintf ( LO_WARN , " \n " , alphSwitchList [ i ] . name1 ) ; texture2 = R_CheckTextureNumForName ( alphSwitchList [ i ] . name2 ) ; if ( texture2 == -1 ) lprintf ( LO_WARN , " \n " , alphSwitchList [ i ] . name2 ) ; if ( texture1 != -1 && texture2 != -1 ) { switchlist [ index ++ ] = texture1 ; switchlist [ index ++ ] = texture2 ; } } } numswitches = index / 2 ; switchlist [ index ] = -1 ; W_UnlockLumpNum ( lump ) ; }
P_InitSwitchList()
Only called at game initialization in order to list the set of switches
and buttons known to the engine.
P_InitSwitchList () Only called at game initialization in order to list the set of switches and buttons known to the engine .
//jff 3/23/98 pointer to switch table // cph - new wad lump handling //jff 3/23/98 read the switch table from a predefined lump //jff 5/11/98 endianess // Ignore switches referencing unknown texture names, instead of exiting. // Warn if either one is missing, but only add if both are valid.