From c7ddc423f67236a99956960cf9fe89abf077839b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 5 Sep 2008 00:02:14 +0000 Subject: Reformat (beautify) Raven sources and add GPL headers. Subversion-branch: /branches/raven-branch Subversion-revision: 1197 --- src/hexen/p_switch.c | 201 +++++++++++++++++++++++++++------------------------ 1 file changed, 106 insertions(+), 95 deletions(-) (limited to 'src/hexen/p_switch.c') diff --git a/src/hexen/p_switch.c b/src/hexen/p_switch.c index fe5aecd0..c534d516 100644 --- a/src/hexen/p_switch.c +++ b/src/hexen/p_switch.c @@ -1,14 +1,26 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 1993-2008 Raven Software +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +//----------------------------------------------------------------------------- -//************************************************************************** -//** -//** p_switch.c : Heretic 2 : Raven Software, Corp. -//** -//** $RCSfile: p_switch.c,v $ -//** $Revision: 1.8 $ -//** $Date: 95/09/05 13:58:59 $ -//** $Author: cjr $ -//** -//************************************************************************** #include "h2def.h" #include "p_local.h" @@ -19,19 +31,18 @@ // CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE // //================================================================== -switchlist_t alphSwitchList[] = -{ - { "SW_1_UP", "SW_1_DN", SFX_SWITCH1 }, - { "SW_2_UP", "SW_2_DN", SFX_SWITCH1 }, - { "VALVE1", "VALVE2", SFX_VALVE_TURN }, - { "SW51_OFF", "SW51_ON", SFX_SWITCH2 }, - { "SW52_OFF", "SW52_ON", SFX_SWITCH2 }, - { "SW53_UP", "SW53_DN", SFX_ROPE_PULL }, - { "PUZZLE5", "PUZZLE9", SFX_SWITCH1 }, - { "PUZZLE6", "PUZZLE10", SFX_SWITCH1 }, - { "PUZZLE7", "PUZZLE11", SFX_SWITCH1 }, - { "PUZZLE8", "PUZZLE12", SFX_SWITCH1 }, - {"\0", "\0", 0} +switchlist_t alphSwitchList[] = { + {"SW_1_UP", "SW_1_DN", SFX_SWITCH1}, + {"SW_2_UP", "SW_2_DN", SFX_SWITCH1}, + {"VALVE1", "VALVE2", SFX_VALVE_TURN}, + {"SW51_OFF", "SW51_ON", SFX_SWITCH2}, + {"SW52_OFF", "SW52_ON", SFX_SWITCH2}, + {"SW53_UP", "SW53_DN", SFX_ROPE_PULL}, + {"PUZZLE5", "PUZZLE9", SFX_SWITCH1}, + {"PUZZLE6", "PUZZLE10", SFX_SWITCH1}, + {"PUZZLE7", "PUZZLE11", SFX_SWITCH1}, + {"PUZZLE8", "PUZZLE12", SFX_SWITCH1}, + {"\0", "\0", 0} }; int switchlist[MAXSWITCHES * 2]; @@ -50,20 +61,20 @@ button_t buttonlist[MAXBUTTONS]; void P_InitSwitchList(void) { - int i; - int index; + int i; + int index; - for (index = 0, i = 0; i < MAXSWITCHES; i++) - { - if(!alphSwitchList[i].soundID) - { - numswitches = index/2; - switchlist[index] = -1; - break; - } - switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); - switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2); - } + for (index = 0, i = 0; i < MAXSWITCHES; i++) + { + if (!alphSwitchList[i].soundID) + { + numswitches = index / 2; + switchlist[index] = -1; + break; + } + switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); + switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2); + } } //================================================================== @@ -71,23 +82,23 @@ void P_InitSwitchList(void) // Start a button counting down till it turns off. // //================================================================== -void P_StartButton(line_t *line,bwhere_e w,int texture,int time) +void P_StartButton(line_t * line, bwhere_e w, int texture, int time) { - int i; + int i; - for (i = 0;i < MAXBUTTONS;i++) - { - if (!buttonlist[i].btimer) - { - buttonlist[i].line = line; - buttonlist[i].where = w; - buttonlist[i].btexture = texture; - buttonlist[i].btimer = time; - buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; - return; - } - } - I_Error("P_StartButton: no button slots left!"); + for (i = 0; i < MAXBUTTONS; i++) + { + if (!buttonlist[i].btimer) + { + buttonlist[i].line = line; + buttonlist[i].where = w; + buttonlist[i].btexture = texture; + buttonlist[i].btimer = time; + buttonlist[i].soundorg = (mobj_t *) & line->frontsector->soundorg; + return; + } + } + I_Error("P_StartButton: no button slots left!"); } //================================================================== @@ -96,51 +107,51 @@ void P_StartButton(line_t *line,bwhere_e w,int texture,int time) // Tell it if switch is ok to use again (1=yes, it's a button). // //================================================================== -void P_ChangeSwitchTexture(line_t *line, int useAgain) +void P_ChangeSwitchTexture(line_t * line, int useAgain) { - int texTop; - int texMid; - int texBot; - int i; + 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; + 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 *)&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 *)&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 *)&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; - } - } + for (i = 0; i < numswitches * 2; i++) + { + if (switchlist[i] == texTop) + { + S_StartSound((mobj_t *) & 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 *) & 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 *) & 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; + } + } } -- cgit v1.2.3