Add fwd-vclip.h

This commit is contained in:
Kp 2018-10-21 00:24:07 +00:00
parent d1092f3ea2
commit 991f72a775
5 changed files with 38 additions and 13 deletions

34
common/main/fwd-vclip.h Normal file
View file

@ -0,0 +1,34 @@
/*
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
* It is copyright by its individual contributors, as recorded in the
* project's Git history. See COPYING.txt at the top level for license
* terms and a link to the Git history.
*/
#pragma once
#include <array>
#include <type_traits>
#include "dxxsconf.h"
#include "dsx-ns.h"
using std::array;
namespace dcx {
struct vclip;
extern unsigned Num_vclips;
}
#ifdef dsx
namespace dsx {
#if defined(DXX_BUILD_DESCENT_I)
#define VCLIP_MAXNUM 70
#elif defined(DXX_BUILD_DESCENT_II)
#define VCLIP_MAXNUM 110
#endif
using d_vclip_array = array<vclip, VCLIP_MAXNUM>;
extern d_vclip_array Vclip;
#undef VCLIP_MAXNUM
}
#endif

View file

@ -29,9 +29,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#ifdef __cplusplus
#include "dxxsconf.h"
#include "dsx-ns.h"
#include "compiler-array.h"
#include "fwd-valptridx.h"
#include "fwd-vclip.h"
#define VCLIP_SMALL_EXPLOSION 2
@ -43,13 +42,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#ifdef dsx
namespace dsx {
#if defined(DXX_BUILD_DESCENT_I)
constexpr std::integral_constant<std::size_t, 70> VCLIP_MAXNUM{};
#elif defined(DXX_BUILD_DESCENT_II)
#define VCLIP_WATER_HIT 84
#define VCLIP_AFTERBURNER_BLOB 95
#define VCLIP_MONITOR_STATIC 99
constexpr std::integral_constant<std::size_t, 110> VCLIP_MAXNUM{};
#endif
}
@ -72,14 +68,9 @@ struct vclip : public prohibit_void_ptr<vclip>
constexpr std::integral_constant<int, -1> vclip_none{};
extern unsigned Num_vclips;
}
namespace dsx {
using d_vclip_array = array<vclip, VCLIP_MAXNUM>;
extern d_vclip_array Vclip;
// draw an object which renders as a vclip.
void draw_vclip_object(grs_canvas &, vcobjptridx_t obj, fix timeleft, int lighted, const vclip &);
void draw_weapon_vclip(grs_canvas &, vcobjptridx_t obj);

View file

@ -1126,7 +1126,7 @@ static void bm_read_vclip(int skip)
#endif
{
bitmap_index bi;
Assert(clip_num < VCLIP_MAXNUM);
assert(clip_num < Vclip.size());
#if defined(DXX_BUILD_DESCENT_II)
if (clip_num >= Num_vclips)

View file

@ -166,7 +166,7 @@ static array<char[FILENAME_LEN], MAX_POLYGON_MODELS_NEW> Save_pof_names;
static int convert_vclip(int vc) {
if (vc < 0)
return vc;
if ((vc < VCLIP_MAXNUM) && (Vclip[vc].num_frames != ~0u))
if (vc < Vclip.size() && (Vclip[vc].num_frames != ~0u))
return vc;
return 0;
}

View file

@ -5429,7 +5429,7 @@ void init_hoard_data()
//Create orb vclip
orb_vclip = Num_vclips++;
Assert(Num_vclips <= VCLIP_MAXNUM);
assert(Num_vclips <= Vclip.size());
Vclip[orb_vclip].play_time = F1_0/2;
Vclip[orb_vclip].num_frames = n_orb_frames;
Vclip[orb_vclip].frame_time = Vclip[orb_vclip].play_time / Vclip[orb_vclip].num_frames;