p_switch.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. /* Emacs style mode select -*- C++ -*-
  2. *-----------------------------------------------------------------------------
  3. *
  4. *
  5. * PrBoom: a Doom port merged with LxDoom and LSDLDoom
  6. * based on BOOM, a modified and improved DOOM engine
  7. * Copyright (C) 1999 by
  8. * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
  9. * Copyright (C) 1999-2000 by
  10. * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
  11. * Copyright 2005, 2006 by
  12. * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. * 02111-1307, USA.
  28. *
  29. * DESCRIPTION:
  30. * Switches, buttons. Two-state animation. Exits.
  31. *
  32. *-----------------------------------------------------------------------------*/
  33. #include "doomstat.h"
  34. #include "w_wad.h"
  35. #include "r_main.h"
  36. #include "p_spec.h"
  37. #include "g_game.h"
  38. #include "s_sound.h"
  39. #include "sounds.h"
  40. #include "lprintf.h"
  41. // killough 2/8/98: Remove switch limit
  42. static int *switchlist; // killough
  43. static int max_numswitches; // killough
  44. static int numswitches; // killough
  45. button_t buttonlist[MAXBUTTONS];
  46. //
  47. // P_InitSwitchList()
  48. //
  49. // Only called at game initialization in order to list the set of switches
  50. // and buttons known to the engine. This enables their texture to change
  51. // when activated, and in the case of buttons, change back after a timeout.
  52. //
  53. // This routine modified to read its data from a predefined lump or
  54. // PWAD lump called SWITCHES rather than a static table in this module to
  55. // allow wad designers to insert or modify switches.
  56. //
  57. // Lump format is an array of byte packed switchlist_t structures, terminated
  58. // by a structure with episode == -0. The lump can be generated from a
  59. // text source file using SWANTBLS.EXE, distributed with the BOOM utils.
  60. // The standard list of switches and animations is contained in the example
  61. // source text file DEFSWANI.DAT also in the BOOM util distribution.
  62. //
  63. // Rewritten by Lee Killough to remove limit 2/8/98
  64. //
  65. void P_InitSwitchList(void)
  66. {
  67. int i, index = 0;
  68. int episode = (gamemode == registered || gamemode==retail) ?
  69. 2 : gamemode == commercial ? 3 : 1;
  70. const switchlist_t *alphSwitchList; //jff 3/23/98 pointer to switch table
  71. int lump = W_GetNumForName("SWITCHES"); // cph - new wad lump handling
  72. //jff 3/23/98 read the switch table from a predefined lump
  73. alphSwitchList = (const switchlist_t *)W_CacheLumpNum(lump);
  74. for (i=0;;i++)
  75. {
  76. if (index+1 >= max_numswitches)
  77. switchlist = realloc(switchlist, sizeof *switchlist *
  78. (max_numswitches = max_numswitches ? max_numswitches*2 : 8));
  79. if (SHORT(alphSwitchList[i].episode) <= episode) //jff 5/11/98 endianess
  80. {
  81. int texture1, texture2;
  82. if (!SHORT(alphSwitchList[i].episode))
  83. break;
  84. // Ignore switches referencing unknown texture names, instead of exiting.
  85. // Warn if either one is missing, but only add if both are valid.
  86. texture1 = R_CheckTextureNumForName(alphSwitchList[i].name1);
  87. if (texture1 == -1)
  88. lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
  89. alphSwitchList[i].name1);
  90. texture2 = R_CheckTextureNumForName(alphSwitchList[i].name2);
  91. if (texture2 == -1)
  92. lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
  93. alphSwitchList[i].name2);
  94. if (texture1 != -1 && texture2 != -1) {
  95. switchlist[index++] = texture1;
  96. switchlist[index++] = texture2;
  97. }
  98. }
  99. }
  100. numswitches = index/2;
  101. switchlist[index] = -1;
  102. W_UnlockLumpNum(lump);
  103. }
  104. //
  105. // P_StartButton()
  106. //
  107. // Start a button (retriggerable switch) counting down till it turns off.
  108. //
  109. // Passed the linedef the button is on, which texture on the sidedef contains
  110. // the button, the texture number of the button, and the time the button is
  111. // to remain active in gametics.
  112. // No return.
  113. //
  114. static void P_StartButton
  115. ( line_t* line,
  116. bwhere_e w,
  117. int texture,
  118. int time )
  119. {
  120. int i;
  121. // See if button is already pressed
  122. for (i = 0;i < MAXBUTTONS;i++)
  123. if (buttonlist[i].btimer && buttonlist[i].line == line)
  124. return;
  125. for (i = 0;i < MAXBUTTONS;i++)
  126. if (!buttonlist[i].btimer) // use first unused element of list
  127. {
  128. buttonlist[i].line = line;
  129. buttonlist[i].where = w;
  130. buttonlist[i].btexture = texture;
  131. buttonlist[i].btimer = time;
  132. /* use sound origin of line itself - no need to compatibility-wrap
  133. * as the popout code gets it wrong whatever its value */
  134. buttonlist[i].soundorg = (mobj_t *)&line->soundorg;
  135. return;
  136. }
  137. I_Error("P_StartButton: no button slots left!");
  138. }
  139. //
  140. // P_ChangeSwitchTexture()
  141. //
  142. // Function that changes switch wall texture on activation.
  143. //
  144. // Passed the line which the switch is on, and whether its retriggerable.
  145. // If not retriggerable, this function clears the line special to insure that
  146. //
  147. // No return
  148. //
  149. void P_ChangeSwitchTexture
  150. ( line_t* line,
  151. int useAgain )
  152. {
  153. /* Rearranged a bit to avoid too much code duplication */
  154. mobj_t *soundorg;
  155. int i, sound;
  156. short *texture, *ttop, *tmid, *tbot;
  157. bwhere_e position;
  158. ttop = &sides[line->sidenum[0]].toptexture;
  159. tmid = &sides[line->sidenum[0]].midtexture;
  160. tbot = &sides[line->sidenum[0]].bottomtexture;
  161. sound = sfx_swtchn;
  162. /* use the sound origin of the linedef (its midpoint)
  163. * unless in a compatibility mode */
  164. soundorg = (mobj_t *)&line->soundorg;
  165. if (comp[comp_sound] || compatibility_level < prboom_6_compatibility) {
  166. /* usually NULL, unless there is another button already pressed in,
  167. * in which case it's the sound origin of that button press... */
  168. soundorg = buttonlist->soundorg;
  169. } else {
  170. // EXIT SWITCH?
  171. /* don't do this unless you're in a compatibility mode */
  172. // proff - this works as advertised, but I don't like the sound
  173. // if (line->special == 11 || line->special == 51) // exit or secret exit
  174. // sound = sfx_swtchx;
  175. }
  176. /* don't zero line->special until after exit switch test */
  177. if (!useAgain)
  178. line->special = 0;
  179. /* search for a texture to change */
  180. texture = NULL; position = 0;
  181. for (i = 0;i < numswitches*2;i++) { /* this could be more efficient... */
  182. if (switchlist[i] == *ttop) {
  183. texture = ttop; position = top; break;
  184. } else if (switchlist[i] == *tmid) {
  185. texture = tmid; position = middle; break;
  186. } else if (switchlist[i] == *tbot) {
  187. texture = tbot; position = bottom; break;
  188. }
  189. }
  190. if (texture == NULL)
  191. return; /* no switch texture was found to change */
  192. *texture = switchlist[i^1];
  193. S_StartSound(soundorg, sound);
  194. if (useAgain)
  195. P_StartButton(line, position, switchlist[i], BUTTONTIME);
  196. }
  197. //
  198. // P_UseSpecialLine
  199. //
  200. //
  201. // Called when a thing uses (pushes) a special line.
  202. // Only the front sides of lines are usable.
  203. // Dispatches to the appropriate linedef function handler.
  204. //
  205. // Passed the thing using the line, the line being used, and the side used
  206. // Returns true if a thinker was created
  207. //
  208. boolean
  209. P_UseSpecialLine
  210. ( mobj_t* thing,
  211. line_t* line,
  212. int side )
  213. {
  214. // e6y
  215. // b.m. side test was broken in boom201
  216. if ((demoplayback ? (demover != 201) : (compatibility_level != boom_201_compatibility)))
  217. if (side) //jff 6/1/98 fix inadvertent deletion of side test
  218. return false;
  219. //jff 02/04/98 add check here for generalized floor/ceil mover
  220. if (!demo_compatibility)
  221. {
  222. // pointer to line function is NULL by default, set non-null if
  223. // line special is push or switch generalized linedef type
  224. int (*linefunc)(line_t *line)=NULL;
  225. // check each range of generalized linedefs
  226. if ((unsigned)line->special >= GenEnd)
  227. {
  228. // Out of range for GenFloors
  229. }
  230. else if ((unsigned)line->special >= GenFloorBase)
  231. {
  232. if (!thing->player)
  233. if ((line->special & FloorChange) || !(line->special & FloorModel))
  234. return false; // FloorModel is "Allow Monsters" if FloorChange is 0
  235. if (!line->tag && ((line->special&6)!=6)) //jff 2/27/98 all non-manual
  236. return false; // generalized types require tag
  237. linefunc = EV_DoGenFloor;
  238. }
  239. else if ((unsigned)line->special >= GenCeilingBase)
  240. {
  241. if (!thing->player)
  242. if ((line->special & CeilingChange) || !(line->special & CeilingModel))
  243. return false; // CeilingModel is "Allow Monsters" if CeilingChange is 0
  244. if (!line->tag && ((line->special&6)!=6)) //jff 2/27/98 all non-manual
  245. return false; // generalized types require tag
  246. linefunc = EV_DoGenCeiling;
  247. }
  248. else if ((unsigned)line->special >= GenDoorBase)
  249. {
  250. if (!thing->player)
  251. {
  252. if (!(line->special & DoorMonster))
  253. return false; // monsters disallowed from this door
  254. if (line->flags & ML_SECRET) // they can't open secret doors either
  255. return false;
  256. }
  257. if (!line->tag && ((line->special&6)!=6)) //jff 3/2/98 all non-manual
  258. return false; // generalized types require tag
  259. linefunc = EV_DoGenDoor;
  260. }
  261. else if ((unsigned)line->special >= GenLockedBase)
  262. {
  263. if (!thing->player)
  264. return false; // monsters disallowed from unlocking doors
  265. if (!P_CanUnlockGenDoor(line,thing->player))
  266. return false;
  267. if (!line->tag && ((line->special&6)!=6)) //jff 2/27/98 all non-manual
  268. return false; // generalized types require tag
  269. linefunc = EV_DoGenLockedDoor;
  270. }
  271. else if ((unsigned)line->special >= GenLiftBase)
  272. {
  273. if (!thing->player)
  274. if (!(line->special & LiftMonster))
  275. return false; // monsters disallowed
  276. if (!line->tag && ((line->special&6)!=6)) //jff 2/27/98 all non-manual
  277. return false; // generalized types require tag
  278. linefunc = EV_DoGenLift;
  279. }
  280. else if ((unsigned)line->special >= GenStairsBase)
  281. {
  282. if (!thing->player)
  283. if (!(line->special & StairMonster))
  284. return false; // monsters disallowed
  285. if (!line->tag && ((line->special&6)!=6)) //jff 2/27/98 all non-manual
  286. return false; // generalized types require tag
  287. linefunc = EV_DoGenStairs;
  288. }
  289. else if ((unsigned)line->special >= GenCrusherBase)
  290. {
  291. if (!thing->player)
  292. if (!(line->special & CrusherMonster))
  293. return false; // monsters disallowed
  294. if (!line->tag && ((line->special&6)!=6)) //jff 2/27/98 all non-manual
  295. return false; // generalized types require tag
  296. linefunc = EV_DoGenCrusher;
  297. }
  298. if (linefunc)
  299. switch((line->special & TriggerType) >> TriggerTypeShift)
  300. {
  301. case PushOnce:
  302. if (!side)
  303. if (linefunc(line))
  304. line->special = 0;
  305. return true;
  306. case PushMany:
  307. if (!side)
  308. linefunc(line);
  309. return true;
  310. case SwitchOnce:
  311. if (linefunc(line))
  312. P_ChangeSwitchTexture(line,0);
  313. return true;
  314. case SwitchMany:
  315. if (linefunc(line))
  316. P_ChangeSwitchTexture(line,1);
  317. return true;
  318. default: // if not a switch/push type, do nothing here
  319. return false;
  320. }
  321. }
  322. // Switches that other things can activate.
  323. if (!thing->player)
  324. {
  325. // never open secret doors
  326. if (line->flags & ML_SECRET)
  327. return false;
  328. switch(line->special)
  329. {
  330. case 1: // MANUAL DOOR RAISE
  331. case 32: // MANUAL BLUE
  332. case 33: // MANUAL RED
  333. case 34: // MANUAL YELLOW
  334. //jff 3/5/98 add ability to use teleporters for monsters
  335. case 195: // switch teleporters
  336. case 174:
  337. case 210: // silent switch teleporters
  338. case 209:
  339. break;
  340. default:
  341. return false;
  342. break;
  343. }
  344. }
  345. if (!P_CheckTag(line)) //jff 2/27/98 disallow zero tag on some types
  346. return false;
  347. // Dispatch to handler according to linedef type
  348. switch (line->special)
  349. {
  350. // Manual doors, push type with no tag
  351. case 1: // Vertical Door
  352. case 26: // Blue Door/Locked
  353. case 27: // Yellow Door /Locked
  354. case 28: // Red Door /Locked
  355. case 31: // Manual door open
  356. case 32: // Blue locked door open
  357. case 33: // Red locked door open
  358. case 34: // Yellow locked door open
  359. case 117: // Blazing door raise
  360. case 118: // Blazing door open
  361. EV_VerticalDoor (line, thing);
  362. break;
  363. // Switches (non-retriggerable)
  364. case 7:
  365. // Build Stairs
  366. if (EV_BuildStairs(line,build8))
  367. P_ChangeSwitchTexture(line,0);
  368. break;
  369. case 9:
  370. // Change Donut
  371. if (EV_DoDonut(line))
  372. P_ChangeSwitchTexture(line,0);
  373. break;
  374. case 11:
  375. /* Exit level
  376. * killough 10/98: prevent zombies from exiting levels
  377. */
  378. if (thing->player && thing->player->health <= 0 && !comp[comp_zombie])
  379. {
  380. S_StartSound(thing, sfx_noway);
  381. return false;
  382. }
  383. #ifdef IPHONE
  384. // disable level switch with timelimit or fraglimit
  385. extern boolean levelTimer;
  386. extern boolean levelFragLimit;
  387. if ( deathmatch && ( levelTimer || levelFragLimit ) ) {
  388. S_StartSound(thing, sfx_noway);
  389. return false;
  390. }
  391. #endif
  392. P_ChangeSwitchTexture(line,0);
  393. G_ExitLevel ();
  394. break;
  395. case 14:
  396. // Raise Floor 32 and change texture
  397. if (EV_DoPlat(line,raiseAndChange,32))
  398. P_ChangeSwitchTexture(line,0);
  399. break;
  400. case 15:
  401. // Raise Floor 24 and change texture
  402. if (EV_DoPlat(line,raiseAndChange,24))
  403. P_ChangeSwitchTexture(line,0);
  404. break;
  405. case 18:
  406. // Raise Floor to next highest floor
  407. if (EV_DoFloor(line, raiseFloorToNearest))
  408. P_ChangeSwitchTexture(line,0);
  409. break;
  410. case 20:
  411. // Raise Plat next highest floor and change texture
  412. if (EV_DoPlat(line,raiseToNearestAndChange,0))
  413. P_ChangeSwitchTexture(line,0);
  414. break;
  415. case 21:
  416. // PlatDownWaitUpStay
  417. if (EV_DoPlat(line,downWaitUpStay,0))
  418. P_ChangeSwitchTexture(line,0);
  419. break;
  420. case 23:
  421. // Lower Floor to Lowest
  422. if (EV_DoFloor(line,lowerFloorToLowest))
  423. P_ChangeSwitchTexture(line,0);
  424. break;
  425. case 29:
  426. // Raise Door
  427. if (EV_DoDoor(line,normal))
  428. P_ChangeSwitchTexture(line,0);
  429. break;
  430. case 41:
  431. // Lower Ceiling to Floor
  432. if (EV_DoCeiling(line,lowerToFloor))
  433. P_ChangeSwitchTexture(line,0);
  434. break;
  435. case 71:
  436. // Turbo Lower Floor
  437. if (EV_DoFloor(line,turboLower))
  438. P_ChangeSwitchTexture(line,0);
  439. break;
  440. case 49:
  441. // Ceiling Crush And Raise
  442. if (EV_DoCeiling(line,crushAndRaise))
  443. P_ChangeSwitchTexture(line,0);
  444. break;
  445. case 50:
  446. // Close Door
  447. if (EV_DoDoor(line,close))
  448. P_ChangeSwitchTexture(line,0);
  449. break;
  450. case 51:
  451. /* Secret EXIT
  452. * killough 10/98: prevent zombies from exiting levels
  453. */
  454. if (thing->player && thing->player->health <= 0 && !comp[comp_zombie])
  455. {
  456. S_StartSound(thing, sfx_noway);
  457. return false;
  458. }
  459. P_ChangeSwitchTexture(line,0);
  460. G_SecretExitLevel ();
  461. break;
  462. case 55:
  463. // Raise Floor Crush
  464. if (EV_DoFloor(line,raiseFloorCrush))
  465. P_ChangeSwitchTexture(line,0);
  466. break;
  467. case 101:
  468. // Raise Floor
  469. if (EV_DoFloor(line,raiseFloor))
  470. P_ChangeSwitchTexture(line,0);
  471. break;
  472. case 102:
  473. // Lower Floor to Surrounding floor height
  474. if (EV_DoFloor(line,lowerFloor))
  475. P_ChangeSwitchTexture(line,0);
  476. break;
  477. case 103:
  478. // Open Door
  479. if (EV_DoDoor(line,open))
  480. P_ChangeSwitchTexture(line,0);
  481. break;
  482. case 111:
  483. // Blazing Door Raise (faster than TURBO!)
  484. if (EV_DoDoor (line,blazeRaise))
  485. P_ChangeSwitchTexture(line,0);
  486. break;
  487. case 112:
  488. // Blazing Door Open (faster than TURBO!)
  489. if (EV_DoDoor (line,blazeOpen))
  490. P_ChangeSwitchTexture(line,0);
  491. break;
  492. case 113:
  493. // Blazing Door Close (faster than TURBO!)
  494. if (EV_DoDoor (line,blazeClose))
  495. P_ChangeSwitchTexture(line,0);
  496. break;
  497. case 122:
  498. // Blazing PlatDownWaitUpStay
  499. if (EV_DoPlat(line,blazeDWUS,0))
  500. P_ChangeSwitchTexture(line,0);
  501. break;
  502. case 127:
  503. // Build Stairs Turbo 16
  504. if (EV_BuildStairs(line,turbo16))
  505. P_ChangeSwitchTexture(line,0);
  506. break;
  507. case 131:
  508. // Raise Floor Turbo
  509. if (EV_DoFloor(line,raiseFloorTurbo))
  510. P_ChangeSwitchTexture(line,0);
  511. break;
  512. case 133:
  513. // BlzOpenDoor BLUE
  514. case 135:
  515. // BlzOpenDoor RED
  516. case 137:
  517. // BlzOpenDoor YELLOW
  518. if (EV_DoLockedDoor (line,blazeOpen,thing))
  519. P_ChangeSwitchTexture(line,0);
  520. break;
  521. case 140:
  522. // Raise Floor 512
  523. if (EV_DoFloor(line,raiseFloor512))
  524. P_ChangeSwitchTexture(line,0);
  525. break;
  526. // killough 1/31/98: factored out compatibility check;
  527. // added inner switch, relaxed check to demo_compatibility
  528. default:
  529. if (!demo_compatibility)
  530. switch (line->special)
  531. {
  532. //jff 1/29/98 added linedef types to fill all functions out so that
  533. // all possess SR, S1, WR, W1 types
  534. case 158:
  535. // Raise Floor to shortest lower texture
  536. // 158 S1 EV_DoFloor(raiseToTexture), CSW(0)
  537. if (EV_DoFloor(line,raiseToTexture))
  538. P_ChangeSwitchTexture(line,0);
  539. break;
  540. case 159:
  541. // Raise Floor to shortest lower texture
  542. // 159 S1 EV_DoFloor(lowerAndChange)
  543. if (EV_DoFloor(line,lowerAndChange))
  544. P_ChangeSwitchTexture(line,0);
  545. break;
  546. case 160:
  547. // Raise Floor 24 and change
  548. // 160 S1 EV_DoFloor(raiseFloor24AndChange)
  549. if (EV_DoFloor(line,raiseFloor24AndChange))
  550. P_ChangeSwitchTexture(line,0);
  551. break;
  552. case 161:
  553. // Raise Floor 24
  554. // 161 S1 EV_DoFloor(raiseFloor24)
  555. if (EV_DoFloor(line,raiseFloor24))
  556. P_ChangeSwitchTexture(line,0);
  557. break;
  558. case 162:
  559. // Moving floor min n to max n
  560. // 162 S1 EV_DoPlat(perpetualRaise,0)
  561. if (EV_DoPlat(line,perpetualRaise,0))
  562. P_ChangeSwitchTexture(line,0);
  563. break;
  564. case 163:
  565. // Stop Moving floor
  566. // 163 S1 EV_DoPlat(perpetualRaise,0)
  567. EV_StopPlat(line);
  568. P_ChangeSwitchTexture(line,0);
  569. break;
  570. case 164:
  571. // Start fast crusher
  572. // 164 S1 EV_DoCeiling(fastCrushAndRaise)
  573. if (EV_DoCeiling(line,fastCrushAndRaise))
  574. P_ChangeSwitchTexture(line,0);
  575. break;
  576. case 165:
  577. // Start slow silent crusher
  578. // 165 S1 EV_DoCeiling(silentCrushAndRaise)
  579. if (EV_DoCeiling(line,silentCrushAndRaise))
  580. P_ChangeSwitchTexture(line,0);
  581. break;
  582. case 166:
  583. // Raise ceiling, Lower floor
  584. // 166 S1 EV_DoCeiling(raiseToHighest), EV_DoFloor(lowerFloortoLowest)
  585. if (EV_DoCeiling(line, raiseToHighest) ||
  586. EV_DoFloor(line, lowerFloorToLowest))
  587. P_ChangeSwitchTexture(line,0);
  588. break;
  589. case 167:
  590. // Lower floor and Crush
  591. // 167 S1 EV_DoCeiling(lowerAndCrush)
  592. if (EV_DoCeiling(line, lowerAndCrush))
  593. P_ChangeSwitchTexture(line,0);
  594. break;
  595. case 168:
  596. // Stop crusher
  597. // 168 S1 EV_CeilingCrushStop()
  598. if (EV_CeilingCrushStop(line))
  599. P_ChangeSwitchTexture(line,0);
  600. break;
  601. case 169:
  602. // Lights to brightest neighbor sector
  603. // 169 S1 EV_LightTurnOn(0)
  604. EV_LightTurnOn(line,0);
  605. P_ChangeSwitchTexture(line,0);
  606. break;
  607. case 170:
  608. // Lights to near dark
  609. // 170 S1 EV_LightTurnOn(35)
  610. EV_LightTurnOn(line,35);
  611. P_ChangeSwitchTexture(line,0);
  612. break;
  613. case 171:
  614. // Lights on full
  615. // 171 S1 EV_LightTurnOn(255)
  616. EV_LightTurnOn(line,255);
  617. P_ChangeSwitchTexture(line,0);
  618. break;
  619. case 172:
  620. // Start Lights Strobing
  621. // 172 S1 EV_StartLightStrobing()
  622. EV_StartLightStrobing(line);
  623. P_ChangeSwitchTexture(line,0);
  624. break;
  625. case 173:
  626. // Lights to Dimmest Near
  627. // 173 S1 EV_TurnTagLightsOff()
  628. EV_TurnTagLightsOff(line);
  629. P_ChangeSwitchTexture(line,0);
  630. break;
  631. case 174:
  632. // Teleport
  633. // 174 S1 EV_Teleport(side,thing)
  634. if (EV_Teleport(line,side,thing))
  635. P_ChangeSwitchTexture(line,0);
  636. break;
  637. case 175:
  638. // Close Door, Open in 30 secs
  639. // 175 S1 EV_DoDoor(close30ThenOpen)
  640. if (EV_DoDoor(line,close30ThenOpen))
  641. P_ChangeSwitchTexture(line,0);
  642. break;
  643. case 189: //jff 3/15/98 create texture change no motion type
  644. // Texture Change Only (Trigger)
  645. // 189 S1 Change Texture/Type Only
  646. if (EV_DoChange(line,trigChangeOnly))
  647. P_ChangeSwitchTexture(line,0);
  648. break;
  649. case 203:
  650. // Lower ceiling to lowest surrounding ceiling
  651. // 203 S1 EV_DoCeiling(lowerToLowest)
  652. if (EV_DoCeiling(line,lowerToLowest))
  653. P_ChangeSwitchTexture(line,0);
  654. break;
  655. case 204:
  656. // Lower ceiling to highest surrounding floor
  657. // 204 S1 EV_DoCeiling(lowerToMaxFloor)
  658. if (EV_DoCeiling(line,lowerToMaxFloor))
  659. P_ChangeSwitchTexture(line,0);
  660. break;
  661. case 209:
  662. // killough 1/31/98: silent teleporter
  663. //jff 209 S1 SilentTeleport
  664. if (EV_SilentTeleport(line, side, thing))
  665. P_ChangeSwitchTexture(line,0);
  666. break;
  667. case 241: //jff 3/15/98 create texture change no motion type
  668. // Texture Change Only (Numeric)
  669. // 241 S1 Change Texture/Type Only
  670. if (EV_DoChange(line,numChangeOnly))
  671. P_ChangeSwitchTexture(line,0);
  672. break;
  673. case 221:
  674. // Lower floor to next lowest floor
  675. // 221 S1 Lower Floor To Nearest Floor
  676. if (EV_DoFloor(line,lowerFloorToNearest))
  677. P_ChangeSwitchTexture(line,0);
  678. break;
  679. case 229:
  680. // Raise elevator next floor
  681. // 229 S1 Raise Elevator next floor
  682. if (EV_DoElevator(line,elevateUp))
  683. P_ChangeSwitchTexture(line,0);
  684. break;
  685. case 233:
  686. // Lower elevator next floor
  687. // 233 S1 Lower Elevator next floor
  688. if (EV_DoElevator(line,elevateDown))
  689. P_ChangeSwitchTexture(line,0);
  690. break;
  691. case 237:
  692. // Elevator to current floor
  693. // 237 S1 Elevator to current floor
  694. if (EV_DoElevator(line,elevateCurrent))
  695. P_ChangeSwitchTexture(line,0);
  696. break;
  697. // jff 1/29/98 end of added S1 linedef types
  698. //jff 1/29/98 added linedef types to fill all functions out so that
  699. // all possess SR, S1, WR, W1 types
  700. case 78: //jff 3/15/98 create texture change no motion type
  701. // Texture Change Only (Numeric)
  702. // 78 SR Change Texture/Type Only
  703. if (EV_DoChange(line,numChangeOnly))
  704. P_ChangeSwitchTexture(line,1);
  705. break;
  706. case 176:
  707. // Raise Floor to shortest lower texture
  708. // 176 SR EV_DoFloor(raiseToTexture), CSW(1)
  709. if (EV_DoFloor(line,raiseToTexture))
  710. P_ChangeSwitchTexture(line,1);
  711. break;
  712. case 177:
  713. // Raise Floor to shortest lower texture
  714. // 177 SR EV_DoFloor(lowerAndChange)
  715. if (EV_DoFloor(line,lowerAndChange))
  716. P_ChangeSwitchTexture(line,1);
  717. break;
  718. case 178:
  719. // Raise Floor 512
  720. // 178 SR EV_DoFloor(raiseFloor512)
  721. if (EV_DoFloor(line,raiseFloor512))
  722. P_ChangeSwitchTexture(line,1);
  723. break;
  724. case 179:
  725. // Raise Floor 24 and change
  726. // 179 SR EV_DoFloor(raiseFloor24AndChange)
  727. if (EV_DoFloor(line,raiseFloor24AndChange))
  728. P_ChangeSwitchTexture(line,1);
  729. break;
  730. case 180:
  731. // Raise Floor 24
  732. // 180 SR EV_DoFloor(raiseFloor24)
  733. if (EV_DoFloor(line,raiseFloor24))
  734. P_ChangeSwitchTexture(line,1);
  735. break;
  736. case 181:
  737. // Moving floor min n to max n
  738. // 181 SR EV_DoPlat(perpetualRaise,0)
  739. EV_DoPlat(line,perpetualRaise,0);
  740. P_ChangeSwitchTexture(line,1);
  741. break;
  742. case 182:
  743. // Stop Moving floor
  744. // 182 SR EV_DoPlat(perpetualRaise,0)
  745. EV_StopPlat(line);
  746. P_ChangeSwitchTexture(line,1);
  747. break;
  748. case 183:
  749. // Start fast crusher
  750. // 183 SR EV_DoCeiling(fastCrushAndRaise)
  751. if (EV_DoCeiling(line,fastCrushAndRaise))
  752. P_ChangeSwitchTexture(line,1);
  753. break;
  754. case 184:
  755. // Start slow crusher
  756. // 184 SR EV_DoCeiling(crushAndRaise)
  757. if (EV_DoCeiling(line,crushAndRaise))
  758. P_ChangeSwitchTexture(line,1);
  759. break;
  760. case 185:
  761. // Start slow silent crusher
  762. // 185 SR EV_DoCeiling(silentCrushAndRaise)
  763. if (EV_DoCeiling(line,silentCrushAndRaise))
  764. P_ChangeSwitchTexture(line,1);
  765. break;
  766. case 186:
  767. // Raise ceiling, Lower floor
  768. // 186 SR EV_DoCeiling(raiseToHighest), EV_DoFloor(lowerFloortoLowest)
  769. if (EV_DoCeiling(line, raiseToHighest) ||
  770. EV_DoFloor(line, lowerFloorToLowest))
  771. P_ChangeSwitchTexture(line,1);
  772. break;
  773. case 187:
  774. // Lower floor and Crush
  775. // 187 SR EV_DoCeiling(lowerAndCrush)
  776. if (EV_DoCeiling(line, lowerAndCrush))
  777. P_ChangeSwitchTexture(line,1);
  778. break;
  779. case 188:
  780. // Stop crusher
  781. // 188 SR EV_CeilingCrushStop()
  782. if (EV_CeilingCrushStop(line))
  783. P_ChangeSwitchTexture(line,1);
  784. break;
  785. case 190: //jff 3/15/98 create texture change no motion type
  786. // Texture Change Only (Trigger)
  787. // 190 SR Change Texture/Type Only
  788. if (EV_DoChange(line,trigChangeOnly))
  789. P_ChangeSwitchTexture(line,1);
  790. break;
  791. case 191:
  792. // Lower Pillar, Raise Donut
  793. // 191 SR EV_DoDonut()
  794. if (EV_DoDonut(line))
  795. P_ChangeSwitchTexture(line,1);
  796. break;
  797. case 192:
  798. // Lights to brightest neighbor sector
  799. // 192 SR EV_LightTurnOn(0)
  800. EV_LightTurnOn(line,0);
  801. P_ChangeSwitchTexture(line,1);
  802. break;
  803. case 193:
  804. // Start Lights Strobing
  805. // 193 SR EV_StartLightStrobing()
  806. EV_StartLightStrobing(line);
  807. P_ChangeSwitchTexture(line,1);
  808. break;
  809. case 194:
  810. // Lights to Dimmest Near
  811. // 194 SR EV_TurnTagLightsOff()
  812. EV_TurnTagLightsOff(line);
  813. P_ChangeSwitchTexture(line,1);
  814. break;
  815. case 195:
  816. // Teleport
  817. // 195 SR EV_Teleport(side,thing)
  818. if (EV_Teleport(line,side,thing))
  819. P_ChangeSwitchTexture(line,1);
  820. break;
  821. case 196:
  822. // Close Door, Open in 30 secs
  823. // 196 SR EV_DoDoor(close30ThenOpen)
  824. if (EV_DoDoor(line,close30ThenOpen))
  825. P_ChangeSwitchTexture(line,1);
  826. break;
  827. case 205:
  828. // Lower ceiling to lowest surrounding ceiling
  829. // 205 SR EV_DoCeiling(lowerToLowest)
  830. if (EV_DoCeiling(line,lowerToLowest))
  831. P_ChangeSwitchTexture(line,1);
  832. break;
  833. case 206:
  834. // Lower ceiling to highest surrounding floor
  835. // 206 SR EV_DoCeiling(lowerToMaxFloor)
  836. if (EV_DoCeiling(line,lowerToMaxFloor))
  837. P_ChangeSwitchTexture(line,1);
  838. break;
  839. case 210:
  840. // killough 1/31/98: silent teleporter
  841. //jff 210 SR SilentTeleport
  842. if (EV_SilentTeleport(line, side, thing))
  843. P_ChangeSwitchTexture(line,1);
  844. break;
  845. case 211: //jff 3/14/98 create instant toggle floor type
  846. // Toggle Floor Between C and F Instantly
  847. // 211 SR Toggle Floor Instant
  848. if (EV_DoPlat(line,toggleUpDn,0))
  849. P_ChangeSwitchTexture(line,1);
  850. break;
  851. case 222:
  852. // Lower floor to next lowest floor
  853. // 222 SR Lower Floor To Nearest Floor
  854. if (EV_DoFloor(line,lowerFloorToNearest))
  855. P_ChangeSwitchTexture(line,1);
  856. break;
  857. case 230:
  858. // Raise elevator next floor
  859. // 230 SR Raise Elevator next floor
  860. if (EV_DoElevator(line,elevateUp))
  861. P_ChangeSwitchTexture(line,1);
  862. break;
  863. case 234:
  864. // Lower elevator next floor
  865. // 234 SR Lower Elevator next floor
  866. if (EV_DoElevator(line,elevateDown))
  867. P_ChangeSwitchTexture(line,1);
  868. break;
  869. case 238:
  870. // Elevator to current floor
  871. // 238 SR Elevator to current floor
  872. if (EV_DoElevator(line,elevateCurrent))
  873. P_ChangeSwitchTexture(line,1);
  874. break;
  875. case 258:
  876. // Build stairs, step 8
  877. // 258 SR EV_BuildStairs(build8)
  878. if (EV_BuildStairs(line,build8))
  879. P_ChangeSwitchTexture(line,1);
  880. break;
  881. case 259:
  882. // Build stairs, step 16
  883. // 259 SR EV_BuildStairs(turbo16)
  884. if (EV_BuildStairs(line,turbo16))
  885. P_ChangeSwitchTexture(line,1);
  886. break;
  887. // 1/29/98 jff end of added SR linedef types
  888. }
  889. break;
  890. // Buttons (retriggerable switches)
  891. case 42:
  892. // Close Door
  893. if (EV_DoDoor(line,close))
  894. P_ChangeSwitchTexture(line,1);
  895. break;
  896. case 43:
  897. // Lower Ceiling to Floor
  898. if (EV_DoCeiling(line,lowerToFloor))
  899. P_ChangeSwitchTexture(line,1);
  900. break;
  901. case 45:
  902. // Lower Floor to Surrounding floor height
  903. if (EV_DoFloor(line,lowerFloor))
  904. P_ChangeSwitchTexture(line,1);
  905. break;
  906. case 60:
  907. // Lower Floor to Lowest
  908. if (EV_DoFloor(line,lowerFloorToLowest))
  909. P_ChangeSwitchTexture(line,1);
  910. break;
  911. case 61:
  912. // Open Door
  913. if (EV_DoDoor(line,open))
  914. P_ChangeSwitchTexture(line,1);
  915. break;
  916. case 62:
  917. // PlatDownWaitUpStay
  918. if (EV_DoPlat(line,downWaitUpStay,1))
  919. P_ChangeSwitchTexture(line,1);
  920. break;
  921. case 63:
  922. // Raise Door
  923. if (EV_DoDoor(line,normal))
  924. P_ChangeSwitchTexture(line,1);
  925. break;
  926. case 64:
  927. // Raise Floor to ceiling
  928. if (EV_DoFloor(line,raiseFloor))
  929. P_ChangeSwitchTexture(line,1);
  930. break;
  931. case 66:
  932. // Raise Floor 24 and change texture
  933. if (EV_DoPlat(line,raiseAndChange,24))
  934. P_ChangeSwitchTexture(line,1);
  935. break;
  936. case 67:
  937. // Raise Floor 32 and change texture
  938. if (EV_DoPlat(line,raiseAndChange,32))
  939. P_ChangeSwitchTexture(line,1);
  940. break;
  941. case 65:
  942. // Raise Floor Crush
  943. if (EV_DoFloor(line,raiseFloorCrush))
  944. P_ChangeSwitchTexture(line,1);
  945. break;
  946. case 68:
  947. // Raise Plat to next highest floor and change texture
  948. if (EV_DoPlat(line,raiseToNearestAndChange,0))
  949. P_ChangeSwitchTexture(line,1);
  950. break;
  951. case 69:
  952. // Raise Floor to next highest floor
  953. if (EV_DoFloor(line, raiseFloorToNearest))
  954. P_ChangeSwitchTexture(line,1);
  955. break;
  956. case 70:
  957. // Turbo Lower Floor
  958. if (EV_DoFloor(line,turboLower))
  959. P_ChangeSwitchTexture(line,1);
  960. break;
  961. case 114:
  962. // Blazing Door Raise (faster than TURBO!)
  963. if (EV_DoDoor (line,blazeRaise))
  964. P_ChangeSwitchTexture(line,1);
  965. break;
  966. case 115:
  967. // Blazing Door Open (faster than TURBO!)
  968. if (EV_DoDoor (line,blazeOpen))
  969. P_ChangeSwitchTexture(line,1);
  970. break;
  971. case 116:
  972. // Blazing Door Close (faster than TURBO!)
  973. if (EV_DoDoor (line,blazeClose))
  974. P_ChangeSwitchTexture(line,1);
  975. break;
  976. case 123:
  977. // Blazing PlatDownWaitUpStay
  978. if (EV_DoPlat(line,blazeDWUS,0))
  979. P_ChangeSwitchTexture(line,1);
  980. break;
  981. case 132:
  982. // Raise Floor Turbo
  983. if (EV_DoFloor(line,raiseFloorTurbo))
  984. P_ChangeSwitchTexture(line,1);
  985. break;
  986. case 99:
  987. // BlzOpenDoor BLUE
  988. case 134:
  989. // BlzOpenDoor RED
  990. case 136:
  991. // BlzOpenDoor YELLOW
  992. if (EV_DoLockedDoor (line,blazeOpen,thing))
  993. P_ChangeSwitchTexture(line,1);
  994. break;
  995. case 138:
  996. // Light Turn On
  997. EV_LightTurnOn(line,255);
  998. P_ChangeSwitchTexture(line,1);
  999. break;
  1000. case 139:
  1001. // Light Turn Off
  1002. EV_LightTurnOn(line,35);
  1003. P_ChangeSwitchTexture(line,1);
  1004. break;
  1005. }
  1006. return true;
  1007. }