Use enum class for check_volatile_wall
This commit is contained in:
parent
bc488a8f57
commit
e283a22709
|
@ -64,7 +64,13 @@ void drop_player_eggs(vobjptridx_t playerobj);
|
||||||
#if defined(DXX_BUILD_DESCENT_II)
|
#if defined(DXX_BUILD_DESCENT_II)
|
||||||
void do_final_boss_frame(void);
|
void do_final_boss_frame(void);
|
||||||
void do_final_boss_hacks(void);
|
void do_final_boss_hacks(void);
|
||||||
int check_volatile_wall(vobjptridx_t obj,vcsegptr_t seg,int sidenum);
|
enum class volatile_wall_result : int8_t
|
||||||
|
{
|
||||||
|
none = -1,
|
||||||
|
lava,
|
||||||
|
water,
|
||||||
|
};
|
||||||
|
volatile_wall_result check_volatile_wall(vobjptridx_t obj,vcsegptr_t seg,int sidenum);
|
||||||
extern int Final_boss_is_dead;
|
extern int Final_boss_is_dead;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -448,7 +448,7 @@ void scrape_player_on_wall(const vobjptridx_t obj, const vsegptridx_t hitseg, sh
|
||||||
//see if wall is volatile or water
|
//see if wall is volatile or water
|
||||||
//if volatile, cause damage to player
|
//if volatile, cause damage to player
|
||||||
//returns 1=lava, 2=water
|
//returns 1=lava, 2=water
|
||||||
int check_volatile_wall(const vobjptridx_t obj, const vcsegptr_t seg, int sidenum)
|
volatile_wall_result check_volatile_wall(const vobjptridx_t obj, const vcsegptr_t seg, int sidenum)
|
||||||
{
|
{
|
||||||
Assert(obj->type==OBJ_PLAYER);
|
Assert(obj->type==OBJ_PLAYER);
|
||||||
|
|
||||||
|
@ -474,30 +474,28 @@ int check_volatile_wall(const vobjptridx_t obj, const vcsegptr_t seg, int sidenu
|
||||||
obj->mtype.phys_info.rotvel.z = (d_rand() - 16384)/2;
|
obj->mtype.phys_info.rotvel.z = (d_rand() - 16384)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (d>0)?1:2;
|
return (d > 0) ? volatile_wall_result::lava : volatile_wall_result::water;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return volatile_wall_result::none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this gets called when an object is scraping along the wall
|
//this gets called when an object is scraping along the wall
|
||||||
void scrape_player_on_wall(const vobjptridx_t obj, const vsegptridx_t hitseg, short hitside, const vms_vector &hitpt)
|
void scrape_player_on_wall(const vobjptridx_t obj, const vsegptridx_t hitseg, short hitside, const vms_vector &hitpt)
|
||||||
{
|
{
|
||||||
int type;
|
|
||||||
|
|
||||||
if (obj->type != OBJ_PLAYER || get_player_id(obj) != Player_num)
|
if (obj->type != OBJ_PLAYER || get_player_id(obj) != Player_num)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((type=check_volatile_wall(obj,hitseg,hitside))!=0) {
|
const auto type = check_volatile_wall(obj, hitseg, hitside);
|
||||||
|
if (type != volatile_wall_result::none)
|
||||||
|
{
|
||||||
vms_vector hit_dir;
|
vms_vector hit_dir;
|
||||||
|
|
||||||
if ((GameTime64 > Last_volatile_scrape_sound_time + F1_0/4) || (GameTime64 < Last_volatile_scrape_sound_time)) {
|
if ((GameTime64 > Last_volatile_scrape_sound_time + F1_0/4) || (GameTime64 < Last_volatile_scrape_sound_time)) {
|
||||||
int sound = (type==1)?SOUND_VOLATILE_WALL_HISS:SOUND_SHIP_IN_WATER;
|
|
||||||
|
|
||||||
Last_volatile_scrape_sound_time = GameTime64;
|
Last_volatile_scrape_sound_time = GameTime64;
|
||||||
|
const auto sound = (type == volatile_wall_result::lava) ? SOUND_VOLATILE_WALL_HISS : SOUND_SHIP_IN_WATER;
|
||||||
multi_digi_link_sound_to_pos(sound, hitseg, 0, hitpt, 0, F1_0);
|
multi_digi_link_sound_to_pos(sound, hitseg, 0, hitpt, 0, F1_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1745,30 +1745,39 @@ static void object_move_one(const vobjptridx_t obj)
|
||||||
}
|
}
|
||||||
#if defined(DXX_BUILD_DESCENT_II)
|
#if defined(DXX_BUILD_DESCENT_II)
|
||||||
{
|
{
|
||||||
int sidemask,under_lavafall=0;
|
bool under_lavafall = false;
|
||||||
static int lavafall_hiss_playing[MAX_PLAYERS]={0};
|
static array<bool, MAX_PLAYERS> lavafall_hiss_playing;
|
||||||
|
|
||||||
sidemask = get_seg_masks(obj->pos, vcsegptr(obj->segnum), obj->size).sidemask;
|
auto &playing = lavafall_hiss_playing[get_player_id(obj)];
|
||||||
if (sidemask) {
|
const auto &&segp = vcsegptr(obj->segnum);
|
||||||
int sidenum,bit,wall_num;
|
if (const auto sidemask = get_seg_masks(obj->pos, segp, obj->size).sidemask)
|
||||||
|
{
|
||||||
for (sidenum=0,bit=1;sidenum<6;bit<<=1,sidenum++)
|
for (unsigned sidenum = 0; sidenum != MAX_SIDES_PER_SEGMENT; ++sidenum)
|
||||||
if ((sidemask & bit) && ((wall_num=Segments[obj->segnum].sides[sidenum].wall_num)!=-1) && Walls[wall_num].type==WALL_ILLUSION) {
|
{
|
||||||
int type;
|
if (!(sidemask & (1 << sidenum)))
|
||||||
if ((type=check_volatile_wall(obj,vsegptridx(obj->segnum),sidenum))!=0) {
|
continue;
|
||||||
int sound = (type==1)?SOUND_LAVAFALL_HISS:SOUND_SHIP_IN_WATERFALL;
|
const auto wall_num = segp->sides[sidenum].wall_num;
|
||||||
|
if (wall_num != wall_none && Walls[wall_num].type == WALL_ILLUSION)
|
||||||
|
{
|
||||||
|
const auto type = check_volatile_wall(obj, segp, sidenum);
|
||||||
|
if (type != volatile_wall_result::none)
|
||||||
|
{
|
||||||
under_lavafall = 1;
|
under_lavafall = 1;
|
||||||
if (!lavafall_hiss_playing[get_player_id(obj)])
|
if (!playing)
|
||||||
{
|
{
|
||||||
lavafall_hiss_playing[get_player_id(obj)] = 1;
|
playing = 1;
|
||||||
|
const auto sound = (type == volatile_wall_result::lava) ? SOUND_LAVAFALL_HISS : SOUND_SHIP_IN_WATERFALL;
|
||||||
digi_link_sound_to_object3( sound, obj, 1, F1_0, vm_distance{i2f(256)}, -1, -1);
|
digi_link_sound_to_object3( sound, obj, 1, F1_0, vm_distance{i2f(256)}, -1, -1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!under_lavafall && lavafall_hiss_playing[get_player_id(obj)]) {
|
if (!under_lavafall && playing)
|
||||||
lavafall_hiss_playing[get_player_id(obj)] = 0;
|
{
|
||||||
|
playing = 0;
|
||||||
digi_kill_sound_linked_to_object( obj);
|
digi_kill_sound_linked_to_object( obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue