2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Header for wall.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-12-22 04:35:48 +00:00
|
|
|
#pragma once
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "segment.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
2015-10-09 02:46:10 +00:00
|
|
|
#include "fwd-wall.h"
|
2014-06-21 23:55:24 +00:00
|
|
|
#include "pack.h"
|
2014-09-06 22:26:11 +00:00
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
2015-11-26 02:56:55 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
|
2014-09-06 22:26:11 +00:00
|
|
|
struct WALL_IS_DOORWAY_mask_t
|
|
|
|
{
|
|
|
|
unsigned value;
|
|
|
|
template <unsigned F>
|
|
|
|
constexpr WALL_IS_DOORWAY_mask_t(WALL_IS_DOORWAY_FLAG<F>) :
|
|
|
|
value(F)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WALL_IS_DOORWAY_result_t
|
|
|
|
{
|
|
|
|
unsigned value;
|
|
|
|
template <unsigned F>
|
|
|
|
constexpr WALL_IS_DOORWAY_result_t(WALL_IS_DOORWAY_sresult_t<F>) :
|
|
|
|
value(F)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
template <unsigned F>
|
|
|
|
unsigned operator&(WALL_IS_DOORWAY_FLAG<F>) const
|
|
|
|
{
|
|
|
|
return value & F;
|
|
|
|
}
|
|
|
|
template <unsigned F>
|
|
|
|
WALL_IS_DOORWAY_result_t operator|=(WALL_IS_DOORWAY_FLAG<F>)
|
|
|
|
{
|
|
|
|
value |= F;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
template <unsigned F>
|
|
|
|
bool operator==(WALL_IS_DOORWAY_sresult_t<F>) const
|
|
|
|
{
|
|
|
|
return value == F;
|
|
|
|
}
|
|
|
|
bool operator&(WALL_IS_DOORWAY_mask_t m) const
|
|
|
|
{
|
|
|
|
return value & m.value;
|
|
|
|
}
|
|
|
|
bool operator==(WALL_IS_DOORWAY_result_t) const = delete;
|
|
|
|
template <typename T>
|
|
|
|
bool operator!=(const T &t) const
|
|
|
|
{
|
|
|
|
return !(*this == t);
|
|
|
|
}
|
|
|
|
};
|
2015-11-26 02:56:55 +00:00
|
|
|
#endif
|
2014-09-06 22:26:11 +00:00
|
|
|
|
2014-06-21 23:55:24 +00:00
|
|
|
struct stuckobj : public prohibit_void_ptr<stuckobj>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2015-03-22 18:49:21 +00:00
|
|
|
objnum_t objnum;
|
|
|
|
short wallnum;
|
|
|
|
object_signature_t signature;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//Start old wall structures
|
|
|
|
|
2015-04-26 20:15:50 +00:00
|
|
|
struct v16_wall : public prohibit_void_ptr<v16_wall>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte type; // What kind of special wall.
|
|
|
|
sbyte flags; // Flags for the wall.
|
2015-04-26 20:15:50 +00:00
|
|
|
uint8_t trigger; // Which trigger is associated with the wall.
|
2006-03-20 17:12:09 +00:00
|
|
|
fix hps; // "Hit points" of the wall.
|
|
|
|
sbyte clip_num; // Which animation associated with the wall.
|
|
|
|
sbyte keys;
|
2014-04-27 03:09:11 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-06-21 23:55:24 +00:00
|
|
|
struct v19_wall : public prohibit_void_ptr<v19_wall>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t segnum;
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte type; // What kind of special wall.
|
|
|
|
sbyte flags; // Flags for the wall.
|
2015-04-26 20:15:50 +00:00
|
|
|
int sidenum; // Seg & side for this wall
|
2006-03-20 17:12:09 +00:00
|
|
|
fix hps; // "Hit points" of the wall.
|
2015-04-26 20:15:50 +00:00
|
|
|
uint8_t trigger; // Which trigger is associated with the wall.
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte clip_num; // Which animation associated with the wall.
|
|
|
|
sbyte keys;
|
|
|
|
int linked_wall; // number of linked wall
|
2014-04-27 03:09:11 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
//End old wall structures
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dsx {
|
|
|
|
|
2014-06-21 23:55:24 +00:00
|
|
|
struct wall : public prohibit_void_ptr<wall>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t segnum;
|
2015-01-12 00:26:02 +00:00
|
|
|
int8_t sidenum; // Seg & side for this wall
|
|
|
|
uint8_t type; // What kind of special wall.
|
2006-03-20 17:12:09 +00:00
|
|
|
fix hps; // "Hit points" of the wall.
|
2015-01-12 00:26:02 +00:00
|
|
|
int16_t linked_wall; // number of linked wall
|
2006-03-20 17:12:09 +00:00
|
|
|
ubyte flags; // Flags for the wall.
|
|
|
|
ubyte state; // Opening, closing, etc.
|
2015-04-26 20:15:50 +00:00
|
|
|
uint8_t trigger; // Which trigger is associated with the wall.
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte clip_num; // Which animation associated with the wall.
|
|
|
|
ubyte keys; // which keys are required
|
2015-01-12 00:26:02 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
sbyte controlling_trigger;// which trigger causes something to happen here. Not like "trigger" above, which is the trigger on this wall.
|
|
|
|
// Note: This gets stuffed at load time in gamemine.c. Don't try to use it in the editor. You will be sorry!
|
|
|
|
sbyte cloak_value; // if this wall is cloaked, the fade value
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2014-04-27 03:09:11 +00:00
|
|
|
};
|
2015-12-22 04:18:50 +00:00
|
|
|
|
|
|
|
}
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
2014-06-21 23:55:24 +00:00
|
|
|
struct active_door : public prohibit_void_ptr<active_door>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
int n_parts; // for linked walls
|
2014-04-27 02:39:44 +00:00
|
|
|
array<short, 2> front_wallnum; // front wall numbers for this door
|
|
|
|
array<short, 2> back_wallnum; // back wall numbers for this door
|
2006-03-20 17:12:09 +00:00
|
|
|
fix time; // how long been opening, closing, waiting
|
2014-04-27 02:39:44 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
|
|
|
|
namespace dsx {
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2014-06-21 23:55:24 +00:00
|
|
|
struct cloaking_wall : public prohibit_void_ptr<cloaking_wall>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
short front_wallnum; // front wall numbers for this door
|
|
|
|
short back_wallnum; // back wall numbers for this door
|
2014-01-12 23:00:43 +00:00
|
|
|
array<fix, 4> front_ls; // front wall saved light values
|
|
|
|
array<fix, 4> back_ls; // back wall saved light values
|
2006-03-20 17:12:09 +00:00
|
|
|
fix time; // how long been cloaking or decloaking
|
2014-01-12 23:00:43 +00:00
|
|
|
};
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-06-21 23:55:24 +00:00
|
|
|
struct wclip : public prohibit_void_ptr<wclip>
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
fix play_time;
|
|
|
|
short num_frames;
|
2014-02-02 05:30:48 +00:00
|
|
|
union {
|
|
|
|
array<int16_t, MAX_CLIP_FRAMES> frames;
|
|
|
|
array<int16_t, MAX_CLIP_FRAMES_D1> d1_frames;
|
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
short open_sound;
|
|
|
|
short close_sound;
|
|
|
|
short flags;
|
2014-02-02 05:08:33 +00:00
|
|
|
array<char, 13> filename;
|
2014-02-02 05:30:48 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-04-27 23:12:34 +00:00
|
|
|
static inline ssize_t operator-(wall *w, array<wall, MAX_WALLS> &W)
|
|
|
|
{
|
|
|
|
return w - static_cast<wall *>(&*W.begin());
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-01-12 00:26:03 +00:00
|
|
|
static inline WALL_IS_DOORWAY_result_t WALL_IS_DOORWAY(const vcsegptr_t seg, const uint_fast32_t side)
|
2013-12-12 00:21:54 +00:00
|
|
|
{
|
2015-01-12 00:26:03 +00:00
|
|
|
const auto child = seg->children[side];
|
|
|
|
if (unlikely(child == segment_none))
|
2013-12-12 00:21:54 +00:00
|
|
|
return WID_WALL;
|
2015-01-12 00:26:03 +00:00
|
|
|
if (unlikely(child == segment_exit))
|
2013-12-12 00:21:54 +00:00
|
|
|
return WID_EXTERNAL;
|
2015-01-12 00:26:03 +00:00
|
|
|
const auto &s = seg->sides[side];
|
|
|
|
if (likely(s.wall_num == wall_none))
|
2013-12-12 00:21:54 +00:00
|
|
|
return WID_NO_WALL;
|
2015-01-12 00:26:03 +00:00
|
|
|
return wall_is_doorway(s);
|
2013-12-12 00:21:54 +00:00
|
|
|
}
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|
2015-07-25 23:10:45 +00:00
|
|
|
#endif
|