Tighten eclip::dest_bm_num handling
Instead of testing for -1, test for any out-of-range value.
This commit is contained in:
parent
29c6d63daa
commit
a3871cfefd
|
@ -60,7 +60,7 @@ struct eclip : public prohibit_void_ptr<eclip>
|
||||||
short changing_object_texture; //Which element of ObjBitmapPtrs array to replace.
|
short changing_object_texture; //Which element of ObjBitmapPtrs array to replace.
|
||||||
int flags; //see above
|
int flags; //see above
|
||||||
int crit_clip; //use this clip instead of above one when mine critical
|
int crit_clip; //use this clip instead of above one when mine critical
|
||||||
int dest_bm_num; //use this bitmap when monitor destroyed
|
unsigned dest_bm_num; //use this bitmap when monitor destroyed
|
||||||
int dest_vclip; //what vclip to play when exploding
|
int dest_vclip; //what vclip to play when exploding
|
||||||
int dest_eclip; //what eclip to play when exploding
|
int dest_eclip; //what eclip to play when exploding
|
||||||
fix dest_size; //3d size of explosion
|
fix dest_size; //3d size of explosion
|
||||||
|
|
|
@ -703,7 +703,7 @@ static void bm_read_eclip(const std::string &dest_bm, const char *const arg, int
|
||||||
Effects[clip_num].dest_eclip = dest_eclip;
|
Effects[clip_num].dest_eclip = dest_eclip;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Effects[clip_num].dest_bm_num = -1;
|
Effects[clip_num].dest_bm_num = ~0u;
|
||||||
Effects[clip_num].dest_eclip = eclip_none;
|
Effects[clip_num].dest_eclip = eclip_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -681,7 +681,6 @@ static void set_texture_name(char *name)
|
||||||
static void bm_read_eclip(int skip)
|
static void bm_read_eclip(int skip)
|
||||||
{
|
{
|
||||||
bitmap_index bitmap;
|
bitmap_index bitmap;
|
||||||
int dest_bm_num = 0;
|
|
||||||
|
|
||||||
assert(clip_num < Effects.size());
|
assert(clip_num < Effects.size());
|
||||||
|
|
||||||
|
@ -690,6 +689,7 @@ static void bm_read_eclip(int skip)
|
||||||
|
|
||||||
Effects[clip_num].flags = 0;
|
Effects[clip_num].flags = 0;
|
||||||
|
|
||||||
|
unsigned dest_bm_num = 0;
|
||||||
//load the dest bitmap first, so that after this routine, the last-loaded
|
//load the dest bitmap first, so that after this routine, the last-loaded
|
||||||
//texture will be the monitor, so that lighting parameter will be applied
|
//texture will be the monitor, so that lighting parameter will be applied
|
||||||
//to the correct texture
|
//to the correct texture
|
||||||
|
@ -803,7 +803,7 @@ static void bm_read_eclip(int skip)
|
||||||
Effects[clip_num].dest_eclip = dest_eclip;
|
Effects[clip_num].dest_eclip = dest_eclip;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Effects[clip_num].dest_bm_num = -1;
|
Effects[clip_num].dest_bm_num = ~0u;
|
||||||
Effects[clip_num].dest_eclip = eclip_none;
|
Effects[clip_num].dest_eclip = eclip_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -540,14 +540,13 @@ static int effect_parent_is_guidebot(fvcobjptr &vcobjptr, const laser_parent &la
|
||||||
namespace dsx {
|
namespace dsx {
|
||||||
int check_effect_blowup(const vmsegptridx_t seg,int side,const vms_vector &pnt, const laser_parent &blower, int force_blowup_flag, int remote)
|
int check_effect_blowup(const vmsegptridx_t seg,int side,const vms_vector &pnt, const laser_parent &blower, int force_blowup_flag, int remote)
|
||||||
{
|
{
|
||||||
int tm,db;
|
int tm;
|
||||||
|
|
||||||
#if defined(DXX_BUILD_DESCENT_I)
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
static constexpr std::integral_constant<int, 0> force_blowup_flag{};
|
static constexpr std::integral_constant<int, 0> force_blowup_flag{};
|
||||||
#elif defined(DXX_BUILD_DESCENT_II)
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
int trigger_check = 0, is_trigger = 0;
|
int trigger_check = 0, is_trigger = 0;
|
||||||
auto wall_num = seg->sides[side].wall_num;
|
auto wall_num = seg->sides[side].wall_num;
|
||||||
db=0;
|
|
||||||
|
|
||||||
// If this wall has a trigger and the blower-upper is not the player or the buddy, abort!
|
// If this wall has a trigger and the blower-upper is not the player or the buddy, abort!
|
||||||
trigger_check = !(blower.parent_type == OBJ_PLAYER || effect_parent_is_guidebot(vcobjptr, blower));
|
trigger_check = !(blower.parent_type == OBJ_PLAYER || effect_parent_is_guidebot(vcobjptr, blower));
|
||||||
|
@ -565,12 +564,13 @@ int check_effect_blowup(const vmsegptridx_t seg,int side,const vms_vector &pnt,
|
||||||
int tmf = tm&0xc000; //tm flags
|
int tmf = tm&0xc000; //tm flags
|
||||||
tm &= 0x3fff; //tm without flags
|
tm &= 0x3fff; //tm without flags
|
||||||
|
|
||||||
const int ec = TmapInfo[tm].eclip_num;
|
const auto ec = TmapInfo[tm].eclip_num;
|
||||||
|
unsigned db = 0;
|
||||||
#if defined(DXX_BUILD_DESCENT_I)
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
if (ec!=-1 && (db=Effects[ec].dest_bm_num)!=-1 && !(Effects[ec].flags&EF_ONE_SHOT))
|
if (ec != eclip_none && (db = Effects[ec].dest_bm_num) != ~0u && !(Effects[ec].flags & EF_ONE_SHOT))
|
||||||
#elif defined(DXX_BUILD_DESCENT_II)
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
//check if it's an animation (monitor) or casts light
|
//check if it's an animation (monitor) or casts light
|
||||||
if ((ec!=-1 && ((db=Effects[ec].dest_bm_num)!=-1 && !(Effects[ec].flags&EF_ONE_SHOT))) || (ec==-1 && (TmapInfo[tm].destroyed!=-1)))
|
if ((ec != eclip_none && ((db = Effects[ec].dest_bm_num) != ~0u && !(Effects[ec].flags & EF_ONE_SHOT))) || (ec == eclip_none && (TmapInfo[tm].destroyed != -1)))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const grs_bitmap *bm = &GameBitmaps[Textures[tm].index];
|
const grs_bitmap *bm = &GameBitmaps[Textures[tm].index];
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "hudmsg.h"
|
#include "hudmsg.h"
|
||||||
#include "switch.h"
|
#include "switch.h"
|
||||||
|
#include "textures.h"
|
||||||
#include "automap.h"
|
#include "automap.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "playsave.h"
|
#include "playsave.h"
|
||||||
|
@ -1794,7 +1795,7 @@ static void net_udp_process_monitor_vector(uint32_t vector)
|
||||||
{
|
{
|
||||||
if ( ((tm = j.tmap_num2) != 0) &&
|
if ( ((tm = j.tmap_num2) != 0) &&
|
||||||
((ec = TmapInfo[tm&0x3fff].eclip_num) != -1) &&
|
((ec = TmapInfo[tm&0x3fff].eclip_num) != -1) &&
|
||||||
((bm = Effects[ec].dest_bm_num) != -1) )
|
(bm = Effects[ec].dest_bm_num) != ~0u)
|
||||||
{
|
{
|
||||||
if (vector & 1)
|
if (vector & 1)
|
||||||
{
|
{
|
||||||
|
@ -1851,7 +1852,8 @@ static int net_udp_create_monitor_vector(void)
|
||||||
blown_bitmap_array blown_bitmaps;
|
blown_bitmap_array blown_bitmaps;
|
||||||
range_for (auto &i, partial_const_range(Effects, Num_effects))
|
range_for (auto &i, partial_const_range(Effects, Num_effects))
|
||||||
{
|
{
|
||||||
if (i.dest_bm_num > 0) {
|
if (i.dest_bm_num < Textures.size())
|
||||||
|
{
|
||||||
blown_bitmaps.insert_unique(i.dest_bm_num);
|
blown_bitmaps.insert_unique(i.dest_bm_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1864,7 +1866,7 @@ static int net_udp_create_monitor_vector(void)
|
||||||
if ((tm = j.tmap_num2) != 0)
|
if ((tm = j.tmap_num2) != 0)
|
||||||
{
|
{
|
||||||
if ( ((ec = TmapInfo[tm&0x3fff].eclip_num) != -1) &&
|
if ( ((ec = TmapInfo[tm&0x3fff].eclip_num) != -1) &&
|
||||||
(Effects[ec].dest_bm_num != -1) )
|
Effects[ec].dest_bm_num != ~0u)
|
||||||
{
|
{
|
||||||
monitor_num++;
|
monitor_num++;
|
||||||
Assert(monitor_num < 32);
|
Assert(monitor_num < 32);
|
||||||
|
|
|
@ -76,7 +76,7 @@ static void paging_touch_wall_effects( int tmap_num )
|
||||||
if ( i.changing_wall_texture == tmap_num ) {
|
if ( i.changing_wall_texture == tmap_num ) {
|
||||||
paging_touch_vclip(i.vc);
|
paging_touch_vclip(i.vc);
|
||||||
|
|
||||||
if (i.dest_bm_num > -1)
|
if (i.dest_bm_num < Textures.size())
|
||||||
PIGGY_PAGE_IN( Textures[i.dest_bm_num] ); //use this bitmap when monitor destroyed
|
PIGGY_PAGE_IN( Textures[i.dest_bm_num] ); //use this bitmap when monitor destroyed
|
||||||
if ( i.dest_vclip > -1 )
|
if ( i.dest_vclip > -1 )
|
||||||
paging_touch_vclip(Vclip[i.dest_vclip]); //what vclip to play when exploding
|
paging_touch_vclip(Vclip[i.dest_vclip]); //what vclip to play when exploding
|
||||||
|
|
|
@ -1387,11 +1387,13 @@ static void bng_process_segment(const object &objp, fix damage, const vmsegptrid
|
||||||
|
|
||||||
// Process only walls which have glass.
|
// Process only walls which have glass.
|
||||||
if ((tm=segp->sides[sidenum].tmap_num2) != 0) {
|
if ((tm=segp->sides[sidenum].tmap_num2) != 0) {
|
||||||
int ec, db;
|
int ec;
|
||||||
|
|
||||||
tm &= 0x3fff; //tm without flags
|
tm &= 0x3fff; //tm without flags
|
||||||
|
|
||||||
if ((((ec=TmapInfo[tm].eclip_num)!=-1) && ((db=Effects[ec].dest_bm_num)!=-1 && !(Effects[ec].flags&EF_ONE_SHOT))) || (ec==-1 && (TmapInfo[tm].destroyed!=-1))) {
|
if (((ec = TmapInfo[tm].eclip_num) != -1 &&
|
||||||
|
(Effects[ec].dest_bm_num != ~0u && !(Effects[ec].flags & EF_ONE_SHOT))) || (ec == -1 && (TmapInfo[tm].destroyed != -1)))
|
||||||
|
{
|
||||||
const auto &&pnt = compute_center_point_on_side(vcvertptr, segp, sidenum);
|
const auto &&pnt = compute_center_point_on_side(vcvertptr, segp, sidenum);
|
||||||
dist = vm_vec_dist_quick(pnt, objp.pos);
|
dist = vm_vec_dist_quick(pnt, objp.pos);
|
||||||
if (dist < damage/2) {
|
if (dist < damage/2) {
|
||||||
|
|
Loading…
Reference in a new issue