2 //**************************************************************************
4 //** p_switch.c : Heretic 2 : Raven Software, Corp.
11 //**************************************************************************
17 //==================================================================
19 // CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE
21 //==================================================================
22 switchlist_t alphSwitchList[] =
24 { "SW_1_UP", "SW_1_DN", SFX_SWITCH1 },
25 { "SW_2_UP", "SW_2_DN", SFX_SWITCH1 },
26 { "VALVE1", "VALVE2", SFX_VALVE_TURN }, // Not in in demo wad - KR
27 { "SW51_OFF", "SW51_ON", SFX_SWITCH2 }, //
28 { "SW52_OFF", "SW52_ON", SFX_SWITCH2 },
29 { "SW53_UP", "SW53_DN", SFX_ROPE_PULL }, //
30 { "PUZZLE5", "PUZZLE9", SFX_SWITCH1 }, //
31 { "PUZZLE6", "PUZZLE10", SFX_SWITCH1 }, //
32 { "PUZZLE7", "PUZZLE11", SFX_SWITCH1 }, //
33 { "PUZZLE8", "PUZZLE12", SFX_SWITCH1 }, //
37 int switchlist[MAXSWITCHES * 2];
39 button_t buttonlist[MAXBUTTONS];
46 = Only called at game initialization
51 void P_InitSwitchList(void)
56 for (index = 0, i = 0; i < MAXSWITCHES; i++)
58 if(!alphSwitchList[i].soundID)
60 numswitches = index/2;
61 switchlist[index] = -1;
64 switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1);
65 switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2);
69 //==================================================================
71 // Start a button counting down till it turns off.
73 //==================================================================
74 void P_StartButton(line_t *line,bwhere_e w,int texture,int time)
78 for (i = 0;i < MAXBUTTONS;i++)
80 if (!buttonlist[i].btimer)
82 buttonlist[i].line = line;
83 buttonlist[i].where = w;
84 buttonlist[i].btexture = texture;
85 buttonlist[i].btimer = time;
86 buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg;
90 I_Error("P_StartButton: no button slots left!");
93 //==================================================================
95 // Function that changes wall texture.
96 // Tell it if switch is ok to use again (1=yes, it's a button).
98 //==================================================================
99 void P_ChangeSwitchTexture(line_t *line, int useAgain)
106 texTop = sides[line->sidenum[0]].toptexture;
107 texMid = sides[line->sidenum[0]].midtexture;
108 texBot = sides[line->sidenum[0]].bottomtexture;
110 for (i = 0; i < numswitches*2; i++)
112 if (switchlist[i] == texTop)
114 S_StartSound((mobj_t *)&line->frontsector->soundorg,
115 alphSwitchList[i/2].soundID);
116 sides[line->sidenum[0]].toptexture = switchlist[i^1];
119 P_StartButton(line, SWTCH_TOP, switchlist[i], BUTTONTIME);
123 else if (switchlist[i] == texMid)
125 S_StartSound((mobj_t *)&line->frontsector->soundorg,
126 alphSwitchList[i/2].soundID);
127 sides[line->sidenum[0]].midtexture = switchlist[i^1];
130 P_StartButton(line, SWTCH_MIDDLE, switchlist[i], BUTTONTIME);
134 else if (switchlist[i] == texBot)
136 S_StartSound((mobj_t *)&line->frontsector->soundorg,
137 alphSwitchList[i/2].soundID);
138 sides[line->sidenum[0]].bottomtexture = switchlist[i^1];
141 P_StartButton(line, SWTCH_BOTTOM, switchlist[i], BUTTONTIME);