Example #1
0
void P_ChangeSwitchTexture(line_t *line, int useAgain)
{
	int	texTop;
	int	texMid;
	int	texBot;
	int	i;

	texTop = sides[line->sidenum[0]].toptexture;
	texMid = sides[line->sidenum[0]].midtexture;
	texBot = sides[line->sidenum[0]].bottomtexture;

	for (i = 0; i < numswitches*2; i++)
	{
		if (switchlist[i] == texTop)
		{
			S_StartSound((mobj_t *)(void *)&line->frontsector->soundorg,
							alphSwitchList[i/2].soundID);
			sides[line->sidenum[0]].toptexture = switchlist[i^1];
			if (useAgain)
			{
				P_StartButton(line, SWTCH_TOP, switchlist[i], BUTTONTIME);
			}
			return;
		}
		else if (switchlist[i] == texMid)
		{
			S_StartSound((mobj_t *)(void *)&line->frontsector->soundorg,
							alphSwitchList[i/2].soundID);
			sides[line->sidenum[0]].midtexture = switchlist[i^1];
			if (useAgain)
			{
				P_StartButton(line, SWTCH_MIDDLE, switchlist[i], BUTTONTIME);
			}
			return;
		}
		else if (switchlist[i] == texBot)
		{
			S_StartSound((mobj_t *)(void *)&line->frontsector->soundorg,
							alphSwitchList[i/2].soundID);
			sides[line->sidenum[0]].bottomtexture = switchlist[i^1];
			if (useAgain)
			{
				P_StartButton(line, SWTCH_BOTTOM, switchlist[i], BUTTONTIME);
			}
			return;
		}
	}
}
Example #2
0
//==================================================================
//
//	Function that changes wall texture.
//	Tell it if switch is ok to use again (1=yes, it's a button).
//
//==================================================================
void P_ChangeSwitchTexture(line_t *line,int useAgain)
{
	int	texTop;
	int	texMid;
	int	texBot;
	int	i;
	int	sound;
	
	if (!useAgain)
		line->special = 0;

	texTop = sides[line->sidenum[0]].toptexture;
	texMid = sides[line->sidenum[0]].midtexture;
	texBot = sides[line->sidenum[0]].bottomtexture;

	sound = sfx_switch;
	//if (line->special == 11) // EXIT SWITCH?
	//	sound = sfx_swtchx;
	
	for (i = 0;i < numswitches*2;i++)
		if (switchlist[i] == texTop)
		{
			S_StartSound(buttonlist->soundorg,sound);
			sides[line->sidenum[0]].toptexture = switchlist[i^1];
			if (useAgain)
				P_StartButton(line,top,switchlist[i],BUTTONTIME);
			return;
		}
		else
		if (switchlist[i] == texMid)
		{
			S_StartSound(buttonlist->soundorg,sound);
			sides[line->sidenum[0]].midtexture = switchlist[i^1];
			if (useAgain)
				P_StartButton(line, middle,switchlist[i],BUTTONTIME);
			return;
		}
		else
		if (switchlist[i] == texBot)
		{
			S_StartSound(buttonlist->soundorg,sound);
			sides[line->sidenum[0]].bottomtexture = switchlist[i^1];
			if (useAgain)
				P_StartButton(line, bottom,switchlist[i],BUTTONTIME);
			return;
		}
}
Example #3
0
//
// Function that changes wall texture.
// Tell it if switch is ok to use again (1=yes, it's a button).
//
void P_ChangeSwitchTexture(line_t *line, int useAgain)
{
    int         i = 0;
    int         swtex;
    side_t      *side = &sides[line->sidenum[0]];
    short       texTop = side->toptexture;
    short       texMid = side->midtexture;
    short       texBot = side->bottomtexture;

    // don't zero line->special until after exit switch test
    if (!useAgain)
        line->special = 0;

    // search for a texture to change
    do
    {
        swtex = switchlist[i];

        if (swtex == texTop)
        {
            S_StartSound((mobj_t *)&line->soundorg, sfx_swtchn);
            if (useAgain)
                P_StartButton(line, top, swtex, BUTTONTIME);
            side->toptexture = switchlist[i ^ 1];
            break;
        }
        else if (swtex == texMid)
        {
            S_StartSound((mobj_t *)&line->soundorg, sfx_swtchn);
            if (useAgain)
                P_StartButton(line, middle, swtex, BUTTONTIME);
            side->midtexture = switchlist[i ^ 1];
            break;
        }
        else if (swtex == texBot)
        {
            S_StartSound((mobj_t *)&line->soundorg, sfx_swtchn);
            if (useAgain)
                P_StartButton(line, bottom, swtex, BUTTONTIME);
            side->bottomtexture = switchlist[i ^ 1];
            break;
        }
        i++;
    } while (swtex != -1);
}
Example #4
0
//
// P_ChangeSwitchTexture()
//
// Function that changes switch wall texture on activation.
//
// Passed the line which the switch is on, and whether its retriggerable.
// If not retriggerable, this function clears the line special to insure that
//
// No return
//
void P_ChangeSwitchTexture
( line_t*       line,
  int           useAgain )
{
  /* Rearranged a bit to avoid too much code duplication */
  mobj_t  *soundorg;
  int     i, sound;
  short   *texture, *ttop, *tmid, *tbot;
  bwhere_e position;

  ttop = &sides[line->sidenum[0]].toptexture;
  tmid = &sides[line->sidenum[0]].midtexture;
  tbot = &sides[line->sidenum[0]].bottomtexture;

  sound = sfx_swtchn;
  /* use the sound origin of the linedef (its midpoint)
   * unless in a compatibility mode */
  soundorg = (mobj_t *)&line->soundorg;
  if (comp[comp_sound] || compatibility_level < prboom_6_compatibility) {
    /* usually NULL, unless there is another button already pressed in,
     * in which case it's the sound origin of that button press... */
    soundorg = buttonlist->soundorg;
  } else {
    // EXIT SWITCH?
    /* don't do this unless you're in a compatibility mode */
    // proff - this works as advertised, but I don't like the sound
    // if (line->special == 11 || line->special == 51) // exit or secret exit
    //   sound = sfx_swtchx;
  }

  /* don't zero line->special until after exit switch test */
  if (!useAgain)
    line->special = 0;

  /* search for a texture to change */
  texture = NULL; position = 0;
  for (i = 0;i < numswitches*2;i++) { /* this could be more efficient... */
    if (switchlist[i] == *ttop) {
      texture = ttop; position = top; break;
    } else if (switchlist[i] == *tmid) {
      texture = tmid; position = middle; break;
    } else if (switchlist[i] == *tbot) {
      texture = tbot; position = bottom; break;
    }
  }
  if (texture == NULL)
    return; /* no switch texture was found to change */
  *texture = switchlist[i^1];

  S_StartSound(soundorg, sound);

  if (useAgain)
    P_StartButton(line, position, switchlist[i], BUTTONTIME);
}
Example #5
0
//
// P_UnArchiveSpecials
//
void P_UnArchiveSpecials(void)
{
    // read in saved thinkers
    while (true)
    {
        byte    tclass = saveg_read8();

        switch (tclass)
        {
            case tc_endspecials:
                // end of list
                return;

            case tc_ceiling:
            {
                ceiling_t   *ceiling = Z_Malloc(sizeof(*ceiling), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_ceiling_t(ceiling);
                ceiling->sector->ceilingdata = ceiling;
                ceiling->thinker.function = T_MoveCeiling;
                P_AddThinker(&ceiling->thinker);
                P_AddActiveCeiling(ceiling);
                break;
            }

            case tc_door:
            {
                vldoor_t    *door = Z_Malloc(sizeof(*door), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_vldoor_t(door);
                door->sector->ceilingdata = door;
                door->thinker.function = T_VerticalDoor;
                P_AddThinker(&door->thinker);
                break;
            }

            case tc_floor:
            {
                floormove_t *floor = Z_Malloc(sizeof(*floor), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_floormove_t(floor);
                floor->sector->floordata = floor;
                floor->thinker.function = T_MoveFloor;
                P_AddThinker(&floor->thinker);
                break;
            }

            case tc_plat:
            {
                plat_t  *plat = Z_Malloc(sizeof(*plat), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_plat_t(plat);
                plat->sector->floordata = plat;
                P_AddThinker(&plat->thinker);
                P_AddActivePlat(plat);
                break;
            }

            case tc_flash:
            {
                lightflash_t    *flash = Z_Malloc(sizeof(*flash), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_lightflash_t(flash);
                flash->thinker.function = T_LightFlash;
                P_AddThinker(&flash->thinker);
                break;
            }

            case tc_strobe:
            {
                strobe_t    *strobe = Z_Malloc(sizeof(*strobe), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_strobe_t(strobe);
                strobe->thinker.function = T_StrobeFlash;
                P_AddThinker(&strobe->thinker);
                break;
            }

            case tc_glow:
            {
                glow_t  *glow = Z_Malloc(sizeof(*glow), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_glow_t(glow);
                glow->thinker.function = T_Glow;
                P_AddThinker(&glow->thinker);
                break;
            }

            case tc_fireflicker:
            {
                fireflicker_t   *fireflicker = Z_Malloc(sizeof(*fireflicker), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_fireflicker_t(fireflicker);
                fireflicker->thinker.function = T_FireFlicker;
                P_AddThinker(&fireflicker->thinker);
                break;
            }

            case tc_elevator:
            {
                elevator_t  *elevator = Z_Malloc(sizeof(*elevator), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_elevator_t(elevator);
                elevator->sector->ceilingdata = elevator;
                elevator->thinker.function = T_MoveElevator;
                P_AddThinker(&elevator->thinker);
                break;
            }

            case tc_scroll:
            {
                scroll_t    *scroll = Z_Malloc(sizeof(*scroll), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_scroll_t(scroll);
                scroll->thinker.function = T_Scroll;
                P_AddThinker(&scroll->thinker);
                break;
            }

            case tc_pusher:
            {
                pusher_t    *pusher = Z_Malloc(sizeof(*pusher), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_pusher_t(pusher);
                pusher->thinker.function = T_Pusher;
                pusher->source = P_GetPushThing(pusher->affectee);
                P_AddThinker(&pusher->thinker);
                break;
            }

            case tc_button:
            {
                button_t    *button = Z_Malloc(sizeof(*button), PU_LEVEL, NULL);

                saveg_read_pad();
                saveg_read_button_t(button);
                P_StartButton(button->line, button->where, button->btexture, button->btimer);
                break;
            }

            default:
                I_Error("This savegame is invalid.");
        }
    }
}
Example #6
0
//
// Function that changes wall texture.
// Tell it if switch is ok to use again (1=yes, it's a button).
//
void P_ChangeSwitchTexture(line_t* line, int useAgain)
{
    int     texTop;
    int     texMid;
    int     texBot;
    int     i;
    int     sound;
    boolean breakglass; // villsa [STRIFE]
    switchlist_t* sl;   // villsa [STRIFE]

    breakglass = false; // villsa [STRIFE]

    texTop = sides[line->sidenum[0]].toptexture;
    texMid = sides[line->sidenum[0]].midtexture;
    texBot = sides[line->sidenum[0]].bottomtexture;

    sound = sfx_swtchn;

    // villsa [STRIFE] check for linetype 182 (break glass)
    if(line->special == 182)
    {
        line->flags &= ~ML_BLOCKING;
        breakglass = true;

        if(useAgain)
        {
            // haleyjd 09/21/10: Corrected (>> 16 == next field)
            texTop = 0;
            texBot = 0;
        }

        if(texMid) // haleyjd 09/21/10: Corrected (>> 16 == next field)
            useAgain = 0;

        sound = sfx_bglass;
    }

    if(!useAgain)
        line->special = 0;

    for(i = 0; i < numswitches*2; i++)
    {
        sl = &alphSwitchList[i / 2]; // villsa [STRIFE]

        if(switchlist[i] == texTop)
        {
            // villsa [STRIFE] set sound
            if(sl->sound)
                sound = sl->sound;

            S_StartSound(buttonlist->soundorg, sound);
            sides[line->sidenum[0]].toptexture = switchlist[i^1];

            if(useAgain)
                P_StartButton(line,top,switchlist[i],BUTTONTIME);

            if(breakglass)
                P_SpawnBrokenGlass(line);

            return;
        }
        else
        {
            if(switchlist[i] == texMid)
            {
                // villsa [STRIFE] set sound
                if(sl->sound)
                    sound = sl->sound;

                S_StartSound(buttonlist->soundorg,sound);
                sides[line->sidenum[0]].midtexture = switchlist[i^1];

                // villsa [STRIFE] affect second side of line
                // BUG: will crash if 1S line is marked with TWOSIDED flag!
                if(line->flags & ML_TWOSIDED)
                    sides[line->sidenum[1]].midtexture = switchlist[i^1];

                if(useAgain)
                    P_StartButton(line, middle,switchlist[i],BUTTONTIME);

                // villsa [STRIFE]: Mines Transmitter hack
                if(sound == sfx_firxpl)
                {
                    breakglass = true;

                    // give quest flag 29 to player
                    players[0].questflags |= QF_QUEST29;

                    // give stamina/accuracy items
                    if(!netgame)
                    {
                        P_GiveItemToPlayer(players, SPR_TOKN, MT_TOKEN_STAMINA);
                        P_GiveItemToPlayer(players, SPR_TOKN, MT_TOKEN_NEW_ACCURACY);
                    }

                }

                // villsa [STRIFE]
                if(breakglass || sound == sfx_bglass)
                    P_SpawnBrokenGlass(line);

                return;
            }
            else
            {
                if(switchlist[i] == texBot)
                {
                    // villsa [STRIFE] set sound
                    if(sl->sound)
                        sound = sl->sound;

                    S_StartSound(buttonlist->soundorg,sound);
                    sides[line->sidenum[0]].bottomtexture = switchlist[i^1];

                    if(useAgain)
                        P_StartButton(line, bottom,switchlist[i],BUTTONTIME);

                    if(breakglass)
                        P_SpawnBrokenGlass(line);

                    return;
                }
            }
        }
    }
}
Example #7
0
//
// P_ChangeSwitchTexture()
//
// Function that changes switch wall texture on activation.
//
// Passed the line which the switch is on, and whether its retriggerable.
// If not retriggerable, this function clears the line special to insure that
//
// No return
//
void P_ChangeSwitchTexture
( line_t*       line,
  int           useAgain )
{
  int     texTop;
  int     texMid;
  int     texBot;
  int     i;
  int     sound;

  if (!useAgain)
    line->special = 0;

  texTop = sides[line->sidenum[0]].toptexture;
  texMid = sides[line->sidenum[0]].midtexture;
  texBot = sides[line->sidenum[0]].bottomtexture;

  sound = sfx_swtchn;

  // EXIT SWITCH?
  if (line->special == 11)
    sound = sfx_swtchx;

  for (i = 0;i < numswitches*2;i++)
  {
    if (switchlist[i] == texTop)     // if an upper texture
    {
      S_StartSound(buttonlist->soundorg,sound);     // switch activation sound
      sides[line->sidenum[0]].toptexture = switchlist[i^1];       //chg texture

      if (useAgain)
        P_StartButton(line,top,switchlist[i],BUTTONTIME);         //start timer

      return;
    }
    else
    {
      if (switchlist[i] == texMid)   // if a normal texture
      {
        S_StartSound(buttonlist->soundorg,sound);   // switch activation sound
        sides[line->sidenum[0]].midtexture = switchlist[i^1];     //chg texture

        if (useAgain)
          P_StartButton(line, middle,switchlist[i],BUTTONTIME);   //start timer

        return;
      }
      else
      {
        if (switchlist[i] == texBot) // if a lower texture
        {
          S_StartSound(buttonlist->soundorg,sound); // switch activation sound
          sides[line->sidenum[0]].bottomtexture = switchlist[i^1];//chg texture

          if (useAgain)
            P_StartButton(line, bottom,switchlist[i],BUTTONTIME); //start timer

          return;
        }
      }
    }
  }
}