From 7e29be75691f7632fd099e94c4a2380f371f1e4f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Oct 2020 07:22:44 +0200 Subject: [PATCH] - switched checkhitwall interface to actors. --- source/games/duke/src/actors_d.cpp | 8 ++--- source/games/duke/src/actors_r.cpp | 6 ++-- source/games/duke/src/dispatch.cpp | 4 +-- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/funct.h | 2 +- source/games/duke/src/player_d.cpp | 8 ++--- source/games/duke/src/player_r.cpp | 6 ++-- source/games/duke/src/sectors.cpp | 2 +- source/games/duke/src/sectors_d.cpp | 54 ++++++++++++++++------------- source/games/duke/src/sectors_r.cpp | 31 ++++++++++------- 10 files changed, 67 insertions(+), 56 deletions(-) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 878b18aed..41b78ee56 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -388,7 +388,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1; updatesector(x1, y1, §); if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum)) - fi.checkhitwall(actor->GetIndex(), x, wal->x, wal->y, spri->z, spri->picnum); + fi.checkhitwall(actor, x, wal->x, wal->y, spri->z, spri->picnum); } } while (sectcnt < sectend); } @@ -1691,7 +1691,7 @@ static bool weaponhitwall(DDukeActor *proj, int j, const vec3_t &oldpos) else { setsprite(proj, oldpos); - fi.checkhitwall(proj->GetIndex(), j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(proj, j, s->x, s->y, s->z, s->picnum); if (s->picnum == FREEZEBLAST) { @@ -2809,7 +2809,7 @@ static void flamethrowerflame(DDukeActor *actor) else if (coll.type == kHitWall) { setsprite(actor, dax, day, daz); - fi.checkhitwall(actor->GetIndex(), coll.index, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(actor, coll.index, s->x, s->y, s->z, s->picnum); } else if (coll.type == kHitSector) { @@ -2939,7 +2939,7 @@ static void heavyhbomb(DDukeActor *actor) if (coll.type== kHitWall) { int j = coll.index; - fi.checkhitwall(actor->GetIndex(), j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(actor, j, s->x, s->y, s->z, s->picnum); int k = getangle( wall[wall[j].point2].x - wall[j].x, diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 21ec55cc4..16d5fc616 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -267,7 +267,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1; updatesector(x1, y1, §); if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum)) - fi.checkhitwall(actor->GetIndex(), x, wal->x, wal->y, spri->z, spri->picnum); + fi.checkhitwall(actor, x, wal->x, wal->y, spri->z, spri->picnum); } } while (sectcnt < sectend); @@ -1249,7 +1249,7 @@ static bool weaponhitwall(DDukeActor *proj, int wal, const vec3_t& oldpos) else { setsprite(proj, oldpos); - fi.checkhitwall(proj->GetIndex(), wal, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(proj, wal, s->x, s->y, s->z, s->picnum); if (!isRRRA() && s->picnum == FREEZEBLAST) { @@ -2650,7 +2650,7 @@ static void heavyhbomb(DDukeActor *actor) if (coll.type == kHitWall) { int j = coll.index; - fi.checkhitwall(actor->GetIndex(), j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(actor, j, s->x, s->y, s->z, s->picnum); int k = getangle( wall[wall[j].point2].x - wall[j].x, diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 0e61eeb43..9ef693690 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -47,8 +47,8 @@ bool checkhitswitch_d(int snum, int w, int switchtype); bool checkhitswitch_r(int snum, int w, int switchtype); void activatebysector_d(int sect, int j); void activatebysector_r(int sect, int j); -void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith); -void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith); +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); diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 3272714f7..d527a2ddb 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -78,7 +78,7 @@ struct Dispatcher void (*operateforcefields)(int s, int low); bool (*checkhitswitch)(int snum, int w, int switchtype); void (*activatebysector)(int sect, int j); - void (*checkhitwall)(int spr, int dawallnum, int x, int y, int z, int atwith); + 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); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index db52d2bda..ed51d86c4 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -137,7 +137,7 @@ int madenoise(int playerNum); int haskey(int sect, int snum); void shootbloodsplat(DDukeActor* i, int p, int sx, int sy, int sz, int sa, int atwith, int BIGFORCE, int OOZFILTER, int NEWBEAST); -void breakwall(short newpn, short spr, short dawallnum); +void breakwall(short newpn, DDukeActor* spr, short dawallnum); int callsound(int sectnum,DDukeActor* snum); int hitasprite(DDukeActor* snum,DDukeActor **hitSprite); int findplayer(const DDukeActor* s, int* dist); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 07581a60d..2f99bde41 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -289,7 +289,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { - fi.checkhitwall(knee->GetIndex(), hitwall, hitx, hity, hitz, KNEE); + fi.checkhitwall(knee, hitwall, hitx, hity, hitz, KNEE); if (p >= 0) fi.checkhitswitch(p, hitwall, 0); } } @@ -526,7 +526,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa if (hitz >= (sector[wall[hitwall].nextsector].floorz)) hitwall = wall[hitwall].nextwall; - fi.checkhitwall(spark->GetIndex(), hitwall, hitx, hity, hitz, SHOTSPARK1); + fi.checkhitwall(spark, hitwall, hitx, hity, hitz, SHOTSPARK1); } } else @@ -542,7 +542,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa else spark->s.xrepeat = spark->s.yrepeat = 0; } else if (hitwall >= 0) - fi.checkhitwall(spark->GetIndex(), hitwall, hitx, hity, hitz, SHOTSPARK1); + fi.checkhitwall(spark, hitwall, hitx, hity, hitz, SHOTSPARK1); } if ((krand() & 255) < 4) @@ -983,7 +983,7 @@ static void shootgrowspark(DDukeActor* actor, int p, int sx, int sy, int sz, int else if (hitsprt != nullptr) fi.checkhitsprite(hitsprt, spark); else if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { - fi.checkhitwall(spark->GetIndex(), hitwall, hitx, hity, hitz, GROWSPARK); + fi.checkhitwall(spark, hitwall, hitx, hity, hitz, GROWSPARK); } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 08231072c..8aff92b70 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -186,7 +186,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { - fi.checkhitwall(wpn->GetIndex(), hitwall, hitx, hity, hitz, atwith); + fi.checkhitwall(wpn, hitwall, hitx, hity, hitz, atwith); if (p >= 0) fi.checkhitswitch(p, hitwall, 0); } } @@ -431,7 +431,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa if (hitz >= (sector[wall[hitwall].nextsector].floorz)) hitwall = wall[hitwall].nextwall; - fi.checkhitwall(spark->GetIndex(), hitwall, hitx, hity, hitz, SHOTSPARK1); + fi.checkhitwall(spark, hitwall, hitx, hity, hitz, SHOTSPARK1); } } else @@ -447,7 +447,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa else spark->s.xrepeat = spark->s.yrepeat = 0; } else if (hitwall >= 0) - fi.checkhitwall(spark->GetIndex(), hitwall, hitx, hity, hitz, SHOTSPARK1); + fi.checkhitwall(spark, hitwall, hitx, hity, hitz, SHOTSPARK1); } if ((krand() & 255) < 10) diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 00f14fc47..ef4e25238 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -1205,7 +1205,7 @@ void operateforcefields_common(DDukeActor *effector, int low, const std::initial // //--------------------------------------------------------------------------- -void breakwall(short newpn, short spr, short dawallnum) +void breakwall(short newpn, DDukeActor* spr, short dawallnum) { wall[dawallnum].picnum = newpn; S_PlayActorSound(VENT_BUST, spr); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 4d7de5a92..bacc68d57 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -639,9 +639,9 @@ void activatebysector_d(int sect, int j) // //--------------------------------------------------------------------------- -void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) +void checkhitwall_d(DDukeActor* spr, int dawallnum, int x, int y, int z, int atwith) { - short j, i, sn = -1, darkestwall; + short j, sn = -1, darkestwall; walltype* wal; wal = &wall[dawallnum]; @@ -675,26 +675,26 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) case W_FORCEFIELD + 2: wal->extra = 1; // tell the forces to animate case BIGFORCE: + { updatesector(x, y, &sn); if (sn < 0) return; - + DDukeActor* spawned; if (atwith == -1) - i = EGS(sn, x, y, z, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); + spawned = EGS(sn, x, y, z, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); else { if (atwith == CHAINGUN) - i = EGS(sn, x, y, z, FORCERIPPLE, -127, 16 + sprite[spr].xrepeat, 16 + sprite[spr].yrepeat, 0, 0, 0, spr, 5); - else i = EGS(sn, x, y, z, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); + spawned = EGS(sn, x, y, z, FORCERIPPLE, -127, 16 + spr->s.xrepeat, 16 + spr->s.yrepeat, 0, 0, 0, spr, 5); + else spawned = EGS(sn, x, y, z, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); } - sprite[i].cstat |= 18 + 128; - sprite[i].ang = getangle(wal->x - wall[wal->point2].x, - wal->y - wall[wal->point2].y) - 512; + spawned->s.cstat |= 18 + 128; + spawned->s.ang = getangle(wal->x - wall[wal->point2].x, wal->y - wall[wal->point2].y) - 512; - S_PlayActorSound(SOMETHINGHITFORCE, i); + S_PlayActorSound(SOMETHINGHITFORCE, spawned); return; - + } case FANSPRITE: wal->overpicnum = FANSPRITEBROKE; wal->cstat &= 65535 - 65; @@ -708,6 +708,7 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) return; case GLASS: + { updatesector(x, y, &sn); if (sn < 0) return; wal->overpicnum = GLASS2; lotsofglass(spr, dawallnum, 10); @@ -716,13 +717,16 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; - i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); - sprite[i].lotag = 128; hittype[i].temp_data[1] = 5; hittype[i].temp_data[2] = dawallnum; - S_PlayActorSound(GLASS_BREAKING, i); + auto spawned = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); + spawned->s.lotag = 128; + spawned->temp_data[1] = 5; + spawned->temp_data[2] = dawallnum; + S_PlayActorSound(GLASS_BREAKING, spawned); return; + } case STAINGLASS1: updatesector(x, y, &sn); if (sn < 0) return; - lotsofcolourglass(spr, dawallnum, 80); + lotsofcolourglass(spr->GetIndex(), dawallnum, 80); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; @@ -816,7 +820,7 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) case ATM: wal->picnum = ATMBROKE; - fi.lotsofmoney(&hittype[spr], 1 + (krand() & 7)); + fi.lotsofmoney(spr, 1 + (krand() & 7)); S_PlayActorSound(GLASS_HEAVYBREAK, spr); break; @@ -857,19 +861,19 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) darkestwall = 0; wal = &wall[sector[sn].wallptr]; - for (i = sector[sn].wallnum; i > 0; i--, wal++) + for (int i = sector[sn].wallnum; i > 0; i--, wal++) if (wal->shade > darkestwall) darkestwall = wal->shade; j = krand() & 1; - StatIterator it(STAT_EFFECTOR); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_EFFECTOR); + while (auto effector = it.Next()) { - if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) + if (effector->s.hitag == wall[dawallnum].lotag && effector->s.lotag == 3) { - hittype[i].temp_data[2] = j; - hittype[i].temp_data[3] = darkestwall; - hittype[i].temp_data[4] = 1; + effector->temp_data[2] = j; + effector->temp_data[3] = darkestwall; + effector->temp_data[4] = 1; } } break; @@ -921,7 +925,7 @@ void checkplayerhurt_d(struct player_struct* p, int j) p->posyv = -(sintable[(p->angle.ang.asbuild()) & 2047] << 8); S_PlayActorSound(DUKE_LONGTERM_PAIN, p->i); - fi.checkhitwall(p->i, j, + fi.checkhitwall(p->GetActor(), j, p->posx + (sintable[(p->angle.ang.asbuild() + 512) & 2047] >> 9), p->posy + (sintable[p->angle.ang.asbuild() & 2047] >> 9), p->posz, -1); @@ -930,7 +934,7 @@ void checkplayerhurt_d(struct player_struct* p, int j) case BIGFORCE: p->hurt_delay = 26; - fi.checkhitwall(p->i, j, + fi.checkhitwall(p->GetActor(), j, p->posx + (sintable[(p->angle.ang.asbuild() + 512) & 2047] >> 9), p->posy + (sintable[p->angle.ang.asbuild() & 2047] >> 9), p->posz, -1); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index e6be24bb8..348a17792 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -971,7 +971,7 @@ static void lotsofpopcorn(short i, short wallnum, short n) // //--------------------------------------------------------------------------- -void checkhitwall_r(int 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) { short j, i, sn = -1, darkestwall; walltype* wal; @@ -1018,20 +1018,24 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) return; case RRTILE1973: + { updatesector(x, y, &sn); if (sn < 0) return; wal->overpicnum = GLASS2; - lotsofpopcorn(spr, dawallnum, 64); + lotsofpopcorn(spr->GetIndex(), dawallnum, 64); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; - i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); - sprite[i].lotag = 128; hittype[i].temp_data[1] = 2; hittype[i].temp_data[2] = dawallnum; - S_PlayActorSound(GLASS_BREAKING, i); + auto spawned = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); + spawned->s.lotag = 128; + spawned->temp_data[1] = 2; + spawned->temp_data[2] = dawallnum; + S_PlayActorSound(GLASS_BREAKING, spawned); return; - + } case GLASS: + { updatesector(x, y, &sn); if (sn < 0) return; wal->overpicnum = GLASS2; lotsofglass(spr, dawallnum, 10); @@ -1040,13 +1044,16 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; - i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); - sprite[i].lotag = 128; hittype[i].temp_data[1] = 2; hittype[i].temp_data[2] = dawallnum; - S_PlayActorSound(GLASS_BREAKING, i); + auto spawned = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); + spawned->s.lotag = 128; + spawned->temp_data[1] = 2; + spawned->temp_data[2] = dawallnum; + S_PlayActorSound(GLASS_BREAKING, spawned); return; + } case STAINGLASS1: updatesector(x, y, &sn); if (sn < 0) return; - lotsofcolourglass(spr, dawallnum, 80); + lotsofcolourglass(spr->GetIndex(), dawallnum, 80); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; @@ -1245,7 +1252,7 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) case ATM: wal->picnum = ATMBROKE; - fi.lotsofmoney(&hittype[spr], 1 + (krand() & 7)); + fi.lotsofmoney(spr, 1 + (krand() & 7)); S_PlayActorSound(GLASS_HEAVYBREAK, spr); break; @@ -1407,7 +1414,7 @@ void checkplayerhurt_r(struct player_struct* p, int j) { case BIGFORCE: p->hurt_delay = 26; - fi.checkhitwall(p->i, j, + fi.checkhitwall(p->GetActor(), j, p->posx + (sintable[(p->angle.ang.asbuild() + 512) & 2047] >> 9), p->posy + (sintable[p->angle.ang.asbuild() & 2047] >> 9), p->posz, -1);