From 87e8801531f044050a73a094f4d924cfdf38d5ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Oct 2020 08:50:03 +0100 Subject: [PATCH] - handle the clipmove result in processinput. --- source/games/duke/src/dispatch.cpp | 4 --- source/games/duke/src/duke3d.h | 1 - source/games/duke/src/funct.h | 2 ++ source/games/duke/src/player_d.cpp | 14 ++++---- source/games/duke/src/player_r.cpp | 53 ++++++++++++++--------------- source/games/duke/src/sectors_d.cpp | 16 ++++----- source/games/duke/src/sectors_r.cpp | 14 ++++---- 7 files changed, 48 insertions(+), 56 deletions(-) diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 9d5b671ef..4e756c763 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -49,8 +49,6 @@ void activatebysector_d(int sect, int j); void activatebysector_r(int sect, int j); void checkhitwall_d(DDukeActor* spr, int dawallnum, int x, int y, int z, int atwith); void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atwith); -void checkplayerhurt_d(struct player_struct* p, int j); -void checkplayerhurt_r(struct player_struct* p, int j); bool checkhitceiling_d(int sn); bool checkhitceiling_r(int sn); void checkhitsprite_d(DDukeActor* i, DDukeActor* sn); @@ -137,7 +135,6 @@ void SetDispatcher() checkhitswitch_d, activatebysector_d, checkhitwall_d, - checkplayerhurt_d, checkhitceiling_d, checkhitsprite_d, checksectors_d, @@ -187,7 +184,6 @@ void SetDispatcher() checkhitswitch_r, activatebysector_r, checkhitwall_r, - checkplayerhurt_r, checkhitceiling_r, checkhitsprite_r, checksectors_r, diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 499cba76b..03e88cd8b 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -79,7 +79,6 @@ struct Dispatcher bool (*checkhitswitch)(int snum, int w, int switchtype); void (*activatebysector)(int sect, int j); void (*checkhitwall)(DDukeActor* spr, int dawallnum, int x, int y, int z, int atwith); - void (*checkplayerhurt)(struct player_struct* p, int j); bool (*checkhitceiling)(int sn); void (*checkhitsprite)(DDukeActor* i, DDukeActor* sn); void (*checksectors)(int low); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index ccd8c2f4f..6c9fd7639 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -180,6 +180,8 @@ void ceilingglass(int snum, int sectnum, int cnt); void spriteglass(DDukeActor* snum, int cnt); void lotsofcolourglass(int snum, int wallNum, int cnt); void lotsofglass(int snum, int wallnum, int cnt); +void checkplayerhurt_d(struct player_struct* p, const Collision& coll); +void checkplayerhurt_r(struct player_struct* p, const Collision& coll); void addspritetodelete(int spnum=0); void checkavailinven(struct player_struct* p); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 2890c0cf5..0cc30fd78 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -3024,24 +3024,24 @@ HORIZONLY: if (sector[p->cursectnum].lotag == 2) k = 0; else k = 1; + Collision clip{}; if (ud.clipping) { - j = 0; p->posx += p->posxv >> 14; p->posy += p->posyv >> 14; updatesector(p->posx, p->posy, &p->cursectnum); changespritesect(pi, p->cursectnum); } else - j = clipmove(&p->posx, &p->posy, + clipmove_ex(&p->posx, &p->posy, &p->posz, &p->cursectnum, - p->posxv, p->posyv, 164L, (4L << 8), i, CLIPMASK0); + p->posxv, p->posyv, 164L, (4L << 8), i, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) p->posz += 32 << 8; - if (j) - fi.checkplayerhurt(p, j); + if (clip.type != kHitNone) + checkplayerhurt_d(p, clip); if (p->jetpack_on == 0) { @@ -3077,8 +3077,8 @@ HORIZONLY: } if (truefdist < PHEIGHT && p->on_ground && psectlotag != 1 && shrunk == 0 && sector[p->cursectnum].lotag == 1) - if (!S_CheckActorSoundPlaying(pi, DUKE_ONWATER)) - S_PlayActorSound(DUKE_ONWATER, pi); + if (!S_CheckActorSoundPlaying(pact, DUKE_ONWATER)) + S_PlayActorSound(DUKE_ONWATER, pact); if (p->cursectnum != s->sectnum) changespritesect(pi, p->cursectnum); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index ecb42a464..88b5fae99 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3915,7 +3915,6 @@ HORIZONLY: else k = 1; Collision clip{}; - int j; if (ud.clipping) { p->posx += p->posxv >> 14; @@ -3924,38 +3923,38 @@ HORIZONLY: changespritesect(pact, p->cursectnum); } else - clipmove(&p->posx, &p->posy, + clipmove_ex(&p->posx, &p->posy, &p->posz, &p->cursectnum, - p->posxv, p->posyv, 164L, (4L << 8), i, CLIPMASK0);//, clip); + p->posxv, p->posyv, 164L, (4L << 8), i, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) p->posz += 32 << 8; - if (j) - fi.checkplayerhurt(p, j); + if (clip.type != kHitNone) + checkplayerhurt_r(p, clip); else if (isRRRA() && p->hurt_delay2 > 0) p->hurt_delay2--; - if ((j & 49152) == 32768) + if (clip.type == kHitWall) { - int var60 = wall[j & (MAXWALLS - 1)].lotag; + int var60 = wall[clip.index].lotag; if (p->OnMotorcycle) { - onMotorcycleMove(snum, psect, j & (MAXWALLS-1)); + onMotorcycleMove(snum, psect, clip.index); } else if (p->OnBoat) { - onBoatMove(snum, psect, j& (MAXWALLS - 1)); + onBoatMove(snum, psect, clip.index); } else { - if (wall[j & (MAXWALLS - 1)].lotag >= 40 && wall[j & (MAXWALLS - 1)].lotag <= 44) + if (wall[clip.index].lotag >= 40 && wall[clip.index].lotag <= 44) { - if (wall[j & (MAXWALLS - 1)].lotag < 44) + if (wall[clip.index].lotag < 44) { - dofurniture(j & (MAXWALLS - 1), p->cursectnum, snum); + dofurniture(clip.index, p->cursectnum, snum); pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); } else @@ -3964,41 +3963,40 @@ HORIZONLY: } } - if ((j & 49152) == 49152) + if (clip.type == kHitSprite) { - int var60 = j & (MAXSPRITES - 1); if (p->OnMotorcycle) { - onMotorcycleHit(snum, &hittype[var60]); + onMotorcycleHit(snum, clip.actor); } else if (p->OnBoat) { - onBoatHit(snum, &hittype[var60]); + onBoatHit(snum, clip.actor); } else - if (badguy(&sprite[var60])) + if (badguy(clip.actor)) { - if (sprite[var60].statnum != 1) + if (clip.actor->s.statnum != 1) { - hittype[var60].timetosleep = 0; - if (sprite[var60].picnum == BILLYRAY) - S_PlayActorSound(404, var60); + clip.actor->timetosleep = 0; + if (clip.actor->s.picnum == BILLYRAY) + S_PlayActorSound(404, clip.actor); else - check_fta_sounds_r(&hittype[var60]); - changespritestat(var60, 1); + check_fta_sounds_r(clip.actor); + changespritestat(clip.actor, 1); } } else - if (sprite[var60].picnum == RRTILE3410) + if (clip.actor->s.picnum == RRTILE3410) { quickkill(p); S_PlayActorSound(446, pact); } - else if (isRRRA() && sprite[var60].picnum == RRTILE2443 && sprite[var60].pal == 19) + else if (isRRRA() && clip.actor->s.picnum == RRTILE2443 && clip.actor->s.pal == 19) { - sprite[var60].pal = 0; + clip.actor->s.pal = 0; p->DrugMode = 5; - sprite[ps[snum].i].extra = max_player_health; + ps[snum].GetActor()->s.extra = max_player_health; } } @@ -4050,6 +4048,7 @@ HORIZONLY: if (p->cursectnum != s->sectnum) changespritesect(pact, p->cursectnum); + int j; if (ud.clipping == 0) { if (s->clipdist == 64) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index d41ad0023..93df5a6a5 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -887,13 +887,11 @@ void checkhitwall_d(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw // //--------------------------------------------------------------------------- -void checkplayerhurt_d(struct player_struct* p, int j) +void checkplayerhurt_d(struct player_struct* p, const Collision& coll) { - if ((j & 49152) == 49152) + if (coll.type == kHitSprite) { - j &= (MAXSPRITES - 1); - - switch (sprite[j].picnum) + switch (coll.actor->s.picnum) { case CACTUS: if (p->hurt_delay < 8) @@ -901,15 +899,15 @@ void checkplayerhurt_d(struct player_struct* p, int j) p->GetActor()->s.extra -= 5; p->hurt_delay = 16; SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - S_PlayActorSound(DUKE_LONGTERM_PAIN, p->i); + S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); } break; } return; } - if ((j & 49152) != 32768) return; - j &= (MAXWALLS - 1); + if (coll.type != kHitWall) return; + int j = coll.index; if (p->hurt_delay > 0) p->hurt_delay--; else if (wall[j].cstat & 85) switch (wall[j].overpicnum) @@ -924,7 +922,7 @@ void checkplayerhurt_d(struct player_struct* p, int j) p->posxv = -(sintable[(p->angle.ang.asbuild() + 512) & 2047] << 8); p->posyv = -(sintable[(p->angle.ang.asbuild()) & 2047] << 8); - S_PlayActorSound(DUKE_LONGTERM_PAIN, p->i); + S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); fi.checkhitwall(p->GetActor(), j, p->posx + (sintable[(p->angle.ang.asbuild() + 512) & 2047] >> 9), diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 513413b78..d885a3949 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1371,13 +1371,11 @@ void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw // //--------------------------------------------------------------------------- -void checkplayerhurt_r(struct player_struct* p, int j) +void checkplayerhurt_r(struct player_struct* p, const Collision &coll) { - if ((j & 49152) == 49152) + if (coll.type == kHitSprite) { - j &= (MAXSPRITES - 1); - - switch (sprite[j].picnum) + switch (coll.actor->s.picnum) { case RRTILE2430: case RRTILE2431: @@ -1391,7 +1389,7 @@ void checkplayerhurt_r(struct player_struct* p, int j) p->GetActor()->s.extra -= 2; p->hurt_delay2 = 16; SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - S_PlayActorSound(DUKE_LONGTERM_PAIN, p->i); + S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); } break; case CACTUS: @@ -1407,8 +1405,8 @@ void checkplayerhurt_r(struct player_struct* p, int j) return; } - if ((j & 49152) != 32768) return; - j &= (MAXWALLS - 1); + if (coll.type != kHitWall) return; + int j = coll.index; if (p->hurt_delay > 0) p->hurt_delay--; else if (wall[j].cstat & 85) switch (wall[j].overpicnum)