1 /** @file p_floor.h  Common playsim routines relating to moving floors.
2  *
3  * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  * @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
5  * @authors Copyright © 1993-1996 id Software, Inc.
6  *
7  * @par License
8  * GPL: http://www.gnu.org/licenses/gpl.html
9  *
10  * <small>This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by the
12  * Free Software Foundation; either version 2 of the License, or (at your
13  * option) any later version. This program is distributed in the hope that it
14  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details. You should have received a copy of the GNU
17  * General Public License along with this program; if not, write to the Free
18  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19  * 02110-1301 USA</small>
20  */
21 
22 #ifndef LIBCOMMON_THINKER_FLOOR_H
23 #define LIBCOMMON_THINKER_FLOOR_H
24 
25 #include "doomsday.h"
26 #ifdef __cplusplus
27 #  include "mapstatereader.h"
28 #  include "mapstatewriter.h"
29 #endif
30 
31 #define FLOORSPEED          (1)
32 
33 typedef enum {
34     FS_DOWN = -1, // Moving down.
35     FS_WAIT, // Currently unused.
36     FS_UP // Moving up.
37 } floorstate_e;
38 
39 typedef enum {
40     FT_LOWER, // Lower floor to highest surrounding floor.
41     FT_LOWERTOLOWEST, // Lower floor to lowest surrounding floor.
42 #if __JHEXEN__
43     FT_LOWERBYVALUE,
44 #endif
45 #if __JDOOM__ || __JDOOM64__ || __JHERETIC__
46     FT_LOWERTURBO, // Lower floor to highest surrounding floor VERY FAST.
47 #endif
48 #if __JDOOM64__
49     FT_TOHIGHESTPLUS8, // jd64
50     FT_TOHIGHESTPLUSBITMIP, // jd64
51     FT_CUSTOMCHANGESEC, // jd64
52 #endif
53     FT_RAISEFLOOR, // Raise floor to lowest surrounding CEILING.
54     FT_RAISEFLOORTONEAREST, // Raise floor to next highest surrounding floor.
55 #if __JDOOM__ || __JDOOM64__ || __JHERETIC__
56     FT_RAISETOTEXTURE, // Raise floor to shortest height texture around it.
57     FT_LOWERANDCHANGE, // Lower floor to lowest surrounding floor and change floorpic.
58     FT_RAISE24,
59     FT_RAISE24ANDCHANGE,
60 #endif
61 #if __JHEXEN__
62     FT_RAISEFLOORBYVALUE,
63 #endif
64     FT_RAISEFLOORCRUSH,
65 #if __JDOOM__ || __JDOOM64__
66     FT_RAISEFLOORTURBO, // Raise to next highest floor, turbo-speed.
67 #endif
68 #if __JDOOM__ || __JDOOM64__ || __JHERETIC__
69     FT_RAISEDONUT,
70 #endif
71 #if __JDOOM__ || __JDOOM64__
72     FT_RAISE512,
73 #endif
74 #if __JDOOM64__
75     FT_RAISE32, // jd64
76 #endif
77 #if __JHERETIC__ || __JHEXEN__
78     FT_RAISEBUILDSTEP,
79 #endif
80 #if __JHEXEN__
81     FT_RAISEBYVALUEMUL8,
82     FT_LOWERBYVALUEMUL8,
83     FT_LOWERMUL8INSTANT,
84     FT_RAISEMUL8INSTANT,
85     FT_TOVALUEMUL8,
86 #endif
87     NUMFLOORTYPES
88 } floortype_e;
89 
90 typedef struct floor_s {
91     thinker_t thinker;
92     floortype_e type;
93     dd_bool crush;
94     Sector *sector;
95     floorstate_e state;
96     int newSpecial;
97     world_Material *material;
98     coord_t floorDestHeight;
99     float speed;
100 #if __JHEXEN__
101     int delayCount;
102     int delayTotal;
103     coord_t stairsDelayHeight;
104     coord_t stairsDelayHeightDelta;
105     coord_t resetHeight;
106     short resetDelay;
107     short resetDelayCount;
108 #endif
109 
110 #ifdef __cplusplus
111     void write(MapStateWriter *msw) const;
112     int read(MapStateReader *msr);
113 #endif
114 } floor_t;
115 
116 #ifdef __cplusplus
117 extern "C" {
118 #endif
119 
120 void T_MoveFloor(void *floorThinker);
121 
122 /**
123  * Handle moving floors.
124  */
125 #if __JHEXEN__
126 int EV_DoFloor(Line *li, byte *args, floortype_e type);
127 #else
128 int EV_DoFloor(Line *li, floortype_e type);
129 #endif
130 
131 #if __JHEXEN__
132 int EV_DoFloorAndCeiling(Line *li, byte *args, int ftype, int ctype);
133 #elif __JDOOM64__
134 int EV_DoFloorAndCeiling(Line *li, int ftype, int ctype);
135 #endif
136 
137 #ifdef __cplusplus
138 } // extern "C"
139 #endif
140 
141 #endif // LIBCOMMON_THINKER_FLOOR_H
142