p_switch.c (2689B)
1 #include "doomdef.h" 2 #include "p_local.h" 3 4 /*================================================================== */ 5 /* */ 6 /* CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE */ 7 /* */ 8 /*================================================================== */ 9 10 button_t buttonlist[MAXBUTTONS];//800975B0 11 12 void P_StartButton(line_t *line,bwhere_e w,int texture,int time); 13 14 /*================================================================== */ 15 /* */ 16 /* Function that changes wall texture. */ 17 /* Tell it if switch is ok to use again (1=yes, it's a button). */ 18 /* */ 19 /*================================================================== */ 20 void P_ChangeSwitchTexture(line_t *line,int useAgain) // 80021460 21 { 22 int sound; 23 int swx; 24 25 /* 52 EXIT! */ 26 /* 124 Secret EXIT */ 27 if(SPECIALMASK(line->special) == 52 || SPECIALMASK(line->special) == 124) 28 sound = sfx_switch2;//sfx_swtchx 29 else 30 sound = sfx_switch1;//sfx_swtchn 31 32 if(SWITCHMASK(line->flags) == (ML_SWITCHX02 | ML_SWITCHX04)) /* Mid */ 33 { 34 S_StartSound((mobj_t *)&line->frontsector->soundorg, sound); 35 36 swx = sides[line->sidenum[0]].midtexture; 37 sides[line->sidenum[0]].midtexture = ((swx - firstswx) ^ 1) + firstswx; 38 39 if (useAgain) 40 P_StartButton(line, middle, swx, BUTTONTIME); 41 } 42 else if(SWITCHMASK(line->flags) == (ML_SWITCHX02)) /* Top */ 43 { 44 S_StartSound((mobj_t *)&line->frontsector->soundorg, sound); 45 46 swx = sides[line->sidenum[0]].toptexture; 47 sides[line->sidenum[0]].toptexture = ((swx - firstswx) ^ 1) + firstswx; 48 49 if (useAgain) 50 P_StartButton(line, top ,swx, BUTTONTIME); 51 } 52 else if(SWITCHMASK(line->flags) == (ML_SWITCHX04)) /* Bot */ 53 { 54 S_StartSound((mobj_t *)&line->frontsector->soundorg, sound); 55 56 swx = sides[line->sidenum[0]].bottomtexture; 57 sides[line->sidenum[0]].bottomtexture = ((swx - firstswx) ^ 1) + firstswx; 58 59 if (useAgain) 60 P_StartButton(line, bottom, swx, BUTTONTIME); 61 } 62 } 63 64 /*================================================================== */ 65 /* */ 66 /* Start a button counting down till it turns off. */ 67 /* */ 68 /*================================================================== */ 69 void P_StartButton(line_t *line,bwhere_e w,int texture,int time) // 80021608 70 { 71 int i; 72 73 for (i = 0;i < MAXBUTTONS;i++) 74 { 75 if (buttonlist[i].btimer <= 0) 76 { 77 buttonlist[i].side = &sides[line->sidenum[0]]; 78 buttonlist[i].where = w; 79 buttonlist[i].btexture = texture; 80 buttonlist[i].btimer = time; 81 buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; 82 return; 83 } 84 } 85 86 //I_Error("P_StartButton: no button slots left!"); 87 }