| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Header for wall.c |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include "dsx-ns.h" |
| 29 |
#include "fwd-segment.h" |
| 30 |
#include "fwd-wall.h" |
| 31 |
#include "fwd-object.h" |
| 32 |
#include "pack.h" |
| 33 |
#include "switch.h" |
| 34 |
#include "d_underlying_value.h" |
| 35 |
|
| 36 |
namespace dcx { |
| 37 |
|
| 38 |
enum class wall_key : uint8_t |
| 39 |
{ |
| 40 |
none = 1, |
| 41 |
blue = 2, |
| 42 |
red = 4, |
| 43 |
gold = 8, |
| 44 |
}; |
| 45 |
|
| 46 |
constexpr uint8_t operator&(const wall_key a, const wall_key b) |
| 47 |
{ |
| 48 |
return underlying_value(a) & underlying_value(b); |
| 49 |
} |
| 50 |
|
| 51 |
#ifdef DXX_BUILD_DESCENT |
| 52 |
enum class wall_is_doorway_mask : uint8_t |
| 53 |
{ |
| 54 |
None = 0, |
| 55 |
fly = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::fly), |
| 56 |
rendpast = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::rendpast), |
| 57 |
fly_rendpast = fly | rendpast, |
| 58 |
}; |
| 59 |
|
| 60 |
enum class wall_is_doorway_result : uint8_t |
| 61 |
{ |
| 62 |
// WALL_IS_DOORWAY return values F/R/RP |
| 63 |
wall = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::render), // 0/1/0 wall |
| 64 |
transparent_wall = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::render) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::rendpast), // 0/1/1 transparent wall |
| 65 |
illusory_wall = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::fly) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::render), // 1/1/0 illusory wall |
| 66 |
transillusory_wall = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::fly) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::render) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::rendpast), // 1/1/1 transparent illusory wall |
| 67 |
no_wall = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::fly) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::rendpast), // 1/0/1 no wall, can fly through |
| 68 |
external = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::external), // 0/0/0/1 do not see it, do not fly through it |
| 69 |
/* if DXX_BUILD_DESCENT == 2 */ |
| 70 |
cloaked_wall = static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::render) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::rendpast) | static_cast<uint8_t>(WALL_IS_DOORWAY_FLAG::cloaked), |
| 71 |
/* endif */ |
| 72 |
}; |
| 73 |
|
| 74 |
[[nodiscard]] |
| 75 |
static constexpr bool operator&(const wall_is_doorway_result r, const WALL_IS_DOORWAY_FLAG f) |
| 76 |
{ |
| 77 |
return static_cast<uint8_t>(r) & static_cast<uint8_t>(f); |
| 78 |
} |
| 79 |
|
| 80 |
[[nodiscard]] |
| 81 |
static constexpr bool operator&(const wall_is_doorway_result r, const wall_is_doorway_mask m) |
| 82 |
{ |
| 83 |
return static_cast<uint8_t>(r) & static_cast<uint8_t>(m); |
| 84 |
} |
| 85 |
|
| 86 |
static inline wall_is_doorway_result &operator|=(wall_is_doorway_result &r, const WALL_IS_DOORWAY_FLAG f) |
| 87 |
{ |
| 88 |
return r = static_cast<wall_is_doorway_result>(static_cast<uint8_t>(r) | static_cast<uint8_t>(f)); |
| 89 |
} |
| 90 |
|
| 91 |
struct stuckobj : public prohibit_void_ptr<stuckobj> |
| 92 |
{ |
| 93 |
objnum_t objnum = object_none; |
| 94 |
wallnum_t wallnum = wall_none; |
| 95 |
}; |
| 96 |
#endif |
| 97 |
|
| 98 |
//Start old wall structures |
| 99 |
|
| 100 |
struct v16_wall : public prohibit_void_ptr<v16_wall> |
| 101 |
{ |
| 102 |
sbyte type; // What kind of special wall. |
| 103 |
sbyte flags; // Flags for the wall. |
| 104 |
uint8_t trigger; // Which trigger is associated with the wall. |
| 105 |
fix hps; // "Hit points" of the wall. |
| 106 |
sbyte clip_num; // Which animation associated with the wall. |
| 107 |
sbyte keys; |
| 108 |
}; |
| 109 |
|
| 110 |
struct v19_wall : public prohibit_void_ptr<v19_wall> |
| 111 |
{ |
| 112 |
segnum_t segnum; |
| 113 |
sbyte type; // What kind of special wall. |
| 114 |
sbyte flags; // Flags for the wall. |
| 115 |
int sidenum; // Seg & side for this wall |
| 116 |
fix hps; // "Hit points" of the wall. |
| 117 |
uint8_t trigger; // Which trigger is associated with the wall. |
| 118 |
sbyte clip_num; // Which animation associated with the wall. |
| 119 |
sbyte keys; |
| 120 |
wallnum_t linked_wall; // number of linked wall |
| 121 |
}; |
| 122 |
|
| 123 |
#ifdef DXX_BUILD_DESCENT |
| 124 |
class d_level_unique_stuck_object_state |
| 125 |
{ |
| 126 |
protected: |
| 127 |
unsigned Num_stuck_objects{0}; |
| 128 |
std::array<stuckobj, 32> Stuck_objects; |
| 129 |
public: |
| 130 |
void init_stuck_objects(); |
| 131 |
}; |
| 132 |
#endif |
| 133 |
|
| 134 |
enum class wall_flag : uint8_t |
| 135 |
{ |
| 136 |
blasted = 1, // Blasted out wall. |
| 137 |
door_opened = 1u << 1, // Open door. |
| 138 |
door_locked = 1u << 3, // Door is locked. |
| 139 |
door_auto = 1u << 4, // Door automatically closes after time. |
| 140 |
illusion_off = 1u << 5, // Illusionary wall is shut off. |
| 141 |
exploding = 1u << 6, |
| 142 |
/* if DXX_BUILD_DESCENT == 2 */ |
| 143 |
buddy_proof = 1u << 7, // Buddy assumes he cannot get through this wall. |
| 144 |
/* endif */ |
| 145 |
}; |
| 146 |
|
| 147 |
enum class wall_flags : uint8_t; |
| 148 |
|
| 149 |
enum class wall_state : uint8_t |
| 150 |
{ |
| 151 |
closed, // Door is closed |
| 152 |
opening, // Door is opening. |
| 153 |
waiting, // Waiting to close |
| 154 |
closing, // Door is closing |
| 155 |
/* if DXX_BUILD_DESCENT == 2 */ |
| 156 |
open, // Door is open, and staying open |
| 157 |
cloaking, // Wall is going from closed -> open |
| 158 |
decloaking, // Wall is going from open -> closed |
| 159 |
/* endif */ |
| 160 |
}; |
| 161 |
|
| 162 |
static constexpr auto &operator|=(wall_flags &wall, const wall_flag f) |
| 163 |
{ |
| 164 |
return wall = static_cast<wall_flags>(underlying_value(wall) | underlying_value(f)); |
| 165 |
} |
| 166 |
|
| 167 |
static constexpr auto &operator&=(wall_flags &wall, const wall_flag f) |
| 168 |
{ |
| 169 |
return wall = static_cast<wall_flags>(underlying_value(wall) & underlying_value(f)); |
| 170 |
} |
| 171 |
|
| 172 |
static constexpr auto operator~(const wall_flag f) |
| 173 |
{ |
| 174 |
return static_cast<wall_flag>(~underlying_value(f)); |
| 175 |
} |
| 176 |
|
| 177 |
static constexpr auto operator&(const wall_flags wall, const wall_flag f) |
| 178 |
{ |
| 179 |
return underlying_value(wall) & underlying_value(f); |
| 180 |
} |
| 181 |
|
| 182 |
static constexpr auto operator|(const wall_flag f1, const wall_flag f2) |
| 183 |
{ |
| 184 |
return static_cast<wall_flag>(underlying_value(f1) | underlying_value(f2)); |
| 185 |
} |
| 186 |
|
| 187 |
} |
| 188 |
|
| 189 |
//End old wall structures |
| 190 |
|
| 191 |
#ifdef DXX_BUILD_DESCENT |
| 192 |
namespace dsx { |
| 193 |
|
| 194 |
/* No shared state is possible for this structure, but include the |
| 195 |
* `unique` qualifier to document its status. |
| 196 |
*/ |
| 197 |
class d_level_unique_stuck_object_state : public ::dcx::d_level_unique_stuck_object_state |
| 198 |
{ |
| 199 |
public: |
| 200 |
void add_stuck_object(fvcwallptr &, vmobjptridx_t objp, const shared_segment &segp, sidenum_t sidenum); |
| 201 |
void remove_stuck_object(vcobjidx_t); |
| 202 |
void kill_stuck_objects(fvmobjptr &, vcwallidx_t wallnum); |
| 203 |
}; |
| 204 |
|
| 205 |
extern d_level_unique_stuck_object_state LevelUniqueStuckObjectState; |
| 206 |
|
| 207 |
struct wall : public prohibit_void_ptr<wall> |
| 208 |
{ |
| 209 |
segnum_t segnum; |
| 210 |
sidenum_t sidenum; // Seg & side for this wall |
| 211 |
uint8_t type; // What kind of special wall. |
| 212 |
fix hps; // "Hit points" of the wall. |
| 213 |
uint16_t explode_time_elapsed; |
| 214 |
wallnum_t linked_wall; // number of linked wall |
| 215 |
wall_flags flags; // Flags for the wall. |
| 216 |
wall_state state; // Opening, closing, etc. |
| 217 |
trgnum_t trigger; // Which trigger is associated with the wall. |
| 218 |
sbyte clip_num; // Which animation associated with the wall. |
| 219 |
wall_key keys; // which keys are required |
| 220 |
#if DXX_BUILD_DESCENT == 2 |
| 221 |
trgnum_t controlling_trigger;// which trigger causes something to happen here. Not like "trigger" above, which is the trigger on this wall. |
| 222 |
// Note: This gets stuffed at load time in gamemine.c. Don't try to use it in the editor. You will be sorry! |
| 223 |
sbyte cloak_value; // if this wall is cloaked, the fade value |
| 224 |
#endif |
| 225 |
}; |
| 226 |
|
| 227 |
} |
| 228 |
|
| 229 |
namespace dcx { |
| 230 |
|
| 231 |
struct active_door : public prohibit_void_ptr<active_door> |
| 232 |
{ |
| 233 |
unsigned n_parts; // for linked walls |
| 234 |
std::array<wallnum_t, 2> front_wallnum; // front wall numbers for this door |
| 235 |
std::array<wallnum_t, 2> back_wallnum; // back wall numbers for this door |
| 236 |
fix time; // how long been opening, closing, waiting |
| 237 |
}; |
| 238 |
|
| 239 |
struct d_level_unique_active_door_state |
| 240 |
{ |
| 241 |
active_door_array ActiveDoors; |
| 242 |
}; |
| 243 |
|
| 244 |
} |
| 245 |
|
| 246 |
namespace dsx { |
| 247 |
#if DXX_BUILD_DESCENT == 2 |
| 248 |
struct cloaking_wall : public prohibit_void_ptr<cloaking_wall> |
| 249 |
{ |
| 250 |
wallnum_t front_wallnum; // front wall numbers for this door |
| 251 |
wallnum_t back_wallnum; // back wall numbers for this door |
| 252 |
std::array<fix, 4> front_ls; // front wall saved light values |
| 253 |
std::array<fix, 4> back_ls; // back wall saved light values |
| 254 |
fix time; // how long been cloaking or decloaking |
| 255 |
}; |
| 256 |
|
| 257 |
struct d_level_unique_cloaking_wall_state |
| 258 |
{ |
| 259 |
cloaking_wall_array CloakingWalls; |
| 260 |
}; |
| 261 |
#endif |
| 262 |
|
| 263 |
struct d_level_unique_wall_state |
| 264 |
{ |
| 265 |
wall_array Walls; |
| 266 |
}; |
| 267 |
|
| 268 |
struct d_level_unique_wall_subsystem_state : |
| 269 |
d_level_unique_active_door_state, |
| 270 |
d_level_unique_trigger_state, |
| 271 |
d_level_unique_wall_state |
| 272 |
#if DXX_BUILD_DESCENT == 2 |
| 273 |
, d_level_unique_cloaking_wall_state |
| 274 |
#endif |
| 275 |
{ |
| 276 |
}; |
| 277 |
|
| 278 |
extern d_level_unique_wall_subsystem_state LevelUniqueWallSubsystemState; |
| 279 |
|
| 280 |
struct wclip : public prohibit_void_ptr<wclip> |
| 281 |
{ |
| 282 |
fix play_time; |
| 283 |
uint16_t num_frames; |
| 284 |
union { |
| 285 |
std::array<uint16_t, MAX_CLIP_FRAMES> frames; |
| 286 |
std::array<uint16_t, MAX_CLIP_FRAMES_D1> d1_frames; |
| 287 |
}; |
| 288 |
sound_effect open_sound; |
| 289 |
sound_effect close_sound; |
| 290 |
short flags; |
| 291 |
std::array<char, 13> filename; |
| 292 |
}; |
| 293 |
|
| 294 |
constexpr std::integral_constant<uint16_t, 0xffff> wclip_frames_none{}; |
| 295 |
|
| 296 |
} |
| 297 |
#endif |