dxx-rebirth/common/main/wall.h

234 lines
6.6 KiB
C
Raw Normal View History

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
2013-12-26 04:18:28 +00:00
#ifdef __cplusplus
#include "fwd-segment.h"
#include "fwd-wall.h"
2018-08-29 01:47:42 +00:00
#include "fwd-object.h"
#include "pack.h"
#include "switch.h"
namespace dcx {
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
struct WALL_IS_DOORWAY_mask_t
{
uint8_t value;
constexpr WALL_IS_DOORWAY_mask_t(WALL_IS_DOORWAY_FLAG F) :
value(static_cast<uint8_t>(F))
{
}
};
struct WALL_IS_DOORWAY_result_t
{
uint8_t value;
constexpr WALL_IS_DOORWAY_result_t(const WALL_IS_DOORWAY_sresult_t f) :
value(static_cast<unsigned>(f))
{
}
unsigned operator&(WALL_IS_DOORWAY_FLAG f) const
{
return value & static_cast<uint8_t>(f);
}
WALL_IS_DOORWAY_result_t &operator|=(WALL_IS_DOORWAY_FLAG f)
{
value |= static_cast<uint8_t>(f);
return *this;
}
bool operator==(WALL_IS_DOORWAY_sresult_t F) const
{
return value == static_cast<unsigned>(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);
}
};
struct stuckobj : public prohibit_void_ptr<stuckobj>
{
2018-08-04 17:52:57 +00:00
objnum_t objnum = object_none;
wallnum_t wallnum = wall_none;
};
2018-08-29 01:47:42 +00:00
#endif
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>
{
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
struct v19_wall : public prohibit_void_ptr<v19_wall>
{
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
2018-08-29 01:47:42 +00:00
#ifdef dsx
class d_level_unique_stuck_object_state
{
protected:
unsigned Num_stuck_objects = 0;
2020-05-02 21:18:42 +00:00
std::array<stuckobj, 32> Stuck_objects;
public:
void init_stuck_objects();
};
2018-08-29 01:47:42 +00:00
#endif
}
2006-03-20 17:12:09 +00:00
//End old wall structures
2016-01-09 16:38:15 +00:00
#ifdef dsx
namespace dsx {
/* No shared state is possible for this structure, but include the
* `unique` qualifier to document its status.
*/
class d_level_unique_stuck_object_state : public ::dcx::d_level_unique_stuck_object_state
{
public:
void add_stuck_object(fvcwallptr &, vmobjptridx_t objp, const shared_segment &segp, unsigned sidenum);
void remove_stuck_object(vcobjidx_t);
void kill_stuck_objects(fvmobjptr &, vcwallidx_t wallnum);
};
extern d_level_unique_stuck_object_state LevelUniqueStuckObjectState;
struct wall : public prohibit_void_ptr<wall>
{
segnum_t segnum;
2016-12-24 22:44:08 +00:00
uint8_t sidenum; // Seg & side for this wall
2015-01-12 00:26:02 +00:00
uint8_t type; // What kind of special wall.
2006-03-20 17:12:09 +00:00
fix hps; // "Hit points" of the wall.
uint16_t explode_time_elapsed;
2016-02-06 22:12:54 +00:00
wallnum_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
#endif
2014-04-27 03:09:11 +00:00
};
}
2006-03-20 17:12:09 +00:00
namespace dcx {
struct active_door : public prohibit_void_ptr<active_door>
{
2016-02-12 04:02:28 +00:00
unsigned n_parts; // for linked walls
2020-05-02 21:18:42 +00:00
std::array<wallnum_t, 2> front_wallnum; // front wall numbers for this door
std::array<wallnum_t, 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
struct d_level_unique_active_door_state
{
active_door_array ActiveDoors;
};
2016-12-10 17:51:08 +00:00
}
namespace dsx {
#if defined(DXX_BUILD_DESCENT_II)
struct cloaking_wall : public prohibit_void_ptr<cloaking_wall>
{
2016-02-06 22:12:54 +00:00
wallnum_t front_wallnum; // front wall numbers for this door
wallnum_t back_wallnum; // back wall numbers for this door
2020-05-02 21:18:42 +00:00
std::array<fix, 4> front_ls; // front wall saved light values
std::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
};
struct d_level_unique_cloaking_wall_state
{
cloaking_wall_array CloakingWalls;
};
#endif
2006-03-20 17:12:09 +00:00
struct d_level_unique_wall_state
{
wall_array Walls;
};
struct d_level_unique_wall_subsystem_state :
d_level_unique_active_door_state,
d_level_unique_trigger_state,
d_level_unique_wall_state
#if defined(DXX_BUILD_DESCENT_II)
, d_level_unique_cloaking_wall_state
#endif
{
};
extern d_level_unique_wall_subsystem_state LevelUniqueWallSubsystemState;
2016-02-12 04:02:28 +00:00
struct wclip : public prohibit_void_ptr<wclip>
{
2006-03-20 17:12:09 +00:00
fix play_time;
2017-06-17 23:05:16 +00:00
uint16_t num_frames;
2014-02-02 05:30:48 +00:00
union {
std::array<uint16_t, MAX_CLIP_FRAMES> frames;
std::array<uint16_t, MAX_CLIP_FRAMES_D1> d1_frames;
2014-02-02 05:30:48 +00:00
};
2006-03-20 17:12:09 +00:00
short open_sound;
short close_sound;
short flags;
2020-05-02 21:18:42 +00:00
std::array<char, 13> filename;
2014-02-02 05:30:48 +00:00
};
2006-03-20 17:12:09 +00:00
constexpr std::integral_constant<uint16_t, 0xffff> wclip_frames_none{};
2017-06-17 23:05:16 +00:00
}
2006-03-20 17:12:09 +00:00
#endif
2015-07-25 23:10:45 +00:00
#endif