diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 22b676816..f672c4168 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -156,7 +156,7 @@ bool isanunderoperator(int lotag); int setanimation(int animsect, int animtype, int animindex, int thegoal, int thevel); void dofurniture(int wallNum, int sectnum, int playerNum); void dotorch(); -int hitawall(struct player_struct* pl, int* hitWall); +int hitawall(struct player_struct* pl, walltype** hitWall); int hits(DDukeActor* snum); DDukeActor* LocateTheLocator(int n, int sectnum); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 1ca12aa8a..c910d518e 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -211,14 +211,12 @@ int hitasprite(DDukeActor* actor, DDukeActor** hitsp) // //--------------------------------------------------------------------------- -int hitawall(struct player_struct* p, int* hitw) +int hitawall(struct player_struct* p, walltype** hitw) { int sx, sy, sz; - int hitw1; - hitscanw(p->pos.x, p->pos.y, p->pos.z, p->cursectnum, - p->angle.ang.bcos(), p->angle.ang.bsin(), 0, nullptr, &hitw1, nullptr, &sx, &sy, &sz, CLIPMASK0); - *hitw = hitw1; + hitscan(p->pos.x, p->pos.y, p->pos.z, p->cursectnum, + p->angle.ang.bcos(), p->angle.ang.bsin(), 0, nullptr, hitw, nullptr, &sx, &sy, &sz, CLIPMASK0); return (FindDistance2D(sx - p->pos.x, sy - p->pos.y)); } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 3a676af9a..068bcd437 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1496,7 +1496,8 @@ void checksectors_d(int snum) { int i = -1, oldz; struct player_struct* p; - int j, hitscanwall; + int j; + walltype* hitscanwall; int neartagsector, neartagwall; DDukeActor* neartagsprite; int neartaghitdist; @@ -1567,21 +1568,20 @@ void checksectors_d(int snum) neartagsprite = nullptr; p->toggle_key_flag = 1; - hitscanwall = -1; + hitscanwall = nullptr; i = hitawall(p, &hitscanwall); - if (hitscanwall >= 0) + if (hitscanwall != nullptr) { - auto hitwal = &wall[hitscanwall]; - if (i < 1280 && hitwal->overpicnum == MIRROR) - if (hitwal->lotag > 0 && S_CheckSoundPlaying(hitwal->lotag) == 0 && snum == screenpeek) + if (i < 1280 && hitscanwall->overpicnum == MIRROR) + if (hitscanwall->lotag > 0 && S_CheckSoundPlaying(hitscanwall->lotag) == 0 && snum == screenpeek) { - S_PlayActorSound(hitwal->lotag, pact); + S_PlayActorSound(hitscanwall->lotag, pact); return; } - if (hitscanwall >= 0 && (hitwal->cstat & 16)) - if (hitwal->lotag) + if (hitscanwall != nullptr && (hitscanwall->cstat & 16)) + if (hitscanwall->lotag) return; } if (p->newOwner != nullptr) @@ -1673,9 +1673,10 @@ void checksectors_d(int snum) return; case NUKEBUTTON: - - hitawall(p, &j); - if (j >= 0 && wall[j].overpicnum == 0) + { + walltype* wal; + hitawall(p, &wal); + if (wal != nullptr && wal->overpicnum == 0) if (neartagsprite->temp_data[0] == 0) { neartagsprite->temp_data[0] = 1; @@ -1686,6 +1687,7 @@ void checksectors_d(int snum) else ud.secretlevel = 0; } return; + } case WATERFOUNTAIN: if (neartagsprite->temp_data[0] != 1) { @@ -1771,9 +1773,10 @@ void checksectors_d(int snum) if (neartagwall >= 0) { - if (wall[neartagwall].lotag > 0 && fi.isadoorwall(wall[neartagwall].picnum)) + auto ntwall = &wall[neartagwall]; + if (ntwall->lotag > 0 && fi.isadoorwall(ntwall->picnum)) { - if (hitscanwall == neartagwall || hitscanwall == -1) + if (hitscanwall == ntwall || hitscanwall == nullptr) fi.checkhitswitch(snum, neartagwall, nullptr); return; } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 5d6c89380..6d7fc919b 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2446,7 +2446,7 @@ void checksectors_r(int snum) { int oldz; struct player_struct* p; - int hitscanwall; + walltype* hitscanwall; int neartagsector, neartagwall; DDukeActor* neartagsprite; int neartaghitdist; @@ -2502,16 +2502,15 @@ void checksectors_r(int snum) { neartagsprite = nullptr; p->toggle_key_flag = 1; - hitscanwall = -1; + hitscanwall = nullptr; hitawall(p, &hitscanwall); - if (hitscanwall >= 0) + if (hitscanwall != nullptr) { - auto hitwal = &wall[hitscanwall]; if (isRRRA()) { - if (hitwal->overpicnum == MIRROR && snum == screenpeek) + if (hitscanwall->overpicnum == MIRROR && snum == screenpeek) if (numplayers == 1) { if (S_CheckActorSoundPlaying(pact, 27) == 0 && S_CheckActorSoundPlaying(pact, 28) == 0 && S_CheckActorSoundPlaying(pact, 29) == 0 @@ -2534,16 +2533,16 @@ void checksectors_r(int snum) } else { - if (hitwal->overpicnum == MIRROR) - if (hitwal->lotag > 0 && S_CheckActorSoundPlaying(pact, hitwal->lotag) == 0 && snum == screenpeek) + if (hitscanwall->overpicnum == MIRROR) + if (hitscanwall->lotag > 0 && S_CheckActorSoundPlaying(pact, hitscanwall->lotag) == 0 && snum == screenpeek) { - S_PlayActorSound(hitwal->lotag, pact); + S_PlayActorSound(hitscanwall->lotag, pact); return; } } - if ((hitwal->cstat & 16)) - if (hitwal->lotag) + if ((hitscanwall->cstat & 16)) + if (hitscanwall->lotag) return; } @@ -2736,9 +2735,10 @@ void checksectors_r(int snum) if (neartagwall >= 0) { - if (wall[neartagwall].lotag > 0 && fi.isadoorwall(wall[neartagwall].picnum)) + auto ntwall = &wall[neartagwall]; + if (ntwall->lotag > 0 && fi.isadoorwall(ntwall->picnum)) { - if (hitscanwall == neartagwall || hitscanwall == -1) + if (hitscanwall == ntwall || hitscanwall == nullptr) fi.checkhitswitch(snum, neartagwall, nullptr); return; }